Documentation

MIPRE.TM.Interp.Routines

The routines: specifications of the instructions #

Each instruction's specification is a reachability statement: from a configuration at the instruction's first phase, with the tapes it reads in a stated shape, a bounded number of steps leads to the configuration at the next instruction, with the stated effect on the tapes it touches and none on the others (Untouched).

@[reducible, inline]

The control at (k, pc), first phase.

Equations
Instances For
    def MIPRE.TM.Interp.next_ (k : ProgId) (pc : Fin maxPc) (h : ↑pc + 1 < maxPc) :

    The control at the instruction after (k, pc).

    Equations
    Instances For
      theorem MIPRE.TM.Interp.resolve_adv (k : ProgId) (pc : Fin maxPc) (h : ↑pc + 1 < maxPc) :
      resolve k pc Next.adv = next_ k pc h
      @[simp]
      theorem MIPRE.TM.Interp.resolve_stay (k : ProgId) (pc : Fin maxPc) (ph : Phase) :
      resolve k pc (Next.stay ph) = some { k := k, pc := pc, ph := ph }
      @[simp]
      theorem MIPRE.TM.Interp.resolve_jmp (k : ProgId) (pc : Fin maxPc) (k' : ProgId) :
      resolve k pc (Next.jmp k') = some { k := k', pc := ⟨0, resolve_jmp._proof_1⟩, ph := Phase.p0 }
      def MIPRE.TM.Interp.Untouched {input : Fin 7 → List Sym} (c c' : Cfg input) (SI : List IT) (SW : List WT) :

      c' agrees with c on the input heads outside SI and on the work tapes outside SW.

      Equations
      Instances For
        theorem MIPRE.TM.Interp.Untouched.refl {input : Fin 7 → List Sym} (c : Cfg input) (SI : List IT) (SW : List WT) :
        Untouched c c SI SW
        theorem MIPRE.TM.Interp.Untouched.trans {input : Fin 7 → List Sym} {c c' c'' : Cfg input} {SI SI' : List IT} {SW SW' : List WT} (h : Untouched c c' SI SW) (h' : Untouched c' c'' SI' SW') :
        Untouched c c'' (SI ++ SI') (SW ++ SW')
        theorem MIPRE.TM.Interp.Untouched.mono {input : Fin 7 → List Sym} {c c' : Cfg input} {SI SI' : List IT} {SW SW' : List WT} (h : Untouched c c' SI SW) (hI : ∀ j ∈ SI, j ∈ SI') (hW : ∀ d ∈ SW, d ∈ SW') :
        Untouched c c' SI' SW'
        theorem MIPRE.TM.Interp.Untouched.tapes {input : Fin 7 → List Sym} {c c' : Cfg input} {SI : List IT} {SW : List WT} (h : Untouched c c' SI SW) {d : WT} (hd : d ∉ SW) :
        theorem MIPRE.TM.Interp.Untouched.pos {input : Fin 7 → List Sym} {c c' : Cfg input} {SI : List IT} {SW : List WT} (h : Untouched c c' SI SW) {d : WT} (hd : d ∉ SW) :
        theorem MIPRE.TM.Interp.Untouched.inputPos {input : Fin 7 → List Sym} {c c' : Cfg input} {SI : List IT} {SW : List WT} (h : Untouched c c' SI SW) {j : IT} (hj : j ∉ SI) :
        theorem MIPRE.TM.Interp.Untouched.inputPos_eq {input : Fin 7 → List Sym} {c c' : Cfg input} {SW : List WT} (h : Untouched c c' [] SW) :

        One step of an instruction #

        The symbol under the head of work tape t.

        theorem MIPRE.TM.Interp.step_instr {input : Fin 7 → List Sym} {c : Cfg input} {k : ProgId} {pc : Fin maxPc} {ph : Phase} (hq : c.state = some { k := k, pc := pc, ph := ph }) {ins : Instr} (hins : instrAt k pc = ins) :

        One step at (k, pc, ph) executing the instruction ins there.

        def MIPRE.TM.Interp.Act.Within (a : Act) (SI : List IT) (SW : List WT) :

        An action that moves only the input heads in SI and touches only the work tapes in SW.

        Equations
        Instances For
          theorem MIPRE.TM.Interp.untouched_applyAct {input : Fin 7 → List Sym} {a : Act} {SI : List IT} {SW : List WT} (h : a.Within SI SW) (q' : Option Ctl) (c : Cfg input) :
          Untouched c (applyAct a q' c) SI SW

          write #

          theorem MIPRE.TM.Interp.exec_write {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} {s : Sym} (hins : instrAt k pc = Instr.write t s) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) :
          ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = Function.update (c.workTapes t) (c.workTapePos t) (some s) ∧ c'.workTapePos t = c.workTapePos t + 1

          move #

          theorem MIPRE.TM.Interp.exec_move {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} {dir : Bool} (hins : instrAt k pc = Instr.move t dir) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) :
          ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t + if dir = true then 1 else -1

          toEnd #

          theorem MIPRE.TM.Interp.exec_toEnd {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.toEnd t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (c : Cfg input) :
          c.state = at_ k pc → Holds (c.workTapes t) (c.workTapePos t) l → c.workTapes t (c.workTapePos t + ↑l.length) = none → ∃ (c' : Cfg input), Reach c (l.length + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t + ↑l.length

          rewind #

          theorem MIPRE.TM.Interp.scan_rewind {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.rewind t) (hpc : ↑pc + 1 < maxPc) (n : ℕ) (c : Cfg input) :
          c.state = some { k := k, pc := pc, ph := Phase.p1 } → (∀ (q : ℤ), c.workTapePos t - ↑n < q → q ≤ c.workTapePos t → c.workTapes t q ≠ none) → c.workTapes t (c.workTapePos t - ↑n) = none → ∃ (c' : Cfg input), Reach c (n + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t - ↑n + 1

          The scan of rewind from p1: cells pos - n + 1 … pos not blank, pos - n blank.

          theorem MIPRE.TM.Interp.exec_rewind {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.rewind t) (hpc : ↑pc + 1 < maxPc) (n : ℕ) (c : Cfg input) (hq : c.state = at_ k pc) (hne : ∀ (q : ℤ), c.workTapePos t - ↑n ≤ q → q < c.workTapePos t → c.workTapes t q ≠ none) (hbl : c.workTapes t (c.workTapePos t - ↑n - 1) = none) :
          ∃ (c' : Cfg input), Reach c (n + 2) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t - ↑n

          From cell p + n with cells p … p + n - 1 not blank and p - 1 blank, rewind reaches cell p (the head may start on the blank after the content).

          eraseRight #

          theorem MIPRE.TM.Interp.scan_erase {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.eraseRight t) (l : List Sym) (c : Cfg input) :
          c.state = some { k := k, pc := pc, ph := Phase.p1 } → Holds (c.workTapes t) (c.workTapePos t) l → c.workTapes t (c.workTapePos t + ↑l.length) = none → ∃ (c' : Cfg input), Reach c (l.length + 1) c' [] ∧ c'.state = some { k := k, pc := pc, ph := Phase.p2 } ∧ Untouched c c' [] [t] ∧ (∀ (q : ℤ), q < c.workTapePos t ∨ c.workTapePos t + ↑l.length ≤ q → c'.workTapes t q = c.workTapes t q) ∧ BlankFrom (c'.workTapes t) (c.workTapePos t) l.length ∧ c'.workTapePos t = c.workTapePos t + ↑l.length - 1

          The erasing scan of eraseRight (p1): erase the l held from the head, then one left.

          theorem MIPRE.TM.Interp.scan_eraseBack {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.eraseRight t) (hpc : ↑pc + 1 < maxPc) (n : ℕ) (c : Cfg input) :
          c.state = some { k := k, pc := pc, ph := Phase.p2 } → BlankFrom (c.workTapes t) (c.workTapePos t - ↑n + 1) n → c.workTapes t (c.workTapePos t - ↑n) = some Sym.fr → ∃ (c' : Cfg input), Reach c (n + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = Function.update (c.workTapes t) (c.workTapePos t - ↑n) none ∧ c'.workTapePos t = c.workTapePos t - ↑n

          The return scan of eraseRight (p2): back over n blanks to the $, erase it.

          theorem MIPRE.TM.Interp.exec_eraseRight {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} (hins : instrAt k pc = Instr.eraseRight t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (c : Cfg input) (hq : c.state = at_ k pc) (hl : Holds (c.workTapes t) (c.workTapePos t) l) (hend : c.workTapes t (c.workTapePos t + ↑l.length) = none) :
          ∃ (c' : Cfg input), Reach c (2 * l.length + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ (∀ (q : ℤ), q < c.workTapePos t ∨ c.workTapePos t + ↑l.length ≤ q → c'.workTapes t q = c.workTapes t q) ∧ BlankFrom (c'.workTapes t) (c.workTapePos t) l.length ∧ c'.workTapePos t = c.workTapePos t

          Erase the l held from the head (no $ among its symbols), ending where it started.

          copyUntil #

          theorem MIPRE.TM.Interp.exec_copyUntil {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Option Sym} {src dst : WT} (hins : instrAt k pc = Instr.copyUntil m src dst) (hpc : ↑pc + 1 < maxPc) (hsd : src ≠ dst) (l : List Sym) (c : Cfg input) :
          c.state = at_ k pc → Holds (c.workTapes src) (c.workTapePos src) l → (∀ s ∈ l, some s ≠ m) → c.workTapes src (c.workTapePos src + ↑l.length) = m → ∃ (c' : Cfg input), Reach c (l.length + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [src, dst] ∧ c'.workTapes src = c.workTapes src ∧ c'.workTapePos src = c.workTapePos src + ↑l.length ∧ Holds (c'.workTapes dst) (c.workTapePos dst) l ∧ (∀ (q : ℤ), q < c.workTapePos dst ∨ c.workTapePos dst + ↑l.length ≤ q → c'.workTapes dst q = c.workTapes dst q) ∧ c'.workTapePos dst = c.workTapePos dst + ↑l.length

          Copy the l held from the head of src (none of whose symbols is m) onto dst, stopping with the src head on the m after it.

          branch, jump, emit, halt #

          theorem MIPRE.TM.Interp.exec_branch_taken {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} {s : Option Sym} {target : ProgId} (hins : instrAt k pc = Instr.branch t s target) (c : Cfg input) (hq : c.state = at_ k pc) (hs : c.workTapes t (c.workTapePos t) = s) :
          ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = at_ target ⟨0, resolve_jmp._proof_1⟩ ∧ Untouched c c' [] [] ∧ ∀ (d : Fin 6), c'.workTapes d = c.workTapes d ∧ c'.workTapePos d = c.workTapePos d
          theorem MIPRE.TM.Interp.exec_branch_not {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {t : WT} {s : Option Sym} {target : ProgId} (hins : instrAt k pc = Instr.branch t s target) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) (hs : c.workTapes t (c.workTapePos t) ≠ s) :
          ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [] ∧ ∀ (d : Fin 6), c'.workTapes d = c.workTapes d ∧ c'.workTapePos d = c.workTapePos d
          theorem MIPRE.TM.Interp.exec_jump {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {target : ProgId} (hins : instrAt k pc = Instr.jump target) (c : Cfg input) (hq : c.state = at_ k pc) :
          ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = at_ target ⟨0, resolve_jmp._proof_1⟩ ∧ Untouched c c' [] [] ∧ ∀ (d : Fin 6), c'.workTapes d = c.workTapes d ∧ c'.workTapePos d = c.workTapePos d
          theorem MIPRE.TM.Interp.exec_emit {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {s : Sym} (hins : instrAt k pc = Instr.emit s) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) :
          ∃ (c' : Cfg input), Reach c 1 c' [s] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [] ∧ ∀ (d : Fin 6), c'.workTapes d = c.workTapes d ∧ c'.workTapePos d = c.workTapePos d
          theorem MIPRE.TM.Interp.exec_halt {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} (hins : instrAt k pc = Instr.halt) (c : Cfg input) (hq : c.state = at_ k pc) :

          Scanning left #

          theorem MIPRE.TM.Interp.scan_leftToMarker {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Sym} {t : WT} (hins : instrAt k pc = Instr.leftToMarker m t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (c : Cfg input) :
          c.state = some { k := k, pc := pc, ph := Phase.p1 } → Holds (c.workTapes t) (c.workTapePos t + 1 - ↑l.length) l → (∀ s ∈ l, s ≠ m) → c.workTapes t (c.workTapePos t - ↑l.length) = some m ∨ c.workTapes t (c.workTapePos t - ↑l.length) = none → ∃ (c' : Cfg input), Reach c (l.length + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t - ↑l.length + 1

          The scan of leftToMarker (phase p1): over the cells pos - n + 1 … pos, none holding m, to the marker or blank at pos - n, then one right.

          theorem MIPRE.TM.Interp.exec_leftToMarker {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Sym} {t : WT} (hins : instrAt k pc = Instr.leftToMarker m t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (c : Cfg input) (hq : c.state = at_ k pc) (hl : Holds (c.workTapes t) (c.workTapePos t - ↑l.length) l) (hm : ∀ s ∈ l, s ≠ m) (hend : c.workTapes t (c.workTapePos t - ↑l.length - 1) = some m ∨ c.workTapes t (c.workTapePos t - ↑l.length - 1) = none) :
          ∃ (c' : Cfg input), Reach c (l.length + 2) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t - ↑l.length

          leftToMarker: from pos, with l (no m) on pos - |l| … pos - 1 and the marker or a blank at pos - |l| - 1, to pos - |l|.

          popBack #

          theorem MIPRE.TM.Interp.scan_popBack {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Sym} {t : WT} (hins : instrAt k pc = Instr.popBack m t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (c : Cfg input) :
          c.state = some { k := k, pc := pc, ph := Phase.p2 } → Holds (c.workTapes t) (c.workTapePos t + 1 - ↑l.length) l → (∀ s ∈ l, s ≠ m) → c.workTapes t (c.workTapePos t - ↑l.length) = some m ∨ c.workTapes t (c.workTapePos t - ↑l.length) = none → ∃ (c' : Cfg input), Reach c (l.length + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ (∀ (q : ℤ), q < c.workTapePos t + 1 - ↑l.length ∨ c.workTapePos t < q → c'.workTapes t q = c.workTapes t q) ∧ BlankFrom (c'.workTapes t) (c.workTapePos t + 1 - ↑l.length) l.length ∧ c'.workTapePos t = c.workTapePos t - ↑l.length + 1

          The scan of popBack (phase p2): erase the cells pos - n + 1 … pos, none holding m, to the marker or blank at pos - n, then one right.

          theorem MIPRE.TM.Interp.exec_popBack_empty {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Sym} {t : WT} (hins : instrAt k pc = Instr.popBack m t) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) (hbl : c.workTapes t (c.workTapePos t - 1) = none) :
          ∃ (c' : Cfg input), Reach c 2 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ c'.workTapes t = c.workTapes t ∧ c'.workTapePos t = c.workTapePos t

          popBack on an empty tape: two steps, nothing.

          theorem MIPRE.TM.Interp.exec_popBack {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {m : Sym} {t : WT} (hins : instrAt k pc = Instr.popBack m t) (hpc : ↑pc + 1 < maxPc) (l : List Sym) (a : Sym) (c : Cfg input) (hq : c.state = at_ k pc) (hl : Holds (c.workTapes t) (c.workTapePos t - ↑l.length - 1) (l ++ [a])) (hm : ∀ s ∈ l, s ≠ m) (hend : c.workTapes t (c.workTapePos t - ↑l.length - 2) = some m ∨ c.workTapes t (c.workTapePos t - ↑l.length - 2) = none) :
          ∃ (c' : Cfg input), Reach c (l.length + 3) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [t] ∧ (∀ (q : ℤ), q < c.workTapePos t - ↑l.length - 1 ∨ c.workTapePos t ≤ q → c'.workTapes t q = c.workTapes t q) ∧ BlankFrom (c'.workTapes t) (c.workTapePos t - ↑l.length - 1) (l.length + 1) ∧ c'.workTapePos t = c.workTapePos t - ↑l.length - 1

          popBack: from the end pos, with l ++ [a] on pos - |l| - 1 … pos - 1, l free of m, and the marker or a blank before: erase them, ending at pos - |l| - 1.

          The budget and the counter #

          A unary tape: n ones from cell 0, blank elsewhere.

          Equations
          Instances For
            theorem MIPRE.TM.Interp.Unary.cell {τ : Tape} {n : ℕ} (h : Unary τ n) (q : ℤ) :
            τ q = if 0 ≤ q ∧ q < ↑n then some Sym.one else none
            theorem MIPRE.TM.Interp.Unary.pop {τ : Tape} {n : ℕ} (h : Unary τ (n + 1)) :
            Unary (Function.update τ (↑n) none) n
            theorem MIPRE.TM.Interp.Unary.push {τ : Tape} {n : ℕ} (h : Unary τ n) :
            Unary (Function.update τ (↑n) (some Sym.one)) (n + 1)
            theorem MIPRE.TM.Interp.Unary.zero_iff {τ : Tape} :
            Unary τ 0 ↔ ∀ (q : ℤ), τ q = none
            theorem MIPRE.TM.Interp.exec_charge_one {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} (hins : instrAt k pc = Instr.charge false) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) {r : ℕ} (hb : Unary (c.workTapes BUD) (r + 1)) (hpos : c.workTapePos BUD = ↑r + 1) :
            ∃ (c' : Cfg input), Reach c 2 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [] [BUD] ∧ Unary (c'.workTapes BUD) r ∧ c'.workTapePos BUD = ↑r

            charge: one step left, then a pop per unit; halts on an exhausted budget.

            theorem MIPRE.TM.Interp.exec_charge_one_fail {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} (hins : instrAt k pc = Instr.charge false) (c : Cfg input) (hq : c.state = at_ k pc) (hb : Unary (c.workTapes BUD) 0) :

            Input heads #

            theorem MIPRE.TM.Interp.inputSymbol_of_lt {input : Fin 7 → List Sym} (c : Cfg input) (j : IT) {q : ℕ} (hq : ↑(c.inputPos j) = q + 1) (hlt : q < (input j).length) :

            The symbol under an input head at position q + 1, q < |input j|.

            theorem MIPRE.TM.Interp.inputSymbol_end {input : Fin 7 → List Sym} (c : Cfg input) (j : IT) (hq : ↑(c.inputPos j) = (input j).length + 1) :
            theorem MIPRE.TM.Interp.inputSymbol_start {input : Fin 7 → List Sym} (c : Cfg input) (j : IT) (hq : ↑(c.inputPos j) = 0) :
            theorem MIPRE.TM.Interp.moveInputPos_val_pos {n : ℕ} (p : Fin (n + 2)) (h : ↑p < n + 1) :
            theorem MIPRE.TM.Interp.exec_moveInput {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {j : IT} {dir : Bool} (hins : instrAt k pc = Instr.moveInput j dir) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) :
            ∃ (c' : Cfg input), Reach c 1 c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [j] [] ∧ c'.inputPos j = Turing.MultiTapeTM.moveInputPos (c.inputPos j) (if dir = true then 1 else -1)
            theorem MIPRE.TM.Interp.scan_rewindInput {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {j : IT} (hins : instrAt k pc = Instr.rewindInput j) (hpc : ↑pc + 1 < maxPc) (q : ℕ) (c : Cfg input) :
            c.state = some { k := k, pc := pc, ph := Phase.p1 } → ↑(c.inputPos j) = q → q ≤ (input j).length → ∃ (c' : Cfg input), Reach c (q + 1) c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [j] [] ∧ ↑(c'.inputPos j) = 0

            The scan of rewindInput (phase p1): from position q to position 0.

            theorem MIPRE.TM.Interp.exec_rewindInput {input : Fin 7 → List Sym} {k : ProgId} {pc : Fin maxPc} {j : IT} (hins : instrAt k pc = Instr.rewindInput j) (hpc : ↑pc + 1 < maxPc) (c : Cfg input) (hq : c.state = at_ k pc) :
            ∃ n ≤ ↑(c.inputPos j) + 2, ∃ (c' : Cfg input), Reach c n c' [] ∧ c'.state = next_ k pc hpc ∧ Untouched c c' [j] [] ∧ ↑(c'.inputPos j) = 0