Documentation

Analysis.Section_2_epilogue

Analysis I, Chapter 2 epilogue: Isomorphism with the Mathlib natural numbers #

In this (technical) epilogue, we show that the "Chapter 2" natural numbers Chapter2.Nat are isomorphic in various senses to the standard natural numbers .

After this epilogue, Chapter2.Nat will be deprecated, and we will instead use the standard natural numbers throughout. In particular, one should use the full Mathlib API for for all subsequent chapters, in lieu of the Chapter2.Nat API.

Filling the sorries here requires both the Chapter2.Nat API and the Mathlib API for the standard natural numbers . As such, they are excellent exercises to prepare you for the aforementioned transition.

In second half of this section we also give a fully axiomatic treatment of the natural numbers via the Peano axioms. The treatment in the preceding three sections was only partially axiomatic, because we used a specific construction Chapter2.Nat of the natural numbers that was an inductive type, and used that inductive type to construct a recursor. Here, we give some exercises to show how one can accomplish the same tasks directly from the Peano axioms, without knowing the specific implementation of the natural numbers.

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]
abbrev Chapter2.Nat.toNat (n : Nat) :

Converting a Chapter 2 natural number to a Mathlib natural number.

Equations
Instances For
    @[reducible, inline]

    The conversion is a bijection. Here we use the existing capability (from Section 2.1) to map the Mathlib natural numbers to the Chapter 2 natural numbers.

    Equations
    Instances For
      @[reducible, inline]
      abbrev Chapter2.Nat.map_add (n m : Nat) :
      (n + m).toNat = n.toNat + m.toNat

      The conversion preserves addition.

      Equations
      • =
      Instances For
        @[reducible, inline]
        abbrev Chapter2.Nat.map_mul (n m : Nat) :
        (n * m).toNat = n.toNat * m.toNat

        The conversion preserves multiplication.

        Equations
        • =
        Instances For
          @[reducible, inline]

          The conversion preserves order.

          Equations
          • =
          Instances For
            @[reducible, inline]
            Equations
            Instances For
              theorem Chapter2.Nat.pow_eq_pow (n m : Nat) :
              n.toNat ^ m.toNat = (n ^ m).toNat

              The conversion preserves exponentiation.

              structure PeanoAxioms :

              The Peano axioms for an abstract type Nat

              Instances For
                theorem PeanoAxioms.ext {x y : PeanoAxioms} (Nat : x.Nat = y.Nat) (zero : x.zero y.zero) (succ : x.succ y.succ) :
                x = y

                The Chapter 2 natural numbers obey the Peano axioms.

                Equations
                Instances For

                  The Mathlib natural numbers obey the Peano axioms.

                  Equations
                  Instances For
                    @[reducible, inline]

                    One can map the Mathlib natural numbers into any other structure obeying the Peano axioms.

                    Equations
                    Instances For

                      One can start the proof here with unfold Function.Injective, although it is not strictly necessary.

                      One can start the proof here with unfold Function.Surjective, although it is not strictly necessary.

                      The notion of an equivalence between two structures obeying the Peano axioms. The symbol is an alias for Mathlib's Equiv class; for instance P.Nat ≃ Q.Nat is an alias for _root_.Equiv P.Nat Q.Nat.

                      Instances
                        @[reducible, inline]
                        abbrev PeanoAxioms.Equiv.symm {P Q : PeanoAxioms} (equiv : P.Equiv Q) :
                        Q.Equiv P

                        This exercise will require application of Mathlib's API for the Equiv class. Some of this API can be invoked automatically via the simp tactic.

                        Equations
                        Instances For
                          @[reducible, inline]
                          abbrev PeanoAxioms.Equiv.trans {P Q R : PeanoAxioms} (equiv1 : P.Equiv Q) (equiv2 : Q.Equiv R) :
                          P.Equiv R

                          This exercise will require application of Mathlib's API for the Equiv class. Some of this API can be invoked automatically via the simp tactic.

                          Equations
                          Instances For
                            @[reducible, inline]

                            Useful Mathlib tools for inverting bijections include Function.surjInv and Function.invFun.

                            Equations
                            Instances For
                              @[reducible, inline]
                              noncomputable abbrev PeanoAxioms.Equiv.mk' (P Q : PeanoAxioms) :
                              P.Equiv Q

                              The task here is to establish that any two structures obeying the Peano axioms are equivalent.

                              Equations
                              Instances For
                                theorem PeanoAxioms.Equiv.uniq {P Q : PeanoAxioms} (equiv1 equiv2 : P.Equiv Q) :
                                equiv1 = equiv2

                                There is only one equivalence between any two structures obeying the Peano axioms.

                                theorem PeanoAxioms.Nat.recurse_uniq {P : PeanoAxioms} (f : P.NatP.NatP.Nat) (c : P.Nat) :
                                ∃! a : P.NatP.Nat, a P.zero = c ∀ (n : P.Nat), a (P.succ n) = f n (a n)

                                A sample result: recursion is well-defined on any structure obeying the Peano axioms