Skip to content

Commit 29d85a0

Browse files
feat: {List,Multiset,Finset}.prod_le_sum (#31012)
1 parent 638d479 commit 29d85a0

File tree

6 files changed

+65
-35
lines changed

6 files changed

+65
-35
lines changed

Mathlib/Algebra/MvPolynomial/Degrees.lean

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,22 +430,17 @@ theorem totalDegree_monomial_le (s : σ →₀ ℕ) (c : R) :
430430
theorem totalDegree_X_pow [Nontrivial R] (s : σ) (n : ℕ) :
431431
(X s ^ n : MvPolynomial σ R).totalDegree = n := by simp [X_pow_eq_monomial, one_ne_zero]
432432

433-
theorem totalDegree_list_prod :
434-
∀ s : List (MvPolynomial σ R), s.prod.totalDegree ≤ (s.map MvPolynomial.totalDegree).sum
435-
| [] => by rw [List.prod_nil, totalDegree_one, List.map_nil, List.sum_nil]
436-
| p::ps => by
437-
grw [List.prod_cons, List.map, List.sum_cons, totalDegree_mul, totalDegree_list_prod]
433+
theorem totalDegree_list_prod (l : List (MvPolynomial σ R)) :
434+
l.prod.totalDegree ≤ (l.map MvPolynomial.totalDegree).sum :=
435+
l.apply_prod_le_sum_map _ totalDegree_one.le totalDegree_mul
438436

439437
theorem totalDegree_multiset_prod (s : Multiset (MvPolynomial σ R)) :
440-
s.prod.totalDegree ≤ (s.map MvPolynomial.totalDegree).sum := by
441-
refine Quotient.inductionOn s fun l => ?_
442-
rw [Multiset.quot_mk_to_coe, Multiset.prod_coe, Multiset.map_coe, Multiset.sum_coe]
443-
exact totalDegree_list_prod l
438+
s.prod.totalDegree ≤ (s.map MvPolynomial.totalDegree).sum :=
439+
s.apply_prod_le_sum_map _ totalDegree_one.le totalDegree_mul
444440

445441
theorem totalDegree_finset_prod {ι : Type*} (s : Finset ι) (f : ι → MvPolynomial σ R) :
446-
(s.prod f).totalDegree ≤ ∑ i ∈ s, (f i).totalDegree := by
447-
refine le_trans (totalDegree_multiset_prod _) ?_
448-
simp only [Multiset.map_map, comp_apply, Finset.sum_map_val, le_refl]
442+
(s.prod f).totalDegree ≤ ∑ i ∈ s, (f i).totalDegree :=
443+
s.apply_prod_le_sum_apply _ totalDegree_one.le totalDegree_mul
449444

450445
theorem totalDegree_finset_sum {ι : Type*} (s : Finset ι) (f : ι → MvPolynomial σ R) :
451446
(s.sum f).totalDegree ≤ Finset.sup s fun i => (f i).totalDegree := by

Mathlib/Algebra/Order/BigOperators/Group/Finset.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ lemma prod_image_le_of_one_le [MulLeftMono N]
236236

237237
end OrderedCommMonoid
238238

239+
section ProdSum
240+
241+
variable [CommMonoid α] [AddCommMonoid β] [Preorder β] [AddLeftMono β]
242+
(s : Finset ι) {f : ι → α} (g : α → β)
243+
244+
theorem apply_prod_le_sum_apply (h_one : g 10) (h_mul : ∀ (a b : α), g (a * b) ≤ g a + g b) :
245+
g (∏ x ∈ s, f x) ≤ ∑ x ∈ s, g (f x) := by
246+
refine (Multiset.apply_prod_le_sum_map _ _ h_one h_mul).trans_eq ?_
247+
rw [Multiset.map_map, Function.comp_def, Finset.sum_map_val]
248+
249+
theorem sum_apply_le_apply_prod (h_one : 0 ≤ g 1) (h_mul : ∀ (a b : α), g a + g b ≤ g (a * b)) :
250+
∑ x ∈ s, g (f x) ≤ g (∏ x ∈ s, f x) :=
251+
s.apply_prod_le_sum_apply (β := βᵒᵈ) g h_one h_mul
252+
253+
end ProdSum
254+
239255
@[to_additive]
240256
lemma max_prod_le [CommMonoid M] [LinearOrder M] [IsOrderedMonoid M] {f g : ι → M} {s : Finset ι} :
241257
max (s.prod f) (s.prod g) ≤ s.prod (fun i ↦ max (f i) (g i)) :=

Mathlib/Algebra/Order/BigOperators/Group/List.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,21 @@ lemma all_one_of_le_one_le_of_prod_eq_one [CommMonoid M] [PartialOrder M] [IsOrd
252252
· exact (length l)
253253
· rfl⟩
254254

255+
section ProdSum
256+
257+
variable {α β : Type*} [Monoid α] [AddMonoid β] [Preorder β] [AddLeftMono β]
258+
(l : List α) (f : α → β)
259+
260+
theorem apply_prod_le_sum_map (h_one : f 10) (h_mul : ∀ (a b : α), f (a * b) ≤ f a + f b) :
261+
f l.prod ≤ (l.map f).sum := by
262+
induction l with
263+
| nil => simp [h_one]
264+
| cons hd tl IH => simpa using (h_mul _ _).trans (add_le_add_left IH _)
265+
266+
theorem sum_map_le_apply_prod (h_one : 0 ≤ f 1) (h_mul : ∀ (a b : α), f a + f b ≤ f (a * b)) :
267+
(l.map f).sum ≤ f l.prod :=
268+
apply_prod_le_sum_map (β := βᵒᵈ) l f h_one h_mul
269+
270+
end ProdSum
271+
255272
end List

Mathlib/Algebra/Order/BigOperators/Group/Multiset.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,19 @@ lemma abs_sum_le_sum_abs [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid
165165
|s.sum| ≤ (s.map abs).sum :=
166166
le_sum_of_subadditive _ abs_zero.le abs_add_le s
167167

168+
section ProdSum
169+
170+
variable [CommMonoid α] [AddCommMonoid β] [Preorder β] [AddLeftMono β] (m : Multiset α) (f : α → β)
171+
172+
lemma apply_prod_le_sum_map (h_one : f 10) (h_mul : ∀ (a b : α), f (a * b) ≤ f a + f b) :
173+
f m.prod ≤ (m.map f).sum := by
174+
induction m using Quotient.inductionOn with
175+
| h l => simp [l.apply_prod_le_sum_map _ h_one h_mul]
176+
177+
lemma sum_map_le_apply_prod (h_one : 0 ≤ f 1) (h_mul : ∀ (a b : α), f a + f b ≤ f (a * b)) :
178+
(m.map f).sum ≤ f m.prod :=
179+
m.apply_prod_le_sum_map (β := βᵒᵈ) f h_one h_mul
180+
181+
end ProdSum
182+
168183
end Multiset

Mathlib/Algebra/Polynomial/BigOperators.lean

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,11 @@ theorem degree_list_sum_le (l : List S[X]) : degree l.sum ≤ (l.map natDegree).
8383
use p
8484
simp [hp]
8585

86-
theorem natDegree_list_prod_le (l : List S[X]) : natDegree l.prod ≤ (l.map natDegree).sum := by
87-
induction l with
88-
| nil => simp
89-
| cons p l ih => dsimp; grw [natDegree_mul_le, ih]
86+
theorem natDegree_list_prod_le (l : List S[X]) : natDegree l.prod ≤ (l.map natDegree).sum :=
87+
l.apply_prod_le_sum_map _ natDegree_one.le fun _ _ => natDegree_mul_le
9088

91-
theorem degree_list_prod_le (l : List S[X]) : degree l.prod ≤ (l.map degree).sum := by
92-
induction l with
93-
| nil => simp
94-
| cons p l ih => dsimp; grw [degree_mul_le, ih]
89+
theorem degree_list_prod_le (l : List S[X]) : degree l.prod ≤ (l.map degree).sum :=
90+
l.apply_prod_le_sum_map _ degree_one_le degree_mul_le
9591

9692
theorem coeff_list_prod_of_natDegree_le (l : List S[X]) (n : ℕ) (hl : ∀ p ∈ l, natDegree p ≤ n) :
9793
coeff (List.prod l) (l.length * n) = (l.map fun p => coeff p n).prod := by

Mathlib/Analysis/Normed/Group/Basic.lean

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,11 +1155,8 @@ theorem norm_multiset_sum_le {E} [SeminormedAddCommGroup E] (m : Multiset E) :
11551155
m.le_sum_of_subadditive norm norm_zero.le norm_add_le
11561156

11571157
@[to_additive existing]
1158-
theorem norm_multiset_prod_le (m : Multiset E) : ‖m.prod‖ ≤ (m.map fun x => ‖x‖).sum := by
1159-
rw [← Multiplicative.ofAdd_le, ofAdd_multiset_prod, Multiset.map_map]
1160-
refine Multiset.le_prod_of_submultiplicative (Multiplicative.ofAdd ∘ norm) ?_ (fun x y => ?_) _
1161-
· simp
1162-
· exact norm_mul_le' x y
1158+
theorem norm_multiset_prod_le (m : Multiset E) : ‖m.prod‖ ≤ (m.map fun x => ‖x‖).sum :=
1159+
m.apply_prod_le_sum_map _ norm_one'.le norm_mul_le'
11631160

11641161
variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] in
11651162
@[bound]
@@ -1173,18 +1170,12 @@ theorem norm_sum_le {E} [SeminormedAddCommGroup E] (s : Finset ι) (f : ι → E
11731170
s.le_sum_of_subadditive norm norm_zero.le norm_add_le f
11741171

11751172
@[to_additive existing]
1176-
theorem enorm_prod_le (s : Finset ι) (f : ι → ε) : ‖∏ i ∈ s, f i‖ₑ ≤ ∑ i ∈ s, ‖f i‖ₑ := by
1177-
rw [← Multiplicative.ofAdd_le, ofAdd_sum]
1178-
refine Finset.le_prod_of_submultiplicative (Multiplicative.ofAdd ∘ enorm) ?_ (fun x y => ?_) _ _
1179-
· simp
1180-
· exact enorm_mul_le' x y
1173+
theorem enorm_prod_le (s : Finset ι) (f : ι → ε) : ‖∏ i ∈ s, f i‖ₑ ≤ ∑ i ∈ s, ‖f i‖ₑ :=
1174+
s.apply_prod_le_sum_apply _ enorm_one'.le enorm_mul_le'
11811175

11821176
@[to_additive existing]
1183-
theorem norm_prod_le (s : Finset ι) (f : ι → E) : ‖∏ i ∈ s, f i‖ ≤ ∑ i ∈ s, ‖f i‖ := by
1184-
rw [← Multiplicative.ofAdd_le, ofAdd_sum]
1185-
refine Finset.le_prod_of_submultiplicative (Multiplicative.ofAdd ∘ norm) ?_ (fun x y => ?_) _ _
1186-
· simp
1187-
· exact norm_mul_le' x y
1177+
theorem norm_prod_le (s : Finset ι) (f : ι → E) : ‖∏ i ∈ s, f i‖ ≤ ∑ i ∈ s, ‖f i‖ :=
1178+
s.apply_prod_le_sum_apply _ norm_one'.le norm_mul_le'
11881179

11891180
@[to_additive]
11901181
theorem enorm_prod_le_of_le (s : Finset ι) {f : ι → ε} {n : ι → ℝ≥0∞} (h : ∀ b ∈ s, ‖f b‖ₑ ≤ n b) :

0 commit comments

Comments
 (0)