Documentation

Complexitylib.Models.TuringMachine.ChoiceTape

Running one nondeterministic path deterministically #

An NTM's transition function has exactly the shape of a TM's, plus a Bool. Feeding that Bool from a dedicated work tape — one cell per step, scanned left to right and written back unchanged — turns the nondeterministic machine into a deterministic one whose run is the chosen path.

This is the primitive that lets deterministic machines reason about nondeterministic runs: a decider that must evaluate "does tm accept x along choice sequence c" places c on the choice tape and runs choiceTM tm.

Main definitions #

Main results #

def Complexity.TM.stepCfg {k : } (tm : TM k) (c : Cfg k tm.Q) :
Cfg k tm.Q

The configuration update inlined in TM.step.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.TM.step_of_not_halted {k : } (tm : TM k) {c : Cfg k tm.Q} (h : c.state tm.qhalt) :
    tm.step c = some (tm.stepCfg c)

    A non-halted configuration steps to stepCfg.

    def Complexity.NTM.choiceTM {k : } (tm : NTM k) :
    TM (k + 1)

    The deterministic machine that runs one path of tm, reading its choice bits from the appended last work tape: each step consults the cell under that head, writes it back unchanged, and advances the head one cell right.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Complexity.NTM.stepCfg {k : } (tm : NTM k) (b : Bool) (c : Cfg k tm.Q) :
      Cfg k tm.Q

      One step of an NTM along a fixed choice bit: the configuration update inlined in NTM.trace.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.NTM.trace_succ_of_not_halted {k : } (tm : NTM k) (T : ) (choices : Fin (T + 1)Bool) {c : Cfg k tm.Q} (h : c.state tm.qhalt) :
        tm.trace (T + 1) choices c = tm.trace T (fun (i : Fin T) => choices i + 1, ) (tm.stepCfg (choices 0, ) c)

        Unfolding one non-halted step of trace.

        def Complexity.NTM.dropChoice {k : } {Q : Type} (c : Cfg (k + 1) Q) :
        Cfg k Q

        Forget the choice tape from a configuration.

        Equations
        Instances For
          def Complexity.NTM.choiceStream {k : } {Q : Type} (c : Cfg (k + 1) Q) (j : ) :

          The choice bits under and to the right of the choice head.

          Equations
          Instances For
            theorem Complexity.NTM.choiceTM_step {k : } (tm : NTM k) (c : Cfg (k + 1) tm.Q) (hhalt : c.state tm.qhalt) (hread : (c.work (Fin.last k)).read Γ.start) :
            ∃ (c₁ : Cfg (k + 1) tm.choiceTM.Q), tm.choiceTM.step c = some c₁ dropChoice c₁ = tm.stepCfg (choiceStream c 0) (dropChoice c) c₁.work (Fin.last k) = (c.work (Fin.last k)).move Dir3.right

            One step of choiceTM is one step of the chosen path. The choice tape is written back unchanged and its head advances one cell.

            theorem Complexity.NTM.choiceTM_simulates {k : } (tm : NTM k) (T : ) (c : Cfg (k + 1) tm.Q) (hinv : (c.work (Fin.last k)).StartInvariant) (hhead : 1 (c.work (Fin.last k)).head) :
            ∃ (c' : Cfg (k + 1) tm.Q), tT, tm.choiceTM.reachesIn t c c' (t < Ttm.choiceTM.halted c') dropChoice c' = tm.trace T (fun (j : Fin T) => choiceStream c j) (dropChoice c)

            A T-step run of choiceTM is the T-step trace of tm along the choice bits on the tape. The run stops early exactly when the path halts; the choice tape is left untouched apart from its head, which advances one cell per step.