Skip to content

Commit ac1246f

Browse files
committed
feat(CategoryTheory/Monoidal): define Mon_ by using Mon_Class (#24646)
The main change is from ```lean structure Mon_ where X : C one : πŸ™_ C ⟢ X mul : X βŠ— X ⟢ X one_mul : (one β–· X) ≫ mul = (Ξ»_ X).hom := by aesop_cat mul_one : (X ◁ one) ≫ mul = (ρ_ X).hom := by aesop_cat mul_assoc : (mul β–· X) ≫ mul = (Ξ±_ X X X).hom ≫ (X ◁ mul) ≫ mul := by aesop_cat ``` to ```lean structure Mon_ where X : C [mon : Mon_Class X] ``` - [ ] depends on: #24597
1 parent cab41c5 commit ac1246f

File tree

24 files changed

+996
-774
lines changed

24 files changed

+996
-774
lines changed

β€ŽMathlib/Algebra/Category/CoalgCat/ComonEquivalence.leanβ€Ž

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ universe v u
3636

3737
namespace CoalgCat
3838

39-
open CategoryTheory MonoidalCategory
39+
open CategoryTheory MonoidalCategory Comon_Class
4040

4141
variable {R : Type u} [CommRing R]
4242

43-
/-- An `R`-coalgebra is a comonoid object in the category of `R`-modules. -/
44-
@[simps X counit comul] def toComonObj (X : CoalgCat R) : Comon_ (ModuleCat R) where
45-
X := ModuleCat.of R X
43+
@[simps counit comul]
44+
noncomputable instance (X : CoalgCat R) : Comon_Class (ModuleCat.of R X) where
4645
counit := ModuleCat.ofHom Coalgebra.counit
4746
comul := ModuleCat.ofHom Coalgebra.comul
48-
counit_comul := ModuleCat.hom_ext <| by simpa using Coalgebra.rTensor_counit_comp_comul
49-
comul_counit := ModuleCat.hom_ext <| by simpa using Coalgebra.lTensor_counit_comp_comul
50-
comul_assoc := ModuleCat.hom_ext <| by simp_rw [ModuleCat.of_coe]; exact Coalgebra.coassoc.symm
47+
counit_comul' := ModuleCat.hom_ext <| by simpa using Coalgebra.rTensor_counit_comp_comul
48+
comul_counit' := ModuleCat.hom_ext <| by simpa using Coalgebra.lTensor_counit_comp_comul
49+
comul_assoc' := ModuleCat.hom_ext <| by simp_rw [ModuleCat.of_coe]; exact Coalgebra.coassoc.symm
50+
51+
/-- An `R`-coalgebra is a comonoid object in the category of `R`-modules. -/
52+
@[simps X]
53+
noncomputable def toComonObj (X : CoalgCat R) : Comon_ (ModuleCat R) := ⟨ModuleCat.of R X⟩
5154

5255
variable (R) in
5356
/-- The natural functor from `R`-coalgebras to comonoid objects in the category of `R`-modules. -/
@@ -62,26 +65,26 @@ def toComon : CoalgCat R β₯€ Comon_ (ModuleCat R) where
6265
/-- A comonoid object in the category of `R`-modules has a natural comultiplication
6366
and counit. -/
6467
@[simps]
65-
noncomputable instance ofComonObjCoalgebraStruct (X : Comon_ (ModuleCat R)) :
66-
CoalgebraStruct R X.X where
67-
comul := X.comul.hom
68-
counit := X.counit.hom
68+
noncomputable instance ofComonObjCoalgebraStruct (X : ModuleCat R) [Comon_Class X] :
69+
CoalgebraStruct R X where
70+
comul := Ξ”[X].hom
71+
counit := Ξ΅[X].hom
6972

7073
/-- A comonoid object in the category of `R`-modules has a natural `R`-coalgebra
7174
structure. -/
72-
def ofComonObj (X : Comon_ (ModuleCat R)) : CoalgCat R :=
73-
{ ModuleCat.of R X.X with
75+
noncomputable def ofComonObj (X : ModuleCat R) [Comon_Class X] : CoalgCat R :=
76+
{ ModuleCat.of R X with
7477
instCoalgebra :=
7578
{ ofComonObjCoalgebraStruct X with
76-
coassoc := ModuleCat.hom_ext_iff.mp X.comul_assoc.symm
77-
rTensor_counit_comp_comul := ModuleCat.hom_ext_iff.mp X.counit_comul
78-
lTensor_counit_comp_comul := ModuleCat.hom_ext_iff.mp X.comul_counit } }
79+
coassoc := ModuleCat.hom_ext_iff.mp (comul_assoc X).symm
80+
rTensor_counit_comp_comul := ModuleCat.hom_ext_iff.mp (counit_comul X)
81+
lTensor_counit_comp_comul := ModuleCat.hom_ext_iff.mp (comul_counit X) } }
7982

