awhecmu/canonical-drafter-extract-mathlib huggingface dataset:
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
h₁ : k₁ ≠ k₂
a : Γ'
s : Option Γ'
S : K' → List Γ'
Sk fst : List Γ'
fst_1 : Option Γ'
snd : List Γ'
e₃ : splitAtPred p Sk = (fst, fst_1, snd)
e₁ : S k₁ = a :: Sk
e₂ : p a = false
IH :
  ∀ {s : Option Γ'} {S : K' → List Γ'}
    (e : splitAtPred p (S k₁) = ((fst, fst_1, snd).1, (fst, fst_1, snd).2.1, (fst, fst_1, snd).2.2)),
    Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
      (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) (fst, fst_1, snd).2.1
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (fst, fst_1, snd).2.2) k₂
          ((fst, fst_1, snd).1.reverseAux (S k₂))))
h :
  update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ snd) k₂ (fst.reverse ++ a :: S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ')
        (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ Sk) k₂ (a :: S k₂)) k₁ snd)
      k₂ (fst.reverse ++ a :: S k₂)
⊢ update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ snd) k₂
      ((a :: fst).reverseAux (S k₂)) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ')
        (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ Sk) k₂ (a :: S k₂)) k₁
        (fst, fst_1, snd).2.2)
      k₂
      ((fst, fst_1, snd).1.reverseAux
        (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ Sk) k₂ (a :: S k₂) k₂))

Tactic:
simp [Function.update_of_ne, h₁, h₁.symm, e₃, List.reverseAux]

Premises used: List.reverseAux, Ne.symm, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
h₁ : k₁ ≠ k₂
a : Γ'
s : Option Γ'
S : K' → List Γ'
Sk fst : List Γ'
fst_1 : Option Γ'
snd : List Γ'
e₃ : splitAtPred p Sk = (fst, fst_1, snd)
e₁ : S k₁ = a :: Sk
e₂ : p a = false
IH :
  ∀ {s : Option Γ'} {S : K' → List Γ'}
    (e : splitAtPred p (S k₁) = ((fst, fst_1, snd).1, (fst, fst_1, snd).2.1, (fst, fst_1, snd).2.2)),
    Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
      (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) (fst, fst_1, snd).2.1
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (fst, fst_1, snd).2.2) k₂
          ((fst, fst_1, snd).1.reverseAux (S k₂))))
⊢ splitAtPred p
      (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ Sk) k₂ (a :: S k₂) k₁) =
    ((fst, fst_1, snd).1, (fst, fst_1, snd).2.1, (fst, fst_1, snd).2.2)

Tactic:
simp [Function.update_of_ne, h₁, h₁.symm, e₃, List.reverseAux]

Premises used: List.reverseAux, Ne.symm, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
h₁ : k₁ ≠ k₂
a : Γ'
s : Option Γ'
S : K' → List Γ'
Sk fst : List Γ'
fst_1 : Option Γ'
snd : List Γ'
e₃ : splitAtPred p Sk = (fst, fst_1, snd)
e₁ : S k₁ = a :: Sk
e₂ : p a = false
IH :
  ∀ {s : Option Γ'} {S : K' → List Γ'}
    (e : splitAtPred p (S k₁) = ((fst, fst_1, snd).1, (fst, fst_1, snd).2.1, (fst, fst_1, snd).2.2)),
    Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
      (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) (fst, fst_1, snd).2.1
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (fst, fst_1, snd).2.2) k₂
          ((fst, fst_1, snd).1.reverseAux (S k₂))))
⊢ update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ snd) k₂ (fst.reverse ++ a :: S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ')
        (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ Sk) k₂ (a :: S k₂)) k₁ snd)
      k₂ (fst.reverse ++ a :: S k₂)

Tactic:
simp [Function.update_comm h₁.symm]

