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

tactic: rw [(_ : TM1.init _ = _)]
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ TrCfg (TM2.init k L) (TM1.init (trInit k L))
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ TrCfg (TM2.init k L) ?m.401294

K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ TM1.init (trInit k L) = ?m.401294

tactic: refine ⟨ListBlank.mk (L.reverse.map fun a ↦ update default k (some a)), fun k' ↦ ?_⟩
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ TrCfg (TM2.init k L) ?m.401294
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
⊢ ListBlank.map (proj k') (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse)) =
    ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse

tactic: refine ListBlank.ext fun i ↦ ?_
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
⊢ ListBlank.map (proj k') (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse)) =
    ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
⊢ (ListBlank.map (proj k') (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))).nth i =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

tactic: rw [ListBlank.map_mk, ListBlank.nth_mk, List.getI_eq_iget_get?, List.map_map]
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
⊢ (ListBlank.map (proj k') (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))).nth i =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
⊢ ((List.map ((proj k').f ∘ fun a => update default k (some a)) L.reverse).get? i).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

tactic: have : ((proj k').f ∘ fun a => update (β := fun k => Option (Γ k)) default k (some a))
  = fun a => (proj k').f (update (β := fun k => Option (Γ k)) default k (some a)) := rfl
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
⊢ ((List.map ((proj k').f ∘ fun a => update default k (some a)) L.reverse).get? i).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
⊢ ((List.map ((proj k').f ∘ fun a => update default k (some a)) L.reverse).get? i).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

tactic: rw [this, List.get?_map, proj, PointedMap.mk_val]
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
⊢ ((List.map ((proj k').f ∘ fun a => update default k (some a)) L.reverse).get? i).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

tactic: by_cases h : k' = k
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : k' = k
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

tactic: subst k'
state_before: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : k' = k
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
i : ℕ
this : ((proj k).f ∘ fun a => update default k (some a)) = fun a => (proj k).f (update default k (some a))
⊢ (Option.map (fun a => update default k (some a) k) (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k)).reverse).nth i

tactic: simp only [Function.update_same]
state_before: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
i : ℕ
this : ((proj k).f ∘ fun a => update default k (some a)) = fun a => (proj k).f (update default k (some a))
⊢ (Option.map (fun a => update default k (some a) k) (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k)).reverse).nth i
state_after: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
i : ℕ
this : ((proj k).f ∘ fun a => update default k (some a)) = fun a => (proj k).f (update default k (some a))
⊢ (Option.map (fun a => some a) (L.reverse.get? i)).iget = (ListBlank.mk (List.map some L).reverse).nth i

tactic: rw [ListBlank.nth_mk, List.getI_eq_iget_get?, ← List.map_reverse, List.get?_map]
state_before: case pos
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
i : ℕ
this : ((proj k).f ∘ fun a => update default k (some a)) = fun a => (proj k).f (update default k (some a))
⊢ (Option.map (fun a => some a) (L.reverse.get? i)).iget = (ListBlank.mk (List.map some L).reverse).nth i
state_after: no goals

tactic: simp only [Function.update_noteq h]
state_before: case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => update default k (some a) k') (L.reverse.get? i)).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i
state_after: case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => default k') (L.reverse.get? i)).iget = (ListBlank.mk (List.map some []).reverse).nth i

tactic: rw [ListBlank.nth_mk, List.getI_eq_iget_get?, List.map, List.reverse_nil]
state_before: case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => default k') (L.reverse.get? i)).iget = (ListBlank.mk (List.map some []).reverse).nth i
state_after: case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => default k') (L.reverse.get? i)).iget = ([].get? i).iget

tactic: cases L.reverse.get? i <;> rfl
state_before: case neg
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
k' : K
i : ℕ
this : ((proj k').f ∘ fun a => update default k (some a)) = fun a => (proj k').f (update default k (some a))
h : ¬k' = k
⊢ (Option.map (fun a => default k') (L.reverse.get? i)).iget = ([].get? i).iget
state_after: no goals

tactic: rw [trInit, TM1.init]
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ TM1.init (trInit k L) =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))) }
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ { l := some default, var := default,
      Tape :=
        Tape.mk₁
          (let L' := List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse;
          (true, L'.headI.2) :: L'.tail) } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))) }

tactic: dsimp only
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ { l := some default, var := default,
      Tape :=
        Tape.mk₁
          (let L' := List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse;
          (true, L'.headI.2) :: L'.tail) } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))) }
state_after: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ { l := some default, var := default,
      Tape :=
        Tape.mk₁
          ((true, (List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse).headI.2) ::
            (List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse).tail) } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))) }

tactic: congr <;> cases L.reverse <;> try rfl
state_before: K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ { l := some default, var := default,
      Tape :=
        Tape.mk₁
          ((true, (List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse).headI.2) ::
            (List.map (fun a => (false, update (fun x => none) k (some a))) L.reverse).tail) } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) L.reverse))) }
state_after: case e_Tape.e_l.e_tail.cons
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
head✝ : Γ k
tail✝ : List (Γ k)
⊢ (List.map (fun a => (false, update (fun x => none) k (some a))) (head✝ :: tail✝)).tail =
    List.map { f := Prod.mk false, map_pt' := ⋯ }.f
      (List.map (fun a => update default k (some a)) (head✝ :: tail✝)).tail

tactic: simp only [List.map_map, List.tail_cons, List.map]
state_before: case e_Tape.e_l.e_tail.cons
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
head✝ : Γ k
tail✝ : List (Γ k)
⊢ (List.map (fun a => (false, update (fun x => none) k (some a))) (head✝ :: tail✝)).tail =
    List.map { f := Prod.mk false, map_pt' := ⋯ }.f
      (List.map (fun a => update default k (some a)) (head✝ :: tail✝)).tail
state_after: case e_Tape.e_l.e_tail.cons
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
head✝ : Γ k
tail✝ : List (Γ k)
⊢ List.map (fun a => (false, update (fun x => none) k (some a))) tail✝ =
    List.map (Prod.mk false ∘ fun a => update default k (some a)) tail✝

tactic: rfl
state_before: case e_Tape.e_l.e_tail.cons
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
head✝ : Γ k
tail✝ : List (Γ k)
⊢ List.map (fun a => (false, update (fun x => none) k (some a))) tail✝ =
    List.map (Prod.mk false ∘ fun a => update default k (some a)) tail✝
state_after: no goals

tactic: rfl
state_before: case e_Tape.e_l.e_tail.nil
K : Type u_1
inst✝² : DecidableEq K
Γ : K → Type u_2
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
⊢ (List.map (fun a => (false, update (fun x => none) k (some a))) []).tail =
    List.map { f := Prod.mk false, map_pt' := ⋯ }.f (List.map (fun a => update default k (some a)) []).tail
state_after: no goals