Nonnegative rationals #
This file defines the nonnegative rationals as a subtype of Rat
and provides its basic algebraic
order structure.
Note that NNRat
is not declared as a Field
here. See Data.NNRat.Lemmas
for that instance.
We also define an instance CanLift ℚ ℚ≥0
. This instance can be used by the lift
tactic to
replace x : ℚ
and hx : 0 ≤ x
in the proof context with x : ℚ≥0
while replacing all occurrences
of x
with ↑x
. This tactic also works for a function f : α → ℚ
with a hypothesis
hf : ∀ x, 0 ≤ f x
.
Notation #
Equations
- One or more equations did not get rendered due to their size.
Equations
- NNRat.«termℚ≥0» = Lean.ParserDescr.node `NNRat.termℚ≥0 1024 (Lean.ParserDescr.symbol "ℚ≥0")
Instances For
Equations
Reinterpret a rational number q
as a non-negative rational number. Returns 0
if q ≤ 0
.
Equations
- Rat.toNNRat q = { val := max q 0, property := ⋯ }
Instances For
Coercion ℚ≥0 → ℚ
as a RingHom
.
Equations
- NNRat.coeHom = { toMonoidHom := { toOneHom := { toFun := Subtype.val, map_one' := NNRat.coe_one }, map_mul' := NNRat.coe_mul }, map_zero' := NNRat.coe_zero, map_add' := NNRat.coe_add }
Instances For
Alias of the reverse direction of Rat.toNNRat_eq_zero
.
@[simp]
theorem
Rat.toNNRat_le_toNNRat_iff
{p : ℚ}
{q : ℚ}
(hp : 0 ≤ p)
:
Rat.toNNRat q ≤ Rat.toNNRat p ↔ q ≤ p
@[simp]
theorem
Rat.toNNRat_lt_toNNRat_iff
{p : ℚ}
{q : ℚ}
(h : 0 < p)
:
Rat.toNNRat q < Rat.toNNRat p ↔ q < p
theorem
Rat.toNNRat_lt_toNNRat_iff_of_nonneg
{p : ℚ}
{q : ℚ}
(hq : 0 ≤ q)
:
Rat.toNNRat q < Rat.toNNRat p ↔ q < p
@[simp]
theorem
Rat.toNNRat_add
{p : ℚ}
{q : ℚ}
(hq : 0 ≤ q)
(hp : 0 ≤ p)
:
Rat.toNNRat (q + p) = Rat.toNNRat q + Rat.toNNRat p
theorem
Rat.toNNRat_mul
{p : ℚ}
{q : ℚ}
(hp : 0 ≤ p)
:
Rat.toNNRat (p * q) = Rat.toNNRat p * Rat.toNNRat q