Premises used: Ne.symm, Function.update_comm
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ : List Γ'
o : Option Γ'
L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ k₂
e : splitAtPred p (S k₁) = (L₁, o, L₂)
nil :
  ∀ {s : Option Γ'} {S : K' → List Γ'} (e : splitAtPred p (S k₁) = ([], o, L₂)),
    Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
      (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) o
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂
          (List.reverseAux [] (S k₂))))
cons :
  ∀ (a : Γ') (L₁ : List Γ')
    (IH :
      ∀ {s : Option Γ'} {S : K' → List Γ'} (e : splitAtPred p (S k₁) = (L₁, o, L₂)),
        Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr)
          (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
          (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) o
            (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂
              (L₁.reverseAux (S k₂)))))
    {s : Option Γ'} {S : K' → List Γ'} (e : splitAtPred p (S k₁) = (a :: L₁, o, L₂)),
    Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
      (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) o
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂
          ((a :: L₁).reverseAux (S k₂))))
⊢ Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move p k₁ k₂ q)) s S)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) o
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁.reverseAux (S k₂))))

Tactic:
induction L₁ generalizing S s with
  | nil =>
    rw [(_ : [].reverseAux _ = _), Function.update_eq_self]
    swap
    · rw [Function.update_of_ne h₁.symm, List.reverseAux_nil]
    refine TransGen.head' rfl ?_
    simp only [tr_move, pop', TM2.stepAux]
    grind [splitAtPred.eq_def]
  | cons a L₁ IH =>
    refine TransGen.head rfl ?_
    rw [tr]; simp only [pop', Option.elim, TM2.stepAux, push']
    rcases e₁ : S k₁ with - | ⟨a', Sk⟩ <;> rw [e₁, splitAtPred] at e
    · cases e
    cases e₂ : p a' <;> simp only [e₂, cond] at e
    swap
    · cases e
    rcases e₃ : splitAtPred p Sk with ⟨_, _, _⟩
    rw [e₃] at e
    cases e
    simp only [List.head?_cons, e₂, List.tail_cons, cond_false]
    convert! @IH _ (update (update S k₁ Sk) k₂ (a :: S k₂)) _ using 2 <;>
      simp [Function.update_of_ne, h₁, h₁.symm, e₃, List.reverseAux]
    simp [Function.update_comm h₁.symm]

Premises used: cond, Function.update_eq_self, Turing.PartrecToTM2.tr, Turing.TM2.stepAux, Relation.TransGen.head, Turing.PartrecToTM2.push', List.reverseAux, List.reverseAux_nil, Ne.symm, List.tail_cons, Relation.TransGen.head', Turing.PartrecToTM2.pop', Function.update_comm, Turing.PartrecToTM2.splitAtPred, List.head?_cons, Turing.PartrecToTM2.splitAtPred.eq_def, Option.elim, cond_false, rfl, Turing.PartrecToTM2.tr_move, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
q : Λ'
s : Option Γ'
S : K' → List Γ'
⊢ rev ≠ main

Tactic:
decide
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ : List Γ'
o : Option Γ'
L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, o, L₂)
⊢ Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (move₂ p k₁ k₂ q)) s S)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (o.elim id List.cons L₂)) k₂
        (L₁ ++ S k₂)))

Tactic:
(move_ok h₁.1 e).trans (TransGen.head rfl ?_)

Premises used: Relation.TransGen.head, Turing.PartrecToTM2.move_ok, And.left, Relation.TransGen.trans, StateTransition.Reaches₁, Turing.PartrecToTM2.move₂, rfl, Turing.PartrecToTM2.moveExcl
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ : List Γ'
o : Option Γ'
L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, o, L₂)
refine :
  TransGen (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦ b ∈ TM2.step (Γ := fun (x : K') ↦ Γ') tr a)
    (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr (Λ'.push k₁ id (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q))) o
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (o.elim id List.cons L₂)) k₂
        (L₁ ++ S k₂)))
