mathlib documentation

data.rat.order

Order for Rational Numbers #

Summary #

We define the order on ℚ, prove that ℚ is a discrete, linearly ordered field, and define functions such as abs and sqrt that depend on this order.

Notations #

Tags #

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

@[protected]
def rat.nonneg (r : ℚ) :
Prop

A rational number is called nonnegative if its numerator is nonnegative.

Equations
@[simp]
theorem rat.mk_nonneg (a : ℤ) {b : ℤ} (h : 0 < b) :
(a /. b).nonneg ↔ 0 ≤ a
@[protected]
theorem rat.nonneg_add {a b : ℚ} :
a.nonneg → b.nonneg → (a + b).nonneg
@[protected]
theorem rat.nonneg_mul {a b : ℚ} :
a.nonneg → b.nonneg → (a * b).nonneg
@[protected]
theorem rat.nonneg_antisymm {a : ℚ} :
a.nonneg → (-a).nonneg → a = 0
@[protected]
theorem rat.nonneg_total (a : ℚ) :
@[protected, instance]
Equations
@[protected]
def rat.le (a b : ℚ) :
Prop

Relation a ≤ b on ℚ defined as a ≤ b ↔ rat.nonneg (b - a). Use a ≤ b instead of rat.le a b.

Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected]
theorem rat.le_def {a b c d : ℤ} (b0 : 0 < b) (d0 : 0 < d) :
a /. b ≤ c /. d ↔ a * d ≤ c * b
@[protected]
theorem rat.le_refl (a : ℚ) :
a ≤ a
@[protected]
theorem rat.le_total (a b : ℚ) :
a ≤ b ∨ b ≤ a
@[protected]
theorem rat.le_antisymm {a b : ℚ} (hab : a ≤ b) (hba : b ≤ a) :
a = b
@[protected]
theorem rat.le_trans {a b c : ℚ} (hab : a ≤ b) (hbc : b ≤ c) :
a ≤ c
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected]
theorem rat.le_def' {p q : ℚ} :
p ≤ q ↔ (p.num) * ↑(q.denom) ≤ (q.num) * ↑(p.denom)
@[protected]
theorem rat.lt_def {p q : ℚ} :
p < q ↔ (p.num) * ↑(q.denom) < (q.num) * ↑(p.denom)
theorem rat.nonneg_iff_zero_le {a : ℚ} :
a.nonneg ↔ 0 ≤ a
theorem rat.num_nonneg_iff_zero_le {a : ℚ} :
0 ≤ a.num ↔ 0 ≤ a
@[protected]
theorem rat.add_le_add_left {a b c : ℚ} :
c + a ≤ c + b ↔ a ≤ b
@[protected]
theorem rat.mul_nonneg {a b : ℚ} (ha : 0 ≤ a) (hb : 0 ≤ b) :
0 ≤ a * b
@[protected, instance]
Equations
theorem rat.num_pos_iff_pos {a : ℚ} :
0 < a.num ↔ 0 < a
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.lt_one_iff_num_lt_denom {q : ℚ} :
q < 1 ↔ q.num < ↑(q.denom)
theorem rat.abs_def (q : ℚ) :