Skip to content

Commit 7ef0067

Browse files
jcreinholdjoelriou
andcommitted
feat(CategoryTheory/Monoidal): Add commutative comonoid objects (#29919)
This PR adds commutative comonoid objects and removes the problematic global comonoid instance (see #29657). ## Main changes ### 1. Add `CommComonObj` class Added `Mathlib/CategoryTheory/Monoidal/CommComon_.lean` defining commutative comonoids. This captures the mathematical notion that swapping the two copies produced by comultiplication gives the same result. In cartesian categories, all comonoids are automatically commutative (copying data has no preferred order). ### 2. Remove global `ComonObj` instance for unit object The global `ComonObj (𝟙_ C)` instance interfered in [related proofs](#29657 (comment)). This PR removes it and updates affected code: - `Bicategory/Monad/Basic.lean`: Now uses `ComonObj.instTensorUnit` for the identity monad's comonad structure - `Monoidal/Bimon_.lean`: Added explicit proofs the global instance previously resolved, verifying unit morphisms preserve comonoid structure ## Design notes - `CommComonObj` extends `ComonObj` and requires `BraidedCategory` for the braiding - Unlike the removed global instance, `CommComonObj` stays a class (it describes a property, not a structure) - The explicit `instTensorUnit` lets users control when to use the trivial comonoid structure [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/) Co-authored-by: Joël Riou <37772949+joelriou@users.noreply.github.com>
1 parent 2f015bc commit 7ef0067

File tree

5 files changed

+117
-2
lines changed

5 files changed

+117
-2
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,7 @@ import Mathlib.CategoryTheory.Monoidal.Cartesian.Over
25662566
import Mathlib.CategoryTheory.Monoidal.Category
25672567
import Mathlib.CategoryTheory.Monoidal.Center
25682568
import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas
2569+
import Mathlib.CategoryTheory.Monoidal.CommComon_
25692570
import Mathlib.CategoryTheory.Monoidal.CommGrp_
25702571
import Mathlib.CategoryTheory.Monoidal.CommMon_
25712572
import Mathlib.CategoryTheory.Monoidal.Comon_

Mathlib/CategoryTheory/Bicategory/Monad/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070

7171
@[simps! counit]
7272
instance {a : B} : Comonad (𝟙 a) :=
73-
inferInstanceAs <| ComonObj (MonoidalCategory.tensorUnit (a ⟶ a))
73+
ComonObj.instTensorUnit (a ⟶ a)
7474

7575
/-- An oplax functor from the trivial bicategory to `B` defines a comonad in `B`. -/
7676
def ofOplaxFromUnit (F : OplaxFunctor (LocallyDiscrete (Discrete Unit)) B) :

Mathlib/CategoryTheory/Monoidal/Bimon_.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ theorem ofMonComonObjX_mul (M : Mon (Comon C)) :
142142

143143
@[deprecated (since := "2025-09-15")] alias ofMon_Comon_ObjX_mul := ofMonComonObjX_mul
144144

145+
attribute [local instance] ComonObj.instTensorUnit in
145146
attribute [local simp] MonObj.tensorObj.one_def MonObj.tensorObj.mul_def tensorμ in
146147
/-- The object level part of the backward direction of `Comon (Mon C) ≌ Mon (Comon C)` -/
147148
@[simps]
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/-
2+
Copyright (c) 2025 Jacob Reinhold. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Jacob Reinhold
5+
-/
6+
import Mathlib.CategoryTheory.Monoidal.Comon_
7+
import Mathlib.CategoryTheory.Monoidal.Braided.Basic
8+
import Mathlib.CategoryTheory.Monoidal.CoherenceLemmas
9+
10+
/-!
11+
# The category of commutative comonoids in a braided monoidal category.
12+
13+
We define the category of commutative comonoid objects in a braided monoidal category `C`.
14+
15+
## Main definitions
16+
17+
* `CommComon C` - The bundled structure of commutative comonoid objects
18+
19+
## Tags
20+
21+
comonoid, commutative, braided
22+
-/
23+
24+
universe v₁ v₂ v₃ u₁ u₂ u₃ u
25+
26+
namespace CategoryTheory
27+
28+
open MonoidalCategory ComonObj Functor
29+
30+
variable {C : Type u₁} [Category.{v₁} C] [MonoidalCategory.{v₁} C] [BraidedCategory.{v₁} C]
31+
32+
variable (C) in
33+
/-- A commutative comonoid object internal to a monoidal category. -/
34+
structure CommComon where
35+
/-- The underlying object in the ambient monoidal category -/
36+
X : C
37+
[comon : ComonObj X]
38+
[comm : IsCommComonObj X]
39+
40+
attribute [instance] CommComon.comon CommComon.comm
41+
42+
namespace CommComon
43+
44+
/-- A commutative comonoid object is a comonoid object. -/
45+
@[simps X]
46+
def toComon (A : CommComon C) : Comon C := ⟨A.X⟩
47+
48+
section
49+
50+
attribute [local instance] ComonObj.instTensorUnit in
51+
/-- The trivial comonoid on the unit object is commutative. -/
52+
instance instCommComonObjUnit : IsCommComonObj (𝟙_ C) where
53+
comul_comm := by simp [← unitors_equal]
54+
55+
end
56+
57+
attribute [local instance] ComonObj.instTensorUnit in
58+
variable (C) in
59+
/-- The trivial commutative comonoid object. We later show this is initial in `CommComon C`. -/
60+
@[simps!]
61+
def trivial : CommComon C := mk (𝟙_ C)
62+
63+
instance : Inhabited (CommComon C) :=
64+
⟨trivial C⟩
65+
66+
variable {M : CommComon C}
67+
68+
instance : Category (CommComon C) :=
69+
InducedCategory.category CommComon.toComon
70+
71+
@[simp]
72+
theorem id_hom (A : CommComon C) : Comon.Hom.hom (𝟙 A) = 𝟙 A.X :=
73+
rfl
74+
75+
@[simp]
76+
theorem comp_hom {R S T : CommComon C} (f : R ⟶ S) (g : S ⟶ T) :
77+
Comon.Hom.hom (f ≫ g) = f.hom ≫ g.hom :=
78+
rfl
79+
80+
@[ext]
81+
lemma hom_ext {A B : CommComon C} (f g : A ⟶ B) (h : f.hom = g.hom) : f = g :=
82+
Comon.Hom.ext h
83+
84+
section
85+
86+
variable (C)
87+
88+
/-- The forgetful functor from commutative comonoid objects to comonoid objects. -/
89+
@[simps!]
90+
def forget₂Comon : CommComon C ⥤ Comon C :=
91+
inducedFunctor _
92+
93+
end
94+
95+
end CommComon
96+
97+
end CategoryTheory

Mathlib/CategoryTheory/Monoidal/Comon_.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ namespace ComonObj
5353

5454
attribute [reassoc (attr := simp)] counit_comul comul_counit comul_assoc
5555

56+
/-- The canonical comonoid structure on the monoidal unit.
57+
This is not a global instance to avoid conflicts with other comonoid structures. -/
5658
@[simps]
57-
instance (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] : ComonObj (𝟙_ C) where
59+
def instTensorUnit (C : Type u₁) [Category.{v₁} C] [MonoidalCategory.{v₁} C] : ComonObj (𝟙_ C) where
5860
counit := 𝟙 _
5961
comul := (λ_ _).inv
6062
counit_comul := by simp
@@ -102,6 +104,7 @@ attribute [instance] Comon.comon
102104

103105
namespace Comon
104106

107+
attribute [local instance] ComonObj.instTensorUnit in
105108
variable (C) in
106109
/-- The trivial comonoid object. We later show this is terminal in `Comon C`.
107110
-/
@@ -442,3 +445,16 @@ def mapComon (F : C ⥤ D) [F.OplaxMonoidal] : Comon C ⥤ Comon D where
442445
-- and so can't state `mapComonFunctor : OplaxMonoidalFunctor C D ⥤ Comon C ⥤ Comon D`.
443446

444447
end CategoryTheory.Functor
448+
449+
section
450+
variable [BraidedCategory.{v₁} C]
451+
452+
/-- Predicate for a comonoid object to be commutative. -/
453+
class IsCommComonObj (X : C) [ComonObj X] where
454+
comul_comm (X) : Δ ≫ (β_ X X).hom = Δ := by cat_disch
455+
456+
open scoped ComonObj
457+
458+
attribute [reassoc (attr := simp)] IsCommComonObj.comul_comm
459+
460+
end

0 commit comments

Comments
 (0)