Documentation

Analysis.Section_3_5

Analysis I, Section 3.5: Cartesian products #

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:

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.

Definition 3.5.1 (Ordered pair). One could also have used Object × Object to define OrderedPair here.

Instances For
    theorem Chapter3.OrderedPair.ext_iff {inst✝ : SetTheory} {x y : OrderedPair} :
    x = y x.fst = y.fst x.snd = y.snd
    theorem Chapter3.OrderedPair.ext {inst✝ : SetTheory} {x y : OrderedPair} (fst : x.fst = y.fst) (snd : x.snd = y.snd) :
    x = y
    @[simp]
    theorem Chapter3.OrderedPair.eq [SetTheory] (x y x' y' : Object) :
    { fst := x, snd := y } = { fst := x', snd := y' } x = x' y = y'

    Definition 3.5.1 (Ordered pair)

    Helper lemma for Exercise 3.5.1

    Exercise 3.5.1, first part

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[reducible, inline]

      A technical operation, turning a object x and a set Y to a set {x} × Y, needed to define the full Cartesian product

      Equations
      Instances For
        @[simp]
        theorem Chapter3.SetTheory.Set.mem_slice [SetTheory] (x z : Object) (Y : Set) :
        z slice x Y ∃ (y : Y.toSubtype), z = OrderedPair.toObject { fst := x, snd := y }
        @[reducible, inline]

        Definition 3.5.4 (Cartesian product)

        Equations
        Instances For

          This instance enables the ×ˢ notation for Cartesian product.

          Equations
          @[simp]
          theorem Chapter3.SetTheory.Set.mem_cartesian [SetTheory] (z : Object) (X Y : Set) :
          z X ×ˢ Y ∃ (x : X.toSubtype) (y : Y.toSubtype), z = OrderedPair.toObject { fst := x, snd := y }
          @[reducible, inline]
          noncomputable abbrev Chapter3.SetTheory.Set.fst [SetTheory] {X Y : Set} (z : (X ×ˢ Y).toSubtype) :
          Equations
          Instances For
            @[reducible, inline]
            noncomputable abbrev Chapter3.SetTheory.Set.snd [SetTheory] {X Y : Set} (z : (X ×ˢ Y).toSubtype) :
            Equations
            Instances For
              theorem Chapter3.SetTheory.Set.pair_eq_fst_snd [SetTheory] {X Y : Set} (z : (X ×ˢ Y).toSubtype) :
              z = OrderedPair.toObject { fst := (fst z), snd := (snd z) }

              This equips an OrderedPair with proofs that xX and y ∈ Y.

              Equations
              Instances For
                @[reducible, inline]
                noncomputable abbrev Chapter3.SetTheory.Set.prod_equiv_prod [SetTheory] (X Y : Set) :
                {x : Object | x X ×ˢ Y} ↑({x : Object | x X} ×ˢ {x : Object | x Y})

                Connections with the Mathlib set product, which consists of Lean pairs like (x, y) equipped with a proof that x is in the left set, and y is in the right set. Lean pairs like (x, y) are similar to our OrderedPair, but more general.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[reducible, inline]

                  Example 3.5.5 / Exercise 3.6.5. There is a bijection between X ×ˢ Y and Y ×ˢ X.

                  Equations
                  • X.prod_commutator Y = { toFun := sorry, invFun := sorry, left_inv := , right_inv := }
                  Instances For
                    @[reducible, inline]
                    noncomputable abbrev Chapter3.SetTheory.Set.curry_equiv [SetTheory] {X Y Z : Set} :
                    (X.toSubtypeY.toSubtypeZ.toSubtype) ((X ×ˢ Y).toSubtypeZ.toSubtype)

                    Example 3.5.5. A function of two variables can be thought of as a function of a pair.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[reducible, inline]
                      abbrev Chapter3.SetTheory.Set.tuple [SetTheory] {I : Set} {X : I.toSubtypeSet} (x : (i : I.toSubtype) → (X i).toSubtype) :

                      Definition 3.5.6. The indexing set I plays the role of { i : 1 ≤ i ≤ n } in the text. See Exercise 3.5.10 below for some connections betweeen this concept and the preceding notion of Cartesian product and ordered pair.

                      Equations
                      Instances For
                        @[reducible, inline]

                        Definition 3.5.6

                        Equations
                        Instances For
                          theorem Chapter3.SetTheory.Set.mem_iProd [SetTheory] {I : Set} {X : I.toSubtypeSet} (t : Object) :
                          t iProd X ∃ (x : (i : I.toSubtype) → (X i).toSubtype), t = tuple x

                          Definition 3.5.6

                          theorem Chapter3.SetTheory.Set.tuple_mem_iProd [SetTheory] {I : Set} {X : I.toSubtypeSet} (x : (i : I.toSubtype) → (X i).toSubtype) :
                          @[simp]
                          theorem Chapter3.SetTheory.Set.tuple_inj [SetTheory] {I : Set} {X : I.toSubtypeSet} (x y : (i : I.toSubtype) → (X i).toSubtype) :
                          tuple x = tuple y x = y
                          @[reducible, inline]
                          noncomputable abbrev Chapter3.SetTheory.Set.prod_associator [SetTheory] (X Y Z : Set) :

                          Example 3.5.8. There is a bijection between (X ×ˢ Y) ×ˢ Z and X ×ˢ (Y ×ˢ Z).

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            @[reducible, inline]

                            Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be defined non-computably, but would be happy to learn of counterexamples.

                            Equations
                            Instances For
                              @[reducible, inline]

                              Example 3.5.10

                              Equations
                              Instances For
                                @[reducible, inline]
                                noncomputable abbrev Chapter3.SetTheory.Set.iProd_of_const_equiv [SetTheory] (I X : Set) :
                                (iProd fun (x : I.toSubtype) => X).toSubtype (I.toSubtypeX.toSubtype)

                                Example 3.5.10

                                Equations
                                Instances For
                                  @[reducible, inline]
                                  noncomputable abbrev Chapter3.SetTheory.Set.iProd_equiv_prod [SetTheory] (X : {0, 1}.toSubtypeSet) :
                                  (iProd X).toSubtype (X 0, ×ˢ X 1, ).toSubtype

                                  Example 3.5.10

                                  Equations
                                  Instances For
                                    @[reducible, inline]
                                    noncomputable abbrev Chapter3.SetTheory.Set.iProd_equiv_prod_triple [SetTheory] (X : {0, 1, 2}.toSubtypeSet) :
                                    (iProd X).toSubtype (X 0, ×ˢ X 1, ×ˢ X 2, ).toSubtype

                                    Example 3.5.10

                                    Equations
                                    Instances For
                                      @[reducible, inline]
                                      noncomputable abbrev Chapter3.SetTheory.Set.iProd_equiv_pi [SetTheory] (I : Set) (X : I.toSubtypeSet) :
                                      (iProd X).toSubtype (Set.univ.pi fun (i : I.toSubtype) => {x : Object | x X i})

                                      Connections with Mathlib's Set.pi

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        @[reducible, inline]

                                        Here we set up some an analogue of Mathlib Fin n types within the Chapter 3 Set Theory, with rudimentary API.

                                        Equations
                                        Instances For
                                          theorem Chapter3.SetTheory.Set.mem_Fin [SetTheory] (n : ) (x : Object) :
                                          x Fin n m < n, x = m
                                          @[reducible, inline]
                                          abbrev Chapter3.SetTheory.Set.Fin_mk [SetTheory] (n m : ) (h : m < n) :
                                          Equations
                                          Instances For
                                            theorem Chapter3.SetTheory.Set.mem_Fin' [SetTheory] {n : } (x : (Fin n).toSubtype) :
                                            ∃ (m : ) (h : m < n), x = Fin_mk n m h
                                            @[reducible, inline]
                                            noncomputable abbrev Chapter3.SetTheory.Set.Fin.toNat [SetTheory] {n : } (i : (Fin n).toSubtype) :
                                            Equations
                                            Instances For
                                              theorem Chapter3.SetTheory.Set.Fin.toNat_spec [SetTheory] {n : } (i : (Fin n).toSubtype) :
                                              ∃ (h : i < n), i = Fin_mk n (↑i) h
                                              @[simp]
                                              theorem Chapter3.SetTheory.Set.Fin.coe_toNat [SetTheory] {n : } (i : (Fin n).toSubtype) :
                                              i = i
                                              @[simp]
                                              theorem Chapter3.SetTheory.Set.Fin.coe_inj [SetTheory] {n : } {i j : (Fin n).toSubtype} :
                                              i = j i = j
                                              @[simp]
                                              theorem Chapter3.SetTheory.Set.Fin.coe_eq_iff [SetTheory] {n : } (i : (Fin n).toSubtype) {j : } :
                                              i = j i = j
                                              @[simp]
                                              theorem Chapter3.SetTheory.Set.Fin.coe_eq_iff' [SetTheory] {n m : } (i : (Fin n).toSubtype) (hi : i Fin m) :
                                              i, hi = i
                                              @[simp]
                                              theorem Chapter3.SetTheory.Set.Fin.toNat_mk [SetTheory] {n : } (m : ) (h : m < n) :
                                              (Fin_mk n m h) = m
                                              @[reducible, inline]
                                              abbrev Chapter3.SetTheory.Set.Fin_embed [SetTheory] (n N : ) (h : n N) (i : (Fin n).toSubtype) :
                                              Equations
                                              Instances For
                                                @[reducible, inline]

                                                Connections with Mathlib's Fin n

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  theorem Chapter3.SetTheory.Set.finite_choice [SetTheory] {n : } {X : (Fin n).toSubtypeSet} (h : ∀ (i : (Fin n).toSubtype), X i ) :

                                                  Lemma 3.5.11 (finite choice)

                                                  @[reducible, inline]

                                                  Exercise 3.5.1, second part (requires axiom of regularity)

                                                  Equations
                                                  Instances For
                                                    structure Chapter3.SetTheory.Set.Tuple [SetTheory] (n : ) :
                                                    Type (max u_1 u_2)

                                                    An alternate definition of a tuple, used in Exercise 3.5.2

                                                    Instances For
                                                      theorem Chapter3.SetTheory.Set.Tuple.ext [SetTheory] {n : } {t t' : Tuple n} (hX : t.X = t'.X) (hx : ∀ (n_1 : (Fin n).toSubtype), (t.x n_1) = (t'.x n_1)) :
                                                      t = t'

                                                      Custom extensionality lemma for Exercise 3.5.2. Placing @[ext] on the structure would generate a lemma requiring proof of t.x = t'.x, but these functions have different types when t.X ≠ t'.X. This lemma handles that part.

                                                      theorem Chapter3.SetTheory.Set.Tuple.ext_iff [SetTheory] {n : } {t t' : Tuple n} :
                                                      t = t' t.X = t'.X ∀ (n_1 : (Fin n).toSubtype), (t.x n_1) = (t'.x n_1)
                                                      theorem Chapter3.SetTheory.Set.Tuple.eq [SetTheory] {n : } (t t' : Tuple n) :
                                                      t = t' ∀ (n_1 : (Fin n).toSubtype), (t.x n_1) = (t'.x n_1)

                                                      Exercise 3.5.2

                                                      @[reducible, inline]
                                                      noncomputable abbrev Chapter3.SetTheory.Set.iProd_equiv_tuples [SetTheory] (n : ) (X : (Fin n).toSubtypeSet) :
                                                      (iProd X).toSubtype { t : Tuple n // ∀ (i : (Fin n).toSubtype), (t.x i) X i }
                                                      Equations
                                                      Instances For

                                                        Exercise 3.5.3. The spirit here is to avoid direct rewrites (which make all of these claims trivial), and instead use OrderedPair.eq or SetTheory.Set.tuple_inj

                                                        theorem Chapter3.OrderedPair.trans [SetTheory] {p q r : OrderedPair} (hpq : p = q) (hqr : q = r) :
                                                        p = r
                                                        theorem Chapter3.SetTheory.Set.tuple_refl [SetTheory] {I : Set} {X : I.toSubtypeSet} (a : (i : I.toSubtype) → (X i).toSubtype) :
                                                        theorem Chapter3.SetTheory.Set.tuple_symm [SetTheory] {I : Set} {X : I.toSubtypeSet} (a b : (i : I.toSubtype) → (X i).toSubtype) :
                                                        theorem Chapter3.SetTheory.Set.tuple_trans [SetTheory] {I : Set} {X : I.toSubtypeSet} {a b c : (i : I.toSubtype) → (X i).toSubtype} (hab : tuple a = tuple b) (hbc : tuple b = tuple c) :
                                                        theorem Chapter3.SetTheory.Set.prod_union [SetTheory] (A B C : Set) :
                                                        A ×ˢ (B C) = A ×ˢ B A ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.prod_inter [SetTheory] (A B C : Set) :
                                                        A ×ˢ (B C) = A ×ˢ B A ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.prod_diff [SetTheory] (A B C : Set) :
                                                        A ×ˢ (B \ C) = A ×ˢ B \ A ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.union_prod [SetTheory] (A B C : Set) :
                                                        (A B) ×ˢ C = A ×ˢ C B ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.inter_prod [SetTheory] (A B C : Set) :
                                                        (A B) ×ˢ C = A ×ˢ C B ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.diff_prod [SetTheory] (A B C : Set) :
                                                        (A \ B) ×ˢ C = A ×ˢ C \ B ×ˢ C

                                                        Exercise 3.5.4

                                                        theorem Chapter3.SetTheory.Set.inter_of_prod [SetTheory] (A B C D : Set) :
                                                        A ×ˢ B C ×ˢ D = (A C) ×ˢ (B D)

                                                        Exercise 3.5.5

                                                        def Chapter3.SetTheory.Set.union_of_prod [SetTheory] :
                                                        Decidable (∀ (A B C D : Set), A ×ˢ B C ×ˢ D = (A C) ×ˢ (B D))
                                                        Equations
                                                        Instances For
                                                          def Chapter3.SetTheory.Set.diff_of_prod [SetTheory] :
                                                          Decidable (∀ (A B C D : Set), A ×ˢ B \ C ×ˢ D = (A \ C) ×ˢ (B \ D))
                                                          Equations
                                                          Instances For
                                                            theorem Chapter3.SetTheory.Set.prod_subset_prod [SetTheory] {A B C D : Set} (hA : A ) (hB : B ) (hC : C ) (hD : D ) :
                                                            A ×ˢ B C ×ˢ D A C B D

                                                            Exercise 3.5.6.

                                                            theorem Chapter3.SetTheory.Set.direct_sum [SetTheory] {X Y Z : Set} (f : Z.toSubtypeX.toSubtype) (g : Z.toSubtypeY.toSubtype) :
                                                            ∃! h : Z.toSubtype(X ×ˢ Y).toSubtype, fst h = f snd h = g

                                                            Exercise 3.5.7

                                                            @[simp]
                                                            theorem Chapter3.SetTheory.Set.iProd_empty_iff [SetTheory] {n : } {X : (Fin n).toSubtypeSet} :
                                                            iProd X = ∃ (i : (Fin n).toSubtype), X i =

                                                            Exercise 3.5.8

                                                            theorem Chapter3.SetTheory.Set.iUnion_inter_iUnion [SetTheory] {I J : Set} (A : I.toSubtypeSet) (B : J.toSubtypeSet) :
                                                            I.iUnion A J.iUnion B = (I ×ˢ J).iUnion fun (p : (I ×ˢ J).toSubtype) => A (fst p) B (snd p)

                                                            Exercise 3.5.9

                                                            @[reducible, inline]
                                                            Equations
                                                            Instances For
                                                              theorem Chapter3.SetTheory.Set.graph_inj [SetTheory] {X Y : Set} (f f' : X.toSubtypeY.toSubtype) :
                                                              graph f = graph f' f = f'

                                                              Exercise 3.5.10

                                                              theorem Chapter3.SetTheory.Set.is_graph [SetTheory] {X Y G : Set} (hG : G X ×ˢ Y) (hvert : ∀ (x : X.toSubtype), ∃! y : Y.toSubtype, OrderedPair.toObject { fst := x, snd := y } G) :
                                                              theorem Chapter3.SetTheory.Set.powerset_axiom' [SetTheory] (X Y : Set) :
                                                              ∃! S : Set, ∀ (F : Object), F S ∃ (f : Y.toSubtypeX.toSubtype), f = F

                                                              Exercise 3.5.11. This trivially follows from SetTheory.Set.powerset_axiom, but the exercise is to derive it from SetTheory.Set.exists_powerset instead.

                                                              theorem Chapter3.SetTheory.Set.recursion [SetTheory] (X : Set) (f : nat.toSubtypeX.toSubtypeX.toSubtype) (c : X.toSubtype) :
                                                              ∃! a : nat.toSubtypeX.toSubtype, a 0 = c ∀ (n : ), a ↑(n + 1) = f (↑n) (a n)

                                                              Exercise 3.5.12, with errata from web site incorporated

                                                              theorem Chapter3.SetTheory.Set.nat_unique [SetTheory] (nat' : Set) (zero : nat'.toSubtype) (succ : nat'.toSubtypenat'.toSubtype) (succ_ne : ∀ (n : nat'.toSubtype), succ n zero) (succ_of_ne : ∀ (n m : nat'.toSubtype), n msucc n succ m) (ind : ∀ (P : nat'.toSubtypeProp), P zero(∀ (n : nat'.toSubtype), P nP (succ n))∀ (n : nat'.toSubtype), P n) :
                                                              ∃! f : nat.toSubtypenat'.toSubtype, Function.Bijective f f 0 = zero ∀ (n : nat.toSubtype) (n' : nat'.toSubtype), f n = n' f ↑(nat_equiv.symm n + 1) = succ n'

                                                              Exercise 3.5.13