Checking a guessed symbol against the input head #
A scan reads work tapes. The one thing it cannot see is the input tape, so a machine that simulates another machine's input head has to compare the symbol under that head against what it guessed by hand.
TM.inMatchTM does exactly that, in two steps: it compares the two cells of a register against
the two bits a caller-supplied encoding assigns to the symbol under the input head, and leaves the
verdict on a result register. The input head does not move, so a simulation whose input head sits
at the simulated position keeps it there.
Main definitions #
TM.inMatchTM— the checkTM.inMoveTM— moving the input head by a guessed direction held in two one-cell registers, so it tracks the simulated oneTM.copyCellTM— copying one register's cell onto another, which is how a scan's verdict leaves the result tapeTM.andCellTM— conjoining one register's cell into another, which is how a machine with no early exit remembers that a check failed
Main results #
TM.inMatchTM_hoareTime— its contract: two steps, the verdict on the result register, the compared register rewound, every other tape untouchedTM.inMoveTM_hoareTime— and the move's: one step, the input head where the register saysTM.copyCellTM_hoareTime— and the copy'sTM.andCellTM_hoareTime— and the conjunction'sTM.guessProtocol_andCellTM— the conjunction never consults the guess tape
Control states of TM.inMatchTM: compare the first bit, then the second, then halt.
- first : InMatchPhase
- second : InMatchPhase
- done : InMatchPhase
Instances For
Equations
Check a guessed symbol against the input head. Register sym, parked at cell one, holds
two bits; expect says which two bits the symbol under the input head should give. The verdict
lands on register res, and sym is left where it started.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The verdict TM.inMatchTM writes: both cells of sym agree with the two bits the symbol
under the input head is expected to give.
Equations
- Complexity.TM.inMatchVerdict expect g c₁ c₂ = (decide (c₁ = Complexity.Γ.ofBool (expect g).1) && decide (c₂ = Complexity.Γ.ofBool (expect g).2))
Instances For
The tape TM.inMatchTM leaves on its result register.
Equations
- Complexity.TM.inMatchRes expect g c₁ c₂ t = { head := 1, cells := Function.update t.cells 1 (Complexity.Γ.ofBool (Complexity.TM.inMatchVerdict expect g c₁ c₂)) }
Instances For
The contract of the input-symbol check. Two steps; the verdict lands on cell one of the result register, the compared register comes back to cell one with its contents intact, and every other tape — the input tape included — is untouched.
Moving the input head with the simulated one #
Equations
- Complexity.TM.instFintypeInMovePhase = { elems := {Complexity.TM.InMovePhase.go, Complexity.TM.InMovePhase.done}, complete := ⋯ }
Move the input head by the direction two registers' cells name. A guessed cell holds a
bit, so it cannot name one of three directions on its own; a machine's transition sees every head
at once, so two one-cell registers do it in a single step. Reading ▷ still forces a move right,
as it must.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The contract of the input-head move. One step; the input head moves as the register says, and every other tape is untouched.
Copying one cell to another register #
Copy the symbol under one register's head onto another register. A scan leaves its verdict on the machine's result tape, which no scan can read; moving it onto an ordinary register is what lets a later check take it into account.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The contract of the cell copy. One step; the destination's cell under its head becomes the source's, and nothing else moves.
Conjoin one register's cell into another. The destination's cell under its head becomes
1 exactly when both it and the source's cell held 1. A loop driver with no early exit — such
as TM.binaryForTM — cannot stop at the first failed check, so its body accumulates the verdicts
here instead.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The contract of the cell conjunction. One step; the destination's cell under its head becomes the conjunction of the two cells, and nothing else moves.
The cell conjunction never consults the guess tape, so it may sit inside a nondeterministic assembly.