Documentation

ZFLean.Rationals

ZFC Rational Numbers #

This file defines the rational numbers in ZFC, based on the integers and using the ZFInt type.

@[reducible, inline]
abbrev ZFSet.ZFInt' :
Type (u_1 + 1)
Equations
Instances For
    @[reducible, inline]
    abbrev ZFSet.qrel (p q : ZFInt × ZFInt') :

    The equivalence relation on ℤ × ℤ⋆ that defines the rational numbers.

    Equations
    Instances For
      @[implicit_reducible]

      ℤ × ℤ⋆ equipped with qrel is a setoid.

      Equations
      @[reducible, inline]
      abbrev ZFSet.ZFRat :
      Type (u_1 + 1)

      is defined as ℤ × ℤ⋆ quotiented by qrel

      Equations
      Instances For
        @[simp]
        @[simp]
        theorem ZFSet.ZFRat.sound {x y : ZFInt × ZFInt'} (h : ZFSet.qrel x y) :
        mk x = mk y
        theorem ZFSet.ZFRat.exact {x y : ZFInt × ZFInt'} :
        mk x = mk yZFSet.qrel x y
        @[reducible, inline]
        Equations
        Instances For
          @[reducible, inline]
          Equations
          Instances For
            @[implicit_reducible]
            Equations
            @[implicit_reducible]
            Equations
            @[implicit_reducible]
            Equations
            theorem ZFSet.ZFRat.mk_eq_zero_iff {n : ZFInt} {m : ZFInt'} :
            mk (n, m) = 0 n = 0
            theorem ZFSet.ZFRat.mk_ne_zero {a : ZFInt} {b : ZFInt'} (ha : a 0) :
            mk (a, b) 0
            theorem ZFSet.ZFRat.mk_eq_one_iff {n : ZFInt} {m : ZFInt'} :
            mk (n, m) = 1 n = m
            @[reducible, inline]
            noncomputable abbrev ZFSet.ZFRat.add (n m : ZFRat) :
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[implicit_reducible]
              noncomputable instance ZFSet.ZFRat.instAdd :
              Equations
              theorem ZFSet.ZFRat.add_eq (n m : ZFInt × ZFInt') :
              mk n + mk m = mk (n.1 * m.2 + n.2 * m.1, n.2 * m.2, )
              theorem ZFSet.ZFRat.add_assoc (n m k : ZFRat) :
              n + (m + k) = n + m + k
              theorem ZFSet.ZFRat.add_comm (n m : ZFRat) :
              n + m = m + n
              theorem ZFSet.ZFRat.add_left_comm (n m k : ZFRat) :
              n + (m + k) = m + (n + k)
              theorem ZFSet.ZFRat.add_right_comm (n m k : ZFRat) :
              n + m + k = n + k + m
              @[simp]
              theorem ZFSet.ZFRat.add_zero {x : ZFRat} :
              x + 0 = x
              @[simp]
              theorem ZFSet.ZFRat.zero_add {x : ZFRat} :
              0 + x = x
              @[reducible, inline]
              Equations
              Instances For
                @[implicit_reducible]
                Equations
                @[simp]
                theorem ZFSet.ZFRat.neg_neg (n : ZFRat) :
                - -n = n
                @[simp]
                theorem ZFSet.ZFRat.neg_zero :
                -0 = 0
                theorem ZFSet.ZFRat.neg_inj {a b : ZFRat} :
                -a = -b a = b
                @[simp]
                theorem ZFSet.ZFRat.neg_eq_zero {a : ZFRat} :
                -a = 0 a = 0
                theorem ZFSet.ZFRat.neg_eq_of_add_eq_zero {a b : ZFRat} (h : a + b = 0) :
                -a = b
                theorem ZFSet.ZFRat.eq_neg_of_eq_neg {a b : ZFRat} (h : a = -b) :
                b = -a
                theorem ZFSet.ZFRat.eq_neg_comm {a b : ZFRat} :
                a = -b b = -a
                theorem ZFSet.ZFRat.neg_eq_comm {a b : ZFRat} :
                -a = b -b = a
                theorem ZFSet.ZFRat.neg_add_cancel_left (a b : ZFRat) :
                -a + (a + b) = b
                theorem ZFSet.ZFRat.add_neg_cancel_left (a b : ZFRat) :
                a + (-a + b) = b
                theorem ZFSet.ZFRat.add_left_cancel {a b c : ZFRat} (h : a + b = a + c) :
                b = c
                @[simp]
                theorem ZFSet.ZFRat.neg_add {a b : ZFRat} :
                -(a + b) = -a + -b
                @[reducible, inline]
                noncomputable abbrev ZFSet.ZFRat.sub (n m : ZFRat) :
                Equations
                Instances For
                  @[implicit_reducible]
                  noncomputable instance ZFSet.ZFRat.instSub :
                  Equations
                  theorem ZFSet.ZFRat.sub_eq (n m : ZFInt × ZFInt') :
                  mk n - mk m = mk (n.1 * m.2 - m.1 * n.2, n.2 * m.2, )
                  theorem ZFSet.ZFRat.sub_eq_add_neg {a b : ZFRat} :
                  a - b = a + -b
                  theorem ZFSet.ZFRat.add_neg_one (i : ZFRat) :
                  i + -1 = i - 1
                  @[simp]
                  theorem ZFSet.ZFRat.sub_self (a : ZFRat) :
                  a - a = 0
                  @[simp]
                  theorem ZFSet.ZFRat.sub_zero (a : ZFRat) :
                  a - 0 = a
                  @[simp]
                  theorem ZFSet.ZFRat.zero_sub (a : ZFRat) :
                  0 - a = -a
                  theorem ZFSet.ZFRat.sub_eq_zero_of_eq {a b : ZFRat} (h : a = b) :
                  a - b = 0
                  theorem ZFSet.ZFRat.eq_of_sub_eq_zero {a b : ZFRat} (h : a - b = 0) :
                  a = b
                  theorem ZFSet.ZFRat.sub_eq_zero {a b : ZFRat} :
                  a - b = 0 a = b
                  theorem ZFSet.ZFRat.sub_sub (a b c : ZFRat) :
                  a - b - c = a - (b + c)
                  theorem ZFSet.ZFRat.neg_sub (a b : ZFRat) :
                  -(a - b) = b - a
                  theorem ZFSet.ZFRat.sub_sub_self (a b : ZFRat) :
                  a - (a - b) = b
                  @[simp]
                  theorem ZFSet.ZFRat.sub_neg (a b : ZFRat) :
                  a - -b = a + b
                  @[simp]
                  theorem ZFSet.ZFRat.sub_add_cancel (a b : ZFRat) :
                  a - b + b = a
                  @[simp]
                  theorem ZFSet.ZFRat.add_sub_cancel (a b : ZFRat) :
                  a + b - b = a
                  theorem ZFSet.ZFRat.add_sub_assoc (a b c : ZFRat) :
                  a + b - c = a + (b - c)
                  theorem ZFSet.ZFRat.sub_left_cancel (a b c : ZFRat) :
                  a - c = b - ca = b
                  theorem ZFSet.ZFRat.sub_right_cancel (a b c : ZFRat) :
                  c - a = c - ba = b
                  theorem ZFSet.ZFRat.add_eq_sub_iff {a b c : ZFRat} :
                  a + b = c a = c - b
                  @[reducible, inline]
                  noncomputable abbrev ZFSet.ZFRat.nsmul :
                  ZFRatZFRat
                  Equations
                  Instances For
                    @[reducible, inline]
                    noncomputable abbrev ZFSet.ZFRat.zsmul (n : ) (x : ZFRat) :
                    Equations
                    Instances For
                      @[reducible, inline]
                      noncomputable abbrev ZFSet.ZFRat.mul (n m : ZFRat) :
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[implicit_reducible]
                        noncomputable instance ZFSet.ZFRat.instMul :
                        Equations
                        theorem ZFSet.ZFRat.mul_eq (n m : ZFInt × ZFInt') :
                        mk n * mk m = mk (n.1 * m.1, n.2 * m.2, )
                        theorem ZFSet.ZFRat.mul_comm (n m : ZFRat) :
                        n * m = m * n
                        theorem ZFSet.ZFRat.left_distrib (a b c : ZFRat) :
                        a * (b + c) = a * b + a * c
                        theorem ZFSet.ZFRat.right_distrib (a b c : ZFRat) :
                        (a + b) * c = a * c + b * c
                        @[simp]
                        theorem ZFSet.ZFRat.zero_mul (a : ZFRat) :
                        0 * a = 0
                        @[simp]
                        theorem ZFSet.ZFRat.mul_zero (a : ZFRat) :
                        a * 0 = 0
                        theorem ZFSet.ZFRat.mul_assoc (a b c : ZFRat) :
                        a * b * c = a * (b * c)
                        @[simp]
                        theorem ZFSet.ZFRat.one_mul (a : ZFRat) :
                        1 * a = a
                        @[simp]
                        theorem ZFSet.ZFRat.mul_one (a : ZFRat) :
                        a * 1 = a
                        theorem ZFSet.ZFRat.mul_eq_zero_iff {a b : ZFRat} :
                        a * b = 0 a = 0 b = 0
                        @[implicit_reducible]
                        noncomputable instance ZFSet.ZFRat.instCommRing :
                        Equations
                        • One or more equations did not get rendered due to their size.
                        @[reducible, inline]
                        abbrev ZFSet.ZFRat.ZFRat' :
                        Type (u_1 + 1)
                        Equations
                        Instances For
                          @[reducible, inline]
                          noncomputable abbrev ZFSet.ZFRat.inv :
                          Equations
                          Instances For
                            @[implicit_reducible]
                            noncomputable instance ZFSet.ZFRat.instInvZFRat' :
                            Equations
                            @[implicit_reducible]
                            noncomputable instance ZFSet.ZFRat.instInv :
                            Equations
                            theorem ZFSet.ZFRat.inv_eq {a : ZFRat} (ha : a 0) :
                            @[reducible, inline]
                            noncomputable abbrev ZFSet.ZFRat.hdiv (n : ZFRat) (m : ZFRat') :
                            Equations
                            Instances For
                              @[reducible, inline]
                              noncomputable abbrev ZFSet.ZFRat.div (n m : ZFRat) :
                              Equations
                              Instances For
                                @[implicit_reducible]
                                Equations
                                @[implicit_reducible]
                                noncomputable instance ZFSet.ZFRat.instDiv :
                                Equations
                                theorem ZFSet.ZFRat.div_eq {n m : ZFRat} (hm : m 0) :
                                n / m = n / m, hm
                                theorem ZFSet.ZFRat.div_eq_mul_inv {n m : ZFRat} (hm : m 0) :
                                n / m = n * m, hm⁻¹
                                @[simp]
                                theorem ZFSet.ZFRat.mul_inv' {a : ZFRat'} :
                                a * a⁻¹ = 1
                                @[simp]
                                theorem ZFSet.ZFRat.mul_inv {a : ZFRat} (ha : a 0) :
                                a * a⁻¹ = 1
                                @[simp]
                                theorem ZFSet.ZFRat.inv_mul' {a : ZFRat'} :
                                a⁻¹ * a = 1
                                @[simp]
                                theorem ZFSet.ZFRat.inv_mul {a : ZFRat} (ha : a 0) :
                                a⁻¹ * a = 1
                                @[implicit_reducible]
                                noncomputable instance ZFSet.ZFRat.instRatCast :
                                Equations
                                noncomputable def ZFSet.ZFRat.qsmul (k : ) (m : ZFRat) :
                                Equations
                                Instances For
                                  noncomputable def ZFSet.ZFRat.nnqsmul :
                                  Equations
                                  Instances For
                                    @[implicit_reducible]
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    @[implicit_reducible]
                                    noncomputable instance ZFSet.ZFRat.instField :
                                    Equations
                                    • One or more equations did not get rendered due to their size.

                                    A rational is positive iff numerator and denominator carry the same sign. Well-defined because for equivalent reps (a,b) ≈ (c,d) (i.e. a*d = b*c), multiplying both sides by b*d gives (a*b)*(d*d) = (b*b)*(c*d), and b*b, d*d are both positive, so a*b and c*d share a sign.

                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        @[implicit_reducible]
                                        Equations
                                        @[implicit_reducible]
                                        Equations
                                        theorem ZFSet.ZFRat.isPos_eq (n : ZFInt × ZFInt') :
                                        (mk n).isPos 0 < n.1 * n.2
                                        theorem ZFSet.ZFRat.lt_eq (n m : ZFInt × ZFInt') :
                                        mk n < mk m 0 < (m.1 * n.2 - n.1 * m.2) * (m.2 * n.2)
                                        theorem ZFSet.ZFRat.isPos_add {x y : ZFRat} (hx : x.isPos) (hy : y.isPos) :
                                        (x + y).isPos
                                        theorem ZFSet.ZFRat.isPos_mul {x y : ZFRat} (hx : x.isPos) (hy : y.isPos) :
                                        (x * y).isPos
                                        theorem ZFSet.ZFRat.lt_asymm {x y : ZFRat} (h : x < y) :
                                        ¬y < x
                                        theorem ZFSet.ZFRat.lt_trans {x y z : ZFRat} (hxy : x < y) (hyz : y < z) :
                                        x < z
                                        theorem ZFSet.ZFRat.lt_trichotomy (x y : ZFRat) :
                                        x < y x = y y < x
                                        theorem ZFSet.ZFRat.le_trans {x y z : ZFRat} (hxy : x y) (hyz : y z) :
                                        x z
                                        theorem ZFSet.ZFRat.le_antisymm {x y : ZFRat} (hxy : x y) (hyx : y x) :
                                        x = y
                                        theorem ZFSet.ZFRat.le_total (x y : ZFRat) :
                                        x y y x
                                        @[implicit_reducible]
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        theorem ZFSet.ZFRat.add_le_add_left (a b : ZFRat) (h : a b) (c : ZFRat) :
                                        a + c b + c
                                        theorem ZFSet.ZFRat.mul_lt_mul_of_pos_left {a : ZFRat} (ha : 0 < a) {b c : ZFRat} (hbc : b < c) :
                                        a * b < a * c
                                        theorem ZFSet.ZFRat.mul_lt_mul_of_pos_right {a : ZFRat} (ha : 0 < a) {b c : ZFRat} (hbc : b < c) :
                                        b * a < c * a
                                        theorem ZFSet.ZFRat.mul_le_mul_of_nonneg_left {a : ZFRat} (ha : 0 a) {b c : ZFRat} (hbc : b c) :
                                        a * b a * c
                                        theorem ZFSet.ZFRat.mul_le_mul_of_nonneg_right {a : ZFRat} (ha : 0 a) {b c : ZFRat} (hbc : b c) :
                                        b * a c * a

                                        Transfer to #

                                        ZFRat and are the same field: the ring morphism ℚ →+* ZFRat given by the RatCast instance is injective because ZFRat has characteristic zero, and surjective because every mk (a, b) is the quotient of the images of two integers. The resulting equivalence is registered as a TransferEquiv, so that the transfer tactic reads a goal about ZFRat in :

                                        example (x y : ZFRat) : x + y = y + x := by
                                          transfer ZFRat → ℚ =>
                                            rw [add_comm]
                                        

                                        The field operations, the numerals and the casts travel through the generic map_… lemmas of the transfer_simps simp set; the order relations are tagged below.

                                        noncomputable def ZFSet.ZFRat.equivRat :

                                        The canonical ring equivalence between the quotient construction ZFRat and Lean's .

                                        Equations
                                        Instances For
                                          @[simp]
                                          @[simp]
                                          @[implicit_reducible]

                                          Equivalence used by the transfer tactic to move goals between ZFRat and .

                                          Equations