mathlib documentation

data.real.nnreal

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 can_lift ℝ ℝ≥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 occurences of x with ↑x. This tactic also works for a function f : α → ℝ with a hypothesis hf : ∀ x, 0 ≤ f x.

Notations #

This file defines ℝ≥0 as a localized notation for nnreal.

@[protected, instance]
@[protected, instance]
@[protected, instance]
@[protected, instance]
@[protected, instance]
@[protected, instance]
@[protected, instance]
noncomputable def nnreal.has_sub  :
@[protected, instance]
@[protected, instance]
def nnreal  :
Type

Nonnegative real numbers.

Equations
@[protected, instance]
noncomputable def nnreal.has_div  :
@[protected, instance]
Equations
@[simp]
theorem nnreal.val_eq_coe (n : ℝ≥0) :
n.val = n
@[protected, instance]
Equations
@[protected]
theorem nnreal.eq {n m : ℝ≥0} :
n = mn = m
@[protected]
theorem nnreal.eq_iff {n m : ℝ≥0} :
n = m n = m
theorem nnreal.ne_iff {x y : ℝ≥0} :
x y x y
noncomputable def real.to_nnreal (r : ) :

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

Equations
theorem real.coe_to_nnreal (r : ) (hr : 0 r) :
theorem nnreal.coe_nonneg (r : ℝ≥0) :
0 r
@[norm_cast]
theorem nnreal.coe_mk (a : ) (ha : 0 a) :
a, ha⟩ = a
@[protected, simp, norm_cast]
theorem nnreal.coe_eq {r₁ r₂ : ℝ≥0} :
r₁ = r₂ r₁ = r₂
@[protected]
theorem nnreal.coe_zero  :
0 = 0
@[protected]
theorem nnreal.coe_one  :
1 = 1
@[protected]
theorem nnreal.coe_add (r₁ r₂ : ℝ≥0) :
(r₁ + r₂) = r₁ + r₂
@[protected]
theorem nnreal.coe_mul (r₁ r₂ : ℝ≥0) :
r₁ * r₂ = (r₁) * r₂
@[protected]
theorem nnreal.coe_inv (r : ℝ≥0) :
@[protected]
theorem nnreal.coe_div (r₁ r₂ : ℝ≥0) :
(r₁ / r₂) = r₁ / r₂
@[protected, simp, norm_cast]
theorem nnreal.coe_bit0 (r : ℝ≥0) :
@[protected, simp, norm_cast]
theorem nnreal.coe_bit1 (r : ℝ≥0) :
@[protected, simp, norm_cast]
theorem nnreal.coe_sub {r₁ r₂ : ℝ≥0} (h : r₂ r₁) :
(r₁ - r₂) = r₁ - r₂
@[protected, simp, norm_cast]
theorem nnreal.coe_eq_zero (r : ℝ≥0) :
r = 0 r = 0
@[protected, simp, norm_cast]
theorem nnreal.coe_eq_one (r : ℝ≥0) :
r = 1 r = 1
theorem nnreal.coe_ne_zero {r : ℝ≥0} :
r 0 r 0
@[protected, instance]
def nnreal.mul_action {M : Type u_1} [mul_action M] :

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

Equations
theorem nnreal.smul_def {M : Type u_1} [mul_action M] (c : ℝ≥0) (x : M) :
c x = c x
@[protected, instance]
def nnreal.is_scalar_tower {M : Type u_1} {N : Type u_2} [mul_action M] [mul_action N] [has_scalar M N] [is_scalar_tower M N] :
@[protected, instance]
def nnreal.smul_comm_class_left {M : Type u_1} {N : Type u_2} [mul_action N] [has_scalar M N] [smul_comm_class M N] :
@[protected, instance]
def nnreal.smul_comm_class_right {M : Type u_1} {N : Type u_2} [mul_action N] [has_scalar M N] [smul_comm_class M N] :
@[protected, instance]
def nnreal.module {M : Type u_1} [add_comm_monoid M] [module M] :

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

Equations
@[protected, instance]
def nnreal.algebra {A : Type u_1} [semiring A] [algebra A] :

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

