Generic proof tools for TM combinators #
This file provides reusable proof infrastructure for TM combinator proofs,
eliminating duplication across SeqInternal, IfInternal, LoopInternal,
and ComplementInternal.
Main results #
reachesIn_map— generic simulation lifting: if a state embedding commutes withstep, thenreachesInlifts through the embeddingexists_reachesIn_of_rewindStep_tape— generic rewind loop for an arbitrary tape accessor: stepping from a "rewind state" moves the head left (preserving cells) until cell 0, then enters a "target state" at head 1exists_reachesIn_of_rewindStep_output— the same rewind loop specialized to the output tapeexists_reachesIn_of_rewindStep_frame— the output-tape rewind loop, additionally proving the input and work tapes are unchangedtransitionTape/transitionInput— the standard tape operations applied at combinator phase boundaries, with cell-preservation and head-bound lemmas (transitionTape_cells,transitionInput_cells,one_le_head_transitionTape,transitionInput_head_ge,head_transitionTape_le)transitionTape_eq_self/transitionInput_eq_self— frame rules: both operations are no-ops on tapes reading a non-▷ symbol
Shared tape stability lemmas #
These lemmas were previously duplicated across multiple Internal files.
readBackWrite recovers the original symbol for non-start symbols.
If wrap commutes with step (i.e., one step of tm corresponds to
one step of tm' through the embedding), then reachesIn lifts.
Generic rewind loop (abstract tape accessor).
For any TM with a designated "rewind state" where stepping:
- At head > 0: stays in rewind, moves head left by 1, preserves cells
- At head = 0: enters target state, moves head to 1, preserves cells
Then from rewind state with tape head at p, the machine reaches the
target state with tape head at 1 in exactly p + 1 steps.
The tape parameter selects which tape to track (output, work, etc.).
This captures the common rewind pattern used in complementTM, ifTM,
loopTM, writeTM, and rewindWorkTM.
Specialization of exists_reachesIn_of_rewindStep_tape for the output tape.
Generic rewind loop (full tape tracking).
Same as exists_reachesIn_of_rewindStep_output, but the step hypotheses also guarantee
that input and work tapes are preserved (given stability conditions:
head ≥ 1 and cells ≥ 1 ≠ start). The conclusion additionally proves
c_target.input = c.input and c_target.work = c.work.
The standard tape transformation applied at combinator phase boundaries
(work tapes and output tape). Writes back the current symbol (preserving
cells) and stays in place; if at cell 0, δ_right_of_start forces a
right move to cell 1.
Used by all combinators (seqTM, ifTM, loopTM, complementTM)
at transitions between phases.
Equations
Instances For
The standard input-tape transformation at combinator phase boundaries.
The input tape is read-only (no write), so only the head moves: stay
in place unless at cell 0, where δ_right_of_start forces right.
Equations
Instances For
transitionTape preserves cells when cells ≥ 1 ≠ start.
transitionInput preserves cells (always, since input has no write).
After transitionTape, head ≥ 1 when cell 0 = start.
After transitionInput, head ≥ 1 when cell 0 = start.
Bound on transitionTape output head: ≤ original head + 1.
Frame rule: transitionTape is the identity when the tape reads a
non-▷ symbol. This is the key lemma for threading invariants through
seqTM / loopTM / ifTM composition: tapes that are "stable"
(head not at cell 0) pass through phase transitions unchanged.
Frame rule: transitionInput is the identity when the tape reads a
non-▷ symbol.