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
M : Λ → TM2.Stmt Γ Λ σ
q : TM2.Stmt Γ Λ σ
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
simp :
  ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
    TrCfg (Γ := Γ)
        (TM2.stepAux (Γ := Γ) q (stVar (Γ := Γ) v (S k) o)
          (update (β := fun (k : K) ↦ List (Γ k)) S k (stWrite (Γ := Γ) v (S k) o)))
        b ∧
      Reaches (TM1.step (tr (Γ := Γ) M))
        (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ go (Γ := Γ) k o q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
⊢ ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
    TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) (stRun (Γ := Γ) o q) v S) b ∧
      Reaches (TM1.step (tr (Γ := Γ) M))
        (TM1.stepAux (trNormal (Γ := Γ) (stRun (Γ := Γ) o q)) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b

Tactic:
simp only [trNormal_run, step_run]

Premises used: Turing.TM2to1.trNormal_run, Turing.TM2to1.step_run
-- 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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
⊢ Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }

Tactic:
have hgo := tr_respects_aux₁ M o q v (hT k) _ le_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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
hgo :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }
obtain :
  ∀ (T' : ListBlank ((k : K) → Option (Γ k)))
    (hT' :
      ∀ (k_1 : K),
        ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k_1) T' =
          ListBlank.mk
            (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k_1)).reverse)
    (hrun :
      Eq (α := TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)
        (TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
          ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
        (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o)
          ((Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
            (Tape.mk' ∅ (addBottom (Γ := Γ) T'))))),
    ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
      TrCfg (Γ := Γ)
          (TM2.stepAux (Γ := Γ) q (stVar (Γ := Γ) v (S k) o)
            (update (β := fun (k : K) ↦ List (Γ k)) S k (stWrite (Γ := Γ) v (S k) o)))
          b ∧
        Reaches (TM1.step (tr (Γ := Γ) M))
          (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ go (Γ := Γ) k o q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
⊢ ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
    TrCfg (Γ := Γ)
        (TM2.stepAux (Γ := Γ) q (stVar (Γ := Γ) v (S k) o)
          (update (β := fun (k : K) ↦ List (Γ k)) S k (stWrite (Γ := Γ) v (S k) o)))
        b ∧
      Reaches (TM1.step (tr (Γ := Γ) M))
        (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ go (Γ := Γ) k o q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b

Tactic:
obtain ⟨T', hT', hrun⟩ := tr_respects_aux₂ (Λ := Λ) hT o

Premises used: Turing.TM2to1.tr_respects_aux₂
-- 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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
hgo :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }
T' : ListBlank ((k : K) → Option (Γ k))
hT' :
  ∀ (k_1 : K),
    ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k_1) T' =
      ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k_1)).reverse
hrun :
  Eq (α := TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)
    (TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
    (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o)
      ((Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
        (Tape.mk' ∅ (addBottom (Γ := Γ) T'))))
⊢ Reaches₁ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    (TM1.stepAux (tr (Γ := Γ) M (go (Γ := Γ) k o q)) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))

Tactic:
have := hgo.tail' 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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
hgo :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }
T' : ListBlank ((k : K) → Option (Γ k))
hT' :
  ∀ (k_1 : K),
    ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k_1) T' =
      ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k_1)).reverse
hrun :
  Eq (α := TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)
    (TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
    (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o)
      ((Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
        (Tape.mk' ∅ (addBottom (Γ := Γ) T'))))
this :
  Reaches₁ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    (TM1.stepAux (tr (Γ := Γ) M (go (Γ := Γ) k o q)) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
⊢ Reaches₁ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := stVar (Γ := Γ) v (S k) o,
      Tape :=
        (Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
          (Tape.mk' ∅ (addBottom (Γ := Γ) T')) }

Tactic:
rw [tr, TM1.stepAux, Tape.move_right_n_head, Tape.mk'_nth_nat, addBottom_nth_snd,
    stk_nth_val _ (hT k), List.getElem?_eq_none (le_of_eq List.length_reverse),
    Option.isNone, cond, hrun, TM1.stepAux] at this

Premises used: cond, Option.isNone, Turing.Tape.move_right_n_head, Turing.TM2to1.stk_nth_val, List.length_reverse, List.getElem?_eq_none, Turing.TM1.stepAux, Turing.Tape.mk'_nth_nat, le_of_eq, Turing.TM2to1.tr, Turing.TM2to1.addBottom_nth_snd
-- 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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
hgo :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }
T' : ListBlank ((k : K) → Option (Γ k))
hT' :
  ∀ (k_1 : K),
    ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k_1) T' =
      ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k_1)).reverse
