mathlib3 documentation

data.fintype.basic

Finite types #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

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

Main declarations #

See data.fintype.card for the cardinality of a fintype, the equivalence with fin (fintype.card α), and pigeonhole principles.

Instances #

Instances for fintype for

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.of_injective and fintype.of_surjective.

@[class]
structure 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.

Instances of this typeclass
Instances of other typeclasses for fintype
def finset.univ {α : Type u_1} [fintype α] :

univ is the universal finite set of type finset α implied from the assumption fintype α.

Equations
@[simp]
theorem finset.mem_univ {α : Type u_1} [fintype α] (x : α) :
@[simp]
theorem finset.mem_univ_val {α : Type u_1} [fintype α] (x : α) :
theorem finset.eq_univ_iff_forall {α : Type u_1} [fintype α] {s : finset α} :
s = finset.univ (x : α), x s
theorem finset.eq_univ_of_forall {α : Type u_1} [fintype α] {s : finset α} :
( (x : α), x s) s = finset.univ
@[simp, norm_cast]
theorem finset.coe_univ {α : Type u_1} [fintype α] :
@[simp, norm_cast]
theorem finset.coe_eq_univ {α : Type u_1} [fintype α] {s : finset α} :
theorem finset.nonempty.eq_univ {α : Type u_1} [fintype α] {s : finset α} [subsingleton α] :
@[simp]
theorem finset.univ_eq_empty {α : Type u_1} [fintype α] [is_empty α] :
@[simp]
@[simp]
theorem finset.subset_univ {α : Type u_1} [fintype α] (s : finset α) :
@[protected, instance]
def finset.bounded_order {α : Type u_1} [fintype α] :
Equations
@[simp]
theorem finset.top_eq_univ {α : Type u_1} [fintype α] :
theorem finset.codisjoint_left {α : Type u_1} [fintype α] {s t : finset α} :
codisjoint s t ⦃a : α⦄, a s a t
theorem finset.codisjoint_right {α : Type u_1} [fintype α] {s t : finset α} :
codisjoint s t ⦃a : α⦄, a t a s
theorem finset.sdiff_eq_inter_compl {α : Type u_1} [fintype α] [decidable_eq α] (s t : finset α) :
s \ t = s t
theorem finset.compl_eq_univ_sdiff {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.mem_compl {α : Type u_1} [fintype α] {s : finset α} [decidable_eq α] {a : α} :
a s a s
theorem finset.not_mem_compl {α : Type u_1} [fintype α] {s : finset α} [decidable_eq α] {a : α} :
a s a s
@[simp, norm_cast]
theorem finset.coe_compl {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.compl_empty {α : Type u_1} [fintype α] [decidable_eq α] :
@[simp]
theorem finset.compl_univ {α : Type u_1} [fintype α] [decidable_eq α] :
@[simp]
theorem finset.compl_eq_empty_iff {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.compl_eq_univ_iff {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.union_compl {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.inter_compl {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.compl_union {α : Type u_1} [fintype α] [decidable_eq α] (s t : finset α) :
(s t) = s t
@[simp]
theorem finset.compl_inter {α : Type u_1} [fintype α] [decidable_eq α] (s t : finset α) :
(s t) = s t
@[simp]
theorem finset.compl_erase {α : Type u_1} [fintype α] {s : finset α} [decidable_eq α] {a : α} :
@[simp]
theorem finset.compl_insert {α : Type u_1} [fintype α] {s : finset α} [decidable_eq α] {a : α} :
@[simp]
theorem finset.insert_compl_self {α : Type u_1} [fintype α] [decidable_eq α] (x : α) :
@[simp]
theorem finset.compl_filter {α : Type u_1} [fintype α] [decidable_eq α] (p : α Prop) [decidable_pred p] [Π (x : α), decidable (¬p x)] :
theorem finset.compl_singleton {α : Type u_1} [fintype α] [decidable_eq α] (a : α) :
theorem finset.insert_inj_on' {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
set.inj_on (λ (a : α), has_insert.insert a s) s
theorem finset.map_univ_of_surjective {α : Type u_1} {β : Type u_2} [fintype α] [fintype β] {f : β α} (hf : function.surjective f) :
@[simp]
theorem finset.map_univ_equiv {α : Type u_1} {β : Type u_2} [fintype α] [fintype β] (f : β α) :
@[simp]
theorem finset.univ_inter {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.inter_univ {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.piecewise_univ {α : Type u_1} [fintype α] [Π (i : α), decidable (i finset.univ)] {δ : α Sort u_2} (f g : Π (i : α), δ i) :
theorem finset.piecewise_compl {α : Type u_1} [fintype α] [decidable_eq α] (s : finset α) [Π (i : α), decidable (i s)] [Π (i : α), decidable (i s)] {δ : α Sort u_2} (f g : Π (i : α), δ i) :
@[simp]
theorem finset.piecewise_erase_univ {α : Type u_1} [fintype α] {δ : α Sort u_2} [decidable_eq α] (a : α) (f g : Π (a : α), δ a) :
@[simp]
theorem finset.univ_filter_exists {α : Type u_1} {β : Type u_2} [fintype α] (f : α β) [fintype β] [decidable_pred (λ (y : β), (x : α), f x = y)] [decidable_eq β] :
finset.filter (λ (y : β), (x : α), f x = y) finset.univ = finset.image f finset.univ
theorem finset.univ_filter_mem_range {α : Type u_1} {β : Type u_2} [fintype α] (f : α β) [fintype β] [decidable_pred (λ (y : β), y set.range f)] [decidable_eq β] :

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

theorem finset.coe_filter_univ {α : Type u_1} [fintype α] (p : α Prop) [decidable_pred p] :
(finset.filter p finset.univ) = {x : α | p x}
@[protected, instance]
def fintype.decidable_pi_fintype {α : Type u_1} {β : α Type u_2} [Π (a : α), decidable_eq (β a)] [fintype α] :
decidable_eq (Π (a : α), β a)
Equations
@[protected, instance]
def fintype.decidable_forall_fintype {α : Type u_1} {p : α Prop} [decidable_pred p] [fintype α] :
decidable ( (a : α), p a)
Equations
@[protected, instance]
def fintype.decidable_exists_fintype {α : Type u_1} {p : α Prop} [decidable_pred p] [fintype α] :
decidable ( (a : α), p a)
Equations
@[protected, instance]
def fintype.decidable_mem_range_fintype {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] (f : α β) :
decidable_pred (λ (_x : β), _x set.range f)
Equations
@[protected, instance]
def fintype.decidable_eq_equiv_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] :
Equations
@[protected, instance]
def fintype.decidable_eq_embedding_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] :
Equations
@[protected, instance]
def fintype.decidable_eq_one_hom_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] [has_one α] [has_one β] :
Equations
@[protected, instance]
def fintype.decidable_eq_zero_hom_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] [has_zero α] [has_zero β] :
Equations
@[protected, instance]
def fintype.decidable_eq_mul_hom_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] [has_mul α] [has_mul β] :
Equations
@[protected, instance]
def fintype.decidable_eq_add_hom_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] [has_add α] [has_add β] :
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
def fintype.decidable_eq_ring_hom_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] [semiring α] [semiring β] :
Equations
@[protected, instance]
Equations
@[protected, instance]
def fintype.decidable_right_inverse_fintype {α : Type u_1} {β : Type u_2} [decidable_eq α] [fintype α] (f : α β) (g : β α) :
Equations
@[protected, instance]
def fintype.decidable_left_inverse_fintype {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype β] (f : α β) (g : β α) :
Equations
def fintype.of_multiset {α : Type u_1} [decidable_eq α] (s : multiset α) (H : (x : α), x s) :

Construct a proof of fintype α from a universal multiset

Equations
def fintype.of_list {α : Type u_1} [decidable_eq α] (l : list α) (H : (x : α), x l) :

Construct a proof of fintype α from a universal list

Equations
@[protected, instance]
@[protected]
def fintype.subtype {α : Type u_1} {p : α Prop} (s : finset α) (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
def fintype.of_finset {α : Type u_1} {p : set α} (s : finset α) (H : (x : α), x s x p) :

Construct a fintype from a finset with the same elements.

Equations
def fintype.of_bijective {α : Type u_1} {β : Type u_2} [fintype α] (f : α β) (H : function.bijective f) :

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

Equations
def fintype.of_surjective {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype α] (f : α β) (H : function.surjective f) :

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

Equations
@[protected, instance]
def finset.decidable_codisjoint {α : Type u_1} [fintype α] [decidable_eq α] {s t : finset α} :
Equations
@[protected, instance]
def finset.decidable_is_compl {α : Type u_1} [fintype α] [decidable_eq α] {s t : finset α} :
Equations
def function.injective.inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (hf : function.injective f) :

The inverse of an hf : injective function f : α → β, of the type ↥(set.range f) → α. This is the computable version of function.inv_fun that requires fintype α and decidable_eq β, or the function version of applying (equiv.of_injective 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
theorem function.injective.left_inv_of_inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (hf : function.injective f) (b : (set.range f)) :
@[simp]
theorem function.injective.right_inv_of_inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (hf : function.injective f) (a : α) :
hf.inv_of_mem_range f a, _⟩ = a
def function.embedding.inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] (f : α β) (b : (set.range f)) :
α

The inverse of an embedding f : α ↪ β, of the type ↥(set.range f) → α. This is the computable version of function.inv_fun that requires fintype α and decidable_eq β, or the function version of applying (equiv.of_injective 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
@[simp]
theorem function.embedding.left_inv_of_inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] (f : α β) (b : (set.range f)) :
@[simp]
theorem function.embedding.right_inv_of_inv_of_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] (f : α β) (a : α) :
noncomputable def fintype.of_injective {α : Type u_1} {β : Type u_2} [fintype β] (f : α β) (H : function.injective f) :

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
def fintype.of_equiv {β : Type u_2} (α : Type u_1) [fintype α] (f : α β) :

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

Equations
def fintype.of_subsingleton {α : Type u_1} (a : α) [subsingleton α] :

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

Equations
@[simp]
theorem fintype.univ_of_subsingleton {α : Type u_1} (a : α) [subsingleton α] :
@[protected, instance]
def fintype.of_is_empty {α : Type u_1} [is_empty α] :
Equations
@[simp, nolint]
theorem fintype.univ_of_is_empty {α : Type u_1} [is_empty α] :

Note: this lemma is specifically about fintype.of_is_empty. For a statement about arbitrary fintype instances, use finset.univ_eq_empty.

def set.to_finset {α : Type u_1} (s : set α) [fintype s] :

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

Equations
theorem set.to_finset_congr {α : Type u_1} {s t : set α} [fintype s] [fintype t] (h : s = t) :
@[simp]
theorem set.mem_to_finset {α : Type u_1} {s : set α} [fintype s] {a : α} :
theorem set.to_finset_of_finset {α : Type u_1} {p : set α} (s : finset α) (H : (x : α), x s x p) :

Many fintype instances for sets are defined using an extensionally equal finset. Rewriting s.to_finset with set.to_finset_of_finset replaces the term with such a finset.

def set.decidable_mem_of_fintype {α : Type u_1} [decidable_eq α] (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
@[simp]
theorem set.coe_to_finset {α : Type u_1} (s : set α) [fintype s] :
@[simp]
theorem set.to_finset_nonempty {α : Type u_1} {s : set α} [fintype s] :
@[simp]
theorem set.to_finset_inj {α : Type u_1} {s t : set α} [fintype s] [fintype t] :
theorem set.to_finset_subset_to_finset {α : Type u_1} {s t : set α} [fintype s] [fintype t] :
@[simp]
theorem set.to_finset_ssubset {α : Type u_1} {s : set α} [fintype s] {t : finset α} :
@[simp]
theorem set.subset_to_finset {α : Type u_1} {t : set α} {s : finset α} [fintype t] :
@[simp]
theorem set.ssubset_to_finset {α : Type u_1} {t : set α} {s : finset α} [fintype t] :
theorem set.to_finset_ssubset_to_finset {α : Type u_1} {s t : set α} [fintype s] [fintype t] :
@[simp]
theorem set.to_finset_subset {α : Type u_1} {s : set α} [fintype s] {t : finset α} :
theorem set.to_finset_mono {α : Type u_1} {s t : set α} [fintype s] [fintype t] :

Alias of the reverse direction of set.to_finset_subset_to_finset.

theorem set.to_finset_strict_mono {α : Type u_1} {s t : set α} [fintype s] [fintype t] :

Alias of the reverse direction of set.to_finset_ssubset_to_finset.

@[simp]
theorem set.disjoint_to_finset {α : Type u_1} {s t : set α} [fintype s] [fintype t] :
@[simp]
theorem set.to_finset_inter {α : Type u_1} (s t : set α) [decidable_eq α] [fintype s] [fintype t] [fintype (s t)] :
@[simp]
theorem set.to_finset_union {α : Type u_1} (s t : set α) [decidable_eq α] [fintype s] [fintype t] [fintype (s t)] :
@[simp]
theorem set.to_finset_diff {α : Type u_1} (s t : set α) [decidable_eq α] [fintype s] [fintype t] [fintype (s \ t)] :
@[simp]
theorem set.to_finset_symm_diff {α : Type u_1} (s t : set α) [decidable_eq α] [fintype s] [fintype t] [fintype (s t)] :
@[simp]
theorem set.to_finset_compl {α : Type u_1} (s : set α) [decidable_eq α] [fintype s] [fintype α] [fintype s] :
@[simp]
@[simp]
theorem set.to_finset_eq_empty {α : Type u_1} {s : set α} [fintype s] :
@[simp]
theorem set.to_finset_eq_univ {α : Type u_1} {s : set α} [fintype α] [fintype s] :
@[simp]
theorem set.to_finset_set_of {α : Type u_1} [fintype α] (p : α Prop) [decidable_pred p] [fintype {x : α | p x}] :
@[simp]
@[simp]
theorem set.to_finset_image {α : Type u_1} {β : Type u_2} [decidable_eq β] (f : α β) (s : set α) [fintype s] [fintype (f '' s)] :
@[simp]
theorem set.to_finset_range {α : Type u_1} {β : Type u_2} [decidable_eq α] [fintype β] (f : β α) [fintype (set.range f)] :
theorem set.to_finset_singleton {α : Type u_1} (a : α) [fintype {a}] :
{a}.to_finset = {a}
theorem set.filter_mem_univ_eq_to_finset {α : Type u_1} [fintype α] (s : set α) [fintype s] [decidable_pred (λ (_x : α), _x s)] :
finset.filter (λ (_x : α), _x s) finset.univ = s.to_finset
@[simp]
theorem finset.to_finset_coe {α : Type u_1} (s : finset α) [fintype s] :
@[protected, instance]
def fin.fintype (n : ) :
Equations
theorem fin.univ_def (n : ) :
@[simp]

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

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

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

@[protected, instance]
def fintype.subtype_eq {α : 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
@[protected, instance]
def fintype.subtype_eq' {α : 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
@[simp]
@[protected, instance]
Equations
@[simp]
theorem fintype.univ_punit  :
finset.univ = {punit.star}
@[protected, instance]
Equations
@[protected, instance]
def additive.fintype {α : Type u_1} [fintype α] :
Equations
@[protected, instance]
Equations
def fintype.prod_left {α : Type u_1} {β : Type u_2} [decidable_eq α] [fintype × β)] [nonempty β] :

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

Equations
def fintype.prod_right {α : Type u_1} {β : Type u_2} [decidable_eq β] [fintype × β)] [nonempty α] :

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

Equations
@[protected, instance]
def ulift.fintype (α : Type u_1) [fintype α] :
Equations
@[protected, instance]
def plift.fintype (α : Type u_1) [fintype α] :
Equations
@[protected, instance]
def order_dual.fintype (α : Type u_1) [fintype α] :
Equations
@[protected, instance]
def order_dual.finite (α : Type u_1) [finite α] :
@[protected, instance]
def lex.fintype (α : Type u_1) [fintype α] :
Equations

fintype (s : finset α) #

@[protected, instance]
def finset.fintype_coe_sort {α : Type u} (s : finset α) :
Equations
@[simp]
theorem finset.univ_eq_attach {α : Type u} (s : finset α) :
theorem fintype.coe_image_univ {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} :
@[protected, instance]
def list.subtype.fintype {α : Type u_1} [decidable_eq α] (l : list α) :
fintype {x // x l}
Equations
@[protected, instance]
def multiset.subtype.fintype {α : Type u_1} [decidable_eq α] (s : multiset α) :
fintype {x // x s}
Equations
@[protected, instance]
def finset.subtype.fintype {α : Type u_1} (s : finset α) :
fintype {x // x s}
Equations
@[protected, instance]
def finset_coe.fintype {α : Type u_1} (s : finset α) :
Equations
theorem finset.attach_eq_univ {α : Type u_1} {s : finset α} :
@[protected, instance]
def plift.fintype_Prop (p : Prop) [decidable p] :
Equations
@[protected, instance]
def Prop.fintype  :
fintype Prop
Equations
@[simp]
@[protected, instance]
def subtype.fintype {α : Type u_1} (p : α Prop) [decidable_pred p] [fintype α] :
fintype {x // p x}
Equations
def set_fintype {α : Type u_1} [fintype α] (s : set α) [decidable_pred (λ (_x : α), _x s)] :

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

Equations
@[simp]
theorem coe_units_equiv_prod_subtype_symm_apply (α : Type u_1) [monoid α] (p : {p // p.fst * p.snd = 1 p.snd * p.fst = 1}) :
@[simp]
@[simp]
theorem coe_inv_units_equiv_prod_subtype_symm_apply (α : Type u_1) [monoid α] (p : {p // p.fst * p.snd = 1 p.snd * p.fst = 1}) :
def units_equiv_prod_subtype (α : Type u_1) [monoid α] :
αˣ {p // p.fst * p.snd = 1 p.snd * p.fst = 1}

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

Equations
@[simp]
theorem units_equiv_ne_zero_apply_coe (α : Type u_1) [group_with_zero α] (a : αˣ) :
def units_equiv_ne_zero (α : Type u_1) [group_with_zero α] :
αˣ {a // a 0}

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

Equations
@[simp]
theorem units_equiv_ne_zero_symm_apply (α : Type u_1) [group_with_zero α] (a : {a // a 0}) :
noncomputable def fintype.finset_equiv_set {α : Type u_1} [fintype α] :
finset α set α

Given fintype α, finset_equiv_set is the equiv between finset α and set α. (All sets on a finite type are finite.)

Equations
@[simp]
@[protected, instance]
Equations
@[protected, instance]
def psigma.fintype_prop_left {α : Prop} {β : α Type u_1} [decidable α] [Π (a : α), fintype (β a)] :
fintype (Σ' (a : α), β a)
Equations
@[protected, instance]
def psigma.fintype_prop_right {α : Type u_1} {β : α Prop} [Π (a : α), decidable (β a)] [fintype α] :
fintype (Σ' (a : α), β a)
Equations
@[protected, instance]
def psigma.fintype_prop_prop {α : Prop} {β : α Prop} [decidable α] [Π (a : α), decidable (β a)] :
fintype (Σ' (a : α), β a)
Equations
@[protected, instance]
def pfun_fintype (p : Prop) [decidable p] (α : p Type u_1) [Π (hp : p), fintype (α hp)] :
fintype (Π (hp : p), α hp)
Equations
theorem mem_image_univ_iff_mem_range {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} {b : β} :
def fintype.choose_x {α : Type u_1} [fintype α] (p : α Prop) [decidable_pred p] (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
def fintype.choose {α : Type u_1} [fintype α] (p : α Prop) [decidable_pred p] (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
theorem fintype.choose_spec {α : Type u_1} [fintype α] (p : α Prop) [decidable_pred p] (hp : ∃! (a : α), p a) :
@[simp]
theorem fintype.choose_subtype_eq {α : Type u_1} (p : α Prop) [fintype {a // p a}] [decidable_eq α] (x : {a // p a}) (h : (∃! (a : {a // p a}), a = x) := _) :
fintype.choose (λ (y : {a // p a}), y = x) h = x
def fintype.bij_inv {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (f_bij : function.bijective f) (b : β) :
α

bij_inv f is the unique inverse to a bijection f. This acts as a computable alternative to function.inv_fun.

Equations
theorem fintype.left_inverse_bij_inv {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (f_bij : function.bijective f) :
theorem fintype.right_inverse_bij_inv {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (f_bij : function.bijective f) :
theorem fintype.bijective_bij_inv {α : Type u_1} {β : Type u_2} [fintype α] [decidable_eq β] {f : α β} (f_bij : function.bijective f) :
def trunc_of_multiset_exists_mem {α : Type u_1} (s : multiset α) :
( (x : α), x s) trunc α

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

Equations
def trunc_of_nonempty_fintype (α : Type u_1) [nonempty α] [fintype α] :

A nonempty fintype constructively contains an element.

Equations
def trunc_sigma_of_exists {α : Type u_1} [fintype α] {P : α Prop} [decidable_pred P] (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
@[simp]
theorem multiset.count_univ {α : Type u_1} [fintype α] [decidable_eq α] (a : α) :
noncomputable def seq_of_forall_finset_exists_aux {α : Type u_1} [decidable_eq α] (P : α Prop) (r : α α Prop) (h : (s : finset α), (y : α), ( (x : α), x s P x) (P y (x : α), x s r x y)) :
α

Auxiliary definition to show exists_seq_of_forall_finset_exists.

Equations
theorem exists_seq_of_forall_finset_exists {α : Type u_1} (P : α Prop) (r : α α Prop) (h : (s : finset α), ( (x : α), x s P x) ( (y : α), P y (x : α), x s r x y)) :
(f : α), ( (n : ), P (f n)) (m n : ), m < n r (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_1} (P : α Prop) (r : α α Prop) [is_symm α r] (h : (s : finset α), ( (x : α), x s P x) ( (y : α), P y (x : α), x s r x y)) :
(f : α), ( (n : ), P (f n)) (m n : ), 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.