Single-tape simulation — simulator state type #
The state type SimQ k Q of NTM.singleTapeSim (for a source machine with
state type Q and k work tapes) and its Fintype/DecidableEq instances.
See docs/A4-SingleTapeSimulation.md §4–5 for the phase semantics.
The instances are noncomputable by design: singleTapeSim is a
noncomputable def, and synthesizing computable DecidableEq for the
function-typed phase data (Fin k → Γ, Fin k → Γw × Dir3) hits Lean's
product/Pi synthesis-size limit. Finite is a Prop and composes with no
such limit, so we route through it (Fintype.ofFinite / Classical.decEq).
A sweep position: which tape's triple (Fin k) and which of its 3 cells
(head-bit / sym-hi / sym-lo, as Fin 3). The tape index is Fin (k+1) — a
finite type (so the state stays Finite) whose 0 is constructible even
when k = 0; the slack index k is unused in normal sweeps, and updates
into Fin k-indexed data are guarded by if h : t.val < k.
Instances For
GATHER-phase data: the simulated state q, the head symbols accumulated so
far (acc), the input/output symbols read at macro-step start (kept for the
δ computation and the ▷-dodge), the current sweep position, a flag for
whether the current tape's head marker was seen in this triple, and the
pending high symbol cell read.
Equations
Instances For
REWIND-phase data (between GATHER and SCATTER): the next state q', the δ
results carried leftward back to cell 1 — per-tape write+move action, the
deferred output write/dir, input dir, original input/output symbols — and the
initial rightCarry marking heads that were at position 0 (acc = ▷, forced
right off ▷), whose new marker must be deposited at block 1 by SCATTER.
Equations
- One or more equations did not get rendered due to their size.
Instances For
SCATTER sweep-1 data (rightward: write new symbols, place stay/right markers,
materialize): the carried δ results, the sweep position, the per-tape
rightCarry (markers to deposit at the next block), isLeftMover (recorded
for sweep 2), and a writeFlag (currently overwriting a head's symbol).
Equations
- One or more equations did not get rendered due to their size.
Instances For
SCATTER sweep-2 data (leftward: deposit left-movers, rewind to cell 1): the
deferred commit info, the sweep position, the isLeftMover set (from sweep
- and the per-tape
leftCarry(markers to deposit at the next-left block).
Equations
- One or more equations did not get rendered due to their size.
Instances For
COMMIT-phase data: the next simulated state and the deferred input/output actions (output write+dir, input dir) with the symbols originally read.
Equations
Instances For
Between macro-steps, about to simulate an N-step from state q.
Equations
Instances For
Rightward read sweep, gathering head symbols.
Equations
Instances For
Leftward rewind back to cell 1, carrying the δ results.
Equations
Instances For
Rightward write/marker sweep (stay/right moves + materialize).
Instances For
Leftward marker sweep (left moves) + final rewind.
Equations
Instances For
Applying the deferred input/output actions.
Equations
Instances For
Noncomputable Fintype via Finite — sidesteps the product/Pi
DecidableEq synthesis limit.
Equations
Noncomputable decidable equality — only used inside proofs (trace/step
reduce c.state = qhalt in Prop), never executed.