Theorem: Turing.TM2to1.tr_respects
File: Mathlib/Computability/TuringMachine.lean

tactic: intro c₁ c₂ h
state_before: K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
⊢ Respects (TM2.step M) (TM1.step (tr M)) TrCfg

tactic: cases' h with l v S L hT
state_before: K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
c₁ : Cfg₂
c₂ : TM1.Cfg Γ' Λ' σ
h : TrCfg c₁ c₂
⊢ match TM2.step M c₁ with
  | some b₁ => ∃ b₂, TrCfg b₁ b₂ ∧ Reaches₁ (TM1.step (tr M)) c₂ b₂
  | none => TM1.step (tr M) c₂ = none

tactic: cases' l with l
state_before: case mk
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Option Λ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ match TM2.step M { l := l, var := v, stk := S } with
  | some b₁ =>
    ∃ b₂,
      TrCfg b₁ b₂ ∧
        Reaches₁ (TM1.step (tr M)) { l := Option.map normal l, var := v, Tape := Tape.mk' ∅ (addBottom L) } b₂
  | none => TM1.step (tr M) { l := Option.map normal l, var := v, Tape := Tape.mk' ∅ (addBottom L) } = none

tactic: simp only [TM2.step, Respects, Option.map_some']
state_before: case mk.some
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
⊢ match TM2.step M { l := some l, var := v, stk := S } with
  | some b₁ =>
    ∃ b₂,
      TrCfg b₁ b₂ ∧
        Reaches₁ (TM1.step (tr M)) { l := Option.map normal (some l), var := v, Tape := Tape.mk' ∅ (addBottom L) } b₂
  | none => TM1.step (tr M) { l := Option.map normal (some l), var := v, Tape := Tape.mk' ∅ (addBottom L) } = none

tactic: rsuffices ⟨b, c, r⟩ : ∃ b, _ ∧ Reaches (TM1.step (tr M)) _ _
state_before: case mk.some
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
⊢ ∃ b₂,
    TrCfg (TM2.stepAux (M l) v S) b₂ ∧
      Reaches₁ (TM1.step (tr M)) { l := some (normal l), var := v, Tape := Tape.mk' ∅ (addBottom L) } b₂

tactic: simp only [tr]
state_before: K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
⊢ ∃ b,
    TrCfg (TM2.stepAux (M l) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (tr M (normal l)) v (Tape.mk' ∅ (addBottom L))) b

tactic: generalize M l = N
state_before: K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
⊢ ∃ b,
    TrCfg (TM2.stepAux (M l) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal (M l)) v (Tape.mk' ∅ (addBottom L))) b

tactic: induction N using stmtStRec generalizing v S L hT with
| H₁ k s q IH => exact tr_respects_aux M hT s @IH
| H₂ a _ IH => exact IH _ hT
| H₃ p q₁ q₂ IH₁ IH₂ =>
  unfold TM2.stepAux trNormal TM1.stepAux
  simp only []
  cases p v <;> [exact IH₂ _ hT; exact IH₁ _ hT]
| H₄ => exact ⟨_, ⟨_, hT⟩, ReflTransGen.refl⟩
| H₅ => exact ⟨_, ⟨_, hT⟩, ReflTransGen.refl⟩
state_before: K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
N : Stmt₂
⊢ ∃ b, TrCfg (TM2.stepAux N v S) b ∧ Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal N) v (Tape.mk' ∅ (addBottom L))) b

tactic: constructor
state_before: case mk.none
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ match TM2.step M { l := none, var := v, stk := S } with
  | some b₁ =>
    ∃ b₂,
      TrCfg b₁ b₂ ∧
        Reaches₁ (TM1.step (tr M)) { l := Option.map normal none, var := v, Tape := Tape.mk' ∅ (addBottom L) } b₂
  | none => TM1.step (tr M) { l := Option.map normal none, var := v, Tape := Tape.mk' ∅ (addBottom L) } = none

tactic: exact ⟨b, c, TransGen.head' rfl r⟩
state_before: case mk.some.intro.intro
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
l : Λ
b : ?m.734846
c : ?m.735219 b
r : Reaches (TM1.step (tr M)) (?m.735220 b) (?m.735221 b)
⊢ ∃ b₂,
    TrCfg (TM2.stepAux (M l) v S) b₂ ∧
      Reaches₁ (TM1.step (tr M)) { l := some (normal l), var := v, Tape := Tape.mk' ∅ (addBottom L) } b₂

tactic: exact tr_respects_aux M hT s @IH
state_before: case H₁
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
k : K
s : StAct k
q : Stmt₂
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q) v (Tape.mk' ∅ (addBottom L))) b
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (TM2.stepAux (stRun s q) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal (stRun s q)) v (Tape.mk' ∅ (addBottom L))) b

tactic: exact IH _ hT
state_before: case H₂
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
a : σ → σ
q✝ : Stmt₂
IH :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q✝ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q✝) v (Tape.mk' ∅ (addBottom L))) b
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (TM2.stepAux (TM2.Stmt.load a q✝) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal (TM2.Stmt.load a q✝)) v (Tape.mk' ∅ (addBottom L))) b

tactic: unfold TM2.stepAux trNormal TM1.stepAux
state_before: case H₃
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
p : σ → Bool
q₁ q₂ : Stmt₂
IH₁ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₁ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₁) v (Tape.mk' ∅ (addBottom L))) b
IH₂ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₂ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₂) v (Tape.mk' ∅ (addBottom L))) b
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (TM2.stepAux (TM2.Stmt.branch p q₁ q₂) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal (TM2.Stmt.branch p q₁ q₂)) v (Tape.mk' ∅ (addBottom L))) b

tactic: simp only []
state_before: case H₃
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
p : σ → Bool
q₁ q₂ : Stmt₂
IH₁ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₁ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₁) v (Tape.mk' ∅ (addBottom L))) b
IH₂ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₂ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₂) v (Tape.mk' ∅ (addBottom L))) b
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (bif p v then TM2.stepAux q₁ v S else TM2.stepAux q₂ v S) b ∧
      Reaches (TM1.step (tr M))
        (bif (fun x => p) (Tape.mk' ∅ (addBottom L)).head v then TM1.stepAux (trNormal q₁) v (Tape.mk' ∅ (addBottom L))
        else TM1.stepAux (trNormal q₂) v (Tape.mk' ∅ (addBottom L)))
        b

tactic: cases p v <;> [exact IH₂ _ hT; exact IH₁ _ hT]
state_before: case H₃
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
p : σ → Bool
q₁ q₂ : Stmt₂
IH₁ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₁ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₁) v (Tape.mk' ∅ (addBottom L))) b
IH₂ :
  ∀ {v : σ} {S : (k : K) → List (Γ k)} (L : ListBlank ((k : K) → Option (Γ k))),
    (∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))) →
      ∃ b,
        TrCfg (TM2.stepAux q₂ v S) b ∧
          Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal q₂) v (Tape.mk' ∅ (addBottom L))) b
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (bif p v then TM2.stepAux q₁ v S else TM2.stepAux q₂ v S) b ∧
      Reaches (TM1.step (tr M))
        (bif p v then TM1.stepAux (trNormal q₁) v (Tape.mk' ∅ (addBottom L))
        else TM1.stepAux (trNormal q₂) v (Tape.mk' ∅ (addBottom L)))
        b

tactic: exact ⟨_, ⟨_, hT⟩, ReflTransGen.refl⟩
state_before: case H₄
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
l✝ : σ → Λ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (TM2.stepAux (TM2.Stmt.goto l✝) v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal (TM2.Stmt.goto l✝)) v (Tape.mk' ∅ (addBottom L))) b

tactic: exact ⟨_, ⟨_, hT⟩, ReflTransGen.refl⟩
state_before: case H₅
K : Type u_4
inst✝² : DecidableEq K
Γ : K → Type u_3
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
M : Λ → Stmt₂
l : Λ
v : σ
S : (k : K) → List (Γ k)
L : ListBlank ((k : K) → Option (Γ k))
hT : ∀ (k : K), ListBlank.map (proj k) L = ListBlank.mk (List.reverse (List.map some (S k)))
⊢ ∃ b,
    TrCfg (TM2.stepAux TM2.Stmt.halt v S) b ∧
      Reaches (TM1.step (tr M)) (TM1.stepAux (trNormal TM2.Stmt.halt) v (Tape.mk' ∅ (addBottom L))) b