Skip to content

Commit da5290c

Browse files
committed
chore: golf using grw (#26981)
This PR cleans up some proofs using `grw`. It also tags a few lemmas with `@[gcongr]` that were required for the proofs. Co-authored-by: Jovan Gerbscheid <jovan.gerbscheid@gmail.com>
1 parent 29700b9 commit da5290c

File tree

73 files changed

+177
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+177
-200
lines changed

Archive/Wiedijk100Theorems/CubingACube.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ theorem smallest_onBoundary {j} (bi : OnBoundary (mi_mem_bcubes : mi h v ∈ _)
355355
have hs : s.Nonempty := by
356356
rcases (nontrivial_bcubes h v).exists_ne i with ⟨i', hi', h2i'⟩
357357
exact ⟨i', hi', h2i'⟩
358-
rcases Set.exists_min_image s (w cs) (Set.toFinite _) hs with ⟨i', ⟨hi', h2i'⟩, h3i'⟩
358+
rcases Set.exists_min_image s (w <| cs ·) (Set.toFinite _) hs with ⟨i', ⟨hi', h2i'⟩, h3i'⟩
359359
rw [mem_singleton_iff] at h2i'
360360
let x := c.b j.succ + c.w - (cs i').w
361361
have hx : x < (cs i).b j.succ := by
@@ -368,8 +368,7 @@ theorem smallest_onBoundary {j} (bi : OnBoundary (mi_mem_bcubes : mi h v ∈ _)
368368
· simp only [side, not_and_or, not_lt, not_le, mem_Ico]; left; exact hx
369369
intro i'' hi'' h2i'' h3i''; constructor; swap; · apply lt_trans hx h3i''.2
370370
rw [le_sub_iff_add_le]
371-
refine le_trans ?_ (t_le_t hi'' j); gcongr; apply h3i' i'' ⟨hi'', _⟩
372-
simp [i, h2i'']
371+
grw [← t_le_t hi'', h3i' i'' ⟨hi'', h2i''⟩]
373372

374373
variable (h v)
375374

Mathlib/Algebra/Category/ModuleCat/Topology/Basic.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,9 @@ def freeMap {X Y : TopCat.{v}} (f : X ⟶ Y) : freeObj R X ⟶ freeObj R Y :=
397397
refine sInf_le ⟨continuousSMul_induced (Finsupp.lmapDomain _ _ f.hom),
398398
continuousAdd_induced (Finsupp.lmapDomain _ _ f.hom), ?_⟩
399399
rw [← coinduced_le_iff_le_induced]
400-
refine le_trans ?_ hτ₃
401-
refine le_of_eq_of_le ?_ (coinduced_mono (continuous_iff_coinduced_le.mp f.hom.2))
400+
grw [← hτ₃, ← coinduced_mono (continuous_iff_coinduced_le.mp f.hom.2)]
402401
rw [coinduced_compose, coinduced_compose]
403-
congr 1
402+
congr! 1
404403
ext x
405404
simp [coe_freeObj]⟩
406405

Mathlib/Algebra/Group/Subgroup/Basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,8 @@ theorem normalClosure_eq_top_of {N : Subgroup G} [hn : N.Normal] {g g' : G} {hg
948948
MonoidHom.restrict_apply, Subtype.mk_eq_mk, ← mul_assoc, mul_inv_cancel, one_mul]
949949
rw [mul_assoc, mul_inv_cancel, mul_one]
950950
rw [eq_top_iff, ← MonoidHom.range_eq_top.2 hs, MonoidHom.range_eq_map]
951-
refine le_trans (map_mono (eq_top_iff.1 ht)) (map_le_iff_le_comap.2 (normalClosure_le_normal ?_))
951+
grw [eq_top_iff.1 ht]
952+
refine map_le_iff_le_comap.2 (normalClosure_le_normal ?_)
952953
rw [Set.singleton_subset_iff, SetLike.mem_coe]
953954
simp only [MonoidHom.codRestrict_apply, MulEquiv.coe_toMonoidHom, MulAut.conj_apply,
954955
MonoidHom.restrict_apply, mem_comap]

Mathlib/Algebra/Lie/Engel.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ theorem lcs_le_lcs_of_is_nilpotent_span_sup_eq_top {n i j : ℕ}
119119
refine ⟨(Submodule.map_mono ih).trans ?_, le_sup_of_le_right ?_⟩
120120
· rw [Submodule.map_sup, ← Submodule.map_comp, ← Module.End.mul_eq_comp, ← pow_succ', ←
121121
I.lcs_succ]
122-
exact sup_le_sup_left coe_map_toEnd_le _
123-
· refine le_trans (mono_lie_right I ?_) (mono_lie_right I hIM)
124-
exact antitone_lowerCentralSeries R L M le_self_add
122+
grw [coe_map_toEnd_le]
123+
· norm_cast
124+
gcongr
125+
exact le_trans (antitone_lowerCentralSeries R L M le_self_add) hIM
125126

126127
theorem isNilpotentOfIsNilpotentSpanSupEqTop (hnp : IsNilpotent <| toEnd R L M x)
127128
(hIM : IsNilpotent I M) : IsNilpotent L M := by

Mathlib/Algebra/Lie/IdealOperations.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ theorem lie_eq_bot_iff : ⁅I, N⁆ = ⊥ ↔ ∀ x ∈ I, ∀ m ∈ N, ⁅(x :
153153
exact h x hx n hn
154154

155155
variable {I J N N'} in
156+
@[gcongr]
156157
theorem mono_lie (h₁ : I ≤ J) (h₂ : N ≤ N') : ⁅I, N⁆ ≤ ⁅J, N'⁆ := by
157158
intro m h
158159
rw [lieIdeal_oper_eq_span, mem_lieSpan] at h; rw [lieIdeal_oper_eq_span, mem_lieSpan]

Mathlib/Algebra/Module/Submodule/IterateMapComap.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ theorem iterateMapComap_le_succ (K : Submodule R N) (h : K.map f ≤ K.map i) (n
5252
simp_rw [iterateMapComap, iterate_succ', Function.comp_apply]
5353
calc
5454
_ ≤ (f.iterateMapComap i n K).map i := map_comap_le _ _
55-
_ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := map_mono (le_comap_map _ _)
56-
_ ≤ _ := map_mono (comap_mono ih)
55+
_ ≤ (((f.iterateMapComap i n K).map f).comap f).map i := by grw [← le_comap_map]
56+
_ ≤ _ := by gcongr; exact ih
5757

5858
/-- If `f` is surjective, `i` is injective, and there exists some `m` such that
5959
`LinearMap.iterateMapComap f i m K = LinearMap.iterateMapComap f i (m + 1) K`,

Mathlib/Algebra/Order/Archimedean/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ theorem exists_div_btwn {x y : K} {n : ℕ} (h : x < y) (nh : (y - x)⁻¹ < n)
415415
rw [div_lt_iff₀ n0']
416416
refine ⟨(lt_div_iff₀ n0').2 <| (lt_iff_lt_of_le_iff_le (zh _)).1 (lt_add_one _), ?_⟩
417417
rw [Int.cast_add, Int.cast_one]
418-
refine lt_of_le_of_lt (add_le_add_right ((zh _).1 le_rfl) _) ?_
418+
grw [(zh _).1 le_rfl]
419419
rwa [← lt_sub_iff_add_lt', ← sub_mul, ← div_lt_iff₀' (sub_pos.2 h), one_div]
420420

421421
theorem exists_rat_btwn {x y : K} (h : x < y) : ∃ q : ℚ, x < q ∧ q < y := by

Mathlib/Algebra/Order/CauSeq/BigOperators.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ lemma of_abv_le (n : ℕ) (hm : ∀ m, n ≤ m → abv (f m) ≤ a m) :
4444
· simp [abv_zero abv]
4545
simp only [Nat.succ_add, Nat.succ_eq_add_one, Finset.sum_range_succ_comm]
4646
simp only [add_assoc, sub_eq_add_neg]
47-
refine le_trans (abv_add _ _ _) ?_
4847
simp only [sub_eq_add_neg] at hi
49-
exact add_le_add (hm _ (le_add_of_nonneg_of_le (Nat.zero_le _) (le_max_left _ _))) hi
48+
grw [abv_add abv, hm _ (by omega), hi]
5049

5150
lemma of_abv (hf : IsCauSeq abs fun m ↦ ∑ n ∈ range m, abv (f n)) :
5251
IsCauSeq abv fun m ↦ ∑ n ∈ range m, f n :=
@@ -127,7 +126,7 @@ theorem _root_.cauchy_product (ha : IsCauSeq abs fun m ↦ ∑ n ∈ range m, ab
127126
∑ i ∈ range K with max N M + 1 ≤ i, abv (f i) * (2 * Q) := by
128127
gcongr
129128
rw [sub_eq_add_neg]
130-
refine le_trans (abv_add _ _ _) ?_
129+
grw [abv_add abv]
131130
rw [two_mul, abv_neg abv]
132131
gcongr <;> exact le_of_lt (hQ _)
133132
_ < ε / (4 * Q) * (2 * Q) := by

Mathlib/Algebra/Order/Field/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ instance (priority := 100) LinearOrderedSemiField.toDenselyOrdered : DenselyOrde
185185
⟨(a₁ + a₂) / 2,
186186
calc
187187
a₁ = (a₁ + a₁) / 2 := (add_self_div_two a₁).symm
188-
_ < (a₁ + a₂) / 2 := div_lt_div_of_pos_right (add_lt_add_left h _) zero_lt_two,
188+
_ < (a₁ + a₂) / 2 := by gcongr; exact zero_lt_two,
189189
calc
190-
(a₁ + a₂) / 2 < (a₂ + a₂) / 2 := div_lt_div_of_pos_right (add_lt_add_right h _) zero_lt_two
190+
(a₁ + a₂) / 2 < (a₂ + a₂) / 2 := by gcongr; exact zero_lt_two
191191
_ = a₂ := add_self_div_two a₂
192192
193193

Mathlib/Algebra/Order/Group/Multiset.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ theorem le_smul_dedup [DecidableEq α] (s : Multiset α) : ∃ n : ℕ, s ≤ n
186186
⟨(s.map fun a => count a s).fold max 0,
187187
le_iff_count.2 fun a => by
188188
rw [count_nsmul]; by_cases h : a ∈ s
189-
· refine le_trans ?_ (Nat.mul_le_mul_left _ <| count_pos.2 <| mem_dedup.2 h)
189+
· grw [← one_le_count_iff_mem.2 <| mem_dedup.2 h]
190190
have : count a s ≤ fold max 0 (map (fun a => count a s) (a ::ₘ erase s a)) := by
191191
simp
192192
rw [cons_erase h] at this

0 commit comments

Comments
 (0)