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/Algebra/Field/Rat.lean once the Field class has been defined.

Main Definitions #

Notation #

theorem Rat.pos (a : ) :
0 < a.den
theorem Rat.mk'_num_den (q : ) :
{ num := q.num, den := q.den, den_nz := , reduced := } = q
@[simp]
theorem Rat.ofInt_eq_cast (n : ) :
ofInt n = n
@[simp]
theorem Rat.intCast_eq_zero {n : } :
n = 0 n = 0
@[simp]
theorem Rat.natCast_eq_zero {n : } :
n = 0 n = 0
@[simp]
theorem Rat.intCast_eq_one {n : } :
n = 1 n = 1
@[simp]
theorem Rat.natCast_eq_one {n : } :
n = 1 n = 1
theorem Rat.mkRat_eq_divInt (n : ) (d : ) :
mkRat n d = divInt n d
@[simp]
theorem Rat.mk'_zero (d : ) (h : d 0) (w : (Int.natAbs 0).Coprime d) :
{ num := 0, den := d, den_nz := h, reduced := w } = 0
theorem Rat.num_ne_zero {q : } :
q.num 0 q 0
@[simp]
theorem Rat.den_ne_zero (q : ) :
q.den 0
@[simp]
theorem Rat.divInt_eq_zero {a b : } (b0 : b 0) :
divInt a b = 0 a = 0
theorem Rat.divInt_ne_zero {a b : } (b0 : b 0) :
divInt a b 0 a 0
theorem Rat.mkRat_num_den' (a : ) :
mkRat a.num a.den = a

Alias of Rat.mkRat_self.

theorem Rat.intCast_eq_divInt (z : ) :
z = divInt z 1
theorem Rat.lift_binop_eq (f : ) (f₁ f₂ : ) (fv : ∀ {n₁ : } {d₁ : } {h₁ : d₁ 0} {c₁ : n₁.natAbs.Coprime d₁} {n₂ : } {d₂ : } {h₂ : d₂ 0} {c₂ : n₂.natAbs.Coprime d₂}, f { num := n₁, den := d₁, den_nz := h₁, reduced := c₁ } { num := n₂, den := d₂, den_nz := h₂, reduced := c₂ } = divInt (f₁ n₁ (↑d₁) n₂ d₂) (f₂ n₁ (↑d₁) n₂ d₂)) (f0 : ∀ {n₁ d₁ n₂ d₂ : }, d₁ 0d₂ 0f₂ n₁ d₁ n₂ d₂ 0) (a b c d : ) (b0 : b 0) (d0 : d 0) (H : ∀ {n₁ d₁ n₂ d₂ : }, a * d₁ = n₁ * bc * d₂ = n₂ * df₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂) :
f (divInt a b) (divInt c d) = divInt (f₁ a b c d) (f₂ a b c d)
theorem Rat.neg_def (q : ) :
-q = divInt (-q.num) q.den
@[simp]
theorem Rat.divInt_neg (n d : ) :
divInt n (-d) = divInt (-n) d
theorem Rat.mk'_mul_mk' (n₁ n₂ : ) (d₁ d₂ : ) (hd₁ : d₁ 0) (hd₂ : d₂ 0) (hnd₁ : n₁.natAbs.Coprime d₁) (hnd₂ : n₂.natAbs.Coprime d₂) (h₁₂ : n₁.natAbs.Coprime d₂) (h₂₁ : n₂.natAbs.Coprime d₁) :
{ num := n₁, den := d₁, den_nz := hd₁, reduced := hnd₁ } * { num := n₂, den := d₂, den_nz := hd₂, reduced := hnd₂ } = { num := n₁ * n₂, den := d₁ * d₂, den_nz := , reduced := }
theorem Rat.mul_eq_mkRat (q r : ) :
q * r = mkRat (q.num * r.num) (q.den * r.den)
@[deprecated Rat.divInt_eq_divInt_iff (since := "2025-08-25")]
theorem Rat.divInt_eq_divInt {d₁ d₂ n₁ n₂ : } (z₁ : d₁ 0) (z₂ : d₂ 0) :
divInt n₁ d₁ = divInt n₂ d₂ n₁ * d₂ = n₂ * d₁

Alias of Rat.divInt_eq_divInt_iff.

theorem Rat.pow_eq_mkRat (q : ) (n : ) :
q ^ n = mkRat (q.num ^ n) (q.den ^ n)
theorem Rat.pow_eq_divInt (q : ) (n : ) :
q ^ n = divInt (q.num ^ n) (q.den ^ n)
@[simp]
theorem Rat.mk'_pow (num : ) (den : ) (hd : den 0) (hdn : num.natAbs.Coprime den) (n : ) :
{ num := num, den := den, den_nz := hd, reduced := hdn } ^ n = { num := num ^ n, den := den ^ n, den_nz := , reduced := }
@[deprecated Rat.inv_divInt (since := "2025-08-25")]
theorem Rat.inv_divInt' (n d : ) :
(divInt n d)⁻¹ = divInt d n

Alias of Rat.inv_divInt.

@[simp]
theorem Rat.inv_mkRat (a : ) (b : ) :
(mkRat a b)⁻¹ = divInt (↑b) a
@[deprecated Rat.inv_def (since := "2025-08-25")]
theorem Rat.inv_def' (a : ) :
a⁻¹ = divInt (↑a.den) a.num

Alias of Rat.inv_def.

@[simp]
theorem Rat.divInt_div_divInt (n₁ d₁ n₂ d₂ : ) :
divInt n₁ d₁ / divInt n₂ d₂ = divInt (n₁ * d₂) (d₁ * n₂)
theorem Rat.div_def' (q r : ) :
q / r = divInt (q.num * r.den) (q.den * r.num)
@[simp]
theorem Rat.divInt_one (n : ) :
divInt n 1 = n

The rational numbers are a group #

Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
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
theorem Rat.num_zero :
num 0 = 0
theorem Rat.den_zero :
den 0 = 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_one :
num 1 = 1
@[simp]
theorem Rat.den_one :
den 1 = 1
theorem Rat.mk_num_ne_zero_of_ne_zero {q : } {n d : } (hq : q 0) (hqnd : q = divInt n d) :
n 0
theorem Rat.mk_denom_ne_zero_of_ne_zero {q : } {n d : } (hq : q 0) (hqnd : q = divInt n d) :
d 0
theorem Rat.divInt_ne_zero_of_ne_zero {n d : } (h : n 0) (hd : d 0) :
divInt n d 0
theorem Rat.add_divInt (a b c : ) :
divInt (a + b) c = divInt a c + divInt b c
theorem Rat.intCast_div_eq_divInt (n d : ) :
n / d = divInt n d
theorem Rat.natCast_div_eq_divInt (n d : ) :
n / d = divInt n d
theorem Rat.divInt_mul_divInt_cancel {x : } (hx : x 0) (n d : ) :
divInt n x * divInt x d = divInt n d
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 : q.isInt = 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
theorem Rat.coe_int_inj (m n : ) :
m = n m = n
def Rat.divCasesOn {C : Sort u_1} (a : ) (div : (n : ) → (d : ) → d 0n.natAbs.Coprime dC (n / d)) :
C a

A version of Rat.casesOn that uses / instead of Rat.mk'. Use as

cases r with
| div p q nonzero coprime =>
Equations
Instances For