Equations
@[simp, norm_cast]
theorem nnreal.coe_indicator {α : Type u_1} (s : set α) (f : α → ℝ≥0) (a : α) :
(s.indicator f a) = s.indicator (λ (x : α), (f x)) a
@[simp, norm_cast]
theorem nnreal.coe_pow (r : ℝ≥0) (n : ) :
(r ^ n) = r ^ n
@[simp, norm_cast]
theorem nnreal.coe_zpow (r : ℝ≥0) (n : ) :
(r ^ n) = r ^ n
@[norm_cast]
theorem nnreal.coe_list_sum (l : list ℝ≥0) :
@[norm_cast]
@[norm_cast]
@[norm_cast]
@[norm_cast]
theorem nnreal.coe_sum {α : Type u_1} {s : finset α} {f : α → ℝ≥0} :
∑ (a : α) in s, f a = ∑ (a : α) in s, (f a)
theorem real.to_nnreal_sum_of_nonneg {α : Type u_1} {s : finset α} {f : α → } (hf : ∀ (a : α), a s0 f a) :
(∑ (a : α) in s, f a).to_nnreal = ∑ (a : α) in s, (f a).to_nnreal
@[norm_cast]
theorem nnreal.coe_prod {α : Type u_1} {s : finset α} {f : α → ℝ≥0} :
∏ (a : α) in s, f a = ∏ (a : α) in s, (f a)
theorem real.to_nnreal_prod_of_nonneg {α : Type u_1} {s : finset α} {f : α → } (hf : ∀ (a : α), a s0 f a) :
(∏ (a : α) in s, f a).to_nnreal = ∏ (a : α) in s, (f a).to_nnreal
theorem nnreal.nsmul_coe (r : ℝ≥0) (n : ) :
(n r) = n r
@[protected, simp, norm_cast]
theorem nnreal.coe_nat_cast (n : ) :
@[protected, simp, norm_cast]
theorem nnreal.coe_le_coe {r₁ r₂ : ℝ≥0} :
r₁ r₂ r₁ r₂
@[protected, simp, norm_cast]
theorem nnreal.coe_lt_coe {r₁ r₂ : ℝ≥0} :
r₁ < r₂ r₁ < r₂
@[protected, simp, norm_cast]
theorem nnreal.coe_pos {r : ℝ≥0} :
0 < r 0 < r
@[protected]
@[simp]
theorem real.to_nnreal_coe {r : ℝ≥0} :
@[simp]
theorem nnreal.mk_coe_nat (n : ) :
n, _⟩ = n
@[simp]

real.to_nnreal and coe : ℝ≥0 → ℝ form a Galois insertion.

