TM Subroutines: proof internals #
Simulation lemmas and HoareTime proofs for the rewind, blank, clear, and
copy subroutine machines defined in
Complexitylib.Models.TuringMachine.Subroutines. Each subroutine gets a
basic Hoare-style spec, and where needed a rich "frame" variant that threads
an arbitrary predicate P on the untouched tapes through the run.
Main results #
writeTM_hoareTime— writessym.toΓto output cell 1rewindWorkTM_hoareTime— rewinds work tapeidxto cell 1rewindWorkTM_hoareTime_frame— work-tape rewind preserving a predicate PrewindInputTM_hoareTime— rewinds the input tape to cell 1rewindInputTM_hoareTime_frame— input rewind preserving a predicate PrewindInputTM_toNTM_hoareTime— NTM-lifted input rewind specrewindInputTM_toNTM_hoareTime_frame— NTM-lifted rich input rewind specblankWorkTM_started_hoareTime— blank a started work tape in linear timeblankWorkTM_hoareTime_frame_of_binaryString— frame-preserving blankclearWorkTM_hoareTime_frame_of_binaryString— blank then rewind to the started empty tape, preserving the framecopyInputToWorkTM_started_hoareTime— copy the Boolean input to a work tapecopyWorkToWorkTM_started_hoareTime— copy one started work tape to anothercopyWorkToWorkTM_hoareTime_frame_of_binaryString— frame-preserving work-to-work copy
writeTM sym writes sym.toΓ to output cell 1 and halts.
Pre: output tape well-formed (cell 0 = ▷, cells ≥ 1 ≠ ▷), head ≤ B.
Post: output cell 1 = sym.toΓ.
Time: B + 3 steps.
rewindWorkTM idx rewinds work tape idx to cell 1 and halts.
Pre: work tape idx well-formed (cell 0 = ▷, cells ≥ 1 ≠ ▷), head ≤ B.
Post: work tape idx head = 1.
Time: B + 2 steps.
rewindInputTM rewinds the input tape to cell 1 and halts.
Pre: input tape well-formed (cell 0 = ▷, cells ≥ 1 ≠ ▷), head ≤ B.
Post: input head = 1.
Time: B + 2 steps.
Rich HoareTime for rewindInputTM that preserves an arbitrary predicate P
through the rewind, provided P is stable when the input cells are unchanged
and the input head is reset to 1. Work and output tapes are preserved
exactly under the usual non-start-under-head side conditions.
Nondeterministic form of rewindInputTM_hoareTime, for phase compositions
that run deterministic setup subroutines through TM.toNTM.
Nondeterministic form of rewindInputTM_hoareTime_frame.
Rich HoareTime for rewindWorkTM that preserves an arbitrary predicate P
through the rewind, provided P depends on cells (not heads) of the target
tape. This is the key tool for threading invariants (e.g., simulation state,
encoded data) through rewind steps in seqTM compositions.
The caller provides hP_preserved showing that P is stable under:
- target tape cells unchanged, head set to 1
- all other work tapes unchanged
- input and output unchanged
If work tape idx holds a started Boolean string x, then blankWorkTM idx clears that tape in |x| + 1 steps and leaves the head at the first
blank cell after the erased string.
Rich HoareTime for blankWorkTM: erase a started Boolean work tape while
preserving arbitrary frame data on the input tape, output tape, and all other
work tapes. This is the form needed to recycle a staged work tape inside a
larger verifier pipeline.
Rich HoareTime for clearWorkTM: erase a started Boolean work tape and
rewind it to the standard started blank tape while preserving the external
frame. The user predicate only needs to be stable once the target tape has
reached the final started blank configuration.
copyInputToWorkTM idx can be started with the input and target work tape
already positioned at cell 1: it copies the entire Boolean input to a binary
prefix on work tape idx and halts within |x| + 1 steps.
If src holds a started Boolean string x and dst is a started blank
work tape, then copyWorkToWorkTM src dst copies x onto dst within
|x| + 1 steps. The source contents are preserved, while its head advances
to the first blank cell after the copied data.
Rich HoareTime for copyWorkToWorkTM: copy a started Boolean work tape to
another started blank work tape while preserving arbitrary frame data on the
input tape, output tape, and all unrelated work tapes. The source cells are
preserved while its head advances to the first blank after the copied string,
and the destination accumulates the copied prefix without losing its left-end
marker.