Theorem: Turing.TM2to1.tr_respects_aux
File: Mathlib/Computability/TuringMachine.lean

tactic: simp only [trNormal_run, step_run]
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        TrCfg (TM2.stepAux q v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) v (Tape.mk' ∅ (addBottom T))) b
⊢ ∃ b,
    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
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        TrCfg (TM2.stepAux q v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) v (Tape.mk' ∅ (addBottom T))) b
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: have hgo := tr_respects_aux₁ M o q v (hT k) _ le_rfl
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        TrCfg (TM2.stepAux q v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) v (Tape.mk' ∅ (addBottom T))) b
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { l := some (go k o q), var := v, Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)) }
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: obtain ⟨T', hT', hrun⟩ := tr_respects_aux₂ hT o
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { l := some (go k o q), var := v, Tape := (Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)) }
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite ?m.384010 (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct ?m.384009 o) ?m.384010 ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux ?m.384009 (stVar ?m.384010 (S k) o)
      ((Tape.move Dir.right)^[(update S k (stWrite ?m.384010 (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: have := hgo.tail' rfl
state_before: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite ?m.384010 (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct ?m.384009 o) ?m.384010 ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux ?m.384009 (stVar ?m.384010 (S k) o)
      ((Tape.move Dir.right)^[(update S k (stWrite ?m.384010 (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite ?m.384010 (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct ?m.384009 o) ?m.384010 ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux ?m.384009 (stVar ?m.384010 (S k) o)
      ((Tape.move Dir.right)^[(update S k (stWrite ?m.384010 (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.stepAux (tr M (go k o q)) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: rw [tr, TM1.stepAux, Tape.move_right_n_head, Tape.mk'_nth_nat, addBottom_nth_snd,
  stk_nth_val _ (hT k), List.get?_len_le (le_of_eq (List.length_reverse _)), Option.isNone, cond,
  hrun, TM1.stepAux] at this
state_before: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite ?m.384010 (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct ?m.384009 o) ?m.384010 ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux ?m.384009 (stVar ?m.384010 (S k) o)
      ((Tape.move Dir.right)^[(update S k (stWrite ?m.384010 (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.stepAux (tr M (go k o q)) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: obtain ⟨c, gc, rc⟩ := IH hT'
state_before: case intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q ?m.387675 (update S k (stWrite v (S k) o))) c
rc : Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) ?m.387675 (Tape.mk' ∅ (addBottom T'))) c
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b

tactic: refine ⟨c, gc, (this.to₀.trans (tr_respects_aux₃ M _) c (TransGen.head' rfl ?_)).to_reflTransGen⟩
state_before: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q ?m.387675 (update S k (stWrite v (S k) o))) c
rc : Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) ?m.387675 (Tape.mk' ∅ (addBottom T'))) c
⊢ ∃ b,
    TrCfg (TM2.stepAux q (stVar v (S k) o) (update S k (stWrite v (S k) o))) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (goto fun x x => go k o q) v (Tape.mk' ∅ (addBottom T))) b
state_after: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q (stVar v (S k) o) (update 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 => b ∈ TM1.step (tr M) a)
    (TM1.stepAux (tr M (ret q)) (stVar v (S k) o) (Tape.mk' ∅ (addBottom T'))) c

tactic: rw [tr, TM1.stepAux, Tape.mk'_head, addBottom_head_fst]
state_before: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q (stVar v (S k) o) (update 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 => b ∈ TM1.step (tr M) a)
    (TM1.stepAux (tr M (ret q)) (stVar v (S k) o) (Tape.mk' ∅ (addBottom T'))) c
state_after: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q (stVar v (S k) o) (update 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 => 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 x => ret q)) (stVar v (S k) o) (Tape.mk' ∅ (addBottom T')))
    c

tactic: exact rc
state_before: case intro.intro.intro.intro
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
q : Stmt₂
v : σ
T : ListBlank ((i : K) → Option (Γ i))
k : K
S : (k : K) → List (Γ k)
hT : ∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse
o : StAct k
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} {T : ListBlank ((k : K) → Option (Γ k))},
    (∀ (k : K), ListBlank.map (proj k) T = ListBlank.mk (List.map some (S k)).reverse) →
      ∃ b,
        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) }
    { 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 k_1) T' = ListBlank.mk (List.map some (update S k (stWrite v (S k) o) k_1)).reverse
hrun :
  TM1.stepAux (trStAct (goto fun x x => ret q) o) v ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T))) =
    TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
      ((Tape.move Dir.right)^[(update 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) }
    (match
      match none with
      | some val => false
      | none => true with
    | true =>
      TM1.stepAux (goto fun x x => ret q) (stVar v (S k) o)
        ((Tape.move Dir.right)^[(update S k (stWrite v (S k) o) k).length] (Tape.mk' ∅ (addBottom T')))
    | false =>
      TM1.stepAux (goto fun x x => go k o q) v
        (Tape.move Dir.right ((Tape.move Dir.right)^[(S k).length] (Tape.mk' ∅ (addBottom T)))))
c : TM1.Cfg Γ' Λ' σ
gc : TrCfg (TM2.stepAux q (stVar v (S k) o) (update 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 => 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 x => ret q)) (stVar v (S k) o) (Tape.mk' ∅ (addBottom T')))
    c
state_after: no goals