8083
variable (R)
8184

8285
/-- The natural functor from comonoid objects in the category of `R`-modules to `R`-coalgebras. -/
83-
def ofComon : Comon_ (ModuleCat R) β₯€ CoalgCat R where
84-
obj X := ofComonObj X
86+
noncomputable def ofComon : Comon_ (ModuleCat R) β₯€ CoalgCat R where
87+
obj X := ofComonObj X.X
8588
map f :=
8689
{ toCoalgHom' :=
8790
{ f.hom.hom with
@@ -122,8 +125,10 @@ theorem tensorObj_comul (K L : CoalgCat R) :
122125
βˆ˜β‚— TensorProduct.map Coalgebra.comul Coalgebra.comul := by
123126
rw [ofComonObjCoalgebraStruct_comul]
124127
dsimp only [Equivalence.symm_inverse, comonEquivalence_functor, toComon_obj]
125-
simp only [Comon_.monoidal_tensorObj_comul, toComonObj_X, ModuleCat.of_coe, toComonObj_comul,
126-
tensorΞΌ_eq_tensorTensorTensorComm]
128+
simp only [Comon_.monoidal_tensorObj_comon_comul, Equivalence.symm_inverse,
129+
comonEquivalence_functor, toComon_obj, toComonObj_X, ModuleCat.of_coe, comul_def,
130+
tensorΞΌ_eq_tensorTensorTensorComm, ModuleCat.hom_comp, ModuleCat.hom_ofHom,
131+
LinearEquiv.comp_toLinearMap_eq_iff]
127132
rfl
128133

129134
theorem tensorHom_toLinearMap (f : M β†’β‚—c[R] N) (g : P β†’β‚—c[R] Q) :
@@ -158,9 +163,7 @@ theorem comul_tensorObj_tensorObj_right :
158163
(CoalgCat.of R N βŠ— CoalgCat.of R P) : CoalgCat R))
159164
= Coalgebra.comul (A := M βŠ—[R] N βŠ—[R] P) := by
160165
rw [ofComonObjCoalgebraStruct_comul]
161-
dsimp
162-
simp only [Comon_.monoidal_tensorObj_comul, toComonObj_comul]
163-
rw [ofComonObjCoalgebraStruct_comul]
166+
simp only [Comon_.monoidal_tensorObj_comon_comul, toComonObj]
164167
simp [tensorΞΌ_eq_tensorTensorTensorComm, TensorProduct.comul_def,
165168
AlgebraTensorModule.tensorTensorTensorComm_eq]
166169
rfl
@@ -171,8 +174,7 @@ theorem comul_tensorObj_tensorObj_left :
171174
= Coalgebra.comul (A := (M βŠ—[R] N) βŠ—[R] P) := by
172175
rw [ofComonObjCoalgebraStruct_comul]
173176
dsimp
174-
simp only [Comon_.monoidal_tensorObj_comul, toComonObj_comul]
175-
rw [ofComonObjCoalgebraStruct_comul]
177+
simp only [Comon_.monoidal_tensorObj_comon_comul, toComonObj]
176178
simp [tensorΞΌ_eq_tensorTensorTensorComm, TensorProduct.comul_def,
177179
AlgebraTensorModule.tensorTensorTensorComm_eq]
178180
rfl

