Documentation

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

Polynomial-time binary ceiling logarithms #

The base-two ceiling logarithm of a binary natural is computed from its bit length and a comparison with the preceding power of two. The primary certificate returns its result in unary, with length at most the binary input length, and binary-output frontends convert that unary counter to Turing.MultiTapeTM.encNat. Zero and one both return zero. The ordinary polynomial-time certificates use the existing binary size, power, comparison and unary-to-binary providers; they never expand the input natural into a unary word.

Main results #

References #

Compute the base-two ceiling logarithm of a binary natural, returning a unary counter. The full input, intermediate power of two and output have polynomial bit cost.

Compute the base-two ceiling logarithm of a binary natural, returning a binary natural (encNat to encNat).

theorem Turing.MultiTapeTM.ComputableInPolyTime.binary_clog_two_nat' {α : Type} {input : α ↪ List Bool} {f : α → ℕ} (hf : ComputableInPolyTime f input encNat) :
ComputableInPolyTime (fun (a : α) => Nat.clog 2 (f a)) input encNat

Compute the base-two ceiling logarithm of a computed binary natural, returning a binary natural.

theorem Turing.MultiTapeTM.ComputableInPolyTime.unary_lt_two_pow' {γ : Type} {encIn : γ ↪ List Bool} {L j : γ → ℕ} (hL : ComputableInPolyTime L encIn encUnary) (hj : ComputableInPolyTime j encIn encUnary) :
ComputableInPolyTime (fun (a : γ) => decide (j a < 2 ^ L a)) encIn encBool

Compare a computed unary natural j a with 2 ^ L a for a computed unary exponent L a by converting j a to binary and computing 2 ^ L a in binary.