/
categories.lagda.md
344 lines (275 loc) · 11.3 KB
/
categories.lagda.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# Categories
```agda
module category-theory.categories where
```
<details><summary>Imports</summary>
```agda
open import category-theory.composition-operations-on-binary-families-of-sets
open import category-theory.isomorphisms-in-precategories
open import category-theory.nonunital-precategories
open import category-theory.precategories
open import category-theory.preunivalent-categories
open import foundation.1-types
open import foundation.cartesian-product-types
open import foundation.dependent-pair-types
open import foundation.equivalences
open import foundation.identity-types
open import foundation.propositions
open import foundation.sets
open import foundation.surjective-maps
open import foundation.universe-levels
```
</details>
## Idea
A **category** in Homotopy Type Theory is a
[precategory](category-theory.precategories.md) for which the
[identifications](foundation-core.identity-types.md) between the objects are the
[isomorphisms](category-theory.isomorphisms-in-precategories.md). More
specifically, an equality between objects gives rise to an isomorphism between
them, by the J-rule. A precategory is a category if this function, called
`iso-eq`, is an [equivalence](foundation-core.equivalences.md). In particular,
being a category is a [proposition](foundation-core.propositions.md) since
`is-equiv` is a proposition.
## Definitions
### The predicate on precategories of being a category
```agda
module _
{l1 l2 : Level} (C : Precategory l1 l2)
where
is-category-prop-Precategory : Prop (l1 ⊔ l2)
is-category-prop-Precategory =
Π-Prop
( obj-Precategory C)
( λ x →
Π-Prop
( obj-Precategory C)
( λ y → is-equiv-Prop (iso-eq-Precategory C x y)))
is-category-Precategory : UU (l1 ⊔ l2)
is-category-Precategory = type-Prop is-category-prop-Precategory
is-prop-is-category-Precategory : is-prop is-category-Precategory
is-prop-is-category-Precategory =
is-prop-type-Prop is-category-prop-Precategory
```
### The type of categories
```agda
Category : (l1 l2 : Level) → UU (lsuc l1 ⊔ lsuc l2)
Category l1 l2 = Σ (Precategory l1 l2) (is-category-Precategory)
module _
{l1 l2 : Level} (C : Category l1 l2)
where
precategory-Category : Precategory l1 l2
precategory-Category = pr1 C
obj-Category : UU l1
obj-Category = obj-Precategory precategory-Category
hom-set-Category : obj-Category → obj-Category → Set l2
hom-set-Category = hom-set-Precategory precategory-Category
hom-Category : obj-Category → obj-Category → UU l2
hom-Category = hom-Precategory precategory-Category
is-set-hom-Category :
(x y : obj-Category) → is-set (hom-Category x y)
is-set-hom-Category = is-set-hom-Precategory precategory-Category
comp-hom-Category :
{x y z : obj-Category} →
hom-Category y z → hom-Category x y → hom-Category x z
comp-hom-Category = comp-hom-Precategory precategory-Category
associative-comp-hom-Category :
{x y z w : obj-Category}
(h : hom-Category z w)
(g : hom-Category y z)
(f : hom-Category x y) →
comp-hom-Category (comp-hom-Category h g) f =
comp-hom-Category h (comp-hom-Category g f)
associative-comp-hom-Category =
associative-comp-hom-Precategory precategory-Category
inv-associative-comp-hom-Category :
{x y z w : obj-Category}
(h : hom-Category z w)
(g : hom-Category y z)
(f : hom-Category x y) →
comp-hom-Category h (comp-hom-Category g f) =
comp-hom-Category (comp-hom-Category h g) f
inv-associative-comp-hom-Category =
inv-associative-comp-hom-Precategory precategory-Category
associative-composition-operation-Category :
associative-composition-operation-binary-family-Set hom-set-Category
associative-composition-operation-Category =
associative-composition-operation-Precategory precategory-Category
id-hom-Category : {x : obj-Category} → hom-Category x x
id-hom-Category = id-hom-Precategory precategory-Category
left-unit-law-comp-hom-Category :
{x y : obj-Category} (f : hom-Category x y) →
comp-hom-Category id-hom-Category f = f
left-unit-law-comp-hom-Category =
left-unit-law-comp-hom-Precategory precategory-Category
right-unit-law-comp-hom-Category :
{x y : obj-Category} (f : hom-Category x y) →
comp-hom-Category f id-hom-Category = f
right-unit-law-comp-hom-Category =
right-unit-law-comp-hom-Precategory precategory-Category
is-unital-composition-operation-Category :
is-unital-composition-operation-binary-family-Set
hom-set-Category
comp-hom-Category
is-unital-composition-operation-Category =
is-unital-composition-operation-Precategory precategory-Category
is-category-Category :
is-category-Precategory precategory-Category
is-category-Category = pr2 C
```
### The underlying nonunital precategory of a category
```agda
module _
{l1 l2 : Level} (C : Category l1 l2)
where
nonunital-precategory-Category : Nonunital-Precategory l1 l2
nonunital-precategory-Category =
nonunital-precategory-Precategory (precategory-Category C)
```
### The underlying preunivalent category of a category
```agda
module _
{l1 l2 : Level} (C : Category l1 l2)
where
is-preunivalent-category-Category :
is-preunivalent-Precategory (precategory-Category C)
is-preunivalent-category-Category x y =
is-emb-is-equiv (is-category-Category C x y)
preunivalent-category-Category : Preunivalent-Category l1 l2
pr1 preunivalent-category-Category = precategory-Category C
pr2 preunivalent-category-Category = is-preunivalent-category-Category
```
### The total hom-type of a category
```agda
total-hom-Category :
{l1 l2 : Level} (C : Category l1 l2) → UU (l1 ⊔ l2)
total-hom-Category C = total-hom-Precategory (precategory-Category C)
obj-total-hom-Category :
{l1 l2 : Level} (C : Category l1 l2) →
total-hom-Category C →
obj-Category C × obj-Category C
obj-total-hom-Category C = obj-total-hom-Precategory (precategory-Category C)
```
### Equalities induce morphisms
```agda
module _
{l1 l2 : Level} (C : Category l1 l2) (x y : obj-Category C)
where
hom-eq-Category : x = y → hom-Category C x y
hom-eq-Category = hom-eq-Precategory (precategory-Category C) x y
hom-inv-eq-Category : x = y → hom-Category C y x
hom-inv-eq-Category = hom-inv-eq-Precategory (precategory-Category C) x y
```
### Pre- and postcomposition by a morphism
```agda
precomp-hom-Category :
{l1 l2 : Level} (C : Category l1 l2) {x y : obj-Category C}
(f : hom-Category C x y) (z : obj-Category C) →
hom-Category C y z → hom-Category C x z
precomp-hom-Category C = precomp-hom-Precategory (precategory-Category C)
postcomp-hom-Category :
{l1 l2 : Level} (C : Category l1 l2) {x y : obj-Category C}
(f : hom-Category C x y) (z : obj-Category C) →
hom-Category C z x → hom-Category C z y
postcomp-hom-Category C = postcomp-hom-Precategory (precategory-Category C)
```
## Properties
### The objects in a category form a 1-type
The type of identities between two objects in a category is equivalent to the
type of isomorphisms between them. But this type is a set, and thus the identity
type is a set.
```agda
module _
{l1 l2 : Level} (C : Category l1 l2)
where
is-1-type-obj-Category : is-1-type (obj-Category C)
is-1-type-obj-Category =
is-1-type-obj-Preunivalent-Category (preunivalent-category-Category C)
obj-1-type-Category : 1-Type l1
obj-1-type-Category =
obj-1-type-Preunivalent-Category (preunivalent-category-Category C)
```
### The total hom-type of a category is a 1-type
```agda
module _
{l1 l2 : Level} (C : Category l1 l2)
where
is-1-type-total-hom-Category :
is-1-type (total-hom-Category C)
is-1-type-total-hom-Category =
is-1-type-total-hom-Preunivalent-Category (preunivalent-category-Category C)
total-hom-1-type-Category : 1-Type (l1 ⊔ l2)
total-hom-1-type-Category =
total-hom-1-type-Preunivalent-Category (preunivalent-category-Category C)
```
### A preunivalent category is a category if and only if `iso-eq` is surjective
```agda
module _
{l1 l2 : Level} (C : Precategory l1 l2)
where
is-surjective-iso-eq-prop-Precategory : Prop (l1 ⊔ l2)
is-surjective-iso-eq-prop-Precategory =
Π-Prop
( obj-Precategory C)
( λ x →
Π-Prop
( obj-Precategory C)
( λ y →
is-surjective-Prop
( iso-eq-Precategory C x y)))
is-surjective-iso-eq-Precategory : UU (l1 ⊔ l2)
is-surjective-iso-eq-Precategory =
type-Prop is-surjective-iso-eq-prop-Precategory
is-prop-is-surjective-iso-eq-Precategory :
is-prop is-surjective-iso-eq-Precategory
is-prop-is-surjective-iso-eq-Precategory =
is-prop-type-Prop is-surjective-iso-eq-prop-Precategory
```
```agda
module _
{l1 l2 : Level} (C : Preunivalent-Category l1 l2)
where
is-category-is-surjective-iso-eq-Preunivalent-Category :
is-surjective-iso-eq-Precategory (precategory-Preunivalent-Category C) →
is-category-Precategory (precategory-Preunivalent-Category C)
is-category-is-surjective-iso-eq-Preunivalent-Category
is-surjective-iso-eq-C x y =
is-equiv-is-emb-is-surjective
( is-surjective-iso-eq-C x y)
( is-preunivalent-Preunivalent-Category C x y)
is-surjective-iso-eq-is-category-Preunivalent-Category :
is-category-Precategory (precategory-Preunivalent-Category C) →
is-surjective-iso-eq-Precategory (precategory-Preunivalent-Category C)
is-surjective-iso-eq-is-category-Preunivalent-Category
is-category-C x y =
is-surjective-is-equiv (is-category-C x y)
is-equiv-is-category-is-surjective-iso-eq-Preunivalent-Category :
is-equiv is-category-is-surjective-iso-eq-Preunivalent-Category
is-equiv-is-category-is-surjective-iso-eq-Preunivalent-Category =
is-equiv-is-prop
( is-prop-is-surjective-iso-eq-Precategory
( precategory-Preunivalent-Category C))
( is-prop-is-category-Precategory (precategory-Preunivalent-Category C))
( is-surjective-iso-eq-is-category-Preunivalent-Category)
is-equiv-is-surjective-iso-eq-is-category-Preunivalent-Category :
is-equiv is-surjective-iso-eq-is-category-Preunivalent-Category
is-equiv-is-surjective-iso-eq-is-category-Preunivalent-Category =
is-equiv-is-prop
( is-prop-is-category-Precategory (precategory-Preunivalent-Category C))
( is-prop-is-surjective-iso-eq-Precategory
( precategory-Preunivalent-Category C))
( is-category-is-surjective-iso-eq-Preunivalent-Category)
equiv-is-category-is-surjective-iso-eq-Preunivalent-Category :
is-surjective-iso-eq-Precategory (precategory-Preunivalent-Category C) ≃
is-category-Precategory (precategory-Preunivalent-Category C)
pr1 equiv-is-category-is-surjective-iso-eq-Preunivalent-Category =
is-category-is-surjective-iso-eq-Preunivalent-Category
pr2 equiv-is-category-is-surjective-iso-eq-Preunivalent-Category =
is-equiv-is-category-is-surjective-iso-eq-Preunivalent-Category
equiv-is-surjective-iso-eq-is-category-Preunivalent-Category :
is-category-Precategory (precategory-Preunivalent-Category C) ≃
is-surjective-iso-eq-Precategory (precategory-Preunivalent-Category C)
pr1 equiv-is-surjective-iso-eq-is-category-Preunivalent-Category =
is-surjective-iso-eq-is-category-Preunivalent-Category
pr2 equiv-is-surjective-iso-eq-is-category-Preunivalent-Category =
is-equiv-is-surjective-iso-eq-is-category-Preunivalent-Category
```