β€ŽMathlib/Algebra/Category/Grp/LeftExactFunctor.leanβ€Ž

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ instance (F : C β₯€β‚— Type v) : PreservesFiniteLimits (inverseAux.obj F) where
6262
noncomputable def inverse : (C β₯€β‚— Type v) β₯€ (C β₯€β‚— AddCommGrp.{v}) :=
6363
ObjectProperty.lift _ inverseAux inferInstance
6464

65+
open scoped Mon_Class
66+
6567
attribute [-instance] Functor.LaxMonoidal.comp Functor.Monoidal.instComp in
6668
/-- Implementation, see `leftExactFunctorForgetEquivalence`.
6769
This is the complicated bit, where we show that forgetting the group structure in the image of
@@ -72,10 +74,14 @@ noncomputable def unitIsoAux (F : C β₯€ AddCommGrp.{v}) [PreservesFiniteLimits F
7274
(F β‹™ forget AddCommGrp).mapCommGrp.obj (Preadditive.commGrpEquivalence.functor.obj X) := by
7375
letI : (F β‹™ forget AddCommGrp).Braided := .ofChosenFiniteProducts _
7476
letI : F.Monoidal := .ofChosenFiniteProducts _
75-
refine CommGrp_.mkIso Multiplicative.toAdd.toIso (by aesop_cat) ?_
77+
refine CommGrp_.mkIso Multiplicative.toAdd.toIso (by
78+
erw [Functor.mapCommGrp_obj_grp_one]
79+
aesop_cat) ?_
7680
dsimp [-Functor.comp_map, -ConcreteCategory.forget_map_eq_coe, -forget_map]
7781
have : F.Additive := Functor.additive_of_preserves_binary_products _
78-
rw [Functor.comp_map, F.map_add, Functor.Monoidal.ΞΌ_comp F (forget AddCommGrp) X X,
82+
simp only [Category.id_comp]
83+
erw [Functor.mapCommGrp_obj_grp_mul]
84+
erw [Functor.comp_map, F.map_add, Functor.Monoidal.ΞΌ_comp F (forget AddCommGrp) X X,
7985
Category.assoc, ← Functor.map_comp, Preadditive.comp_add, Functor.Monoidal.ΞΌ_fst,
8086
Functor.Monoidal.ΞΌ_snd]
8187
aesop_cat

β€ŽMathlib/CategoryTheory/Monad/EquivMon.leanβ€Ž

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A monad "is just" a monoid in the category of endofunctors.
2525

2626
namespace CategoryTheory
2727

28-
open Category
28+
open Category Mon_Class
2929

3030
universe v u -- morphism levels before object levels. See note [category_theory universes].
3131

@@ -35,13 +35,16 @@ namespace Monad
3535

3636
attribute [local instance] endofunctorMonoidalCategory
3737

38+
@[simps]
39+
instance (M : Monad C) : Mon_Class (M : C β₯€ C) where
40+
one := M.Ξ·
41+
mul := M.ΞΌ
42+
mul_assoc' := by ext; simp [M.assoc]
43+
3844
/-- To every `Monad C` we associated a monoid object in `C β₯€ C`. -/
3945
@[simps]
4046
def toMon (M : Monad C) : Mon_ (C β₯€ C) where
4147
X := (M : C β₯€ C)
42-
one := M.Ξ·
43-
mul := M.ΞΌ
44-
mul_assoc := by ext; simp [M.assoc]
4548

4649
variable (C) in
4750
/-- Passing from `Monad C` to `Mon_ (C β₯€ C)` is functorial. -/
@@ -51,17 +54,17 @@ def monadToMon : Monad C β₯€ Mon_ (C β₯€ C) where
5154
map f := { hom := f.toNatTrans }
5255

5356
/-- To every monoid object in `C β₯€ C` we associate a `Monad C`. -/
54-
@[simps Ξ· ΞΌ]
57+
@[simps «η» «μ»]
5558
def ofMon (M : Mon_ (C β₯€ C)) : Monad C where
5659
toFunctor := M.X
57-
Ξ· := M.one
58-
ΞΌ := M.mul
60+
«η» := η[M.X]
61+
«μ» := μ[M.X]
5962
left_unit := fun X => by
60-
simpa [-Mon_.mul_one] using congrArg (fun t ↦ t.app X) M.mul_one
63+
simpa [-Mon_Class.mul_one] using congrArg (fun t ↦ t.app X) (mul_one M.X)
6164
right_unit := fun X => by
62-
simpa [-Mon_.one_mul] using congrArg (fun t ↦ t.app X) M.one_mul
65+
simpa [-Mon_Class.one_mul] using congrArg (fun t ↦ t.app X) (one_mul M.X)
6366
assoc := fun X => by
64-
simpa [-Mon_.mul_assoc] using congrArg (fun t ↦ t.app X) M.mul_assoc
67+
simpa [-Mon_Class.mul_assoc] using congrArg (fun t ↦ t.app X) (mul_assoc M.X)
6568

6669
-- Porting note: `@[simps]` fails to generate `ofMon_obj`:
6770
@[simp] lemma ofMon_obj (M : Mon_ (C β₯€ C)) (X : C) : (ofMon M).obj X = M.X.obj X := rfl
@@ -75,9 +78,9 @@ def monToMonad : Mon_ (C β₯€ C) β₯€ Monad C where
7578
map {X Y} f :=
7679
{ f.hom with
7780
app_Ξ· X := by
78-
simpa [-Mon_.Hom.one_hom] using congrArg (fun t ↦ t.app X) f.one_hom
81+
simpa [-IsMon_Hom.one_hom] using congrArg (fun t ↦ t.app X) f.one_hom
7982
app_ΞΌ Z := by
80-
simpa [-Mon_.Hom.mul_hom] using congrArg (fun t ↦ t.app Z) f.mul_hom }
83+
simpa [-IsMon_Hom.mul_hom] using congrArg (fun t ↦ t.app Z) f.mul_hom }
8184

8285
/-- Oh, monads are just monoids in the category of endofunctors (equivalence of categories). -/
8386
@[simps]

β€ŽMathlib/CategoryTheory/Monoidal/Bimod.leanβ€Ž

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ universe v₁ vβ‚‚ u₁ uβ‚‚
1616

1717
open CategoryTheory
1818

19-
open CategoryTheory.MonoidalCategory
19+
open CategoryTheory.MonoidalCategory Mon_Class
2020

2121
variable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory.{v₁} C]
2222

