Skip to content

Commit dec45e9

Browse files
committed
feat(CategoryTheory): semicartesian monoidal categories (#31064)
This PR refactors Cartesian Monoidal Categories through Semicartesian Monoidal Categories. There are interesting weaker settings where it is too much to ask the full monoidal structure to be given by the cartesian structure, but reasonable for the monoidal unit to be terminal. A category like this is usually referred to as "Semicartesian". In semicartesian setting we have `fst (X Y : C) : X ⊗ Y ⟶ X` and `snd (X Y : C) : X ⊗ Y ⟶ Y` for free, but without their universal property. https://ncatlab.org/nlab/show/semicartesian+monoidal+category This PR makes`CartesianMonoidalCategory` an extension of `SemiCartesianMonoidalCategory` Some examples of semicartesian but not cartesian monoidal categories: - The opposite of the category FinInj of finite sets with injections. - The category of nominal sets. - The category of commutative (semi-) rings. Personally, I need semicartesian structure for two other downstream projects where the use cases are natural number objects in semicartesian monoidal categories and the category of context of certain type theories.
1 parent 7f1e069 commit dec45e9

File tree

1 file changed

+46
-35
lines changed
  • Mathlib/CategoryTheory/Monoidal/Cartesian

1 file changed

+46
-35
lines changed

Mathlib/CategoryTheory/Monoidal/Cartesian/Basic.lean

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,45 @@ universe v v₁ v₂ v₃ u u₁ u₂ u₃
4545

4646
open MonoidalCategory Limits
4747

48+
/-- A monoidal category is semicartesian if the unit for the tensor product is a terminal object. -/
49+
class SemiCartesianMonoidalCategory (C : Type u) [Category.{v} C] extends MonoidalCategory C where
50+
/-- The tensor unit is a terminal object. -/
51+
isTerminalTensorUnit : IsTerminal (𝟙_ C)
52+
/-- The first projection from the product. -/
53+
fst (X Y : C) : X ⊗ Y ⟶ X
54+
/-- The second projection from the product. -/
55+
snd (X Y : C) : X ⊗ Y ⟶ Y
56+
fst_def (X Y : C) : fst X Y = X ◁ isTerminalTensorUnit.from Y ≫ (ρ_ X).hom := by cat_disch
57+
snd_def (X Y : C) : snd X Y = isTerminalTensorUnit.from X ▷ Y ≫ (λ_ Y).hom := by cat_disch
58+
59+
namespace SemiCartesianMonoidalCategory
60+
61+
variable {C : Type u} [Category.{v} C] [SemiCartesianMonoidalCategory C]
62+
63+
/-- The unique map to the terminal object. -/
64+
def toUnit (X : C) : X ⟶ 𝟙_ C := isTerminalTensorUnit.from X
65+
66+
instance (X : C) : Unique (X ⟶ 𝟙_ C) := isTerminalEquivUnique _ _ isTerminalTensorUnit _
67+
68+
lemma default_eq_toUnit (X : C) : default = toUnit X := rfl
69+
70+
/--
71+
This lemma follows from the preexisting `Unique` instance, but
72+
it is often convenient to use it directly as `apply toUnit_unique` forcing
73+
lean to do the necessary elaboration.
74+
-/
75+
@[ext]
76+
lemma toUnit_unique {X : C} (f g : X ⟶ 𝟙_ _) : f = g :=
77+
Subsingleton.elim _ _
78+
79+
@[simp] lemma toUnit_unit : toUnit (𝟙_ C) = 𝟙 (𝟙_ C) := toUnit_unique ..
80+
81+
@[reassoc (attr := simp)]
82+
theorem comp_toUnit {X Y : C} (f : X ⟶ Y) : f ≫ toUnit Y = toUnit X :=
83+
toUnit_unique _ _
84+
85+
end SemiCartesianMonoidalCategory
86+
4887
variable (C) in
4988
/--
5089
An instance of `CartesianMonoidalCategory C` bundles an explicit choice of a binary
@@ -53,22 +92,18 @@ product of two objects of `C`, and a terminal object in `C`.
5392
Users should use the monoidal notation: `X ⊗ Y` for the product and `𝟙_ C` for
5493
the terminal object.
5594
-/
56-
class CartesianMonoidalCategory (C : Type u) [Category.{v} C] extends MonoidalCategory C where
57-
/-- The tensor unit is a terminal object. -/
58-
isTerminalTensorUnit : IsTerminal (𝟙_ C)
59-
/-- The first projection from the product. -/
60-
fst (X Y : C) : X ⊗ Y ⟶ X
61-
/-- The second projection from the product. -/
62-
snd (X Y : C) : X ⊗ Y ⟶ Y
95+
class CartesianMonoidalCategory (C : Type u) [Category.{v} C] extends
96+
SemiCartesianMonoidalCategory C where
6397
/-- The monoidal product is the categorical product. -/
6498
tensorProductIsBinaryProduct (X Y : C) : IsLimit <| BinaryFan.mk (fst X Y) (snd X Y)
65-
fst_def (X Y : C) : fst X Y = X ◁ isTerminalTensorUnit.from Y ≫ (ρ_ X).hom := by cat_disch
66-
snd_def (X Y : C) : snd X Y = isTerminalTensorUnit.from X ▷ Y ≫ (λ_ Y).hom := by cat_disch
6799

68100
@[deprecated (since := "2025-05-15")] alias ChosenFiniteProducts := CartesianMonoidalCategory
69101

70102
namespace CartesianMonoidalCategory
71103

104+
export SemiCartesianMonoidalCategory (isTerminalTensorUnit fst snd fst_def snd_def toUnit
105+
toUnit_unique toUnit_unit comp_toUnit comp_toUnit_assoc default_eq_toUnit)
106+
72107
variable {C : Type u} [Category.{v} C]
73108

74109
section OfChosenFiniteProducts
@@ -180,7 +215,7 @@ abbrev ofChosenFiniteProducts : CartesianMonoidalCategory C :=
180215
}
181216

