The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Basic.NNReal.Defs

255 declarations and 2 deprecated aliases. Mathlib docs · Source

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 ℝ≥0 is the restriction of the order on ℝ; these relations define a conditionally complete linear order with a bottom element, ConditionallyCompleteLinearOrderBot;

  • a + b and a * b are the restrictions of addition and multiplication of real numbers to ℝ≥0; these operations together with 0 = ⟨0, _⟩ and 1 = ⟨1, _⟩ turn ℝ≥0 into a conditionally complete linear ordered archimedean commutative semifield; we have no typeclass for this in mathlib yet, so we define the following instances instead:

    • IsOrderedRing ℝ≥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 α, see Mathlib/Algebra/Order/Nonneg/Ring.lean.

  • Real.toNNReal x is defined as ⟨max x 0, _⟩, i.e. ↑(Real.toNNReal x) = x when 0 ≤ x and ↑(Real.toNNReal x) = 0 otherwise.

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.

No NNReal.mk_nonpos, nonpos_iff_eq_zero is more useful`.

No NNReal.mk_neg, not_lt_zero is more useful`.

No NNReal.mk_nonneg, that's just a special case of zero_le.

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.

theorem NNReal.mk.congr_simp E1 #

∀ (x x_1 : ℝ) (e_x : x = x_1) (hx : 0 ≤ x), NNReal.mk x hx = NNReal.mk x_1 ⋯

def NNReal E1 #

Type

Nonnegative real numbers, denoted as ℝ≥0 within the NNReal namespace

def NNReal.«termℝ≥0» E1 #

Lean.ParserDescr

Nonnegative real numbers, denoted as ℝ≥0 within the NNReal namespace

def NNReal.toReal E1 #

NNReal → ℝ

Coercion ℝ≥0 → ℝ.

instance NNReal.instCoeReal E0 #

Coe NNReal ℝ

def NNReal.mk E1 #

(x : ℝ) → 0 ≤ x → NNReal

Constructor of ℝ≥0 from a nonnegative real number.

Important: You should use NNReal.mk instead of the anonymous constructor ⟨_, _⟩ to avoid abuse of the definitional equality between ℝ≥0 and { r : ℝ // 0 ≤ r }.

instance NNReal.instZero E0 #

Zero NNReal

instance NNReal.instOne E0 #

One NNReal

instance NNReal.instBot E0 #

Bot NNReal

instance NNReal.instCommSemiring E0 #

CommSemiring NNReal

instance NNReal.instDistribLattice E0 #

DistribLattice NNReal

instance NNReal.instInhabited E0 #

Inhabited NNReal

instance NNReal.instCanonicallyOrderedAdd E0 #

CanonicallyOrderedAdd NNReal

instance NNReal.instSemilatticeSup E0 #

SemilatticeSup NNReal

instance NNReal.instSemilatticeInf E0 #

SemilatticeInf NNReal

instance NNReal.instPartialOrder E0 #

PartialOrder NNReal

instance NNReal.instIsOrderedRing E0 #

IsOrderedRing NNReal

instance NNReal.instSemiring E0 #

Semiring NNReal

instance NNReal.instIsStrictOrderedRing E0 #

IsStrictOrderedRing NNReal

instance NNReal.instMulArchimedean E0 #

MulArchimedean NNReal

instance NNReal.instArchimedean E0 #

Archimedean NNReal

instance NNReal.instCommMonoidWithZero E0 #

CommMonoidWithZero NNReal

instance NNReal.instNontrivial E0 #

Nontrivial NNReal

instance NNReal.instDenselyOrdered E0 #

DenselyOrdered NNReal

instance NNReal.instAddCancelCommMonoid E0 #

AddCancelCommMonoid NNReal

instance NNReal.instNoZeroDivisors E0 #

NoZeroDivisors NNReal

instance NNReal.instOrderBot E0 #

OrderBot NNReal

instance NNReal.instSub E0 #

Sub NNReal

instance NNReal.instOrderedSub E0 #

OrderedSub NNReal

instance NNReal.instLinearOrder E0 #

LinearOrder NNReal

instance NNReal.instNNRatCast E0 #

NNRatCast NNReal

instance NNReal.instInv E0 #

Inv NNReal

instance NNReal.instDiv E0 #

Div NNReal

instance NNReal.instSMulNNRat E0 #

SMul ℚ≥0 NNReal

instance NNReal.zpow E0 #

Pow NNReal ℤ

instance NNReal.instSemifield E0 #

Semifield NNReal

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).

instance NNReal.instIsOrderedRing_1 E0 #

IsOrderedRing NNReal

instance NNReal.instIsStrictOrderedRing_1 E0 #

IsStrictOrderedRing NNReal

instance NNReal.instLinearOrderedCommGroupWithZero E0 #

LinearOrderedCommGroupWithZero NNReal

theorem NNReal.mk_coe E0 #

∀ (a : NNReal) (ha : 0 ≤ ↑a), NNReal.mk (↑a) ha = a

theorem NNReal.val_eq_coe E0 #

∀ (n : NNReal), ↑n = ↑n

instance NNReal.canLift E0 #

