The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Finset.Filter
34 declarations. Mathlib docs · Source
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
theorem Finset.filter.congr_simp E1 #
∀ {α : Type u_1} (p p_1 : α → Prop),
p = p_1 →
∀ {inst : DecidablePred p} [inst_1 : DecidablePred p_1] (s s_1 : Finset α),
s = s_1 → Finset.filter p s = Finset.filter p_1 s_1
def Finset.filter E3 #
{α : Type u_1} → (p : α → Prop) → [DecidablePred p] → Finset α → Finset α
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).
def Mathlib.Meta.knownToBeFinsetNotSet E1 #
Option Lean.Expr → Lean.Elab.TermElabM Bool
Return true if expectedType? is some (Finset ?α), throws throwUnsupportedSyntax if it is
some (Set ?α), and returns false otherwise.
def Mathlib.Meta.elabFinsetBuilderSep E1 #
Lean.Elab.Term.TermElab
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
theorem Finset.filter_val E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s : Finset α),
(Finset.filter p s).val = Multiset.filter p s.val
theorem Finset.filter_subset E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s : Finset α), Finset.filter p s ⊆ s
theorem Finset.mem_filter E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α} {a : α}, a ∈ Finset.filter p s ↔ a ∈ s ∧ p a
theorem Finset.mem_of_mem_filter E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, ∀ x ∈ Finset.filter p s, x ∈ s
theorem Finset.filter_ssubset E1 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, Finset.filter p s ⊂ s ↔ ∃ x ∈ s, ¬p x
theorem Finset.filter_filter E1 #
∀ {α : Type u_1} (p q : α → Prop) [inst : DecidablePred p] [inst_1 : DecidablePred q] (s : Finset α),
Finset.filter q (Finset.filter p s) = {a ∈ s | p a ∧ q a}
theorem Finset.filter_comm E1 #
∀ {α : Type u_1} (p q : α → Prop) [inst : DecidablePred p] [inst_1 : DecidablePred q] (s : Finset α),
Finset.filter q (Finset.filter p s) = Finset.filter p (Finset.filter q s)
theorem Finset.filter_congr_decidable E1 #
∀ {α : Type u_1} (s : Finset α) (p : α → Prop) (h : DecidablePred p) [inst : DecidablePred p],
Finset.filter p s = Finset.filter p s
theorem Finset.filter_true E0 #
∀ {α : Type u_1} {h : DecidablePred fun x ↦ True} (s : Finset α), {x ∈ s | True} = s
theorem Finset.filter_false E0 #
∀ {α : Type u_1} {h : DecidablePred fun x ↦ False} (s : Finset α), {x ∈ s | False} = ∅
theorem Finset.filter_eq_self E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, Finset.filter p s = s ↔ ∀ x ∈ s, p x
theorem Finset.filter_eq_empty_iff E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, Finset.filter p s = ∅ ↔ ∀ ⦃x : α⦄, x ∈ s → ¬p x
theorem Finset.filter_nonempty_iff E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, (Finset.filter p s).Nonempty ↔ ∃ a ∈ s, p a
theorem Finset.filter_true_of_mem E1 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, (∀ x ∈ s, p x) → Finset.filter p s = s
If all elements of a Finset satisfy the predicate p, s.filter p is s.
theorem Finset.filter_false_of_mem E1 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Finset α}, (∀ x ∈ s, ¬p x) → Finset.filter p s = ∅
If all elements of a Finset fail to satisfy the predicate p, s.filter p is ∅.
theorem Finset.filter_const E0 #
∀ {α : Type u_1} (p : Prop) [inst : Decidable p] (s : Finset α), {_a ∈ s | p} = if p then s else ∅
theorem Finset.filter_congr E1 #
∀ {α : Type u_1} {p q : α → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {s : Finset α},
(∀ x ∈ s, p x ↔ q x) → Finset.filter p s = Finset.filter q s
theorem Finset.filter_congr' E1 #
∀ {α : Type u_1} {p q : α → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {s t : Finset α},
s = t → (∀ x ∈ s, p x ↔ q x) → Finset.filter p s = Finset.filter q t
theorem Finset.filter_empty E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p], Finset.filter p ∅ = ∅
theorem Finset.filter_subset_filter E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] {s t : Finset α}, s ⊆ t → Finset.filter p s ⊆ Finset.filter p t
theorem Finset.monotone_filter_left E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p], Monotone (Finset.filter p)
theorem Finset.monotone_filter_right E1 #
∀ {α : Type u_1} (s : Finset α) ⦃p q : α → Prop⦄ [inst : DecidablePred p] [inst_1 : DecidablePred q],
(∀ a ∈ s, p a → q a) → Finset.filter p s ⊆ Finset.filter q s
theorem Finset.coe_filter E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s : Finset α), ↑(Finset.filter p s) = {x | x ∈ s ∧ p x}
theorem Finset.subset_coe_filter_of_subset_forall E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s : Finset α) {t : Set α},
t ⊆ ↑s → (∀ x ∈ t, p x) → t ⊆ ↑(Finset.filter p s)
theorem Finset.disjoint_filter_filter E1 #
∀ {α : Type u_1} {s t : Finset α} {p q : α → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q],
Disjoint s t → Disjoint (Finset.filter p s) (Finset.filter q t)
theorem Set.pairwiseDisjoint_filter E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (f : α → β) (s : Set β) (t : Finset α),
s.PairwiseDisjoint fun x ↦ {x_1 ∈ t | f x_1 = x}
theorem Finset.disjoint_filter_and_not_filter E1 #
∀ {α : Type u_1} (p q : α → Prop) [inst : DecidablePred p] [inst_1 : DecidablePred q] {s : Finset α},
Disjoint ({x ∈ s | p x ∧ ¬q x}) ({x ∈ s | q x ∧ ¬p x})
theorem Finset.filter_inj E1 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s t : Finset α},
Finset.filter p s = Finset.filter p t ↔ ∀ ⦃a : α⦄, p a → (a ∈ s ↔ a ∈ t)
theorem Finset.filter_inj' E1 #
∀ {α : Type u_1} {p q : α → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {s : Finset α},
Finset.filter p s = Finset.filter q s ↔ ∀ ⦃a : α⦄, a ∈ s → (p a ↔ q a)
theorem Finset.filter_mem_eq_of_subset E0 #
∀ {α : Type u_1} {s t : Finset α} [inst : DecidablePred fun x ↦ x ∈ s], s ⊆ t → {x ∈ t | x ∈ s} = s