Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ee8cb15

Browse files
committed
feat(category_theory): functorial images (#2373)
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I * add documentation for `comma.lean`, * introduce the arrow category as a special case of the comma construction, and * introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.
1 parent aa42f3b commit ee8cb15

File tree

2 files changed

+306
-7
lines changed

2 files changed

+306
-7
lines changed

src/category_theory/comma.lean

Lines changed: 169 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,48 @@ import category_theory.isomorphism
77
import category_theory.equivalence
88
import category_theory.punit
99

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+
1052
namespace category_theory
1153

1254
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]
1557
variables {T : Type u₃} [𝒯 : category.{v₃} T]
1658
include 𝒜 ℬ 𝒯
1759

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`. -/
1862
structure comma (L : A ⥤ T) (R : B ⥤ T) : Type (max u₁ u₂ v₃) :=
1963
(left : A . obviously)
2064
(right : B . obviously)
2165
(hom : L.obj left ⟶ R.obj right)
2266

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+
2379
variables {L : A ⥤ T} {R : B ⥤ T}
2480

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+
-/
2584
@[ext] structure comma_morphism (X Y : comma L R) :=
2685
(left : X.left ⟶ Y.left . obviously)
2786
(right : X.right ⟶ Y.right . obviously)
2887
(w' : L.map left ≫ Y.hom = X.hom ≫ R.map right . obviously)
2988

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+
3096
restate_axiom comma_morphism.w'
3197
attribute [simp] comma_morphism.w
3298

@@ -54,17 +120,21 @@ namespace comma
54120
section
55121
variables {X Y Z : comma L R} {f : X ⟶ Y} {g : Y ⟶ Z}
56122

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
57125
@[simp] lemma comp_left : (f ≫ g).left = f.left ≫ g.left := rfl
58126
@[simp] lemma comp_right : (f ≫ g).right = f.right ≫ g.right := rfl
59127

60128
end
61129

62130
variables (L) (R)
63131

132+
/-- The functor sending an object `X` in the comma category to `X.left`. -/
64133
def fst : comma L R ⥤ A :=
65134
{ obj := λ X, X.left,
66135
map := λ _ _ f, f.left }
67136

137+
/-- The functor sending an object `X` in the comma category to `X.right`. -/
68138
def snd : comma L R ⥤ B :=
69139
{ obj := λ X, X.right,
70140
map := λ _ _ f, f.right }
@@ -74,12 +144,17 @@ def snd : comma L R ⥤ B :=
74144
@[simp] lemma fst_map {X Y : comma L R} {f : X ⟶ Y} : (fst L R).map f = f.left := rfl
75145
@[simp] lemma snd_map {X Y : comma L R} {f : X ⟶ Y} : (snd L R).map f = f.right := rfl
76146

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. -/
77151
def nat_trans : fst L R ⋙ L ⟶ snd L R ⋙ R :=
78152
{ app := λ X, X.hom }
79153

80154
section
81155
variables {L₁ L₂ L₃ : A ⥤ T} {R₁ R₂ R₃ : B ⥤ T}
82156

157+
/-- A natural transformation `L₁ ⟶ L₂` induces a functor `comma L₂ R ⥤ comma L₁ R`. -/
83158
def map_left (l : L₁ ⟶ L₂) : comma L₂ R ⥤ comma L₁ R :=
84159
{ obj := λ X,
85160
{ left := X.left,
@@ -99,6 +174,8 @@ variables {X Y : comma L₂ R} {f : X ⟶ Y} {l : L₁ ⟶ L₂}
99174
@[simp] lemma map_left_map_right : ((map_left R l).map f).right = f.right := rfl
100175
end
101176

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. -/
102179
def map_left_id : map_left R (𝟙 L) ≅ 𝟭 _ :=
103180
{ hom :=
104181
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
@@ -113,8 +190,11 @@ variables {X : comma L R}
113190
@[simp] lemma map_left_id_inv_app_right : (((map_left_id L R).inv).app X).right = 𝟙 (X.right) := rfl
114191
end
115192

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. -/
116196
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) :=
118198
{ hom :=
119199
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
120200
inv :=
@@ -128,6 +208,7 @@ variables {X : comma L₃ R} {l : L₁ ⟶ L₂} {l' : L₂ ⟶ L₃}
128208
@[simp] lemma map_left_comp_inv_app_right : (((map_left_comp R l l').inv).app X).right = 𝟙 (X.right) := rfl
129209
end
130210

211+
/-- A natural transformation `R₁ ⟶ R₂` induces a functor `comma L R₁ ⥤ comma L R₂`. -/
131212
def map_right (r : R₁ ⟶ R₂) : comma L R₁ ⥤ comma L R₂ :=
132213
{ obj := λ X,
133214
{ left := X.left,
@@ -147,6 +228,8 @@ variables {X Y : comma L R₁} {f : X ⟶ Y} {r : R₁ ⟶ R₂}
147228
@[simp] lemma map_right_map_right : ((map_right L r).map f).right = f.right := rfl
148229
end
149230

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. -/
150233
def map_right_id : map_right L (𝟙 R) ≅ 𝟭 _ :=
151234
{ hom :=
152235
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
@@ -161,7 +244,11 @@ variables {X : comma L R}
161244
@[simp] lemma map_right_id_inv_app_right : (((map_right_id L R).inv).app X).right = 𝟙 (X.right) := rfl
162245
end
163246

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') :=
165252
{ hom :=
166253
{ app := λ X, { left := 𝟙 _, right := 𝟙 _ } },
167254
inv :=
@@ -181,9 +268,17 @@ end comma
181268

182269
omit 𝒜 ℬ
183270

271+
/-- The over category has as objects arrows in `T` with codomain `X` and as morphisms commutative
272+
triangles. -/
184273
@[derive category]
185274
def over (X : T) := comma.{v₃ 0 v₃} (𝟭 T) ((functor.const punit).obj X)
186275

276+
-- Satisfying the inhabited linter
277+
instance over.inhabited [inhabited T] : inhabited (over (default T)) :=
278+
{ default :=
279+
{ left := default T,
280+
hom := 𝟙 _ } }
281+
187282
namespace over
188283

189284
variables {X : T}
@@ -202,12 +297,15 @@ by tidy
202297
@[simp, reassoc] lemma w {A B : over X} (f : A ⟶ B) : f.left ≫ B.hom = A.hom :=
203298
by have := f.w; tidy
204299

300+
/-- To give an object in the over category, it suffices to give a morphism with codomain `X`. -/
205301
def mk {X Y : T} (f : Y ⟶ X) : over X :=
206302
{ left := Y, hom := f }
207303

208304
@[simp] lemma mk_left {X Y : T} (f : Y ⟶ X) : (mk f).left = Y := rfl
209305
@[simp] lemma mk_hom {X Y : T} (f : Y ⟶ X) : (mk f).hom = f := rfl
210306

307+
/-- To give a morphism in the over category, it suffices to give an arrow fitting in a commutative
308+
triangle. -/
211309
def hom_mk {U V : over X} (f : U.left ⟶ V.left) (w : f ≫ V.hom = U.hom . obviously) :
212310
U ⟶ V :=
213311
{ 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
216314
(hom_mk f).left = f :=
217315
rfl
218316

317+
/-- The forgetful functor mapping an arrow to its domain. -/
219318
def forget : (over X) ⥤ T := comma.fst _ _
220319

221320
@[simp] lemma forget_obj {U : over X} : forget.obj U = U.left := rfl
222321
@[simp] lemma forget_map {U V : over X} {f : U ⟶ V} : forget.map f = f.left := rfl
223322

323+
/-- A morphism `f : X ⟶ Y` induces a functor `over X ⥤ over Y` in the obvious way. -/
224324
def map {Y : T} (f : X ⟶ Y) : over X ⥤ over Y := comma.map_right _ $ (functor.const punit).map f
225325

226326
section
@@ -278,6 +378,7 @@ section
278378
variables {D : Type u₃} [𝒟 : category.{v₃} D]
279379
include 𝒟
280380

381+
/-- A functor `F : T ⥤ D` induces a functor `over X ⥤ over (F.obj X)` in the obvious way. -/
281382
def post (F : T ⥤ D) : over X ⥤ over (F.obj X) :=
282383
{ obj := λ Y, mk $ F.map Y.hom,
283384
map := λ Y₁ Y₂ f,
@@ -288,9 +389,17 @@ end
288389

289390
end over
290391

392+
/-- The under category has as objects arrows with domain `X` and as morphisms commutative
393+
triangles. -/
291394
@[derive category]
292395
def under (X : T) := comma.{0 v₃ v₃} ((functor.const punit).obj X) (𝟭 T)
293396

397+
-- Satisfying the inhabited linter
398+
instance under.inhabited [inhabited T] : inhabited (under (default T)) :=
399+
{ default :=
400+
{ right := default T,
401+
hom := 𝟙 _ } }
402+
294403
namespace under
295404

296405
variables {X : T}
@@ -309,12 +418,15 @@ by tidy
309418
@[simp] lemma w {A B : under X} (f : A ⟶ B) : A.hom ≫ f.right = B.hom :=
310419
by have := f.w; tidy
311420

421+
/-- To give an object in the under category, it suffices to give an arrow with domain `X`. -/
312422
def mk {X Y : T} (f : X ⟶ Y) : under X :=
313423
{ right := Y, hom := f }
314424

315425
@[simp] lemma mk_right {X Y : T} (f : X ⟶ Y) : (mk f).right = Y := rfl
316426
@[simp] lemma mk_hom {X Y : T} (f : X ⟶ Y) : (mk f).hom = f := rfl
317427

428+
/-- To give a morphism in the under category, it suffices to give a morphism fitting in a
429+
commutative triangle. -/
318430
def hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom . obviously) :
319431
U ⟶ V :=
320432
{ right := f }
@@ -323,11 +435,13 @@ def hom_mk {U V : under X} (f : U.right ⟶ V.right) (w : U.hom ≫ f = V.hom .
323435
(hom_mk f).right = f :=
324436
rfl
325437

438+
/-- The forgetful functor mapping an arrow to its domain. -/
326439
def forget : (under X) ⥤ T := comma.snd _ _
327440

328441
@[simp] lemma forget_obj {U : under X} : forget.obj U = U.right := rfl
329442
@[simp] lemma forget_map {U V : under X} {f : U ⟶ V} : forget.map f = f.right := rfl
330443

444+
/-- A morphism `X ⟶ Y` induces a functor `under Y ⥤ under X` in the obvious way. -/
331445
def map {Y : T} (f : X ⟶ Y) : under Y ⥤ under X := comma.map_left _ $ (functor.const punit).map f
332446

333447
section
@@ -341,6 +455,7 @@ section
341455
variables {D : Type u₃} [𝒟 : category.{v₃} D]
342456
include 𝒟
343457

458+
/-- A functor `F : T ⥤ D` induces a functor `under X ⥤ under (F.obj X)` in the obvious way. -/
344459
def post {X : T} (F : T ⥤ D) : under X ⥤ under (F.obj X) :=
345460
{ obj := λ Y, mk $ F.map Y.hom,
346461
map := λ Y₁ Y₂ f,
@@ -351,4 +466,56 @@ end
351466

352467
end under
353468

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+
354521
end category_theory

0 commit comments

Comments
 (0)