CanLift ℝ NNReal NNReal.toReal fun r ↦ 0 ≤ r

theorem NNReal.eq E1 #

∀ {n m : NNReal}, ↑n = ↑m → n = m

theorem NNReal.ne_iff E0 #

∀ {x y : NNReal}, ↑x ≠ ↑y ↔ x ≠ y

theorem NNReal.forall E1 #

∀ {p : NNReal → Prop}, (∀ (x : NNReal), p x) ↔ ∀ (x : ℝ) (hx : 0 ≤ x), p (NNReal.mk x hx)

theorem NNReal.exists E1 #

∀ {p : NNReal → Prop}, (∃ x, p x) ↔ ∃ x, ∃ (hx : 0 ≤ x), p (NNReal.mk x hx)

def Real.toNNReal E1 #

ℝ → NNReal

Reinterpret a real number r as a non-negative real number. Returns 0 if r < 0.

theorem Real.coe_toNNReal E0 #

∀ (r : ℝ), 0 ≤ r → ↑r.toNNReal = r

theorem Real.toNNReal_of_nonneg E1 #

∀ {r : ℝ} (hr : 0 ≤ r), r.toNNReal = NNReal.mk r hr

theorem Real.le_coe_toNNReal E1 #

∀ (r : ℝ), r ≤ ↑r.toNNReal

theorem NNReal.coe_nonneg E0 #

∀ (r : NNReal), 0 ≤ ↑r

theorem NNReal.not_toReal_neg E0 #

∀ {r : NNReal}, ¬↑r < 0

theorem NNReal.coe_mk E0 #

∀ (a : ℝ) (ha : 0 ≤ a), ↑(NNReal.mk a ha) = a

theorem NNReal.coe_injective E0 #

Function.Injective NNReal.toReal

theorem NNReal.coe_inj E0 #

∀ {r₁ r₂ : NNReal}, ↑r₁ = ↑r₂ ↔ r₁ = r₂

theorem NNReal.coe_zero E0 #

↑0 = 0

theorem NNReal.coe_one E0 #

↑1 = 1

theorem NNReal.mk_zero E0 #

NNReal.mk 0 ⋯ = 0

theorem NNReal.mk_one E0 #

NNReal.mk 1 ⋯ = 1

theorem NNReal.coe_add E0 #

∀ (r₁ r₂ : NNReal), ↑(r₁ + r₂) = ↑r₁ + ↑r₂

theorem NNReal.coe_mul E0 #

∀ (r₁ r₂ : NNReal), ↑(r₁ * r₂) = ↑r₁ * ↑r₂

theorem NNReal.coe_inv E0 #

∀ (r : NNReal), ↑r⁻¹ = (↑r)⁻¹

theorem NNReal.coe_div E0 #

∀ (r₁ r₂ : NNReal), ↑(r₁ / r₂) = ↑r₁ / ↑r₂

theorem NNReal.coe_two E0 #

↑2 = 2

theorem NNReal.coe_sub E0 #

∀ {r₁ r₂ : NNReal}, r₂ ≤ r₁ → ↑(r₁ - r₂) = ↑r₁ - ↑r₂

theorem NNReal.coe_eq_zero E0 #

∀ {r : NNReal}, ↑r = 0 ↔ r = 0

theorem NNReal.coe_eq_one E0 #

∀ {r : NNReal}, ↑r = 1 ↔ r = 1

theorem NNReal.coe_ne_zero E0 #

∀ {r : NNReal}, ↑r ≠ 0 ↔ r ≠ 0

theorem NNReal.coe_ne_one E0 #

∀ {r : NNReal}, ↑r ≠ 1 ↔ r ≠ 1

def NNReal.toRealHom E1 #

NNReal →+* ℝ

Coercion ℝ≥0 → ℝ as a RingHom.

TODO: what if we define Coe ℝ≥0 ℝ using this function?

theorem NNReal.coe_toRealHom E0 #

⇑NNReal.toRealHom = NNReal.toReal

instance NNReal.instSMulOfReal E0 #

{M : Type u_1} → [SMul ℝ M] → SMul NNReal M

A scalar multiplication over ℝ restricts to a scalar multiplication over ℝ≥0.

instance NNReal.instMulActionOfReal E0 #

{M : Type u_1} → [MulAction ℝ M] → MulAction NNReal M

A MulAction over ℝ restricts to a MulAction over ℝ≥0.

theorem NNReal.smul_def E0 #

∀ {M : Type u_1} [inst : SMul ℝ M] (c : NNReal) (x : M), c • x = ↑c • x

instance NNReal.instIsScalarTowerOfReal E0 #

∀ {M : Type u_1} {N : Type u_2} [inst : MulAction ℝ M] [inst_1 : MulAction ℝ N] [inst_2 : SMul M N]
  [IsScalarTower ℝ M N], IsScalarTower NNReal M N

instance NNReal.smulCommClass_left E0 #

∀ {M : Type u_1} {N : Type u_2} [inst : MulAction ℝ N] [inst_1 : SMul M N] [SMulCommClass ℝ M N],
  SMulCommClass NNReal M N

instance NNReal.smulCommClass_right E0 #

