l3lab/ntp-mathlib huggingface dataset:
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
  refine' s.induction_on _ _
  · simp only [filter_zero, nsmul_zero]
  · intro a ha ih
    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
    congr
    split_ifs with hp <;>
      · simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
        

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
n : ℕ
a : α
ha : Multiset α
ih : filter p (n • ha) = n • filter p ha
hp : p a
⊢ ∀ a_1 ∈ n • {a}, p a_1

Next tactic:
intro b hb
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
  refine' s.induction_on _ _
  · simp only [filter_zero, nsmul_zero]
  · intro a ha ih
    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
    congr
    split_ifs with hp <;>
      · simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
        intro b hb
        

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
n : ℕ
a : α
ha : Multiset α
ih : filter p (n • ha) = n • filter p ha
hp : p a
b : α
hb : b ∈ n • {a}
⊢ p b

Next tactic:
rwa [mem_singleton.mp (mem_of_mem_nsmul hb)]
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
  refine' s.induction_on _ _
  · simp only [filter_zero, nsmul_zero]
  · intro a ha ih
    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
    congr
    split_ifs with hp <;>
      · 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
n : ℕ
a : α
ha : Multiset α
ih : filter p (n • ha) = n • filter p ha
hp : ¬p a
⊢ filter p (n • {a}) = n • 0

Next tactic:
simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
  refine' s.induction_on _ _
  · simp only [filter_zero, nsmul_zero]
  · intro a ha ih
    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
    congr
    split_ifs with hp <;>
      · simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
        

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
n : ℕ
a : α
ha : Multiset α
ih : filter p (n • ha) = n • filter p ha
hp : ¬p a
⊢ ∀ a_1 ∈ n • {a}, ¬p a_1

Next tactic:
intro b hb
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
  refine' s.induction_on _ _
  · simp only [filter_zero, nsmul_zero]
  · intro a ha ih
    rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
    congr
    split_ifs with hp <;>
      · simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
        intro b hb
        

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
n : ℕ
a : α
ha : Multiset α
ih : filter p (n • ha) = n • filter p ha
hp : ¬p a
b : α
hb : b ∈ n • {a}
⊢ ¬p b

Next tactic:
rwa [mem_singleton.mp (mem_of_mem_nsmul hb)]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
s t : Multiset α
⊢ filter p (s - t) = filter p s - filter p t

Next tactic:
revert s
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t : Multiset α
⊢ ∀ (s : Multiset α), filter p (s - t) = filter p s - filter p t

Next tactic:
refine' Multiset.induction_on t (by simp) fun a t IH s => _
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
t : Multiset α
⊢ ∀ (s : Multiset α), filter p (s - 0) = filter p s - filter p 0

Next tactic:
simp
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
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)

Next tactic:
rw [sub_cons, IH]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
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)

Next tactic:
by_cases h : p a
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
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)

Next tactic:
rw [filter_cons_of_pos _ h, sub_cons]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
congr
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    

Proof state:
case pos.e_a
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
by_cases m : a ∈ s
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
  · 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
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)

Next tactic:
rw [filter_cons_of_neg _ h]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
  · rw [filter_cons_of_neg _ h]
    

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
by_cases m : a ∈ s
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
  · rw [filter_cons_of_neg _ h]
    by_cases m : a ∈ s
    · 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
rw [(by rw [filter_cons_of_neg _ h] : filter p (erase s a) = filter p (a ::ₘ erase s a)),
        cons_erase m]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
  · rw [filter_cons_of_neg _ h]
    by_cases m : a ∈ s
    · rw [(by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
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)

Next tactic:
rw [filter_cons_of_neg _ h]
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
    filter p (s - t) = filter p s - filter p t := by
  revert s; refine' Multiset.induction_on t (by simp) fun a t IH s => _
  rw [sub_cons, IH]
  by_cases h : p a
  · rw [filter_cons_of_pos _ h, sub_cons]
    congr
    by_cases m : a ∈ s
    · rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
        cons_erase m]
    · rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
  · rw [filter_cons_of_neg _ h]
    by_cases m : a ∈ s
    · rw [(by rw [filter_cons_of_neg _ h] : filter p (erase s a) = filter p (a ::ₘ erase s a)),
        cons_erase m]
    · 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
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

Next tactic:
rw [erase_of_not_mem m]
@[simp]
theorem filter_union [DecidableEq α] (s t : Multiset α) :
    filter p (s ∪ t) = filter p s ∪ filter p t := by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidableEq α
s t : Multiset α
⊢ filter p (s ∪ t) = filter p s ∪ filter p t

Next tactic:
simp [(· ∪ ·), union]
@[simp]
theorem filter_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p (filter q s) = filter (fun a => p a ∧ q a) s :=
  Quot.inductionOn s fun l => by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s : Multiset α
l : List α
⊢ filter p (filter q (Quot.mk Setoid.r l)) = filter (fun a => p a ∧ q a) (Quot.mk Setoid.r l)

Next tactic:
simp
lemma filter_comm (q) [DecidablePred q] (s : Multiset α) :
    filter p (filter q s) = filter q (filter p s) := by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s : Multiset α
⊢ filter p (filter q s) = filter q (filter p s)

