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

tactic: rw [(_ : TM1.init _ = _)]
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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))

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

tactic: simp only [TM2.Cfg.stk, TM2.init]
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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)) (List.reverse L))) =
    ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))

tactic: refine' ListBlank.ext fun i ↦ _
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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)) (List.reverse L))) =
    ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))

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

tactic: rw [this, List.get?_map, proj, PointedMap.mk_val]
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
⊢ Option.iget (List.get? (List.map ((proj k').f ∘ fun a => update default k (some a)) (List.reverse L)) i) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))) i

tactic: simp only []
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
⊢ Option.iget (Option.map (fun a => update default k (some a) k') (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))) i

tactic: by_cases h : k' = k
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
⊢ Option.iget (Option.map (fun a => update default k (some a) k') (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))) i

tactic: subst k'
state_before: case pos
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
h : k' = k
⊢ Option.iget (Option.map (fun a => update default k (some a) k') (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))) i

tactic: simp only [Function.update_same]
state_before: case pos
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k) (update default k (some a))
⊢ Option.iget (Option.map (fun a => update default k (some a) k) (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k)))) i

tactic: rw [ListBlank.nth_mk, List.getI_eq_iget_get?, ← List.map_reverse, List.get?_map]
state_before: case pos
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k) (update default k (some a))
⊢ Option.iget (Option.map (fun a => some a) (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some L))) i

tactic: simp only [Function.update_noteq h]
state_before: case neg
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
h : ¬k' = k
⊢ Option.iget (Option.map (fun a => update default k (some a) k') (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some (update (fun x => []) k L k')))) i

tactic: rw [ListBlank.nth_mk, List.getI_eq_iget_get?, List.map, List.reverse_nil]
state_before: case neg
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
h : ¬k' = k
⊢ Option.iget (Option.map (fun a => default k') (List.get? (List.reverse L) i)) =
    ListBlank.nth (ListBlank.mk (List.reverse (List.map some []))) i

tactic: cases L.reverse.get? i <;> rfl
state_before: case neg
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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 => PointedMap.f (proj k') (update default k (some a))
h : ¬k' = k
⊢ Option.iget (Option.map (fun a => default k') (List.get? (List.reverse L) i)) = Option.iget (List.get? [] i)

tactic: rw [trInit, TM1.init]
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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)) (List.reverse L)))) }

tactic: dsimp only
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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))) (List.reverse L);
          (true, (List.headI L').snd) :: List.tail L') } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) (List.reverse L)))) }

tactic: congr <;> cases L.reverse <;> try rfl
state_before: K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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.headI (List.map (fun a => (false, update (fun x => none) k (some a))) (List.reverse L))).snd) ::
            List.tail (List.map (fun a => (false, update (fun x => none) k (some a))) (List.reverse L))) } =
    { l := Option.map normal (some default), var := default,
      Tape := Tape.mk' ∅ (addBottom (ListBlank.mk (List.map (fun a => update default k (some a)) (List.reverse L)))) }

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

tactic: rfl
state_before: case e_Tape.e_l.e_tail.cons
K : Type u_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : 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_2
inst✝² : DecidableEq K
Γ : K → Type u_1
Λ : Type u_3
inst✝¹ : Inhabited Λ
σ : Type u_4
inst✝ : Inhabited σ
M : Λ → Stmt₂
k : K
L : List (Γ k)
head✝ : Γ k
tail✝ : List (Γ k)
⊢ List.tail (List.map (fun a => (false, update (fun x => none) k (some a))) (head✝ :: tail✝)) =
    List.map { f := Prod.mk false, map_pt' := (_ : (false, default) = (false, default)) }.f
      (List.tail (List.map (fun a => update default k (some a)) (head✝ :: tail✝)))