∀ {M : Type u_1} {N : Type u_2} [inst : MulAction ℝ N] [inst_1 : SMul M N] [SMulCommClass M ℝ N],
  SMulCommClass M NNReal N

instance NNReal.instDistribMulActionOfReal E0 #

{M : Type u_1} → [inst : AddMonoid M] → [DistribMulAction ℝ M] → DistribMulAction NNReal M

A DistribMulAction over ℝ restricts to a DistribMulAction over ℝ≥0.

instance NNReal.instModuleOfReal E0 #

{M : Type u_1} → [inst : AddCommMonoid M] → [Module ℝ M] → Module NNReal M

A Module over ℝ restricts to a Module over ℝ≥0.

instance NNReal.instAlgebraOfReal E0 #

{A : Type u_1} → [inst : Semiring A] → [Algebra ℝ A] → Algebra NNReal A

An Algebra over ℝ restricts to an Algebra over ℝ≥0.

theorem NNReal.coe_pow E0 #

∀ (r : NNReal) (n : ℕ), ↑(r ^ n) = ↑r ^ n

theorem NNReal.coe_zpow E0 #

∀ (r : NNReal) (n : ℤ), ↑(r ^ n) = ↑r ^ n

theorem NNReal.coe_nsmul E0 #

∀ (r : NNReal) (n : ℕ), ↑(n • r) = n • ↑r

theorem NNReal.coe_nnqsmul E0 #

∀ (q : ℚ≥0) (x : NNReal), ↑(q • x) = q • ↑x

theorem NNReal.coe_natCast E0 #

∀ (n : ℕ), ↑↑n = ↑n

theorem NNReal.coe_ofNat E0 #

∀ (n : ℕ) [inst : n.AtLeastTwo], ↑(OfNat.ofNat n) = OfNat.ofNat n

theorem NNReal.coe_ofScientific E0 #

∀ (m : ℕ) (s : Bool) (e : ℕ), ↑(OfScientific.ofScientific m s e) = OfScientific.ofScientific m s e

theorem NNReal.algebraMap_eq_coe E0 #

⇑(algebraMap NNReal ℝ) = NNReal.toReal

theorem NNReal.coe_le_coe E0 #

∀ {r₁ r₂ : NNReal}, ↑r₁ ≤ ↑r₂ ↔ r₁ ≤ r₂

theorem NNReal.coe_lt_coe E0 #

∀ {r₁ r₂ : NNReal}, ↑r₁ < ↑r₂ ↔ r₁ < r₂

theorem NNReal.coe_pos E0 #

∀ {r : NNReal}, 0 < ↑r ↔ 0 < r

theorem NNReal.one_le_coe E0 #

∀ {r : NNReal}, 1 ≤ ↑r ↔ 1 ≤ r

theorem NNReal.one_lt_coe E0 #

∀ {r : NNReal}, 1 < ↑r ↔ 1 < r

theorem NNReal.coe_le_one E0 #

∀ {r : NNReal}, ↑r ≤ 1 ↔ r ≤ 1

theorem NNReal.coe_lt_one E0 #

∀ {r : NNReal}, ↑r < 1 ↔ r < 1

theorem NNReal.coe_mono E0 #

Monotone NNReal.toReal

theorem NNReal.mk_le_mk E0 #

∀ {a b : ℝ} {ha : 0 ≤ a} {hb : 0 ≤ b}, NNReal.mk a ha ≤ NNReal.mk b hb ↔ a ≤ b

theorem NNReal.mk_lt_mk E0 #

∀ {a b : ℝ} {ha : 0 ≤ a} {hb : 0 ≤ b}, NNReal.mk a ha < NNReal.mk b hb ↔ a < b

theorem NNReal.mk_eq_zero E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, NNReal.mk a ha = 0 ↔ a = 0

theorem NNReal.zero_eq_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, 0 = NNReal.mk a ha ↔ 0 = a

theorem NNReal.mk_pos E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, 0 < NNReal.mk a ha ↔ 0 < a

theorem NNReal.mk_eq_one E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, NNReal.mk a ha = 1 ↔ a = 1

theorem NNReal.mk_le_one E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, NNReal.mk a ha ≤ 1 ↔ a ≤ 1

theorem NNReal.mk_lt_one E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, NNReal.mk a ha < 1 ↔ a < 1

theorem NNReal.one_eq_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, 1 = NNReal.mk a ha ↔ 1 = a

theorem NNReal.one_le_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, 1 ≤ NNReal.mk a ha ↔ 1 ≤ a

theorem NNReal.one_lt_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a}, 1 < NNReal.mk a ha ↔ 1 < a

theorem NNReal.mk_eq_natCast E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, NNReal.mk a ha = ↑n ↔ a = ↑n

theorem NNReal.mk_le_natCast E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, NNReal.mk a ha ≤ ↑n ↔ a ≤ ↑n

theorem NNReal.mk_lt_natCast E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, NNReal.mk a ha < ↑n ↔ a < ↑n

theorem NNReal.natCast_eq_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, ↑n = NNReal.mk a ha ↔ ↑n = a

