Nonnegative real numbers #
In this file we define NNReal (notation: ℝ≥0) to be the type of non-negative real numbers,
a.k.a. the interval [0, ∞). We also define the following operations and structures on ℝ≥0:
the order on
ℝ≥0is the restriction of the order onℝ; these relations define a conditionally complete linear order with a bottom element,ConditionallyCompleteLinearOrderBot;a + banda * bare the restrictions of addition and multiplication of real numbers toℝ≥0; these operations together with0 = ⟨0, _⟩and1 = ⟨1, _⟩turnℝ≥0into a conditionally complete linear ordered archimedean commutative semifield; we have no typeclass for this inmathlibyet, so we define the following instances instead:LinearOrderedSemiring ℝ≥0;OrderedCommSemiring ℝ≥0;CanonicallyOrderedAdd ℝ≥0;LinearOrderedCommGroupWithZero ℝ≥0;CanonicallyLinearOrderedAddCommMonoid ℝ≥0;Archimedean ℝ≥0;ConditionallyCompleteLinearOrderBot ℝ≥0.
These instances are derived from corresponding instances about the type
{x : α // 0 ≤ x}in an appropriate ordered field/ring/group/monoidα, seeMathlib/Algebra/Order/Nonneg/Ring.lean.Real.toNNReal xis defined as⟨max x 0, _⟩, i.e.↑(Real.toNNReal x) = xwhen0 ≤ xand↑(Real.toNNReal x) = 0otherwise.
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 #
This file defines ℝ≥0 as a localized notation for NNReal.
Equations
Equations
- instPartialOrderNNReal = Subtype.partialOrder fun (r : ℝ) => 0 ≤ r
Nonnegative real numbers, denoted as ℝ≥0 within the NNReal namespace
Equations
- NNReal.«termℝ≥0» = Lean.ParserDescr.node `NNReal.«termℝ≥0» 1024 (Lean.ParserDescr.symbol "ℝ≥0")
Instances For
Coercion ℝ≥0 → ℝ.
Equations
Instances For
Equations
- NNReal.instCoeReal = { coe := NNReal.toReal }
Equations
- NNReal.instLinearOrder = Subtype.instLinearOrder fun (r : ℝ) => 0 ≤ r
Redo the Nonneg.semifield instance, because this will get unfolded a lot,
and ends up inserting the non-reducible defeq ℝ≥0 = { x // x ≥ 0 } in places where
it needs to be reducible(-with-instances).
Equations
- One or more equations did not get rendered due to their size.
Coercion ℝ≥0 → ℝ as a RingHom.
TODO: what if we define Coe ℝ≥0 ℝ using this function?
Equations
- NNReal.toRealHom = { toFun := NNReal.toReal, map_one' := NNReal.coe_one, map_mul' := NNReal.coe_mul, map_zero' := NNReal.coe_zero, map_add' := NNReal.coe_add }
Instances For
A DistribMulAction over ℝ restricts to a DistribMulAction over ℝ≥0.
An Algebra over ℝ restricts to an Algebra over ℝ≥0.
Equations
- NNReal.instAlgebraOfReal = { smul := fun (x1 : NNReal) (x2 : A) => x1 • x2, algebraMap := (algebraMap ℝ A).comp NNReal.toRealHom, commutes' := ⋯, smul_def' := ⋯ }
Alias for the use of gcongr
Alias of Real.toNNReal_coe_nat.
If a is a nonnegative real number, then the closed interval [0, a] in ℝ is order
isomorphic to the interval Set.Iic a.
Equations
- a.orderIsoIccZeroCoe = { toEquiv := Equiv.Set.sep (Set.Ici 0) fun (x : ℝ) => x ≤ ↑a, map_rel_iff' := ⋯ }
Instances For
Lemmas about subtraction #
In this section we provide a few lemmas about subtraction that do not fit well into any other
typeclass. For lemmas about subtraction and addition see lemmas about OrderedSub in the file
Mathlib/Algebra/Order/Sub/Basic.lean. See also mul_tsub and tsub_mul.
The absolute value on ℝ as a map to ℝ≥0.
Equations
- Real.nnabs = { toFun := fun (x : ℝ) => ⟨|x|, ⋯⟩, map_zero' := Real.nnabs._proof_3, map_one' := Real.nnabs._proof_5, map_mul' := Real.nnabs._proof_7 }
Instances For
To prove a property holds for real numbers it suffices to show that it holds for x : ℝ≥0,
and if it holds for x : ℝ≥0, then it does also for (-↑x : ℝ).
A version of nnreal_induction_on which splits into three cases (zero, positive and negative)
instead of two.
If Γ₀ˣ is nontrivial and f : Γ₀ →*₀ ℝ≥0 is strictly monotone, then for any positive
r : ℝ≥0, there exists d : Γ₀ˣ with f d < r.
If Γ₀ˣ is nontrivial and f : Γ₀ →*₀ ℝ≥0 is strictly monotone, then for any positive
real r, there exists d : Γ₀ˣ with f d < r.
While not very useful, this instance uses the same representation as Real.instRepr.
Equations
- instReprNNReal = { reprPrec := fun (r : NNReal) (x : ℕ) => Std.format "(" ++ Std.format (repr ↑r) ++ Std.format ").toNNReal" }
Extension for the positivity tactic: cast from ℝ≥0 to ℝ.
Equations
- One or more equations did not get rendered due to their size.