The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Fintype.Defs

42 declarations. Mathlib docs · Source

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.Basic for elementary results, 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.

Preparatory lemmas

def Fintype.ctorIdx E1 #

{α : Type u_3} → Fintype α → ℕ

class Fintype E3 #

Type u_3 → Type u_3

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.

ctor Fintype.mk E0 #

{α : Type u_3} → (elems : Finset α) → (∀ (x : α), x ∈ elems) → Fintype α

abbrev Fintype.elems E1 #

{α : Type u_3} → [self : Fintype α] → Finset α

The Finset containing all elements of a Fintype

theorem Fintype.complete E1 #

∀ {α : Type u_3} [self : Fintype α] (x : α), x ∈ Fintype.elems

A proof that elems contains every element of the type

theorem Finset.nodup_map_iff_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} {f : α → β} {s : Finset α}, (Multiset.map f s.val).Nodup ↔ Set.InjOn f ↑s

instance List.instDecidableInjOnCoeFinsetOfDecidableEq E0 #

{α : Type u_1} → {β : Type u_2} → {f : α → β} → {s : Finset α} → [DecidableEq β] → Decidable (Set.InjOn f ↑s)

instance List.instDecidableBijOnCoeFinsetOfDecidableEq E0 #

{α : Type u_1} →
  {β : Type u_2} → {f : α → β} → {s : Finset α} → {t' : Finset β} → [DecidableEq β] → Decidable (Set.BijOn f ↑s ↑t')

def Finset.univ E3 #

{α : Type u_1} → [Fintype α] → Finset α

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

theorem Finset.mem_univ E0 #

∀ {α : Type u_1} [inst : Fintype α] (x : α), x ∈ Finset.univ

theorem Finset.mem_univ_val E0 #

∀ {α : Type u_1} [inst : Fintype α] (x : α), x ∈ Finset.univ.val

theorem Finset.coe_univ E0 #

∀ {α : Type u_1} [inst : Fintype α], ↑Finset.univ = Set.univ

theorem Finset.coe_eq_univ E0 #

∀ {α : Type u_1} [inst : Fintype α] {s : Finset α}, ↑s = Set.univ ↔ s = Finset.univ

theorem Finset.subset_univ E0 #

∀ {α : Type u_1} [inst : Fintype α] (s : Finset α), s ⊆ Finset.univ

theorem Finset.mem_filter_univ E0 #

∀ {α : Type u_1} [inst : Fintype α] {p : α → Prop} [inst_1 : DecidablePred p] (x : α),
  x ∈ Finset.filter p Finset.univ ↔ p x

def Mathlib.Meta.elabFinsetBuilderSetOf E1 #

Lean.Elab.Term.TermElab

Elaborate set builder notation for Finset.

  • {x | p x} is elaborated as Finset.filter (fun x ↦ p x) Finset.univ if the expected type is Finset ?α.
  • {x : α | p x} is elaborated as Finset.filter (fun x : α ↦ p x) Finset.univ if the expected type is Finset ?α.
  • {x ∉ s | p x} is elaborated as Finset.filter (fun x ↦ p x) sᶜ if either the expected type is Finset ?α or the expected type is not Set ?α and s has expected type Finset ?α.
  • {x ≠ a | p x} is elaborated as Finset.filter (fun x ↦ p x) {a}ᶜ if the expected type is Finset ?α.

See also

  • Data.Set.Defs for the Set builder notation elaborator that this elaborator partly overrides.
  • Data.Finset.Basic for the Finset builder notation elaborator partly overriding this one for syntax of the form {x ∈ s | p x}.
  • Data.Fintype.Basic for the Finset builder notation elaborator handling syntax of the form {x | p x}, {x : α | p x}, {x ∉ s | p x}, {x ≠ a | p x}.
  • Order.LocallyFinite.Basic for the Finset builder notation elaborator handling syntax of the form {x ≤ a | p x}, {x ≥ a | p x}, {x < a | p x}, {x > a | p x}.

def Mathlib.Meta.delabFinsetFilter E1 #

Lean.PrettyPrinter.Delaborator.Delab

Delaborator for Finset.filter. The pp.funBinderTypes option controls whether to show the domain type when the filter is over Finset.univ.