@@ -78,17 +78,17 @@ structure Bimod (A B : Mon_ C) where
7878
X : C
7979
/-- The left action of this bimodule object -/
8080
actLeft : A.X βŠ— X ⟢ X
81-
one_actLeft : (A.one β–· X) ≫ actLeft = (Ξ»_ X).hom := by aesop_cat
81+
one_actLeft : Ξ· β–· X ≫ actLeft = (Ξ»_ X).hom := by aesop_cat
8282
left_assoc :
83-
(A.mul β–· X) ≫ actLeft = (Ξ±_ A.X A.X X).hom ≫ (A.X ◁ actLeft) ≫ actLeft := by aesop_cat
83+
ΞΌ β–· X ≫ actLeft = (Ξ±_ A.X A.X X).hom ≫ A.X ◁ actLeft ≫ actLeft := by aesop_cat
8484
/-- The right action of this bimodule object -/
8585
actRight : X βŠ— B.X ⟢ X
86-
actRight_one : (X ◁ B.one) ≫ actRight = (ρ_ X).hom := by aesop_cat
86+
actRight_one : X ◁ Ξ· ≫ actRight = (ρ_ X).hom := by aesop_cat
8787
right_assoc :
88-
(X ◁ B.mul) ≫ actRight = (Ξ±_ X B.X B.X).inv ≫ (actRight β–· B.X) ≫ actRight := by
88+
X ◁ ΞΌ ≫ actRight = (Ξ±_ X B.X B.X).inv ≫ actRight β–· B.X ≫ actRight := by
8989
aesop_cat
9090
middle_assoc :
91-
(actLeft β–· B.X) ≫ actRight = (Ξ±_ A.X X B.X).hom ≫ (A.X ◁ actRight) ≫ actLeft := by
91+
actLeft β–· B.X ≫ actRight = (Ξ±_ A.X X B.X).hom ≫ A.X ◁ actRight ≫ actLeft := by
9292
aesop_cat
9393

