Analysis I, Section 3.6: Cardinality of sets #
I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.
Main constructions and results of this section:
- Cardinality of a set
- Finite and infinite sets
- Connections with Mathlib equivalents
After this section, these notions will be deprecated in favor of their Mathlib equivalents.
Tips from past users #
Users of the companion who have completed the exercises in this section are welcome to send their tips for future users in this section as PRs.
- (Add tip here)
Definition 3.6.1 (Equal cardinality)
Equations
- X.EqualCard Y = ∃ (f : X.toSubtype → Y.toSubtype), Function.Bijective f
Instances For
Proposition 3.6.4 / Exercise 3.6.1
Equations
- Chapter3.SetTheory.Set.EqualCard.inst_setoid = { r := Chapter3.SetTheory.Set.EqualCard, iseqv := ⋯ }
Definition 3.6.5
Equations
- X.has_card n = (X ≈ Chapter3.SetTheory.Set.Fin n)
Instances For
It is convenient for Lean purposes to give infinite sets the junk cardinality of zero.
Equations
- X.card = if h : X.finite then Exists.choose h else 0
Instances For
Equations
Instances For
Exercise 3.6.8
Exercise 3.6.12
Equations
- One or more equations did not get rendered due to their size.
Instances For
Exercise 3.6.12 (i), first part
Equations
Instances For
Any Fin n can be cast to Fin (n + 1). Compare to Mathlib Fin.castSucc.
Equations
Instances For
Any Fin (n + 1) except n can be cast to Fin n. Compare to Mathlib Fin.castPred.
Equations
Instances For
Now is a good time to prove this result, which will be useful for completing Exercise 3.6.12 (i).
If some x : Fin (n+1) is never equal to i, we can shrink it into Fin n by shifting all x > i down by one.
Compare to Mathlib Fin.predAbove.
Equations
- Chapter3.SetTheory.Set.Fin.predAbove i x h = if hx : ↑x < ↑i then Chapter3.SetTheory.Set.Fin_mk n ↑x ⋯ else Chapter3.SetTheory.Set.Fin_mk n (↑x - 1) ⋯
Instances For
We can expand x : Fin n into Fin (n + 1) by shifting all x ≥ i up by one.
The output is never i, so it forms an inverse to the shrinking done by predAbove.
Compare to Mathlib Fin.succAbove.
Equations
- Chapter3.SetTheory.Set.Fin.succAbove i x = if ↑x < ↑i then Chapter3.SetTheory.Set.Fin_embed n (n + 1) ⋯ x else Chapter3.SetTheory.Set.Fin_mk (n + 1) (↑x + 1) ⋯
Instances For
Exercise 3.6.12 (i), second part
Exercise 3.6.12 (ii)