hrun :
  Eq (α := TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)
    (TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
    (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o)
      ((Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
        (Tape.mk' ∅ (addBottom (Γ := Γ) T'))))
this :
  Reaches₁ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := stVar (Γ := Γ) v (S k) o,
      Tape :=
        (Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
          (Tape.mk' ∅ (addBottom (Γ := Γ) T')) }
c : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ
gc :
  TrCfg (Γ := Γ)
    (TM2.stepAux (Γ := Γ) q (stVar (Γ := Γ) v (S k) o)
      (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o)))
    c
rc :
  Reaches (TM1.step (tr (Γ := Γ) M))
    (TM1.stepAux (trNormal (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o) (Tape.mk' ∅ (addBottom (Γ := Γ) T'))) c
⊢ ReflTransGen (fun (a b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ) ↦ b ∈ TM1.step (tr (Γ := Γ) M) a)
    (bif true then TM1.stepAux (trNormal (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o) (Tape.mk' ∅ (addBottom (Γ := Γ) T'))
    else
      TM1.stepAux (move Dir.left (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q)) (stVar (Γ := Γ) v (S k) o)
        (Tape.mk' ∅ (addBottom (Γ := Γ) T')))
    c

Tactic:
rc

Premises used: cond, StateTransition.Reaches
-- 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 : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct K Γ σ k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K),
        ListBlank.map (proj (Γ := fun (i : K) ↦ Option (Γ i)) k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) q v S) b ∧
          Reaches (TM1.step (tr (Γ := Γ) M)) (TM1.stepAux (trNormal (Γ := Γ) q) v (Tape.mk' ∅ (addBottom (Γ := Γ) T))) b
hgo :
  Reaches₀ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (go (Γ := Γ) k o q), var := v,
      Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T)) }
T' : ListBlank ((k : K) → Option (Γ k))
hT' :
  ∀ (k_1 : K),
    ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k_1) T' =
      ListBlank.mk (List.map some (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k_1)).reverse
hrun :
  Eq (α := TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)
    (TM1.stepAux (trStAct (Γ := Γ) (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) o) v
      ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom (Γ := Γ) T))))
    (TM1.stepAux (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o)
      ((Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
        (Tape.mk' ∅ (addBottom (Γ := Γ) T'))))
this :
  Reaches₁ (TM1.step (tr (Γ := Γ) M))
    { l := some (go (Γ := Γ) k o q), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) T) :
      TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ }
    { l := some (ret (Γ := Γ) q), var := stVar (Γ := Γ) v (S k) o,
      Tape :=
        (Tape.move Dir.right)^[(update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o) k).length]
          (Tape.mk' ∅ (addBottom (Γ := Γ) T')) }
c : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ
gc :
  TrCfg (Γ := Γ)
    (TM2.stepAux (Γ := Γ) q (stVar (Γ := Γ) v (S k) o)
      (update (β := fun (a : K) ↦ List (Γ a)) S k (stWrite (Γ := Γ) v (S k) o)))
    c
rc :
  Reaches (TM1.step (tr (Γ := Γ) M))
    (TM1.stepAux (trNormal (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o) (Tape.mk' ∅ (addBottom (Γ := Γ) T'))) c