9494
attribute [reassoc (attr := simp)] Bimod.one_actLeft Bimod.actRight_one Bimod.left_assoc
@@ -165,8 +165,8 @@ variable (A)
165165
@[simps]
166166
def regular : Bimod A A where
167167
X := A.X
168-
actLeft := A.mul
169-
actRight := A.mul
168+
actLeft := ΞΌ
169+
actRight := ΞΌ
170170

171171
instance : Inhabited (Bimod A A) :=
172172
⟨regular A⟩
@@ -218,7 +218,7 @@ theorem whiskerLeft_Ο€_actLeft :
218218
erw [map_Ο€_preserves_coequalizer_inv_colimMap (tensorLeft _)]
219219
simp only [Category.assoc]
220220

221-
theorem one_act_left' : (R.one β–· _) ≫ actLeft P Q = (Ξ»_ _).hom := by
221+
theorem one_act_left' : (Ξ· β–· _) ≫ actLeft P Q = (Ξ»_ _).hom := by
222222
refine (cancel_epi ((tensorLeft _).map (coequalizer.Ο€ _ _))).1 ?_
223223
dsimp [X]
224224
-- Porting note: had to replace `rw` by `erw`
@@ -230,7 +230,7 @@ theorem one_act_left' : (R.one β–· _) ≫ actLeft P Q = (Ξ»_ _).hom := by
230230
monoidal
231231

232232
theorem left_assoc' :
233-
(R.mul β–· _) ≫ actLeft P Q = (Ξ±_ R.X R.X _).hom ≫ (R.X ◁ actLeft P Q) ≫ actLeft P Q := by
233+
(ΞΌ β–· _) ≫ actLeft P Q = (Ξ±_ R.X R.X _).hom ≫ (R.X ◁ actLeft P Q) ≫ actLeft P Q := by
234234
refine (cancel_epi ((tensorLeft _).map (coequalizer.Ο€ _ _))).1 ?_
235235
dsimp [X]
236236
slice_lhs 1 2 => rw [whisker_exchange]
@@ -277,7 +277,7 @@ theorem Ο€_tensor_id_actRight :
277277
erw [map_Ο€_preserves_coequalizer_inv_colimMap (tensorRight _)]
278278
simp only [Category.assoc]
279279

280-
theorem actRight_one' : (_ ◁ T.one) ≫ actRight P Q = (ρ_ _).hom := by
280+
theorem actRight_one' : (_ ◁ Ξ·) ≫ actRight P Q = (ρ_ _).hom := by
281281
refine (cancel_epi ((tensorRight _).map (coequalizer.Ο€ _ _))).1 ?_
282282
dsimp [X]
283283
-- Porting note: had to replace `rw` by `erw`
@@ -288,7 +288,7 @@ theorem actRight_one' : (_ ◁ T.one) ≫ actRight P Q = (ρ_ _).hom := by
288288
simp
289289

290290
theorem right_assoc' :
291-
(_ ◁ T.mul) ≫ actRight P Q =
291+
(_ ◁ ΞΌ) ≫ actRight P Q =
292292
(Ξ±_ _ T.X T.X).inv ≫ (actRight P Q β–· T.X) ≫ actRight P Q := by
293293
refine (cancel_epi ((tensorRight _).map (coequalizer.Ο€ _ _))).1 ?_
294294
dsimp [X]
@@ -595,7 +595,7 @@ noncomputable def hom : TensorBimod.X (regular R) P ⟢ P.X :=
595595

596596
/-- The underlying morphism of the inverse component of the left unitor isomorphism. -/
597597
noncomputable def inv : P.X ⟢ TensorBimod.X (regular R) P :=
598-
(Ξ»_ P.X).inv ≫ (R.one β–· _) ≫ coequalizer.Ο€ _ _
598+
(Ξ»_ P.X).inv ≫ (Ξ·[R.X] β–· _) ≫ coequalizer.Ο€ _ _
599599

