l3lab/ntp-mathlib huggingface dataset:
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> 

Proof state:
case intro.succ
f g : Code
IHf :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
IHg :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal g k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal g (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s s' : Option Γ'
n : ℕ
⊢ Reaches₁ (TM2.step tr)
      { l := some (Λ'.pred ?m.611874 ?m.611875), var := s, stk := elim (trList v) [] ?m.611876 ?m.611877 }
      (Nat.rec { l := some ?m.611874, var := s', stk := elim (trList (List.tail v)) [] ?m.611876 ?m.611877 }
        (fun n x => { l := some ?m.611875, var := s', stk := elim (trList (n :: List.tail v)) [] ?m.611876 ?m.611877 })
        (Nat.succ n)) →
    ∃ b₂,
      TrCfg (Nat.rec (stepNormal f k (List.tail v)) (fun y x => stepNormal g k (y :: List.tail v)) (Nat.succ n)) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal (Code.case f g) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
intro h
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · 

Proof state:
case intro.zero
f g : Code
IHf :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
IHg :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal g k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal g (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s s' : Option Γ'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred ?m.611874 ?m.611875), var := s, stk := elim (trList v) [] ?m.611876 ?m.611877 }
    (Nat.rec { l := some ?m.611874, var := s', stk := elim (trList (List.tail v)) [] ?m.611876 ?m.611877 }
      (fun n x => { l := some ?m.611875, var := s', stk := elim (trList (n :: List.tail v)) [] ?m.611876 ?m.611877 })
      Nat.zero)
⊢ ∃ b₂,
    TrCfg (Nat.rec (stepNormal f k (List.tail v)) (fun y x => stepNormal g k (y :: List.tail v)) Nat.zero) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.case f g) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      

Proof state:
case intro.zero.intro.intro
f g : Code
IHf :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
IHg :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal g k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal g (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s s' : Option Γ'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred ?m.611874 ?m.611875), var := s, stk := elim (trList v) [] ?m.611876 ?m.611877 }
    (Nat.rec { l := some ?m.611874, var := s', stk := elim (trList (List.tail v)) [] ?m.611876 ?m.611877 }
      (fun n x => { l := some ?m.611875, var := s', stk := elim (trList (n :: List.tail v)) [] ?m.611876 ?m.611877 })
      Nat.zero)
c : Cfg'
h₁ : TrCfg (stepNormal f k ?m.612007) c
h₂ :
  Reaches₁ (TM2.step tr)
    { l := some (trNormal f (trCont k)), var := s', stk := elim (trList ?m.612007) [] [] (trContStack k) } c
⊢ ∃ b₂,
    TrCfg (Nat.rec (stepNormal f k (List.tail v)) (fun y x => stepNormal g k (y :: List.tail v)) Nat.zero) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.case f g) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
exact ⟨_, h₁, h.trans h₂⟩
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
    · 

Proof state:
case intro.succ
f g : Code
IHf :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
IHg :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal g k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal g (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s s' : Option Γ'
n : ℕ
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred (trNormal f (trCont k)) (trNormal g (trCont k))), var := s,
      stk := elim (trList v) [] [] (trContStack k) }
    (Nat.rec { l := some (trNormal f (trCont k)), var := s', stk := elim (trList (List.tail v)) [] [] (trContStack k) }
      (fun n x =>
        { l := some (trNormal g (trCont k)), var := s', stk := elim (trList (n :: List.tail v)) [] [] (trContStack k) })
      (Nat.succ n))
⊢ ∃ b₂,
    TrCfg (Nat.rec (stepNormal f k (List.tail v)) (fun y x => stepNormal g k (y :: List.tail v)) (Nat.succ n)) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.case f g) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
    · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
      

Proof state:
case intro.succ.intro.intro
f g : Code
IHf :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
IHg :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal g k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal g (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s s' : Option Γ'
n : ℕ
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred (trNormal f (trCont k)) (trNormal g (trCont k))), var := s,
      stk := elim (trList v) [] [] (trContStack k) }
    (Nat.rec { l := some (trNormal f (trCont k)), var := s', stk := elim (trList (List.tail v)) [] [] (trContStack k) }
      (fun n x =>
        { l := some (trNormal g (trCont k)), var := s', stk := elim (trList (n :: List.tail v)) [] [] (trContStack k) })
      (Nat.succ n))
c : Cfg'
h₁ : TrCfg (stepNormal g k ?m.612131) c
h₂ :
  Reaches₁ (TM2.step tr)
    { l := some (trNormal g (trCont k)), var := s', stk := elim (trList ?m.612131) [] [] (trContStack k) } c
⊢ ∃ b₂,
    TrCfg (Nat.rec (stepNormal f k (List.tail v)) (fun y x => stepNormal g k (y :: List.tail v)) (Nat.succ n)) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.case f g) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
exact ⟨_, h₁, h.trans h₂⟩
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
    · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
  

Proof state:
case fix
a✝ : Code
a_ih✝ :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal a✝ k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal a✝ (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepNormal (Code.fix a✝) k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.fix a✝) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
case fix f IH => apply IH
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
    · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
  

Proof state:
f : Code
IH :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepNormal (Code.fix f) k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.fix f) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
case fix f IH => apply IH
theorem trNormal_respects (c k v s) :
    ∃ b₂,
      TrCfg (stepNormal c k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          ⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction c generalizing k v s
  case zero' => refine' ⟨_, ⟨s, rfl⟩, TransGen.single _⟩; simp
  case succ => refine' ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩
  case tail =>
    let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons
    refine' ⟨_, ⟨o, rfl⟩, _⟩; convert clear_ok _ using 2; simp; rfl; swap
    refine' splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) _
    cases v <;> simp
  case
    cons f fs IHf _ =>
    obtain ⟨c, h₁, h₂⟩ := IHf (Cont.cons₁ fs v k) v none
    refine' ⟨c, h₁, TransGen.head rfl <| (move_ok (by decide) (splitAtPred_false _)).trans _⟩
    simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, ne_eq,
      Function.update_noteq, elim_main, elim_rev, elim_update_rev]
    refine' (copy_ok _ none [] (trList v).reverse _ _).trans _
    convert h₂ using 2
    simp [List.reverseAux_eq, trContStack]
  case comp f _ _ IHg => exact IHg (Cont.comp f k) v s
  case case f g IHf IHg =>
    rw [stepNormal]
    simp only
    obtain ⟨s', h⟩ := pred_ok _ _ s v _ _
    revert h; cases' v.headI with n <;> intro h
    · obtain ⟨c, h₁, h₂⟩ := IHf k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
    · obtain ⟨c, h₁, h₂⟩ := IHg k _ s'
      exact ⟨_, h₁, h.trans h₂⟩
  case fix f IH => 

Proof state:
f : Code
IH :
  ∀ (k : Cont) (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepNormal f k v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (trNormal f (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂
k : Cont
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepNormal (Code.fix f) k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (trNormal (Code.fix f) (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) } b₂

Next tactic:
apply IH
theorem tr_ret_respects (k v s) : ∃ b₂,
    TrCfg (stepRet k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        ⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  

Proof state:
k : Cont
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet k v) b₂ ∧
      Reaches₁ (TM2.step tr) { l := some (Λ'.ret (trCont k)), var := s, stk := elim (trList v) [] [] (trContStack k) }
        b₂

Next tactic:
induction k generalizing v s
theorem tr_ret_respects (k v s) : ∃ b₂,
    TrCfg (stepRet k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        ⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction k generalizing v s
  

Proof state:
case halt
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet Cont.halt v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont Cont.halt)), var := s, stk := elim (trList v) [] [] (trContStack Cont.halt) } b₂
case cons₁
a✝² : Code
a✝¹ : List ℕ
a✝ : Cont
a_ih✝ :
  ∀ (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepRet a✝ v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.ret (trCont a✝)), var := s, stk := elim (trList v) [] [] (trContStack a✝) } b₂
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet (Cont.cons₁ a✝² a✝¹ a✝) v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont (Cont.cons₁ a✝² a✝¹ a✝))), var := s,
          stk := elim (trList v) [] [] (trContStack (Cont.cons₁ a✝² a✝¹ a✝)) }
        b₂
case cons₂
a✝¹ : List ℕ
a✝ : Cont
a_ih✝ :
  ∀ (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepRet a✝ v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.ret (trCont a✝)), var := s, stk := elim (trList v) [] [] (trContStack a✝) } b₂
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet (Cont.cons₂ a✝¹ a✝) v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont (Cont.cons₂ a✝¹ a✝))), var := s,
          stk := elim (trList v) [] [] (trContStack (Cont.cons₂ a✝¹ a✝)) }
        b₂
case comp
a✝¹ : Code
a✝ : Cont
a_ih✝ :
  ∀ (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepRet a✝ v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.ret (trCont a✝)), var := s, stk := elim (trList v) [] [] (trContStack a✝) } b₂
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet (Cont.comp a✝¹ a✝) v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont (Cont.comp a✝¹ a✝))), var := s,
          stk := elim (trList v) [] [] (trContStack (Cont.comp a✝¹ a✝)) }
        b₂
case fix
a✝¹ : Code
a✝ : Cont
a_ih✝ :
  ∀ (v : List ℕ) (s : Option Γ'),
    ∃ b₂,
      TrCfg (stepRet a✝ v) b₂ ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.ret (trCont a✝)), var := s, stk := elim (trList v) [] [] (trContStack a✝) } b₂
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet (Cont.fix a✝¹ a✝) v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont (Cont.fix a✝¹ a✝))), var := s,
          stk := elim (trList v) [] [] (trContStack (Cont.fix a✝¹ a✝)) }
        b₂

Next tactic:
case halt => exact ⟨_, rfl, TransGen.single rfl⟩
theorem tr_ret_respects (k v s) : ∃ b₂,
    TrCfg (stepRet k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        ⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction k generalizing v s
  

Proof state:
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet Cont.halt v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont Cont.halt)), var := s, stk := elim (trList v) [] [] (trContStack Cont.halt) } b₂

Next tactic:
case halt => exact ⟨_, rfl, TransGen.single rfl⟩
theorem tr_ret_respects (k v s) : ∃ b₂,
    TrCfg (stepRet k v) b₂ ∧
      Reaches₁ (TM2.step tr)
        ⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
  induction k generalizing v s
  case halt => 

Proof state:
v : List ℕ
s : Option Γ'
⊢ ∃ b₂,
    TrCfg (stepRet Cont.halt v) b₂ ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.ret (trCont Cont.halt)), var := s, stk := elim (trList v) [] [] (trContStack Cont.halt) } b₂

Next tactic:
exact ⟨_, rfl, TransGen.single rfl⟩