Skip to content

Commit 6e294ac

Browse files
committed
chore: use grw, gcongr even more (#30632)
Also delete a redundant instance.
1 parent 60f4da8 commit 6e294ac

File tree

11 files changed

+32
-47
lines changed

11 files changed

+32
-47
lines changed

Archive/Imo/Imo1982Q1.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ lemma imo1982_q1 {f : ℕ+ → ℕ} (hf : IsGood f) : f 1982 = 660 := by
114114
suffices h : 33343333 by simp at h
115115
calc
116116
3334 = 5 * f 1982 + 29 * f 3 + f 2 := by rw [hf.f₃, hf.f₂, hr, add_zero, mul_one]
117-
(5 : ℕ+) * f 1982 + (29 : ℕ+) * f 3 + f 2 ≤ f (5 * 1982 + 29 * 3) + f 2 :=
118-
add_le_add_right hf.superlinear _
117+
(5 : ℕ+) * f 1982 + (29 : ℕ+) * f 3 + f 2 ≤ f (5 * 1982 + 29 * 3) + f 2 := by
118+
grw [hf.superlinear]
119119
_ ≤ f (5 * 1982 + 29 * 3 + 2) := hf.superadditive
120120
_ = 3333 := hf.f_9999

Archive/Imo/Imo2013Q5.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
178178
calc
179179
↑(pn + 2) * f x = (↑pn + 1 + 1) * f x := by norm_cast
180180
_ = (↑pn + 1) * f x + f x := by ring
181-
_ ≤ f (↑pn.succ * x) + f x := mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
181+
_ ≤ f (↑pn.succ * x) + f x := by norm_cast; grw [hpn pn.succ_pos]
182182
_ ≤ f ((↑pn + 1) * x + x) := by exact_mod_cast H2 _ _ (mul_pos pn.cast_add_one_pos hx) hx
183183
_ = f ((↑pn + 1 + 1) * x) := by ring_nf
184184
_ = f (↑(pn + 2) * x) := by norm_cast

Mathlib/Algebra/Order/AbsoluteValue/Basic.lean

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,8 @@ lemma apply_nat_le_self [IsOrderedRing S] (n : ℕ) : abv n ≤ n := by
184184
· simp [Subsingleton.eq_zero (n : R)]
185185
induction n with
186186
| zero => simp
187-
| succ n hn =>
188-
simp only [Nat.cast_succ]
189-
calc
190-
abv (n + 1) ≤ abv n + abv 1 := abv.add_le ..
191-
_ = abv n + 1 := congrArg (abv n + ·) abv.map_one
192-
_ ≤ n + 1 := add_le_add_right hn 1
187+
| succ n ih =>
188+
· grw [Nat.cast_succ, Nat.cast_succ, abv.add_le, abv.map_one, ih]
193189

194190
end IsDomain
195191

Mathlib/Algebra/Order/GroupWithZero/WithZero.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ instance {α : Type*} [Mul α] [Preorder α] [MulLeftStrictMono α] :
3232
PosMulStrictMono (WithZero α) where
3333
mul_lt_mul_of_pos_left
3434
| (x : α), hx, 0, (b : α), _ => by simpa only [mul_zero] using WithZero.zero_lt_coe _
35-
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; exact mul_lt_mul_left' h x
35+
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
3636

3737
open Function in
3838
instance {α : Type*} [Mul α] [Preorder α] [MulRightStrictMono α] :
3939
MulPosStrictMono (WithZero α) where
4040
mul_lt_mul_of_pos_right
4141
| (x : α), hx, 0, (b : α), _ => by simpa only [mul_zero] using WithZero.zero_lt_coe _
42-
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; exact mul_lt_mul_right' h x
42+
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
4343

4444
instance {α : Type*} [Mul α] [Preorder α] [MulLeftMono α] :
4545
PosMulMono (WithZero α) where
4646
mul_le_mul_of_nonneg_left
4747
| 0, _, a, b, _ => by simp
4848
| (x : α), _, 0, _, _ => by simp
4949
| (x : α), _, (a : α), 0, h => by simp at h
50-
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; exact mul_le_mul_left' h x
50+
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
5151

5252
-- This makes `lt_mul_of_le_of_one_lt'` work on `ℤᵐ⁰`
5353
open Function in
@@ -57,7 +57,7 @@ instance {α : Type*} [Mul α] [Preorder α] [MulRightMono α] :
5757
| 0, _, a, b, _ => by simp
5858
| (x : α), _, 0, _, _ => by simp
5959
| (x : α), _, (a : α), 0, h => by simp at h
60-
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; exact mul_le_mul_right' h x
60+
| (x : α), hx, (a : α), (b : α), h => by norm_cast at h ⊢; gcongr
6161

6262
section Units
6363

Mathlib/Algebra/Polynomial/BigOperators.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ theorem degree_list_sum_le (l : List S[X]) : degree l.sum ≤ (l.map natDegree).
8686
theorem natDegree_list_prod_le (l : List S[X]) : natDegree l.prod ≤ (l.map natDegree).sum := by
8787
induction l with
8888
| nil => simp
89-
| cons hd tl IH => simpa using natDegree_mul_le.trans (add_le_add_left IH _)
89+
| cons p l ih => dsimp; grw [natDegree_mul_le, ih]
9090

9191
theorem degree_list_prod_le (l : List S[X]) : degree l.prod ≤ (l.map degree).sum := by
9292
induction l with
9393
| nil => simp
94-
| cons hd tl IH => simpa using (degree_mul_le _ _).trans (add_le_add_left IH _)
94+
| cons p l ih => dsimp; grw [degree_mul_le, ih]
9595

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

Mathlib/Algebra/Polynomial/Degree/Definitions.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ natDegree_mul_le.trans <| add_le_add ‹_› ‹_›
479479
theorem natDegree_pow_le {p : R[X]} {n : ℕ} : (p ^ n).natDegree ≤ n * p.natDegree := by
480480
induction n with
481481
| zero => simp
482-
| succ i hi =>
483-
rw [pow_succ, Nat.succ_mul]
484-
apply le_trans natDegree_mul_le (add_le_add_right hi _)
482+
| succ n ih => grw [pow_succ, Nat.succ_mul, natDegree_mul_le, ih]
485483

486484
theorem natDegree_pow_le_of_le (n : ℕ) (hp : natDegree p ≤ m) :
487485
natDegree (p ^ n) ≤ n * m :=

Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,6 @@ variable {G : Type*} [NormedAddCommGroup G]
704704
theorem coeFn_le [PartialOrder G] (f g : Lp.simpleFunc G p μ) : (f : α → G) ≤ᵐ[μ] g ↔ f ≤ g := by
705705
rw [← Subtype.coe_le_coe, ← Lp.coeFn_le]
706706

707-
instance instAddLeftMono [PartialOrder G] [IsOrderedAddMonoid G] :
708-
AddLeftMono (Lp.simpleFunc G p μ) := by
709-
refine ⟨fun f g₁ g₂ hg₁₂ => ?_⟩
710-
exact add_le_add_left hg₁₂ f
711-
712707
variable (p μ G)
713708

714709
theorem coeFn_zero : (0 : Lp.simpleFunc G p μ) =ᵐ[μ] (0 : α → G) :=

Mathlib/MeasureTheory/Integral/IntervalIntegral/TrapezoidalRule.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ theorem sum_trapezoidal_error_adjacent_intervals {f : ℝ → ℝ} {N : ℕ} {a
106106
suffices ∀ {k : ℕ}, k ≤ N → a + k * h ∈ [[a, a + N * h]] from
107107
IntervalIntegrable.mono h_f_int (Set.uIcc_subset_uIcc (this hk.le) (this hk)) le_rfl
108108
rcases le_total h 0 with h_neg | h_pos <;> intro k hk <;> rw [← Nat.cast_le (α := ℝ)] at hk
109-
· exact Set.mem_uIcc_of_ge (add_le_add_left (mul_le_mul_of_nonpos_right hk h_neg) a)
110-
(add_le_of_nonpos_right (mul_nonpos_of_nonneg_of_nonpos k.cast_nonneg h_neg))
109+
· simpa [Set.mem_uIcc] using .inr
110+
⟨mul_le_mul_of_nonpos_right hk h_neg, mul_nonpos_of_nonneg_of_nonpos k.cast_nonneg h_neg
111111
· exact Set.mem_uIcc_of_le (le_add_of_nonneg_right (by positivity)) (by grw [hk])
112112

113113
/-- The most basic case possible: two ordered points, with N = 1. This lemma is used in the proof of

Mathlib/RingTheory/PowerSeries/Order.lean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ theorem le_order_mul (φ ψ : R⟦X⟧) : order φ + order ψ ≤ order (φ * ψ
184184
theorem le_order_pow (φ : R⟦X⟧) (n : ℕ) : n • order φ ≤ order (φ ^ n) := by
185185
induction n with
186186
| zero => simp
187-
| succ n hn =>
188-
simp only [add_smul, one_smul, pow_succ]
189-
apply le_trans _ (le_order_mul _ _)
190-
exact add_le_add_right hn φ.order
187+
| succ n ih => grw [add_smul, one_smul, pow_succ, ih, le_order_mul]
191188

192189
theorem le_order_prod {R : Type*} [CommSemiring R] {ι : Type*} (φ : ι → R⟦X⟧) (s : Finset ι) :
193190
∑ i ∈ s, (φ i).order ≤ (∏ i ∈ s, φ i).order := by

Mathlib/SetTheory/Ordinal/NaturalOps.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,13 @@ theorem nmul_lt_nmul_of_pos_left (h₁ : a < b) (h₂ : 0 < c) : c ⨳ a < c ⨳
531531
theorem nmul_lt_nmul_of_pos_right (h₁ : a < b) (h₂ : 0 < c) : a ⨳ c < b ⨳ c :=
532532
lt_nmul_iff.2 ⟨a, h₁, 0, h₂, by simp⟩
533533

534+
@[gcongr]
534535
theorem nmul_le_nmul_left (h : a ≤ b) (c) : c ⨳ a ≤ c ⨳ b := by
535536
rcases lt_or_eq_of_le h with (h₁ | rfl) <;> rcases (eq_zero_or_pos c).symm with (h₂ | rfl)
536537
· exact (nmul_lt_nmul_of_pos_left h₁ h₂).le
537538
all_goals simp
538539

540+
@[gcongr]
539541
theorem nmul_le_nmul_right (h : a ≤ b) (c) : a ⨳ c ≤ b ⨳ c := by
540542
rw [nmul_comm, nmul_comm b]
541543
exact nmul_le_nmul_left h c
@@ -727,7 +729,7 @@ theorem mul_le_nmul (a b : Ordinal.{u}) : a * b ≤ a ⨳ b := by
727729
rcases eq_zero_or_pos a with (rfl | ha)
728730
· simp
729731
· rw [(isNormal_mul_right ha).apply_of_isSuccLimit hc, Ordinal.iSup_le_iff]
730-
rintro ⟨i, hi
731-
exact (H i hi).trans (nmul_le_nmul_left hi.le a)
732+
rintro ⟨i, (hi : i < c)
733+
grw [H i hi, hi]
732734

733735
end Ordinal

0 commit comments

Comments
 (0)