Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 1d37ff1

Browse files
committed
feat(analysis/mean_inequalities): add weighted generalized mean inequality for ennreal (#5316)
1 parent cecab59 commit 1d37ff1

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

src/analysis/mean_inequalities.lean

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,75 @@ by exact_mod_cast real.arith_mean_le_rpow_mean s _ _ (λ i _, (w i).coe_nonneg)
252252

253253
end nnreal
254254

255+
namespace ennreal
256+
257+
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ennreal`-valued
258+
functions and real exponents. -/
259+
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ennreal) (hw' : ∑ i in s, w i = 1) {p : ℝ}
260+
(hp : 1 ≤ p) :
261+
(∑ i in s, w i * z i) ^ p ≤ ∑ i in s, (w i * z i ^ p) :=
262+
begin
263+
have hp_pos : 0 < p, from lt_of_lt_of_le zero_lt_one hp,
264+
have hp_nonneg : 0 ≤ p, from le_of_lt hp_pos,
265+
have hp_not_nonpos : ¬ p ≤ 0, by simp [hp_pos],
266+
have hp_not_neg : ¬ p < 0, by simp [hp_nonneg],
267+
have h_top_iff_rpow_top : ∀ (i : ι) (hi : i ∈ s), w i * z i = ⊤ ↔ w i * (z i) ^ p = ⊤,
268+
by simp [hp_pos, hp_nonneg, hp_not_nonpos, hp_not_neg],
269+
refine le_of_top_imp_top_of_to_nnreal_le _ _,
270+
{ -- first, prove `(∑ i in s, w i * z i) ^ p = ⊤ → ∑ i in s, (w i * z i ^ p) = ⊤`
271+
rw [rpow_eq_top_iff, sum_eq_top_iff, sum_eq_top_iff],
272+
intro h,
273+
simp only [and_false, hp_not_neg, false_or] at h,
274+
rcases h.left with ⟨a, H, ha⟩,
275+
use [a, H],
276+
rwa ←h_top_iff_rpow_top a H, },
277+
{ -- second, suppose both `(∑ i in s, w i * z i) ^ p ≠ ⊤` and `∑ i in s, (w i * z i ^ p) ≠ ⊤`,
278+
-- and prove `((∑ i in s, w i * z i) ^ p).to_nnreal ≤ (∑ i in s, (w i * z i ^ p)).to_nnreal`,
279+
-- by using `nnreal.rpow_arith_mean_le_arith_mean_rpow`.
280+
intros h_top_rpow_sum _,
281+
-- show hypotheses needed to put the `.to_nnreal` inside the sums.
282+
have h_top : ∀ (a : ι), a ∈ s → w a * z a < ⊤,
283+
{ have h_top_sum : ∑ (i : ι) in s, w i * z i < ⊤,
284+
{ by_contra h,
285+
rw [lt_top_iff_ne_top, not_not] at h,
286+
rw [h, top_rpow_of_pos hp_pos] at h_top_rpow_sum,
287+
exact h_top_rpow_sum rfl, },
288+
rwa sum_lt_top_iff at h_top_sum, },
289+
have h_top_rpow : ∀ (a : ι), a ∈ s → w a * z a ^ p < ⊤,
290+
{ intros i hi,
291+
specialize h_top i hi,
292+
rw lt_top_iff_ne_top at h_top ⊢,
293+
rwa [ne.def, ←h_top_iff_rpow_top i hi], },
294+
-- put the `.to_nnreal` inside the sums.
295+
simp_rw [to_nnreal_sum h_top_rpow, ←to_nnreal_rpow, to_nnreal_sum h_top, to_nnreal_mul,
296+
←to_nnreal_rpow],
297+
-- use corresponding nnreal result
298+
refine nnreal.rpow_arith_mean_le_arith_mean_rpow s (λ i, (w i).to_nnreal) (λ i, (z i).to_nnreal)
299+
_ hp,
300+
-- verify the hypothesis `∑ i in s, (w i).to_nnreal = 1`, using `∑ i in s, w i = 1` .
301+
have h_sum_nnreal : (∑ i in s, w i) = ↑(∑ i in s, (w i).to_nnreal),
302+
{ have hw_top : ∑ i in s, w i < ⊤, by { rw hw', exact one_lt_top, },
303+
rw ←to_nnreal_sum,
304+
{ rw coe_to_nnreal,
305+
rwa ←lt_top_iff_ne_top, },
306+
{ rwa sum_lt_top_iff at hw_top, }, },
307+
rwa [←coe_eq_coe, ←h_sum_nnreal], },
308+
end
309+
310+
/-- Weighted generalized mean inequality, version for two elements of `ennreal` and real
311+
exponents. -/
312+
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ennreal) (hw' : w₁ + w₂ = 1) {p : ℝ}
313+
(hp : 1 ≤ p) :
314+
(w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p :=
315+
begin
316+
have h := rpow_arith_mean_le_arith_mean_rpow (univ : finset (fin 2))
317+
(fin.cons w₁ $ fin.cons w₂ fin_zero_elim) (fin.cons z₁ $ fin.cons z₂ $ fin_zero_elim) _ hp,
318+
{ simpa [fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero] using h, },
319+
{ simp [hw', fin.sum_univ_succ, fin.sum_univ_zero, fin.cons_succ, fin.cons_zero], },
320+
end
321+
322+
end ennreal
323+
255324
namespace real
256325

257326
theorem geom_mean_le_arith_mean2_weighted {w₁ w₂ p₁ p₂ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)

src/data/real/ennreal.lean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,20 @@ coe_mono.map_min
500500
@[norm_cast] lemma coe_max : ((max r p:ℝ≥0):ennreal) = max r p :=
501501
coe_mono.map_max
502502

503+
lemma le_of_top_imp_top_of_to_nnreal_le {a b : ennreal} (h : a = ⊤ → b = ⊤)
504+
(h_nnreal : a ≠ ⊤ → b ≠ ⊤ → a.to_nnreal ≤ b.to_nnreal) :
505+
a ≤ b :=
506+
begin
507+
by_cases ha : a = ⊤,
508+
{ rw h ha,
509+
exact le_top, },
510+
by_cases hb : b = ⊤,
511+
{ rw hb,
512+
exact le_top, },
513+
rw [←coe_to_nnreal hb, ←coe_to_nnreal ha, coe_le_coe],
514+
exact h_nnreal ha hb,
515+
end
516+
503517
end order
504518

505519
section complete_lattice
@@ -1297,6 +1311,16 @@ def to_nnreal_hom : ennreal →* ℝ≥0 :=
12971311
map_mul' := by rintro (_|x) (_|y); simp only [← coe_mul, none_eq_top, some_eq_coe,
12981312
to_nnreal_top_mul, to_nnreal_mul_top, top_to_nnreal, mul_zero, zero_mul, to_nnreal_coe] }
12991313

1314+
lemma to_nnreal_mul {a b : ennreal}: (a * b).to_nnreal = a.to_nnreal * b.to_nnreal :=
1315+
to_nnreal_hom.map_mul a b
1316+
1317+
lemma to_nnreal_pow (a : ennreal) (n : ℕ) : (a ^ n).to_nnreal = a.to_nnreal ^ n :=
1318+
to_nnreal_hom.map_pow a n
1319+
1320+
lemma to_nnreal_prod {ι : Type*} {s : finset ι} {f : ι → ennreal} :
1321+
(∏ i in s, f i).to_nnreal = ∏ i in s, (f i).to_nnreal :=
1322+
to_nnreal_hom.map_prod _ _
1323+
13001324
/-- `ennreal.to_real` as a `monoid_hom`. -/
13011325
def to_real_hom : ennreal →* ℝ :=
13021326
(nnreal.to_real_hom : ℝ≥0 →* ℝ).comp to_nnreal_hom

0 commit comments

Comments
 (0)