Documentation

Mathlib.Algebra.Order.Ring.Unbundled.Rat

The rational numbers possess a linear order #

This file constructs the order on ℚ and proves various facts relating the order to ring structure on ℚ. This only uses unbundled type classes, e.g. CovariantClass, relating the order structure and algebra structure on ℚ. For the bundled LinearOrderedCommRing instance on ℚ, see Algebra.Order.Ring.Rat.

Tags #

rat, rationals, field, ℚ, numerator, denominator, num, denom, order, ordering

@[simp]
theorem Rat.mkRat_nonneg {a : ℤ} (ha : 0 ≤ a) (b : ℕ) :
0 ≤ mkRat a b
theorem Rat.ofScientific_nonneg (m : ℕ) (s : Bool) (e : ℕ) :
@[instance_reducible]
Equations
@[simp]
theorem NNRat.cast_ofScientific {K : Type u_1} [NNRatCast K] (m : ℕ) (s : Bool) (e : ℕ) :

Casting a scientific literal via ℚ≥0 is the same as casting directly.

theorem Rat.divInt_le_divInt {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
divInt a b ≤ divInt c d ↔ a * d ≤ c * b
theorem Rat.lt_iff_le_not_ge (a b : ℚ) :
a < b ↔ a ≤ b ∧ ¬b ≤ a
@[instance_reducible]
Equations
  • One or more equations did not get rendered due to their size.
theorem Rat.mkRat_nonneg_iff (a : ℤ) {b : ℕ} (hb : b ≠ 0) :
0 ≤ mkRat a b ↔ 0 ≤ a
theorem Rat.mkRat_pos_iff (a : ℤ) {b : ℕ} (hb : b ≠ 0) :
0 < mkRat a b ↔ 0 < a
theorem Rat.mkRat_pos {a : ℤ} (ha : 0 < a) {b : ℕ} (hb : b ≠ 0) :
0 < mkRat a b
theorem Rat.mkRat_nonpos_iff (a : ℤ) {b : ℕ} (hb : b ≠ 0) :
mkRat a b ≤ 0 ↔ a ≤ 0
theorem Rat.mkRat_nonpos {a : ℤ} (ha : a ≤ 0) (b : ℕ) :
mkRat a b ≤ 0
theorem Rat.mkRat_neg_iff (a : ℤ) {b : ℕ} (hb : b ≠ 0) :
mkRat a b < 0 ↔ a < 0
theorem Rat.mkRat_neg {a : ℤ} (ha : a < 0) {b : ℕ} (hb : b ≠ 0) :
mkRat a b < 0

Extra instances to short-circuit type class resolution #

These also prevent non-computable instances being used to construct these instances non-computably.

@[instance_reducible]
Equations
@[instance_reducible]
instance Rat.instInf :
Equations
@[instance_reducible]
instance Rat.instSup :
Equations
@[instance_reducible]
Equations

Miscellaneous lemmas #

@[simp]
theorem Rat.num_nonpos {a : ℚ} :
a.num ≤ 0 ↔ a ≤ 0
@[simp]
theorem Rat.num_pos {a : ℚ} :
0 < a.num ↔ 0 < a
@[simp]
theorem Rat.num_neg {a : ℚ} :
a.num < 0 ↔ a < 0
@[deprecated "use `div_lt_div_iff₀`" (since := "2026-03-20")]
theorem Rat.div_lt_div_iff_mul_lt_mul {a b c d : ℤ} (b_pos : 0 < b) (d_pos : 0 < d) :
↑a / ↑b < ↑c / ↑d ↔ a * d < c * b
theorem Rat.num_le_denom_iff {q : ℚ} :
q.num ≤ ↑q.den ↔ q ≤ 1
theorem Rat.num_lt_denom_iff {q : ℚ} :
q.num < ↑q.den ↔ q < 1
@[deprecated Rat.num_lt_denom_iff (since := "2026-02-24")]
theorem Rat.lt_one_iff_num_lt_denom {q : ℚ} :
q.num < ↑q.den ↔ q < 1

Alias of Rat.num_lt_denom_iff.

theorem Rat.abs_def (q : ℚ) :
|q| = divInt ↑q.num.natAbs ↑q.den
theorem Rat.abs_def' (q : ℚ) :
|q| = { num := |q.num|, den := q.den, den_nz := ⋯, reduced := ⋯ }
@[simp]
@[simp]
theorem Rat.den_abs_eq_den (q : ℚ) :
|q|.den = q.den