theorem NNReal.natCast_le_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, ↑n ≤ NNReal.mk a ha ↔ ↑n ≤ a

theorem NNReal.natCast_lt_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ}, ↑n < NNReal.mk a ha ↔ ↑n < a

theorem NNReal.mk_eq_ofNat E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], NNReal.mk a ha = OfNat.ofNat n ↔ a = OfNat.ofNat n

theorem NNReal.mk_le_ofNat E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], NNReal.mk a ha ≤ OfNat.ofNat n ↔ a ≤ OfNat.ofNat n

theorem NNReal.mk_lt_ofNat E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], NNReal.mk a ha < OfNat.ofNat n ↔ a < OfNat.ofNat n

theorem NNReal.ofNat_eq_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], OfNat.ofNat n = NNReal.mk a ha ↔ OfNat.ofNat n = a

theorem NNReal.ofNat_le_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], OfNat.ofNat n ≤ NNReal.mk a ha ↔ OfNat.ofNat n ≤ a

theorem NNReal.ofNat_lt_mk E0 #

∀ {a : ℝ} {ha : 0 ≤ a} {n : ℕ} [inst : n.AtLeastTwo], OfNat.ofNat n < NNReal.mk a ha ↔ OfNat.ofNat n < a

theorem Real.toNNReal_monotone E1 #

Monotone Real.toNNReal

theorem Real.toNNReal_mono E1 #

∀ {r₁ r₂ : ℝ}, r₁ ≤ r₂ → r₁.toNNReal ≤ r₂.toNNReal

theorem Real.toNNReal_coe E0 #

∀ {r : NNReal}, (↑r).toNNReal = r

theorem NNReal.mk_natCast E0 #

∀ (n : ℕ), NNReal.mk ↑n ⋯ = ↑n

theorem Real.toNNReal_natCast E0 #

∀ (n : ℕ), (↑n).toNNReal = ↑n

theorem Real.toNNReal_ofNat E0 #

∀ (n : ℕ) [inst : n.AtLeastTwo], (OfNat.ofNat n).toNNReal = OfNat.ofNat n

def NNReal.gi E1 #

GaloisInsertion Real.toNNReal NNReal.toReal

Real.toNNReal and NNReal.toReal : ℝ≥0 → ℝ form a Galois insertion.

instance NNReal.instPosSMulStrictMono E0 #

∀ {α : Type u_2} [inst : Preorder α] [inst_1 : MulAction ℝ α] [PosSMulStrictMono ℝ α], PosSMulStrictMono NNReal α

instance NNReal.instSMulPosStrictMono E0 #

∀ {α : Type u_2} [inst : Zero α] [inst_1 : Preorder α] [inst_2 : MulAction ℝ α] [SMulPosStrictMono ℝ α],
  SMulPosStrictMono NNReal α

def NNReal.orderIsoIccZeroCoe E1 #

(a : NNReal) → ↑(Set.Icc 0 ↑a) ≃o ↑(Set.Iic a)

If a is a nonnegative real number, then the closed interval [0, a] in ℝ is order isomorphic to the interval Set.Iic a.

theorem NNReal.orderIsoIccZeroCoe_apply_coe_coe E0 #

∀ (a : NNReal) (b : ↑(Set.Icc 0 ↑a)), ↑↑(a.orderIsoIccZeroCoe b) = ↑b

theorem NNReal.orderIsoIccZeroCoe_symm_apply_coe E0 #

∀ (a : NNReal) (b : ↑(Set.Iic a)), ↑(a.orderIsoIccZeroCoe.symm b) = ↑↑b

theorem NNReal.coe_image E0 #

∀ {s : Set NNReal}, NNReal.toReal '' s = {x | ∃ (h : 0 ≤ x), NNReal.mk x h ∈ s}

theorem NNReal.bddAbove_coe E0 #

∀ {s : Set NNReal}, BddAbove (NNReal.toReal '' s) ↔ BddAbove s

theorem NNReal.bddBelow_coe E0 #

∀ (s : Set NNReal), BddBelow (NNReal.toReal '' s)

instance NNReal.instConditionallyCompleteLinearOrderBot E0 #

ConditionallyCompleteLinearOrderBot NNReal

theorem NNReal.coe_sSup E0 #

∀ (s : Set NNReal), ↑(sSup s) = sSup (NNReal.toReal '' s)

theorem NNReal.coe_iSup E0 #

∀ {ι : Sort u_2} (s : ι → NNReal), ↑(⨆ i, s i) = ⨆ i, ↑(s i)

theorem NNReal.coe_sInf E0 #

∀ (s : Set NNReal), ↑(sInf s) = sInf (NNReal.toReal '' s)

theorem NNReal.sInf_empty E0 #

sInf ∅ = 0

theorem NNReal.coe_iInf E0 #

∀ {ι : Sort u_2} (s : ι → NNReal), ↑(⨅ i, s i) = ⨅ i, ↑(s i)

instance NNReal.addLeftMono E0 #

AddLeftMono NNReal

instance NNReal.addLeftReflectLT E0 #

AddLeftReflectLT NNReal

instance NNReal.mulLeftMono E0 #

