Documentation

Mathlib.Data.Rat.Defs

Basics for the Rational Numbers #

Summary #

We define the integral domain structure on ℚ and prove basic lemmas about it. The definition of the field structure on ℚ will be done in Mathlib.Data.Rat.Basic once the Field class has been defined.

Main Definitions #

Notations #

theorem Rat.pos (a : ℚ) :
0 < a.den
@[simp]
theorem Rat.ofInt_eq_cast (n : ℤ) :
Rat.ofInt n = ↑n
@[simp]
theorem Rat.coe_int_num (n : ℤ) :
(↑n).num = n
@[simp]
theorem Rat.coe_int_den (n : ℤ) :
(↑n).den = 1
theorem Rat.mkRat_eq (n : ℤ) (d : ℕ) :
mkRat n d = Rat.divInt n ↑d
@[simp]
theorem Rat.zero_mk (d : ℕ) (h : d ≠ 0) (w : Nat.Coprime (Int.natAbs 0) d) :
Rat.mk' 0 d = 0
@[simp]
theorem Rat.num_eq_zero {q : ℚ} :
q.num = 0 ↔ q = 0
theorem Rat.num_ne_zero {q : ℚ} :
q.num ≠ 0 ↔ q ≠ 0
@[simp]
theorem Rat.divInt_eq_zero {a : ℤ} {b : ℤ} (b0 : b ≠ 0) :
Rat.divInt a b = 0 ↔ a = 0
theorem Rat.divInt_ne_zero {a : ℤ} {b : ℤ} (b0 : b ≠ 0) :
Rat.divInt a b ≠ 0 ↔ a ≠ 0
theorem Rat.normalize_eq_mk' (n : ℤ) (d : ℕ) (h : d ≠ 0) (c : Nat.gcd (Int.natAbs n) d = 1) :
theorem Rat.num_den {a : ℚ} :
Rat.divInt a.num ↑a.den = a
theorem Rat.num_den' {n : ℤ} {d : ℕ} {h : d ≠ 0} {c : Nat.Coprime (Int.natAbs n) d} :
Rat.mk' n d = Rat.divInt n ↑d
def Rat.numDenCasesOn {C : ℚ → Sort u} (a : ℚ) :
((n : ℤ) → (d : ℕ) → 0 < d → Nat.Coprime (Int.natAbs n) d → C (Rat.divInt n ↑d)) → C a

Define a (dependent) function or prove ∀ r : ℚ, p r by dealing with rational numbers of the form n /. d with 0 < d and coprime n, d.