instance Fintype.decidablePiFintype E0 #

{α : Type u_1} → {β : α → Type u_3} → [(a : α) → DecidableEq (β a)] → [Fintype α] → DecidableEq ((a : α) → β a)

instance Fintype.decidableForallFintype E0 #

{α : Type u_1} → {p : α → Prop} → [DecidablePred p] → [Fintype α] → Decidable (∀ (a : α), p a)

instance Fintype.decidableExistsFintype E0 #

{α : Type u_1} → {p : α → Prop} → [DecidablePred p] → [Fintype α] → Decidable (∃ a, p a)

instance Fintype.instDecidableLEForall E0 #

{α : Type u_1} →
  {β : α → Type u_3} →
    [inst : (a : α) → LE (β a)] → [(a : α) → DecidableLE (β a)] → [Fintype α] → DecidableLE ((a : α) → β a)

instance Fintype.decidableMemRangeFintype E0 #

{α : Type u_1} → {β : Type u_2} → [Fintype α] → [DecidableEq β] → (f : α → β) → DecidablePred fun x ↦ x ∈ Set.range f

instance Fintype.decidableSubsingleton E0 #

{α : Type u_1} → [Fintype α] → [DecidableEq α] → {s : Set α} → [DecidablePred fun x ↦ x ∈ s] → Decidable s.Subsingleton

instance Fintype.decidableEqEquivFintype E0 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → [Fintype α] → DecidableEq (α ≃ β)

instance Fintype.decidableEqEmbeddingFintype E0 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → [Fintype α] → DecidableEq (α ↪ β)

theorem Fintype.nodup_map_univ_iff_injective E1 #

∀ {α : Type u_1} {β : Type u_2} [inst : Fintype α] {f : α → β},
  (Multiset.map f Finset.univ.val).Nodup ↔ Function.Injective f

instance Fintype.decidableInjectiveFintype E0 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → [Fintype α] → DecidablePred Function.Injective

instance Fintype.decidableSurjectiveFintype E0 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → [Fintype α] → [Fintype β] → DecidablePred Function.Surjective

instance Fintype.decidableBijectiveFintype E0 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → [Fintype α] → [Fintype β] → DecidablePred Function.Bijective

instance Fintype.decidableRightInverseFintype E0 #

{α : Type u_1} →
  {β : Type u_2} → [DecidableEq α] → [Fintype α] → (f : α → β) → (g : β → α) → Decidable (Function.RightInverse f g)

instance Fintype.decidableLeftInverseFintype E0 #

{α : Type u_1} →
  {β : Type u_2} → [DecidableEq β] → [Fintype β] → (f : α → β) → (g : β → α) → Decidable (Function.LeftInverse f g)

instance Fintype.instDecidableRelWCovByOfDecidableLE E0 #

{α : Type u_1} → [Fintype α] → [inst : Preorder α] → [DecidableLE α] → DecidableRel WCovBy

instance Fintype.instDecidableRelCovByOfDecidableLT E0 #

{α : Type u_1} → [Fintype α] → [inst : LT α] → [DecidableLT α] → DecidableRel CovBy

instance Fintype.subsingleton E0 #

∀ (α : Type u_3), Subsingleton (Fintype α)

instance Fintype.instFastSubsingleton E0 #

∀ (α : Type u_3), Lean.Meta.FastSubsingleton (Fintype α)

def Fintype.subtype E1 #

{α : Type u_1} → {p : α → Prop} → (s : Finset α) → (∀ (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.

def Fintype.ofFinset E1 #

{α : Type u_1} → {p : Set α} → (s : Finset α) → (∀ (x : α), x ∈ s ↔ x ∈ p) → Fintype ↑p

Construct a fintype from a finset with the same elements.

instance Bool.fintype E0 #

Fintype Bool

instance Ordering.fintype E0 #

Fintype Ordering

instance OrderDual.fintype E0 #

(α : Type u_3) → [Fintype α] → Fintype αᵒᵈ

instance OrderDual.finite E0 #

∀ (α : Type u_3) [Finite α], Finite αᵒᵈ

instance Lex.fintype E0 #

(α : Type u_3) → [Fintype α] → Fintype (Lex α)