Skip to content

Commit f0b9582

Browse files
committed
refactor(Algebra): replace RingEquivClass.toRingEquiv by structure-specific coercions
Remove the coercion from `E` to `RingEquiv` assuming `RingEquivClass E` and given by `RingEquivClass.toRingEquiv`. For each concrete type, reimplement this coercion through the relevant structure projection.
1 parent b43655d commit f0b9582

File tree

27 files changed

+56
-61
lines changed

27 files changed

+56
-61
lines changed

Mathlib/Algebra/Algebra/Equiv.lean

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This is declared as the default coercion from `F` to `A ≃ₐ[R] B`. -/
6767
@[coe]
6868
def toAlgEquiv {F R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A]
6969
[Algebra R B] [EquivLike F A B] [AlgEquivClass F R A B] (f : F) : A ≃ₐ[R] B :=
70-
{ (f : A ≃ B), (f : A ≃+* B) with commutes' := commutes f }
70+
{ (f : A ≃ B), (RingEquivClass.toRingEquiv f : A ≃+* B) with commutes' := commutes f }
7171

7272
end AlgEquivClass
7373

@@ -140,22 +140,21 @@ protected theorem coe_coe {F : Type*} [EquivLike F A₁ A₂] [AlgEquivClass F R
140140
theorem coe_fun_injective : @Function.Injective (A₁ ≃ₐ[R] A₂) (A₁ → A₂) fun e => (e : A₁ → A₂) :=
141141
DFunLike.coe_injective
142142

143-
instance hasCoeToRingEquiv : CoeOut (A₁ ≃ₐ[R] A₂) (A₁ ≃+* A₂) :=
144-
⟨AlgEquiv.toRingEquiv⟩
143+
instance : CoeOut (A₁ ≃ₐ[R] A₂) (A₁ ≃+* A₂) where coe := AlgEquiv.toRingEquiv
145144

146145
@[simp]
147146
theorem coe_toEquiv : ((e : A₁ ≃ A₂) : A₁ → A₂) = e :=
148147
rfl
149148

150-
@[simp]
149+
@[deprecated "Now a syntactic equality" (since := "2026-04-09"), nolint synTaut]
151150
theorem toRingEquiv_eq_coe : e.toRingEquiv = e :=
152151
rfl
153152

154-
@[simp, norm_cast]
153+
@[simp]
155154
lemma toRingEquiv_toRingHom : ((e : A₁ ≃+* A₂) : A₁ →+* A₂) = e :=
156155
rfl
157156

158-
@[simp, norm_cast]
157+
@[simp]
159158
theorem coe_ringEquiv : ((e : A₁ ≃+* A₂) : A₁ → A₂) = e :=
160159
rfl
161160

Mathlib/Algebra/Algebra/Tower.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,14 @@ variable {R}
266266

267267
/-- Any `f : A ≃ₐ[R] B` is also an `R ⧸ I`-algebra isomorphism if the `R`-algebra structure on
268268
`A` and `B` factors via `R ⧸ I`. -/
269-
@[simps! apply]
270269
def extendScalarsOfSurjective (h : Function.Surjective (algebraMap R S))
271270
(f : A ≃ₐ[R] B) : A ≃ₐ[S] B where
272271
toRingEquiv := f
273272
commutes' := (f.toAlgHom.extendScalarsOfSurjective h).commutes'
274273

274+
@[simp] lemma coe_extendScalarsOfSurjective (h : Function.Surjective (algebraMap R S))
275+
(f : A ≃ₐ[R] B) : ⇑(extendScalarsOfSurjective h f) = f := rfl
276+
275277
@[simp]
276278
lemma restrictScalars_extendScalarsOfSurjective (h : Function.Surjective (algebraMap R S))
277279
(f : A ≃ₐ[R] B) :

Mathlib/Algebra/Order/Hom/Ring.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ This is declared as the default coercion from `F` to `α ≃+*o β`. -/
108108
@[coe]
109109
def OrderRingIsoClass.toOrderRingIso [Mul α] [Add α] [LE α] [Mul β] [Add β] [LE β]
110110
[OrderIsoClass F α β] [RingEquivClass F α β] (f : F) : α ≃+*o β :=
111-
{ (f : α ≃+* β) with map_le_map_iff' := map_le_map_iff f }
111+
{ (RingEquivClass.toRingEquiv f : α ≃+* β) with map_le_map_iff' := map_le_map_iff f }
112112

113113
/-- Any type satisfying `OrderRingIsoClass` can be cast into `OrderRingIso` via
114114
`OrderRingIsoClass.toOrderRingIso`. -/
@@ -316,6 +316,8 @@ instance : RingEquivClass (α ≃+*o β) α β where
316316
map_mul f := f.map_mul'
317317
map_add f := f.map_add'
318318

319+
instance : CoeOut (α ≃+*o β) (α ≃+* β) where coe := toRingEquiv
320+
319321
theorem toFun_eq_coe (f : α ≃+*o β) : f.toFun = f :=
320322
rfl
321323

@@ -331,15 +333,15 @@ theorem coe_mk (e : α ≃+* β) (h) : ⇑(⟨e, h⟩ : α ≃+*o β) = e :=
331333
theorem mk_coe (e : α ≃+*o β) (h) : (⟨e, h⟩ : α ≃+*o β) = e :=
332334
ext fun _ => rfl
333335

334-
@[simp]
336+
@[deprecated "Now a syntactic equality" (since := "2026-04-09"), nolint synTaut]
335337
theorem toRingEquiv_eq_coe (f : α ≃+*o β) : f.toRingEquiv = f :=
336338
RingEquiv.ext fun _ => rfl
337339

338340
@[simp]
339341
theorem toOrderIso_eq_coe (f : α ≃+*o β) : f.toOrderIso = f :=
340342
OrderIso.ext rfl
341343

342-
@[simp, norm_cast]
344+
@[simp]
343345
theorem coe_toRingEquiv (f : α ≃+*o β) : ⇑(f : α ≃+* β) = f :=
344346
rfl
345347

Mathlib/Algebra/Ring/Equiv.lean

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ def toRingEquiv [Mul α] [Add α] [Mul β] [Add β] [EquivLike F α β] [RingEqu
117117

118118
end RingEquivClass
119119

120-
/-- Any type satisfying `RingEquivClass` can be cast into `RingEquiv` via
121-
`RingEquivClass.toRingEquiv`. -/
122-
instance [Mul α] [Add α] [Mul β] [Add β] [EquivLike F α β] [RingEquivClass F α β] :
123-
CoeTC F (α ≃+* β) :=
124-
⟨RingEquivClass.toRingEquiv⟩
125-
126120
namespace RingEquiv
127121

128122
section Basic

Mathlib/Algebra/Star/StarAlgHom.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ an actual `StarAlgEquiv`. This is declared as the default coercion from `F` to `
667667
def toStarAlgEquiv {F R A B : Type*} [Add A] [Mul A] [SMul R A] [Star A] [Add B] [Mul B] [SMul R B]
668668
[Star B] [EquivLike F A B] [NonUnitalAlgEquivClass F R A B] [StarHomClass F A B]
669669
(f : F) : A ≃⋆ₐ[R] B :=
670-
{ (f : A ≃+* B) with
670+
{ (RingEquivClass.toRingEquiv f : A ≃+* B) with
671671
map_star' := map_star f
672672
map_smul' := map_smul f }
673673

@@ -784,8 +784,7 @@ theorem refl_symm : (StarAlgEquiv.refl : A ≃⋆ₐ[R] A).symm = StarAlgEquiv.r
784784
theorem toStarRingEquiv_symm (e : A ≃⋆ₐ[R] B) : (e.symm : B ≃⋆+* A) = (e : A ≃⋆+* B).symm := rfl
785785

786786
@[simp]
787-
theorem toRingEquiv_symm (e : A ≃⋆ₐ[R] B) : (e.symm : B ≃+* A) = (e : A ≃+* B).symm :=
788-
rfl
787+
theorem toRingEquiv_symm (e : A ≃⋆ₐ[R] B) : (e : A ≃⋆+* B).symm = (e : A ≃+* B).symm := rfl
789788

790789
/-- Transitivity of `StarAlgEquiv`. -/
791790
@[trans]

Mathlib/Algebra/Star/StarRingHom.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ instance (priority := 100) {F A B : Type*} [NonUnitalNonAssocSemiring A] [Star A
274274
@[coe]
275275
def toStarRingEquiv {F A B : Type*} [Add A] [Mul A] [Star A] [Add B] [Mul B] [Star B]
276276
[EquivLike F A B] [RingEquivClass F A B] [StarRingEquivClass F A B] (f : F) : A ≃⋆+* B :=
277-
{ (f : A ≃+* B) with
277+
{ (RingEquivClass.toRingEquiv f : A ≃+* B) with
278278
map_star' := map_star f }
279279

280280
/-- Any type satisfying `StarRingEquivClass` can be cast into `StarRingEquiv` via
@@ -313,7 +313,9 @@ instance : FunLike (A ≃⋆+* B) A B where
313313
coe f := f.toFun
314314
coe_injective' := DFunLike.coe_injective
315315

316-
@[simp]
316+
instance : CoeOut (A ≃⋆+* B) (A ≃+* B) where coe := toRingEquiv
317+
318+
@[deprecated "Now a syntactic equality" (since := "2026-04-09"), nolint synTaut]
317319
theorem toRingEquiv_eq_coe (e : A ≃⋆+* B) : e.toRingEquiv = e :=
318320
rfl
319321

Mathlib/AlgebraicGeometry/AffineScheme.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,14 @@ def SpecMapRestrictBasicOpenIso {R S : CommRingCat} (f : R ⟶ S) (r : R) :
985985
change _ =
986986
(f ≫ (Scheme.ΓSpecIso S).inv ≫ (Spec S).presheaf.map (homOfLE le_top).op)
987987
ext
988-
simp only [Localization.awayMap, IsLocalization.Away.map, AlgEquiv.toRingEquiv_eq_coe,
988+
simp only [Localization.awayMap, IsLocalization.Away.map,
989989
RingEquiv.toCommRingCatIso_hom, AlgEquiv.toRingEquiv_toRingHom, CommRingCat.hom_comp,
990990
CommRingCat.hom_ofHom, RingHom.comp_apply, IsLocalization.map_eq, RingHom.coe_coe,
991991
AlgEquiv.commutes, IsAffineOpen.algebraMap_Spec_obj]
992992
· enter [2, 2, 1]; tactic =>
993993
change _ = (Scheme.ΓSpecIso R).inv ≫ (Spec R).presheaf.map (homOfLE le_top).op
994994
ext
995-
simp only [AlgEquiv.toRingEquiv_eq_coe, RingEquiv.toCommRingCatIso_hom,
995+
simp only [RingEquiv.toCommRingCatIso_hom,
996996
AlgEquiv.toRingEquiv_toRingHom, CommRingCat.hom_comp, CommRingCat.hom_ofHom,
997997
RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, AlgEquiv.commutes,
998998
IsAffineOpen.algebraMap_Spec_obj, homOfLE_leOfHom]

Mathlib/FieldTheory/RatFunc/IntermediateField.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ theorem irreducible_minpolyX' (hf : ¬∃ c, f = C c) : Irreducible (f.minpolyX
127127
let φ : K[X][X] := f.num.map (algebraMap ..) -
128128
Polynomial.C Polynomial.X * f.denom.map (algebraMap ..)
129129
have φ_map : φ.mapEquiv e.toRingEquiv = (f.minpolyX K[f]) := by
130-
simp only [AlgEquiv.toRingEquiv_eq_coe, algebraMap_eq, map_sub, mapEquiv_apply,
130+
simp only [algebraMap_eq, map_sub, mapEquiv_apply,
131131
AlgEquiv.toRingEquiv_toRingHom, algEquivOfTranscendental_coe, Polynomial.map_map, map_mul,
132132
map_C, RingHom.coe_coe, aeval_X, e, φ]
133133
congr 2 <;> ext <;> simp

Mathlib/NumberTheory/KummerDedekind.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ lemma quotMapEquivQuotQuotMap_symm_apply (hx : (conductor R x).comap (algebraMap
8787
(hx' : IsIntegral R x) (Q : R[X]) :
8888
(quotMapEquivQuotQuotMap hx hx').symm (Q.map (Ideal.Quotient.mk I)) = Q.aeval x := by
8989
apply (quotMapEquivQuotQuotMap hx hx').injective
90-
rw [quotMapEquivQuotQuotMap, AlgEquiv.toRingEquiv_eq_coe, RingEquiv.symm_trans_apply,
90+
rw [quotMapEquivQuotQuotMap, RingEquiv.symm_trans_apply,
9191
RingEquiv.symm_symm, RingEquiv.coe_trans, Function.comp_apply, RingEquiv.symm_apply_apply,
9292
RingEquiv.symm_trans_apply, quotEquivOfEq_symm, quotEquivOfEq_mk]
9393
congr

Mathlib/NumberTheory/NumberField/CMField.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ theorem mem_realUnits_iff (u : (𝓞 K)ˣ) :
279279
theorem unitsComplexConj_eq_self_iff [Algebra.IsIntegral ℚ K] (u : (𝓞 K)ˣ) :
280280
unitsComplexConj K u = u ↔ u ∈ realUnits K := by
281281
simp_rw [Units.ext_iff, mem_realUnits_iff, RingOfIntegers.ext_iff, Units.coe_mapEquiv,
282-
AlgEquiv.toRingEquiv_eq_coe, RingEquiv.coe_toMulEquiv, RingOfIntegers.mapRingEquiv_apply,
282+
RingEquiv.coe_toMulEquiv, RingOfIntegers.mapRingEquiv_apply,
283283
AlgEquiv.coe_ringEquiv, Units.complexConj_eq_self_iff,
284284
IsScalarTower.algebraMap_apply (𝓞 K⁺) (𝓞 K) K]
285285

0 commit comments

Comments
 (0)