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 <$> c.eval v
state_after: 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 <$> c.eval 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 <$> c.eval v
state_after: 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 <$> c.eval 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 <$> c.eval v
state_after: 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) i ↔ x ∈ halt <$> c.eval 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 (TM2.step tr) i ↔ x ∈ halt <$> c.eval v
state_after: 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) i ↔ ∃ a ∈ c.eval v, halt a = x

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 (TM2.step tr) i ↔ ∃ a ∈ c.eval v, halt a = x
state_after: 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 (TM2.step tr) i
⊢ ∃ a ∈ c.eval v, halt a = x

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 ∈ c.eval v, halt a = x) → x ∈ eval (TM2.step tr) i

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 (TM2.step tr) i
⊢ ∃ a ∈ c.eval v, halt a = x
state_after: 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 (TM2.step tr) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : c ∈ eval step (stepNormal c✝ Cont.halt v)
⊢ ∃ a ∈ c✝.eval 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 (TM2.step tr) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : c ∈ eval step (stepNormal c✝ Cont.halt v)
⊢ ∃ a ∈ c✝.eval v, halt a = x
state_after: 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 (TM2.step tr) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : ∃ a ∈ c✝.eval v, Cfg.halt a = c
⊢ ∃ a ∈ c✝.eval 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 (TM2.step tr) i
c : Cfg
hc₁ : TrCfg c x
hc₂ : ∃ a ∈ c✝.eval v, Cfg.halt a = c
⊢ ∃ a ∈ c✝.eval v, halt a = x
state_after: 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 (TM2.step tr) i
v' : List ℕ
hv : v' ∈ c.eval v
hc₁ : TrCfg (Cfg.halt v') x
⊢ ∃ a ∈ c.eval 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 (TM2.step tr) i
v' : List ℕ
hv : v' ∈ c.eval v
hc₁ : TrCfg (Cfg.halt v') x
⊢ ∃ a ∈ c.eval v, halt a = x
state_after: no goals

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 ∈ c.eval v, halt a = x) → x ∈ eval (TM2.step tr) i
state_after: 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' ∈ c.eval v
⊢ halt v' ∈ eval (TM2.step tr) 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' ∈ c.eval v
⊢ halt v' ∈ eval (TM2.step tr) i
state_after: 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' ∈ c.eval 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 (TM2.step tr) i

tactic: simp only [stepNormal_eval, Part.map_eq_map, Part.mem_map_iff, Cfg.halt.injEq,
  exists_eq_right] 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' ∈ c.eval 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 (TM2.step tr) i
state_after: 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' ∈ c.eval v
this : v' ∈ c.eval v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (TM2.step tr) 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' ∈ c.eval v
this : v' ∈ c.eval v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (TM2.step tr) i
state_after: 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' ∈ c.eval v
this : v' ∈ c.eval v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
h : halt v' ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (TM2.step tr) 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' ∈ c.eval v
this : v' ∈ c.eval v → ∃ b₂, TrCfg (Cfg.halt v') b₂ ∧ b₂ ∈ eval (TM2.step tr) i
h : halt v' ∈ eval (TM2.step tr) i
⊢ halt v' ∈ eval (TM2.step tr) i
state_after: no goals