MulLeftMono NNReal

theorem NNReal.lt_iff_exists_rat_btwn E1 #

∀ (a b : NNReal), a < b ↔ ∃ q, 0 ≤ q ∧ a < (↑q).toNNReal ∧ (↑q).toNNReal < b

theorem NNReal.bot_eq_zero E1 #

⊥ = 0

theorem NNReal.mul_sup E1 #

∀ (a b c : NNReal), a * max b c = max (a * b) (a * c)

theorem NNReal.sup_mul E1 #

∀ (a b c : NNReal), max a b * c = max (a * c) (b * c)

theorem NNReal.coe_max E0 #

∀ (x y : NNReal), ↑(max x y) = max ↑x ↑y

theorem NNReal.coe_min E0 #

∀ (x y : NNReal), ↑(min x y) = min ↑x ↑y

theorem NNReal.zero_le_coe E0 #

∀ {q : NNReal}, 0 ≤ ↑q

instance NNReal.instIsStrictOrderedModule E0 #

∀ {M : Type u_2} [inst : AddCommMonoid M] [inst_1 : PartialOrder M] [inst_2 : Module ℝ M] [IsStrictOrderedModule ℝ M],
  IsStrictOrderedModule NNReal M

theorem Real.coe_toNNReal' E0 #

∀ (r : ℝ), ↑r.toNNReal = max r 0

theorem Real.toNNReal_zero E0 #

Real.toNNReal 0 = 0

theorem Real.toNNReal_one E0 #

Real.toNNReal 1 = 1

theorem Real.toNNReal_pos E0 #

∀ {r : ℝ}, 0 < r.toNNReal ↔ 0 < r

theorem Real.toNNReal_eq_zero E0 #

∀ {r : ℝ}, r.toNNReal = 0 ↔ r ≤ 0

theorem Real.toNNReal_of_nonpos E1 #

∀ {r : ℝ}, r ≤ 0 → r.toNNReal = 0

theorem Real.toNNReal_eq_iff_eq_coe E0 #

∀ {r : ℝ} {p : NNReal}, p ≠ 0 → (r.toNNReal = p ↔ r = ↑p)

theorem Real.toNNReal_eq_one E0 #

∀ {r : ℝ}, r.toNNReal = 1 ↔ r = 1

theorem Real.toNNReal_eq_natCast E0 #

∀ {r : ℝ} {n : ℕ}, n ≠ 0 → (r.toNNReal = ↑n ↔ r = ↑n)

theorem Real.toNNReal_eq_ofNat E0 #

∀ {r : ℝ} {n : ℕ} [inst : n.AtLeastTwo], r.toNNReal = OfNat.ofNat n ↔ r = OfNat.ofNat n

theorem Real.toNNReal_le_toNNReal_iff E0 #

∀ {r p : ℝ}, 0 ≤ p → (r.toNNReal ≤ p.toNNReal ↔ r ≤ p)

theorem Real.toNNReal_le_one E0 #

∀ {r : ℝ}, r.toNNReal ≤ 1 ↔ r ≤ 1

theorem Real.one_lt_toNNReal E0 #

∀ {r : ℝ}, 1 < r.toNNReal ↔ 1 < r

theorem Real.toNNReal_le_natCast E0 #

∀ {r : ℝ} {n : ℕ}, r.toNNReal ≤ ↑n ↔ r ≤ ↑n

theorem Real.natCast_lt_toNNReal E0 #

∀ {r : ℝ} {n : ℕ}, ↑n < r.toNNReal ↔ ↑n < r

theorem Real.toNNReal_le_ofNat E0 #

∀ {r : ℝ} {n : ℕ} [inst : n.AtLeastTwo], r.toNNReal ≤ OfNat.ofNat n ↔ r ≤ ↑n

theorem Real.ofNat_lt_toNNReal E0 #

∀ {r : ℝ} {n : ℕ} [inst : n.AtLeastTwo], OfNat.ofNat n < r.toNNReal ↔ ↑n < r

theorem Real.toNNReal_eq_toNNReal_iff E0 #

∀ {r p : ℝ}, 0 ≤ r → 0 ≤ p → (r.toNNReal = p.toNNReal ↔ r = p)

theorem Real.toNNReal_lt_toNNReal_iff' E0 #

∀ {r p : ℝ}, r.toNNReal < p.toNNReal ↔ r < p ∧ 0 < p

theorem Real.toNNReal_lt_toNNReal_iff E0 #

∀ {r p : ℝ}, 0 < p → (r.toNNReal < p.toNNReal ↔ r < p)

theorem Real.lt_of_toNNReal_lt E1 #

∀ {r p : ℝ}, r.toNNReal < p.toNNReal → r < p

theorem Real.toNNReal_lt_toNNReal_iff_of_nonneg E1 #

∀ {r p : ℝ}, 0 ≤ r → (r.toNNReal < p.toNNReal ↔ r < p)

theorem Real.toNNReal_le_toNNReal_iff' E1 #

∀ {r p : ℝ}, r.toNNReal ≤ p.toNNReal ↔ r ≤ p ∨ r ≤ 0

