Guessing in designated states #
Complexitylib.Models.TuringMachine.GuessTape pairs NTM.ofGuess M with NTM.choiceTM, which
forces M to consume a guess at every step. No machine assembled from
Complexitylib.Models.TuringMachine.Combinators does that: the handoff step of TM.seqTM, and
every step of a subroutine that has no interest in the guesses, leaves the tape's head where it
is. This file drops that requirement.
A machine here nominates a set of advancing states. In an advancing state it consumes the cell under the guess head and moves that head on; in every other state it neither consults the guess tape nor moves its head. Between the two lies the whole deterministic subroutine library, usable unchanged.
The price is that the guess tape's head and the step counter part company: at step i the head
sits at the cursor, the number of advancing steps so far. NTM.ofGuess M still consumes one
choice per step, so the correspondence between a loaded tape and a choice sequence is no longer
the identity — it is the cursor. NTM.exists_guessTape is what makes it work in the direction a
soundness proof needs: every choice sequence is realized by some loaded tape, because the
choices made at non-advancing steps are the ones the machine never looks at.
Main definitions #
TM.traceD— run a deterministic machine for a fixed number of steps, halting in placeTM.GuessProtocol— advance and consume in the nominated states, hold elsewhereNTM.guessBit— the bit the machine reads at a given step
Main results #
NTM.dropChoice_stepCfg— one step ofMis one step ofNTM.ofGuess Malong the bit readNTM.dropChoice_traceD— and a run is a trace along the bits readTM.traceD_of_reachesIn,TM.traceD_add,TM.traceD_of_reachesIn_halted— a run of a fixed length is the deterministic trace, traces compose, and a halted trace stays putNTM.exists_guessTape— every choice sequence comes from a loaded guess tape
Run a deterministic machine for T steps, staying put once halted. The deterministic
counterpart of NTM.trace.
Equations
Instances For
The guess protocol. In an advancing state the machine consumes the cell under the guess head and moves that head on; in every other state it holds the head still and nothing visible depends on what the cell holds. The guess tape's contents are never altered.
- write (q : M.Q) : q ≠ M.qhalt → ∀ (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 always written back unchanged.
- dir (q : M.Q) : q ≠ M.qhalt → ∀ (iHead : Γ) (wHeads : Fin (k + 1) → Γ) (oHead : Γ), wHeads (Fin.last k) ≠ Γ.start → (M.δ q iHead wHeads oHead).2.2.2.2.1 (Fin.last k) = if Adv q = true then Dir3.right else Dir3.stay
The guess head advances in advancing states and holds still elsewhere.
- indep (q : M.Q) : q ≠ M.qhalt → ¬Adv q = true → ∀ (iHead : Γ) (ww : Fin k → Γ) (oHead g g' : Γ), visible (M.δ q iHead (Fin.snoc ww g) oHead) = visible (M.δ q iHead (Fin.snoc ww g') oHead)
Outside the advancing states the guess is not consulted.
Instances For
Run a nondeterministic machine forward, taking the i-th choice at step i. Unlike
NTM.trace, which consumes its choices from the front, this indexes them absolutely, which is
what a statement about "the step at which a guess was consumed" needs.
Equations
Instances For
A step preserves the guess tape and moves its head at most one cell right, so a tape holding
bits for T + 1 cells still holds them for T.
Every choice sequence comes from a loaded tape #
The largest index below T at which P holds, or 0 if there is none.
Equations
- Complexity.NTM.searchIdx P 0 = 0
- Complexity.NTM.searchIdx P i.succ = if P i = true then i else Complexity.NTM.searchIdx P i
Instances For
Whether the nondeterministic run consumes a guess at step i.
Equations
- Complexity.NTM.consumes M Adv choices d i = (!decide (((Complexity.NTM.ofGuess M).nrunAt choices d i).state = M.qhalt) && Adv ((Complexity.NTM.ofGuess M).nrunAt choices d i).state)
Instances For
Where the guess head sits after i steps: one cell on for every guess consumed.
Equations
- Complexity.NTM.cursor M Adv choices d 0 = 1
- Complexity.NTM.cursor M Adv choices d i.succ = Complexity.NTM.cursor M Adv choices d i + if Complexity.NTM.consumes M Adv choices d i = true then 1 else 0
Instances For
The guess string that realizes a choice sequence. Cell p + 1 holds the choice made at
the step whose cursor is p + 1; cells no advancing step ever reads hold whatever falls out.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every choice sequence is realized by a loaded guess tape. Running M on the tape
NTM.guessOf builds reproduces, step for step, the path of NTM.ofGuess M along choices: the
guesses land where the advancing steps read them, and the bits the machine never looks at are
free.
A path of NTM.ofGuess M is a run of M on a loaded guess tape. This is the transfer a
nondeterministic construction is built on: design and verify M deterministically, with its
guesses arriving on the last work tape, and read the result off here as a statement about the
paths of NTM.ofGuess M. Unlike NTM.ofGuess_trace it asks nothing of M between guesses, so
M may be assembled from the ordinary deterministic combinators.