Skip to content

Commit 835057f

Browse files
committed
chore(Multiset,Finset): add filter_true/filter_false (#28838)
- Add `Multiset.filter_true` and `Multiset.filter_false`. - Rename `Finset.filter_True` to `Finset.filter_true`. - Rename `Finset.filter_False` to `Finset.filter_false`. - Add `@[simp]` to `filter_true`/`filter_false`/`filter_eq_self`/`filter_eq_nil`.
1 parent c3c8322 commit 835057f

File tree

10 files changed

+24
-11
lines changed

10 files changed

+24
-11
lines changed

Mathlib/AlgebraicTopology/DoldKan/Decomposition.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ theorem decomposition_Q (n q : ℕ) :
5252
∑ i : Fin (n + 1) with i.val < q, (P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by
5353
induction' q with q hq
5454
· simp only [Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero,
55-
Finset.filter_False, Finset.sum_empty]
55+
Finset.filter_false, Finset.sum_empty]
5656
· by_cases hqn : q + 1 ≤ n + 1
5757
swap
5858
· rw [Q_is_eventually_constant (show n + 1 ≤ q by omega), hq]

Mathlib/Combinatorics/SimpleGraph/Finite.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ theorem complete_graph_degree [DecidableEq V] (v : V) :
297297

298298
@[simp]
299299
theorem bot_degree (v : V) : (⊥ : SimpleGraph V).degree v = 0 := by
300-
simp_rw [degree, neighborFinset_eq_filter, bot_adj, filter_False]
300+
simp_rw [degree, neighborFinset_eq_filter, bot_adj, filter_false]
301301
exact Finset.card_empty
302302

303303
theorem IsRegularOfDegree.top [DecidableEq V] :

Mathlib/Data/DFinsupp/NeLocus.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } :=
5252
theorem neLocus_eq_empty {f g : Π₀ a, N a} : f.neLocus g = ∅ ↔ f = g :=
5353
fun h ↦
5454
ext fun a ↦ not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_notMem.mp h a)),
55-
fun h ↦ h ▸ by simp only [neLocus, Ne, not_true, Finset.filter_False]⟩
55+
fun h ↦ h ▸ by simp only [neLocus, Ne, not_true, Finset.filter_false]⟩
5656

5757
@[simp]
5858
theorem nonempty_neLocus_iff {f g : Π₀ a, N a} : (f.neLocus g).Nonempty ↔ f ≠ g :=

Mathlib/Data/Finset/Filter.lean

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,21 @@ theorem filter_congr_decidable (s : Finset α) (p : α → Prop) (h : DecidableP
141141
[DecidablePred p] : @filter α p h s = s.filter p := by congr
142142

143143
@[simp]
144-
theorem filter_True {h} (s : Finset α) : @filter _ (fun _ => True) h s = s := by ext; simp
144+
theorem filter_true {h} (s : Finset α) : @filter _ (fun _ => True) h s = s := by ext; simp
145+
146+
@[deprecated (since := "2025-08-24")] alias filter_True := filter_true
145147

146148
@[simp]
147-
theorem filter_False {h} (s : Finset α) : @filter _ (fun _ => False) h s = ∅ := by ext; simp
149+
theorem filter_false {h} (s : Finset α) : @filter _ (fun _ => False) h s = ∅ := by ext; simp
150+
151+
@[deprecated (since := "2025-08-24")] alias filter_False := filter_false
148152

149153
variable {p q}
150154

155+
@[simp]
151156
lemma filter_eq_self : s.filter p = s ↔ ∀ x ∈ s, p x := by simp [Finset.ext_iff]
152157

158+
@[simp]
153159
theorem filter_eq_empty_iff : s.filter p = ∅ ↔ ∀ ⦃x⦄, x ∈ s → ¬p x := by simp [Finset.ext_iff]
154160

155161
theorem filter_nonempty_iff : (s.filter p).Nonempty ↔ ∃ a ∈ s, p a := by

Mathlib/Data/Finsupp/NeLocus.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by
5454
theorem neLocus_eq_empty {f g : α →₀ N} : f.neLocus g = ∅ ↔ f = g :=
5555
fun h =>
5656
ext fun a => not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_notMem.mp h a)),
57-
fun h => h ▸ by simp only [neLocus, Ne, not_true, Finset.filter_False]⟩
57+
fun h => h ▸ by simp only [neLocus, Ne, not_true, Finset.filter_false]⟩
5858

5959
@[simp]
6060
theorem nonempty_neLocus_iff {f g : α →₀ N} : (f.neLocus g).Nonempty ↔ f ≠ g :=