Next tactic:
simp [and_comm]
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
by_cases p a
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝ : p a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
by_cases q a
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝ : ¬p a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
by_cases q a
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝¹ : p a
h✝ : q a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
simp [*]
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝¹ : p a
h✝ : ¬q a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
simp [*]
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> 

Proof state:
case pos
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝¹ : ¬p a
h✝ : q a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
simp [*]
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
    filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
  Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> 

Proof state:
case neg
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
q : α → Prop
inst✝ : DecidablePred q
s✝ : Multiset α
a : α
s : Multiset α
IH : filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s
h✝¹ : ¬p a
h✝ : ¬q a
⊢ filter p (a ::ₘ s) + filter q (a ::ₘ s) =
    filter (fun a => p a ∨ q a) (a ::ₘ s) + filter (fun a => p a ∧ q a) (a ::ₘ s)

Next tactic:
simp [*]
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
⊢ filter p s + filter (fun a => ¬p a) s = s

Next tactic:
rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
  rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
  · 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
⊢ s + 0 = s

Next tactic:
simp only [add_zero]
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
  rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
  · simp only [add_zero]
  · 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
⊢ ∀ a ∈ s, ¬(p a ∧ ¬p a)

Next tactic:
simp [Decidable.em, -Bool.not_eq_true, -not_and, not_and_or, or_comm]
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
  rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
  · simp only [add_zero]
  · simp [Decidable.em, -Bool.not_eq_true, -not_and, not_and_or, or_comm]
  · 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
s : Multiset α
⊢ ∀ a ∈ s, p a ∨ ¬p a

Next tactic:
simp only [Bool.not_eq_true, decide_eq_true_eq, Bool.eq_false_or_eq_true,
      decide_True, implies_true, Decidable.em]
theorem map_filter (f : β → α) (s : Multiset β) : filter p (map f s) = map f (filter (p ∘ f) s) :=
  Quot.inductionOn s fun l => by 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
f : β → α
s : Multiset β
l : List β
⊢ filter p (map f (Quot.mk Setoid.r l)) = map f (filter (p ∘ f) (Quot.mk Setoid.r l))

Next tactic:
simp [List.map_filter]
theorem map_filter (f : β → α) (s : Multiset β) : filter p (map f s) = map f (filter (p ∘ f) s) :=
  Quot.inductionOn s fun l => by simp [List.map_filter]; 

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝ : DecidablePred p
f : β → α
s : Multiset β
l : List β
⊢ List.map f (List.filter ((fun b => decide (p b)) ∘ f) l) ~ List.map f (List.filter (fun b => decide (p (f b))) l)

Next tactic:
rfl
lemma map_filter' {f : α → β} (hf : Injective f) (s : Multiset α)
    [DecidablePred fun b => ∃ a, p a ∧ f a = b] :
    (s.filter p).map f = (s.map f).filter fun b => ∃ a, p a ∧ f a = b := by
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
f : α → β
hf : Injective f
s : Multiset α
inst✝ : DecidablePred fun b => ∃ a, p a ∧ f a = b
⊢ map f (filter p s) = filter (fun b => ∃ a, p a ∧ f a = b) (map f s)

Next tactic:
simp [(· ∘ ·), map_filter, hf.eq_iff]
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
  

Proof state:
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
s : Multiset α
P : α → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ card (filter P s) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬P a

Next tactic:
fconstructor
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
  fconstructor
  · 

Proof state:
case mp
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
s : Multiset α
P : α → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ card (filter P s) ≤ n → ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬P a

Next tactic:
intro H s' hs' s'_card
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
  fconstructor
  · intro H s' hs' s'_card
    

Proof state:
case mp
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
s : Multiset α
P : α → Prop
inst✝ : DecidablePred P
n : ℕ
H : card (filter P s) ≤ n
s' : Multiset α
hs' : s' ≤ s
s'_card : n < card s'
⊢ ∃ a ∈ s', ¬P a

Next tactic:
by_contra! rid
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
  fconstructor
  · intro H s' hs' s'_card
    by_contra! rid
    

Proof state:
case mp
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
s : Multiset α
P : α → Prop
inst✝ : DecidablePred P
n : ℕ
H : card (filter P s) ≤ n
s' : Multiset α
hs' : s' ≤ s
s'_card : n < card s'
rid : ∀ a ∈ s', P a
⊢ False

Next tactic:
have card := card_le_of_le (monotone_filter_left P hs') |>.trans H
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
    card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
  fconstructor
  · intro H s' hs' s'_card
    by_contra! rid
    have card := card_le_of_le (monotone_filter_left P hs') |>.trans H
    

Proof state:
case mp
α : Type u_1
β : Type v
γ : Type u_2
p : α → Prop
inst✝¹ : DecidablePred p
s : Multiset α
P : α → Prop
inst✝ : DecidablePred P
n : ℕ
H : Multiset.card (filter P s) ≤ n
s' : Multiset α
hs' : s' ≤ s
s'_card : n < Multiset.card s'
rid : ∀ a ∈ s', P a
card : Multiset.card (filter P s') ≤ n
⊢ False

Next tactic:
exact s'_card.not_le (filter_eq_self.mpr rid ▸ card)