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

tactic: obtain ⟨i, h₁, h₂⟩ := tr_init c v
state_before: c : Code
v : List ℕ
⊢ eval (TM2.step tr) (init c v) = halt <$> Code.eval c v

tactic: refine' Part.ext fun x => _
state_before: case intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
⊢ eval (TM2.step tr) (init c v) = halt <$> Code.eval c v

tactic: rw [reaches_eval h₂.to_reflTransGen]
state_before: case intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
⊢ x ∈ eval (TM2.step tr) (init c v) ↔ x ∈ halt <$> Code.eval c v

tactic: simp [-TM2.step]
state_before: case intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
⊢ x ∈ eval (fun a => TM2.step tr a) i ↔ x ∈ halt <$> Code.eval c v

tactic: refine' ⟨fun h => _, _⟩
state_before: case intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
⊢ x ∈ eval (fun a => TM2.step tr a) i ↔ ∃ a, a ∈ Code.eval c v ∧ halt a = x

tactic: obtain ⟨c, hc₁, hc₂⟩ := tr_eval_rev tr_respects h₁ h
state_before: case intro.intro.refine'_1
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
h : x ∈ eval (fun a => TM2.step tr a) i
⊢ ∃ a, a ∈ Code.eval c v ∧ halt a = x

tactic: simp [stepNormal_eval] at hc₂
state_before: case intro.intro.refine'_1.intro.intro
c✝ : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c✝ Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c✝ v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
h : x ∈ eval (fun a => TM2.step tr a) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : c ∈ eval step (stepNormal c✝ Cont.halt v)
⊢ ∃ a, a ∈ Code.eval c✝ v ∧ halt a = x

tactic: obtain ⟨v', hv, rfl⟩ := hc₂
state_before: case intro.intro.refine'_1.intro.intro
c✝ : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c✝ Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c✝ v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
h : x ∈ eval (fun a => TM2.step tr a) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : ∃ a, a ∈ Code.eval c✝ v ∧ Cfg.halt a = c
⊢ ∃ a, a ∈ Code.eval c✝ v ∧ halt a = x

tactic: exact ⟨_, hv, hc₁.symm⟩
state_before: case intro.intro.refine'_1.intro.intro.intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
h : x ∈ eval (fun a => TM2.step tr a) i
v' : List ℕ
hv : v' ∈ Code.eval c v
hc₁ : TrCfg (Cfg.halt v') x
⊢ ∃ a, a ∈ Code.eval c v ∧ halt a = x

tactic: rintro ⟨v', hv, rfl⟩
state_before: case intro.intro.refine'_2
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
x : TM2.Cfg (fun x => Γ') Λ' (Option Γ')
⊢ (∃ a, a ∈ Code.eval c v ∧ halt a = x) → x ∈ eval (fun a => TM2.step tr a) i

tactic: have := Turing.tr_eval (b₁ := Cfg.halt v') tr_respects h₁
state_before: case intro.intro.refine'_2.intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
v' : List ℕ
hv : v' ∈ Code.eval c v
⊢ halt v' ∈ eval (fun a => TM2.step tr a) i

tactic: simp [stepNormal_eval, -TM2.step] at this
state_before: case intro.intro.refine'_2.intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
v' : List ℕ
hv : v' ∈ Code.eval c v
this : Cfg.halt v' ∈ eval step (stepNormal c Cont.halt v) → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (fun a => TM2.step tr a) i

tactic: obtain ⟨_, ⟨⟩, h⟩ := this hv
state_before: case intro.intro.refine'_2.intro.intro
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
v' : List ℕ
hv : v' ∈ Code.eval c v
this : v' ∈ Code.eval c v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (fun a => TM2.step tr a) i

tactic: exact h
state_before: case intro.intro.refine'_2.intro.intro.intro.intro.refl
c : Code
v : List ℕ
i : Cfg'
h₁ : TrCfg (stepNormal c Cont.halt v) i
h₂ : Reaches₁ (TM2.step tr) (init c v) i
v' : List ℕ
hv : v' ∈ Code.eval c v
this : v' ∈ Code.eval c v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
h : halt v' ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (fun a => TM2.step tr a) i