@@ -7,6 +7,48 @@ import category_theory.isomorphism
7
7
import category_theory.equivalence
8
8
import category_theory.punit
9
9
10
+ /-!
11
+ # Comma categories
12
+
13
+ A comma category is a construction in category theory, which builds a category out of two functors
14
+ with a common codomain. Specifically, for functors `L : A ⥤ T` and `R : B ⥤ T`, an object in
15
+ `comma L R` is a morphism `hom : L.obj left ⟶ R.obj right` for some objects `left : A` and
16
+ `right : B`, and a morphism in `comma L R` between `hom : L.obj left ⟶ R.obj right` and
17
+ `hom' : L.obj left' ⟶ R.obj right'` is a commutative square
18
+
19
+ L.obj left ⟶ L.obj left'
20
+ | |
21
+ hom | | hom'
22
+ ↓ ↓
23
+ R.obj right ⟶ R.obj right',
24
+
25
+ where the top and bottom morphism come from morphisms `left ⟶ left'` and `right ⟶ right'`,
26
+ respectively.
27
+
28
+ Several important constructions are special cases of this construction.
29
+ * If `L` is the identity functor and `R` is a constant functor, then `comma L R` is the "slice" or
30
+ "over" category over the object `R` maps to.
31
+ * Conversely, if `L` is a constant functor and `R` is the identity functor, then `comma L R` is the
32
+ "coslice" or "under" category under the object `L` maps to.
33
+ * If `L` and `R` both are the identity functor, then `comma L R` is the arrow category of `T`.
34
+
35
+ ## Main definitions
36
+
37
+ * `comma L R`: the comma category of the functors `L` and `R`.
38
+ * `over X`: the over category of the object `X`.
39
+ * `under X`: the under category of the object `X`.
40
+ * `arrow T`: the arrow category of the category `T`.
41
+
42
+ ## References
43
+
44
+ * https://ncatlab.org/nlab/show/comma+category
45
+
46
+ ## Tags
47
+
48
+ comma, slice, coslice, over, under, arrow
49
+ -/
50
+
51
+
10
52
namespace category_theory
11
53
12
54
universes v₁ v₂ v₃ u₁ u₂ u₃ -- declare the `v`'s first; see `category_theory.category` for an explanation
@@ -15,18 +57,42 @@ variables {B : Type u₂} [ℬ : category.{v₂} B]
15
57
variables {T : Type u₃} [𝒯 : category.{v₃} T]
16
58
include 𝒜 ℬ 𝒯
17
59
60
+ /-- The objects of the comma category are triples of an object `left : A`, an object
61
+ `right : B` and a morphism `hom : L.obj left ⟶ R.obj right`. -/
18
62
structure comma (L : A ⥤ T) (R : B ⥤ T) : Type (max u₁ u₂ v₃) :=
19
63
(left : A . obviously)
20
64
(right : B . obviously)
21
65
(hom : L.obj left ⟶ R.obj right)
22
66
67
+ section
68
+ omit 𝒜 ℬ
69
+
70
+ -- Satisfying the inhabited linter
71
+ instance comma.inhabited [inhabited T] : inhabited (comma (𝟭 T) (𝟭 T)) :=
72
+ { default :=
73
+ { left := default T,
74
+ right := default T,
75
+ hom := 𝟙 (default T) } }
76
+
77
+ end
78
+
23
79
variables {L : A ⥤ T} {R : B ⥤ T}
24
80
81
+ /-- A morphism between two objects in the comma category is a commutative square connecting the
82
+ morphisms coming from the two objects using morphisms in the image of the functors `L` and `R`.
83
+ -/
25
84
@[ext] structure comma_morphism (X Y : comma L R) :=
26
85
(left : X.left ⟶ Y.left . obviously)
27
86
(right : X.right ⟶ Y.right . obviously)
28
87
(w' : L.map left ≫ Y.hom = X.hom ≫ R.map right . obviously)
29
88
89
+ -- Satisfying the inhabited linter
90
+ instance comma_morphism.inhabited [inhabited (comma L R)] :
91
+ inhabited (comma_morphism (default (comma L R)) (default (comma L R))) :=
92
+ { default :=
93
+ { left := 𝟙 _,
94
+ right := 𝟙 _ } }
95
+
30
96
restate_axiom comma_morphism.w'
31
97
attribute [simp] comma_morphism.w
32
98
@@ -54,17 +120,21 @@ namespace comma
54
120
section
55
121
variables {X Y Z : comma L R} {f : X ⟶ Y} {g : Y ⟶ Z}
56
122
123
+ @[simp] lemma id_left : ((𝟙 X) : comma_morphism X X).left = 𝟙 X.left := rfl
124
+ @[simp] lemma id_right : ((𝟙 X) : comma_morphism X X).right = 𝟙 X.right := rfl
57
125
@[simp] lemma comp_left : (f ≫ g).left = f.left ≫ g.left := rfl
58
126
@[simp] lemma comp_right : (f ≫ g).right = f.right ≫ g.right := rfl
59
127
60
128
end
61
129
62
130
variables (L) (R)
63
131
132
+ /-- The functor sending an object `X` in the comma category to `X.left`. -/
64
133
def fst : comma L R ⥤ A :=
65
134
{ obj := λ X, X.left,
66
135
map := λ _ _ f, f.left }
67
136
137
+ /-- The functor sending an object `X` in the comma category to `X.right`. -/
68
138
def snd : comma L R ⥤ B :=
69
139
{ obj := λ X, X.right,
70
140
map := λ _ _ f, f.right }
@@ -74,12 +144,17 @@ def snd : comma L R ⥤ B :=
74
144
@[simp] lemma fst_map {X Y : comma L R} {f : X ⟶ Y} : (fst L R).map f = f.left := rfl
75
145
@[simp] lemma snd_map {X Y : comma L R} {f : X ⟶ Y} : (snd L R).map f = f.right := rfl
76
146
147
+ /-- We can interpret the commutative square constituting a morphism in the comma category as a
148
+ natural transformation between the functors `fst ⋙ L` and `snd ⋙ R` from the comma category
149
+ to `T`, where the components are given by the morphism that constitutes an object of the comma
150
+ category. -/
77
151
def nat_trans : fst L R ⋙ L ⟶ snd L R ⋙ R :=
78
152
{ app := λ X, X.hom }
79
153
80
154
section
81
155
variables {L₁ L₂ L₃ : A ⥤ T} {R₁ R₂ R₃ : B ⥤ T}
82
156
157
+ /-- A natural transformation `L₁ ⟶ L₂` induces a functor `comma L₂ R ⥤ comma L₁ R`. -/
83
158
def map_left (l : L₁ ⟶ L₂) : comma L₂ R ⥤ comma L₁ R :=
84
159
{ obj := λ X,
85
160
{ left := X.left,
@@ -99,6 +174,8 @@ variables {X Y : comma L₂ R} {f : X ⟶ Y} {l : L₁ ⟶ L₂}
99
174
@[simp] lemma map_left_map_right : ((map_left R l).map f).right = f.right := rfl
100
175
end
101
176
177
+ /-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `L` is
178
+ naturally isomorphic to the identity functor. -/
102
179
def map_left_id : map_left R (𝟙 L) ≅ 𝟭 _ :=
103
180
{ hom :=
104
181
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
@@ -113,8 +190,11 @@ variables {X : comma L R}
113
190
@[simp] lemma map_left_id_inv_app_right : (((map_left_id L R).inv).app X).right = 𝟙 (X.right) := rfl
114
191
end
115
192
193
+ /-- The functor `comma L₁ R ⥤ comma L₃ R` induced by the composition of two natural transformations
194
+ `l : L₁ ⟶ L₂` and `l' : L₂ ⟶ L₃` is naturally isomorphic to the composition of the two functors
195
+ induced by these natural transformations. -/
116
196
def map_left_comp (l : L₁ ⟶ L₂) (l' : L₂ ⟶ L₃) :
117
- (map_left R (l ≫ l')) ≅ (map_left R l') ⋙ (map_left R l) :=
197
+ (map_left R (l ≫ l')) ≅ (map_left R l') ⋙ (map_left R l) :=
118
198
{ hom :=
119
199
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
120
200
inv :=
@@ -128,6 +208,7 @@ variables {X : comma L₃ R} {l : L₁ ⟶ L₂} {l' : L₂ ⟶ L₃}
128
208
@[simp] lemma map_left_comp_inv_app_right : (((map_left_comp R l l').inv).app X).right = 𝟙 (X.right) := rfl
129
209
end
130
210
211
+ /-- A natural transformation `R₁ ⟶ R₂` induces a functor `comma L R₁ ⥤ comma L R₂`. -/
131
212
def map_right (r : R₁ ⟶ R₂) : comma L R₁ ⥤ comma L R₂ :=
132
213
{ obj := λ X,
133
214
{ left := X.left,
@@ -147,6 +228,8 @@ variables {X Y : comma L R₁} {f : X ⟶ Y} {r : R₁ ⟶ R₂}
147
228
@[simp] lemma map_right_map_right : ((map_right L r).map f).right = f.right := rfl
148
229
end
149
230
231
+ /-- The functor `comma L R ⥤ comma L R` induced by the identity natural transformation on `R` is
232
+ naturally isomorphic to the identity functor. -/
150
233
def map_right_id : map_right L (𝟙 R) ≅ 𝟭 _ :=
151
234
{ hom :=
152
235
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
@@ -161,7 +244,11 @@ variables {X : comma L R}
161
244
@[simp] lemma map_right_id_inv_app_right : (((map_right_id L R).inv).app X).right = 𝟙 (X.right) := rfl
162
245
end
163
246
164
- def map_right_comp (r : R₁ ⟶ R₂) (r' : R₂ ⟶ R₃) : (map_right L (r ≫ r')) ≅ (map_right L r) ⋙ (map_right L r') :=
247
+ /-- The functor `comma L R₁ ⥤ comma L R₃` induced by the composition of the natural transformations
248
+ `r : R₁ ⟶ R₂` and `r' : R₂ ⟶ R₃` is naturally isomorphic to the composition of the functors
249
+ induced by these natural transformations. -/
250
+ def map_right_comp (r : R₁ ⟶ R₂) (r' : R₂ ⟶ R₃) :
251
+ (map_right L (r ≫ r')) ≅ (map_right L r) ⋙ (map_right L r') :=
165
252
{ hom :=
166
253
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
167
254
inv :=
@@ -181,9 +268,17 @@ end comma
181
268
182
269
omit 𝒜 ℬ
183
270
271
+ /-- The over category has as objects arrows in `T` with codomain `X` and as morphisms commutative
272
+ triangles. -/
184
273
@[derive category]
185
274
def over (X : T) := comma.{v₃ 0 v₃} (𝟭 T) ((functor.const punit).obj X)
186
275
276
+ -- Satisfying the inhabited linter
277
+ instance over.inhabited [inhabited T] : inhabited (over (default T)) :=
278
+ { default :=
279
+ { left := default T,
280
+ hom := 𝟙 _ } }
281
+
187
282
namespace over
188
283
189
284
variables {X : T}
@@ -202,12 +297,15 @@ by tidy
202
297
@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=
203
298
by have := f.w; tidy
204
299
300
+ /-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/
205
301
def mk {X Y : T} (f : Y ⟶ X) : over X :=
206
302
{ left := Y, hom := f }
207
303
208
304
@[simp] lemma mk_left {X Y : T} (f : Y ⟶ X) : (mk f).left = Y := rfl
209
305
@[simp] lemma mk_hom {X Y : T} (f : Y ⟶ X) : (mk f).hom = f := rfl
210
306
307
+ /-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative
308
+ triangle. -/
211
309
def hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :
212
310
U ⟶ V :=
213
311
{ left := f }
@@ -216,11 +314,13 @@ def hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obv
216
314
(hom_mk f).left = f :=
217
315
rfl
218
316
317
+ /-- The forgetful functor mapping an arrow to its domain. -/
219
318
def forget : (over X) ⥤ T := comma.fst _ _
220
319
221
320
@[simp] lemma forget_obj {U : over X} : forget.obj U = U.left := rfl
222
321
@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : forget.map f = f.left := rfl
223
322
323
+ /-- A morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way. -/
224
324
def map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ (functor.const punit).map f
225
325
226
326
section
@@ -278,6 +378,7 @@ section
278
378
variables {D : Type u₃} [𝒟 : category.{v₃} D]
279
379
include 𝒟
280
380
381
+ /-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/
281
382
def post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=
282
383
{ obj := λ Y, mk $ F.map Y.hom,
283
384
map := λ Y₁ Y₂ f,
288
389
289
390
end over
290
391
392
+ /-- The under category has as objects arrows with domain `X` and as morphisms commutative
393
+ triangles. -/
291
394
@[derive category]
292
395
def under (X : T) := comma.{0 v₃ v₃} ((functor.const punit).obj X) (𝟭 T)
293
396
397
+ -- Satisfying the inhabited linter
398
+ instance under.inhabited [inhabited T] : inhabited (under (default T)) :=
399
+ { default :=
400
+ { right := default T,
401
+ hom := 𝟙 _ } }
402
+
294
403
namespace under
295
404
296
405
variables {X : T}
@@ -309,12 +418,15 @@ by tidy
309
418
@[simp] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=
310
419
by have := f.w; tidy
311
420
421
+ /-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/
312
422
def mk {X Y : T} (f : X ⟶ Y) : under X :=
313
423
{ right := Y, hom := f }
314
424
315
425
@[simp] lemma mk_right {X Y : T} (f : X ⟶ Y) : (mk f).right = Y := rfl
316
426
@[simp] lemma mk_hom {X Y : T} (f : X ⟶ Y) : (mk f).hom = f := rfl
317
427
428
+ /-- To give a morphism in the under category, it suffices to give a morphism fitting in a
429
+ commutative triangle. -/
318
430
def hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :
319
431
U ⟶ V :=
320
432
{ right := f }
@@ -323,11 +435,13 @@ def hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom .
323
435
(hom_mk f).right = f :=
324
436
rfl
325
437
438
+ /-- The forgetful functor mapping an arrow to its domain. -/
326
439
def forget : (under X) ⥤ T := comma.snd _ _
327
440
328
441
@[simp] lemma forget_obj {U : under X} : forget.obj U = U.right := rfl
329
442
@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : forget.map f = f.right := rfl
330
443
444
+ /-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/
331
445
def map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ (functor.const punit).map f
332
446
333
447
section
@@ -341,6 +455,7 @@ section
341
455
variables {D : Type u₃} [𝒟 : category.{v₃} D]
342
456
include 𝒟
343
457
458
+ /-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/
344
459
def post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=
345
460
{ obj := λ Y, mk $ F.map Y.hom,
346
461
map := λ Y₁ Y₂ f,
351
466
352
467
end under
353
468
469
+ section
470
+ variables (T)
471
+
472
+ /-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative
473
+ squares in `T`. -/
474
+ @[derive category]
475
+ def arrow := comma.{v₃ v₃ v₃} (𝟭 T) (𝟭 T)
476
+
477
+ -- Satisfying the inhabited linter
478
+ instance arrow.inhabited [inhabited T] : inhabited (arrow T) :=
479
+ { default := show comma (𝟭 T) (𝟭 T), from default (comma (𝟭 T) (𝟭 T)) }
480
+
481
+ end
482
+
483
+ namespace arrow
484
+
485
+ @[simp] lemma id_left (f : arrow T) : comma_morphism.left (𝟙 f) = 𝟙 (f.left) := rfl
486
+ @[simp] lemma id_right (f : arrow T) : comma_morphism.right (𝟙 f) = 𝟙 (f.right) := rfl
487
+
488
+ /-- An object in the arrow category is simply a morphism in `T`. -/
489
+ def mk {X Y : T} (f : X ⟶ Y) : arrow T :=
490
+ ⟨X, Y, f⟩
491
+
492
+ @[simp] lemma mk_hom {X Y : T} (f : X ⟶ Y) : (mk f).hom = f := rfl
493
+
494
+ /-- A morphism in the arrow category is a commutative square connecting two objects of the arrow
495
+ category. -/
496
+ def hom_mk {f g : arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}
497
+ (w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g :=
498
+ { left := u,
499
+ right := v,
500
+ w' := w }
501
+
502
+ @[simp] lemma hom_mk_left {f g : arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}
503
+ (w : u ≫ g.hom = f.hom ≫ v) : (hom_mk w).left = u := rfl
504
+ @[simp] lemma hom_mk_right {f g : arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}
505
+ (w : u ≫ g.hom = f.hom ≫ v) : (hom_mk w).right = v := rfl
506
+
507
+ /-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/
508
+ def hom_mk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}
509
+ (w : u ≫ g = f ≫ v) : arrow.mk f ⟶ arrow.mk g :=
510
+ { left := u,
511
+ right := v,
512
+ w' := w }
513
+
514
+ @[simp] lemma hom_mk'_left {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}
515
+ (w : u ≫ g = f ≫ v) : (hom_mk' w).left = u := rfl
516
+ @[simp] lemma hom_mk'_right {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q}
517
+ (w : u ≫ g = f ≫ v) : (hom_mk' w).right = v := rfl
518
+
519
+ end arrow
520
+
354
521
end category_theory
0 commit comments