theorem Real.toNNReal_le_toNNReal_iff_of_pos E1 #

∀ {r p : ℝ}, 0 < r → (r.toNNReal ≤ p.toNNReal ↔ r ≤ p)

theorem Real.one_le_toNNReal E0 #

∀ {r : ℝ}, 1 ≤ r.toNNReal ↔ 1 ≤ r

theorem Real.toNNReal_lt_one E0 #

∀ {r : ℝ}, r.toNNReal < 1 ↔ r < 1

theorem Real.natCast_le_toNNReal' E0 #

∀ {n : ℕ} {r : ℝ}, ↑n ≤ r.toNNReal ↔ ↑n ≤ r ∨ n = 0

theorem Real.toNNReal_lt_natCast' E0 #

∀ {n : ℕ} {r : ℝ}, r.toNNReal < ↑n ↔ r < ↑n ∧ n ≠ 0

theorem Real.natCast_le_toNNReal E1 #

∀ {n : ℕ} {r : ℝ}, n ≠ 0 → (↑n ≤ r.toNNReal ↔ ↑n ≤ r)

theorem Real.toNNReal_lt_natCast E1 #

∀ {r : ℝ} {n : ℕ}, n ≠ 0 → (r.toNNReal < ↑n ↔ r < ↑n)

theorem Real.toNNReal_lt_ofNat E0 #

∀ {r : ℝ} {n : ℕ} [inst : n.AtLeastTwo], r.toNNReal < OfNat.ofNat n ↔ r < OfNat.ofNat n

theorem Real.ofNat_le_toNNReal E0 #

∀ {n : ℕ} {r : ℝ} [inst : n.AtLeastTwo], OfNat.ofNat n ≤ r.toNNReal ↔ OfNat.ofNat n ≤ r

theorem Real.toNNReal_add E0 #

∀ {r p : ℝ}, 0 ≤ r → 0 ≤ p → (r + p).toNNReal = r.toNNReal + p.toNNReal

theorem Real.toNNReal_add_toNNReal E1 #

∀ {r p : ℝ}, 0 ≤ r → 0 ≤ p → r.toNNReal + p.toNNReal = (r + p).toNNReal

theorem Real.toNNReal_le_toNNReal E1 #

∀ {r p : ℝ}, r ≤ p → r.toNNReal ≤ p.toNNReal

theorem Real.toNNReal_add_le E1 #

∀ {r p : ℝ}, (r + p).toNNReal ≤ r.toNNReal + p.toNNReal

theorem Real.toNNReal_le_iff_le_coe E0 #

∀ {r : ℝ} {p : NNReal}, r.toNNReal ≤ p ↔ r ≤ ↑p

theorem Real.le_toNNReal_iff_coe_le E1 #

∀ {r : NNReal} {p : ℝ}, 0 ≤ p → (r ≤ p.toNNReal ↔ ↑r ≤ p)

theorem Real.le_toNNReal_iff_coe_le' E1 #

∀ {r : NNReal} {p : ℝ}, 0 < r → (r ≤ p.toNNReal ↔ ↑r ≤ p)

theorem Real.toNNReal_lt_iff_lt_coe E0 #

∀ {r : ℝ} {p : NNReal}, 0 ≤ r → (r.toNNReal < p ↔ r < ↑p)

theorem Real.lt_toNNReal_iff_coe_lt E1 #

∀ {r : NNReal} {p : ℝ}, r < p.toNNReal ↔ ↑r < p

theorem Real.toNNReal_pow E1 #

∀ {x : ℝ}, 0 ≤ x → ∀ (n : ℕ), (x ^ n).toNNReal = x.toNNReal ^ n

theorem Real.toNNReal_zpow E1 #

∀ {x : ℝ}, 0 ≤ x → ∀ (n : ℤ), (x ^ n).toNNReal = x.toNNReal ^ n

theorem Real.toNNReal_mul E1 #

∀ {p q : ℝ}, 0 ≤ p → (p * q).toNNReal = p.toNNReal * q.toNNReal

theorem NNReal.mul_eq_mul_left E1 #

∀ {a b c : NNReal}, a ≠ 0 → (a * b = a * c ↔ b = c)

theorem NNReal.pow_antitone_exp E1 #

∀ {a : NNReal} (m n : ℕ), m ≤ n → a ≤ 1 → a ^ n ≤ a ^ m

theorem NNReal.exists_pow_lt_of_lt_one E1 #

∀ {a b : NNReal}, 0 < a → b < 1 → ∃ n, b ^ n < a

theorem NNReal.exists_mem_Ico_zpow E1 #

∀ {x y : NNReal}, x ≠ 0 → 1 < y → ∃ n, x ∈ Set.Ico (y ^ n) (y ^ (n + 1))

theorem NNReal.exists_mem_Ioc_zpow E1 #

∀ {x y : NNReal}, x ≠ 0 → 1 < y → ∃ n, x ∈ Set.Ioc (y ^ n) (y ^ (n + 1))

theorem NNReal.sub_def E0 #

∀ {r p : NNReal}, r - p = (↑r - ↑p).toNNReal

theorem NNReal.coe_sub_def E0 #

