RAM snapshot word-width decoder #
This module exposes the exact framed semantics of the first concrete snapshot
decoder phase. Starting on a self-delimiting word, wordWidthTM stops on its
zero separator and leaves the unary-prefix length as a canonical binary
natural on a separate work tape.
Rewind a decoded append-position target to cell one without changing its
binary contents or any framed tape. This converts HasBinaryPrefix into the
read-position convention HasBinaryString in at most |bits| + 3 steps.
Exact framed execution of unary-width decoding. The source begins at the first prefix bit, the width counter begins at canonical zero, and all unrelated tapes are preserved exactly.
Unary-width decoding is safe for one-way-output composition.
Exact one-step framed execution of the payload-copy leaf. It consumes one source bit, appends it to the target, and preserves every unrelated tape.
The one-bit payload copier never moves the output head left.
The separator phase consumes one zero and otherwise preserves the frame.
Exact framed execution of the bounded payload loop. The source begins on the first payload bit, the target is an empty appendable prefix, the counter is zero, and the preserved width tape equals the payload length. The machine copies the complete payload and leaves the source at the next encoded word.
The bounded payload loop preserves one-way-output safety.
Exact end-to-end decoding of one self-delimiting width/payload layout. The source is left at the next word and the target contains the complete payload as an appendable binary prefix.
Coarse all-prefix space envelope for complete word decoding. Starting from
auxiliary-space budget initialSpace, no prefix of the exact decoder run can
use more than initialSpace + wordDecodeTime width; this follows from the
one-cell-per-transition head-growth bound and is independent of endpoint
correctness.
A canonical WordCode.encode prefix decodes to the natural's canonical
little-endian bit string and leaves the following encoded stream untouched.
The existing checked decoder is quasi-linear in the decoded word width. This tightens the former quadratic charging by retaining the bit-width of the binary loop limit instead of replacing it by the limit's numeric value.
Complete word decoding preserves one-way-output safety.
Linear unary-marker decoder #
Exact framed execution of the optimized decoder. It uses one unary marker
instead of a binary width/counter pair and takes exactly 3 * width + 3
transitions.
The optimized decoder handles a canonical natural-number word in time linear in the encoded word width.
The optimized decoder never moves the output head left.