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 #
Turing.MultiTapeTM.ComputableInPolyTime.binary_clog_two: ceiling logarithm from binary input to unary output.Turing.MultiTapeTM.ComputableInPolyTime.binary_clog_two_nat,.binary_clog_two_nat': ceiling logarithm from binary input to binary output (encNattoencNat), and its compositional rule.Turing.MultiTapeTM.ComputableInPolyTime.unary_lt_two_pow': compare a computed unary natural against2 ^ Lfor a computed unary exponentLvia binary conversion andbinary_two_pow.
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).
Compute the base-two ceiling logarithm of a computed binary natural, returning a binary natural.
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.