Binary input-length counter #
This module exposes a read-only input scan that counts every Boolean input symbol in canonical little-endian binary on one designated work tape. The machine preserves input cells; output and unrelated work tapes remain blank and finish with their heads initialized at cell one.
The resource contracts are deliberately separate: the runtime theorem gives
an n · size(n)-shaped bound, while the all-reachable auxiliary-space proof
reuses the local successor bound at each iteration and is formally O(log n).
Main results #
TM.binaryLengthTM_reachesIn_frame— exact endpoint and complete tape frame.TM.binaryLengthTM_hoareTimeSpace— time-bounded and all-reachable space contract.TM.binaryLengthSpace_bigO_log— the explicit space budget is logarithmic.TM.Experimental.binaryLengthRoutine_transducerSafe— the experimental routine is structurally output-safe.TM.binaryLengthTM_isTransducer— the output head never moves left.
The exact binary-length-counter runtime has a concrete O(n log n)-shaped
upper bound.
The explicit all-reachable auxiliary-space budget is logarithmic.
From fresh tapes, the machine halts after exactly binaryLengthTime
transitions with the canonical binary input length on counterIdx. Input
cells are preserved exactly; output and unrelated work tapes remain blank and
finish with their heads at cell one.
Fresh-start time-bounded Hoare contract for binary length counting.
Time-bounded and honest all-reachable auxiliary-space contract. In particular, this does not derive space from the total runtime.
Binary length counting is assembled only from transducer-safe routine constructors and calls.
binaryLengthTM is safe for append-only-output composition.