Documentation

Mathlib.Data.NNReal.Defs

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:

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.

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

Equations
    Instances For

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

      Equations
        Instances For

          Coercion ℝ≥0 → ℝ.

          Equations
            Instances For
              noncomputable instance NNReal.instInv :
              Equations
                noncomputable instance NNReal.instDiv :
                Equations
                  noncomputable instance NNReal.instSMulNNRat :
                  Equations
                    noncomputable instance NNReal.zpow :
                    Equations
                      noncomputable instance NNReal.instSemifield :

                      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
                        @[simp]
                        theorem NNReal.val_eq_coe (n : NNReal) :
                        n = n
                        theorem NNReal.eq {n m : NNReal} :
                        n = mn = m
                        theorem NNReal.eq_iff {n m : NNReal} :
                        n = m n = m
                        theorem NNReal.ne_iff {x y : NNReal} :
                        x y x y
                        theorem NNReal.forall {p : NNRealProp} :
                        (∀ (x : NNReal), p x) ∀ (x : ) (hx : 0 x), p x, hx
                        theorem NNReal.exists {p : NNRealProp} :
                        (∃ (x : NNReal), p x) ∃ (x : ) (hx : 0 x), p x, hx

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

                        Equations
                          Instances For
                            theorem Real.coe_toNNReal (r : ) (hr : 0 r) :
                            r.toNNReal = r
                            @[simp]
                            theorem NNReal.coe_mk (a : ) (ha : 0 a) :
                            a, ha = a
                            @[simp]
                            theorem NNReal.coe_inj {r₁ r₂ : NNReal} :
                            r₁ = r₂ r₁ = r₂
                            @[simp]
                            theorem NNReal.coe_zero :
                            0 = 0
                            @[simp]
                            theorem NNReal.coe_one :
                            1 = 1
                            @[simp]
                            theorem NNReal.mk_zero :
                            0, = 0
                            @[simp]
                            theorem NNReal.mk_one :
                            1, = 1
                            @[simp]
                            theorem NNReal.coe_add (r₁ r₂ : NNReal) :
                            ↑(r₁ + r₂) = r₁ + r₂
                            @[simp]
                            theorem NNReal.coe_mul (r₁ r₂ : NNReal) :
                            ↑(r₁ * r₂) = r₁ * r₂
                            @[simp]
                            theorem NNReal.coe_inv (r : NNReal) :
                            r⁻¹ = (↑r)⁻¹
                            @[simp]
                            theorem NNReal.coe_div (r₁ r₂ : NNReal) :
                            ↑(r₁ / r₂) = r₁ / r₂
                            @[simp]
                            theorem NNReal.coe_sub {r₁ r₂ : NNReal} (h : r₂ r₁) :
                            ↑(r₁ - r₂) = r₁ - r₂
                            @[simp]
                            theorem NNReal.coe_eq_zero {r : NNReal} :
                            r = 0 r = 0
                            @[simp]
                            theorem NNReal.coe_eq_one {r : NNReal} :
                            r = 1 r = 1
                            theorem NNReal.coe_ne_zero {r : NNReal} :
                            r 0 r 0
                            theorem NNReal.coe_ne_one {r : NNReal} :
                            r 1 r 1

                            Coercion ℝ≥0 → ℝ as a RingHom.

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

                            Equations
                              Instances For

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

                                Equations
                                  theorem NNReal.smul_def {M : Type u_1} [MulAction M] (c : NNReal) (x : M) :
                                  c x = c x

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

                                  Equations

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

                                    Equations
                                      @[simp]
                                      theorem NNReal.coe_pow (r : NNReal) (n : ) :
                                      ↑(r ^ n) = r ^ n
                                      @[simp]
                                      theorem NNReal.coe_zpow (r : NNReal) (n : ) :
                                      ↑(r ^ n) = r ^ n
                                      @[simp]
                                      theorem NNReal.coe_nsmul (r : NNReal) (n : ) :
                                      ↑(n r) = n r
                                      @[simp]
                                      theorem NNReal.coe_nnqsmul (q : ℚ≥0) (x : NNReal) :
                                      ↑(q x) = q x
                                      @[simp]
                                      theorem NNReal.coe_natCast (n : ) :
                                      n = n
                                      @[simp]
                                      theorem NNReal.coe_le_coe {r₁ r₂ : NNReal} :
                                      r₁ r₂ r₁ r₂
                                      @[simp]
                                      theorem NNReal.coe_lt_coe {r₁ r₂ : NNReal} :
                                      r₁ < r₂ r₁ < r₂
                                      @[simp]
                                      theorem NNReal.coe_pos {r : NNReal} :
                                      0 < r 0 < r
                                      @[simp]
                                      theorem NNReal.one_le_coe {r : NNReal} :
                                      1 r 1 r
                                      @[simp]
                                      theorem NNReal.one_lt_coe {r : NNReal} :
                                      1 < r 1 < r
                                      @[simp]
                                      theorem NNReal.coe_le_one {r : NNReal} :
                                      r 1 r 1
                                      @[simp]
                                      theorem NNReal.coe_lt_one {r : NNReal} :
                                      r < 1 r < 1
                                      theorem Real.toNNReal_mono {r₁ r₂ : } (h : r₁ r₂) :
                                      @[simp]
                                      theorem Real.toNNReal_coe {r : NNReal} :
                                      (↑r).toNNReal = r
                                      @[simp]
                                      theorem NNReal.mk_natCast (n : ) :
                                      n, = n
                                      @[simp]
                                      theorem Real.toNNReal_coe_nat (n : ) :
                                      (↑n).toNNReal = n

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

                                      Equations
                                        Instances For
                                          def NNReal.orderIsoIccZeroCoe (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.

                                          Equations
                                            Instances For
                                              @[simp]
                                              theorem NNReal.orderIsoIccZeroCoe_apply_coe_coe (a : NNReal) (b : (Set.Icc 0 a)) :
                                              (a.orderIsoIccZeroCoe b) = b
                                              theorem NNReal.coe_image {s : Set NNReal} :
                                              toReal '' s = {x : | ∃ (h : 0 x), x, h s}
                                              @[simp]
                                              theorem NNReal.coe_iSup {ι : Sort u_2} (s : ιNNReal) :
                                              (⨆ (i : ι), s i) = ⨆ (i : ι), (s i)
                                              theorem NNReal.coe_iInf {ι : Sort u_2} (s : ιNNReal) :
                                              (⨅ (i : ι), s i) = ⨅ (i : ι), (s i)
                                              theorem NNReal.lt_iff_exists_rat_btwn (a b : NNReal) :
                                              a < b ∃ (q : ), 0 q a < (↑q).toNNReal (↑q).toNNReal < b
                                              theorem NNReal.mul_sup (a b c : NNReal) :
                                              a * max b c = max (a * b) (a * c)
                                              theorem NNReal.sup_mul (a b c : NNReal) :
                                              max a b * c = max (a * c) (b * c)
                                              @[simp]
                                              theorem NNReal.coe_max (x y : NNReal) :
                                              (max x y) = max x y
                                              @[simp]
                                              theorem NNReal.coe_min (x y : NNReal) :
                                              (min x y) = min x y
                                              @[simp]
                                              theorem NNReal.zero_le_coe {q : NNReal} :
                                              0 q
                                              @[simp]
                                              theorem Real.coe_toNNReal' (r : ) :
                                              r.toNNReal = max r 0
                                              @[simp]
                                              theorem Real.toNNReal_pos {r : } :
                                              0 < r.toNNReal 0 < r
                                              theorem Real.toNNReal_eq_iff_eq_coe {r : } {p : NNReal} (hp : p 0) :
                                              r.toNNReal = p r = p
                                              @[simp]
                                              theorem Real.toNNReal_eq_one {r : } :
                                              r.toNNReal = 1 r = 1
                                              @[simp]
                                              theorem Real.toNNReal_eq_natCast {r : } {n : } (hn : n 0) :
                                              r.toNNReal = n r = n
                                              @[simp]
                                              theorem Real.toNNReal_le_toNNReal_iff {r p : } (hp : 0 p) :
                                              @[simp]
                                              theorem Real.one_lt_toNNReal {r : } :
                                              1 < r.toNNReal 1 < r
                                              @[simp]
                                              theorem Real.toNNReal_le_natCast {r : } {n : } :
                                              r.toNNReal n r n
                                              @[simp]
                                              theorem Real.natCast_lt_toNNReal {r : } {n : } :
                                              n < r.toNNReal n < r
                                              @[simp]
                                              theorem Real.ofNat_lt_toNNReal {r : } {n : } [n.AtLeastTwo] :
                                              @[simp]
                                              theorem Real.toNNReal_eq_toNNReal_iff {r p : } (hr : 0 r) (hp : 0 p) :
                                              @[simp]
                                              theorem Real.toNNReal_lt_one {r : } :
                                              r.toNNReal < 1 r < 1
                                              @[simp]
                                              theorem Real.natCastle_toNNReal' {n : } {r : } :
                                              n r.toNNReal n r n = 0
                                              @[simp]
                                              theorem Real.toNNReal_lt_natCast' {n : } {r : } :
                                              r.toNNReal < n r < n n 0
                                              theorem Real.natCast_le_toNNReal {n : } {r : } (hn : n 0) :
                                              n r.toNNReal n r
                                              theorem Real.toNNReal_lt_natCast {r : } {n : } (hn : n 0) :
                                              r.toNNReal < n r < n
                                              @[simp]
                                              theorem Real.toNNReal_add {r p : } (hr : 0 r) (hp : 0 p) :
                                              theorem Real.toNNReal_add_toNNReal {r p : } (hr : 0 r) (hp : 0 p) :
                                              theorem Real.le_toNNReal_iff_coe_le {r : NNReal} {p : } (hp : 0 p) :
                                              r p.toNNReal r p
                                              theorem Real.le_toNNReal_iff_coe_le' {r : NNReal} {p : } (hr : 0 < r) :
                                              r p.toNNReal r p
                                              theorem Real.toNNReal_lt_iff_lt_coe {r : } {p : NNReal} (ha : 0 r) :
                                              r.toNNReal < p r < p
                                              theorem Real.toNNReal_pow {x : } (hx : 0 x) (n : ) :
                                              (x ^ n).toNNReal = x.toNNReal ^ n
                                              theorem Real.toNNReal_zpow {x : } (hx : 0 x) (n : ) :
                                              (x ^ n).toNNReal = x.toNNReal ^ n
                                              theorem Real.toNNReal_mul {p q : } (hp : 0 p) :
                                              theorem NNReal.mul_eq_mul_left {a b c : NNReal} (h : a 0) :
                                              a * b = a * c b = c
                                              theorem NNReal.pow_antitone_exp {a : NNReal} (m n : ) (mn : m n) (a1 : a 1) :
                                              a ^ n a ^ m
                                              theorem NNReal.exists_pow_lt_of_lt_one {a b : NNReal} (ha : 0 < a) (hb : b < 1) :
                                              ∃ (n : ), b ^ n < a
                                              theorem NNReal.exists_mem_Ico_zpow {x y : NNReal} (hx : x 0) (hy : 1 < y) :
                                              ∃ (n : ), x Set.Ico (y ^ n) (y ^ (n + 1))
                                              theorem NNReal.exists_mem_Ioc_zpow {x y : NNReal} (hx : x 0) (hy : 1 < y) :
                                              ∃ (n : ), x Set.Ioc (y ^ n) (y ^ (n + 1))

                                              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.sub_def {r p : NNReal} :
                                              r - p = (r - p).toNNReal
                                              theorem NNReal.coe_sub_def {r p : NNReal} :
                                              ↑(r - p) = max (r - p) 0
                                              @[simp]
                                              theorem NNReal.inv_le {r p : NNReal} (h : r 0) :
                                              r⁻¹ p 1 r * p
                                              @[simp]
                                              theorem NNReal.le_inv_iff_mul_le {r p : NNReal} (h : p 0) :
                                              r p⁻¹ r * p 1
                                              @[simp]
                                              theorem NNReal.lt_inv_iff_mul_lt {r p : NNReal} (h : p 0) :
                                              r < p⁻¹ r * p < 1
                                              theorem NNReal.div_le_of_le_mul {a b c : NNReal} (h : a b * c) :
                                              a / c b
                                              theorem NNReal.div_le_of_le_mul' {a b c : NNReal} (h : a b * c) :
                                              a / b c
                                              theorem NNReal.mul_lt_of_lt_div {a b r : NNReal} (h : a < b / r) :
                                              a * r < b
                                              theorem NNReal.le_of_forall_lt_one_mul_le {x y : NNReal} (h : a < 1, a * x y) :
                                              x y
                                              theorem NNReal.half_lt_self {a : NNReal} (h : a 0) :
                                              a / 2 < a
                                              theorem NNReal.div_lt_one_of_lt {a b : NNReal} (h : a < b) :
                                              a / b < 1
                                              theorem Real.toNNReal_div {x y : } (hx : 0 x) :
                                              theorem Real.toNNReal_div' {x y : } (hy : 0 y) :
                                              theorem NNReal.inv_lt_one_iff {x : NNReal} (hx : x 0) :
                                              x⁻¹ < 1 1 < x
                                              theorem NNReal.inv_lt_inv {x y : NNReal} (hx : x 0) (h : x < y) :
                                              theorem NNReal.exists_nat_pos_inv_lt {b : NNReal} (hb : 0 < b) :
                                              ∃ (n : ), 0 < n (↑n)⁻¹ < b
                                              @[simp]
                                              theorem NNReal.abs_eq (x : NNReal) :
                                              |x| = x
                                              theorem NNReal.iSup_of_not_bddAbove {ι : Sort u_1} {f : ιNNReal} (hf : ¬BddAbove (Set.range f)) :
                                              ⨆ (i : ι), f i = 0
                                              theorem NNReal.iSup_empty {ι : Sort u_1} [IsEmpty ι] (f : ιNNReal) :
                                              ⨆ (i : ι), f i = 0
                                              theorem NNReal.iInf_empty {ι : Sort u_1} [IsEmpty ι] (f : ιNNReal) :
                                              ⨅ (i : ι), f i = 0
                                              @[simp]
                                              theorem NNReal.iSup_eq_zero {ι : Sort u_1} {f : ιNNReal} (hf : BddAbove (Set.range f)) :
                                              ⨆ (i : ι), f i = 0 ∀ (i : ι), f i = 0
                                              @[simp]
                                              theorem NNReal.iInf_const_zero {α : Sort u_2} :
                                              ⨅ (x : α), 0 = 0

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

                                              Equations
                                                Instances For
                                                  @[simp]
                                                  theorem Real.coe_nnabs (x : ) :
                                                  (nnabs x) = |x|
                                                  @[simp]
                                                  theorem Real.nnabs_of_nonneg {x : } (h : 0 x) :
                                                  @[simp]
                                                  theorem Real.nnabs_pos {x : } :
                                                  0 < nnabs x x 0
                                                  theorem Real.nnreal_dichotomy (r : ) :
                                                  ∃ (x : NNReal), r = x r = -x

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

                                                  theorem Real.nnreal_trichotomy (r : ) :
                                                  r = 0 ∃ (x : NNReal), 0 < x (r = x r = -x)

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

                                                  theorem Real.nnreal_induction_on {motive : Prop} (nonneg : ∀ (x : NNReal), motive x) (nonpos : ∀ (x : NNReal), motive xmotive (-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' {motive : Prop} (zero : motive 0) (pos : ∀ (x : NNReal), 0 < xmotive x) (neg : ∀ (x : NNReal), 0 < xmotive xmotive (-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 {Γ₀ : Type u_1} [LinearOrderedCommGroupWithZero Γ₀] [h : Nontrivial Γ₀ˣ] {f : Γ₀ →*₀ NNReal} (hf : StrictMono f) {r : NNReal} (hr : 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 {Γ₀ : Type u_1} [LinearOrderedCommGroupWithZero Γ₀] [h : Nontrivial Γ₀ˣ] {f : Γ₀ →*₀ NNReal} (hf : StrictMono f) {r : } (hr : 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.

                                                  unsafe instance instReprNNReal :

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

                                                  Equations
                                                    theorem Mathlib.Meta.Positivity.nnreal_coe_pos {r : NNReal} :
                                                    0 < r0 < r

                                                    Alias of the reverse direction of NNReal.coe_pos.

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

                                                    Equations
                                                      Instances For

                                                        Alias of the reverse direction of Real.nnabs_pos.