Documentation

Complexitylib.Models.TuringMachine.Lift

Tape-layout combinators: extra work tapes and output retargeting #

Two DTM combinators that change a machine's tape layout without changing its behavior:

Correspondence proofs #

Both combinators are proved correct by a step-commutation lemma through a configuration embedding (liftCfg / retargetCfg): one step of the derived machine on an embedded configuration equals one step of tm, embedded. The embeddings park the dummy tapes at cell 1 with blank cells; the initial configuration instead has dummy heads at cell 0 (on ), so the step lemma is stated for any dummy tape with cells = Tape.init [] and head ≤ 1 — covering both the initial bounce and the parked steady state (mirroring NTM.pad0).

The time bounds are preserved exactly (no + 1): the dummy-tape bounce happens during the simulated machine's own first step.

def Complexity.TM.liftTM {n : } (tm : TM n) (m : ) :
TM (n + m)

Pad tm : TM n with m never-used work tapes. Work tapes 0..n-1 (indexed by Fin.castAdd m i) behave exactly as tm's; the extra tapes n..n+m-1 write back what they read (readBackWrite) and idle (idleDir): they bounce off at the first step and then park at cell 1 forever. Input and output behavior is unchanged.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def Complexity.TM.liftCfg {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) :
    Cfg (n + m) tm.Q

    Embed a configuration of tm : TM n into one of tm.liftTM m: work tapes i < n are c's, the extras are the canonical parked blank tape (head 1, blank cells). State, input, and output are shared.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem Complexity.TM.liftCfg_state {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) :
      (tm.liftCfg m c).state = c.state

      liftCfg leaves the state unchanged.

      @[simp]
      theorem Complexity.TM.liftCfg_input {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) :
      (tm.liftCfg m c).input = c.input

      liftCfg leaves the input tape unchanged.

      @[simp]
      theorem Complexity.TM.liftCfg_output {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) :
      (tm.liftCfg m c).output = c.output

      liftCfg leaves the output tape unchanged.

      theorem Complexity.TM.liftCfg_work_lt {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) (i : Fin (n + m)) (h : i < n) :
      (tm.liftCfg m c).work i = c.work i, h

      liftCfg maps the first n work tapes to c's work tapes.

      theorem Complexity.TM.liftCfg_work_ge {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) (i : Fin (n + m)) (h : n i) :

      liftCfg maps the extra work tapes to the parked blank tape.

      theorem Complexity.TM.liftTM_step_liftCfg {n : } (tm : TM n) (m : ) (c : Cfg n tm.Q) :
      (tm.liftTM m).step (tm.liftCfg m c) = Option.map (tm.liftCfg m) (tm.step c)

      Step commutation on embedded configurations: once the extra tapes are parked, tm.liftTM m steps exactly as tm does through liftCfg.

      theorem Complexity.TM.liftTM_decidesInTime {n : } (tm : TM n) (m : ) {L : Language} {T : } (h : tm.DecidesInTime L T) :

      Lifting preserves deciding, with the same time bound. The extra work tapes never interfere: the lifted machine's run tracks tm's run step for step.

      theorem Complexity.TM.liftTM_computesInTime {n : } (tm : TM n) (m : ) {f : List BoolList Bool} {T : } (h : tm.ComputesInTime f T) :

      Lifting preserves function computation, with the same time bound.

      theorem Complexity.TM.liftTM_decidesInSpace {n : } (tm : TM n) (m : ) {L : Language} {S : } (h : tm.DecidesInSpace L S) :
      (tm.liftTM m).DecidesInSpace L fun (k : ) => max (S k) 1

      Lifting preserves space bounds up to the parked cell. The extra work tapes' heads never move past cell 1, so tm.liftTM m decides L in space max (S ·) 1.

      def Complexity.TM.retargetOutput {n : } (tm : TM n) :
      TM (n + 1)

      Redirect tm's output actions to a fresh work tape. retargetOutput tm : TM (n + 1) behaves like tm, except that the output write and direction are applied to work tape n (the Fin.last n tape), whose read is fed to tm.δ as the virtual output head; the real output tape is idled (readBackWrite/idleDir). Work tapes 0..n-1 (indexed by Fin.castSucc i) and the input tape behave as before.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Complexity.TM.retargetCfg {n : } (tm : TM n) (c : Cfg n tm.Q) :
        Cfg (n + 1) tm.Q

        Embed a configuration of tm : TM n into one of tm.retargetOutput: work tapes i < n are c's, work tape n is c's output tape, and the real output tape is the canonical parked blank tape.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem Complexity.TM.retargetCfg_state {n : } (tm : TM n) (c : Cfg n tm.Q) :

          retargetCfg leaves the state unchanged.

          @[simp]
          theorem Complexity.TM.retargetCfg_input {n : } (tm : TM n) (c : Cfg n tm.Q) :

          retargetCfg leaves the input tape unchanged.

          theorem Complexity.TM.retargetCfg_work_lt {n : } (tm : TM n) (c : Cfg n tm.Q) (i : Fin (n + 1)) (h : i < n) :
          (tm.retargetCfg c).work i = c.work i, h

          retargetCfg maps the first n work tapes to c's work tapes.

          theorem Complexity.TM.retargetCfg_work_last {n : } (tm : TM n) (c : Cfg n tm.Q) :

          retargetCfg maps the last work tape to c's output tape.

          Step commutation on embedded configurations: once the real output tape is parked, tm.retargetOutput steps exactly as tm does through retargetCfg.

          theorem Complexity.TM.retargetOutput_computesInTime {n : } (tm : TM n) {f : List BoolList Bool} {T : } (h : tm.ComputesInTime f T) (x : List Bool) :
          ∃ (c' : Cfg (n + 1) tm.Q), tT x.length, tm.retargetOutput.reachesIn t (tm.retargetOutput.initCfg x) c' tm.retargetOutput.halted c' (c'.work (Fin.last n)).HasOutput (f x)

          Output retargeting preserves computation, with the same time bound. If tm computes f within time T, then retargetOutput tm halts within T(|x|) steps with f x written on work tape n (the Fin.last n tape). This is the form needed to compose "compute a clock value onto a work tape".