Cardinality of finite types #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 set_theory.cardinal.finite
module.
There is (noncomputably) an equivalence between a finite type α
and fin (nat.card α)
.
Equations
- finite.equiv_fin α = _.mpr (nonempty.some _)
Similar to finite.equiv_fin
but with control over the term used for the cardinality.
Equations
- finite.equiv_fin_of_card_eq h = eq.rec (finite.equiv_fin α) h
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.