Equations
Instances For
    def Rat.numDenCasesOn' {C : ℚ → Sort u} (a : ℚ) (H : (n : ℤ) → (d : ℕ) → d ≠ 0 → C (Rat.divInt n ↑d)) :
    C a

    Define a (dependent) function or prove ∀ r : ℚ, p r by dealing with rational numbers of the form n /. d with d ≠ 0.

    Equations
    Instances For
      theorem Rat.lift_binop_eq (f : ℚ → ℚ → ℚ) (f₁ : ℤ → ℤ → ℤ → ℤ → ℤ) (f₂ : ℤ → ℤ → ℤ → ℤ → ℤ) (fv : ∀ {n₁ : ℤ} {d₁ : ℕ} {h₁ : d₁ ≠ 0} {c₁ : Nat.Coprime (Int.natAbs n₁) d₁} {n₂ : ℤ} {d₂ : ℕ} {h₂ : d₂ ≠ 0} {c₂ : Nat.Coprime (Int.natAbs n₂) d₂}, f (Rat.mk' n₁ d₁) (Rat.mk' n₂ d₂) = Rat.divInt (f₁ n₁ (↑d₁) n₂ ↑d₂) (f₂ n₁ (↑d₁) n₂ ↑d₂)) (f0 : ∀ {n₁ d₁ n₂ d₂ : ℤ}, d₁ ≠ 0 → d₂ ≠ 0 → f₂ n₁ d₁ n₂ d₂ ≠ 0) (a : ℤ) (b : ℤ) (c : ℤ) (d : ℤ) (b0 : b ≠ 0) (d0 : d ≠ 0) (H : ∀ {n₁ d₁ n₂ d₂ : ℤ}, a * d₁ = n₁ * b → c * d₂ = n₂ * d → f₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂) :
      f (Rat.divInt a b) (Rat.divInt c d) = Rat.divInt (f₁ a b c d) (f₂ a b c d)
      @[simp]
      theorem Rat.add_def'' {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :
      Rat.divInt a b + Rat.divInt c d = Rat.divInt (a * d + c * b) (b * d)
      @[simp]
      theorem Rat.neg_def {a : ℤ} {b : ℤ} :
      @[simp]
      theorem Rat.divInt_neg_den (n : ℤ) (d : ℤ) :
      @[simp]
      theorem Rat.sub_def'' {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :
      Rat.divInt a b - Rat.divInt c d = Rat.divInt (a * d - c * b) (b * d)
      @[simp]
      theorem Rat.mul_def' {a : ℤ} {b : ℤ} {c : ℤ} {d : ℤ} (b0 : b ≠ 0) (d0 : d ≠ 0) :
      Rat.divInt a b * Rat.divInt c d = Rat.divInt (a * c) (b * d)
      Equations
      @[simp]
      theorem Rat.inv_def' {a : ℤ} {b : ℤ} :
      theorem Rat.add_zero (a : ℚ) :
      a + 0 = a
      theorem Rat.zero_add (a : ℚ) :
      0 + a = a
      theorem Rat.add_comm (a : ℚ) (b : ℚ) :
      a + b = b + a
      theorem Rat.add_assoc (a : ℚ) (b : ℚ) (c : ℚ) :
      a + b + c = a + (b + c)
      theorem Rat.add_left_neg (a : ℚ) :
      -a + a = 0
      @[simp]
      theorem Rat.divInt_one (n : ℤ) :
      Rat.divInt n 1 = ↑n
      theorem Rat.mkRat_one {n : ℤ} :
      mkRat n 1 = ↑n
      theorem Rat.mul_assoc (a : ℚ) (b : ℚ) (c : ℚ) :
      a * b * c = a * (b * c)
      theorem Rat.add_mul (a : ℚ) (b : ℚ) (c : ℚ) :
      (a + b) * c = a * c + b * c
      theorem Rat.mul_add (a : ℚ) (b : ℚ) (c : ℚ) :
      a * (b + c) = a * b + a * c
      theorem Rat.mul_inv_cancel (a : ℚ) :
      a ≠ 0 → a * a⁻¹ = 1
      theorem Rat.inv_mul_cancel (a : ℚ) (h : a ≠ 0) :
      a⁻¹ * a = 1

      At this point in the import hierarchy we have not defined the Field typeclass. Instead we'll instantiate CommRing and CommGroupWithZero at this point. The Rat.field instance and any field-specific lemmas can be found in Mathlib.Data.Rat.Basic.

      Equations
      Equations
      Equations
      Equations
      Equations
      Equations
      Equations
      Equations
      Equations
      theorem Rat.eq_iff_mul_eq_mul {p : ℚ} {q : ℚ} :
      p = q ↔ p.num * ↑q.den = q.num * ↑p.den
      @[simp]
      theorem Rat.den_neg_eq_den (q : ℚ) :
      (-q).den = q.den
      @[simp]
      theorem Rat.num_neg_eq_neg_num (q : ℚ) :
      (-q).num = -q.num
      @[simp]
      theorem Rat.num_zero :
      0.num = 0
      @[simp]
      theorem Rat.den_zero :
      0.den = 1
      theorem Rat.zero_of_num_zero {q : ℚ} (hq : q.num = 0) :
      q = 0
      theorem Rat.zero_iff_num_zero {q : ℚ} :
      q = 0 ↔ q.num = 0
      theorem Rat.num_ne_zero_of_ne_zero {q : ℚ} (h : q ≠ 0) :
      q.num ≠ 0
      @[simp]
      theorem Rat.num_one :
      1.num = 1
      @[simp]
      theorem Rat.den_one :
      1.den = 1
      theorem Rat.mk_num_ne_zero_of_ne_zero {q : ℚ} {n : ℤ} {d : ℤ} (hq : q ≠ 0) (hqnd : q = Rat.divInt n d) :
      n ≠ 0
      theorem Rat.mk_denom_ne_zero_of_ne_zero {q : ℚ} {n : ℤ} {d : ℤ} (hq : q ≠ 0) (hqnd : q = Rat.divInt n d) :
      d ≠ 0
      theorem Rat.divInt_ne_zero_of_ne_zero {n : ℤ} {d : ℤ} (h : n ≠ 0) (hd : d ≠ 0) :
      theorem Rat.mul_num_den (q : ℚ) (r : ℚ) :
      q * r = Rat.divInt (q.num * r.num) ↑(q.den * r.den)
      theorem Rat.div_num_den (q : ℚ) (r : ℚ) :
      q / r = Rat.divInt (q.num * ↑r.den) (↑q.den * r.num)
      theorem Rat.add_divInt (a : ℤ) (b : ℤ) (c : ℤ) :
      theorem Rat.divInt_eq_div (n : ℤ) (d : ℤ) :
      Rat.divInt n d = ↑n / ↑d
      theorem Rat.divInt_mul_divInt_cancel {x : ℤ} (hx : x ≠ 0) (n : ℤ) (d : ℤ) :
      theorem Rat.divInt_div_divInt_cancel_left {x : ℤ} (hx : x ≠ 0) (n : ℤ) (d : ℤ) :
      theorem Rat.divInt_div_divInt_cancel_right {x : ℤ} (hx : x ≠ 0) (n : ℤ) (d : ℤ) :
      theorem Rat.coe_int_div_eq_divInt {n : ℤ} {d : ℤ} :
      ↑n / ↑d = Rat.divInt n d
      theorem Rat.num_div_den (r : ℚ) :
      ↑r.num / ↑r.den = r
      theorem Rat.coe_int_num_of_den_eq_one {q : ℚ} (hq : q.den = 1) :
      ↑q.num = q
      theorem Rat.eq_num_of_isInt {q : ℚ} (h : Rat.isInt q = true) :
      q = ↑q.num
      theorem Rat.den_eq_one_iff (r : ℚ) :
      r.den = 1 ↔ ↑r.num = r
      instance Rat.canLift :
      CanLift ℚ ℤ Int.cast fun (q : ℚ) => q.den = 1
      Equations
      theorem Rat.coe_nat_eq_divInt (n : ℕ) :
      ↑n = Rat.divInt (↑n) 1
      @[simp]
      theorem Rat.coe_nat_num (n : ℕ) :
      (↑n).num = ↑n
      @[simp]
      theorem Rat.coe_nat_den (n : ℕ) :
      (↑n).den = 1
      theorem Rat.coe_int_inj (m : ℤ) (n : ℤ) :
      ↑m = ↑n ↔ m = n
      theorem Rat.mkRat_eq_div {n : ℤ} {d : ℕ} :
      mkRat n d = ↑n / ↑d