Cardinality of finite types #
The cardinality of a finite type α
is given by Nat.card α
. This function has
the "junk value" of 0
for infinite types, but to ensure the function has valid
output, one just needs to know that it's possible to produce a Finite
instance
for the type. (Note: we could have defined a Finite.card
that required you to
supply a Finite
instance, but (a) the function would be noncomputable
anyway
so there is no need to supply the instance and (b) the function would have a more
complicated dependent type that easily leads to "motive not type correct" errors.)
Implementation notes #
Theorems about Nat.card
are sometimes incidentally true for both finite and infinite
types. If removing a finiteness constraint results in no loss in legibility, we remove
it. We generally put such theorems into the SetTheory.Cardinal.Finite
module.
There is (noncomputably) an equivalence between a finite type α
and Fin (Nat.card α)
.
Equations
- Finite.equivFin α = let_fun this := ⋯.some; ⋯.mpr this
Instances For
Similar to Finite.equivFin
but with control over the term used for the cardinality.
Equations
- Finite.equivFinOfCardEq h = h ▸ Finite.equivFin α
Instances For
If f
is injective, then Nat.card α ≤ Nat.card β
. We must also assume
Nat.card β = 0 → Nat.card α = 0
since Nat.card
is defined to be 0
for infinite types.
If f
is surjective, then Nat.card β ≤ Nat.card α
. We must also assume
Nat.card α = 0 → Nat.card β = 0
since Nat.card
is defined to be 0
for infinite types.
NB: Nat.card
is defined to be 0
for infinite types.
Alias of PartENat.card_eq_coe_natCard
.