case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList []) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail [])) [] c d }
        (fun n x => { l := some q₂, var := s', stk := elim (trList (n :: List.tail [])) [] c d }) (List.headI []))

case cons.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.zero :: v)) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail (Nat.zero :: v))) [] c d }
        (fun n x => { l := some q₂, var := s', stk := elim (trList (n :: List.tail (Nat.zero :: v))) [] c d })
        (List.headI (Nat.zero :: v)))

case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.succ n :: v)) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail (Nat.succ n :: v))) [] c d }
        (fun n_1 x => { l := some q₂, var := s', stk := elim (trList (n_1 :: List.tail (Nat.succ n :: v))) [] c d })
        (List.headI (Nat.succ n :: v)))
q₁ q₂ : Λ'
s : Option Γ'
v : List ℕ
c d : List Γ'
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList v) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail v)) [] c d }
        (fun n x => { l := some q₂, var := s', stk := elim (trList (n :: List.tail v)) [] c d }) (List.headI v))
rcases v with (_ | ⟨_ | n, v⟩)
case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.succ n :: v)) [] c d }
    (Nat.rec { l := some q₁, var := none, stk := elim (trList (List.tail (Nat.succ n :: v))) [] c d }
      (fun n_1 x => { l := some q₂, var := none, stk := elim (trList (n_1 :: List.tail (Nat.succ n :: v))) [] c d })
      (List.headI (Nat.succ n :: v)))
case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.succ n :: v)) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail (Nat.succ n :: v))) [] c d }
        (fun n_1 x => { l := some q₂, var := s', stk := elim (trList (n_1 :: List.tail (Nat.succ n :: v))) [] c d })
        (List.headI (Nat.succ n :: v)))
refine' ⟨none, _⟩
case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (Num.succ' ↑n) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match ↑n with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }
case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.succ n :: v)) [] c d }
    (Nat.rec { l := some q₁, var := none, stk := elim (trList (List.tail (Nat.succ n :: v))) [] c d }
      (fun n_1 x => { l := some q₂, var := none, stk := elim (trList (n_1 :: List.tail (Nat.succ n :: v))) [] c d })
      (List.headI (Nat.succ n :: v)))