600600
theorem hom_inv_id : hom P ≫ inv P = πŸ™ _ := by
601601
dsimp only [hom, inv, TensorBimod.X]
@@ -606,7 +606,7 @@ theorem hom_inv_id : hom P ≫ inv P = πŸ™ _ := by
606606
slice_lhs 3 3 => rw [← Iso.inv_hom_id_assoc (Ξ±_ R.X R.X P.X) (R.X ◁ P.actLeft)]
607607
slice_lhs 4 6 => rw [← Category.assoc, ← coequalizer.condition]
608608
slice_lhs 2 3 => rw [associator_inv_naturality_left]
609-
slice_lhs 3 4 => rw [← comp_whiskerRight, Mon_.one_mul]
609+
slice_lhs 3 4 => rw [← comp_whiskerRight, Mon_Class.one_mul]
610610
slice_rhs 1 2 => rw [Category.comp_id]
611611
monoidal
612612

@@ -650,7 +650,7 @@ noncomputable def hom : TensorBimod.X P (regular S) ⟢ P.X :=
650650

651651
/-- The underlying morphism of the inverse component of the right unitor isomorphism. -/
652652
noncomputable def inv : P.X ⟢ TensorBimod.X P (regular S) :=
653-
(ρ_ P.X).inv ≫ (_ ◁ S.one) ≫ coequalizer.Ο€ _ _
653+
(ρ_ P.X).inv ≫ (_ ◁ Ξ·[S.X]) ≫ coequalizer.Ο€ _ _
654654

655655
theorem hom_inv_id : hom P ≫ inv P = πŸ™ _ := by
656656
dsimp only [hom, inv, TensorBimod.X]
@@ -660,7 +660,7 @@ theorem hom_inv_id : hom P ≫ inv P = πŸ™ _ := by
660660
slice_lhs 2 3 => rw [← whisker_exchange]
661661
slice_lhs 3 4 => rw [coequalizer.condition]
662662
slice_lhs 2 3 => rw [associator_naturality_right]
663-
slice_lhs 3 4 => rw [← MonoidalCategory.whiskerLeft_comp, Mon_.mul_one]
663+
slice_lhs 3 4 => rw [← MonoidalCategory.whiskerLeft_comp, Mon_Class.mul_one]
664664
slice_rhs 1 2 => rw [Category.comp_id]
665665
monoidal
666666

@@ -765,7 +765,7 @@ theorem id_whiskerLeft_bimod {X Y : Mon_ C} {M N : Bimod X Y} (f : M ⟢ N) :
765765
slice_rhs 4 4 => rw [← Iso.inv_hom_id_assoc (Ξ±_ X.X X.X N.X) (X.X ◁ N.actLeft)]
766766
slice_rhs 5 7 => rw [← Category.assoc, ← coequalizer.condition]
767767
slice_rhs 3 4 => rw [associator_inv_naturality_left]
768-
slice_rhs 4 5 => rw [← comp_whiskerRight, Mon_.one_mul]
768+
slice_rhs 4 5 => rw [← comp_whiskerRight, Mon_Class.one_mul]
769769
have : (Ξ»_ (X.X βŠ— N.X)).inv ≫ (Ξ±_ (πŸ™_ C) X.X N.X).inv ≫ ((Ξ»_ X.X).hom β–· N.X) = πŸ™ _ := by
770770
monoidal
771771
slice_rhs 2 4 => rw [this]
@@ -819,7 +819,7 @@ theorem whiskerRight_id_bimod {X Y : Mon_ C} {M N : Bimod X Y} (f : M ⟢ N) :
819819
slice_rhs 3 4 => rw [← whisker_exchange]
820820
slice_rhs 4 5 => rw [coequalizer.condition]
821821
slice_rhs 3 4 => rw [associator_naturality_right]
822-
slice_rhs 4 5 => rw [← MonoidalCategory.whiskerLeft_comp, Mon_.mul_one]
822+
slice_rhs 4 5 => rw [← MonoidalCategory.whiskerLeft_comp, Mon_Class.mul_one]
823823
simp
824824

825825
theorem whiskerRight_comp_bimod {W X Y Z : Mon_ C} {M M' : Bimod W X} (f : M ⟢ M') (N : Bimod X Y)

0 commit comments

Comments
Β (0)