⊢ Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr) (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (move₂ p k₁ k₂ q)) s S)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (o.elim id List.cons L₂)) k₂
        (L₁ ++ S k₂)))

Tactic:
refine (move_ok h₁.1 e).trans (TransGen.head rfl ?_)

Premises used: Relation.TransGen.head, Turing.PartrecToTM2.move_ok, And.left, Relation.TransGen.trans, rfl
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ : List Γ'
o : Option Γ'
L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, o, L₂)
simp :
  TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := none, var := var, stk := stk } => none
        | { l := some l, var := v, stk := S } => some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        some b)
    (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr (Λ'.push k₁ id (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q))) o
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ')
        (update (β := fun (a : K') ↦ List Γ') S k₁
          ((match (motive :=
              Option Γ' → ((a : List Γ') → List Γ') → (Γ' → (a : List Γ') → List Γ') → (a : List Γ') → List Γ') o, id,
              List.cons with
            | some x, x_1, f => f x
            | none, y, x => y)
            L₂))
        k₂ (L₁ ++ S k₂)))
⊢ TransGen (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦ b ∈ TM2.step (Γ := fun (x : K') ↦ Γ') tr a)
    (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr (Λ'.push k₁ id (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q))) o
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (o.elim id List.cons L₂)) k₂
        (L₁ ++ S k₂)))

Tactic:
simp only [TM2.step, Option.mem_def, Option.elim]

Premises used: Turing.TM2.step, Option.elim, Option.mem_def
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, Option.none, L₂)
none :
  TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := Option.none, var := var, stk := stk } => Option.none
        | { l := some l, var := v, stk := S } => some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        some b)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q)) Option.none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) Option.none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂)))
⊢ TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := Option.none, var := var, stk := stk } => Option.none
        | { l := some l, var := v, stk := S } => some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        some b)
    (TM2.stepAux (Γ := fun (x : K') ↦ Γ')
      (branch (Γ := fun (x : K') ↦ Γ') (fun (s : Option Γ') ↦ (id s).isSome)
        (push (Γ := fun (x : K') ↦ Γ') k₁ (fun (s : Option Γ') ↦ (id s).getD default)
          (goto (Γ := fun (x : K') ↦ Γ') fun (x : Option Γ') ↦ Λ'.move (fun (x : Γ') ↦ false) rev k₂ q))
        (goto (Γ := fun (x : K') ↦ Γ') fun (x : Option Γ') ↦ Λ'.move (fun (x : Γ') ↦ false) rev k₂ q))
      Option.none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) Option.none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (id L₂)) k₂ (L₁ ++ S k₂)))

Tactic:
simp only [id, TM2.stepAux, Option.isSome, cond_true, cond_false]

Premises used: Turing.TM2.stepAux, id, cond_true, Option.isSome, cond_false
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
⊢ Reaches₁ (TM2.step (Γ := fun (x : K') ↦ Γ') tr)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q)) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ')
        (update (β := fun (a : K') ↦ List Γ')
          (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
            (L₁.reverseAux (S rev)))
          rev [])
        k₂
        ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
              (L₁.reverseAux (S rev)) rev).reverseAux
          (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
            (L₁.reverseAux (S rev)) k₂))))

Tactic:
move_ok h₁.2.1.symm (splitAtPred_false _)

Premises used: Turing.PartrecToTM2.move_ok, Turing.PartrecToTM2.splitAtPred_false, Ne.symm, And.right, And.left
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
h :
  update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ')
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
          (L₁.reverseAux (S rev)))
        rev [])
      k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))
          k₂))
⊢ TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := none, var := var, stk := stk } => none
        | { l := some l, var := v, stk := S } => some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        some b)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q)) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂)))

Tactic:
convert! move_ok h₁.2.1.symm (splitAtPred_false _) using 2

