Output-emission subroutines #
Building blocks for machines that compute string functions (ComputesInTime):
the output tape is treated as an append-only accumulator, written left to
right. The central predicate OutAcc ys out says the output tape holds
exactly the bits ys (after the ▷ at cell 0) with the head parked on the
first blank, ready to append; emitters have Hoare specs of the shape
{OutAcc ys ∧ …} emit {OutAcc (ys ++ w) ∧ …}
which compose by seqTM along List.append associativity. The final bridge
to ComputesInTime is OutAcc.hasOutput.
This layer is the foundation for the Cook–Levin reduction emitter
(docs/A5-ReductionEmitter.md).
Main definitions #
TM.OutAcc— the output-accumulator predicateTM.bumpTM— entry adapter: bump every head from▷to cell 1TM.emitBitsTM— append a fixed word to the outputTM.emitUnaryTM— append a register's value as a doubled-unary runTM.emitLitTM— append one encoded literal (sign bits, unary body, terminator)
Main results #
TM.OutAcc.hasOutput— accumulated output isHasOutputTM.outAcc_append_bit— onewriteAndMove _ .rightextends the accumulatorTM.emitBitsTM_hoareTime—emitBitsTM wappendswin|w|steps, preserving the input and work tapes
Output accumulator. The output tape holds exactly the bits ys
(cells 1..|ys|, after the ▷ at cell 0), all cells beyond are blank,
and the head is parked on the first blank — ready to append.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Appending one bit. Writing Γ.ofBool b at the accumulator head and
moving right extends the accumulator by b.
Entry adapter: one step moving every head from ▷ (cell 0, the
initial configuration) to cell 1, establishing the parked discipline:
blank work tapes become zero registers and the blank output becomes the
empty accumulator.
Equations
- One or more equations did not get rendered due to their size.
Instances For
bumpTM Hoare specification. From the initial configuration's tapes,
one step establishes: parked input (cells intact), zero registers on all
work tapes, and the empty output accumulator.
Append the fixed word w to the output and halt. State k = number of
bits already emitted; each step writes bit k and moves the output head
right; input and work tapes are parked and untouched.
Equations
- One or more equations did not get rendered due to their size.
Instances For
emitBitsTM Hoare specification. Appends the word w to the output
accumulator in |w| steps, leaving the (parked) input and work tapes
literally unchanged. Ghost-parametrized by the initial tapes for
seqTM composition.
The states of emitUnaryTM: emitA/emitB alternate to emit two trues per
register mark, back rewinds the register head to ▷, park steps it to
cell 1, and done halts.
- emitA : EmitUnaryPhase
- emitB : EmitUnaryPhase
- back : EmitUnaryPhase
- park : EmitUnaryPhase
- done : EmitUnaryPhase
Instances For
EmitUnaryPhase is a finite type, as required for TM state spaces.
Equations
- One or more equations did not get rendered due to their size.
Append 2v trues to the output, where v is the value of register r
(the doubled-unary body doubleBits (Unary.encode v) of a literal's
variable index), restoring the register exactly. The head sweeps right
over the register's marks emitting two trues per mark (emitA/emitB),
then rewinds to cell 1 (back/park).
Equations
- One or more equations did not get rendered due to their size.
Instances For
emitUnaryTM Hoare specification. Appends 2v trues (the doubled
unary body of a literal with variable index v) to the output accumulator
in 3v + 3 steps, restoring all tapes exactly: the scanned register r
included.
The standard emit-spec shape: ghost-fixed input and work tapes, output
accumulator holding ys.
Equations
- Complexity.TM.EmitPred inp₀ work₀ ys inp work out = (inp = inp₀ ∧ work = work₀ ∧ Complexity.TM.OutAcc ys out)
Instances For
Emit-spec states pass through combinator phase boundaries unchanged:
parked ghosts and the accumulator are fixed points of
transitionTape / transitionInput. The h_trans obligation of
seqTM_hoareTime for any two composed emitters.
Append one encoded literal with sign s and variable index read from
register r: the bits [s, s] ++ (2v trues) ++ [false, true]
(= doubleBits (Lit.encodeRaw ⟨s, v⟩) ++ [false, true], the form literals
take inside Clause.encode).
Equations
Instances For
emitLitTM Hoare specification. Appends the encoded literal in
3v + 9 steps, preserving the input and work tapes (the scanned register
included). The first seqTM-composed emitter spec; later emitters chain
the same way.