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 Semifield
here. See Mathlib/Algebra/Field/Rat.lean
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 #
ℚ≥0
is notation for NNRat
in locale NNRat
.
Huge warning #
Whenever you state a lemma about the coercion ℚ≥0 → ℚ
, check that Lean inserts NNRat.cast
, not
Subtype.val
. Else your lemma will never apply.
Reinterpret a rational number q
as a non-negative rational number. Returns 0
if q ≤ 0
.
Equations
Instances For
Alias of the reverse direction of Rat.toNNRat_eq_zero
.