Building a nondeterministic machine from a deterministic one #
Complexitylib.Models.TuringMachine.ChoiceTape runs one path of a given NTM deterministically.
This file goes the other way, which is what a construction needs: it turns a deterministic
machine that reads a guess tape into a nondeterministic machine whose choices supply that
tape's contents.
The point is leverage. Every subroutine in Complexitylib.Models.TuringMachine.Subroutines is
deterministic, and so is every Hoare-style contract proved about them. Assembling an NTM by
hand forgoes all of it. Assembling a TM that consults one extra tape for its guesses, and then
applying NTM.ofGuess, keeps the whole toolkit and confines the nondeterminism to a single
tape read.
Conventions #
The guess tape is the last work tape, matching NTM.choiceTM. A machine that uses it as a
guess tape must, at every step, write the cell back unchanged and move that head one cell right —
that is TM.GuessDiscipline. The discipline is what makes the guesses independent: the machine
consumes exactly one fresh bit per step and can never revisit one.
Main definitions #
NTM.ofGuess— the nondeterministic machine a guess-reading deterministic machine denotesTM.GuessDiscipline— write the guess cell back, advance its headTape.BoolFrom— the guess tape holds Boolean symbols for the nextTcells
Main results #
NTM.choiceTM_ofGuess_δ— the round trip is the identity on transitionsNTM.step_ofGuess— and on steps, wherever the guess cell holds a bitNTM.reachesIn_ofGuess_iff— and on runsNTM.ofGuess_simulates— aT-step run ofMon a loaded guess tape is a trace ofNTM.ofGuess Malong the bits loaded onto it
The guess-tape discipline. At every transition the machine writes the last work tape's cell back unchanged and advances that head one cell right, so it consumes exactly one fresh guess per step and never revisits one.
- write (q : M.Q) (iHead : Γ) (wHeads : Fin (k + 1) → Γ) (oHead : Γ) : (M.δ q iHead wHeads oHead).2.1 (Fin.last k) = readBackWrite (wHeads (Fin.last k))
The guess cell is written back unchanged.
- dir (q : M.Q) (iHead : Γ) (wHeads : Fin (k + 1) → Γ) (oHead : Γ) : (M.δ q iHead wHeads oHead).2.2.2.2.1 (Fin.last k) = Dir3.right
The guess head advances one cell right.
Instances For
The nondeterministic machine a guess-reading deterministic machine denotes. The choice
bit is fed to M as the symbol under the last work head, and that tape disappears.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The round trip is the identity on transitions. Reattaching the guess tape to
NTM.ofGuess M recovers M, wherever the guess cell holds a bit.
The round trip is the identity on runs, as long as the guess tape holds bits for as many cells as the run has steps.
A run of M on a loaded guess tape is a trace of NTM.ofGuess M. This is the transfer
that lets a nondeterministic construction be carried out deterministically: build M, prove
whatever is wanted of its runs with the deterministic toolkit, and read it off here as a
statement about the paths of NTM.ofGuess M.
Reading back a loaded guess tape. A tape whose cells from the head onward spell g
presents exactly g as its choice stream.
Loading a guess tape #
The guess tape carrying g: cell j + 1 holds g j, and the head starts on cell 1.
Equations
- Complexity.NTM.loadTape g = { head := 1, cells := fun (j : ℕ) => if j = 0 then Complexity.Γ.start else Complexity.Γ.ofBool (g (j - 1)) }
Instances For
The starting configuration of the deterministic machine: the input in place, every work tape blank except the last, which carries the guesses.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The paths of NTM.ofGuess M are the runs of M on a loaded guess tape. This is the
form a construction uses: design M so that its run on guess string g does what the path
along g should do, and this reads that back as a statement about NTM.ofGuess M.