182217
omit 𝒯 in
183-
/-- Construct an instance of `CartesianMonoidalCategory C` given the existence of finite products
218+
/-- Constructs an instance of `CartesianMonoidalCategory C` given the existence of finite products
184219
in `C`. -/
185220
noncomputable abbrev ofHasFiniteProducts [HasFiniteProducts C] : CartesianMonoidalCategory C :=
186221
.ofChosenFiniteProducts (getLimitCone (.empty C)) (getLimitCone <| pair · ·)
@@ -194,31 +229,7 @@ variable {C : Type u} [Category.{v} C] [CartesianMonoidalCategory C]
194229
open MonoidalCategory
195230

196231
/--
197-
The unique map to the terminal object.
198-
-/
199-
def toUnit (X : C) : X ⟶ 𝟙_ C := isTerminalTensorUnit.from _
200-
201-
instance (X : C) : Unique (X ⟶ 𝟙_ C) := isTerminalEquivUnique _ _ isTerminalTensorUnit _
202-
203-
lemma default_eq_toUnit (X : C) : default = toUnit X := rfl
204-
205-
/--
206-
This lemma follows from the preexisting `Unique` instance, but
207-
it is often convenient to use it directly as `apply toUnit_unique` forcing
208-
lean to do the necessary elaboration.
209-
-/
210-
@[ext]
211-
lemma toUnit_unique {X : C} (f g : X ⟶ 𝟙_ _) : f = g :=
212-
Subsingleton.elim _ _
213-
214-
@[simp] lemma toUnit_unit : toUnit (𝟙_ C) = 𝟙 (𝟙_ C) := toUnit_unique ..
215-
216-
@[reassoc (attr := simp)]
217-
theorem comp_toUnit {X Y : C} (f : X ⟶ Y) : f ≫ toUnit Y = toUnit X :=
218-
toUnit_unique _ _
219-
220-
/--
221-
Construct a morphism to the product given its two components.
232+
Constructs a morphism to the product given its two components.
222233
-/
223234
def lift {T X Y : C} (f : T ⟶ X) (g : T ⟶ Y) : T ⟶ X ⊗ Y :=
224235
(BinaryFan.IsLimit.lift' (tensorProductIsBinaryProduct X Y) f g).1

0 commit comments

Comments
 (0)