Skip to content

Commit 045542d

Browse files
committed
feat(Data/ENNReal): more big operator lemmas (leanprover-community#40211)
Also fix the variable implicitness and and names of a few existing declarations. Renames: * `coe_finsetSum` to `ofNNReal_finsetSum` * `coe_finsetProd` to `ofNNReal_finsetProd`
1 parent 5135da2 commit 045542d

7 files changed

Lines changed: 45 additions & 24 deletions

File tree

Mathlib/Analysis/MeanInequalities.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,10 @@ lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p)
10121012
have := coe_le_coe.2 <| NNReal.inner_le_weight_mul_Lp s hp.le (fun i ↦ ENNReal.toNNReal (w i))
10131013
fun i ↦ ENNReal.toNNReal (f i)
10141014
rw [coe_mul] at this
1015-
simp_rw [coe_rpow_of_nonneg _ <| inv_nonneg.2 hp₀.le, coe_finsetSum, ← ENNReal.toNNReal_rpow,
1015+
simp_rw [coe_rpow_of_nonneg _ <| inv_nonneg.2 hp₀.le, ofNNReal_finsetSum, ← ENNReal.toNNReal_rpow,
10161016
← ENNReal.toNNReal_mul, sum_congr rfl fun i hi ↦ coe_toNNReal (H'.2 i hi)] at this
1017-
simp only [toNNReal_mul, coe_mul, sub_nonneg, hp₁.le, coe_rpow_of_nonneg, coe_finsetSum] at this
1017+
simp only [toNNReal_mul, coe_mul, sub_nonneg, hp₁.le, coe_rpow_of_nonneg, ofNNReal_finsetSum]
1018+
at this
10181019
convert! this using 2 with i hi
10191020
· obtain hw | hw := eq_or_ne (w i) 0
10201021
· simp [hw]

Mathlib/Analysis/MeanInequalitiesPow.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0∞) (hw' : ∑
254254
(fun i => (z i).toNNReal) ?_ hp
255255
-- verify the hypothesis `∑ i ∈ s, (w i).toNNReal = 1`, using `∑ i ∈ s, w i = 1` .
256256
have h_sum_nnreal : ∑ i ∈ s, w i = ↑(∑ i ∈ s, (w i).toNNReal) := by
257-
rw [coe_finsetSum]
258-
refine sum_congr rfl fun i hi => (coe_toNNReal ?_).symm
259-
refine (lt_top_of_sum_ne_top ?_ hi).ne
257+
push_cast
258+
congr! with i hi
259+
refine (coe_toNNReal (lt_top_of_sum_ne_top ?_ hi).ne).symm
260260
exact hw'.symm ▸ ENNReal.one_ne_top
261261
rwa [← coe_inj, ← h_sum_nnreal]
262262

Mathlib/Data/ENNReal/BigOperators.lean

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Johannes Hölzl, Yury Kudryashov
55
-/
66
module
77

8+
public import Mathlib.Algebra.BigOperators.Finsupp.Basic
89
public import Mathlib.Algebra.BigOperators.WithTop
910
public import Mathlib.Data.NNReal.Basic
1011
public import Mathlib.Data.ENNReal.Inv
@@ -18,41 +19,51 @@ interact with the order structure on `ℝ≥0∞`.
1819

1920
public section
2021

21-
open Set NNReal ENNReal
22+
open Set NNReal
2223

2324
namespace ENNReal
2425

2526
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
2627

2728
section OperationsAndInfty
2829

29-
variable {α : Type*}
30+
variable {ι M : Type*} [Zero M]
3031

3132
@[simp, norm_cast]
32-
theorem coe_finsetSum {s : Finset α} {f : α → ℝ≥0} : ↑(∑ a ∈ s, f a) = ∑ a ∈ s, (f a : ℝ≥0) :=
33-
map_sum ofNNRealHom f s
33+
lemma ofNNReal_finsetSum (s : Finset ι) (f : ι → ℝ≥0) : ↑(∑ i ∈ s, f i) = ∑ i ∈ s, ofNNReal (f i) :=
34+
map_sum ofNNRealHom ..
3435

35-
@[deprecated (since := "2026-04-08")] alias coe_finset_sum := coe_finsetSum
36+
@[deprecated (since := "2026-06-04")] alias coe_finsetSum := ofNNReal_finsetSum
37+
@[deprecated (since := "2026-04-08")] alias coe_finset_sum := ofNNReal_finsetSum
3638

3739
@[simp, norm_cast]
38-
theorem coe_finsetProd {s : Finset α} {f : α → ℝ≥0} : ↑(∏ a ∈ s, f a) = ∏ a ∈ s, (f a : ℝ≥0∞) :=
39-
map_prod ofNNRealHom f s
40+
lemma ofNNReal_finsetProd (s : Finset ι) (f : ι → ℝ≥0) :
41+
↑(∏ i ∈ s, f i) = ∏ i ∈ s, ofNNReal (f i) := map_prod ofNNRealHom f s
4042

41-
@[deprecated (since := "2026-04-08")] alias coe_finset_prod := coe_finsetProd
43+
@[deprecated (since := "2026-06-04")] alias coe_finsetProd := ofNNReal_finsetProd
44+
@[deprecated (since := "2026-04-08")] alias coe_finset_prod := ofNNReal_finsetProd
45+
46+
@[simp, norm_cast]
47+
lemma ofNNReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :
48+
f.sum g = f.sum (fun i m ↦ ofNNReal (g i m)) := map_finsuppSum ofNNRealHom ..
49+
50+
@[simp, norm_cast]
51+
lemma ofNNReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :
52+
f.prod g = f.prod (fun i m ↦ ofNNReal (g i m)) := map_finsuppProd ofNNRealHom ..
4253

4354
@[simp]
44-
theorem toNNReal_prod {ι : Type*} {s : Finset ι} {f : ι → ℝ≥0} :
55+
theorem toNNReal_prod (s : Finset ι) (f : ι → ℝ≥0) :
4556
(∏ i ∈ s, f i).toNNReal = ∏ i ∈ s, (f i).toNNReal :=
4657
map_prod toNNRealHom _ _
4758

4859
@[simp]
49-
theorem toReal_prod {ι : Type*} {s : Finset ι} {f : ι → ℝ≥0} :
60+
theorem toReal_prod (s : Finset ι) (f : ι → ℝ≥0) :
5061
(∏ i ∈ s, f i).toReal = ∏ i ∈ s, (f i).toReal :=
5162
map_prod toRealHom _ _
5263

5364
theorem ofReal_prod_of_nonneg {α : Type*} {s : Finset α} {f : α → ℝ} (hf : ∀ i, i ∈ s → 0 ≤ f i) :
5465
ENNReal.ofReal (∏ i ∈ s, f i) = ∏ i ∈ s, ENNReal.ofReal (f i) := by
55-
simp_rw [ENNReal.ofReal, ← coe_finsetProd, coe_inj]
66+
simp_rw [ENNReal.ofReal, ← ofNNReal_finsetProd, coe_inj]
5667
exact Real.toNNReal_prod_of_nonneg hf
5768

5869
theorem iInf_sum {ι α : Type*} {f : ι → α → ℝ≥0∞} {s : Finset α} [Nonempty ι]
@@ -98,7 +109,7 @@ theorem lt_top_of_sum_ne_top {s : Finset α} {f : α → ℝ≥0∞} (h : ∑ x
98109
infinity -/
99110
theorem toNNReal_sum {s : Finset α} {f : α → ℝ≥0∞} (hf : ∀ a ∈ s, f a ≠ ∞) :
100111
ENNReal.toNNReal (∑ a ∈ s, f a) = ∑ a ∈ s, ENNReal.toNNReal (f a) := by
101-
rw [← coe_inj, coe_toNNReal, coe_finsetSum, sum_congr rfl]
112+
rw [← coe_inj, coe_toNNReal, ofNNReal_finsetSum, sum_congr rfl]
102113
· intro x hx
103114
exact (coe_toNNReal (hf x hx)).symm
104115
· exact sum_ne_top.2 hf
@@ -111,7 +122,7 @@ theorem toReal_sum {s : Finset α} {f : α → ℝ≥0∞} (hf : ∀ a ∈ s, f
111122

112123
theorem ofReal_sum_of_nonneg {s : Finset α} {f : α → ℝ} (hf : ∀ i, i ∈ s → 0 ≤ f i) :
113124
ENNReal.ofReal (∑ i ∈ s, f i) = ∑ i ∈ s, ENNReal.ofReal (f i) := by
114-
simp_rw [ENNReal.ofReal, ← coe_finsetSum, coe_inj]
125+
simp_rw [ENNReal.ofReal, ← ofNNReal_finsetSum, coe_inj]
115126
exact Real.toNNReal_sum_of_nonneg hf
116127

117128
theorem sum_lt_sum_of_nonempty {s : Finset α} (hs : s.Nonempty) {f g : α → ℝ≥0∞}

Mathlib/Data/NNReal/Basic.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Johan Commelin
55
-/
66
module
77

8+
public import Mathlib.Algebra.BigOperators.Finsupp.Basic
89
public import Mathlib.Algebra.BigOperators.Expect
910
public import Mathlib.Algebra.Order.BigOperators.Group.Finset
1011
public import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset
@@ -34,6 +35,7 @@ open Function Set
3435
open scoped BigOperators
3536

3637
namespace NNReal
38+
variable {M : Type*} [Zero M]
3739

3840
noncomputable instance : FloorSemiring ℝ≥0 := inferInstanceAs <| FloorSemiring (Subtype _)
3941

@@ -79,6 +81,14 @@ variable {ι : Type*} {s : Finset ι} {f : ι → ℝ}
7981
theorem coe_sum (s : Finset ι) (f : ι → ℝ≥0) : ∑ i ∈ s, f i = ∑ i ∈ s, (f i : ℝ) :=
8082
map_sum toRealHom _ _
8183

84+
@[simp, norm_cast]
85+
lemma toReal_finsuppSum (f : ι →₀ M) (g : ι → M → ℝ≥0) :
86+
f.sum g = f.sum (fun i m ↦ toReal (g i m)) := map_finsuppSum toRealHom ..
87+
88+
@[simp, norm_cast]
89+
lemma toReal_finsuppProd (f : ι →₀ M) (g : ι → M → ℝ≥0) :
90+
f.prod g = f.prod (fun i m ↦ toReal (g i m)) := map_finsuppProd toRealHom ..
91+
8292
@[simp, norm_cast]
8393
lemma coe_expect (s : Finset ι) (f : ι → ℝ≥0) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : ℝ) :=
8494
map_expect toRealHom ..

Mathlib/MeasureTheory/Measure/HasOuterApproxClosedProd.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ lemma ext_of_integral_prod_mul_prod_boundedContinuousFunction
165165
μ = ν := by
166166
refine ext_of_lintegral_prod_mul_prod_boundedContinuousFunction fun f g ↦ ?_
167167
rw [← toReal_eq_toReal_iff']
168-
· simp only [coe_finsetProd]
168+
· simp only [ofNNReal_finsetProd]
169169
have {μ : Measure ((Π i, X i) × Π j, Y j)} :
170170
(∫⁻ p, (∏ i, (f i (p.1 i) : ℝ≥0∞)) * ∏ j, (g j (p.2 j) : ℝ≥0∞) ∂μ).toReal =
171171
∫ p, (∏ i, (f i (p.1 i)).toReal) * ∏ j, (g j (p.2 j)).toReal ∂μ := by

Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ theorem convexBodyLT_volume :
110110
simp_rw [convexBodyLTFactor, coe_mul, ENNReal.coe_pow]
111111
ring
112112
_ = (convexBodyLTFactor K) * ∏ w, (f w) ^ (mult w) := by
113-
simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finsetProd, mult_isReal, mult_isComplex,
113+
simp_rw [prod_eq_prod_mul_prod, coe_mul, ofNNReal_finsetProd, mult_isReal, mult_isComplex,
114114
pow_one, ENNReal.coe_pow, ofReal_coe_nnreal]
115115

116116
variable {f}
@@ -241,7 +241,7 @@ theorem convexBodyLT'_volume :
241241
simp_rw [coe_mul, ENNReal.coe_pow]
242242
ring
243243
_ = convexBodyLT'Factor K * ∏ w, (f w) ^ (mult w) := by
244-
simp_rw [prod_eq_prod_mul_prod, coe_mul, coe_finsetProd, mult_isReal, mult_isComplex,
244+
simp_rw [prod_eq_prod_mul_prod, coe_mul, ofNNReal_finsetProd, mult_isReal, mult_isComplex,
245245
pow_one, ENNReal.coe_pow, ofReal_coe_nnreal, mul_assoc]
246246

247247
end convexBodyLT'

Mathlib/Topology/Algebra/InfiniteSum/ENNReal.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ variable {f g : α → ℝ≥0∞}
4444
@[norm_cast]
4545
protected theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} :
4646
HasSum (fun a => (f a : ℝ≥0∞)) ↑r ↔ HasSum f r := by
47-
simp only [HasSum, ← coe_finsetSum, tendsto_coe]
47+
simp only [HasSum, ← ofNNReal_finsetSum, tendsto_coe]
4848

4949
protected theorem tsum_coe_eq {f : α → ℝ≥0} (h : HasSum f r) : (∑' a, (f a : ℝ≥0∞)) = r :=
5050
(ENNReal.hasSum_coe.2 h).tsum_eq
@@ -384,8 +384,7 @@ the sequence of partial sum converges to `r`. -/
384384
theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0} {r : ℝ≥0} :
385385
HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 r) := by
386386
rw [← ENNReal.hasSum_coe, ENNReal.hasSum_iff_tendsto_nat]
387-
simp only [← ENNReal.coe_finsetSum]
388-
exact ENNReal.tendsto_coe
387+
norm_cast
389388

390389
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
391390
¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop atTop := by

0 commit comments

Comments
 (0)