Skip to content

Commit e86ff5d

Browse files
committed
chore(Algebra): generalise prod_le_prod_of_subset_of_one_le
1 parent 0f33149 commit e86ff5d

5 files changed

Lines changed: 33 additions & 28 deletions

File tree

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,37 +129,40 @@ theorem prod_le_one' [MulLeftMono N] (h : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s,
129129
(prod_le_prod' h).trans_eq (by rw [prod_const_one])
130130

131131
@[to_additive (attr := gcongr) sum_le_sum_of_subset_of_nonneg]
132-
theorem prod_le_prod_of_subset_of_one_le' [MulLeftMono N] (h : s ⊆ t)
133-
(hf : ∀ i ∈ t, i ∉ s → 1f i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
132+
lemma prod_le_prod_of_subset_of_one_le' [MulLeftMono N] (h : s ⊆ t) (hfg : ∀ i ∈ s, f i ≤ g i)
133+
(hg : ∀ i ∈ t, i ∉ s → 1g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, g i := by
134134
classical calc
135-
∏ i ∈ s, f i ≤ (∏ i ∈ t \ s, f i) * ∏ i ∈ s, f i :=
136-
le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]
137-
_ = ∏ i ∈ t \ s ∪ s, f i := (prod_union sdiff_disjoint).symm
138-
_ = ∏ i ∈ t, f i := by rw [sdiff_union_of_subset h]
135+
∏ i ∈ s, f i
136+
_ ≤ ∏ i ∈ s, g i := by gcongr with i hi; exact hfg i hi
137+
_ ≤ (∏ i ∈ t \ s, g i) * ∏ i ∈ s, g i :=
138+
le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]
139+
_ = ∏ i ∈ t \ s ∪ s, g i := (prod_union sdiff_disjoint).symm
140+
_ = ∏ i ∈ t, g i := by rw [sdiff_union_of_subset h]
139141

140142
@[to_additive]
141143
theorem prod_le_prod_of_subset_of_le_one'
142144
{ι : Type u_1} {N : Type u_5} [CommMonoid N] [Preorder N]
143-
{f : ι → N} {s t : Finset ι} [MulLeftMono N] (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → f i ≤ 1) :
144-
∏ i ∈ t, f i ≤ ∏ i ∈ s, f i :=
145-
prod_le_prod_of_subset_of_one_le' (N := Nᵒᵈ) h hf
145+
{f g : ι → N} {s t : Finset ι} [MulLeftMono N] (h : s ⊆ t) (hfg : ∀ i ∈ s, f i ≤ g i)
146+
(hf : ∀ i ∈ t, i ∉ s → f i ≤ 1) :
147+
∏ i ∈ t, f i ≤ ∏ i ∈ s, g i :=
148+
prod_le_prod_of_subset_of_one_le' (N := Nᵒᵈ) h hfg hf
146149

147150
@[to_additive sum_mono_set_of_nonneg]
148151
theorem prod_mono_set_of_one_le' [MulLeftMono N] (hf : ∀ x, 1 ≤ f x) :
149152
Monotone fun s ↦ ∏ x ∈ s, f x :=
150-
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x
153+
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst (by simp) fun x _ _ ↦ hf x
151154

152155
@[to_additive]
153156
theorem prod_anti_set_of_le_one'
154157
{ι : Type u_1} {N : Type u_5} [CommMonoid N] [Preorder N]
155158
{f : ι → N} [MulLeftMono N] (hf : ∀ (x : ι), f x ≤ 1) :
156159
Antitone fun (s : Finset ι) => ∏ x ∈ s, f x :=
157-
fun _ _ hst ↦ prod_le_prod_of_subset_of_le_one' hst (by simp [hf])
160+
fun _ _ hst ↦ prod_le_prod_of_subset_of_le_one' hst (by simp) (by simp [hf])
158161

159162
@[to_additive sum_le_univ_sum_of_nonneg]
160163
theorem prod_le_univ_prod_of_one_le' [MulLeftMono N] [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :
161164
∏ x ∈ s, f x ≤ ∏ x, f x :=
162-
prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a
165+
prod_le_prod_of_subset_of_one_le' (subset_univ s) (by simp) fun a _ _ ↦ w a
163166

164167
@[to_additive sum_eq_zero_iff_of_nonneg]
165168
theorem prod_eq_one_iff_of_one_le' {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N]
@@ -199,7 +202,7 @@ theorem single_le_prod' [MulLeftMono N] (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a
199202
calc
200203
f a = ∏ i ∈ {a}, f i := (prod_singleton _ _).symm
201204
_ ≤ ∏ i ∈ s, f i :=
202-
prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi
205+
prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) (by simp) fun i hi _ ↦ hf i hi
203206

