Documentation

Analysis.Appendix_B_1

Analysis I, Appendix B.1: The decimal representation of natural numbers #

Am implementation of the decimal representation of Mathlib's natural numbers .

This is separate from the way decimal numerals are already represenated in Mathlib via the OfNat typeclass.

Definition B.1.1

Equations
Instances For
    @[reducible, inline]
    Equations
    • d = d
    Instances For
      theorem AppendixB.Digit.lt (d : Digit) :
      d < 10
      @[reducible, inline]
      abbrev AppendixB.Digit.mk {n : } (h : n < 10) :
      Equations
      Instances For
        @[simp]
        theorem AppendixB.Digit.toNat_mk {n : } (h : n < 10) :
        (mk h) = n
        @[simp]
        theorem AppendixB.Digit.inj (d d' : Digit) :
        d = d' d = d'
        theorem AppendixB.Digit.mk_eq_iff (d : Digit) {n : } (h : n < 10) :
        d = mk h d = n
        theorem AppendixB.Digit.eq (n : Digit) :
        n = 0 n = 1 n = 2 n = 3 n = 4 n = 5 n = 6 n = 7 n = 8 n = 9

        Definition B.1.2

        Instances For
          theorem AppendixB.PosintDecimal.congr {p q : PosintDecimal} (h : p.digits.length = q.digits.length) (h' : ∀ (n : ) (h₁ : n < p.digits.length) (h₂ : n < q.digits.length), p.digits.get n, h₁ = q.digits.get n, h₂) :
          p = q
          @[reducible, inline]
          Equations
          Instances For
            def AppendixB.PosintDecimal.mk' (head : Digit) (tail : List Digit) (h : head 0) :

            A slightly clunky way of creating decimals.

            Equations
            Instances For

              We are indexing digits in a decimal from left to right rather than from right to left, thus necessitating a reversal here.

              Equations
              Instances For
                @[simp]
                theorem AppendixB.PosintDecimal.ten_eq_ten :
                (mk' 1 [0] ) = 10

                Remark B.1.3

                theorem AppendixB.PosintDecimal.digit_eq {d : Digit} (h : d 0) :
                (mk' d [] h) = d
                @[reducible, inline]

                An operation implicit in the proof of Theorem B.1.4:

                Equations
                Instances For
                  @[simp]
                  theorem AppendixB.PosintDecimal.append_toNat (p : PosintDecimal) (d : Digit) :
                  (p.append d) = d + 10 * p

                  Theorem B.1.4 (Uniqueness and existence of decimal representations)

                  @[simp]
                  theorem AppendixB.PosintDecimal.coe_inj (p q : PosintDecimal) :
                  p = q p = q
                  @[reducible, inline]
                  Equations
                  Instances For
                    @[reducible, inline]
                    Equations
                    Instances For
                      theorem AppendixB.PosintDecimal.carry_succ (p q : PosintDecimal) (i : ) :
                      p.carry q (i + 1) = if (p.digit i) + (q.digit i) + p.carry q i < 10 then 0 else 1
                      @[reducible, inline]
                      Equations
                      Instances For

                        Exercise B.1.1

                        Define this number such that it satisfies the two following theorems.

                        Equations
                        Instances For
                          theorem AppendixB.PosintDecimal.sum_eq (p q : PosintDecimal) (i : ) :
                          ((p.longAddition q).digit i) = p.sum_digit q i (p.longAddition q) = p + q