The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Finset.Defs
78 declarations and 7 deprecated aliases. Mathlib docs · Source
Finite sets
Terms of type Finset α are one way of talking about finite subsets of α in Mathlib.
Below, Finset α is defined as a structure with 2 fields:
valis aMultiset αof elements;nodupis a proof thatvalhas no duplicates.
Finsets in Lean are constructive in that they have an underlying List that enumerates their
elements. In particular, any function that uses the data of the underlying list cannot depend on its
ordering. This is handled on the Multiset level by multiset API, so in most cases one needn't
worry about it explicitly.
Finsets give a basic foundation for defining finite sums and products over types:
∑ i ∈ (s : Finset α), f i;∏ i ∈ (s : Finset α), f i.
Lean refers to these operations as big operators.
More information can be found in Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean.
Finsets are directly used to define fintypes in Lean.
A Fintype α instance for a type α consists of a universal Finset α containing every term of
α, called univ. See Mathlib/Data/Fintype/Basic.lean.
Finset.card, the size of a finset is defined in Mathlib/Data/Finset/Card.lean.
This is then used to define Fintype.card, the size of a type.
File structure
This file defines the Finset type and the membership and subset relations between finsets.
Most constructions involving Finsets have been split off to their own files.
Main definitions
Finset: Defines a type for the finite subsets ofα. Constructing aFinsetrequires two pieces of data:val, aMultiset αof elements, andnodup, a proof thatvalhas no duplicates.a ∈ (s : Finset α)is defined through coercion toSet α.
Tags
finite sets, finset
set coercion
extensionality
type coercion
Subset and strict subset relations
Order embedding from Finset α to Set α
Assorted results
These results can be defined using the current imports, but deserve to be given a nicer home.
theorem Finset.mk.inj E1 #
∀ {α : Type u_3} {val : Multiset α} {nodup : val.Nodup} {val_1 : Multiset α} {nodup_1 : val_1.Nodup},
{ val := val, nodup := nodup } = { val := val_1, nodup := nodup_1 } → val = val_1
theorem Finset.mk.injEq E0 #
∀ {α : Type u_3} (val : Multiset α) (nodup : val.Nodup) (val_1 : Multiset α) (nodup_1 : val_1.Nodup),
({ val := val, nodup := nodup } = { val := val_1, nodup := nodup_1 }) = (val = val_1)
def Finset.ctorIdx E1 #
{α : Type u_3} → Finset α → ℕ
theorem Finset.mk.congr_simp E1 #
∀ {α : Type u_3} (val val_1 : Multiset α) (e_val : val = val_1) (nodup : val.Nodup),
{ val := val, nodup := nodup } = { val := val_1, nodup := ⋯ }
instance Finset.instUsesSetNotationForOrder E0 #
(α : Type u_3) → UsesSetNotationForOrder (Finset α)
structure Finset E3 #
Type u_3 → Type u_3
Finset α is the type of finite sets of elements of α. It is implemented
as a multiset (a list up to permutation) which has no duplicate elements.
ctor Finset.mk E0 #
{α : Type u_3} → (val : Multiset α) → val.Nodup → Finset α
abbrev Finset.val E3 #
{α : Type u_3} → Finset α → Multiset α
The underlying multiset
theorem Finset.nodup E3 #
∀ {α : Type u_3} (self : Finset α), self.val.Nodup
val contains no duplicates
instance Multiset.canLiftFinset E0 #
∀ {α : Type u_3}, CanLift (Multiset α) (Finset α) Finset.val Multiset.Nodup
theorem Finset.val_injective E0 #
∀ {α : Type u_1}, Function.Injective Finset.val
theorem Finset.val_inj E0 #
∀ {α : Type u_1} {s t : Finset α}, s.val = t.val ↔ s = t
instance Finset.decidableEq E0 #
{α : Type u_1} → [DecidableEq α] → DecidableEq (Finset α)
instance Finset.instSetLike E0 #
{α : Type u_1} → SetLike (Finset α) α
Convert a finset to a set in the natural way.
theorem Finset.mem_def E0 #
∀ {α : Type u_1} {a : α} {s : Finset α}, a ∈ s ↔ a ∈ s.val
theorem Finset.mem_val E0 #
∀ {α : Type u_1} {a : α} {s : Finset α}, (a ∈ s.val) = (a ∈ s)
theorem Finset.mem_mk E0 #
∀ {α : Type u_1} {a : α} {s : Multiset α} {nd : s.Nodup}, a ∈ { val := s, nodup := nd } ↔ a ∈ s
instance Finset.decidableMem E0 #
{α : Type u_1} → [_h : DecidableEq α] → (a : α) → (s : Finset α) → Decidable (a ∈ s)
theorem Finset.forall_mem_not_eq E0 #
∀ {α : Type u_1} {s : Finset α} {a : α}, (∀ b ∈ s, ¬a = b) ↔ a ∉ s
theorem Finset.forall_mem_not_eq' E0 #
∀ {α : Type u_1} {s : Finset α} {a : α}, (∀ b ∈ s, ¬b = a) ↔ a ∉ s
instance Finset.instPartialOrder E0 #
{α : Type u_1} → PartialOrder (Finset α)
theorem Finset.mem_coe E0 #
∀ {α : Type u_1} {a : α} {s : Finset α}, a ∈ ↑s ↔ a ∈ s
theorem Finset.setOfPred_mem E0 #
∀ {α : Type u_3} {s : Finset α}, {a | a ∈ s} = ↑s
theorem Finset.coe_mem E0 #
∀ {α : Type u_1} {s : Finset α} (x : ↑↑s), ↑x ∈ s
theorem Finset.mk_coe E0 #
∀ {α : Type u_1} {s : Finset α} (x : ↑↑s) {h : ↑x ∈ ↑s}, ⟨↑x, h⟩ = x
instance Finset.decidableMem' E0 #
{α : Type u_1} → [DecidableEq α] → (a : α) → (s : Finset α) → Decidable (a ∈ ↑s)
theorem Finset.ext E1 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, (∀ (a : α), a ∈ s₁ ↔ a ∈ s₂) → s₁ = s₂
theorem Finset.ext_iff E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ = s₂ ↔ ∀ (a : α), a ∈ s₁ ↔ a ∈ s₂
theorem Finset.coe_inj E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, ↑s₁ = ↑s₂ ↔ s₁ = s₂
theorem Finset.coe_injective E0 #
∀ {α : Type u_3}, Function.Injective SetLike.coe
theorem Finset.forall_coe E0 #
∀ {α : Type u_3} (s : Finset α) (p : ↥s → Prop), (∀ (x : ↥s), p x) ↔ ∀ (x : α) (h : x ∈ s), p ⟨x, h⟩
theorem Finset.exists_coe E0 #
∀ {α : Type u_3} (s : Finset α) (p : ↥s → Prop), (∃ x, p x) ↔ ∃ x, ∃ (h : x ∈ s), p ⟨x, h⟩
instance Finset.PiFinsetCoe.canLift E0 #
∀ (ι : Type u_3) (α : ι → Type u_4) [_ne : ∀ (i : ι), Nonempty (α i)] (s : Finset ι),
CanLift ((i : ↥s) → α ↑i) ((i : ι) → α i) (fun f i ↦ f ↑i) fun x ↦ True
instance Finset.PiFinsetCoe.canLift' E0 #
∀ (ι : Type u_3) (α : Type u_4) [_ne : Nonempty α] (s : Finset ι),
CanLift (↥s → α) (ι → α) (fun f i ↦ f ↑i) fun x ↦ True
instance Finset.FinsetCoe.canLift E0 #
∀ {α : Type u_1} (s : Finset α), CanLift α (↥s) Subtype.val fun a ↦ a ∈ s
theorem Finset.coe_sort_coe E0 #
∀ {α : Type u_1} (s : Finset α), ↑↑s = ↥s
theorem Finset.subset_def E0 #
∀ {α : Type u_1} {s t : Finset α}, s ⊆ t ↔ s.val ⊆ t.val
theorem Finset.ssubset_def E0 #
∀ {α : Type u_1} {s t : Finset α}, s ⊂ t ↔ s ⊆ t ∧ ¬t ⊆ s
theorem Finset.Subset.refl E1 #
∀ {α : Type u_1} (s : Finset α), s ⊆ s
theorem Finset.Subset.rfl E1 #
∀ {α : Type u_1} {s : Finset α}, s ⊆ s
theorem Finset.subset_of_eq E0 #
∀ {α : Type u_1} {s t : Finset α}, s = t → s ⊆ t
theorem Finset.Subset.trans E1 #
∀ {α : Type u_1} {s₁ s₂ s₃ : Finset α}, s₁ ⊆ s₂ → s₂ ⊆ s₃ → s₁ ⊆ s₃
theorem Finset.Superset.trans E1 #
∀ {α : Type u_1} {s₁ s₂ s₃ : Finset α}, s₁ ⊇ s₂ → s₂ ⊇ s₃ → s₁ ⊇ s₃
theorem Finset.mem_of_subset E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α} {a : α}, s₁ ⊆ s₂ → a ∈ s₁ → a ∈ s₂
theorem Finset.notMem_mono E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊆ t → ∀ {a : α}, a ∉ t → a ∉ s
theorem Finset.notMem_subset E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊆ t → ∀ {a : α}, a ∉ t → a ∉ s
Alias of Finset.notMem_mono.
theorem Finset.Subset.antisymm E1 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ ⊆ s₂ → s₂ ⊆ s₁ → s₁ = s₂
theorem Finset.subset_iff E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ ⊆ s₂ ↔ ∀ ⦃x : α⦄, x ∈ s₁ → x ∈ s₂
theorem Finset.subset_iff_notMem E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊆ t ↔ ∀ ⦃a : α⦄, a ∉ t → a ∉ s
theorem Finset.coe_subset E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, ↑s₁ ⊆ ↑s₂ ↔ s₁ ⊆ s₂
theorem Finset.val_le_iff E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁.val ≤ s₂.val ↔ s₁ ⊆ s₂
theorem Finset.Subset.antisymm_iff E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ = s₂ ↔ s₁ ⊆ s₂ ∧ s₂ ⊆ s₁
theorem Finset.not_subset E1 #
∀ {α : Type u_1} {s t : Finset α}, ¬s ⊆ t ↔ ∃ x ∈ s, x ∉ t
theorem Finset.coe_ssubset E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, ↑s₁ ⊂ ↑s₂ ↔ s₁ ⊂ s₂
theorem Finset.val_lt_iff E0 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁.val < s₂.val ↔ s₁ ⊂ s₂
theorem Finset.val_strictMono E0 #
∀ {α : Type u_1}, StrictMono Finset.val
theorem Finset.ssubset_iff_subset_ne E1 #
∀ {α : Type u_1} {s t : Finset α}, s ⊂ t ↔ s ⊆ t ∧ s ≠ t
theorem Finset.ssubset_iff_of_subset E1 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ ⊆ s₂ → (s₁ ⊂ s₂ ↔ ∃ x ∈ s₂, x ∉ s₁)
theorem Finset.ssubset_of_ssubset_of_subset E1 #
∀ {α : Type u_1} {s₁ s₂ s₃ : Finset α}, s₁ ⊂ s₂ → s₂ ⊆ s₃ → s₁ ⊂ s₃
theorem Finset.ssubset_of_subset_of_ssubset E1 #
∀ {α : Type u_1} {s₁ s₂ s₃ : Finset α}, s₁ ⊆ s₂ → s₂ ⊂ s₃ → s₁ ⊂ s₃
theorem Finset.exists_of_ssubset E1 #
∀ {α : Type u_1} {s₁ s₂ : Finset α}, s₁ ⊂ s₂ → ∃ x ∈ s₂, x ∉ s₁
instance Finset.isWellFounded_ssubset E0 #
∀ {α : Type u_1}, WellFounded fun x1 x2 ↦ x1 ⊂ x2
instance Finset.wellFoundedLT E0 #
∀ {α : Type u_1}, WellFoundedLT (Finset α)
def Finset.coeEmb E1 #
{α : Type u_1} → Finset α ↪o Set α
Coercion to Set α as an OrderEmbedding.
theorem Finset.coe_coeEmb E0 #
∀ {α : Type u_1}, ⇑Finset.coeEmb = SetLike.coe
instance Finset.decidableDforallFinset E0 #
{α : Type u_1} →
{s : Finset α} →
{p : (a : α) → a ∈ s → Prop} →
[_hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] → Decidable (∀ (a : α) (h : a ∈ s), p a h)
instance Finset.instDecidableRelSubset E0 #
{α : Type u_1} → [DecidableEq α] → DecidableRel fun x1 x2 ↦ x1 ⊆ x2
instance Finset.instDecidableRelSSubset E0 #
{α : Type u_1} → [DecidableEq α] → DecidableRel fun x1 x2 ↦ x1 ⊂ x2
instance Finset.instDecidableLE E0 #
{α : Type u_1} → [DecidableEq α] → DecidableLE (Finset α)
instance Finset.instDecidableLT E0 #
{α : Type u_1} → [DecidableEq α] → DecidableLT (Finset α)
instance Finset.decidableDExistsFinset E0 #
{α : Type u_1} →
{s : Finset α} →
{p : (a : α) → a ∈ s → Prop} →
[_hp : (a : α) → (h : a ∈ s) → Decidable (p a h)] → Decidable (∃ a, ∃ (h : a ∈ s), p a h)
instance Finset.decidableExistsAndFinset E0 #
{α : Type u_1} → {s : Finset α} → {p : α → Prop} → [_hp : (a : α) → Decidable (p a)] → Decidable (∃ a ∈ s, p a)
instance Finset.decidableExistsAndFinsetCoe E0 #
{α : Type u_1} → {s : Finset α} → {p : α → Prop} → [DecidablePred p] → Decidable (∃ a ∈ ↑s, p a)
instance Finset.decidableEqPiFinset E0 #
{α : Type u_1} →
{s : Finset α} → {β : α → Type u_3} → [_h : (a : α) → DecidableEq (β a)] → DecidableEq ((a : α) → a ∈ s → β a)
decidable equality for functions whose domain is bounded by finsets
instance List.instDecidableMapsToCoeFinsetOfDecidablePredMemSet E0 #
{α : Type u_1} →
{β : Type u_2} →
{f : α → β} → {s : Finset α} → {t : Set β} → [DecidablePred fun x ↦ x ∈ t] → Decidable (Set.MapsTo f (↑s) t)
instance List.instDecidableSurjOnCoeFinsetOfDecidableEq E0 #
{α : Type u_1} →
{β : Type u_2} → {f : α → β} → {s : Finset α} → {t' : Finset β} → [DecidableEq β] → Decidable (Set.SurjOn f ↑s ↑t')
theorem Finset.pairwise_subtype_iff_pairwise_finset' E1 #
∀ {α : Type u_1} {β : Type u_2} {s : Finset α} (r : β → β → Prop) (f : α → β),
Pairwise (Function.onFun r fun x ↦ f ↑x) ↔ (↑s).Pairwise (Function.onFun r f)
theorem Finset.pairwise_subtype_iff_pairwise_finset E1 #
∀ {α : Type u_1} {s : Finset α} (r : α → α → Prop), Pairwise (Function.onFun r fun x ↦ ↑x) ↔ (↑s).Pairwise r
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Finset.le_eq_subset | 2026-05-24 | |
Finset.le_iff_subset | 2026-05-24 | |
Finset.lt_eq_subset | 2026-05-24 | |
Finset.lt_iff_ssubset | 2026-05-24 | |
Finset.not_mem_subset | Finset.notMem_subset | 2026-09-28 |
Finset.setOf_mem | Finset.setOfPred_mem | 2026-07-09 |
Finset.subset_of_le | 2026-05-24 |