204207
@[to_additive]
205208
lemma mul_le_prod [MulLeftMono N] {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s)
@@ -208,7 +211,7 @@ lemma mul_le_prod [MulLeftMono N] {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi :
208211
calc
209212
f i * f j = ∏ k ∈ .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton]
210213
_ ≤ ∏ k ∈ s, f k := by
211-
refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
214+
refine prod_le_prod_of_subset_of_one_le' ?_ (by simp) fun k hk _ ↦ hf k hk
212215
simp [cons_subset, *]
213216

214217
@[to_additive sum_le_card_nsmul]
@@ -235,7 +238,7 @@ theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' [MulLeftMono N] {t : Finset
235238
calc
236239
(∏ y ∈ t, ∏ x ∈ s with g x = y, f x) ≤
237240
∏ y ∈ t ∪ s.image g, ∏ x ∈ s with g x = y, f x :=
238-
prod_le_prod_of_subset_of_one_le' subset_union_left fun y _ ↦ h y
241+
prod_le_prod_of_subset_of_one_le' subset_union_left (by simp) fun y _ ↦ h y
239242
_ = ∏ x ∈ s, f x :=
240243
prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _
241244

@@ -418,7 +421,7 @@ lemma single_le_prod_of_canonicallyOrdered {i : ι} (hi : i ∈ s) :
418421
@[to_additive sum_le_sum_of_subset]
419422
theorem prod_le_prod_of_subset' (h : s ⊆ t) : ∏ x ∈ s, f x ≤ ∏ x ∈ t, f x :=
420423
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
421-
prod_le_prod_of_subset_of_one_le' h fun _ _ _ ↦ one_le
424+
prod_le_prod_of_subset_of_one_le' h (by simp) fun _ _ _ ↦ one_le
422425

