Theorem: Multiset.filter_sub
File: Mathlib/Data/Multiset/Basic.lean

tactic: revert s
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
s t : Multiset α
⊢ filter p (s - t) = filter p s - filter p t

tactic: refine' Multiset.induction_on t (by simp) fun a t IH s => _
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t : Multiset α
⊢ ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t

tactic: rw [sub_cons, IH]
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
⊢ filter p (s - a ::ₘ t) = filter p s - filter p (a ::ₘ t)

tactic: by_cases h : p a
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
⊢ filter p (erase s a) - filter p t = filter p s - filter p (a ::ₘ t)

tactic: simp
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t : Multiset α
⊢ ∀ (s : Multiset α), filter p (s - 0) = filter p s - filter p 0

tactic: rw [filter_cons_of_pos _ h, sub_cons]
state_before: case pos
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : p a
⊢ filter p (erase s a) - filter p t = filter p s - filter p (a ::ₘ t)

tactic: congr
state_before: case pos
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : p a
⊢ filter p (erase s a) - filter p t = erase (filter p s) a - filter p t

tactic: by_cases m : a ∈ s
state_before: case pos.e_a
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : p a
⊢ filter p (erase s a) = erase (filter p s) a

tactic: rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
  cons_erase m]
state_before: case pos
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : p a
m : a ∈ s
⊢ filter p (erase s a) = erase (filter p s) a

tactic: rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
state_before: case neg
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : p a
m : ¬a ∈ s
⊢ filter p (erase s a) = erase (filter p s) a

tactic: rw [filter_cons_of_neg _ h]
state_before: case neg
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : ¬p a
⊢ filter p (erase s a) - filter p t = filter p s - filter p (a ::ₘ t)

tactic: by_cases m : a ∈ s
state_before: case neg
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : ¬p a
⊢ filter p (erase s a) - filter p t = filter p s - filter p t

tactic: rw [(by rw [filter_cons_of_neg _ h] : filter p (erase s a) = filter p (a ::ₘ erase s a)),
  cons_erase m]
state_before: case pos
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : ¬p a
m : a ∈ s
⊢ filter p (erase s a) - filter p t = filter p s - filter p t

tactic: rw [filter_cons_of_neg _ h]
state_before: α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : ¬p a
m : a ∈ s
⊢ filter p (erase s a) = filter p (a ::ₘ erase s a)

tactic: rw [erase_of_not_mem m]
state_before: case neg
α : Type u_1
β : Type ?u.237039
γ : Type ?u.237042
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t✝ : Multiset α
a : α
t : Multiset α
IH : ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t
s : Multiset α
h : ¬p a
m : ¬a ∈ s
⊢ filter p (erase s a) - filter p t = filter p s - filter p t