Skip to content

Commit 6ffd1a5

Browse files
kim-emScott Morrison
andcommitted
chore: cleanup of some ext porting notes (#5176)
Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
1 parent afa4bb0 commit 6ffd1a5

File tree

8 files changed

+14
-37
lines changed

8 files changed

+14
-37
lines changed

Mathlib/Algebra/ContinuedFractions/Basic.lean

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ We store the sequence of partial numerators and denominators in a sequence of
112112
`GeneralizedContinuedFraction.Pair`s `s`.
113113
For convenience, one often writes `[h; (a₀, b₀), (a₁, b₁), (a₂, b₂),...]`.
114114
-/
115-
@[ext] -- Porting note: added to replace the manually written ext lemmas
115+
@[ext]
116116
structure GeneralizedContinuedFraction where
117117
/-- Head term -/
118118
h : α
119119
/-- Sequence of partial numerator and denominator pairs. -/
120120
s : Stream'.Seq <| Pair α
121121
#align generalized_continued_fraction GeneralizedContinuedFraction
122+
#align generalized_continued_fraction.ext_iff GeneralizedContinuedFraction.ext_iff
123+
#align generalized_continued_fraction.ext GeneralizedContinuedFraction.ext
122124

123125
variable {α}
124126

@@ -403,8 +405,3 @@ def convergents' (g : GeneralizedContinuedFraction K) (n : ℕ) : K :=
403405
#align generalized_continued_fraction.convergents' GeneralizedContinuedFraction.convergents'
404406

405407
end GeneralizedContinuedFraction
406-
407-
-- Porting note: The `ext`-lemmas that were here can be autogenerated by
408-
-- the `@[ext]` attribute on `GeneralizedContinuedFraction`.
409-
#align generalized_continued_fraction.ext_iff GeneralizedContinuedFraction.ext_iff
410-
#align generalized_continued_fraction.ext GeneralizedContinuedFraction.ext

Mathlib/Algebra/DirectSum/Basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Note: `open DirectSum` will enable the notation `⨁ i, β i` for `DirectSum β`
3838
def DirectSum [∀ i, AddCommMonoid (β i)] : Type _ :=
3939
-- Porting note: Failed to synthesize
4040
-- Π₀ i, β i deriving AddCommMonoid, Inhabited
41+
-- See https://github.com/leanprover-community/mathlib4/issues/5020
4142
Π₀ i, β i
4243
#align direct_sum DirectSum
4344

@@ -209,7 +210,7 @@ theorem toAddMonoid_of (i) (x : β i) : toAddMonoid φ (of β i x) = φ i x :=
209210

210211
theorem toAddMonoid.unique (f : ⨁ i, β i) : ψ f = toAddMonoid (fun i => ψ.comp (of β i)) f := by
211212
congr
212-
-- Porting note: ext applied unsuitable ext lemma
213+
-- Porting note: ext applies addHom_ext' here, which isn't what we want.
213214
apply Dfinsupp.addHom_ext'
214215
simp [toAddMonoid, of]
215216
#align direct_sum.to_add_monoid.unique DirectSum.toAddMonoid.unique

Mathlib/Algebra/DirectSum/Ring.lean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,7 @@ private theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := by
254254
simp only [coe_comp, Function.comp_apply, AddMonoidHom.compHom_apply_apply, aux, flip_apply,
255255
AddMonoidHom.flipHom_apply] at sol
256256
exact sol
257-
-- Porting note: Next three lines used to be a single `ext` which does not work anymore
258-
refine DirectSum.addHom_ext' (fun ai ↦ AddMonoidHom.ext (fun ax ↦ ?_))
259-
refine DirectSum.addHom_ext' (fun bi ↦ AddMonoidHom.ext (fun bx ↦ ?_))
260-
refine DirectSum.addHom_ext' (fun ci ↦ AddMonoidHom.ext (fun cx ↦ ?_))
257+
ext ai ax bi bx ci cx
261258
dsimp only [coe_comp, Function.comp_apply, AddMonoidHom.compHom_apply_apply, flip_apply,
262259
AddMonoidHom.flipHom_apply]
263260
simp_rw [mulHom_of_of]

Mathlib/Algebra/Free.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ def lift : (α → β) ≃ (FreeMagma α →ₙ* β) where
119119
map_mul' := fun x y ↦ rfl }
120120
invFun F := F ∘ of
121121
left_inv f := by rfl
122-
-- Porting note: replaced ext by FreeMagma.hom_ext
123-
right_inv F := FreeMagma.hom_ext (rfl)
122+
right_inv F := by ext; rfl
124123
#align free_magma.lift FreeMagma.lift
125124

126125
@[to_additive (attr := simp)]
@@ -468,7 +467,7 @@ variable {α : Type u}
468467
@[to_additive]
469468
instance : Semigroup (FreeSemigroup α) where
470469
mul L1 L2 := ⟨L1.1, L1.2 ++ L2.1 :: L2.2
471-
-- Porting note: replaced ext by FreeSemigroup.ext
470+
-- Porting note: replaced ext by FreeSemigroup.ext
472471
mul_assoc _L1 _L2 _L3 := FreeSemigroup.ext _ _ rfl <| List.append_assoc _ _ _
473472

474473
@[to_additive (attr := simp)]

Mathlib/Algebra/FreeMonoid/Basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ theorem lift_restrict (f : FreeMonoid α →* M) : lift (f ∘ of) = f := lift.a
269269
#align free_add_monoid.lift_restrict FreeAddMonoid.lift_restrict
270270

271271
@[to_additive]
272-
theorem comp_lift (g : M →* N) (f : α → M) : g.comp (lift f) = lift (g ∘ f) :=
273-
-- Porting note: replace ext by FreeMonoid.hom_eq
274-
FreeMonoid.hom_eq (by simp)
272+
theorem comp_lift (g : M →* N) (f : α → M) : g.comp (lift f) = lift (g ∘ f) := by
273+
ext
274+
simp
275275
#align free_monoid.comp_lift FreeMonoid.comp_lift
276276
#align free_add_monoid.comp_lift FreeAddMonoid.comp_lift
277277

Mathlib/Data/Bitvec/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ theorem decide_addLsb_mod_two {x b} : decide (addLsb x b % 2 = 1) = b := by
127127

128128
theorem ofNat_toNat {n : ℕ} (v : Bitvec n) : Bitvec.ofNat n v.toNat = v := by
129129
cases' v with xs h
130-
-- Porting note: was `ext1`
130+
-- Porting note: was `ext1`, but that now applies `Vector.ext` rather than `Subtype.ext`.
131131
apply Subtype.ext
132132
change Vector.toList _ = xs
133133
dsimp [Bitvec.toNat, bitsToNat]

Mathlib/Data/Dfinsupp/Multiset.lean

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,7 @@ theorem toDfinsupp_singleton (a : α) : toDfinsupp {a} = Dfinsupp.single a 1 :=
8383
/-- `Multiset.toDfinsupp` as an `AddEquiv`. -/
8484
@[simps! apply symm_apply]
8585
def equivDfinsupp : Multiset α ≃+ Π₀ _ : α, ℕ :=
86-
AddMonoidHom.toAddEquiv Multiset.toDfinsupp Dfinsupp.toMultiset
87-
(by
88-
-- Porting note: used to be ext.
89-
/- potential bug: in lean 3, `trace.ext` outputs
90-
"matched goal to rule: dfinsupp.add_hom_ext'"
91-
but that lemma does not apply!-/
92-
apply Multiset.addHom_ext
93-
simp)
94-
(by
95-
-- Porting note: used to be ext
96-
apply Dfinsupp.addHom_ext
97-
simp)
86+
AddMonoidHom.toAddEquiv Multiset.toDfinsupp Dfinsupp.toMultiset (by ext; simp) (by ext; simp)
9887
#align multiset.equiv_dfinsupp Multiset.equivDfinsupp
9988

10089
@[simp]

Mathlib/Data/Finsupp/Basic.lean

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,16 +628,10 @@ def mapDomainEmbedding {α β : Type _} (f : α ↪ β) : (α →₀ ℕ) ↪ β
628628
theorem mapDomain.addMonoidHom_comp_mapRange [AddCommMonoid N] (f : α → β) (g : M →+ N) :
629629
(mapDomain.addMonoidHom f).comp (mapRange.addMonoidHom g) =
630630
(mapRange.addMonoidHom g).comp (mapDomain.addMonoidHom f) := by
631-
apply Finsupp.addHom_ext'
632-
intro x
633-
apply AddMonoidHom.ext
634-
intro x_1
635-
apply Finsupp.ext
636-
intro a
631+
ext
637632
simp only [AddMonoidHom.coe_comp, Finsupp.mapRange_single, Finsupp.mapDomain.addMonoidHom_apply,
638633
Finsupp.singleAddHom_apply, eq_self_iff_true, Function.comp_apply, Finsupp.mapDomain_single,
639634
Finsupp.mapRange.addMonoidHom_apply]
640-
-- porting note: this is ugly, just expanded the Lean 3 proof; `ext` didn't work in the same way
641635
#align finsupp.map_domain.add_monoid_hom_comp_map_range Finsupp.mapDomain.addMonoidHom_comp_mapRange
642636

643637
/-- When `g` preserves addition, `mapRange` and `mapDomain` commute. -/

0 commit comments

Comments
 (0)