∀ {r p : NNReal}, ↑(r - p) = max (↑r - ↑p) 0

theorem NNReal.inv_mk E0 #

∀ {r : ℝ} (hr : 0 ≤ r), (NNReal.mk r hr)⁻¹ = NNReal.mk r⁻¹ ⋯

theorem NNReal.inv_le E0 #

∀ {r p : NNReal}, r ≠ 0 → (r⁻¹ ≤ p ↔ 1 ≤ r * p)

theorem NNReal.inv_le_of_le_mul E1 #

∀ {r p : NNReal}, 1 ≤ r * p → r⁻¹ ≤ p

theorem NNReal.le_inv_iff_mul_le E0 #

∀ {r p : NNReal}, p ≠ 0 → (r ≤ p⁻¹ ↔ r * p ≤ 1)

theorem NNReal.lt_inv_iff_mul_lt E0 #

∀ {r p : NNReal}, p ≠ 0 → (r < p⁻¹ ↔ r * p < 1)

theorem NNReal.div_le_of_le_mul E1 #

∀ {a b c : NNReal}, a ≤ b * c → a / c ≤ b

theorem NNReal.div_le_of_le_mul' E1 #

∀ {a b c : NNReal}, a ≤ b * c → a / b ≤ c

theorem NNReal.mul_lt_of_lt_div E1 #

∀ {a b r : NNReal}, a < b / r → a * r < b

theorem NNReal.le_of_forall_lt_one_mul_le E1 #

∀ {x y : NNReal}, (∀ a < 1, a * x ≤ y) → x ≤ y

theorem NNReal.half_le_self E1 #

∀ (a : NNReal), a / 2 ≤ a

theorem NNReal.half_lt_self E1 #

∀ {a : NNReal}, a ≠ 0 → a / 2 < a

theorem NNReal.div_lt_one_of_lt E1 #

∀ {a b : NNReal}, a < b → a / b < 1

theorem Real.toNNReal_inv E1 #

∀ {x : ℝ}, x⁻¹.toNNReal = x.toNNReal⁻¹

theorem Real.toNNReal_div E1 #

∀ {x y : ℝ}, 0 ≤ x → (x / y).toNNReal = x.toNNReal / y.toNNReal

theorem Real.toNNReal_div' E1 #

∀ {x y : ℝ}, 0 ≤ y → (x / y).toNNReal = x.toNNReal / y.toNNReal

theorem NNReal.inv_lt_one_iff E0 #

∀ {x : NNReal}, x ≠ 0 → (x⁻¹ < 1 ↔ 1 < x)

theorem NNReal.inv_lt_inv E1 #

∀ {x y : NNReal}, x ≠ 0 → x < y → y⁻¹ < x⁻¹

theorem NNReal.exists_nat_pos_inv_lt E1 #

∀ {b : NNReal}, 0 < b → ∃ n, 0 < n ∧ (↑n)⁻¹ < b

theorem NNReal.abs_eq E0 #

∀ (x : NNReal), |↑x| = ↑x

theorem NNReal.le_toNNReal_of_coe_le E1 #

∀ {x : NNReal} {y : ℝ}, ↑x ≤ y → x ≤ y.toNNReal

theorem NNReal.sSup_of_not_bddAbove E1 #

∀ {s : Set NNReal}, ¬BddAbove s → sSup s = 0

theorem NNReal.iSup_of_not_bddAbove E1 #

∀ {ι : Sort u_1} {f : ι → NNReal}, ¬BddAbove (Set.range f) → ⨆ i, f i = 0

theorem NNReal.iSup_empty E1 #

∀ {ι : Sort u_1} [IsEmpty ι] (f : ι → NNReal), ⨆ i, f i = 0

theorem NNReal.iInf_empty E1 #

∀ {ι : Sort u_1} [IsEmpty ι] (f : ι → NNReal), ⨅ i, f i = 0

theorem NNReal.iSup_eq_zero E0 #

∀ {ι : Sort u_1} {f : ι → NNReal}, BddAbove (Set.range f) → (⨆ i, f i = 0 ↔ ∀ (i : ι), f i = 0)

theorem NNReal.iInf_const_zero E0 #

∀ {α : Sort u_2}, ⨅ x, 0 = 0

theorem Set.OrdConnected.preimage_coe_nnreal_real E1 #

