Skip to content

Commit cfd3878

Browse files
committed
generalize a lot more
1 parent 7e5500e commit cfd3878

3 files changed

Lines changed: 57 additions & 67 deletions

File tree

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

Lines changed: 42 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ namespace Finset
2828

2929
section OrderedCommMonoid
3030

31-
variable [CommMonoid M] [CommMonoid N] [PartialOrder N] [IsOrderedMonoid N]
31+
variable [CommMonoid M] [CommMonoid N] [PartialOrder N]
3232

3333
/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map
3434
submultiplicative on `{x | p x}`, i.e., `p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be
3535
a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
3636
`f (∏ x ∈ s, g x) ≤ ∏ x ∈ s, f (g x)`. -/
3737
@[to_additive le_sum_nonempty_of_subadditive_on_pred]
38-
theorem le_prod_nonempty_of_submultiplicative_on_pred (f : M → N) (p : M → Prop)
38+
theorem le_prod_nonempty_of_submultiplicative_on_pred [IsOrderedMonoid N] (f : M → N) (p : M → Prop)
3939
(h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))
4040
(g : ι → M) (s : Finset ι) (hs_nonempty : s.Nonempty) (hs : ∀ i ∈ s, p (g i)) :
4141
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
@@ -54,8 +54,9 @@ add_decl_doc le_sum_nonempty_of_subadditive_on_pred
5454
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y` and `g i`, `i ∈ s`, is a
5555
nonempty finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
5656
@[to_additive le_sum_nonempty_of_subadditive]
57-
theorem le_prod_nonempty_of_submultiplicative (f : M → N) (h_mul : ∀ x y, f (x * y) ≤ f x * f y)
58-
{s : Finset ι} (hs : s.Nonempty) (g : ι → M) : f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
57+
theorem le_prod_nonempty_of_submultiplicative [IsOrderedMonoid N] (f : M → N)
58+
(h_mul : ∀ x y, f (x * y) ≤ f x * f y) {s : Finset ι} (hs : s.Nonempty) (g : ι → M) :
59+
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
5960
le_prod_nonempty_of_submultiplicative_on_pred f (fun _ ↦ True) (fun x y _ _ ↦ h_mul x y)
6061
(fun _ _ _ _ ↦ trivial) g s hs fun _ _ ↦ trivial
6162

@@ -68,9 +69,10 @@ such that `f 1 = 1` and `f` is submultiplicative on `{x | p x}`, i.e.,
6869
`p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be a finite family of elements of `M` such
6970
that `∀ i ∈ s, p (g i)`. Then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
7071
@[to_additive le_sum_of_subadditive_on_pred]
71-
theorem le_prod_of_submultiplicative_on_pred (f : M → N) (p : M → Prop) (h_one : f 1 = 1)
72-
(h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))
73-
(g : ι → M) {s : Finset ι} (hs : ∀ i ∈ s, p (g i)) : f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
72+
theorem le_prod_of_submultiplicative_on_pred [IsOrderedMonoid N] (f : M → N) (p : M → Prop)
73+
(h_one : f 1 = 1) (h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y)
74+
(hp_mul : ∀ x y, p x → p y → p (x * y)) (g : ι → M) {s : Finset ι} (hs : ∀ i ∈ s, p (g i)) :
75+
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
7476
rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)
7577
· simp [h_one]
7678
· exact le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul g s hs_nonempty hs
@@ -84,7 +86,7 @@ add_decl_doc le_sum_of_subadditive_on_pred
8486
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y`, `f 1 = 1`, and `g i`,
8587
`i ∈ s`, is a finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
8688
@[to_additive le_sum_of_subadditive]
87-
theorem le_prod_of_submultiplicative (f : M → N) (h_one : f 1 = 1)
89+
theorem le_prod_of_submultiplicative [IsOrderedMonoid N] (f : M → N) (h_one : f 1 = 1)
8890
(h_mul : ∀ x y, f (x * y) ≤ f x * f y) (s : Finset ι) (g : ι → M) :
8991
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
9092
le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) (by simp)
@@ -99,7 +101,7 @@ variable {f g : ι → N} {s t : Finset ι}
99101
equal to the corresponding factor `g i` of another finite product, then
100102
`∏ i ∈ s, f i ≤ ∏ i ∈ s, g i`. -/
101103
@[to_additive (attr := gcongr) sum_le_sum]
102-
theorem prod_le_prod' (h : ∀ i ∈ s, f i ≤ g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ s, g i :=
104+
theorem prod_le_prod' [MulLeftMono N] (h : ∀ i ∈ s, f i ≤ g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ s, g i :=
103105
Multiset.prod_map_le_prod_map f g h
104106

