Theorem: Turing.PartrecToTM2.succ_ok
File: Mathlib/Computability/TMToPartrec.lean

tactic: simp [trNat, Num.add_one]
state_before: q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trList [n]) [] c d }
    { l := some q, var := none, stk := elim (trList [Nat.succ n]) [] c d }

tactic: cases' (n : Num) with a
state_before: q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trNum ↑n ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trNum (Num.succ ↑n) ++ [Γ'.cons]) [] c d }

tactic: simp [Num.succ, trNum, Num.succ']
state_before: case pos
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trNum (Num.pos a) ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trNum (Num.succ (Num.pos a)) ++ [Γ'.cons]) [] c d }

tactic: suffices ∀ l₁, ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum a.succ) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr) ⟨some q.succ, s, K'.elim (trPosNum a ++ [Γ'.cons]) l₁ c d⟩
        ⟨some (unrev q), s', K'.elim (l₂' ++ [Γ'.cons]) l₁' c d⟩ by
  obtain ⟨l₁', l₂', s', e, h⟩ := this []
  simp [List.reverseAux] at e
  refine' h.trans _
  convert unrev_ok using 2
  simp [e, List.reverseAux_eq]
state_before: case pos
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d }

tactic: induction' a with m IH m _ generalizing s <;> intro l₁
state_before: case pos
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
⊢ ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }

