The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Fintype.Sets
60 declarations and 2 deprecated aliases. Mathlib docs · Source
Subsets of finite types
In a Fintype, all Sets are automatically Finsets, and there are only finitely many of them.
Main results
Set.toFinset: convert a subset of a finite type to aFinsetFinset.fintypeCoeSort:((s : Finset α) : Type*)is a finite typeFintype.finsetEquivSet:Finset αandSet αare equivalent ifαis aFintype
Fintype (s : Finset α)
def Set.toFinset E3 #
{α : Type u_1} → (s : Set α) → [Fintype ↑s] → Finset α
Construct a finset enumerating a set s, given a Fintype instance.
theorem Set.toFinset_congr E1 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s = t → s.toFinset = t.toFinset
theorem Set.mem_toFinset E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s] {a : α}, a ∈ s.toFinset ↔ a ∈ s
theorem Set.toFinset_ofFinset E1 #
∀ {α : Type u_1} {p : Set α} (s : Finset α) (H : ∀ (x : α), x ∈ s ↔ x ∈ p), p.toFinset = s
Many Fintype instances for sets are defined using an extensionally equal Finset.
Rewriting s.toFinset with Set.toFinset_ofFinset replaces the term with such a Finset.
def Set.decidableMemOfFintype E1 #
{α : Type u_1} → [DecidableEq α] → (s : Set α) → [Fintype ↑s] → (a : α) → Decidable (a ∈ s)
Membership of a set with a Fintype instance is decidable.
Using this as an instance leads to potential loops with Subtype.fintype under certain decidability
assumptions, so it should only be declared a local instance.
theorem Set.coe_toFinset E0 #
∀ {α : Type u_1} (s : Set α) [inst : Fintype ↑s], ↑s.toFinset = s
theorem Set.toFinset_nonempty E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s], s.toFinset.Nonempty ↔ s.Nonempty
theorem Set.Aesop.toFinset_nonempty_of_nonempty E1 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s], s.Nonempty → s.toFinset.Nonempty
Alias of the reverse direction of Set.toFinset_nonempty.
theorem Set.toFinset_inj E0 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s.toFinset = t.toFinset ↔ s = t
theorem Set.toFinset_subset_toFinset E1 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s.toFinset ⊆ t.toFinset ↔ s ⊆ t
theorem Set.toFinset_ssubset E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s] {t : Finset α}, s.toFinset ⊂ t ↔ s ⊂ ↑t
theorem Set.subset_toFinset E0 #
∀ {α : Type u_1} {t : Set α} {s : Finset α} [inst : Fintype ↑t], s ⊆ t.toFinset ↔ ↑s ⊆ t
theorem Set.ssubset_toFinset E0 #
∀ {α : Type u_1} {t : Set α} {s : Finset α} [inst : Fintype ↑t], s ⊂ t.toFinset ↔ ↑s ⊂ t
theorem Set.toFinset_ssubset_toFinset E1 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s.toFinset ⊂ t.toFinset ↔ s ⊂ t
theorem Set.toFinset_subset E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s] {t : Finset α}, s.toFinset ⊆ t ↔ s ⊆ ↑t
theorem Set.toFinset_mono E1 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s ⊆ t → s.toFinset ⊆ t.toFinset
Alias of the reverse direction of Set.toFinset_subset_toFinset.
theorem Set.toFinset_strict_mono E1 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s ⊂ t → s.toFinset ⊂ t.toFinset
Alias of the reverse direction of Set.toFinset_ssubset_toFinset.
theorem Set.disjoint_toFinset E0 #
∀ {α : Type u_1} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], Disjoint s.toFinset t.toFinset ↔ Disjoint s t
theorem Set.toFinset_nontrivial E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s], s.toFinset.Nontrivial ↔ s.Nontrivial
theorem Set.subsingleton_toFinset_iff E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s], Subsingleton ↥s.toFinset ↔ s.Subsingleton
theorem Set.toFinset_inter E0 #
∀ {α : Type u_1} (s t : Set α) [inst : DecidableEq α] [inst_1 : Fintype ↑s] [inst_2 : Fintype ↑t]
[inst_3 : Fintype ↑(s ∩ t)], (s ∩ t).toFinset = s.toFinset ∩ t.toFinset
theorem Set.toFinset_union E0 #
∀ {α : Type u_1} (s t : Set α) [inst : DecidableEq α] [inst_1 : Fintype ↑s] [inst_2 : Fintype ↑t]
[inst_3 : Fintype ↑(s ∪ t)], (s ∪ t).toFinset = s.toFinset ∪ t.toFinset
theorem Set.toFinset_sdiff E0 #
∀ {α : Type u_1} (s t : Set α) [inst : DecidableEq α] [inst_1 : Fintype ↑s] [inst_2 : Fintype ↑t]
[inst_3 : Fintype ↑(s \ t)], (s \ t).toFinset = s.toFinset \ t.toFinset
theorem Set.toFinset_symmDiff E0 #
∀ {α : Type u_1} (s t : Set α) [inst : DecidableEq α] [inst_1 : Fintype ↑s] [inst_2 : Fintype ↑t]
[inst_3 : Fintype ↑(symmDiff s t)], (symmDiff s t).toFinset = symmDiff s.toFinset t.toFinset
theorem Set.toFinset_compl E0 #
∀ {α : Type u_1} (s : Set α) [inst : DecidableEq α] [inst_1 : Fintype ↑s] [inst_2 : Fintype α] [inst_3 : Fintype ↑sᶜ],
sᶜ.toFinset = s.toFinsetᶜ
theorem Set.toFinset_empty E0 #
∀ {α : Type u_1} [inst : Fintype ↑∅], ∅.toFinset = ∅
theorem Set.toFinset_univ E0 #
∀ {α : Type u_1} [inst : Fintype α] [inst_1 : Fintype ↑Set.univ], Set.univ.toFinset = Finset.univ
theorem Set.toFinset_eq_empty E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype ↑s], s.toFinset = ∅ ↔ s = ∅
theorem Set.toFinset_eq_univ E0 #
∀ {α : Type u_1} {s : Set α} [inst : Fintype α] [inst_1 : Fintype ↑s], s.toFinset = Finset.univ ↔ s = Set.univ
theorem Set.toFinset_ofPred E0 #
∀ {α : Type u_1} [inst : Fintype α] (p : α → Prop) [inst_1 : DecidablePred p] [inst_2 : Fintype ↑{x | p x}],
{x | p x}.toFinset = Finset.filter p Finset.univ
theorem Set.toFinset_ssubset_univ E1 #
∀ {α : Type u_1} [inst : Fintype α] {s : Set α} [inst_1 : Fintype ↑s], s.toFinset ⊂ Finset.univ ↔ s ⊂ Set.univ
theorem Set.toFinset_image E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (f : α → β) (s : Set α) [inst_1 : Fintype ↑s]
[inst_2 : Fintype ↑(f '' s)], (f '' s).toFinset = Finset.image f s.toFinset
theorem Set.toFinset_range E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq α] [inst_1 : Fintype β] (f : β → α)
[inst_2 : Fintype ↑(Set.range f)], (Set.range f).toFinset = Finset.image f Finset.univ
theorem Set.toFinset_singleton E0 #
∀ {α : Type u_1} (a : α) [inst : Fintype ↑{a}], {a}.toFinset = {a}
theorem Set.toFinset_insert E0 #
∀ {α : Type u_1} [inst : DecidableEq α] {a : α} {s : Set α} [inst_1 : Fintype ↑(insert a s)] [inst_2 : Fintype ↑s],
(insert a s).toFinset = insert a s.toFinset
theorem Set.filter_mem_univ_eq_toFinset E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Set α) [inst_1 : Fintype ↑s] [inst_2 : DecidablePred fun x ↦ x ∈ s],
{x | x ∈ s} = s.toFinset
theorem Finset.toFinset_coe E0 #
∀ {α : Type u_1} (s : Finset α) [inst : Fintype ↑↑s], (↑s).toFinset = s
instance Finset.fintypeCoeSort E3 #
{α : Type u} → (s : Finset α) → Fintype ↥s
theorem Finset.univ_eq_attach E0 #
∀ {α : Type u} (s : Finset α), Finset.univ = s.attach
theorem Fintype.coe_image_univ E0 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : DecidableEq β] {f : α → β},
↑(Finset.image f Finset.univ) = Set.range f
instance List.Subtype.fintype E0 #
{α : Type u_1} → [DecidableEq α] → (l : List α) → Fintype { x // x ∈ l }
instance Multiset.Subtype.fintype E0 #
{α : Type u_1} → [DecidableEq α] → (s : Multiset α) → Fintype { x // x ∈ s }
instance Finset.Subtype.fintype E0 #
{α : Type u_1} → (s : Finset α) → Fintype ↥s
instance FinsetCoe.fintype E0 #
{α : Type u_1} → (s : Finset α) → Fintype ↑↑s
theorem Finset.attach_eq_univ E1 #
∀ {α : Type u_1} {s : Finset α}, s.attach = Finset.univ
instance Prop.fintype E0 #
Fintype Prop
theorem Fintype.univ_Prop E0 #
∀ [inst : DecidableEq Prop], Finset.univ = {True, False}
instance Subtype.fintype E0 #
{α : Type u_1} → (p : α → Prop) → [DecidablePred p] → [Fintype α] → Fintype { x // p x }
def setFintype E1 #
{α : Type u_1} → [Fintype α] → (s : Set α) → [DecidablePred fun x ↦ x ∈ s] → Fintype ↑s
A set on a fintype, when coerced to a type, is a fintype.
def Fintype.finsetEquivSet E3 #
{α : Type u_1} → [Fintype α] → Finset α ≃ Set α
Given Fintype α, finsetEquivSet is the equiv between Finset α and Set α. (All
sets on a finite type are finite.)
theorem Fintype.coe_finsetEquivSet E0 #
∀ {α : Type u_1} [inst : Fintype α], ⇑Fintype.finsetEquivSet = SetLike.coe
theorem Fintype.finsetEquivSet_apply E0 #
∀ {α : Type u_1} [inst : Fintype α] (s : Finset α), Fintype.finsetEquivSet s = ↑s
theorem Fintype.finsetEquivSet_symm_apply E0 #
∀ {α : Type u_1} [inst : Fintype α] (s : Set α) [inst_1 : Fintype ↑s], Fintype.finsetEquivSet.symm s = s.toFinset
def Fintype.finsetOrderIsoSet E1 #
{α : Type u_1} → [Fintype α] → Finset α ≃o Set α
Given a fintype α, finsetOrderIsoSet is the order isomorphism between Finset α and Set α
(all sets on a finite type are finite).
theorem Fintype.finsetOrderIsoSet_toEquiv E0 #
∀ {α : Type u_1} [inst : Fintype α], Fintype.finsetOrderIsoSet.toEquiv = Fintype.finsetEquivSet
theorem Fintype.coe_finsetOrderIsoSet E0 #
∀ {α : Type u_1} [inst : Fintype α], ⇑Fintype.finsetOrderIsoSet = SetLike.coe
theorem Fintype.coe_finsetOrderIsoSet_symm E0 #
∀ {α : Type u_1} [inst : Fintype α], ⇑Fintype.finsetOrderIsoSet.symm = ⇑Fintype.finsetEquivSet.symm
theorem mem_image_univ_iff_mem_range E0 #
∀ {α : Type u_3} {β : Type u_4} [inst : Fintype α] [inst_1 : DecidableEq β] {f : α → β} {b : β},
b ∈ Finset.image f Finset.univ ↔ b ∈ Set.range f
def finsetStx E1 #
Lean.ParserDescr
finset% t elaborates t as a Finset.
If t is a Set, then inserts Set.toFinset.
Does not make use of the expected type; useful for big operators over finsets.
#check finset% Finset.range 2 -- Finset Nat
#check finset% (Set.univ : Set Bool) -- Finset Bool
def precheckFinsetStx E1 #
Lean.Elab.Term.Quotation.Precheck
quot_precheck for the finset% syntax.
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Set.toFinset_diff | Set.toFinset_sdiff | 2026-06-03 |
Set.toFinset_setOf | Set.toFinset_ofPred | 2026-07-09 |