TM Subroutines #
Small concrete Turing machines used as composable building blocks for
constructing larger machines via seqTM, ifTM, and loopTM.
Each subroutine has a corresponding HoareTime specification in
Complexitylib.Models.TuringMachine.Subroutines.Internal.
Main definitions #
TM.writeTM— write a symbol to output cell 1 and haltTM.rewindWorkTM— rewind a work tape head to cell 1TM.rewindInputTM— rewind the input tape head to cell 1TM.scanRightTM— scan a work tape right until blankTM.blankWorkTM— blank a started work tape while scanning rightTM.clearWorkTM— blank a started work tape and rewind it to cell 1TM.copyInputToWorkTM— copy input tape contents to a work tapeTM.copyWorkToWorkTM— copy one work tape's contents to anotherTM.compareWorkTapesTM— compare two work tapes cell by cell
State space of writeTM: rewind the output head to ▷, step right to
cell 1, write the symbol, then halt.
- rewind : WritePhase
- goRight : WritePhase
- write : WritePhase
- done : WritePhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Write sym to output cell 1 and halt.
Phases: rewind output to ▷ → move right to cell 1 → write → halt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
State space of rewindWorkTM/rewindInputTM: move the head left until it
reads ▷, then move right once to land on cell 1 and halt.
- moveLeft : RewindPhase
- moveRight : RewindPhase
- done : RewindPhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Rewind work tape idx to cell 1 (first data cell after ▷).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rewind the input tape to cell 1 (first data cell after ▷). Work and
output tapes are only written with readBackWrite, so their contents are
preserved under the usual no-start-under-head side conditions.
Equations
- One or more equations did not get rendered due to their size.
Instances For
State space of scanRightTM/blankWorkTM: scan right until reading
Γ.blank, then halt.
Instances For
Equations
Scan work tape idx right until finding Γ.blank. Preserves tape contents.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Scan work tape idx right until finding Γ.blank, overwriting every
visited nonblank cell with Γ.blank. This consumes a started Boolean string
and leaves the tape blank to the right of the current head.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Blank a started work tape and rewind it to cell 1, yielding the standard
started blank tape shape.
Equations
Instances For
State space of copyInputToWorkTM/copyWorkToWorkTM: copy symbols
rightward until the source reads Γ.blank, then halt.
Instances For
Equations
Copy input tape data to work tape idx. Reads input right, writes to work tape.
Stops when input reads Γ.blank. Skips ▷ at cell 0.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Copy the contents of work tape src to work tape dst. Reads src
right, writes the same bits to dst, and stops when src reads Γ.blank.
The source tape contents are preserved by writing the currently read symbol
back before moving right.
Equations
- One or more equations did not get rendered due to their size.
Instances For
State space of compareWorkTapesTM: compare cells while both tapes agree,
ending in matchDone (equal) or mismatch (unequal) before halting.
- comparing : ComparePhase
- mismatch : ComparePhase
- matchDone : ComparePhase
- done : ComparePhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Compare work tapes idx₁ and idx₂ cell by cell.
Both advance right together. Stops when both read Γ.blank.
Writes Γ.one to output if match, Γ.zero if mismatch.
Assumes output head is at cell 1.
Equations
- One or more equations did not get rendered due to their size.