awhecmu/canonical-drafter-extract-mathlib huggingface dataset:
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
k : K
q : TM1.Stmt (Γ' K Γ) (Λ' K Γ Λ σ) σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
f : σ → Option (Γ k) → σ
hd : Γ k
tl : List (Γ k)
e : S k = hd :: tl
k' : K
i : ℕ
h' : ¬k' = k
pos :
  i = tl.length →
    update (β := fun (k : K) ↦ Option (Γ k)) (L.nth i) k (none : Option (Γ k)) k' =
      ListBlank.nth
        (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse) i
neg :
  ¬i = tl.length →
    L.nth i k' =
      ListBlank.nth
        (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse) i
⊢ (if i = tl.length then update (β := fun (k : K) ↦ Option (Γ k)) (L.nth i) k none else L.nth i) k' =
    ListBlank.nth (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse)
      i

Tactic:
split_ifs
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
k : K
q : TM1.Stmt (Γ' K Γ) (Λ' K Γ Λ σ) σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
f : σ → Option (Γ k) → σ
hd : Γ k
tl : List (Γ k)
e : S k = hd :: tl
k' : K
i : ℕ
h' : ¬k' = k
h : i = tl.length
pos :
  ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i =
    ListBlank.nth (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse)
      i
⊢ update (β := fun (k : K) ↦ Option (Γ k)) (L.nth i) k (none : Option (Γ k)) k' =
    ListBlank.nth (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse)
      i

Tactic:
rw [Function.update_of_ne h', ← proj_map_nth, hL]

Premises used: Turing.proj_map_nth, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
k : K
q : TM1.Stmt (Γ' K Γ) (Λ' K Γ Λ σ) σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
f : σ → Option (Γ k) → σ
hd : Γ k
tl : List (Γ k)
e : S k = hd :: tl
k' : K
i : ℕ
h' : ¬k' = k
h : ¬i = tl.length
neg : L.nth i k' = ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i
neg₁ :
  (ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k') L).nth i =
    ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i
neg₂ neg₃ :
  ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i =
    ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i
⊢ L.nth i k' =
    ListBlank.nth (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse)
      i

Tactic:
rw [Function.update_of_ne h', ← proj_map_nth, hL]

Premises used: Turing.proj_map_nth, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
k : K
q : TM1.Stmt (Γ' K Γ) (Λ' K Γ Λ σ) σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
f : σ → Option (Γ k) → σ
hd : Γ k
tl : List (Γ k)
e : S k = hd :: tl
k' : K
i : ℕ
h' : ¬k' = k
h : i = tl.length
pos pos₁ :
  ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i =
    ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i
⊢ ListBlank.nth (ListBlank.mk (List.map some (S k')).reverse) i =
    ListBlank.nth (ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (hd :: tl).tail k')).reverse)
      i

Tactic:
rw [Function.update_of_ne h']

Premises used: Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
H : 0 ≤ S.length
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }

Tactic:
rfl
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
succ :
  { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } ∈
    TM1.step (tr (Γ := Γ) M)
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }

Tactic:
apply (IH (le_of_lt H)).tail

Premises used: le_of_lt, StateTransition.Reaches₀.tail
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
succ :
  { l := some (go (Γ := Γ) k o q), var := v,
      Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } ∈
    TM1.step (tr (Γ := Γ) M)
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
⊢ { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } ∈
    TM1.step (tr (Γ := Γ) M)
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }

Tactic:
rw [iterate_succ_apply']

Premises used: Function.iterate_succ_apply'
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
succ :
  some
      (bif (L.nth n k).isNone then
        TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
          ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))
      else
        { l := some (go (Γ := Γ) k o q), var := v,
          Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }) =
    some
      { l := some (go (Γ := Γ) k o q), var := v,
        Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) }
⊢ { l := some (go (Γ := Γ) k o q), var := v,
      Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } ∈
    TM1.step (tr (Γ := Γ) M)
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }

Tactic:
simp only [TM1.step, TM1.stepAux, tr, Tape.mk'_nth_nat, Tape.move_right_n_head,
      addBottom_nth_snd, Option.mem_def]

Premises used: Turing.Tape.move_right_n_head, Turing.TM1.step, Turing.TM1.stepAux, Turing.Tape.mk'_nth_nat, Turing.TM2to1.tr, Turing.TM2to1.addBottom_nth_snd, Option.mem_def
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
succ :
  some
      (bif (some (getElem (valid := fun (as : List (Γ k)) (i : ℕ) ↦ i < as.length) S.reverse n ⋯)).isNone then
        TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
          ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))
      else
        { l := some (go (Γ := Γ) k o q), var := v,
          Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }) =
    some
      { l := some (go (Γ := Γ) k o q), var := v,
        Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) }
succ₁ : n < S.reverse.length
⊢ some
      (bif (L.nth n k).isNone then
        TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
          ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))
      else
        { l := some (go (Γ := Γ) k o q), var := v,
          Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }) =
    some
      { l := some (go (Γ := Γ) k o q), var := v,
        Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) }

Tactic:
rw [stk_nth_val _ hL, List.getElem?_eq_getElem]

