Filtering a finite set #
Main declarations #
Finset.filter: Given a decidable predicatep : α → Prop,s.filter pis the finset consisting of those elements inssatisfying the predicatep.
Tags #
finite sets, finset
filter #
Finset.filter p s is the set of elements of s that satisfy p.
For example, one can use s.filter (· ∈ t) to get the intersection of s with t : Set α
as a Finset α (when a DecidablePred (· ∈ t) instance is available).
Equations
- Finset.filter p s = { val := Multiset.filter p s.val, nodup := ⋯ }
Instances For
Return true if expectedType? is some (Finset ?α), throws throwUnsupportedSyntax if it is
some (Set ?α), and returns false otherwise.
Equations
- One or more equations did not get rendered due to their size.
- Mathlib.Meta.knownToBeFinsetNotSet none = pure false
Instances For
Elaborate set builder notation for Finset.
{x ∈ s | p x} is elaborated as Finset.filter (fun x ↦ p x) s if either the expected type is
Finset ?α or the expected type is not Set ?α and s has expected type Finset ?α.
See also
Data.Set.Defsfor theSetbuilder notation elaborator that this elaborator partly overrides.Data.Fintype.Basicfor theFinsetbuilder notation elaborator handling syntax of the form{x | p x},{x : α | p x},{x ∉ s | p x},{x ≠ a | p x}.Order.LocallyFinite.Basicfor theFinsetbuilder notation elaborator handling syntax of the form{x ≤ a | p x},{x ≥ a | p x},{x < a | p x},{x > a | p x}.
TODO: Write a delaborator
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
@[simp]
theorem Finset.filter_subset {α : Type u_1} (p : α → Prop) [DecidablePred p] (s : Finset α) :
filter p s ⊆ s
theorem Finset.mem_of_mem_filter {α : Type u_1} {p : α → Prop} [DecidablePred p] {s : Finset α} (x : α) (h : x ∈ filter p s) :
theorem Finset.filter_filter {α : Type u_1} (p q : α → Prop) [DecidablePred p] [DecidablePred q] (s : Finset α) :
theorem Finset.filter_comm {α : Type u_1} (p q : α → Prop) [DecidablePred p] [DecidablePred q] (s : Finset α) :
theorem Finset.filter_congr_decidable {α : Type u_1} (s : Finset α) (p : α → Prop) (h : DecidablePred p) [DecidablePred p] :
@[simp]
@[simp]
theorem Finset.filter_false {α : Type u_1} {h : DecidablePred fun (x : α) => False} (s : Finset α) :
@[simp]
theorem Finset.filter_congr {α : Type u_1} {p q : α → Prop} [DecidablePred p] [DecidablePred q] {s : Finset α} (H : ∀ (x : α), x ∈ s → (p x ↔ q x)) :
@[simp]
theorem Finset.filter_subset_filter {α : Type u_1} (p : α → Prop) [DecidablePred p] {s t : Finset α} (h : s ⊆ t) :
theorem Finset.monotone_filter_right {α : Type u_1} (s : Finset α) ⦃p q : α → Prop⦄ [DecidablePred p] [DecidablePred q] (h : ∀ (a : α), a ∈ s → p a → q a) :
theorem Finset.subset_coe_filter_of_subset_forall {α : Type u_1} (p : α → Prop) [DecidablePred p] (s : Finset α) {t : Set α} (h₁ : t ⊆ ↑s) (h₂ : ∀ (x : α), x ∈ t → p x) :
t ⊆ ↑(filter p s)
theorem Finset.disjoint_filter_filter {α : Type u_1} {s t : Finset α} {p q : α → Prop} [DecidablePred p] [DecidablePred q] :
theorem Set.pairwiseDisjoint_filter {α : Type u_1} {β : Type u_2} [DecidableEq β] (f : α → β) (s : Set β) (t : Finset α) :
s.PairwiseDisjoint fun (x : β) => Finset.filter (fun (x_1 : α) => f x_1 = x) t
theorem Finset.disjoint_filter_and_not_filter {α : Type u_1} (p q : α → Prop) [DecidablePred p] [DecidablePred q] {s : Finset α} :
theorem Finset.filter_inj' {α : Type u_1} {p q : α → Prop} [DecidablePred p] [DecidablePred q] {s : Finset α} :
@[simp]
theorem Finset.filter_mem_eq_of_subset {α : Type u_1} {s t : Finset α} [DecidablePred fun (x : α) => x ∈ s] (hst : s ⊆ t) :