Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Nat.Log

Polynomial-time logarithms and bounded powers #

The base-two logarithm is the binary representation's length minus one, with truncated subtraction handling zero. Unary input first uses the certified unary-to-binary conversion. Other fixed bases use repeated division with a linear bound on the encoded state. Ceiling logarithms follow from floor logarithms; raising a fixed factor to a ceiling logarithm uses the existing polynomial bound on logarithmically many multiplications. These latter certificates charge unary counter lengths; the bounded-power rule also accepts any caller's encoding with a certified unary size function.

Main results #

References #

The base-two logarithm is polynomial-time on binary naturals, with its result in unary.

The base-two logarithm is polynomial-time with both input and output in unary.

Fixed-base logarithms are polynomial-time on unary counters, including bases zero and one. The division loop maintains the logarithm identity and a linear bound on its complete state.

Ceiling logarithms in any fixed base are polynomial-time on unary counters.

theorem Turing.MultiTapeTM.ComputableTidilyInPolyTime.unary_pow_clog_const {α : Type} {input : α ↪ List Bool} {size : α → ℕ} (hsize : ComputableTidilyInPolyTime size input encUnary) (factor base : ℕ) :
ComputableTidilyInPolyTime (fun (x : α) => factor ^ Nat.clog base (size x)) input encUnary

Given an efficient unary size function, a fixed factor raised to its fixed-base ceiling logarithm has a polynomial-time unary output in the caller's original encoding. The bound charges every intermediate power, including the initial one when the factor is zero.

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_pow_clog_const {α : Type} {input : α ↪ List Bool} {size : α → ℕ} (hsize : ComputableInPolyTime size input encUnary) (factor base : ℕ) :
ComputableInPolyTime (fun (x : α) => factor ^ Nat.clog base (size x)) input encUnary

Turing.MultiTapeTM.ComputableTidilyInPolyTime.unary_pow_clog_const for plain certificates.