Skip to content

Commit 3537c25

Browse files
committed
chore(*): use gcongr&positivity (#25128)
1 parent 401dce0 commit 3537c25

File tree

15 files changed

+94
-86
lines changed

15 files changed

+94
-86
lines changed

Mathlib/Analysis/Analytic/Basic.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ theorem min_radius_le_radius_add (p q : FormalMultilinearSeries 𝕜 E F) :
319319
have := ((p.isLittleO_one_of_lt_radius hr.1).add (q.isLittleO_one_of_lt_radius hr.2)).isBigO
320320
refine (p + q).le_radius_of_isBigO ((isBigO_of_le _ fun n => ?_).trans this)
321321
rw [← add_mul, norm_mul, norm_mul, norm_norm]
322-
exact mul_le_mul_of_nonneg_right ((norm_add_le _ _).trans (le_abs_self _)) (norm_nonneg _)
322+
gcongr
323+
exact (norm_add_le _ _).trans (le_abs_self _)
323324

324325
@[simp]
325326
theorem radius_neg (p : FormalMultilinearSeries 𝕜 E F) : (-p).radius = p.radius := by
@@ -356,7 +357,7 @@ theorem radius_shift (p : FormalMultilinearSeries 𝕜 E F) : p.shift.radius = p
356357
· simp
357358
right
358359
rw [pow_succ, ← mul_assoc]
359-
apply mul_le_mul_of_nonneg_right (h m) zero_le_coe
360+
gcongr; apply h
360361
· apply iSup_mono'
361362
intro C
362363
use ‖p 1‖ ⊔ C / r

Mathlib/Analysis/Analytic/ChangeOrigin.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ theorem changeOriginSeries_summable_aux₃ {r : ℝ≥0} (hr : ↑r < p.radius)
187187
refine NNReal.summable_of_le
188188
(fun n => ?_) (NNReal.summable_sigma.1 <| p.changeOriginSeries_summable_aux₂ hr k).2
189189
simp only [NNReal.tsum_mul_right]
190-
exact mul_le_mul' (p.nnnorm_changeOriginSeries_le_tsum _ _) le_rfl
190+
gcongr
191+
apply p.nnnorm_changeOriginSeries_le_tsum
191192

192193
theorem le_changeOriginSeries_radius (k : ℕ) : p.radius ≤ (p.changeOriginSeries k).radius :=
193194
ENNReal.le_of_forall_nnreal_lt fun _r hr =>
@@ -209,11 +210,11 @@ theorem changeOrigin_radius : p.radius - ‖x‖₊ ≤ (p.changeOrigin x).radiu
209210
rw [lt_tsub_iff_right, add_comm] at hr
210211
have hr' : (‖x‖₊ : ℝ≥0∞) < p.radius := (le_add_right le_rfl).trans_lt hr
211212
apply le_radius_of_summable_nnnorm
212-
have : ∀ k : ℕ,
213+
have (k : ℕ) :
213214
‖p.changeOrigin x k‖₊ * r ^ k ≤
214215
(∑' s : Σl : ℕ, { s : Finset (Fin (k + l)) // s.card = l }, ‖p (k + s.1)‖₊ * ‖x‖₊ ^ s.1) *
215-
r ^ k :=
216-
fun k => mul_le_mul_right' (p.nnnorm_changeOrigin_le k hr') (r ^ k)
216+
r ^ k := by
217+
gcongr; exact p.nnnorm_changeOrigin_le k hr'
217218
refine NNReal.summable_of_le this ?_
218219
simpa only [← NNReal.tsum_mul_right] using
219220
(NNReal.summable_sigma.1 (p.changeOriginSeries_summable_aux₁ hr)).2

Mathlib/Analysis/Analytic/Composition.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ theorem compAlongComposition_bound {n : ℕ} (p : FormalMultilinearSeries 𝕜 E
292292
‖f.compAlongComposition p c v‖ = ‖f (p.applyComposition c v)‖ := rfl
293293
_ ≤ ‖f‖ * ∏ i, ‖p.applyComposition c v i‖ := ContinuousMultilinearMap.le_opNorm _ _
294294
_ ≤ ‖f‖ * ∏ i, ‖p (c.blocksFun i)‖ * ∏ j : Fin (c.blocksFun i), ‖(v ∘ c.embedding i) j‖ := by
295-
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
296-
refine Finset.prod_le_prod (fun i _hi => norm_nonneg _) fun i _hi => ?_
295+
gcongr with i
297296
apply ContinuousMultilinearMap.le_opNorm
298297
_ = (‖f‖ * ∏ i, ‖p (c.blocksFun i)‖) *
299298
∏ i, ∏ j : Fin (c.blocksFun i), ‖(v ∘ c.embedding i) j‖ := by

Mathlib/Analysis/NormedSpace/OperatorNorm/Basic.lean

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ theorem opNorm_smul_le {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F]
278278
(c : 𝕜') (f : E →SL[σ₁₂] F) : ‖c • f‖ ≤ ‖c‖ * ‖f‖ :=
279279
(c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun _ => by
280280
rw [smul_apply, norm_smul, mul_assoc]
281-
exact mul_le_mul_of_nonneg_left (le_opNorm _ _) (norm_nonneg _)
282-
281+
gcongr
282+
apply le_opNorm
283283

284284
/-- Operator seminorm on the space of continuous (semi)linear maps, as `Seminorm`.
285285
@@ -322,10 +322,9 @@ instance toNormedSpace {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F]
322322

323323
/-- The operator norm is submultiplicative. -/
324324
theorem opNorm_comp_le (f : E →SL[σ₁₂] F) : ‖h.comp f‖ ≤ ‖h‖ * ‖f‖ :=
325-
csInf_le bounds_bddBelow
326-
⟨mul_nonneg (opNorm_nonneg _) (opNorm_nonneg _), fun x => by
327-
rw [mul_assoc]
328-
exact h.le_opNorm_of_le (f.le_opNorm x)⟩
325+
csInf_le bounds_bddBelow ⟨by positivity, fun x => by
326+
rw [mul_assoc]
327+
exact h.le_opNorm_of_le (f.le_opNorm x)⟩
329328

330329
/-- Continuous linear maps form a seminormed ring with respect to the operator norm. -/
331330
instance toSeminormedRing : SeminormedRing (E →L[𝕜] E) :=
@@ -411,8 +410,8 @@ theorem mkContinuous_norm_le (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (hC : 0 ≤
411410
then its norm is bounded by the bound or zero if bound is negative. -/
412411
theorem mkContinuous_norm_le' (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
413412
‖f.mkContinuous C h‖ ≤ max C 0 :=
414-
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) fun x =>
415-
(h x).trans <| mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)
413+
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) fun x => (h x).trans <| by
414+
gcongr; apply le_max_left
416415

417416
end LinearMap
418417

Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ variable [RingHomIsometric σ₂₃]
6060

6161
theorem opNorm_le_bound₂ (f : E →SL[σ₁₃] F →SL[σ₂₃] G) {C : ℝ} (h0 : 0 ≤ C)
6262
(hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) : ‖f‖ ≤ C :=
63-
f.opNorm_le_bound h0 fun x => (f x).opNorm_le_bound (mul_nonneg h0 (norm_nonneg _)) <| hC x
63+
f.opNorm_le_bound h0 fun x => (f x).opNorm_le_bound (by positivity) <| hC x
6464

6565

6666
theorem le_opNorm₂ [RingHomIsometric σ₁₃] (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (x : E) (y : F) :
@@ -300,7 +300,7 @@ variable (Eₗ) {𝕜 E Fₗ Gₗ}
300300
/-- Apply `L(x,-)` pointwise to bilinear maps, as a continuous bilinear map -/
301301
@[simps! apply]
302302
def precompR (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : E →L[𝕜] (Eₗ →L[𝕜] Fₗ) →L[𝕜] Eₗ →L[𝕜] Gₗ :=
303-
(compL 𝕜 Eₗ Fₗ Gₗ).comp L
303+
compL 𝕜 Eₗ Fₗ Gₗ ∘L L
304304

305305
/-- Apply `L(-,y)` pointwise to bilinear maps, as a continuous bilinear map -/
306306
def precompL (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : (Eₗ →L[𝕜] E) →L[𝕜] Fₗ →L[𝕜] Eₗ →L[𝕜] Gₗ :=
@@ -312,7 +312,7 @@ def precompL (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : (Eₗ →L[𝕜] E) →L[
312312
theorem norm_precompR_le (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : ‖precompR Eₗ L‖ ≤ ‖L‖ :=
313313
calc
314314
‖precompR Eₗ L‖ ≤ ‖compL 𝕜 Eₗ Fₗ Gₗ‖ * ‖L‖ := opNorm_comp_le _ _
315-
_ ≤ 1 * ‖L‖ := mul_le_mul_of_nonneg_right (norm_compL_le _ _ _ _) (norm_nonneg L)
315+
_ ≤ 1 * ‖L‖ := by gcongr; apply norm_compL_le
316316
_ = ‖L‖ := by rw [one_mul]
317317

318318
theorem norm_precompL_le (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : ‖precompL Eₗ L‖ ≤ ‖L‖ := by
@@ -364,15 +364,15 @@ is the product of the norms. -/
364364
@[simp]
365365
theorem norm_smulRight_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) : ‖smulRight c f‖ = ‖c‖ * ‖f‖ := by
366366
refine le_antisymm ?_ ?_
367-
· refine opNorm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) fun x => ?_
367+
· refine opNorm_le_bound _ (by positivity) fun x => ?_
368368
calc
369369
‖c x • f‖ = ‖c x‖ * ‖f‖ := norm_smul _ _
370-
_ ≤ ‖c‖ * ‖x‖ * ‖f‖ := mul_le_mul_of_nonneg_right (le_opNorm _ _) (norm_nonneg _)
370+
_ ≤ ‖c‖ * ‖x‖ * ‖f‖ := by gcongr; apply le_opNorm
371371
_ = ‖c‖ * ‖f‖ * ‖x‖ := by ring
372372
· obtain hf | hf := (norm_nonneg f).eq_or_gt
373373
· simp [hf]
374374
· rw [← le_div_iff₀ hf]
375-
refine opNorm_le_bound _ (div_nonneg (norm_nonneg _) (norm_nonneg f)) fun x => ?_
375+
refine opNorm_le_bound _ (by positivity) fun x => ?_
376376
rw [div_mul_eq_mul_div, le_div_iff₀ hf]
377377
calc
378378
‖c x‖ * ‖f‖ = ‖c x • f‖ := (norm_smul _ _).symm

Mathlib/Analysis/NormedSpace/OperatorNorm/Mul.lean

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ variable {R}
196196
theorem norm_toSpanSingleton (x : E) : ‖toSpanSingleton 𝕜 x‖ = ‖x‖ := by
197197
refine opNorm_eq_of_bounds (norm_nonneg _) (fun x => ?_) fun N _ h => ?_
198198
· rw [toSpanSingleton_apply, norm_smul, mul_comm]
199-
· specialize h 1
200-
rw [toSpanSingleton_apply, norm_smul, mul_comm] at h
201-
exact (mul_le_mul_right (by simp)).mp h
199+
· simpa [toSpanSingleton_apply, norm_smul] using h 1
202200

203201
variable {𝕜}
204202

@@ -212,7 +210,6 @@ theorem opNorm_lsmul_le : ‖(lsmul 𝕜 R : R →L[𝕜] E →L[𝕜] E)‖ ≤
212210
simp_rw [one_mul]
213211
exact opNorm_lsmul_apply_le _
214212

215-
216213
end SMulLinear
217214

218215
end ContinuousLinearMap
@@ -253,11 +250,8 @@ theorem opNorm_lsmul [NormedField R] [NormedAlgebra 𝕜 R] [NormedSpace R E]
253250
· rw [one_mul]
254251
apply opNorm_lsmul_apply_le
255252
obtain ⟨y, hy⟩ := exists_ne (0 : E)
256-
have := le_of_opNorm_le _ (h 1) y
257-
simp_rw [lsmul_apply, one_smul, norm_one, mul_one] at this
258253
refine le_of_mul_le_mul_right ?_ (norm_pos_iff.mpr hy)
259-
simp_rw [one_mul, this]
260-
254+
simpa using le_of_opNorm_le _ (h 1) y
261255

262256
end ContinuousLinearMap
263257

Mathlib/Analysis/NormedSpace/OperatorNorm/NormedSpace.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ theorem antilipschitz_of_comap_nhds_le [h : RingHomIsometric σ₁₂] (f : E
8080
calc
8181
‖x‖ = ‖c ^ n‖⁻¹ * ‖c ^ n • x‖ := by
8282
rwa [← norm_inv, ← norm_smul, inv_smul_smul₀ (zpow_ne_zero _ _)]
83-
_ ≤ ‖c ^ n‖⁻¹ * 1 := (mul_le_mul_of_nonneg_left (hε _ hlt).le (inv_nonneg.2 (norm_nonneg _)))
83+
_ ≤ ‖c ^ n‖⁻¹ * 1 := by gcongr; exact (hε _ hlt).le
8484
_ ≤ ε⁻¹ * ‖c‖ * ‖f x‖ := by rwa [mul_one]
8585

8686
end LinearMap

Mathlib/Combinatorics/SimpleGraph/Regularity/Bound.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def stepBound (n : ℕ) : ℕ :=
4141
theorem le_stepBound : id ≤ stepBound := fun n =>
4242
Nat.le_mul_of_pos_right _ <| pow_pos (by norm_num) n
4343

44-
theorem stepBound_mono : Monotone stepBound := fun _ _ h =>
45-
Nat.mul_le_mul h <| Nat.pow_le_pow_right (by norm_num) h
44+
theorem stepBound_mono : Monotone stepBound := fun _ _ h => by unfold stepBound; gcongr; decide
4645

4746
theorem stepBound_pos_iff {n : ℕ} : 0 < stepBound n ↔ 0 < n :=
4847
mul_pos_iff_of_pos_right <| by positivity
@@ -198,10 +197,12 @@ theorem bound_pos : 0 < bound ε l :=
198197
variable {ι 𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] {s t : Finset ι} {x : 𝕜}
199198

200199
theorem mul_sq_le_sum_sq (hst : s ⊆ t) (f : ι → 𝕜) (hs : x ^ 2 ≤ ((∑ i ∈ s, f i) / #s) ^ 2)
201-
(hs' : (#s : 𝕜) ≠ 0) : (#s : 𝕜) * x ^ 2 ≤ ∑ i ∈ t, f i ^ 2 :=
202-
(mul_le_mul_of_nonneg_left (hs.trans sum_div_card_sq_le_sum_sq_div_card) <|
203-
Nat.cast_nonneg _).trans <| (mul_div_cancel₀ _ hs').le.trans <|
204-
sum_le_sum_of_subset_of_nonneg hst fun _ _ _ => sq_nonneg _
200+
(hs' : (#s : 𝕜) ≠ 0) : (#s : 𝕜) * x ^ 2 ≤ ∑ i ∈ t, f i ^ 2 := calc
201+
_ ≤ (#s : 𝕜) * ((∑ i ∈ s, f i ^ 2) / #s) := by
202+
gcongr
203+
exact hs.trans sum_div_card_sq_le_sum_sq_div_card
204+
_ = ∑ i ∈ s, f i ^ 2 := mul_div_cancel₀ _ hs'
205+
_ ≤ ∑ i ∈ t, f i ^ 2 := by gcongr
205206

206207
theorem add_div_le_sum_sq_div_card (hst : s ⊆ t) (f : ι → 𝕜) (d : 𝕜) (hx : 0 ≤ x)
207208
(hs : x ≤ |(∑ i ∈ s, f i) / #s - (∑ i ∈ t, f i) / #t|) (ht : d ≤ ((∑ i ∈ t, f i) / #t) ^ 2) :

Mathlib/Combinatorics/SimpleGraph/Regularity/Uniform.lean

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,17 @@ lemma IsEquipartition.card_interedges_sparsePairs_le' (hP : P.IsEquipartition)
275275
calc
276276
_ ≤ ∑ UV ∈ P.sparsePairs G ε, (#(G.interedges UV.1 UV.2) : 𝕜) := mod_cast card_biUnion_le
277277
_ ≤ ∑ UV ∈ P.sparsePairs G ε, ε * (#UV.1 * #UV.2) := ?_
278-
_ ≤ _ := sum_le_sum_of_subset_of_nonneg (filter_subset _ _) fun i _ _ ↦ by positivity
279-
_ = _ := (mul_sum _ _ _).symm
280-
_ ≤ _ := mul_le_mul_of_nonneg_left ?_ hε
278+
_ ≤ ∑ UV ∈ P.parts.offDiag, ε * (#UV.1 * #UV.2) := by gcongr; apply filter_subset
279+
_ = ε * ∑ UV ∈ P.parts.offDiag, (#UV.1 * #UV.2 : 𝕜) := (mul_sum _ _ _).symm
280+
_ ≤ _ := ?_
281281
· gcongr with UV hUV
282282
obtain ⟨U, V⟩ := UV
283283
simp [mk_mem_sparsePairs, ← card_interedges_div_card] at hUV
284284
refine ((div_lt_iff₀ ?_).1 hUV.2.2.2).le
285285
exact mul_pos (Nat.cast_pos.2 (P.nonempty_of_mem_parts hUV.1).card_pos)
286286
(Nat.cast_pos.2 (P.nonempty_of_mem_parts hUV.2.1).card_pos)
287287
norm_cast
288+
gcongr
288289
calc
289290
(_ : ℕ) ≤ _ := sum_le_card_nsmul P.parts.offDiag (fun i ↦ #i.1 * #i.2)
290291
((#A / #P.parts + 1)^2 : ℕ) ?_
@@ -308,8 +309,9 @@ private lemma aux {i j : ℕ} (hj : 0 < j) : j * (j - 1) * (i / j + 1) ^ 2 < (i
308309
have : j * (j - 1) < j ^ 2 := by
309310
rw [sq]; exact Nat.mul_lt_mul_of_pos_left (Nat.sub_lt hj zero_lt_one) hj
310311
apply (Nat.mul_lt_mul_of_pos_right this <| pow_pos Nat.succ_pos' _).trans_le
311-
rw [← mul_pow]
312-
exact Nat.pow_le_pow_left (add_le_add_right (Nat.mul_div_le i j) _) _
312+
rw [← mul_pow, Nat.mul_succ]
313+
gcongr
314+
apply Nat.mul_div_le
313315

314316
lemma IsEquipartition.card_biUnion_offDiag_le' (hP : P.IsEquipartition) :
315317
(#(P.parts.biUnion offDiag) : 𝕜) ≤ #A * (#A + #P.parts) / #P.parts := by
@@ -336,7 +338,7 @@ lemma IsEquipartition.card_biUnion_offDiag_le (hε : 0 < ε) (hP : P.IsEquiparti
336338
apply hP.card_biUnion_offDiag_le'.trans
337339
rw [div_le_iff₀ (Nat.cast_pos.2 (P.parts_nonempty hA.ne_empty).card_pos)]
338340
have : (#A : 𝕜) + #P.parts ≤ 2 * #A := by
339-
rw [two_mul]; exact add_le_add_left (Nat.cast_le.2 P.card_parts_le_card) _
341+
rw [two_mul]; gcongr; exact P.card_parts_le_card
340342
refine (mul_le_mul_of_nonneg_left this <| by positivity).trans ?_
341343
suffices 1 ≤ ε/4 * #P.parts by
342344
rw [mul_left_comm, ← sq]

Mathlib/Combinatorics/SimpleGraph/Triangle/Counting.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ private lemma good_vertices_triangle_card [DecidableEq α] (dst : 2 * ε ≤ G.e
7878
rw [← or_and_left, and_or_left] at hx
7979
simp only [false_or, and_not_self, mul_comm (_ - _)] at hx
8080
obtain ⟨-, hxY, hsu⟩ := hx
81-
have hY : #t * ε ≤ #{y ∈ t | G.Adj x y} :=
82-
(mul_le_mul_of_nonneg_left (by linarith) (Nat.cast_nonneg _)).trans hxY
83-
have hZ : #u * ε ≤ #{y ∈ u | G.Adj x y} :=
84-
(mul_le_mul_of_nonneg_left (by linarith) (Nat.cast_nonneg _)).trans hsu
81+
have hY : #t * ε ≤ #{y ∈ t | G.Adj x y} := by
82+
refine le_trans ?_ hxY; gcongr; linarith
83+
have hZ : #u * ε ≤ #{y ∈ u | G.Adj x y} := by
84+
refine le_trans ?_ hsu; gcongr; linarith
8585
rw [card_image_of_injective _ (Prod.mk_right_injective _)]
8686
have := utu (filter_subset (G.Adj x) _) (filter_subset (G.Adj x) _) hY hZ
8787
have : ε ≤ G.edgeDensity {y ∈ t | G.Adj x y} {y ∈ u | G.Adj x y} := by
@@ -122,7 +122,7 @@ lemma triangle_counting'
122122
mul_assoc, mul_comm ε, two_mul]
123123
refine (Nat.cast_le.2 <| card_union_le _ _).trans ?_
124124
rw [Nat.cast_add]
125-
exact add_le_add h₁ h₂
125+
gcongr
126126
rintro a _ b _ t
127127
rw [Function.onFun, disjoint_left]
128128
simp only [Prod.forall, mem_image, not_exists, exists_prop, mem_filter, Prod.mk_inj,

0 commit comments

Comments
 (0)