Equations
theorem nnreal.coe_Sup (s : set ℝ≥0) :
(Sup s) = Sup (coe '' s)
theorem nnreal.coe_Inf (s : set ℝ≥0) :
(Inf s) = Inf (coe '' s)
theorem nnreal.le_of_forall_pos_le_add {a b : ℝ≥0} (h : ∀ (ε : ℝ≥0), 0 < εa b + ε) :
a b
theorem nnreal.le_of_add_le_left {a b c : ℝ≥0} (h : a + b c) :
a c
theorem nnreal.le_of_add_le_right {a b c : ℝ≥0} (h : a + b c) :
b c
theorem nnreal.lt_iff_exists_rat_btwn (a b : ℝ≥0) :
a < b ∃ (q : ), 0 q a < q.to_nnreal q.to_nnreal < b
theorem nnreal.bot_eq_zero  :
= 0
theorem nnreal.mul_sup (a b c : ℝ≥0) :
a * (b c) = a * b a * c
theorem nnreal.mul_finset_sup {α : Type u_1} {f : α → ℝ≥0} {s : finset α} (r : ℝ≥0) :
r * s.sup f = s.sup (λ (a : α), r * f a)
theorem nnreal.finset_sup_div {α : Type u_1} {f : α → ℝ≥0} {s : finset α} (r : ℝ≥0) :
s.sup f / r = s.sup (λ (a : α), f a / r)
@[simp, norm_cast]
theorem nnreal.coe_max (x y : ℝ≥0) :
(max x y) = max x y
@[simp, norm_cast]
theorem nnreal.coe_min (x y : ℝ≥0) :
(min x y) = min x y
@[simp]
theorem nnreal.zero_le_coe {q : ℝ≥0} :
0 q
@[simp]
theorem real.to_nnreal_zero  :
@[simp]
theorem real.to_nnreal_one  :
@[simp]
theorem real.to_nnreal_pos {r : } :
0 < r.to_nnreal 0 < r
@[simp]
theorem real.to_nnreal_eq_zero {r : } :
r.to_nnreal = 0 r 0
theorem real.to_nnreal_of_nonpos {r : } :
r 0r.to_nnreal = 0
@[simp]
theorem real.coe_to_nnreal' (r : ) :
@[simp]
theorem real.to_nnreal_le_to_nnreal_iff {r p : } (hp : 0 p) :
@[simp]
theorem real.to_nnreal_lt_to_nnreal_iff {r p : } (h : 0 < p) :
@[simp]
theorem real.to_nnreal_add {r p : } (hr : 0 r) (hp : 0 p) :
theorem real.to_nnreal_add_to_nnreal {r p : } (hr : 0 r) (hp : 0 p) :
theorem real.to_nnreal_le_to_nnreal {r p : } (h : r p) :
theorem real.le_to_nnreal_iff_coe_le {r : ℝ≥0} {p : } (hp : 0 p) :
theorem real.le_to_nnreal_iff_coe_le' {r : ℝ≥0} {p : } (hr : 0 < r) :
theorem real.to_nnreal_lt_iff_lt_coe {r : } {p : ℝ≥0} (ha : 0 r) :
@[simp]
theorem real.to_nnreal_bit0 {r : } (hr : 0 r) :
@[simp]
theorem real.to_nnreal_bit1 {r : } (hr : 0 r) :
theorem nnreal.mul_eq_mul_left {a b c : ℝ≥0} (h : a 0) :
a * b = a * c b = c
theorem real.to_nnreal_mul {p q : } (hp : 0 p) :
theorem nnreal.pow_antitone_exp {a : ℝ≥0} (m n : ) (mn : m n) (a1 : a 1) :
a ^ n a ^ m
theorem nnreal.exists_pow_lt_of_lt_one {a b : ℝ≥0} (ha : 0 < a) (hb : b < 1) :
∃ (n : ), b ^ n < a
theorem nnreal.exists_mem_Ico_zpow {x y : ℝ≥0} (hx : x 0) (hy : 1 < y) :
∃ (n : ), x set.Ico (y ^ n) (y ^ (n + 1))
theorem nnreal.exists_mem_Ioc_zpow {x y : ℝ≥0} (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 has_ordered_sub in the file algebra.order.sub. See also mul_tsub and tsub_mul.

theorem nnreal.sub_def {r p : ℝ≥0} :
r - p = (r - p).to_nnreal
theorem nnreal.coe_sub_def {r p : ℝ≥0} :
(r - p) = max (r - p) 0
theorem nnreal.sub_div (a b c : ℝ≥0) :
(a - b) / c = a / c - b / c
theorem nnreal.sum_div {ι : Type u_1} (s : finset ι) (f : ι → ℝ≥0) (b : ℝ≥0) :
(∑ (i : ι) in s, f i) / b = ∑ (i : ι) in s, f i / b
@[simp]
theorem nnreal.inv_pos {r : ℝ≥0} :
0 < r⁻¹ 0 < r
theorem nnreal.div_pos {r p : ℝ≥0} (hr : 0 < r) (hp : 0 < p) :
0 < r / p
@[protected]
theorem nnreal.mul_inv {r p : ℝ≥0} :
(r * p)⁻¹ = p⁻¹ * r⁻¹
theorem nnreal.div_self_le (r : ℝ≥0) :
r / r 1
@[simp]
theorem nnreal.inv_le {r p : ℝ≥0} (h : r 0) :
r⁻¹ p 1 r * p
theorem nnreal.inv_le_of_le_mul {r p : ℝ≥0} (h : 1 r * p) :
@[simp]
theorem nnreal.le_inv_iff_mul_le {r p : ℝ≥0} (h : p 0) :
r p⁻¹ r * p 1
@[simp]
theorem nnreal.lt_inv_iff_mul_lt {r p : ℝ≥0} (h : p 0) :
r < p⁻¹ r * p < 1
theorem nnreal.mul_le_iff_le_inv {a b r : ℝ≥0} (hr : r 0) :
r * a b a r⁻¹ * b
theorem nnreal.le_div_iff_mul_le {a b r : ℝ≥0} (hr : r 0) :
a b / r a * r b
theorem nnreal.div_le_iff {a b r : ℝ≥0} (hr : r 0) :
a / r b a b * r
theorem nnreal.div_le_iff' {a b r : ℝ≥0} (hr : r 0) :
a / r b a r * b
theorem nnreal.div_le_of_le_mul {a b c : ℝ≥0} (h : a b * c) :
a / c b
theorem nnreal.div_le_of_le_mul' {a b c : ℝ≥0} (h : a b * c) :
a / b c
theorem nnreal.le_div_iff {a b r : ℝ≥0} (hr : r 0) :
a b / r a * r b
theorem nnreal.le_div_iff' {a b r : ℝ≥0} (hr : r 0) :
a b / r r * a b
theorem nnreal.div_lt_iff {a b r : ℝ≥0} (hr : r 0) :
a / r < b a < b * r
theorem nnreal.div_lt_iff' {a b r : ℝ≥0} (hr : r 0) :
a / r < b a < r * b
theorem nnreal.lt_div_iff {a b r : ℝ≥0} (hr : r 0) :
a < b / r a * r < b
theorem nnreal.lt_div_iff' {a b r : ℝ≥0} (hr : r 0) :
a < b / r r * a < b
theorem nnreal.mul_lt_of_lt_div {a b r : ℝ≥0} (h : a < b / r) :
a * r < b
theorem nnreal.div_le_div_left_of_le {a b c : ℝ≥0} (b0 : 0 < b) (c0 : 0 < c) (cb : c b) :
a / b a / c
theorem nnreal.div_le_div_left {a b c : ℝ≥0} (a0 : 0 < a) (b0 : 0 < b) (c0 : 0 < c) :
a / b a / c c b
theorem nnreal.le_of_forall_lt_one_mul_le {x y : ℝ≥0} (h : ∀ (a : ℝ≥0), a < 1a * x y) :
x y
theorem nnreal.div_add_div_same (a b c : ℝ≥0) :
a / c + b / c = (a + b) / c
theorem nnreal.half_pos {a : ℝ≥0} (h : 0 < a) :
0 < a / 2
theorem nnreal.add_halves (a : ℝ≥0) :
a / 2 + a / 2 = a
theorem nnreal.half_lt_self {a : ℝ≥0} (h : a 0) :
a / 2 < a
theorem nnreal.div_lt_one_of_lt {a b : ℝ≥0} (h : a < b) :
a / b < 1
theorem nnreal.div_add_div (a : ℝ≥0) {b : ℝ≥0} (c : ℝ≥0) {d : ℝ≥0} (hb : b 0) (hd : d 0) :
a / b + c / d = (a * d + b * c) / b * d
theorem nnreal.add_div' (a b c : ℝ≥0) (hc : c 0) :
b + a / c = (b * c + a) / c
theorem nnreal.div_add' (a b c : ℝ≥0) (hc : c 0) :
a / c + b = (a + b * c) / c
theorem real.to_nnreal_div {x y : } (hx : 0 x) :
theorem real.to_nnreal_div' {x y : } (hy : 0 y) :
theorem nnreal.inv_lt_one_iff {x : ℝ≥0} (hx : x 0) :
x⁻¹ < 1 1 < x
theorem nnreal.inv_lt_one {x : ℝ≥0} (hx : 1 < x) :
x⁻¹ < 1
theorem nnreal.zpow_pos {x : ℝ≥0} (hx : x 0) (n : ) :
0 < x ^ n
@[simp]
theorem nnreal.abs_eq (x : ℝ≥0) :
noncomputable def real.nnabs  :

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

Equations
@[simp, norm_cast]
theorem real.coe_nnabs (x : ) :
@[simp]
theorem real.nnabs_of_nonneg {x : } (h : 0 x) :