Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Plumbing.InputPrefix

A stored prefix before the read-only input #

A machine can read a prepared work word followed by the real input. It uses one additional work tape for the prefix and never copies the suffix. A simulated step acts on the original work tapes, then a routing step handles crossing the join. The route reads a blank after moving towards the join, so it distinguishes that blank from the boundary at the opposite end.

Whether the simulated head reads the stored prefix or the physical input.

  • stored : Region

    The left blank or a symbol of the stored prefix.

  • input : Region

    A symbol of the physical input or its right blank.

Instances For

    A simulated instruction is followed by a routing step, including at the first halt.

    • run {Q : Type} (region : Region) (q : Q) : Control Q

      Run an instruction using the active input head.

    • route {Q : Type} (region : Region) (checkJoin : Bool) (next : Option Q) : Control Q

      Check for a crossing after the movement and enter the next state.

    Instances For
      noncomputable def Turing.MultiTapeTM.InputPrefix.machine {k : ℕ} {Symbol Q : Type} (tm : MultiTapeTM k Symbol Q) :
      MultiTapeTM (k + 1) Symbol (Control Q)

      Simulate a machine on a prepared nonempty prefix and the physical input. The extra tape holds the prefix, blank on each side, with its head at the first symbol at entry. The physical input head starts on its left blank.

      The simulator enters the stored-prefix phase.

      def Turing.MultiTapeTM.InputPrefix.config {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) :
      Cfg (k + 1) Symbol (Control Q) input

      A stable simulator configuration stores the prefix on its last work tape. The physical input head is parked at the left blank while the virtual head reads the prefix. For an empty prefix, a virtual head at position one enters directly in the physical-input phase.

      theorem Turing.MultiTapeTM.InputPrefix.config_wordsCfg {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (hpre : pre ≠ []) (q : Option Q) (ws : Fin k → List Symbol) (out : List Symbol) :
      config pre (wordsCfg (pre ++ input) q ws out) = { state := Option.map (Control.run Region.stored) q, inputPos := 0, workTapes := fun (i : Fin (k + 1)) => Fin.lastCases (motive := fun (x : Fin (k + 1)) => ℤ → Option Symbol) (fun (z : ℤ) => tapeOfList pre (z - 1)) (fun (i : Fin k) => tapeOfList (ws i)) i, workTapePos := fun (i : Fin (k + 1)) => Fin.lastCases 1 (fun (x : Fin k) => 0) i, output := out }

      A nonempty prepared prefix occupies cells starting at one. All other word heads start at zero, and the physical input head starts on the left blank.

      theorem Turing.MultiTapeTM.InputPrefix.config_halted_iff {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) :

      The simulator halts exactly when its stable source configuration has halted.

      @[simp]
      theorem Turing.MultiTapeTM.InputPrefix.config_output {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) :
      (config pre c).output = c.output

      Stable configurations retain the original machine's output.

      @[simp]
      theorem Turing.MultiTapeTM.InputPrefix.config_workTapePos {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (i : Fin k) :

      The original work heads keep their coordinates in a stable simulator configuration.

      @[simp]
      theorem Turing.MultiTapeTM.InputPrefix.config_workTapes {k : ℕ} {Symbol Q : Type} {input : List Symbol} (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (i : Fin k) :

      Stable simulator configurations keep the contents of the original work tapes.

      theorem Turing.MultiTapeTM.InputPrefix.step_step_config {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (q : Q) (hq : c.state = some q) :
      step (step (config pre c)) = config pre (step c)

      Every live instruction on the concatenated input executes in two native steps. The second step completes any boundary crossing, even if the instruction halts.

      theorem Turing.MultiTapeTM.InputPrefix.runFrom_config {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (t : ℕ) :
      runFrom (config pre c) (2 * t) = config pre (runFrom c t)

      At even times, the simulator agrees with the corresponding source configuration. Both runs remain stationary after their first halt.

      theorem Turing.MultiTapeTM.InputPrefix.haltsAt_config {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) {t : ℕ} (ht : tm.HaltsAt c t) :
      (machine tm).HaltsAt (config pre c) (2 * t)

      Routing doubles the first halting time, with no early halts at odd times.

      theorem Turing.MultiTapeTM.InputPrefix.workTapePos_runFrom_odd {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (t : ℕ) (i : Fin k) :
      (runFrom (config pre c) (2 * t + 1)).workTapePos i.castSucc = (runFrom c (t + 1)).workTapePos i

      At the intermediate time, the original work heads have already moved to their next source positions. This accounts for the original workspace at both native phases.

      theorem Turing.MultiTapeTM.InputPrefix.prefixHead_runFrom {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (t : ℕ) :
      have x := (runFrom (config pre c) t).workTapePos (Fin.last k); 0 ≤ x ∧ x ≤ ↑pre.length + 1

      The added work head stays within the prefix and its two blanks, including during routing.

      theorem Turing.MultiTapeTM.InputPrefix.space_runPath_le {k : ℕ} {Symbol Q : Type} {input : List Symbol} (tm : MultiTapeTM k Symbol Q) (pre : List Symbol) (c : Cfg k Symbol Q (pre ++ input)) (t : ℕ) :

      Through (2t) simulator steps the original work tapes use the source workspace through (t) steps. The extra tape visits at most the length of the prefix plus its two blanks.