Theorem: List.modifyLast_append_one
File: Mathlib/Data/List/Basic.lean

tactic: cases l with
| nil =>
  simp only [nil_append, modifyLast, modifyLast.go, Array.toListAppend_eq, Array.data_toArray]
| cons _ tl =>
  simp only [cons_append, modifyLast]
  rw [modifyLast.go]
  case x_3 => exact append_ne_nil_of_ne_nil_right tl [a] (cons_ne_nil a [])
  rw [modifyLast.go_append_one, Array.toListAppend_eq, Array.push_data, Array.data_toArray,
    nil_append, cons_append, nil_append, cons_inj_right]
  exact modifyLast_append_one _ _ tl
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a : α
l : List α
⊢ modifyLast f (l ++ [a]) = l ++ [f a]
state_after: no goals

tactic: simp only [nil_append, modifyLast, modifyLast.go, Array.toListAppend_eq, Array.data_toArray]
state_before: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a : α
⊢ modifyLast f ([] ++ [a]) = [] ++ [f a]
state_after: no goals

tactic: simp only [cons_append, modifyLast]
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast f (head✝ :: tl ++ [a]) = head✝ :: tl ++ [f a]
state_after: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (head✝ :: (tl ++ [a])) #[] = head✝ :: (tl ++ [f a])

tactic: rw [modifyLast.go]
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (head✝ :: (tl ++ [a])) #[] = head✝ :: (tl ++ [f a])
state_after: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) (#[].push head✝) = head✝ :: (tl ++ [f a])

case cons.x_3
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ tl ++ [a] = [] → False

tactic: case x_3 => exact append_ne_nil_of_ne_nil_right tl [a] (cons_ne_nil a [])
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) (#[].push head✝) = head✝ :: (tl ++ [f a])

case cons.x_3
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ tl ++ [a] = [] → False
state_after: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) (#[].push head✝) = head✝ :: (tl ++ [f a])

tactic: rw [modifyLast.go_append_one, Array.toListAppend_eq, Array.push_data, Array.data_toArray,
  nil_append, cons_append, nil_append, cons_inj_right]
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) (#[].push head✝) = head✝ :: (tl ++ [f a])
state_after: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) #[] = tl ++ [f a]

tactic: exact modifyLast_append_one _ _ tl
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ modifyLast.go f (tl ++ [a]) #[] = tl ++ [f a]
state_after: no goals

tactic: exact append_ne_nil_of_ne_nil_right tl [a] (cons_ne_nil a [])
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
f : α → α
a head✝ : α
tl : List α
⊢ tl ++ [a] = [] → False
state_after: no goals