⊢ ReflTransGen (fun (a b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ) ↦ b ∈ TM1.step (tr (Γ := Γ) M) a)
    (bif true then TM1.stepAux (trNormal (Γ := Γ) q) (stVar (Γ := Γ) v (S k) o) (Tape.mk' ∅ (addBottom (Γ := Γ) T'))
    else
      TM1.stepAux (move Dir.left (goto fun (x : Γ' K Γ) (x_1 : σ) ↦ ret (Γ := Γ) q)) (stVar (Γ := Γ) v (S k) o)
        (Tape.mk' ∅ (addBottom (Γ := Γ) T')))
    c

Tactic:
exact rc
-- 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 Γ Λ σ
c₁ : TM2.Cfg Γ Λ σ
c₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ
h : TrCfg (Γ := Γ) c₁ c₂
none :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k)))
    (hT :
      ∀ (k : K),
        ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map Option.some (S k)).reverse),
    match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) Option.none v S) with
    | Option.some b₁ =>
      ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) b₁ b₂ ∧
          Reaches₁ (TM1.step (tr (Γ := Γ) M))
            { l := Option.map (normal (Γ := Γ)) Option.none, var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) } b₂
    | Option.none =>
      TM1.step (tr (Γ := Γ) M)
          { l := Option.map (normal (Γ := Γ)) Option.none, var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
            TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
        Option.none
some :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k)))
    (hT :
      ∀ (k : K),
        ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map Option.some (S k)).reverse)
    (l : Λ),
    match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) (Option.some l) v S) with
    | Option.some b₁ =>
      ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) b₁ b₂ ∧
          Reaches₁ (TM1.step (tr (Γ := Γ) M))
            { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
            b₂
    | Option.none =>
      TM1.step (tr (Γ := Γ) M)
          { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
            TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
        Option.none
⊢ match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M c₁ with
  | Option.some b₁ =>
    ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ), TrCfg (Γ := Γ) b₁ b₂ ∧ Reaches₁ (TM1.step (tr (Γ := Γ) M)) c₂ b₂
  | Option.none => TM1.step (tr (Γ := Γ) M) c₂ = Option.none

Tactic:
obtain @⟨- | l, v, S, L, hT⟩ := h
-- 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 Γ Λ σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
⊢ match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) none v S) with
  | some b₁ =>
    ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
      TrCfg (Γ := Γ) b₁ b₂ ∧
        Reaches₁ (TM1.step (tr (Γ := Γ) M))
          { l := Option.map (normal (Γ := Γ)) none, var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) } b₂
  | none =>
    TM1.step (tr (Γ := Γ) M)
        { l := Option.map (normal (Γ := Γ)) none, var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
      none

Tactic:
constructor
-- 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 Γ Λ σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT :
  ∀ (k : K),
    ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map Option.some (S k)).reverse
l : Λ
some :
  ∀ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ) (c : TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) (M l) v S) b)
    (r :
      Reaches (TM1.step (tr (Γ := Γ) M))
        (TM1.stepAux (tr (Γ := Γ) M (normal (Γ := Γ) l)) v (Tape.mk' ∅ (addBottom (Γ := Γ) L))) b),
    match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) (Option.some l) v S) with
    | Option.some b₁ =>
      ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
        TrCfg (Γ := Γ) b₁ b₂ ∧
          Reaches₁ (TM1.step (tr (Γ := Γ) M))
            { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) }
            b₂
    | none =>
      TM1.step (tr (Γ := Γ) M)
          { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
            TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
        none
rsuffices :
  ∃ (b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
    TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) (M l) v S) b ∧
      Reaches (TM1.step (tr (Γ := Γ) M))
        (TM1.stepAux (tr (Γ := Γ) M (normal (Γ := Γ) l)) v (Tape.mk' ∅ (addBottom (Γ := Γ) L))) b
⊢ match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) (Option.some l) v S) with
  | Option.some b₁ =>
    ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
      TrCfg (Γ := Γ) b₁ b₂ ∧
        Reaches₁ (TM1.step (tr (Γ := Γ) M))
          { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) } b₂
  | none =>
    TM1.step (tr (Γ := Γ) M)
        { l := Option.map (normal (Γ := Γ)) (Option.some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
      none

Tactic:
rsuffices ⟨b, c, r⟩ : ∃ b, _ ∧ Reaches (TM1.step (tr M)) _ _

Premises used: Turing.TM1.step, Turing.TM2to1.tr, StateTransition.Reaches
-- 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 Γ Λ σ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj (Γ := fun (k : K) ↦ Option (Γ k)) k) L = ListBlank.mk (List.map some (S k)).reverse
l : Λ
b : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ
c : TrCfg (Γ := Γ) (TM2.stepAux (Γ := Γ) (M l) v S) b
r :
  Reaches (TM1.step (tr (Γ := Γ) M))
    (TM1.stepAux (tr (Γ := Γ) M (normal (Γ := Γ) l)) v (Tape.mk' ∅ (addBottom (Γ := Γ) L))) b
⊢ match (motive := Option (TM2.Cfg Γ Λ σ) → Prop) TM2.step (Γ := Γ) M (TM2.Cfg.mk (Γ := Γ) (some l) v S) with
  | some b₁ =>
    ∃ (b₂ : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ),
      TrCfg (Γ := Γ) b₁ b₂ ∧
        Reaches₁ (TM1.step (tr (Γ := Γ) M))
          { l := Option.map (normal (Γ := Γ)) (some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) } b₂
  | none =>
    TM1.step (tr (Γ := Γ) M)
        { l := Option.map (normal (Γ := Γ)) (some l), var := v, Tape := Tape.mk' ∅ (addBottom (Γ := Γ) L) :
          TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ } =
      none

Tactic:
⟨b, c, TransGen.head' rfl r⟩

Premises used: Relation.TransGen.head', And.intro, Exists.intro, rfl