∀ {s : Set ℝ}, s.OrdConnected → (NNReal.toReal ⁻¹' s).OrdConnected

theorem Set.OrdConnected.image_coe_nnreal_real E1 #

∀ {t : Set NNReal}, t.OrdConnected → (NNReal.toReal '' t).OrdConnected

theorem Set.OrdConnected.image_real_toNNReal E1 #

∀ {s : Set ℝ}, s.OrdConnected → (Real.toNNReal '' s).OrdConnected

theorem Set.OrdConnected.preimage_real_toNNReal E1 #

∀ {t : Set NNReal}, t.OrdConnected → (Real.toNNReal ⁻¹' t).OrdConnected

def Real.nnabs E1 #

ℝ →*₀ NNReal

The absolute value on ℝ as a map to ℝ≥0.

theorem Real.coe_nnabs E0 #

∀ (x : ℝ), ↑(Real.nnabs x) = |x|

theorem Real.nnabs_of_nonneg E0 #

∀ {x : ℝ}, 0 ≤ x → Real.nnabs x = x.toNNReal

theorem Real.nnabs_coe E0 #

∀ (x : NNReal), Real.nnabs ↑x = x

theorem Real.coe_toNNReal_le E0 #

∀ (x : ℝ), ↑x.toNNReal ≤ |x|

theorem Real.toNNReal_abs E0 #

∀ (x : ℝ), |x|.toNNReal = Real.nnabs x

theorem Real.nnabs_natCast E0 #

∀ (n : ℕ), Real.nnabs ↑n = ↑n

theorem Real.nnabs_ofNat E0 #

∀ (n : ℕ) [inst : n.AtLeastTwo], Real.nnabs (OfNat.ofNat n) = OfNat.ofNat n

theorem Real.cast_natAbs_eq_nnabs_cast E1 #

∀ (n : ℤ), ↑n.natAbs = Real.nnabs ↑n

theorem Real.nnabs_pos E0 #

∀ {x : ℝ}, 0 < Real.nnabs x ↔ x ≠ 0

theorem Real.nnreal_dichotomy E1 #

∀ (r : ℝ), ∃ x, r = ↑x ∨ r = -↑x

Every real number nonnegative or nonpositive, phrased using ℝ≥0.

theorem Real.nnreal_trichotomy E1 #

∀ (r : ℝ), r = 0 ∨ ∃ x, 0 < x ∧ (r = ↑x ∨ r = -↑x)

Every real number is either zero, positive or negative, phrased using ℝ≥0.

theorem Real.nnreal_induction_on E1 #

∀ {motive : ℝ → Prop}, (∀ (x : NNReal), motive ↑x) → (∀ (x : NNReal), motive ↑x → motive (-↑x)) → ∀ (r : ℝ), motive r

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 : ℝ).

theorem Real.nnreal_induction_on' E1 #

∀ {motive : ℝ → Prop},
  motive 0 →
    (∀ (x : NNReal), 0 < x → motive ↑x) → (∀ (x : NNReal), 0 < x → motive ↑x → motive (-↑x)) → ∀ (r : ℝ), motive r

A version of nnreal_induction_on which splits into three cases (zero, positive and negative) instead of two.

theorem NNReal.exists_lt_of_strictMono E1 #

∀ {Γ₀ : Type u_1} [inst : LinearOrderedCommGroupWithZero Γ₀] [h : Nontrivial Γ₀ˣ] {f : Γ₀ →*₀ NNReal},
  StrictMono ⇑f → ∀ {r : NNReal}, 0 < r → ∃ d, f ↑d < r

If Γ₀ˣ is nontrivial and f : Γ₀ →*₀ ℝ≥0 is strictly monotone, then for any positive r : ℝ≥0, there exists d : Γ₀ˣ with f d < r.

theorem Real.exists_lt_of_strictMono E1 #

∀ {Γ₀ : Type u_1} [inst : LinearOrderedCommGroupWithZero Γ₀] [h : Nontrivial Γ₀ˣ] {f : Γ₀ →*₀ NNReal},
  StrictMono ⇑f → ∀ {r : ℝ}, 0 < r → ∃ d, ↑(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.

instance instReprNNReal E0 #

Repr NNReal

While not very useful, this instance uses the same representation as Real.instRepr.

theorem Mathlib.Meta.Positivity.nnreal_coe_pos E1 #

∀ {r : NNReal}, 0 < r → 0 < ↑r

Alias of the reverse direction of NNReal.coe_pos.

def Mathlib.Meta.Positivity.evalNNRealtoReal E1 #

Mathlib.Meta.Positivity.PositivityExt

Extension for the positivity tactic: cast from ℝ≥0 to ℝ.

def Mathlib.Meta.Positivity.evalRealToNNReal E1 #

Mathlib.Meta.Positivity.PositivityExt

Extension for the positivity tactic: Real.toNNReal

theorem Mathlib.Meta.Positivity.nnabs_pos_of_pos E1 #

∀ {x : ℝ}, x ≠ 0 → 0 < Real.nnabs x

Alias of the reverse direction of Real.nnabs_pos.

def Mathlib.Meta.Positivity.evalRealNNAbs E1 #

Mathlib.Meta.Positivity.PositivityExt

Extension for the positivity tactic: Real.nnabs

def NNReal.recToNNReal E1 #

{C : NNReal → Sort u_1} → ((x : ℝ) → 0 ≤ x → C x.toNNReal) → (t : NNReal) → C t

A Subtype.mk-free eliminator for ℝ≥0, exposing the underlying real and its nonnegativity. Used by the basify tactic: a goal mentioning ⟨x, hx⟩ : ℝ≥0 is not type-correct at the transparency simp checks at, because ℝ≥0 is semireducible.

Deprecated aliases

NameNew nameSince
Real.natCastle_toNNReal'Real.natCast_le_toNNReal'2026-10-13
Real.toNNReal_coe_natReal.toNNReal_natCast2026-05-19