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

tactic: rw [List.getLast_singleton'] at h'
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a : α
h : filter p [a] ≠ []
h' : p ([a].getLast ⋯) = true
⊢ (filter p [a]).getLast h = [a].getLast ⋯
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a : α
h : filter p [a] ≠ []
h' : p a = true
⊢ (filter p [a]).getLast h = [a].getLast ⋯

tactic: simp [List.filter_cons, h']
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a : α
h : filter p [a] ≠ []
h' : p a = true
⊢ (filter p [a]).getLast h = [a].getLast ⋯
state_after: no goals

tactic: rw [List.getLast_cons_cons] at h' ⊢
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h : filter p (a :: b :: as) ≠ []
h' : p ((a :: b :: as).getLast ⋯) = true
⊢ (filter p (a :: b :: as)).getLast h = (a :: b :: as).getLast ⋯
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
⊢ (filter p (a :: b :: as)).getLast h = (b :: as).getLast ⋯

tactic: simp only [List.filter_cons (x := a)] at h ⊢
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
⊢ (filter p (a :: b :: as)).getLast h = (b :: as).getLast ⋯
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯

tactic: obtain ha | ha := Bool.eq_false_or_eq_true (p a)
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯
state_after: case inl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯

case inr
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = false
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯

tactic: simp only [ha, ite_true]
state_before: case inl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯
state_after: case inl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ (a :: filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯

tactic: rw [getLast_cons, getLast_filter (b :: as) _ h']
state_before: case inl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ (a :: filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ filter p (b :: as) ≠ []

tactic: exact ne_nil_of_mem <| mem_filter.2 ⟨getLast_mem _, h'⟩
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = true
⊢ filter p (b :: as) ≠ []
state_after: no goals

tactic: simp only [ha, cond_false] at h ⊢
state_before: case inr
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
h : (if p a = true then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
ha : p a = false
⊢ (if p a = true then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯
state_after: case inr
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
ha : p a = false
h : (if False then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
⊢ (if False then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯

tactic: exact getLast_filter (b :: as) h h'
state_before: case inr
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
a b : α
as : List α
h✝ : filter p (a :: b :: as) ≠ []
h' : p ((b :: as).getLast ⋯) = true
ha : p a = false
h : (if False then a :: filter p (b :: as) else filter p (b :: as)) ≠ []
⊢ (if False then a :: filter p (b :: as) else filter p (b :: as)).getLast ⋯ = (b :: as).getLast ⋯
state_after: no goals