Skip to content

Commit 2a813c4

Browse files
committed
chore: scope dangerous instances for monoid objects (#37883)
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
1 parent 1a1f872 commit 2a813c4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Mathlib/CategoryTheory/Monoidal/Internal/Module.lean

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ variable {R : Type u} [CommRing R]
4040

4141
namespace MonModuleEquivalenceAlgebra
4242

43-
instance MonObj.toRing (A : ModuleCat.{u} R) [MonObj A] : Ring A :=
43+
/-- The ring structure on a monoid object.
44+
This instance is dangerous as it doesn't round trip from a ring to a monoid object and then back
45+
to a ring, since the `npow` field is lost in the middle. Therefore, it is scoped. -/
46+
@[implicit_reducible]
47+
def MonObj.toRing (A : ModuleCat.{u} R) [MonObj A] : Ring A :=
4448
{ (inferInstance : AddCommGroup A) with
4549
one := η[A] (1 : R)
4650
mul := fun x y => μ[A] (x ⊗ₜ y)
@@ -65,7 +69,12 @@ instance MonObj.toRing (A : ModuleCat.{u} R) [MonObj A] : Ring A :=
6569
mul_zero := fun x => show μ[A] _ = 0 by
6670
rw [TensorProduct.tmul_zero, map_zero] }
6771

68-
instance Algebra_of_Mon_ (A : ModuleCat.{u} R) [MonObj A] : Algebra R A where
72+
scoped[ModuleCat.MonModuleEquivalenceAlgebra] attribute [instance] MonObj.toRing
73+
74+
/-- The algebra structure on a monoid object.
75+
This instance is dangerous as it doesn't round trip from a ring to a monoid object and then back
76+
to a ring, since the `npow` field is lost in the middle. Therefore, it is scoped. -/
77+
scoped instance Algebra_of_Mon_ (A : ModuleCat.{u} R) [MonObj A] : Algebra R A where
6978
algebraMap :=
7079
{ η[A].hom with
7180
map_zero' := η[A].hom.map_zero

0 commit comments

Comments
 (0)