simp [trNat, Num.add_one, Num.succ, trNum]
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (Num.succ' Num.zero) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match Num.zero with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }

case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
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 (Λ'.pred q₁ q₂), var := s,
      stk := elim (trPosNum (Num.succ' (Num.pos a)) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match Num.pos a with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }
case cons.succ
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (Num.succ' ↑n) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match ↑n with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }
cases' (n : Num) with a
case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
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 (Λ'.pred q₁ q₂), var := s,
      stk := elim (trPosNum (Num.succ' (Num.pos a)) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match Num.pos a with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }
simp [trNum, Num.succ']
case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
⊢ ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
suffices ∀ l₁, ∃ l₁' l₂' s',
  List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
    Reaches₁ (TM2.step tr)
      ⟨some (q₁.pred q₂), s, K'.elim (trPosNum a.succ ++ Γ'.cons :: trList v) l₁ c d⟩
      ⟨some (unrev q₂), s', K'.elim (l₂' ++ Γ'.cons :: trList v) 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]
case cons.succ.pos.one
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum PosNum.one) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ PosNum.one) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }

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

case cons.succ.pos.bit0
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit0 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
case cons.succ.pos
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
⊢ ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
induction' a with m IH m IH generalizing s <;> intro l₁
case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ Nat.rec { l := some q₁, var := none, stk := elim (trList (List.tail [])) [] c d }
      (fun n x => { l := some q₂, var := none, stk := elim (trList (n :: List.tail [])) [] c d }) (List.headI []) ∈
    TM2.step tr { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList []) [] c d }
case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList []) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail [])) [] c d }
        (fun n x => { l := some q₂, var := s', stk := elim (trList (n :: List.tail [])) [] c d }) (List.headI []))
refine' ⟨none, TransGen.single _⟩
case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ { l := some q₁, var := none, stk := elim [] [] c d } =
    Nat.rec { l := some q₁, var := none, stk := elim [] [] c d }
      (fun n x => { l := some q₂, var := none, stk := elim (trNat n ++ [Γ'.cons]) [] c d }) default
case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ Nat.rec { l := some q₁, var := none, stk := elim (trList (List.tail [])) [] c d }
      (fun n x => { l := some q₂, var := none, stk := elim (trList (n :: List.tail [])) [] c d }) (List.headI []) ∈
    TM2.step tr { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList []) [] c d }
simp
no goals
case nil
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
⊢ { l := some q₁, var := none, stk := elim [] [] c d } =
    Nat.rec { l := some q₁, var := none, stk := elim [] [] c d }
      (fun n x => { l := some q₂, var := none, stk := elim (trNat n ++ [Γ'.cons]) [] c d }) default
rfl
case cons.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
⊢ Nat.rec { l := some q₁, var := some Γ'.cons, stk := elim (trList (List.tail (Nat.zero :: v))) [] c d }
      (fun n x => { l := some q₂, var := some Γ'.cons, stk := elim (trList (n :: List.tail (Nat.zero :: v))) [] c d })
      (List.headI (Nat.zero :: v)) ∈
    TM2.step tr { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.zero :: v)) [] c d }
case cons.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
⊢ ∃ s',
    Reaches₁ (TM2.step tr) { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.zero :: v)) [] c d }
      (Nat.rec { l := some q₁, var := s', stk := elim (trList (List.tail (Nat.zero :: v))) [] c d }
        (fun n x => { l := some q₂, var := s', stk := elim (trList (n :: List.tail (Nat.zero :: v))) [] c d })
        (List.headI (Nat.zero :: v)))
refine' ⟨some Γ'.cons, TransGen.single _⟩
no goals
case cons.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
⊢ Nat.rec { l := some q₁, var := some Γ'.cons, stk := elim (trList (List.tail (Nat.zero :: v))) [] c d }
      (fun n x => { l := some q₂, var := some Γ'.cons, stk := elim (trList (n :: List.tail (Nat.zero :: v))) [] c d })
      (List.headI (Nat.zero :: v)) ∈
    TM2.step tr { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trList (Nat.zero :: v)) [] c d }
simp
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (Γ'.bit1 :: Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (Num.succ' Num.zero) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none,
      stk :=
        elim
          ((match Num.zero with
            | Num.zero => []
            | Num.pos n => trPosNum n) ++
            Γ'.cons :: trList v)
          [] c d }
simp [trPosNum, trNum, show Num.zero.succ' = PosNum.one from rfl]
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂)) s (elim (Γ'.bit1 :: Γ'.cons :: trList v) [] c d))
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂), var := s, stk := elim (Γ'.bit1 :: Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
refine' TransGen.head rfl _
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 := some Γ'.cons, stk := elim (Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 (Λ'.pred q₁ q₂)) s (elim (Γ'.bit1 :: Γ'.cons :: trList v) [] c d))
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
simp
case h.e'_2.h.e'_7
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ elim (Γ'.cons :: trList v) [] c d =
    update (update (elim (Γ'.cons :: trList v) [] c d) rev []) main
      (List.reverseAux (elim (Γ'.cons :: trList v) [] c d rev) (elim (Γ'.cons :: trList v) [] c d main))
case cons.succ.zero
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ 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 := some Γ'.cons, stk := elim (Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (Γ'.cons :: trList v) [] c d }
convert unrev_ok using 2
no goals
case h.e'_2.h.e'_7
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
⊢ elim (Γ'.cons :: trList v) [] c d =
    update (update (elim (Γ'.cons :: trList v) [] c d) rev []) main
      (List.reverseAux (elim (Γ'.cons :: trList v) [] c d rev) (elim (Γ'.cons :: trList v) [] c d main))
simp
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux [] (trPosNum a) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
obtain ⟨l₁', l₂', s', e, h⟩ := this []
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux [] (trPosNum a) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
simp [List.reverseAux] at e
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ TransGen (fun a b => b ∈ TM2.step tr a)
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) 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 (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
refine' h.trans _
case h.e'_2.h.e'_7
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ elim (trPosNum a ++ Γ'.cons :: trList v) [] c d =
    update (update (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d) rev []) main
      (List.reverseAux (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d rev) (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d main))
case intro.intro.intro.intro
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ TransGen (fun a b => b ∈ TM2.step tr a)
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
    { l := some q₂, var := none, stk := elim (trPosNum a ++ Γ'.cons :: trList v) [] c d }
convert unrev_ok using 2
no goals
case h.e'_2.h.e'_7
q₁ q₂ : Λ'
s : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
a : PosNum
this :
  ∀ (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum a) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
l₁' l₂' : List Γ'
s' : Option Γ'
e : trPosNum a = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ a) ++ Γ'.cons :: trList v) [] c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ elim (trPosNum a ++ Γ'.cons :: trList v) [] c d =
    update (update (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d) rev []) main
      (List.reverseAux (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d rev) (elim (l₂' ++ Γ'.cons :: trList v) l₁' c d main))
simp [e, List.reverseAux_eq]
case cons.succ.pos.one
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
s : Option Γ'
l₁ : List Γ'
⊢ { l := some (unrev q₂), var := some Γ'.cons, stk := elim ([] ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d } ∈
    TM2.step tr
      (TM2.stepAux (tr (Λ'.pred q₁ q₂)) s (elim (trPosNum (PosNum.succ PosNum.one) ++ Γ'.cons :: trList v) l₁ c d))
case cons.succ.pos.one
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum PosNum.one) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ PosNum.one) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
refine' ⟨Γ'.bit1::l₁, [], some Γ'.cons, rfl, TransGen.head rfl (TransGen.single _)⟩
no goals
case cons.succ.pos.one
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
s : Option Γ'
l₁ : List Γ'
⊢ { l := some (unrev q₂), var := some Γ'.cons, stk := elim ([] ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d } ∈
    TM2.step tr
      (TM2.stepAux (tr (Λ'.pred q₁ q₂)) s (elim (trPosNum (PosNum.succ PosNum.one) ++ Γ'.cons :: trList v) l₁ c d))
simp [trPosNum, show PosNum.one.succ = PosNum.one.bit0 from rfl]
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit1 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
case cons.succ.pos.bit1
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit1 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
obtain ⟨l₁', l₂', s', e, h⟩ := IH (some Γ'.bit0) (Γ'.bit1 :: l₁)
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d } ∈
    TM2.step tr
      { l := some (Λ'.pred q₁ q₂), var := s,
        stk := elim (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) l₁ c d }
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit1 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
refine' ⟨l₁', l₂', s', e, TransGen.head _ h⟩
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ (bif decide (List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) = some Γ'.bit0) then
      { l := some (Λ'.pred q₁ q₂), var := List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v),
        stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) (Γ'.bit1 :: l₁) c d }
    else
      bif
          match Option.iget (List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) with
          | Γ'.consₗ => true
          | Γ'.cons => true
          | x => false then
        { l := some q₁, var := List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v),
          stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) l₁ c d }
      else
        bif
            match
              Option.iget (List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v))) with
            | Γ'.consₗ => true
            | Γ'.cons => true
            | x => false then
          { l := some (unrev q₂),
            var := List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)),
            stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) l₁ c d }
        else
          { l := some (unrev q₂),
            var := List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)),
            stk :=
              elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }) =
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d } ∈
    TM2.step tr
      { l := some (Λ'.pred q₁ q₂), var := s,
        stk := elim (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) l₁ c d }
simp
no goals
case cons.succ.pos.bit1.intro.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ l₁' l₂' : List Γ'
s' : Option Γ'
e : List.reverseAux (Γ'.bit1 :: l₁) (trPosNum m) = List.reverseAux l₁' l₂'
h :
  Reaches₁ (TM2.step tr)
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
    { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
⊢ (bif decide (List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v) = some Γ'.bit0) then
      { l := some (Λ'.pred q₁ q₂), var := List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v),
        stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) (Γ'.bit1 :: l₁) c d }
    else
      bif
          match Option.iget (List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) with
          | Γ'.consₗ => true
          | Γ'.cons => true
          | x => false then
        { l := some q₁, var := List.head? (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v),
          stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) l₁ c d }
      else
        bif
            match
              Option.iget (List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v))) with
            | Γ'.consₗ => true
            | Γ'.cons => true
            | x => false then
          { l := some (unrev q₂),
            var := List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)),
            stk := elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) l₁ c d }
        else
          { l := some (unrev q₂),
            var := List.head? (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)),
            stk :=
              elim (List.tail (trPosNum (PosNum.succ (PosNum.bit1 m)) ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }) =
    { l := some (Λ'.pred q₁ q₂), var := some Γ'.bit0,
      stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) (Γ'.bit1 :: l₁) c d }
rfl
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit0 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
case cons.succ.pos.bit0
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit0 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
obtain ⟨a, l, e, h⟩ : ∃ a l, (trPosNum m = a::l) ∧ natEnd a = false := by
  cases m <;> refine' ⟨_, _, rfl, rfl⟩
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ { l := some (unrev q₂), var := some a, stk := elim (trPosNum m ++ Γ'.cons :: trList v) (Γ'.bit0 :: l₁) c d } ∈
    TM2.step tr
      { l := some (Λ'.pred q₁ q₂), var := s,
        stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ ∃ l₁' l₂' s',
    List.reverseAux l₁ (trPosNum (PosNum.bit0 m)) = List.reverseAux l₁' l₂' ∧
      Reaches₁ (TM2.step tr)
        { l := some (Λ'.pred q₁ q₂), var := s,
          stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
        { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
refine' ⟨Γ'.bit0 :: l₁, _, some a, rfl, TransGen.single _⟩
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ (bif natEnd Γ'.bit1 then { l := some q₁, var := some Γ'.bit1, stk := elim (a :: (l ++ Γ'.cons :: trList v)) l₁ c d }
    else { l := some (unrev q₂), var := some a, stk := elim (a :: (l ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }) =
    { l := some (unrev q₂), var := some a, stk := elim (a :: (l ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ { l := some (unrev q₂), var := some a, stk := elim (trPosNum m ++ Γ'.cons :: trList v) (Γ'.bit0 :: l₁) c d } ∈
    TM2.step tr
      { l := some (Λ'.pred q₁ q₂), var := s,
        stk := elim (trPosNum (PosNum.succ (PosNum.bit0 m)) ++ Γ'.cons :: trList v) l₁ c d }
simp [trPosNum, PosNum.succ, e, h, show some Γ'.bit1 ≠ some Γ'.bit0 by decide,
  Option.iget, -natEnd]
no goals
case cons.succ.pos.bit0.intro.intro.intro
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ (bif natEnd Γ'.bit1 then { l := some q₁, var := some Γ'.bit1, stk := elim (a :: (l ++ Γ'.cons :: trList v)) l₁ c d }
    else { l := some (unrev q₂), var := some a, stk := elim (a :: (l ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }) =
    { l := some (unrev q₂), var := some a, stk := elim (a :: (l ++ Γ'.cons :: trList v)) (Γ'.bit0 :: l₁) c d }
rfl
no goals
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
⊢ ∃ a l, trPosNum m = a :: l ∧ natEnd a = false
cases m <;> refine' ⟨_, _, rfl, rfl⟩
no goals
q₁ q₂ : Λ'
s✝ : Option Γ'
c d : List Γ'
v : List ℕ
n : ℕ
m : PosNum
IH :
  ∀ (s : Option Γ') (l₁ : List Γ'),
    ∃ l₁' l₂' s',
      List.reverseAux l₁ (trPosNum m) = List.reverseAux l₁' l₂' ∧
        Reaches₁ (TM2.step tr)
          { l := some (Λ'.pred q₁ q₂), var := s, stk := elim (trPosNum (PosNum.succ m) ++ Γ'.cons :: trList v) l₁ c d }
          { l := some (unrev q₂), var := s', stk := elim (l₂' ++ Γ'.cons :: trList v) l₁' c d }
s : Option Γ'
l₁ : List Γ'
a : Γ'
l : List Γ'
e : trPosNum m = a :: l
h : natEnd a = false
⊢ some Γ'.bit1 ≠ some Γ'.bit0
decide