Nonnegative rationals #
This file defines the nonnegative rationals as a subtype of Rat
and provides its algebraic order
structure.
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
- 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
- NNRat.instCoeNNRatRat = { coe := Subtype.val }
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 := (_ : 0 ≤ max q 0) }
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
instance
NNRat.instMulActionNNRatToMonoidToMonoidWithZeroToSemiringToStrictOrderedSemiringToLinearOrderedSemiringToLinearOrderedCommSemiringToLinearOrderedSemifieldInstNNRatCanonicallyLinearOrderedSemifield
{α : Type u_1}
[MulAction ℚ α]
:
A MulAction
over ℚ
restricts to a MulAction
over ℚ≥0
.
Equations
- One or more equations did not get rendered due to their size.
instance
NNRat.instDistribMulActionNNRatToMonoidToMonoidWithZeroToSemiringToStrictOrderedSemiringToLinearOrderedSemiringToLinearOrderedCommSemiringToLinearOrderedSemifieldInstNNRatCanonicallyLinearOrderedSemifieldToAddMonoid
{α : Type u_1}
[AddCommMonoid α]
[DistribMulAction ℚ α]
:
A DistribMulAction
over ℚ
restricts to a DistribMulAction
over ℚ≥0
.
Equations
- One or more equations did not get rendered due to their size.
@[simp]
theorem
NNRat.coe_indicator
{α : Type u_1}
(s : Set α)
(f : α → NNRat)
(a : α)
:
↑(Set.indicator s f a) = Set.indicator s (fun (x : α) => ↑(f x)) a
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
theorem
Rat.toNNRat_div
{p : ℚ}
{q : ℚ}
(hp : 0 ≤ p)
:
Rat.toNNRat (p / q) = Rat.toNNRat p / Rat.toNNRat q
theorem
Rat.toNNRat_div'
{p : ℚ}
{q : ℚ}
(hq : 0 ≤ q)
:
Rat.toNNRat (p / q) = Rat.toNNRat p / Rat.toNNRat q