Machine emission of terminated-unary natural codes #
This module exposes a concrete consumer of the canonical binary count-up loop.
Starting with a zero scratch counter and a distinct preserved binary limit, the
machine emits one true bit per value below the limit, clears the scratch tape
back to canonical zero, and emits the terminating false bit.
The endpoint contracts preserve the complete input and work-tape frame and
append exactly NatCode.encode value. The space contract covers every
reachable configuration; output growth is uncharged because the machine also
satisfies the one-way-output transducer discipline.
Main results #
emitNatCodeLoopTM_reachesIn_framegives the exact unary-body loop run.emitNatCodeTM_hoareTimegives the restored-frame endpoint and time bound.emitNatCodeTM_hoareTimeSpaceadds an all-prefix auxiliary-space bound.emitNatCodeTM_isTransducerproves one-way-output safety.
The unary-body loop has an exact runtime and endpoint: it preserves the
input and every nonscratch work tape, leaves the scratch counter equal to the
limit, and appends exactly value one-bits.
Terminated-unary emission restores the scratch counter and the complete
external frame, then appends exactly NatCode.encode value within
emitNatCodeTime value steps.
Time-and-space form of emitNatCodeTM_hoareTime. The hypotheses state
that the initial input/work heads fit in initialSpace; every reachable
configuration then fits in emitNatCodeSpace initialSpace value.
Natural-code emission never moves its output head left.