423426
@[to_additive sum_mono_set]
424427
theorem prod_mono_set' (f : ι → M) : Monotone fun s ↦ ∏ x ∈ s, f x := fun _ _ hs ↦
@@ -478,7 +481,7 @@ theorem prod_lt_prod_of_subset' [MulLeftStrictMono M] (h : s ⊆ t) {i : ι} (ht
478481
rw [prod_insert hs]
479482
exact lt_mul_of_one_lt_left' (∏ j ∈ s, f j) hlt
480483
_ ≤ ∏ j ∈ t, f j := by
481-
apply prod_le_prod_of_subset_of_one_le'
484+
refine prod_le_prod_of_subset_of_one_le' ?_ (by simp) ?_
482485
· simp [Finset.insert_subset_iff, h, ht]
483486
· intro x hx h'x
484487
simp only [mem_insert, not_or] at h'x

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,18 @@ lemma le_prod_max_one {M : Type*} [CommMonoidWithZero M] [LinearOrder M] [ZeroLE
6868

6969
@[gcongr]
7070
theorem prod_le_prod_of_subset_of_one_le (h : s ⊆ t)
71-
(hf0 : ∀ i ∈ s, 0 ≤ f i)
72-
(hf : ∀ i ∈ t, i ∉ s → 1f i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
71+
(hf0 : ∀ i ∈ s, 0 ≤ f i) (hfg : ∀ i ∈ s, f i ≤ g i)
72+
(hf : ∀ i ∈ t, i ∉ s → 1g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, g i := by
7373
have := posMulMono_iff_mulPosMono.1 ‹PosMulMono R›
7474
classical
7575
calc
76-
∏ i ∈ s, f i ≤ (∏ i ∈ t \ s, f i) * ∏ i ∈ s, f i :=
77-
le_mul_of_one_le_left (prod_nonneg hf0) <| one_le_prod <| by simpa only [mem_sdiff, and_imp]
78-
_ = ∏ i ∈ t \ s ∪ s, f i := (prod_union sdiff_disjoint).symm
79-
_ = ∏ i ∈ t, f i := by rw [sdiff_union_of_subset h]
76+
∏ i ∈ s, f i
77+
_ ≤ ∏ i ∈ s, g i := by gcongr with i hi; exacts [hf0, hfg i hi]
78+
_ ≤ (∏ i ∈ t \ s, g i) * ∏ i ∈ s, g i :=
79+
le_mul_of_one_le_left (prod_nonneg fun i hi ↦ (hf0 i hi).trans (hfg i hi)) <|
80+
one_le_prod <| by simpa only [mem_sdiff, and_imp]
81+
_ = ∏ i ∈ t \ s ∪ s, g i := (prod_union sdiff_disjoint).symm
82+
_ = ∏ i ∈ t, g i := by rw [sdiff_union_of_subset h]
8083

8184
theorem prod_le_prod_of_subset_of_le_one (h : s ⊆ t) (hf0 : ∀ i ∈ t, 0 ≤ f i)
8285
(hf : ∀ i ∈ t, i ∉ s → f i ≤ 1) :
@@ -92,7 +95,7 @@ theorem prod_le_prod_of_subset_of_le_one (h : s ⊆ t) (hf0 : ∀ i ∈ t, 0 ≤
9295
theorem prod_mono_set_of_one_le (hf : ∀ x, 1 ≤ f x) :
9396
Monotone fun s ↦ ∏ x ∈ s, f x :=
9497
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le hst
95-
(fun i _ ↦ zero_le_one.trans (hf i)) (fun x _ _ ↦ hf x)
98+
(fun i _ ↦ zero_le_one.trans (hf i)) (by simp) (fun x _ _ ↦ hf x)
9699

97100
theorem prod_anti_set_of_le_one (hf0 : ∀ (x : ι), 0 ≤ f x) (hf : ∀ (x : ι), f x ≤ 1) :
98101
Antitone fun (s : Finset ι) => ∏ x ∈ s, f x :=

Mathlib/Analysis/Complex/Exponential.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ theorem sum_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : ∑ i ∈ rang
247247
refine le_lim (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩)
248248
simp only [exp', const_apply, re_sum]
249249
norm_cast
250-
refine sum_le_sum_of_subset_of_nonneg (range_mono hj) fun _ _ _ ↦ ?_
251-
positivity
250+
gcongr
252251
_ = exp x := by rw [exp, Complex.exp, ← cauSeqRe, lim_re]
253252

254253
lemma pow_div_factorial_le_exp (hx : 0 ≤ x) (n : ℕ) : x ^ n / n ! ≤ exp x :=

Mathlib/NumberTheory/Primorial.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ theorem primorial_pos (n : ℕ) : 0 < n# :=
5353
prod_pos fun _p hp ↦ (mem_filter.1 hp).2.pos
5454

5555
theorem primorial_mono {m n : ℕ} (h : m ≤ n) : m# ≤ n# :=
56-
prod_le_prod_of_subset_of_one_le' (by gcongr) (by grind)
56+
prod_le_prod_of_subset_of_one_le' (by gcongr) (by simp) (by grind)
5757

5858
theorem primorial_monotone : Monotone primorial := fun _ _ ↦ primorial_mono
5959

Mathlib/Topology/Algebra/InfiniteSum/Order.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected lemma Multipliable.tprod_subtype_le {κ γ : Type*} [CommGroup γ] [Pa
9393
theorem prod_le_hasProd [L.NeBot] [L.LeAtTop] (s : Finset ι) (hs : ∀ i, i ∉ s → 1 ≤ f i)
9494
(hf : HasProd f a L) : ∏ i ∈ s, f i ≤ a := by
9595
refine ge_of_tendsto hf <| .filter_mono L.le_atTop <| eventually_atTop.2 ?_
96-
exact ⟨s, fun _t hst ↦ prod_le_prod_of_subset_of_one_le' hst fun i _ hbs ↦ hs i hbs⟩
96+
exact ⟨s, fun _t hst ↦ prod_le_prod_of_subset_of_one_le' hst (by simp) fun i _ hbs ↦ hs i hbs⟩
9797

9898
@[to_additive]
9999
theorem isLUB_hasProd (h : ∀ i, 1 ≤ f i) (hf : HasProd f a) :

0 commit comments

Comments
 (0)