Premises used: Turing.PartrecToTM2.move_ok, Turing.PartrecToTM2.splitAtPred_false, Ne.symm, And.right, And.left
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
h :
  update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S rev []) k₁ L₂) k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
          k₂))
⊢ update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ')
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
          (L₁.reverseAux (S rev)))
        rev [])
      k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev (L₁.reverseAux (S rev))
          k₂))

Tactic:
simp only [Function.update_comm h₁.1, Function.update_idem]

Premises used: Function.update_comm, And.left, Function.update_idem
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
rw : update (β := fun (a : K') ↦ List Γ') S rev (S rev) = S
rw₁ rw₂ : S = S
⊢ update (β := fun (a : K') ↦ List Γ') S rev [] = S

Tactic:
rw [← h₂, Function.update_eq_self]

Premises used: Function.update_eq_self
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
h :
  update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
          k₂))
⊢ update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ')
      (update (β := fun (a : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S rev []) k₁ L₂) k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
          k₂))

Tactic:
rw [show update S rev [] = S by rw [← h₂, Function.update_eq_self]]
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
e : splitAtPred p (S k₁) = (L₁, none, L₂)
⊢ update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂ (L₁ ++ S k₂) =
    update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) k₂
      ((update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
            rev).reverseAux
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (k : K') ↦ List Γ') S rev (L₁.reverseAux (S rev))) k₁ L₂
          k₂))

Tactic:
simp only [Function.update_of_ne h₁.2.2.symm, Function.update_of_ne h₁.2.1,
      Function.update_of_ne h₁.1.symm, List.reverseAux_eq, h₂, Function.update_self,
      List.append_nil, List.reverse_reverse]

Premises used: Ne.symm, List.reverseAux_eq, List.append_nil, List.reverse_reverse, And.right, And.left, Function.update_self, Function.update_of_ne
-- Module: Mathlib.Computability.TuringMachine.ToPartrec
Goal:
p : Γ' → Bool
k₁ k₂ : K'
q : Λ'
s : Option Γ'
L₁ L₂ : List Γ'
S : K' → List Γ'
h₁ : k₁ ≠ rev ∧ k₂ ≠ rev ∧ k₁ ≠ k₂
h₂ : S rev = []
val : Γ'
e : splitAtPred p (S k₁) = (L₁, Option.some val, L₂)
some :
  TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := none, var := var, stk := stk } => none
        | { l := Option.some l, var := v, stk := S } => Option.some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        Option.some b)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (Option.some (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q)) (Option.some val)
      (update (β := fun (k : K') ↦ List Γ')
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
          (L₁.reverseAux (S rev)))
        k₁
        (val ::
          update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
            (L₁.reverseAux (S rev)) k₁)))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (Option.some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (val :: L₂)) k₂ (L₁ ++ S k₂)))
⊢ TransGen
    (fun (a b : TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ')) ↦
      (match (motive :=
          TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ') → Option (TM2.Cfg (fun (x : K') ↦ Γ') Λ' (Option Γ'))) a with
        | { l := none, var := var, stk := stk } => none
        | { l := Option.some l, var := v, stk := S } => Option.some (TM2.stepAux (Γ := fun (x : K') ↦ Γ') (tr l) v S)) =
        Option.some b)
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (Option.some (Λ'.move (fun (x : Γ') ↦ false) rev k₂ q)) (Option.some val)
      (update (β := fun (k : K') ↦ List Γ')
        (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
          (L₁.reverseAux (S rev)))
        k₁
        ((Option.some val).getD default ::
          update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ L₂) rev
            (L₁.reverseAux (S rev)) k₁)))
    (TM2.Cfg.mk (Γ := fun (x : K') ↦ Γ') (Option.some q) none
      (update (β := fun (k : K') ↦ List Γ') (update (β := fun (a : K') ↦ List Γ') S k₁ (val :: L₂)) k₂ (L₁ ++ S k₂)))

Tactic:
simp only [Option.getD_some]

Premises used: Option.getD_some