-- Mathlib/Computability/TuringMachine.lean
theorem trCfg_init (k) (L : List (Γ k)) : TrCfg (TM2.init k L)
    (TM1.init (trInit k L) : TM1.Cfg (Γ' K Γ) (Λ' K Γ Λ σ) σ)

Proof state:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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)[i]?.iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

Tactic:
rw [this, List.getElem?_map, proj, PointedMap.mk_val]

Result:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

Proof state:
case pos
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget = (ListBlank.mk (List.map some L).reverse).nth i

Tactic:
rw [ListBlank.nth_mk, List.getI_eq_iget_getElem?, ← List.map_reverse, List.getElem?_map]

Result:
no goals

Proof state:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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_getElem?, List.map_map]

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

Proof state:
case e_Tape.e_l.e_tail.nil
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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

Tactic:
rfl

Result:
no goals

Proof state:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
k : K
L : List (Γ k)
⊢ TrCfg (TM2.init k L) ?m.157252

Tactic:
refine ⟨ListBlank.mk (L.reverse.map fun a ↦ update default k (some a)), fun k' ↦ ?_⟩

Result:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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

Proof state:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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

Result:
case e_Tape.e_l.e_tail.cons
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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

Proof state:
case pos
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

Tactic:
subst k'

Result:
case pos
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k)).reverse).nth i

Proof state:
case neg
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget =
    (ListBlank.mk (List.map some (update (fun x => []) k L k')).reverse).nth i

Tactic:
simp only [Function.update_of_ne h]

Result:
case neg
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget = (ListBlank.mk (List.map some []).reverse).nth i

Proof state:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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 ↦ ?_

Result:
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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

Proof state:
case neg
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget = (ListBlank.mk (List.map some []).reverse).nth i

Tactic:
rw [ListBlank.nth_mk, List.getI_eq_iget_getElem?, List.map, List.reverse_nil]

Result:
case neg
K : Type u_1
Γ : K → Type u_2
Λ : Type u_3
σ : Type u_4
inst✝² : DecidableEq K
inst✝¹ : Inhabited Λ
inst✝ : Inhabited σ
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[i]?).iget = [][i]?.iget