Premises used: Turing.TM2to1.stk_nth_val, List.getElem?_eq_getElem
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
⊢ some
      (bif (some (getElem (valid := fun (as : List (Γ k)) (i : ℕ) ↦ i < as.length) S.reverse n ⋯)).isNone then
        TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
          ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))
      else
        { l := some (go (Γ := Γ) k o q), var := v,
          Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }) =
    some
      { l := some (go (Γ := Γ) k o q), var := v,
        Tape := Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))) }

Tactic:
rfl
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
IH :
  ∀ (H : n ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
H : n + 1 ≤ S.length
succ succ₁ succ₂ succ₃ : n < S.length
⊢ n < S.reverse.length

Tactic:
rwa [List.length_reverse]

Premises used: List.length_reverse
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
k : K
o : StAct K Γ σ k
q : TM2.Stmt Γ Λ σ
v : σ
S : List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hL : ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some S).reverse
n : ℕ
H : n ≤ S.length
zero :
  ∀ (H : 0 ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
succ :
  ∀ (n : ℕ)
    (IH :
      ∀ (H : n ≤ S.length),
        Reaches₀ (TM1.step (tr (Γ := Γ) M))
          { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
            TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
          { l := some (go (Γ := Γ) k o q), var := v,
            Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) })
    (H : n + 1 ≤ S.length),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
        TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (go (Γ := Γ) k o q), var := v,
        Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }

Tactic:
induction n with
  | zero => rfl
  | succ n IH =>
    apply (IH (le_of_lt H)).tail
    rw [iterate_succ_apply']
    simp only [TM1.step, TM1.stepAux, tr, Tape.mk'_nth_nat, Tape.move_right_n_head,
      addBottom_nth_snd, Option.mem_def]
    rw [stk_nth_val _ hL, List.getElem?_eq_getElem]
    · rfl
    · rwa [List.length_reverse]

Premises used: Function.iterate_succ_apply', Turing.Tape.move_right_n_head, Turing.TM2to1.stk_nth_val, List.length_reverse, Turing.TM1.step, Turing.TM1.stepAux, List.getElem?_eq_getElem, Turing.Tape.mk'_nth_nat, Turing.TM2to1.tr, Turing.TM2to1.addBottom_nth_snd, Option.mem_def
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[0] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[0] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }

Tactic:
rfl
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
n : ℕ
IH :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }

Tactic:
Reaches₀.head ?_ IH

Premises used: StateTransition.Reaches₀.head
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
n : ℕ
IH :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
succ :
  { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } ∈
    TM1.step (tr (Γ := Γ) M)
      { l := some (ret (Γ := Γ) q), var := v,
        Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }

Tactic:
refine Reaches₀.head ?_ IH

Premises used: StateTransition.Reaches₀.head
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
n : ℕ
IH :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
succ :
  (bif false then
      TM1.stepAux (trNormal (Γ := Γ) q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))))
    else
      TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) v
        ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))) =
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
⊢ some
      (TM1.stepAux (tr (Γ := Γ) M (ret (Γ := Γ) q)) v
        ((Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))) =
    some { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }

Tactic:
rw [Option.some_inj, tr, TM1.stepAux, Tape.move_right_n_head, Tape.mk'_nth_nat,
      addBottom_nth_succ_fst, TM1.stepAux, iterate_succ', Function.comp_apply, Tape.move_right_left]

Premises used: Turing.TM2to1.addBottom_nth_succ_fst, Turing.Tape.move_right_n_head, Function.iterate_succ', Turing.TM1.stepAux, Turing.Tape.move_right_left, Function.comp_apply, Turing.Tape.mk'_nth_nat, Option.some_inj, Turing.TM2to1.tr
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
n : ℕ
IH :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
⊢ (bif false then
      TM1.stepAux (trNormal (Γ := Γ) q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L))))
    else
      TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) v
        ((Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)))) =
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }

Tactic:
rfl
-- Module: Mathlib.Computability.TuringMachine.StackTuringMachine
Goal:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst : DecidableEq K
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
L : ListBlank ((k : K) → Option (Γ k))
n : ℕ
zero :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[0] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[0] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) }
succ :
  ∀ (n : ℕ)
    (IH :
      Reaches₀ (TM1.step (tr (Γ := Γ) M))
        { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
        { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }),
    Reaches₀ (TM1.step (tr (Γ := Γ) M))
      { l := some (ret (Γ := Γ) q), var := v,
        Tape := (Tape.move Dir.right)^[n + 1] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
      { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (ret (Γ := Γ) q), var := v, Tape := (Tape.move Dir.right)^[n] (Tape.mk' ∅ (addBottom (Γ := Γ) L)) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }

Tactic:
induction n with
  | zero => rfl
  | succ n IH =>
    refine Reaches₀.head ?_ IH
    simp only [Option.mem_def, TM1.step]
    rw [Option.some_inj, tr, TM1.stepAux, Tape.move_right_n_head, Tape.mk'_nth_nat,
      addBottom_nth_succ_fst, TM1.stepAux, iterate_succ', Function.comp_apply, Tape.move_right_left]
    rfl

Premises used: Turing.TM2to1.addBottom_nth_succ_fst, Turing.Tape.move_right_n_head, Function.iterate_succ', Turing.TM1.step, Turing.TM1.stepAux, Turing.Tape.move_right_left, Function.comp_apply, Turing.Tape.mk'_nth_nat, Option.some_inj, Turing.TM2to1.tr, Option.mem_def