tactic: refine' TransGen.head rfl _
state_before: case zero
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trNum Num.zero ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trNum (Num.succ Num.zero) ++ [Γ'.cons]) [] c d }

tactic: simp
state_before: case zero
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ TransGen
    (fun a b =>
      b ∈
        (fun x =>
            match x with
            | { l := none, var := var, stk := stk } => none
            | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
          a)
    (TM2.stepAux (tr (Λ'.succ q)) s (elim (trNum Num.zero ++ [Γ'.cons]) [] c d))
    { l := some q, var := none, stk := elim (trNum (Num.succ Num.zero) ++ [Γ'.cons]) [] c d }

tactic: convert unrev_ok using 2
state_before: case zero
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ TransGen
    (fun a b =>
      (match a with
        | { l := none, var := var, stk := stk } => none
        | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S)) =
        some b)
    { l := some (unrev q), var := List.head? (trNum Num.zero ++ [Γ'.cons]),
      stk := elim (Γ'.bit1 :: Γ'.cons :: List.tail (trNum Num.zero ++ [Γ'.cons])) [] c d }
    { l := some q, var := none, stk := elim (trNum (Num.succ Num.zero) ++ [Γ'.cons]) [] c d }

tactic: simp
state_before: case h.e'_2.h.e'_7
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ elim (trNum (Num.succ Num.zero) ++ [Γ'.cons]) [] c d =
    update (update (elim (Γ'.bit1 :: Γ'.cons :: List.tail (trNum Num.zero ++ [Γ'.cons])) [] c d) rev []) main
      (List.reverseAux (elim (Γ'.bit1 :: Γ'.cons :: List.tail (trNum Num.zero ++ [Γ'.cons])) [] c d rev)
        (elim (Γ'.bit1 :: Γ'.cons :: List.tail (trNum Num.zero ++ [Γ'.cons])) [] c d main))

tactic: rfl
state_before: case h.e'_2.h.e'_7
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
⊢ elim (trNum (Num.succ Num.zero) ++ [Γ'.cons]) [] c d =
    elim (Γ'.bit1 :: Γ'.cons :: List.tail (trNum Num.zero ++ [Γ'.cons])) [] c d

tactic: obtain ⟨l₁', l₂', s', e, h⟩ := this []
state_before: q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d }

tactic: simp [List.reverseAux] at e
state_before: case intro.intro.intro.intro
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux [] (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d }

tactic: refine' h.trans _
state_before: case intro.intro.intro.intro
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum (PosNum.succ a) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ Reaches₁
    (fun x =>
      match x with
      | { l := none, var := var, stk := stk } => none
      | { l := some l, var := v, stk := S } => some (TM2.stepAux (tr l) v S))
    { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some q, var := none, stk := elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d }

tactic: convert unrev_ok using 2
state_before: case intro.intro.intro.intro
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum (PosNum.succ a) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ TransGen (fun a b => b ∈ TM2.step tr a) { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
    { l := some q, var := none, stk := elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d }

tactic: simp [e, List.reverseAux_eq]
state_before: case h.e'_2.h.e'_7
q : Λ'
s : Option Γ'
n : ℕ
c d : List Γ'
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ a)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum (PosNum.succ a) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum a ++ [Γ'.cons]) [] c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ elim (trPosNum (PosNum.succ a) ++ [Γ'.cons]) [] c d =
    update (update (elim (l₂' ++ [Γ'.cons]) l₁' c d) rev []) main
      (List.reverseAux (elim (l₂' ++ [Γ'.cons]) l₁' c d rev) (elim (l₂' ++ [Γ'.cons]) l₁' c d main))

tactic: refine' ⟨Γ'.bit0 :: l₁, [Γ'.bit1], some Γ'.cons, rfl, TransGen.head rfl (TransGen.single _)⟩
state_before: case pos.one
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.succ PosNum.one)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum PosNum.one ++ [Γ'.cons]) l₁ c d }
        { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }

tactic: simp [trPosNum]
state_before: case pos.one
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
s : Option Γ'
l₁ : List Γ'
⊢ { l := some (unrev q), var := some Γ'.cons, stk := elim ([Γ'.bit1] ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d } ∈
    TM2.step tr (TM2.stepAux (tr (Λ'.succ q)) s (elim (trPosNum PosNum.one ++ [Γ'.cons]) l₁ c d))

tactic: obtain ⟨l₁', l₂', s', e, h⟩ := IH (Γ'.bit0 :: l₁)
state_before: case pos.bit1
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.succ (PosNum.bit1 m))) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit1 m) ++ [Γ'.cons]) l₁ c d }
        { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }

tactic: refine' ⟨l₁', l₂', s', e, TransGen.head _ h⟩
state_before: case pos.bit1.intro.intro.intro.intro
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit0 :: l₁) (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.succ q), var := ?m.513910, stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.succ (PosNum.bit1 m))) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit1 m) ++ [Γ'.cons]) l₁ c d }
        { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }

tactic: swap
state_before: case pos.bit1.intro.intro.intro.intro.refine'_1
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ Option Γ'

case pos.bit1.intro.intro.intro.intro.refine'_2
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit0 :: l₁) (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.succ q), var := ?pos.bit1.intro.intro.intro.intro.refine'_1,
      stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ { l := some (Λ'.succ q), var := ?pos.bit1.intro.intro.intro.intro.refine'_1,
      stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d } ∈
    TM2.step tr { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit1 m) ++ [Γ'.cons]) l₁ c d }

tactic: simp [PosNum.succ, trPosNum]
state_before: case pos.bit1.intro.intro.intro.intro.refine'_2
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit0 :: l₁) (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.succ q), var := ?pos.bit1.intro.intro.intro.intro.refine'_1,
      stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ { l := some (Λ'.succ q), var := ?pos.bit1.intro.intro.intro.intro.refine'_1,
      stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d } ∈
    TM2.step tr { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit1 m) ++ [Γ'.cons]) l₁ c d }

case pos.bit1.intro.intro.intro.intro.refine'_1
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ Option Γ'

tactic: rfl
state_before: case pos.bit1.intro.intro.intro.intro.refine'_2
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit0 :: l₁) (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.succ q), var := ?pos.bit1.intro.intro.intro.intro.refine'_1,
      stk := elim (trPosNum m ++ [Γ'.cons]) (Γ'.bit0 :: l₁) c d }
    { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
⊢ some Γ'.bit1 = ?pos.bit1.intro.intro.intro.intro.refine'_1

case pos.bit1.intro.intro.intro.intro.refine'_1
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
IH :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ Option Γ'

tactic: refine' ⟨l₁, _, some Γ'.bit0, rfl, TransGen.single _⟩
state_before: case pos.bit0
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
a_ih✝ :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.succ (PosNum.bit0 m))) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]) l₁ c d }
        { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }

tactic: simp
state_before: case pos.bit0
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
a_ih✝ :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ { l := some (unrev q), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ [Γ'.cons]) l₁ c d } ∈
    TM2.step tr { l := some (Λ'.succ q), var := s, stk := elim (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]) l₁ c d }

tactic: rfl
state_before: case pos.bit0
q : Λ'
s✝ : Option Γ'
n : ℕ
c d : List Γ'
m : PosNum
a_ih✝ :
  ∀ {s : Option Γ'} (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum (PosNum.succ m)) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr) { l := some (Λ'.succ q), var := s, stk := elim (trPosNum m ++ [Γ'.cons]) l₁ c d }
          { l := some (unrev q), var := s', stk := elim (l₂' ++ [Γ'.cons]) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ (bif decide (List.head? (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]) = some Γ'.bit1) then
      { l := some (Λ'.succ q), var := List.head? (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]),
        stk := elim (List.tail (trPosNum (PosNum.bit0 m) ++ [Γ'.cons])) (Γ'.bit0 :: l₁) c d }
    else
      bif decide (List.head? (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]) = some Γ'.cons) then
        { l := some (unrev q), var := List.head? (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]),
          stk := elim (Γ'.bit1 :: Γ'.cons :: List.tail (trPosNum (PosNum.bit0 m) ++ [Γ'.cons])) l₁ c d }
      else
        { l := some (unrev q), var := List.head? (trPosNum (PosNum.bit0 m) ++ [Γ'.cons]),
          stk := elim (Γ'.bit1 :: List.tail (trPosNum (PosNum.bit0 m) ++ [Γ'.cons])) l₁ c d }) =
    { l := some (unrev q), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ [Γ'.cons]) l₁ c d }