Mathlib/Data/Multiset/Filter.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,23 @@ theorem mem_of_mem_filter {a : α} {s} (h : a ∈ filter p s) : a ∈ s :=
9696
theorem mem_filter_of_mem {a : α} {l} (m : a ∈ l) (h : p a) : a ∈ filter p l :=
9797
mem_filter.2 ⟨m, h⟩
9898

99+
@[simp]
99100
theorem filter_eq_self {s} : filter p s = s ↔ ∀ a ∈ s, p a :=
100101
Quot.inductionOn s fun _l =>
101102
Iff.trans ⟨fun h => filter_sublist.eq_of_length (congr_arg card h),
102103
congr_arg ofList⟩ <| by simp
103104

105+
@[simp]
104106
theorem filter_eq_nil {s} : filter p s = 0 ↔ ∀ a ∈ s, ¬p a :=
105107
Quot.inductionOn s fun _l =>
106108
Iff.trans ⟨fun h => eq_nil_of_length_eq_zero (congr_arg card h), congr_arg ofList⟩ (by simp)
107109

110+
@[simp]
111+
lemma filter_true (s : Multiset α) : s.filter (fun _ ↦ True) = s := by simp
112+
113+
@[simp]
114+
lemma filter_false (s : Multiset α) : s.filter (fun _ ↦ False) = 0 := by simp
115+
108116
theorem le_filter {s t} : s ≤ filter p t ↔ s ≤ t ∧ ∀ a ∈ s, p a :=
109117
fun h => ⟨le_trans h (filter_le _ _), fun _a m => of_mem_filter (mem_of_le h m)⟩, fun ⟨h, al⟩ =>
110118
filter_eq_self.2 al ▸ filter_le_filter p h⟩

Mathlib/Data/Nat/Count.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ alias ⟨_, count_of_forall⟩ := count_iff_forall
133133
@[simp] theorem count_true (n : ℕ) : count (fun _ ↦ True) n = n := count_of_forall fun _ _ ↦ trivial
134134

135135
theorem count_iff_forall_not {n : ℕ} : count p n = 0 ↔ ∀ m < n, ¬p m := by
136-
simpa [count_eq_card_filter_range, mem_range] using
137-
card_filter_eq_zero_iff (p := p) (s := range n)
136+
simp [count_eq_card_filter_range]
138137

139138
alias ⟨_, count_of_forall_not⟩ := count_iff_forall_not
140139

Mathlib/LinearAlgebra/LinearIndependent/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ theorem linearIndependent_sum {v : ι ⊕ ι' → M} :
452452
-- Porting note: `g` must be specified.
453453
rw [Finset.sum_preimage' (g := fun x => g x • v x),
454454
Finset.sum_preimage' (g := fun x => g x • v x), ← Finset.sum_union, ← Finset.filter_or]
455-
· simpa only [← mem_union, range_inl_union_range_inr, mem_univ, Finset.filter_True]
455+
· simpa only [← mem_union, range_inl_union_range_inr, mem_univ, Finset.filter_true]
456456
· exact Finset.disjoint_filter.2 fun x _ hx =>
457457
disjoint_left.1 isCompl_range_inl_range_inr.disjoint hx
458458
rw [← eq_neg_iff_add_eq_zero] at this

Mathlib/LinearAlgebra/Matrix/SemiringInverse.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ theorem detp_mul :
9595

9696
theorem mul_adjp_apply_eq : (A * adjp s A) i i = detp s A := by
9797
have key := sum_fiberwise_eq_sum_filter (ofSign s) univ (· i) fun σ ↦ ∏ k, A k (σ k)
98-
simp_rw [mem_univ, filter_True] at key
98+
simp_rw [mem_univ, filter_true] at key
9999
simp_rw [mul_apply, adjp_apply, mul_sum, detp, ← key]
100100
refine sum_congr rfl fun x hx ↦ sum_congr rfl fun σ hσ ↦ ?_
101101
rw [← prod_mul_prod_compl ({i} : Finset n), prod_singleton, (mem_filter.mp hσ).2]

Mathlib/Order/Partition/Finpartition.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ theorem mem_atomise :
732732

733733
theorem atomise_empty (hs : s.Nonempty) : (atomise s ∅).parts = {s} := by
734734
simp only [atomise, powerset_empty, image_singleton, notMem_empty, IsEmpty.forall_iff,
735-
imp_true_iff, filter_True]
735+
imp_true_iff, filter_true]
736736
exact erase_eq_of_notMem (notMem_singleton.2 hs.ne_empty.symm)
737737

738738
theorem card_atomise_le : #(atomise s F).parts ≤ 2 ^ #F :=

0 commit comments

Comments
 (0)