105107
attribute [bound] sum_le_sum
@@ -109,54 +111,39 @@ or equal to the corresponding summand `g i` of another finite sum, then
109111
`∑ i ∈ s, f i ≤ ∑ i ∈ s, g i`. -/
110112
add_decl_doc sum_le_sum
111113

112-
section MulLeftMono
113-
variable {N : Type*} [CommMonoid N] [PartialOrder N] [MulLeftMono N]
114-
variable {f g : ι → N} {s t : Finset ι}
115-
116114
@[to_additive sum_nonneg]
117-
theorem one_le_prod' (h : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i := by
118-
classical
119-
induction s using Finset.induction_on with
120-
| empty => simp
121-
| insert i s hins H =>
122-
rw [Finset.prod_insert hins]
123-
grind [one_le_mul]
115+
theorem one_le_prod' [MulLeftMono N] (h : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
116+
le_trans (by rw [prod_const_one]) (prod_le_prod' h)
124117

125118
@[to_additive Finset.sum_nonneg']
126-
theorem one_le_prod'' (h : ∀ i : ι, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
119+
theorem one_le_prod'' [MulLeftMono N] (h : ∀ i : ι, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
127120
Finset.one_le_prod' fun i _ ↦ h i
128121

129122
@[to_additive sum_nonpos]
130-
theorem prod_le_one' (h : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s, f i ≤ 1 := by
131-
classical
132-
induction s using Finset.induction_on with
133-
| empty => simp
134-
| insert i s hins H =>
135-
rw [Finset.prod_insert hins]
136-
grind [mul_le_one']
137-
138-
end MulLeftMono
123+
theorem prod_le_one' [MulLeftMono N] (h : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s, f i ≤ 1 :=
124+
(prod_le_prod' h).trans_eq (by rw [prod_const_one])
139125

140126
@[to_additive (attr := gcongr) sum_le_sum_of_subset_of_nonneg]
141-
theorem prod_le_prod_of_subset_of_one_le' (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → 1 ≤ f i) :
142-
∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
127+
theorem prod_le_prod_of_subset_of_one_le' [MulLeftMono N] (h : s ⊆ t)
128+
(hf : ∀ i ∈ t, i ∉ s → 1 ≤ f i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
143129
classical calc
144130
∏ i ∈ s, f i ≤ (∏ i ∈ t \ s, f i) * ∏ i ∈ s, f i :=
145131
le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]
146132
_ = ∏ i ∈ t \ s ∪ s, f i := (prod_union sdiff_disjoint).symm
147133
_ = ∏ i ∈ t, f i := by rw [sdiff_union_of_subset h]
148134

149135
@[to_additive sum_mono_set_of_nonneg]
150-
theorem prod_mono_set_of_one_le' (hf : ∀ x, 1 ≤ f x) : Monotone fun s ↦ ∏ x ∈ s, f x :=
136+
theorem prod_mono_set_of_one_le' [MulLeftMono N] (hf : ∀ x, 1 ≤ f x) :
137+
Monotone fun s ↦ ∏ x ∈ s, f x :=
151138
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x
152139

153140
@[to_additive sum_le_univ_sum_of_nonneg]
154-
theorem prod_le_univ_prod_of_one_le' [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :
141+
theorem prod_le_univ_prod_of_one_le' [MulLeftMono N] [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :
155142
∏ x ∈ s, f x ≤ ∏ x, f x :=
156143
prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a
157144

158145
@[to_additive sum_eq_zero_iff_of_nonneg]
159-
theorem prod_eq_one_iff_of_one_le' :
146+
theorem prod_eq_one_iff_of_one_le' [MulLeftMono N] :
160147
(∀ i ∈ s, 1 ≤ f i) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := by
161148
classical
162149
refine Finset.induction_on s
@@ -167,31 +154,33 @@ theorem prod_eq_one_iff_of_one_le' :
167154
forall_mem_insert, ih this]
168155

169156
@[to_additive sum_pos_iff_of_nonneg]
170-
lemma one_lt_prod_iff_of_one_le (hf : ∀ x ∈ s, 1 ≤ f x) :
157+
lemma one_lt_prod_iff_of_one_le [MulLeftMono N] (hf : ∀ x ∈ s, 1 ≤ f x) :
171158
1 < ∏ x ∈ s, f x ↔ ∃ x ∈ s, 1 < f x := by
172159
have hsum : 1 ≤ ∏ x ∈ s, f x := one_le_prod' hf
173160
rw [hsum.lt_iff_ne', Ne, prod_eq_one_iff_of_one_le' hf, not_forall]
174161
simp +contextual [← exists_prop, - exists_const_iff, hf _ _ |>.lt_iff_ne']
175162

176163
@[to_additive sum_eq_zero_iff_of_nonpos]
177-
theorem prod_eq_one_iff_of_le_one' :
164+
theorem prod_eq_one_iff_of_le_one' [MulLeftMono N] :
178165
(∀ i ∈ s, f i ≤ 1) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) :=
179166
prod_eq_one_iff_of_one_le' (N := Nᵒᵈ)
180167

181168
@[to_additive]
182-
lemma prod_lt_one_iff_of_le_one (hf : ∀ x ∈ s, f x ≤ 1) :
169+
lemma prod_lt_one_iff_of_le_one [MulLeftMono N] (hf : ∀ x ∈ s, f x ≤ 1) :
183170
∏ x ∈ s, f x < 1 ↔ ∃ x ∈ s, f x < 1 :=
184171
one_lt_prod_iff_of_one_le (N := Nᵒᵈ) hf
185172

186173
@[to_additive single_le_sum]
187-
theorem single_le_prod' (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) : f a ≤ ∏ x ∈ s, f x :=
174+
theorem single_le_prod' [MulLeftMono N] (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) :
175+
f a ≤ ∏ x ∈ s, f x :=
188176
calc
189177
f a = ∏ i ∈ {a}, f i := (prod_singleton _ _).symm
190178
_ ≤ ∏ i ∈ s, f i :=
191179
prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi
192180

193181
@[to_additive]
194-
lemma mul_le_prod {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i ≠ j) :
182+
lemma mul_le_prod [MulLeftMono N] {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s)
183+
(hne : i ≠ j) :
195184
f i * f j ≤ ∏ k ∈ s, f k :=
196185
calc
197186
f i * f j = ∏ k ∈ .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton]
@@ -200,14 +189,14 @@ lemma mul_le_prod {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj :
200189
simp [cons_subset, *]
201190

202191
@[to_additive sum_le_card_nsmul]
203-
theorem prod_le_pow_card (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :
192+
theorem prod_le_pow_card [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :
204193
s.prod f ≤ n ^ #s := by
205194
refine (Multiset.prod_le_pow_card (s.val.map f) n ?_).trans ?_
206195
· simpa using h
207196
· simp
208197

209198
@[to_additive card_nsmul_le_sum]
210-
theorem pow_card_le_prod (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) :
199+
theorem pow_card_le_prod [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) :
211200
n ^ #s ≤ s.prod f := Finset.prod_le_pow_card (N := Nᵒᵈ) _ _ _ h
212201

213202
theorem card_biUnion_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Finset β) (n : ℕ)
@@ -217,8 +206,8 @@ theorem card_biUnion_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Fi
217206
variable {ι' : Type*} [DecidableEq ι']
218207

219208
@[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg]
220-
theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ι'} {g : ι → ι'} {f : ι → N}
221-
(h : ∀ y ∉ t, (1 : N) ≤ ∏ x ∈ s with g x = y, f x) :
209+
theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' [MulLeftMono N] {t : Finset ι'} {g : ι → ι'}
210+
{f : ι → N} (h : ∀ y ∉ t, (1 : N) ≤ ∏ x ∈ s with g x = y, f x) :
222211
(∏ y ∈ t, ∏ x ∈ s with g x = y, f x) ≤ ∏ x ∈ s, f x :=
223212
calc
224213
(∏ y ∈ t, ∏ x ∈ s with g x = y, f x) ≤
@@ -228,13 +217,13 @@ theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ι'} {g : ι
228217
prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _
229218

230219
@[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos]
231-
theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ι'} {g : ι → ι'} {f : ι → N}
232-
(h : ∀ y ∉ t, ∏ x ∈ s with g x = y, f x ≤ 1) :
220+
theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' [MulLeftMono N] {t : Finset ι'} {g : ι → ι'}
221+
{f : ι → N} (h : ∀ y ∉ t, ∏ x ∈ s with g x = y, f x ≤ 1) :
233222
∏ x ∈ s, f x ≤ ∏ y ∈ t, ∏ x ∈ s with g x = y, f x :=
234223
prod_fiberwise_le_prod_of_one_le_prod_fiber' (N := Nᵒᵈ) h
235224

236225
@[to_additive]
237-
lemma prod_image_le_of_one_le
226+
lemma prod_image_le_of_one_le [MulLeftMono N]
238227
{g : ι → ι'} {f : ι' → N} (hf : ∀ u ∈ s.image g, 1 ≤ f u) :
239228
∏ u ∈ s.image g, f u ≤ ∏ u ∈ s, f (g u) := by
240229
rw [prod_comp f g]
@@ -260,12 +249,12 @@ theorem abs_sum_le_sum_abs {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrder
260249
(f : ι → G) (s : Finset ι) :
261250
|∑ i ∈ s, f i| ≤ ∑ i ∈ s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f
262251

263-
theorem abs_sum_of_nonneg {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G]
252+
theorem abs_sum_of_nonneg {G : Type*} [AddCommGroup G] [LinearOrder G] [AddLeftMono G]
264253
{f : ι → G} {s : Finset ι}
265254
(hf : ∀ i ∈ s, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by
266255
rw [abs_of_nonneg (Finset.sum_nonneg hf)]
267256

268-
theorem abs_sum_of_nonneg' {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G]
257+
theorem abs_sum_of_nonneg' {G : Type*} [AddCommGroup G] [LinearOrder G] [AddLeftMono G]
269258
{f : ι → G} {s : Finset ι}
270259
(hf : ∀ i, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by
271260
rw [abs_of_nonneg (Finset.sum_nonneg' hf)]
@@ -564,20 +553,18 @@ end Finset
564553

565554
namespace Fintype
566555
section OrderedCommMonoid
567-
variable [Fintype ι] [CommMonoid M] [PartialOrder M] {f : ι → M}
556+
variable [Fintype ι] [CommMonoid M] [PartialOrder M] [MulLeftMono M] {f : ι → M}
568557

569558
@[to_additive (attr := mono) sum_mono]
570-
theorem prod_mono' [IsOrderedMonoid M] : Monotone fun f : ι → M ↦ ∏ i, f i := fun _ _ hfg ↦
559+
theorem prod_mono' : Monotone fun f : ι → M ↦ ∏ i, f i := fun _ _ hfg ↦
571560
Finset.prod_le_prod' fun x _ ↦ hfg x
572561

573562
@[to_additive sum_nonneg]
574-
lemma one_le_prod [MulLeftMono M] (hf : 1 ≤ f) : 1 ≤ ∏ i, f i := Finset.one_le_prod' fun _ _ ↦ hf _
563+
lemma one_le_prod (hf : 1 ≤ f) : 1 ≤ ∏ i, f i := Finset.one_le_prod' fun _ _ ↦ hf _
575564

576-
@[to_additive] lemma prod_le_one [MulLeftMono M] (hf : f ≤ 1) : ∏ i, f i ≤ 1 :=
565+
@[to_additive] lemma prod_le_one (hf : f ≤ 1) : ∏ i, f i ≤ 1 :=
577566
Finset.prod_le_one' fun _ _ ↦ hf _
578567

579-
variable [IsOrderedMonoid M]
580-
581568
@[to_additive]
582569
lemma prod_eq_one_iff_of_one_le (hf : 1 ≤ f) : ∏ i, f i = 1 ↔ f = 1 :=
583570
(Finset.prod_eq_one_iff_of_one_le' fun i _ ↦ hf i).trans <| by simp [funext_iff]

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,51 +23,54 @@ variable {ι α β : Type*}
2323

2424
namespace Multiset
2525
section OrderedCommMonoid
26-
variable [CommMonoid α] [PartialOrder α] [IsOrderedMonoid α] {s t : Multiset α} {a : α}
26+
variable [CommMonoid α] [PartialOrder α] {s t : Multiset α} {a : α}
2727

2828
@[to_additive sum_nonneg]
29-
lemma one_le_prod_of_one_le : (∀ x ∈ s, (1 : α) ≤ x) → 1 ≤ s.prod :=
29+
lemma one_le_prod_of_one_le [MulLeftMono α] : (∀ x ∈ s, (1 : α) ≤ x) → 1 ≤ s.prod :=
3030
Quotient.inductionOn s fun l hl => by simpa using List.one_le_prod_of_one_le hl
3131

3232
@[to_additive]
33-
lemma single_le_prod : (∀ x ∈ s, (1 : α) ≤ x) → ∀ x ∈ s, x ≤ s.prod :=
33+
lemma single_le_prod [IsOrderedMonoid α] : (∀ x ∈ s, (1 : α) ≤ x) → ∀ x ∈ s, x ≤ s.prod :=
3434
Quotient.inductionOn s fun l hl x hx => by simpa using List.single_le_prod hl x hx
3535

3636
@[to_additive sum_le_card_nsmul]
37-
lemma prod_le_pow_card (s : Multiset α) (n : α) (h : ∀ x ∈ s, x ≤ n) : s.prod ≤ n ^ card s := by
37+
lemma prod_le_pow_card [MulLeftMono α] (s : Multiset α) (n : α) (h : ∀ x ∈ s, x ≤ n) :
38+
s.prod ≤ n ^ card s := by
3839
induction s using Quotient.inductionOn
3940
simpa using List.prod_le_pow_card _ _ h
4041

4142
@[to_additive all_zero_of_le_zero_le_of_sum_eq_zero]
42-
lemma all_one_of_le_one_le_of_prod_eq_one :
43+
lemma all_one_of_le_one_le_of_prod_eq_one [IsOrderedMonoid α] :
4344
(∀ x ∈ s, (1 : α) ≤ x) → s.prod = 1 → ∀ x ∈ s, x = (1 : α) :=
4445
Quotient.inductionOn s (by
4546
simp only [quot_mk_to_coe, prod_coe, mem_coe]
4647
exact fun l => List.all_one_of_le_one_le_of_prod_eq_one)
4748

4849
@[to_additive]
49-
lemma prod_le_prod_of_rel_le (h : s.Rel (· ≤ ·) t) : s.prod ≤ t.prod := by
50+
lemma prod_le_prod_of_rel_le [MulLeftMono α] (h : s.Rel (· ≤ ·) t) : s.prod ≤ t.prod := by
5051
induction h with
5152
| zero => rfl
5253
| cons rh _ rt =>
5354
rw [prod_cons, prod_cons]
5455
exact mul_le_mul' rh rt
5556

5657
@[to_additive]
57-
lemma prod_map_le_prod_map {s : Multiset ι} (f : ι → α) (g : ι → α) (h : ∀ i, i ∈ s → f i ≤ g i) :
58-
(s.map f).prod ≤ (s.map g).prod :=
58+
lemma prod_map_le_prod_map [MulLeftMono α] {s : Multiset ι} (f : ι → α) (g : ι → α)
59+
(h : ∀ i, i ∈ s → f i ≤ g i) : (s.map f).prod ≤ (s.map g).prod :=
5960
prod_le_prod_of_rel_le <| rel_map.2 <| rel_refl_of_refl_on h
6061

6162
@[to_additive]
62-
lemma prod_map_le_prod (f : α → α) (h : ∀ x, x ∈ s → f x ≤ x) : (s.map f).prod ≤ s.prod :=
63+
lemma prod_map_le_prod [MulLeftMono α] (f : α → α) (h : ∀ x, x ∈ s → f x ≤ x) :
64+
(s.map f).prod ≤ s.prod :=
6365
prod_le_prod_of_rel_le <| rel_map_left.2 <| rel_refl_of_refl_on h
6466

6567
@[to_additive]
66-
lemma prod_le_prod_map (f : α → α) (h : ∀ x, x ∈ s → x ≤ f x) : s.prod ≤ (s.map f).prod :=
68+
lemma prod_le_prod_map [MulLeftMono α] (f : α → α) (h : ∀ x, x ∈ s → x ≤ f x) :
69+
s.prod ≤ (s.map f).prod :=
6770
prod_map_le_prod (α := αᵒᵈ) f h
6871

6972
@[to_additive card_nsmul_le_sum]
70-
lemma pow_card_le_prod (h : ∀ x ∈ s, a ≤ x) : a ^ card s ≤ s.prod := by
73+
lemma pow_card_le_prod [MulLeftMono α] (h : ∀ x ∈ s, a ≤ x) : a ^ card s ≤ s.prod := by
7174
rw [← Multiset.prod_replicate, ← Multiset.map_const]
7275
exact prod_map_le_prod _ h
7376

Mathlib/Tactic/Positivity/Finset.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def evalFinsetSum : PositivityExt where eval {u α} zα pα e := do
8787
let pr : Q(∀ i, 0 ≤ $f i) ← mkLambdaFVars #[i] pbody
8888
let pα' ← synthInstanceQ q(AddLeftMono $α)
8989
assertInstancesCommute
90-
return .nonnegative q(@sum_nonneg $ι $α $instα $pα $pα' $f $s fun i _ ↦ $pr i)
90+
return .nonnegative q(@sum_nonneg $ι $α $instα $pα $f $s $pα' fun i _ ↦ $pr i)
9191
| _ => throwError "not Finset.sum"
9292

9393
variable {α : Type*} {s : Finset α}

0 commit comments

Comments
 (0)