# Finite types #

This file defines a typeclass to state that a type is finite.

## Main declarations #

• Fintype α: Typeclass saying that a type is finite. It takes as fields a Finset and a proof that all terms of type α are in it.
• Finset.univ: The finset of all elements of a fintype.

See Data.Fintype.Card for the cardinality of a fintype, the equivalence with Fin (Fintype.card α), and pigeonhole principles.

## Instances #

Instances for Fintype for

• {x // p x} are in this file as Fintype.subtype
• Option α are in Data.Fintype.Option
• α × β are in Data.Fintype.Prod
• α ⊕ β are in Data.Fintype.Sum
• Σ (a : α), β a are in Data.Fintype.Sigma

These files also contain appropriate Infinite instances for these types.

Infinite instances for ℕ, ℤ, Multiset α, and List α are in Data.Fintype.Lattice.

Types which have a surjection from/an injection to a Fintype are themselves fintypes. See Fintype.ofInjective and Fintype.ofSurjective.

class Fintype (α : Type u_4) :
Type u_4

Fintype α means that α is finite, i.e. there are only finitely many distinct elements of type α. The evidence of this is a finset elems (a list up to permutation without duplicates), together with a proof that everything of type α is in the list.

• elems :

The Finset containing all elements of a Fintype

• complete : ∀ (x : α), x Fintype.elems

A proof that elems contains every element of the type

Instances
def Finset.univ {α : Type u_1} [] :

univ is the universal finite set of type Finset α implied from the assumption Fintype α.

Equations
• Finset.univ = Fintype.elems
Instances For
@[simp]
theorem Finset.mem_univ {α : Type u_1} [] (x : α) :
x Finset.univ
theorem Finset.mem_univ_val {α : Type u_1} [] (x : α) :
x Finset.univ.val
theorem Finset.eq_univ_iff_forall {α : Type u_1} [] {s : } :
s = Finset.univ ∀ (x : α), x s
theorem Finset.eq_univ_of_forall {α : Type u_1} [] {s : } :
(∀ (x : α), x s)s = Finset.univ
@[simp]
theorem Finset.coe_univ {α : Type u_1} [] :
Finset.univ = Set.univ
@[simp]
theorem Finset.coe_eq_univ {α : Type u_1} [] {s : } :
s = Set.univ s = Finset.univ
theorem Finset.Nonempty.eq_univ {α : Type u_1} [] {s : } [] :
s.Nonemptys = Finset.univ
theorem Finset.univ_nonempty_iff {α : Type u_1} [] :
Finset.univ.Nonempty
theorem Finset.univ_nonempty {α : Type u_1} [] [] :
Finset.univ.Nonempty
theorem Finset.univ_eq_empty_iff {α : Type u_1} [] :
Finset.univ =
@[simp]
theorem Finset.univ_eq_empty {α : Type u_1} [] [] :
Finset.univ =
@[simp]
theorem Finset.univ_unique {α : Type u_1} [] [] :
Finset.univ = {default}
@[simp]
theorem Finset.subset_univ {α : Type u_1} [] (s : ) :
s Finset.univ
instance Finset.boundedOrder {α : Type u_1} [] :
Equations
• Finset.boundedOrder = let src := ; BoundedOrder.mk
@[simp]
theorem Finset.top_eq_univ {α : Type u_1} [] :
= Finset.univ
theorem Finset.ssubset_univ_iff {α : Type u_1} [] {s : } :
s Finset.univ s Finset.univ
@[simp]
theorem Finset.univ_subset_iff {α : Type u_1} [] {s : } :
Finset.univ s s = Finset.univ
theorem Finset.codisjoint_left {α : Type u_1} [] {s : } {t : } :
∀ ⦃a : α⦄, asa t
theorem Finset.codisjoint_right {α : Type u_1} [] {s : } {t : } :
∀ ⦃a : α⦄, ata s
instance Finset.booleanAlgebra {α : Type u_1} [] [] :
Equations
• Finset.booleanAlgebra = GeneralizedBooleanAlgebra.toBooleanAlgebra
theorem Finset.sdiff_eq_inter_compl {α : Type u_1} [] [] (s : ) (t : ) :
s \ t = s t
theorem Finset.compl_eq_univ_sdiff {α : Type u_1} [] [] (s : ) :
s = Finset.univ \ s
@[simp]
theorem Finset.mem_compl {α : Type u_1} [] {s : } [] {a : α} :
a s as
theorem Finset.not_mem_compl {α : Type u_1} [] {s : } [] {a : α} :
as a s
@[simp]
theorem Finset.coe_compl {α : Type u_1} [] [] (s : ) :
s = (s)
@[simp]
theorem Finset.compl_subset_compl {α : Type u_1} [] {s : } {t : } [] :
s t t s
@[simp]
theorem Finset.compl_ssubset_compl {α : Type u_1} [] {s : } {t : } [] :
s t t s
theorem Finset.subset_compl_comm {α : Type u_1} [] {s : } {t : } [] :
s t t s
@[simp]
theorem Finset.subset_compl_singleton {α : Type u_1} [] {s : } [] {a : α} :
s {a} as
@[simp]
theorem Finset.compl_empty {α : Type u_1} [] [] :
= Finset.univ
@[simp]
theorem Finset.compl_univ {α : Type u_1} [] [] :
Finset.univ =
@[simp]
theorem Finset.compl_eq_empty_iff {α : Type u_1} [] [] (s : ) :
s = s = Finset.univ
@[simp]
theorem Finset.compl_eq_univ_iff {α : Type u_1} [] [] (s : ) :
s = Finset.univ s =
@[simp]
theorem Finset.union_compl {α : Type u_1} [] [] (s : ) :
s s = Finset.univ
@[simp]
theorem Finset.inter_compl {α : Type u_1} [] [] (s : ) :
@[simp]
theorem Finset.compl_union {α : Type u_1} [] [] (s : ) (t : ) :
(s t) = s t
@[simp]
theorem Finset.compl_inter {α : Type u_1} [] [] (s : ) (t : ) :
(s t) = s t
@[simp]
theorem Finset.compl_erase {α : Type u_1} [] {s : } [] {a : α} :
@[simp]
theorem Finset.compl_insert {α : Type u_1} [] {s : } [] {a : α} :
(insert a s) =
theorem Finset.insert_compl_insert {α : Type u_1} [] {s : } [] {a : α} (ha : as) :
@[simp]
theorem Finset.insert_compl_self {α : Type u_1} [] [] (x : α) :
insert x {x} = Finset.univ
@[simp]
theorem Finset.compl_filter {α : Type u_1} [] [] (p : αProp) [] [(x : α) → Decidable ¬p x] :
(Finset.filter p Finset.univ) = Finset.filter (fun (x : α) => ¬p x) Finset.univ
theorem Finset.compl_ne_univ_iff_nonempty {α : Type u_1} [] [] (s : ) :
s Finset.univ s.Nonempty
theorem Finset.compl_singleton {α : Type u_1} [] [] (a : α) :
{a} = Finset.erase Finset.univ a
theorem Finset.insert_inj_on' {α : Type u_1} [] [] (s : ) :
Set.InjOn (fun (a : α) => insert a s) s
theorem Finset.image_univ_of_surjective {α : Type u_1} {β : Type u_2} [] [] [] {f : βα} (hf : ) :
Finset.image f Finset.univ = Finset.univ
@[simp]
theorem Finset.image_univ_equiv {α : Type u_1} {β : Type u_2} [] [] [] (f : β α) :
Finset.image (f) Finset.univ = Finset.univ
@[simp]
theorem Finset.univ_inter {α : Type u_1} [] [] (s : ) :
Finset.univ s = s
@[simp]
theorem Finset.inter_univ {α : Type u_1} [] [] (s : ) :
s Finset.univ = s
@[simp]
theorem Finset.inter_eq_univ {α : Type u_1} [] {s : } {t : } [] :
s t = Finset.univ s = Finset.univ t = Finset.univ
theorem Finset.singleton_eq_univ {α : Type u_1} [] [] (a : α) :
{a} = Finset.univ
theorem Finset.map_univ_of_surjective {α : Type u_1} {β : Type u_2} [] [] {f : β α} (hf : ) :
Finset.map f Finset.univ = Finset.univ
@[simp]
theorem Finset.map_univ_equiv {α : Type u_1} {β : Type u_2} [] [] (f : β α) :
Finset.map Finset.univ = Finset.univ
@[simp]
theorem Finset.piecewise_univ {α : Type u_1} [] [(i : α) → Decidable (i Finset.univ)] {δ : αSort u_4} (f : (i : α) → δ i) (g : (i : α) → δ i) :
Finset.piecewise Finset.univ f g = f
theorem Finset.piecewise_compl {α : Type u_1} [] [] (s : ) [(i : α) → Decidable (i s)] [(i : α) → Decidable (i s)] {δ : αSort u_4} (f : (i : α) → δ i) (g : (i : α) → δ i) :
=
@[simp]
theorem Finset.piecewise_erase_univ {α : Type u_1} [] {δ : αSort u_4} [] (a : α) (f : (a : α) → δ a) (g : (a : α) → δ a) :
Finset.piecewise (Finset.erase Finset.univ a) f g = Function.update f a (g a)
theorem Finset.univ_map_equiv_to_embedding {α : Type u_4} {β : Type u_5} [] [] (e : α β) :
Finset.map Finset.univ = Finset.univ
@[simp]
theorem Finset.univ_filter_exists {α : Type u_1} {β : Type u_2} [] (f : αβ) [] [DecidablePred fun (y : β) => ∃ (x : α), f x = y] [] :
Finset.filter (fun (y : β) => ∃ (x : α), f x = y) Finset.univ = Finset.image f Finset.univ
theorem Finset.univ_filter_mem_range {α : Type u_1} {β : Type u_2} [] (f : αβ) [] [DecidablePred fun (y : β) => y ] [] :
Finset.filter (fun (y : β) => y ) Finset.univ = Finset.image f Finset.univ

Note this is a special case of (Finset.image_preimage f univ _).symm.

theorem Finset.coe_filter_univ {α : Type u_1} [] (p : αProp) [] :
(Finset.filter p Finset.univ) = {x : α | p x}
@[simp]
theorem Finset.subtype_eq_univ {α : Type u_1} {s : } {p : αProp} [] [Fintype { a : α // p a }] :
= Finset.univ ∀ ⦃a : α⦄, p aa s
@[simp]
theorem Finset.subtype_univ {α : Type u_1} [] (p : αProp) [] [Fintype { a : α // p a }] :
Finset.subtype p Finset.univ = Finset.univ
instance Fintype.decidablePiFintype {α : Type u_5} {β : αType u_4} [(a : α) → DecidableEq (β a)] [] :
DecidableEq ((a : α) → β a)
Equations
instance Fintype.decidableForallFintype {α : Type u_1} {p : αProp} [] [] :
Decidable (∀ (a : α), p a)
Equations
• Fintype.decidableForallFintype = decidable_of_iff (aFinset.univ, p a) (_ : (aFinset.univ, p a) ∀ (a : α), p a)
instance Fintype.decidableExistsFintype {α : Type u_1} {p : αProp} [] [] :
Decidable (∃ (a : α), p a)
Equations
• Fintype.decidableExistsFintype = decidable_of_iff (∃ a ∈ Finset.univ, p a) (_ : (∃ x ∈ Finset.univ, p x) ∃ (a : α), p a)
instance Fintype.decidableMemRangeFintype {α : Type u_1} {β : Type u_2} [] [] (f : αβ) :
DecidablePred fun (x : β) => x
Equations
• = Fintype.decidableExistsFintype
instance Fintype.decidableSubsingleton {α : Type u_1} [] [] {s : Set α} [DecidablePred fun (x : α) => x s] :
Equations
• Fintype.decidableSubsingleton = decidable_of_iff (as, bs, a = b) (_ : (as, bs, a = b) as, bs, a = b)
instance Fintype.decidableEqEquivFintype {α : Type u_1} {β : Type u_2} [] [] :
Equations
instance Fintype.decidableEqEmbeddingFintype {α : Type u_1} {β : Type u_2} [] [] :
Equations
instance Fintype.decidableEqZeroHomFintype {α : Type u_1} {β : Type u_2} [] [] [Zero α] [Zero β] :
Equations
theorem Fintype.decidableEqZeroHomFintype.proof_1 {α : Type u_1} {β : Type u_2} [Zero α] [Zero β] (a : ZeroHom α β) (b : ZeroHom α β) :
a = b a = b
instance Fintype.decidableEqOneHomFintype {α : Type u_1} {β : Type u_2} [] [] [One α] [One β] :
Equations
instance Fintype.decidableEqAddHomFintype {α : Type u_1} {β : Type u_2} [] [] [Add α] [Add β] :
Equations
a = b a = b
instance Fintype.decidableEqMulHomFintype {α : Type u_1} {β : Type u_2} [] [] [Mul α] [Mul β] :
Equations
instance Fintype.decidableEqAddMonoidHomFintype {α : Type u_1} {β : Type u_2} [] [] [] [] :
Equations
theorem Fintype.decidableEqAddMonoidHomFintype.proof_1 {α : Type u_1} {β : Type u_2} [] [] (a : α →+ β) (b : α →+ β) :
a = b a = b
instance Fintype.decidableEqMonoidHomFintype {α : Type u_1} {β : Type u_2} [] [] [] [] :
Equations
instance Fintype.decidableEqMonoidWithZeroHomFintype {α : Type u_1} {β : Type u_2} [] [] [] [] :
Equations
instance Fintype.decidableEqRingHomFintype {α : Type u_1} {β : Type u_2} [] [] [] [] :
Equations
instance Fintype.decidableInjectiveFintype {α : Type u_1} {β : Type u_2} [] [] [] :
DecidablePred Function.Injective
Equations
• = id inferInstance
instance Fintype.decidableSurjectiveFintype {α : Type u_1} {β : Type u_2} [] [] [] :
DecidablePred Function.Surjective
Equations
• = id inferInstance
instance Fintype.decidableBijectiveFintype {α : Type u_1} {β : Type u_2} [] [] [] [] :
DecidablePred Function.Bijective
Equations
• = id inferInstance
instance Fintype.decidableRightInverseFintype {α : Type u_1} {β : Type u_2} [] [] (f : αβ) (g : βα) :
Equations
• = let_fun this := inferInstance; this
instance Fintype.decidableLeftInverseFintype {α : Type u_1} {β : Type u_2} [] [] (f : αβ) (g : βα) :
Equations
• = let_fun this := inferInstance; this
def Fintype.ofMultiset {α : Type u_1} [] (s : ) (H : ∀ (x : α), x s) :

Construct a proof of Fintype α from a universal multiset

Equations
• = { elems := , complete := (_ : ∀ (x : α), ) }
Instances For
def Fintype.ofList {α : Type u_1} [] (l : List α) (H : ∀ (x : α), x l) :

Construct a proof of Fintype α from a universal list

Equations
• = { elems := , complete := (_ : ∀ (x : α), ) }
Instances For
instance Fintype.subsingleton (α : Type u_4) :
Equations
• (_ : ) = (_ : )
def Fintype.subtype {α : Type u_1} {p : αProp} (s : ) (H : ∀ (x : α), x s p x) :
Fintype { x : α // p x }

Given a predicate that can be represented by a finset, the subtype associated to the predicate is a fintype.

Equations
• One or more equations did not get rendered due to their size.
Instances For
def Fintype.ofFinset {α : Type u_1} {p : Set α} (s : ) (H : ∀ (x : α), x s x p) :
Fintype p

Construct a fintype from a finset with the same elements.

Equations
Instances For
def Fintype.ofBijective {α : Type u_1} {β : Type u_2} [] (f : αβ) (H : ) :

If f : α → β is a bijection and α is a fintype, then β is also a fintype.

Equations
• One or more equations did not get rendered due to their size.
Instances For
def Fintype.ofSurjective {α : Type u_1} {β : Type u_2} [] [] (f : αβ) (H : ) :

If f : α → β is a surjection and α is a fintype, then β is also a fintype.

Equations
Instances For
@[simp]
theorem Finset.filter_univ_mem {α : Type u_1} [] [] (s : ) :
Finset.filter (fun (x : α) => x s) Finset.univ = s
instance Finset.decidableCodisjoint {α : Type u_1} [] [] {s : } {t : } :
Equations
• Finset.decidableCodisjoint = decidable_of_iff (∀ ⦃a : α⦄, asa t) (_ : (∀ ⦃a : α⦄, asa t) )
instance Finset.decidableIsCompl {α : Type u_1} [] [] {s : } {t : } :
Equations
def Function.Injective.invOfMemRange {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (hf : ) :
()α

The inverse of an hf : injective function f : α → β, of the type ↥(Set.range f) → α. This is the computable version of Function.invFun that requires Fintype α and DecidableEq β, or the function version of applying (Equiv.ofInjective f hf).symm. This function should not usually be used for actual computation because for most cases, an explicit inverse can be stated that has better computational properties. This function computes by checking all terms a : α to find the f a = b, so it is O(N) where N = Fintype.card α.

Equations
• = Finset.choose (fun (a : α) => f a = b) Finset.univ (_ : ∃! (a : α), a Finset.univ (fun (a : α) => f a = b) a)
Instances For
theorem Function.Injective.left_inv_of_invOfMemRange {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (hf : ) (b : ()) :
f = b
@[simp]
theorem Function.Injective.right_inv_of_invOfMemRange {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (hf : ) (a : α) :
Function.Injective.invOfMemRange hf { val := f a, property := (_ : f a ) } = a
theorem Function.Injective.invFun_restrict {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (hf : ) [] :
theorem Function.Injective.invOfMemRange_surjective {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (hf : ) :
def Function.Embedding.invOfMemRange {α : Type u_1} {β : Type u_2} [] [] (f : α β) (b : ()) :
α

The inverse of an embedding f : α ↪ β, of the type ↥(Set.range f) → α. This is the computable version of Function.invFun that requires Fintype α and DecidableEq β, or the function version of applying (Equiv.ofInjective f f.injective).symm. This function should not usually be used for actual computation because for most cases, an explicit inverse can be stated that has better computational properties. This function computes by checking all terms a : α to find the f a = b, so it is O(N) where N = Fintype.card α.

Equations
Instances For
@[simp]
theorem Function.Embedding.left_inv_of_invOfMemRange {α : Type u_1} {β : Type u_2} [] [] (f : α β) (b : ()) :
= b
@[simp]
theorem Function.Embedding.right_inv_of_invOfMemRange {α : Type u_1} {β : Type u_2} [] [] (f : α β) (a : α) :
Function.Embedding.invOfMemRange f { val := f a, property := (_ : f a ) } = a
theorem Function.Embedding.invFun_restrict {α : Type u_1} {β : Type u_2} [] [] (f : α β) [] :
theorem Function.Embedding.invOfMemRange_surjective {α : Type u_1} {β : Type u_2} [] [] (f : α β) :
noncomputable def Fintype.ofInjective {α : Type u_1} {β : Type u_2} [] (f : αβ) (H : ) :

Given an injective function to a fintype, the domain is also a fintype. This is noncomputable because injectivity alone cannot be used to construct preimages.

Equations
• = if hα : then else { elems := , complete := (_ : ∀ (x : α), x ) }
Instances For
def Fintype.ofEquiv {β : Type u_2} (α : Type u_4) [] (f : α β) :

If f : α ≃ β and α is a fintype, then β is also a fintype.

Equations
Instances For
def Fintype.ofSubsingleton {α : Type u_1} (a : α) [] :

Any subsingleton type with a witness is a fintype (with one term).

Equations
• = { elems := {a}, complete := (_ : ∀ (x : α), x {a}) }
Instances For
@[simp]
theorem Fintype.univ_ofSubsingleton {α : Type u_1} (a : α) [] :
Finset.univ = {a}
def Fintype.ofIsEmpty {α : Type u_1} [] :

An empty type is a fintype. Not registered as an instance, to make sure that there aren't two conflicting Fintype ι instances around when casing over whether a fintype ι is empty or not.

Equations
• Fintype.ofIsEmpty = { elems := , complete := (_ : ∀ (a : α), a ) }
Instances For
@[simp]
theorem Fintype.univ_ofIsEmpty {α : Type u_1} [] :
Finset.univ =

Note: this lemma is specifically about Fintype.ofIsEmpty. For a statement about arbitrary Fintype instances, use Finset.univ_eq_empty.

Equations
Equations
def Set.toFinset {α : Type u_1} (s : Set α) [Fintype s] :

Construct a finset enumerating a set s, given a Fintype instance.

Equations
Instances For
theorem Set.toFinset_congr {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] (h : s = t) :
@[simp]
theorem Set.mem_toFinset {α : Type u_1} {s : Set α} [Fintype s] {a : α} :
a s
theorem Set.toFinset_ofFinset {α : Type u_1} {p : Set α} (s : ) (H : ∀ (x : α), x s x p) :

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 {α : Type u_1} [] (s : Set α) [Fintype s] (a : α) :

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.

Equations
Instances For
@[simp]
theorem Set.coe_toFinset {α : Type u_1} (s : Set α) [Fintype s] :
() = s
@[simp]
theorem Set.toFinset_nonempty {α : Type u_1} {s : Set α} [Fintype s] :
().Nonempty
@[simp]
theorem Set.toFinset_inj {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
s = t
theorem Set.toFinset_subset_toFinset {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
s t
@[simp]
theorem Set.toFinset_ssubset {α : Type u_1} {s : Set α} [Fintype s] {t : } :
s t
@[simp]
theorem Set.subset_toFinset {α : Type u_1} {t : Set α} {s : } [Fintype t] :
s t
@[simp]
theorem Set.ssubset_toFinset {α : Type u_1} {t : Set α} {s : } [Fintype t] :
s t
theorem Set.toFinset_ssubset_toFinset {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
s t
@[simp]
theorem Set.toFinset_subset {α : Type u_1} {s : Set α} [Fintype s] {t : } :
s t
theorem Set.toFinset_mono {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
s t

Alias of the reverse direction of Set.toFinset_subset_toFinset.

theorem Set.toFinset_strict_mono {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
s t

Alias of the reverse direction of Set.toFinset_ssubset_toFinset.

@[simp]
theorem Set.disjoint_toFinset {α : Type u_1} {s : Set α} {t : Set α} [Fintype s] [Fintype t] :
@[simp]
theorem Set.toFinset_inter {α : Type u_1} (s : Set α) (t : Set α) [] [Fintype s] [Fintype t] [Fintype (s t)] :
@[simp]
theorem Set.toFinset_union {α : Type u_1} (s : Set α) (t : Set α) [] [Fintype s] [Fintype t] [Fintype (s t)] :
@[simp]
theorem Set.toFinset_diff {α : Type u_1} (s : Set α) (t : Set α) [] [Fintype s] [Fintype t] [Fintype (s \ t)] :
@[simp]
theorem Set.toFinset_symmDiff {α : Type u_1} (s : Set α) (t : Set α) [] [Fintype s] [Fintype t] [Fintype (symmDiff s t)] :
@[simp]
theorem Set.toFinset_compl {α : Type u_1} (s : Set α) [] [Fintype s] [] [Fintype s] :
@[simp]
theorem Set.toFinset_empty {α : Type u_1} [] :
@[simp]
theorem Set.toFinset_univ {α : Type u_1} [] [Fintype Set.univ] :
Set.toFinset Set.univ = Finset.univ
@[simp]
theorem Set.toFinset_eq_empty {α : Type u_1} {s : Set α} [Fintype s] :
s =
@[simp]
theorem Set.toFinset_eq_univ {α : Type u_1} {s : Set α} [] [Fintype s] :
= Finset.univ s = Set.univ
@[simp]
theorem Set.toFinset_setOf {α : Type u_1} [] (p : αProp) [] [Fintype {x : α | p x}] :
Set.toFinset {x : α | p x} = Finset.filter p Finset.univ
theorem Set.toFinset_ssubset_univ {α : Type u_1} [] {s : Set α} [Fintype s] :
Finset.univ s Set.univ
@[simp]
theorem Set.toFinset_image {α : Type u_1} {β : Type u_2} [] (f : αβ) (s : Set α) [Fintype s] [Fintype (f '' s)] :
@[simp]
theorem Set.toFinset_range {α : Type u_1} {β : Type u_2} [] [] (f : βα) [Fintype ()] :
= Finset.image f Finset.univ
@[simp]
theorem Set.toFinset_singleton {α : Type u_1} (a : α) [Fintype {a}] :
Set.toFinset {a} = {a}
@[simp]
theorem Set.toFinset_insert {α : Type u_1} [] {a : α} {s : Set α} [Fintype (insert a s)] [Fintype s] :
theorem Set.filter_mem_univ_eq_toFinset {α : Type u_1} [] (s : Set α) [Fintype s] [DecidablePred fun (x : α) => x s] :
Finset.filter (fun (x : α) => x s) Finset.univ =
@[simp]
theorem Finset.toFinset_coe {α : Type u_1} (s : ) [Fintype s] :
= s
instance Fin.fintype (n : ) :
Equations
• = { elems := { val := (), nodup := (_ : ) }, complete := (_ : ∀ (a : Fin n), ) }
theorem Fin.univ_def (n : ) :
Finset.univ = { val := (), nodup := (_ : ) }
@[simp]
theorem List.toFinset_finRange (n : ) :
= Finset.univ
@[simp]
theorem Fin.image_succAbove_univ {n : } (i : Fin (n + 1)) :
Finset.image () Finset.univ = {i}
@[simp]
theorem Fin.image_succ_univ (n : ) :
Finset.image Fin.succ Finset.univ = {0}
@[simp]
theorem Fin.image_castSucc (n : ) :
Finset.image Fin.castSucc Finset.univ = {}
theorem Fin.univ_succ (n : ) :
Finset.univ = Finset.cons 0 (Finset.map { toFun := Fin.succ, inj' := (_ : Function.Injective Fin.succ) } Finset.univ) (_ : 0Finset.map { toFun := Fin.succ, inj' := (_ : Function.Injective Fin.succ) } Finset.univ)

Embed Fin n into Fin (n + 1) by prepending zero to the univ

theorem Fin.univ_castSuccEmb (n : ) :
Finset.univ = Finset.cons () (Finset.map Fin.castSuccEmb.toEmbedding Finset.univ) (_ : Finset.map { toFun := Fin.castSucc, inj' := (_ : ∀ (x x_1 : Fin n), x = x_1) } Finset.univ)

Embed Fin n into Fin (n + 1) by appending a new Fin.last n to the univ

theorem Fin.univ_succAbove (n : ) (p : Fin (n + 1)) :
Finset.univ = Finset.cons p (Finset.map ().toEmbedding Finset.univ) (_ : pFinset.map { toFun := , inj' := (_ : ∀ (x x_1 : Fin n), = Fin.succAbove p x_1x = x_1) } Finset.univ)

Embed Fin n into Fin (n + 1) by inserting around a specified pivot p : Fin (n + 1) into the univ

instance Unique.fintype {α : Type u_4} [] :
Equations
instance Fintype.subtypeEq {α : Type u_1} (y : α) :
Fintype { x : α // x = y }

Short-circuit instance to decrease search for Unique.fintype, since that relies on a subsingleton elimination for Unique.

Equations
instance Fintype.subtypeEq' {α : Type u_1} (y : α) :
Fintype { x : α // y = x }

Short-circuit instance to decrease search for Unique.fintype, since that relies on a subsingleton elimination for Unique.

Equations
theorem Fintype.univ_empty :
Finset.univ =
theorem Fintype.univ_pempty :
Finset.univ =
instance Unit.fintype :
Equations
theorem Fintype.univ_unit :
Finset.univ = {()}
instance PUnit.fintype :
Equations
theorem Fintype.univ_punit :
Finset.univ =
instance Bool.fintype :
Equations
@[simp]
theorem Fintype.univ_bool :
Finset.univ = {true, false}
instance Additive.fintype {α : Type u_1} [] :
Equations
instance Multiplicative.fintype {α : Type u_1} [] :
Equations
def Fintype.prodLeft {α : Type u_4} {β : Type u_5} [] [Fintype (α × β)] [] :

Given that α × β is a fintype, α is also a fintype.

Equations
Instances For
def Fintype.prodRight {α : Type u_4} {β : Type u_5} [] [Fintype (α × β)] [] :

Given that α × β is a fintype, β is also a fintype.

Equations
Instances For
instance ULift.fintype (α : Type u_4) [] :
Equations
instance PLift.fintype (α : Type u_4) [] :
Equations
instance OrderDual.fintype (α : Type u_4) [] :
Equations
• = inst
instance OrderDual.finite (α : Type u_4) [] :
Equations
• (_ : ) = inst
instance Lex.fintype (α : Type u_4) [] :
Equations
• = inst

### Fintype (s : Finset α)#

instance Finset.fintypeCoeSort {α : Type u} (s : ) :
Fintype { x : α // x s }
Equations
• = { elems := , complete := (_ : ∀ (x : { x : α // x s }), ) }
@[simp]
theorem Finset.univ_eq_attach {α : Type u} (s : ) :
Finset.univ =
theorem Fintype.coe_image_univ {α : Type u_1} {β : Type u_2} [] [] {f : αβ} :
(Finset.image f Finset.univ) =
instance List.Subtype.fintype {α : Type u_1} [] (l : List α) :
Fintype { x : α // x l }
Equations
instance Multiset.Subtype.fintype {α : Type u_1} [] (s : ) :
Fintype { x : α // x s }
Equations
instance Finset.Subtype.fintype {α : Type u_1} (s : ) :
Fintype { x : α // x s }
Equations
• = { elems := , complete := (_ : ∀ (x : { x : α // x s }), ) }
instance FinsetCoe.fintype {α : Type u_1} (s : ) :
Fintype s
Equations
theorem Finset.attach_eq_univ {α : Type u_1} {s : } :
= Finset.univ
instance PLift.fintypeProp (p : Prop) [] :
Equations
• = { elems := if h : p then {{ down := h }} else , complete := (_ : ∀ (x : ), x if h : p then {{ down := h }} else ) }
instance Prop.fintype :
Equations
@[simp]
theorem Fintype.univ_Prop :
Finset.univ = {True, False}
instance Subtype.fintype {α : Type u_1} (p : αProp) [] [] :
Fintype { x : α // p x }
Equations
def setFintype {α : Type u_1} [] (s : Set α) [DecidablePred fun (x : α) => x s] :
Fintype s

A set on a fintype, when coerced to a type, is a fintype.

Equations
Instances For
@[simp]
theorem unitsEquivProdSubtype_apply_coe (α : Type u_1) [] (u : αˣ) :
() = (u, u⁻¹)
@[simp]
theorem val_unitsEquivProdSubtype_symm_apply (α : Type u_1) [] (p : { p : α × α // p.1 * p.2 = 1 p.2 * p.1 = 1 }) :
(.symm p) = (p).1
@[simp]
theorem val_inv_unitsEquivProdSubtype_symm_apply (α : Type u_1) [] (p : { p : α × α // p.1 * p.2 = 1 p.2 * p.1 = 1 }) :
(.symm p)⁻¹ = (p).2
def unitsEquivProdSubtype (α : Type u_1) [] :
αˣ { p : α × α // p.1 * p.2 = 1 p.2 * p.1 = 1 }

The αˣ type is equivalent to a subtype of α × α.

Equations
• One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem unitsEquivNeZero_symm_apply (α : Type u_1) [] (a : { a : α // a 0 }) :
().symm a = Units.mk0 a (_ : a 0)
@[simp]
theorem unitsEquivNeZero_apply_coe (α : Type u_1) [] (a : αˣ) :
(() a) = a
def unitsEquivNeZero (α : Type u_1) [] :
αˣ { a : α // a 0 }

In a GroupWithZero α, the unit group αˣ is equivalent to the subtype of nonzero elements.

Equations
• One or more equations did not get rendered due to their size.
Instances For
noncomputable def Fintype.finsetEquivSet {α : Type u_1} [] :
Set α

Given Fintype α, finsetEquivSet is the equiv between Finset α and Set α. (All sets on a finite type are finite.)

Equations
• One or more equations did not get rendered due to their size.
Instances For
@[simp]
theorem Fintype.coe_finsetEquivSet {α : Type u_1} [] :
Fintype.finsetEquivSet = Finset.toSet
@[simp]
theorem Fintype.finsetEquivSet_apply {α : Type u_1} [] (s : ) :
Fintype.finsetEquivSet s = s
@[simp]
theorem Fintype.finsetEquivSet_symm_apply {α : Type u_1} [] (s : Set α) [Fintype s] :
Fintype.finsetEquivSet.symm s =
@[simp]
theorem Fintype.finsetOrderIsoSet_toEquiv {α : Type u_1} [] :
Fintype.finsetOrderIsoSet.toEquiv = Fintype.finsetEquivSet
noncomputable def Fintype.finsetOrderIsoSet {α : Type u_1} [] :
≃o Set α

Given a fintype α, finsetOrderIsoSet is the order isomorphism between Finset α and Set α (all sets on a finite type are finite).

Equations
• Fintype.finsetOrderIsoSet = { toEquiv := Fintype.finsetEquivSet, map_rel_iff' := (_ : ∀ {a b : }, a b a b) }
Instances For
@[simp]
theorem Fintype.coe_finsetOrderIsoSet {α : Type u_1} [] :
Fintype.finsetOrderIsoSet = Finset.toSet
@[simp]
theorem Fintype.coe_finsetOrderIsoSet_symm {α : Type u_1} [] :
(OrderIso.symm Fintype.finsetOrderIsoSet) = Fintype.finsetEquivSet.symm
instance Quotient.fintype {α : Type u_1} [] (s : ) [DecidableRel fun (x x_1 : α) => x x_1] :
Equations
instance PSigma.fintypePropLeft {α : Prop} {β : αType u_4} [] [(a : α) → Fintype (β a)] :
Fintype ((a : α) ×' β a)
Equations
• One or more equations did not get rendered due to their size.
instance PSigma.fintypePropRight {α : Type u_4} {β : αProp} [(a : α) → Decidable (β a)] [] :
Fintype ((a : α) ×' β a)
Equations
• One or more equations did not get rendered due to their size.
instance PSigma.fintypePropProp {α : Prop} {β : αProp} [] [(a : α) → Decidable (β a)] :
Fintype ((a : α) ×' β a)
Equations
• One or more equations did not get rendered due to their size.
instance pfunFintype (p : Prop) [] (α : pType u_4) [(hp : p) → Fintype (α hp)] :
Fintype ((hp : p) → α hp)
Equations
• One or more equations did not get rendered due to their size.
theorem mem_image_univ_iff_mem_range {α : Type u_4} {β : Type u_5} [] [] {f : αβ} {b : β} :
b Finset.image f Finset.univ b
def Fintype.chooseX {α : Type u_1} [] (p : αProp) [] (hp : ∃! (a : α), p a) :
{ a : α // p a }

Given a fintype α and a predicate p, associate to a proof that there is a unique element of α satisfying p this unique element, as an element of the corresponding subtype.

Equations
Instances For
def Fintype.choose {α : Type u_1} [] (p : αProp) [] (hp : ∃! (a : α), p a) :
α

Given a fintype α and a predicate p, associate to a proof that there is a unique element of α satisfying p this unique element, as an element of α.

Equations
• = ()
Instances For
theorem Fintype.choose_spec {α : Type u_1} [] (p : αProp) [] (hp : ∃! (a : α), p a) :
p ()
theorem Fintype.choose_subtype_eq {α : Type u_4} (p : αProp) [Fintype { a : α // p a }] [] (x : { a : α // p a }) (h : optParam (∃! (a : { a : α // p a }), a = x) (_ : ∃ (x_1 : { a : α // p a }), (fun (a : { a : α // p a }) => a = x) x_1 ∀ (y : { a : α // p a }), (fun (a : { a : α // p a }) => a = x) yy = x_1)) :
Fintype.choose (fun (y : { a : α // p a }) => y = x) h = x
def Fintype.bijInv {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (f_bij : ) (b : β) :
α

bijInv f is the unique inverse to a bijection f. This acts as a computable alternative to Function.invFun.

Equations
Instances For
theorem Fintype.leftInverse_bijInv {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (f_bij : ) :
theorem Fintype.rightInverse_bijInv {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (f_bij : ) :
theorem Fintype.bijective_bijInv {α : Type u_1} {β : Type u_2} [] [] {f : αβ} (f_bij : ) :
def truncOfMultisetExistsMem {α : Type u_4} (s : ) :
(∃ (x : α), x s)

For s : Multiset α, we can lift the existential statement that ∃ x, x ∈ s to a Trunc α.

Equations
• One or more equations did not get rendered due to their size.
Instances For
def truncOfNonemptyFintype (α : Type u_4) [] [] :

A Nonempty Fintype constructively contains an element.

Equations
Instances For
def truncSigmaOfExists {α : Type u_4} [] {P : αProp} [] (h : ∃ (a : α), P a) :
Trunc ((a : α) ×' P a)

By iterating over the elements of a fintype, we can lift an existential statement ∃ a, P a to Trunc (Σ' a, P a), containing data.

Equations
Instances For
@[simp]
theorem Multiset.count_univ {α : Type u_1} [] [] (a : α) :
Multiset.count a Finset.univ.val = 1
@[simp]
theorem Multiset.map_univ_val_equiv {α : Type u_1} {β : Type u_2} [] [] (e : α β) :
Multiset.map (e) Finset.univ.val = Finset.univ.val
@[simp]
theorem Multiset.bijective_iff_map_univ_eq_univ {α : Type u_1} {β : Type u_2} [] [] (f : αβ) :
Multiset.map f Finset.univ.val = Finset.univ.val

For functions on finite sets, they are bijections iff they map universes into universes.

noncomputable def seqOfForallFinsetExistsAux {α : Type u_4} [] (P : αProp) (r : ααProp) (h : ∀ (s : ), ∃ (y : α), (xs, P x)P y xs, r x y) :
α

Auxiliary definition to show exists_seq_of_forall_finset_exists.

Equations
• One or more equations did not get rendered due to their size.
Instances For
theorem exists_seq_of_forall_finset_exists {α : Type u_4} (P : αProp) (r : ααProp) (h : ∀ (s : ), (xs, P x)∃ (y : α), P y xs, r x y) :
∃ (f : α), (∀ (n : ), P (f n)) ∀ (m n : ), m < nr (f m) (f n)

Induction principle to build a sequence, by adding one point at a time satisfying a given relation with respect to all the previously chosen points.

More precisely, Assume that, for any finite set s, one can find another point satisfying some relation r with respect to all the points in s. Then one may construct a function f : ℕ → α such that r (f m) (f n) holds whenever m < n. We also ensure that all constructed points satisfy a given predicate P.

theorem exists_seq_of_forall_finset_exists' {α : Type u_4} (P : αProp) (r : ααProp) [IsSymm α r] (h : ∀ (s : ), (xs, P x)∃ (y : α), P y xs, r x y) :
∃ (f : α), (∀ (n : ), P (f n)) Pairwise fun (m n : ) => r (f m) (f n)

Induction principle to build a sequence, by adding one point at a time satisfying a given symmetric relation with respect to all the previously chosen points.

More precisely, Assume that, for any finite set s, one can find another point satisfying some relation r with respect to all the points in s. Then one may construct a function f : ℕ → α such that r (f m) (f n) holds whenever m ≠ n. We also ensure that all constructed points satisfy a given predicate P.