Documentation

Analysis.Section_3_6

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:

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.

@[reducible, inline]

Definition 3.6.1 (Equal cardinality)

Equations
Instances For
    @[reducible, inline]

    Definition 3.6.5

    Equations
    Instances For
      theorem Chapter3.SetTheory.Set.Example_3_6_7b [SetTheory] {a b c d : Object} (hab : a b) (hac : a c) (had : a d) (hbc : b c) (hbd : b d) (hcd : c d) :
      {a, b, c, d}.has_card 4
      theorem Chapter3.SetTheory.Set.pos_card_nonempty [SetTheory] {n : } (h : n 1) {X : Set} (hX : X.has_card n) :

      Lemma 3.6.9

      theorem Chapter3.SetTheory.Set.card_erase [SetTheory] {n : } (h : n 1) {X : Set} (hX : X.has_card n) (x : X.toSubtype) :
      (X \ {x}).has_card (n - 1)

      Lemma 3.6.9

      theorem Chapter3.SetTheory.Set.card_uniq [SetTheory] {X : Set} {n m : } (h1 : X.has_card n) (h2 : X.has_card m) :
      n = m

      Proposition 3.6.8 (Uniqueness of cardinality)

      @[reducible, inline]
      Equations
      Instances For
        @[reducible, inline]
        Equations
        Instances For
          theorem Chapter3.SetTheory.Set.bounded_on_finite [SetTheory] {n : } (f : (Fin n).toSubtypenat.toSubtype) :
          ∃ (M : ), ∀ (i : (Fin n).toSubtype), nat_equiv.symm (f i) M

          Exercise 3.6.3, phrased using Mathlib natural numbers

          noncomputable def Chapter3.SetTheory.Set.card [SetTheory] (X : Set) :

          It is convenient for Lean purposes to give infinite sets the junk cardinality of zero.

          Equations
          Instances For
            theorem Chapter3.SetTheory.Set.card_to_has_card [SetTheory] {X : Set} {n : } (hn : n 0) :
            X.card = nX.has_card n
            theorem Chapter3.SetTheory.Set.card_insert [SetTheory] {X : Set} (hX : X.finite) {x : Object} (hx : xX) :
            (X {x}).finite (X {x}).card = X.card + 1

            Proposition 3.6.14 (a) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_union [SetTheory] {X Y : Set} (hX : X.finite) (hY : Y.finite) :
            (X Y).finite (X Y).card X.card + Y.card

            Proposition 3.6.14 (b) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_union_disjoint [SetTheory] {X Y : Set} (hX : X.finite) (hY : Y.finite) (hdisj : Disjoint X Y) :
            (X Y).card = X.card + Y.card

            Proposition 3.6.14 (b) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_subset [SetTheory] {X Y : Set} (hX : X.finite) (hY : Y X) :

            Proposition 3.6.14 (c) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_ssubset [SetTheory] {X Y : Set} (hX : X.finite) (hY : Y X) :
            Y.card < X.card

            Proposition 3.6.14 (c) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_image [SetTheory] {X Y : Set} (hX : X.finite) (f : X.toSubtypeY.toSubtype) :
            (image f X).finite (image f X).card X.card

            Proposition 3.6.14 (d) / Exercise 3.6.4

            Proposition 3.6.14 (d) / Exercise 3.6.4

            theorem Chapter3.SetTheory.Set.card_prod [SetTheory] {X Y : Set} (hX : X.finite) (hY : Y.finite) :
            (X ×ˢ Y).finite (X ×ˢ Y).card = X.card * Y.card

            Proposition 3.6.14 (e) / Exercise 3.6.4

            Equations
            Instances For
              theorem Chapter3.SetTheory.Set.card_pow [SetTheory] {X Y : Set} (hY : Y.finite) (hX : X.finite) :
              (Y ^ X).finite (Y ^ X).card = Y.card ^ X.card

              Proposition 3.6.14 (f) / Exercise 3.6.4

              Exercise 3.6.5. You might find SetTheory.Set.prod_commutator useful.

              @[reducible, inline]
              noncomputable abbrev Chapter3.SetTheory.Set.pow_fun_equiv' [SetTheory] (A B : Set) :
              Equations
              Instances For

                Exercise 3.6.6. You may find SetTheory.Set.curry_equiv useful.

                theorem Chapter3.SetTheory.Set.pow_pow_eq_pow_mul [SetTheory] (a b c : ) :
                (a ^ b) ^ c = a ^ (b * c)

                Exercise 3.6.7

                theorem Chapter3.SetTheory.Set.card_union_add_card_inter [SetTheory] {A B : Set} (hA : A.finite) (hB : B.finite) :
                A.card + B.card = (A B).card + (A B).card

                Exercise 3.6.9

                theorem Chapter3.SetTheory.Set.pigeonhole_principle [SetTheory] {n : } {A : (Fin n).toSubtypeSet} (hA : ∀ (i : (Fin n).toSubtype), (A i).finite) (hAcard : ((Fin n).iUnion A).card > n) :
                ∃ (i : (Fin n).toSubtype), (A i).card 2

                Exercise 3.6.10

                theorem Chapter3.SetTheory.Set.two_to_two_iff [SetTheory] {X Y : Set} (f : X.toSubtypeY.toSubtype) :
                Function.Injective f SX, S.card = 2(image f S).card = 2

                Exercise 3.6.11

                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

                  This connects our concept of a permutation with Mathlib's Equiv between Fin n and Fin n.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Any Fin n can be cast to Fin (n + 1). Compare to Mathlib Fin.castSucc.

                    Equations
                    Instances For
                      noncomputable def Chapter3.SetTheory.Set.Fin.castPred [SetTheory] {n : } (x : (Fin (n + 1)).toSubtype) (h : x n) :

                      Any Fin (n + 1) except n can be cast to Fin n. Compare to Mathlib Fin.castPred.

                      Equations
                      Instances For
                        @[simp]
                        theorem Chapter3.SetTheory.Set.Fin.castSucc_castPred [SetTheory] {n : } (x : (Fin (n + 1)).toSubtype) (h : x n) :

                        Any natural n can be cast to Fin (n + 1). Compare to Mathlib Fin.last.

                        Equations
                        Instances For
                          theorem Chapter3.SetTheory.Set.card_iUnion_card_disjoint [SetTheory] {n m : } {S : (Fin n).toSubtypeSet} (hSc : ∀ (i : (Fin n).toSubtype), (S i).has_card m) (hSd : Pairwise fun (i j : (Fin n).toSubtype) => Disjoint (S i) (S j)) :
                          ((Fin n).iUnion S).finite ((Fin n).iUnion S).card = n * m

                          Now is a good time to prove this result, which will be useful for completing Exercise 3.6.12 (i).

                          noncomputable def Chapter3.SetTheory.Set.Fin.predAbove [SetTheory] {n : } (i x : (Fin (n + 1)).toSubtype) (h : x 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
                          Instances For
                            noncomputable def Chapter3.SetTheory.Set.Fin.succAbove [SetTheory] {n : } (i : (Fin (n + 1)).toSubtype) (x : (Fin n).toSubtype) :
                            (Fin (n + 1)).toSubtype

                            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
                            Instances For
                              @[simp]
                              @[simp]
                              theorem Chapter3.SetTheory.Set.Fin.succAbove_predAbove [SetTheory] {n : } (i x : (Fin (n + 1)).toSubtype) (h : x i) :
                              succAbove i (predAbove i x h) = x
                              @[simp]

                              Exercise 3.6.12 (i), second part

                              Connections with Mathlib's Set.ncard