The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Fintype.Card
99 declarations and 1 deprecated aliases. Mathlib docs · Source
Cardinalities of finite types
This file defines the cardinality Fintype.card α as the number of elements in (univ : Finset α).
We also include some elementary results on the values of Fintype.card on specific types.
Main declarations
Fintype.card α: Cardinality of a fintype. Equal toFinset.univ.card.Finite.surjective_of_injective: an injective function from a finite type to itself is also surjective.
def Fintype.card E1 #
(α : Type u_3) → [Fintype α] → ℕ
card α is the number of elements in α, defined when α is a fintype.
theorem Fintype.subtype_card E1 #
∀ {α : Type u_1} {p : α → Prop} (s : Finset α) (H : ∀ (x : α), x ∈ s ↔ p x), Fintype.card { x // p x } = s.card
theorem Fintype.card_of_subtype E1 #
∀ {α : Type u_1} {p : α → Prop} (s : Finset α),
(∀ (x : α), x ∈ s ↔ p x) → ∀ [inst : Fintype { x // p x }], Fintype.card { x // p x } = s.card
theorem Fintype.card_ofFinset E0 #
∀ {α : Type u_1} {p : Set α} (s : Finset α) (H : ∀ (x : α), x ∈ s ↔ x ∈ p), Fintype.card ↑p = s.card
theorem Fintype.card_of_finset' E1 #
∀ {α : Type u_1} {p : Set α} (s : Finset α),
(∀ (x : α), x ∈ s ↔ x ∈ p) → ∀ [inst : Fintype ↑p], Fintype.card ↑p = s.card
theorem Fintype.ofEquiv_card E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] (f : α ≃ β), Fintype.card β = Fintype.card α
theorem Fintype.card_congr E1 #
∀ {α : Type u_3} {β : Type u_4} [inst : Fintype α] [inst_1 : Fintype β] (f : α ≃ β), Fintype.card α = Fintype.card β
theorem Fintype.card_congr' E1 #
∀ {α β : Type u_3} [inst : Fintype α] [inst_1 : Fintype β], α = β → Fintype.card α = Fintype.card β
theorem Fintype.card_ofSubsingleton E1 #
∀ {α : Type u_1} (a : α) [inst : Subsingleton α], Fintype.card α = 1
Note: this lemma is specifically about Fintype.ofSubsingleton. For a statement about
arbitrary Fintype instances, use either Fintype.card_le_one_iff_subsingleton or
Fintype.card_unique.
theorem Fintype.card_unique E0 #
∀ {α : Type u_1} [Unique α] [h : Fintype α], Fintype.card α = 1
theorem Fintype.card_ofIsEmpty E1 #
∀ {α : Type u_1} [inst : IsEmpty α], Fintype.card α = 0
Note: this lemma is specifically about Fintype.ofIsEmpty. For a statement about
arbitrary Fintype instances, use Fintype.card_eq_zero.
theorem Set.toFinset_card E0 #
∀ {α : Type u_3} (s : Set α) [inst : Fintype ↑s], s.toFinset.card = Fintype.card ↑s
theorem Finset.card_univ E0 #
∀ {α : Type u_1} [inst : Fintype α], Finset.univ.card = Fintype.card α
theorem Finset.card_eq_iff_eq_univ E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Finset α), s.card = Fintype.card α ↔ s = Finset.univ
theorem Finset.card_le_univ E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Finset α), s.card ≤ Fintype.card α
theorem Finset.card_lt_univ_of_notMem E1 #
∀ {α : Type u_1} [inst : Fintype α] {s : Finset α} {x : α}, x ∉ s → s.card < Fintype.card α
theorem Finset.card_lt_iff_ne_univ E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Finset α), s.card < Fintype.card α ↔ s ≠ Finset.univ
theorem Finset.card_compl_lt_iff_nonempty E1 #
∀ {α : Type u_1} [inst : Fintype α] [inst_1 : DecidableEq α] (s : Finset α), sᶜ.card < Fintype.card α ↔ s.Nonempty
theorem Finset.card_univ_sdiff E1 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : Fintype α] (s : Finset α),
(Finset.univ \ s).card = Fintype.card α - s.card
theorem Finset.card_compl E1 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : Fintype α] (s : Finset α), sᶜ.card = Fintype.card α - s.card
theorem Finset.card_add_card_compl E0 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : Fintype α] (s : Finset α), s.card + sᶜ.card = Fintype.card α
theorem Finset.card_compl_add_card E0 #
∀ {α : Type u_1} [inst : DecidableEq α] [inst_1 : Fintype α] (s : Finset α), sᶜ.card + s.card = Fintype.card α
theorem Finset.compl_eq_of_disjoint_of_card_add_eq E0 #
∀ {ι : Type u_3} [inst : DecidableEq ι] [inst_1 : Fintype ι] {S₁ S₂ : Finset ι},
Disjoint S₁ S₂ → S₁.card + S₂.card = Finset.univ.card → S₁ᶜ = S₂
theorem Fintype.card_compl_set E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Set α) [inst_1 : Fintype ↑s] [inst_2 : Fintype ↑sᶜ],
Fintype.card ↑sᶜ = Fintype.card α - Fintype.card ↑s
theorem Fintype.card_subtype_eq E0 #
∀ {α : Type u_1} (y : α) [inst : Fintype { x // x = y }], Fintype.card { x // x = y } = 1
theorem Fintype.card_subtype_eq' E1 #
∀ {α : Type u_1} (y : α) [inst : Fintype { x // y = x }], Fintype.card { x // y = x } = 1
theorem Fintype.card_empty E1 #
Fintype.card Empty = 0
theorem Fintype.card_pempty E1 #
Fintype.card PEmpty.{u_3 + 1} = 0
theorem Fintype.card_unit E1 #
Fintype.card Unit = 1
theorem Fintype.card_punit E0 #
Fintype.card PUnit.{u_3 + 1} = 1
theorem Fintype.card_bool E0 #
Fintype.card Bool = 2
theorem Fintype.card_ulift E0 #
∀ (α : Type u_3) [inst : Fintype α], Fintype.card (ULift.{u_4, u_3} α) = Fintype.card α
theorem Fintype.card_plift E0 #
∀ (α : Type u_3) [inst : Fintype α], Fintype.card (PLift α) = Fintype.card α
theorem Fintype.card_orderDual E0 #
∀ (α : Type u_3) [inst : Fintype α], Fintype.card αᵒᵈ = Fintype.card α
theorem Fintype.card_lex E0 #
∀ (α : Type u_3) [inst : Fintype α], Fintype.card (Lex α) = Fintype.card α
theorem Fintype.card_setUniv E1 #
∀ {α : Type u_1} [inst : Fintype α] {h : Fintype ↑Set.univ}, Fintype.card ↑Set.univ = Fintype.card α
theorem Fintype.card_subtype_true E0 #
∀ {α : Type u_1} [inst : Fintype α] {h : Fintype { _a // True }}, Fintype.card { _a // True } = Fintype.card α
def Fintype.sumLeft E1 #
{α : Type u_3} → {β : Type u_4} → [Fintype (α ⊕ β)] → Fintype α
Given that α ⊕ β is a fintype, α is also a fintype. This is non-computable as it uses
that Sum.inl is an injection, but there's no clear inverse if α is empty.
def Fintype.sumRight E1 #
{α : Type u_3} → {β : Type u_4} → [Fintype (α ⊕ β)] → Fintype β
Given that α ⊕ β is a fintype, β is also a fintype. This is non-computable as it uses
that Sum.inr is an injection, but there's no clear inverse if β is empty.
theorem Finite.exists_univ_list E1 #
∀ (α : Type u_3) [Finite α], ∃ l, l.Nodup ∧ ∀ (x : α), x ∈ l
theorem List.Nodup.length_le_card E1 #
∀ {α : Type u_3} [inst : Fintype α] {l : List α}, l.Nodup → l.length ≤ Fintype.card α
theorem Fintype.card_le_of_injective E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α → β),
Function.Injective f → Fintype.card α ≤ Fintype.card β
theorem Fintype.not_injective_of_card_lt E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α → β),
Fintype.card β < Fintype.card α → ¬Function.Injective f
theorem Fintype.card_le_of_embedding E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α ↪ β), Fintype.card α ≤ Fintype.card β
theorem Fintype.card_lt_of_injective_of_notMem E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α → β),
Function.Injective f → ∀ {b : β}, b ∉ Set.range f → Fintype.card α < Fintype.card β
theorem Fintype.existsUnique_notMem_image_of_injective_of_card_eq_add_one E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] [inst_2 : DecidableEq β] (f : α → β),
Function.Injective f → Fintype.card β = Fintype.card α + 1 → ∃! x, x ∉ Finset.image f Finset.univ
Given an injective map f : α → β such that β has cardinality one more
than α, there exists a unique element of β not in the image of f.
theorem Fintype.card_lt_of_injective_not_surjective E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α → β),
Function.Injective f → ¬Function.Surjective f → Fintype.card α < Fintype.card β
theorem Fintype.card_le_of_surjective E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] (f : α → β),
Function.Surjective f → Fintype.card β ≤ Fintype.card α
theorem Fintype.card_range_le E1 #
∀ {α : Type u_3} {β : Type u_4} (f : α → β) [inst : Fintype α] [inst_1 : Fintype ↑(Set.range f)],
Fintype.card ↑(Set.range f) ≤ Fintype.card α
theorem Fintype.card_range E1 #
∀ {α : Type u_3} {β : Type u_4} {F : Type u_5} [inst : FunLike F α β] [EmbeddingLike F α β] (f : F) [inst_2 : Fintype α]
[inst_3 : Fintype ↑(Set.range ⇑f)], Fintype.card ↑(Set.range ⇑f) = Fintype.card α
theorem Fintype.card_eq_zero_iff E0 #
∀ {α : Type u_1} [inst : Fintype α], Fintype.card α = 0 ↔ IsEmpty α
theorem Fintype.card_eq_zero E0 #
∀ {α : Type u_1} [inst : Fintype α] [IsEmpty α], Fintype.card α = 0
theorem Fintype.card_of_isEmpty E1 #
∀ {α : Type u_1} [inst : Fintype α] [IsEmpty α], Fintype.card α = 0
Alias of Fintype.card_eq_zero.
def Fintype.cardEqZeroEquivEquivEmpty E1 #
{α : Type u_1} → [inst : Fintype α] → Fintype.card α = 0 ≃ (α ≃ Empty)
A Fintype with cardinality zero is equivalent to Empty.
theorem Fintype.card_pos_iff E0 #
∀ {α : Type u_1} [inst : Fintype α], 0 < Fintype.card α ↔ Nonempty α
theorem Fintype.card_pos E1 #
∀ {α : Type u_1} [inst : Fintype α] [h : Nonempty α], 0 < Fintype.card α
theorem Fintype.card_ne_zero E0 #
∀ {α : Type u_1} [inst : Fintype α] [Nonempty α], Fintype.card α ≠ 0
instance Fintype.instNeZeroNatCardOfNonempty E0 #
∀ {α : Type u_1} [inst : Fintype α] [Nonempty α], NeZero (Fintype.card α)
theorem Fintype.existsUnique_iff_card_one E1 #
∀ {α : Type u_3} [inst : Fintype α] (p : α → Prop) [inst_1 : DecidablePred p], (∃! a, p a) ↔ {x | p x}.card = 1
theorem Fintype.two_lt_card_iff E0 #
∀ {α : Type u_1} [inst : Fintype α], 2 < Fintype.card α ↔ ∃ a b c, a ≠ b ∧ a ≠ c ∧ b ≠ c
theorem Fintype.card_of_bijective E1 #
∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] [inst_1 : Fintype β] {f : α → β},
Function.Bijective f → Fintype.card α = Fintype.card β
theorem Finite.surjective_of_injective E3 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Injective f → Function.Surjective f
theorem Finite.injective_iff_surjective E1 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Injective f ↔ Function.Surjective f
theorem Finite.injective_iff_bijective E1 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Injective f ↔ Function.Bijective f
theorem Finite.surjective_iff_bijective E1 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Surjective f ↔ Function.Bijective f
theorem Finite.injective_iff_surjective_of_equiv E1 #
∀ {α : Type u_1} {β : Type u_2} [Finite α] {f : α → β} (e : α ≃ β), Function.Injective f ↔ Function.Surjective f
theorem Function.Injective.bijective_of_finite E1 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Injective f → Function.Bijective f
Alias of the forward direction of Finite.injective_iff_bijective.
theorem Function.Surjective.bijective_of_finite E1 #
∀ {α : Type u_1} [Finite α] {f : α → α}, Function.Surjective f → Function.Bijective f
Alias of the forward direction of Finite.surjective_iff_bijective.
theorem Function.Injective.surjective_of_finite E1 #
∀ {α : Type u_1} {β : Type u_2} [Finite α] {f : α → β} (e : α ≃ β), Function.Injective f → Function.Surjective f
Alias of the forward direction of Finite.injective_iff_surjective_of_equiv.
theorem Function.Surjective.injective_of_finite E1 #
∀ {α : Type u_1} {β : Type u_2} [Finite α] {f : α → β} (e : α ≃ β), Function.Surjective f → Function.Injective f
Alias of the reverse direction of Finite.injective_iff_surjective_of_equiv.
theorem Fintype.card_coe E0 #
∀ {α : Type u_1} (s : Finset α) [inst : Fintype ↥s], Fintype.card ↥s = s.card
theorem Finset.exists_superset_card_eq E0 #
∀ {α : Type u_1} [inst : Fintype α] {n : ℕ} {s : Finset α}, s.card ≤ n → n ≤ Fintype.card α → ∃ t, s ⊆ t ∧ t.card = n
We can inflate a set s to any bigger size.
theorem Fintype.card_prop E0 #
Fintype.card Prop = 2
theorem set_fintype_card_le_univ E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Set α) [inst_1 : Fintype ↑s], Fintype.card ↑s ≤ Fintype.card α
theorem set_fintype_card_eq_univ_iff E0 #
∀ {α : Type u_1} [inst : Fintype α] (s : Set α) [inst_1 : Fintype ↑s], Fintype.card ↑s = Fintype.card α ↔ s = Set.univ
theorem Fintype.card_subtype_le E1 #
∀ {α : Type u_1} [inst : Fintype α] (p : α → Prop) [inst_1 : Fintype { a // p a }],
Fintype.card { x // p x } ≤ Fintype.card α
theorem Fintype.card_subtype_lt E1 #
∀ {α : Type u_1} [inst : Fintype α] {p : α → Prop} [inst_1 : Fintype { a // p a }] {x : α},
¬p x → Fintype.card { x // p x } < Fintype.card α
theorem Fintype.card_subtype E1 #
∀ {α : Type u_1} [inst : Fintype α] (p : α → Prop) [inst_1 : Fintype { a // p a }] [inst_2 : DecidablePred p],
Fintype.card { x // p x } = {x | p x}.card
theorem Fintype.card_subtype_compl E0 #
∀ {α : Type u_1} [inst : Fintype α] (p : α → Prop) [inst_1 : Fintype { x // p x }] [inst_2 : Fintype { x // ¬p x }],
Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x }
theorem Fintype.card_subtype_mono E1 #
∀ {α : Type u_1} (p q : α → Prop),
p ≤ q →
∀ [inst : Fintype { x // p x }] [inst_1 : Fintype { x // q x }],
Fintype.card { x // p x } ≤ Fintype.card { x // q x }
theorem Fintype.card_compl_eq_card_compl E1 #
∀ {α : Type u_1} [Finite α] (p q : α → Prop) [inst : Fintype { x // p x }] [inst_1 : Fintype { x // ¬p x }]
[inst_2 : Fintype { x // q x }] [inst_3 : Fintype { x // ¬q x }],
Fintype.card { x // p x } = Fintype.card { x // q x } → Fintype.card { x // ¬p x } = Fintype.card { x // ¬q x }
If two subtypes of a fintype have equal cardinality, so do their complements.
theorem Fintype.card_quotient_le E1 #
∀ {α : Type u_1} [inst : Fintype α] (s : Setoid α) [inst_1 : DecidableRel fun x1 x2 ↦ x1 ≈ x2],
Fintype.card (Quotient s) ≤ Fintype.card α
theorem univ_eq_singleton_of_card_one E1 #
∀ {α : Type u_3} [inst : Fintype α] (x : α), Fintype.card α = 1 → Finset.univ = {x}
theorem Finite.wellFounded_of_trans_of_irrefl E1 #
∀ {α : Type u_1} [Finite α] (r : α → α → Prop) [IsTrans α r] [Std.Irrefl r], WellFounded r
instance Finite.to_wellFoundedLT E0 #
∀ {α : Type u_1} [Finite α] [inst : Preorder α], WellFoundedLT α
instance Finite.to_wellFoundedGT E0 #
∀ {α : Type u_1} [Finite α] [inst : Preorder α], WellFoundedGT α
instance Bool.instWellFoundedLT E0 #
WellFoundedLT Bool
instance Bool.instWellFoundedGT E0 #
WellFoundedGT Bool
instance Prop.instWellFoundedLT E0 #
WellFoundedLT Prop
instance Prop.instWellFoundedGT E0 #
WellFoundedGT Prop
def truncOfCardPos E1 #
{α : Type u_3} → [inst : Fintype α] → 0 < Fintype.card α → Trunc α
A Fintype with positive cardinality constructively contains an element.
theorem Fintype.induction_subsingleton_or_nontrivial E1 #
∀ {P : (α : Type u_3) → [Fintype α] → Prop} (α : Type u_3) [inst : Fintype α],
(∀ (α : Type u_3) [inst : Fintype α] [Subsingleton α], P α) →
(∀ (α : Type u_3) [inst : Fintype α] [Nontrivial α],
(∀ (β : Type u_3) [inst_2 : Fintype β], Fintype.card β < Fintype.card α → P β) → P α) →
P α
A custom induction principle for fintypes. The base case is a subsingleton type,
and the induction step is for non-trivial types, and one can assume the hypothesis for
smaller types (via Fintype.card).
The major premise is Fintype α, so to use this with the induction tactic you have to give a name
to that instance and use that name.
theorem Fintype.card_fin E0 #
∀ (n : ℕ), Fintype.card (Fin n) = n
theorem Fintype.card_fin_lt_of_le E1 #
∀ {m n : ℕ}, m ≤ n → Fintype.card { i // ↑i < m } = m
theorem Finset.card_fin E1 #
∀ (n : ℕ), Finset.univ.card = n
theorem fin_injective E1 #
Function.Injective Fin
Fin as a map from ℕ to Type is injective. Note that since this is a statement about
equality of types, using it should be avoided if possible.
theorem Fin.val_eq_val_of_heq E0 #
∀ {k l : ℕ} {i : Fin k} {j : Fin l}, i ≍ j → ↑i = ↑j
theorem Fin.cast_eq_cast' E1 #
∀ {n m : ℕ} (h : Fin n = Fin m), cast h = Fin.cast ⋯
A reversed version of Fin.cast_eq_cast that is easier to rewrite with.
theorem card_finset_fin_le E1 #
∀ {n : ℕ} (s : Finset (Fin n)), s.card ≤ n
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Finset.card_univ_diff | Finset.card_univ_sdiff | 2026-06-03 |