Documentation

Analysis.Appendix_B_1

Аналіз I, Додаток B.1: Десяткове подання натуральних чисел #

Реалізація десяткового подання натуральних чисел з Mathlib.

Це відокремлено від способу, у який десяткові числівники вже представлені в Mathlib через типоклас OfNat.

Визначення 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

        Визначення 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) :

            Трохи незграбний спосіб створення десяткових чисел.

            Equations
            Instances For

              Ми індексуємо цифри в десятковому числі зліва направо, а не справа наліво, тому тут потрібне обертання.

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

                Зауваження B.1.3

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

                Операція, неявно присутня в доведенні Теореми B.1.4:

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

                  Теорема B.1.4 (Унікальність та існування десяткових подань)

                  @[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

                        Вправа B.1.1

                        Визначте це число так, щоб воно задовольняло дві наступні теореми.

                        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