Module docstring
{"# Definition of the Finite typeclass
This file defines a typeclass Finite saying that α : Sort* is finite. A type is Finite if it
is equivalent to Fin n for some n. We also define Infinite α as a typeclass equivalent to
¬Finite α.
The Finite predicate has no computational relevance and, being Prop-valued, gets to enjoy proof
irrelevance -- it represents the mere fact that the type is finite. While the Finite class also
represents finiteness of a type, a key difference is that a Fintype instance represents finiteness
in a computable way: it gives a concrete algorithm to produce a Finset whose elements enumerate
the terms of the given type. As such, one generally relies on congruence lemmas when rewriting
expressions involving Fintype instances.
Every Fintype instance automatically gives a Finite instance, see Fintype.finite, but not vice
versa. Every Fintype instance should be computable since they are meant for computation. If it's
not possible to write a computable Fintype instance, one should prefer writing a Finite instance
instead.
Main definitions
Finite αdenotes thatαis a finite type.Infinite αdenotes thatαis an infinite type.Set.Finite : Set α → PropSet.Infinite : Set α → PropSet.toFiniteto proveSet.Finitefor aSetfrom aFiniteinstance.
Implementation notes
This file defines both the type-level Finite class and the set-level Set.Finite definition.
The definition of Finite α is not just Nonempty (Fintype α) since Fintype requires
that α : Type*, and the definition in this module allows for α : Sort*. This means
we can write the instance Finite.prop.
A finite set is defined to be a set whose coercion to a type has a Finite instance.
There are two components to finiteness constructions. The first is Fintype instances for each
construction. This gives a way to actually compute a Finset that represents the set, and these
may be accessed using set.toFinset. This gets the Finset in the correct form, since otherwise
Finset.univ : Finset s is a Finset for the subtype for s. The second component is
\"constructors\" for Set.Finite that give proofs that Fintype instances exist classically given
other Set.Finite proofs. Unlike the Fintype instances, these do not use any decidability
instances since they do not compute anything.
Tags
finite, fintype, finite sets ","### Finite sets ","### Infinite sets "}