-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tex
2268 lines (2118 loc) · 97.7 KB
/
main.tex
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%% Document type
\documentclass[]{amsbook}
%% Packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{exercise}
\usepackage{hyperref}
\usepackage{tikz-cd}
\usepackage{bbm}
%% User-defined commands
\newcommand{\q}{\quad}
\newcommand{\qq}{\qquad}
\newcommand{\catname}[1]{\mathbf{#1}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\0}{\mathbf{0}}
\newcommand{\1}{\mathbf{1}}
\newcommand{\oldemptyset}{\emptyset}
\renewcommand{\emptyset}{\varnothing}
\newcommand{\dps}{\displaystyle}
\newcommand{\List}{\texttt{List}}
\newcommand{\mbb}[1]{\mathbb{#1}}
\newcommand{\mc}[1]{\mathcal{#1}}
\newcommand{\opn}[1]{\operatorname{#1}}
\newtheorem{prop}{Proposition}
\newenvironment{solution}
{\begin{proof}[Solution]}{\end{proof}}
\begin{document}
\title{Introduction to Categories and Categorical Logic}
\author{Vishal Lama}
\date{\today}
\maketitle
\tableofcontents
\chapter{Introduction to Categories and Categorical Logic}
\section{Introduction}
We say that a function $f: X \to Y$ is:\\~\\
\begin{tabular}{ l l }
\emph{injective} & if $\forall x, x' \in X. f(x) = f(x') \implies x = x'$, \\
\emph{surjective} & if $\forall y \in Y. \exists x \in X. f(x) = y$, \\~\\
\emph{monic} & if $\forall g, h. f \circ g = f \circ h \implies g = h$
\q ($f$ is left cancellative),\\
\emph{epic} & if $\forall g, h. g \circ f = h \circ f \implies g = h$
\q ($f$ is right cancellative).
\end{tabular}\\
\begin{prop}
Let $f : X \to Y$. Then,
\begin{enumerate}
\item $f$ is injective $\iff f$ is monic.
\item $f$ is surjective $\iff f$ is epic.
\end{enumerate}
\end{prop}
\begin{proof}
We first show $(1)$.\\
($\impliedby$) Suppose $f$ is monic. Fix a one-element set
$\boldsymbol{1} = \{ \bullet \}$. Then, note that elements $x \in X$ are in
1-1 correspondence with functions $\bar{x}: \boldsymbol{1} \to X$, defined
by $\bar{x}(\bullet) := x$. Then, for all $x, x' \in X$, we have\\~\\
\begin{tabular} { l l }
& $f(x) = f(x')$\\
$\implies$ & $f(\bar{x}(\bullet)) = f(\bar{x'}(\bullet))$\\
$\implies$ & $(f \circ \bar{x})(\bullet) = (f \circ \bar{x'})(\bullet)$\\
$\implies$ & $f \circ \bar{x} = f \circ \bar{x'}$\\
$\implies$ & $\bar{x} = \bar{x'}$ \q (since $f$ is monic) \\
$\implies$ & $\bar{x}(\bullet) = \bar{x'}(\bullet)$\\
$\implies$ & $x = x'$
\end{tabular}\\
This shows that $f$ is injective.\\
($\implies$) Suppose $f$ is injective. Let $f \circ g = f \circ h$ for all
$g, h: A \to X$. Then, for all $a \in A$,\\
\begin{tabular} { l l }
& $(f \circ g)(a) = (f \circ h)(a)$\\
$\implies$ & $f(g(a)) = f(h(a))$\\
$\implies$ & $g(a) = h(a)$ \q (since $f$ is injective)\\
$\implies$ & $g = h$
\end{tabular}\\
This establishes that $f$ is monic. And, we are done.
\end{proof}
\setcounter{Exercise}{1}
\begin{Exercise}
Show that $f: X \to Y$ is surjective iff it is epic.
\end{Exercise}
\begin{solution}
($\implies$) Suppose $f: X \to Y$ is epic. And, assume, for the sake of
contradiction, $f$ is \emph{not} surjective. Then, there exists some $y_0
\in Y$, such that, for all $x \in X$, $f(x) \ne y_0$. Define mappings
$g, h: Y \to Y \cup \{ Y \}$ by:
\begin{center}
$g(y) := y$\\~\\
$h(y) :=
\begin{cases}
y & \text{if } y \ne y_0 \\
Y & \text{if } y = y_0
\end{cases}$
\end{center}
Note that $g \ne h$.\\
Then, for all $x \in X$, $(g \circ f)(x) = g(f(x)) = h(f(x)) = (h \circ f)
(x)$.
This implies $g \circ f = h \circ f$, which implies $g = h$, since $f$ is
epic. The last conclusion contradicts the fact that $g = h$. Thus, we
conclude $f$ is surjective.\\~\\
($\impliedby$) Suppose $f: X \to Y$ is surjective. Then, for any $y \in Y$,
there exists an $x \in X$, such that $f(x) = y$. Now, assume, for all
$g, h: Y \to Z$, $g \circ f = h \circ f$. Then, for all $y \in Y$,
$g(y) = g(f(x)) = (g \circ f)(x) = (h \circ f)(x) = h(f(x)) = h(y)$, which
implies $g = h$, showing that $f$ is epic.\\
And, this completes our proof.
\end{solution}
\setcounter{Exercise}{4}
\begin{Exercise}
Suppose $G$ and $H$ are groups (and hence monoids), and that $h: G \to H$
is a monoid homomorphism. Prove that $h$ is a group homomorphism.
\end{Exercise}
\begin{solution}
We need only show that $h$ preserves inverses. To that end,
suppose $g^{-1}$ is the inverse of $g \in G$. Then, $h(g) h(g^{-1}) =
h(g g^{-1}) = h(1_G) = 1_H = h(1_G) = h(g^{-1} g) = h(g^{-1}) h(g)$.
This establishes $h$ preserves inverses, and we are done.
\end{solution}
\begin{Exercise}
Check that $\catname{Mon}, \catname{Vect}_k, \catname{Pos}$, and
$\catname{Top}$ are indeed categories.
\end{Exercise}
\begin{solution}
($\catname{Mon}$) The objects are monoids $(M, \cdot, 1_M)$, and morphisms
are monoid homomorphisms. Given monoid homomorphisms, $f: (M, \cdot, 1_M)
\to (N, \cdot, 1_N)$ and $g: (N, \cdot, 1_N) \to (P, \cdot, 1_P)$, the
function $g \circ f: (M, \cdot, 1_M) \to (P, \cdot, 1_P)$ is also a monoid
homomorphism, because for all $m, m' \in M$, we have $(g \circ f)(m m') =
g(f(m m')) = g(f(m) f(m')) = (g(f(m)) (g(f(m'))) = ((g \circ f)(m))
((g \circ f)(m'))$. Also, for each monoid, the identity morphism is the
identity function. It is also easy to check that for all monoid
homomorphisms $f, g$ and $h$ with the appropriate domains and codomains,
$h \circ (g \circ f) = (h \circ g) \circ f$. This establishes that
$\catname{Mon}$ is indeed a category.
($\catname{Vect}_k$) The objects are vector spaces over a field $k$, and
morphisms are linear maps between vector spaces. Suppose $f: U \to V$ and
$g: V \to W$ are linear maps. Then, for all $x, y \in U$, we have
$(g \circ f)(x + y) = g(f(x + y)) = g(f(x) + f(y)) = g(f(x)) + g (f(y)) =
(g \circ f)(x) + (g \circ f)(y)$. Also, for all $\alpha \in k$, we have
$(g \circ f)(\alpha x) = g(f(\alpha x)) = g(\alpha f(x)) = \alpha g(f(x))
= \alpha (g \circ f)(x)$. This establishes $g \circ f: U \to W$ is a
linear map as well. The identity map $1_U$ for any vector space $U$ is the
identity morphism. The associativity of linear maps and the identity axiom
follow from the property of functions. This shows that $\catname{Vect}_k$
is also a category.
($\catname{Pos}$) The objects are partially ordered sets, and morphisms
are monotone functions between these sets. Suppose $h: P \to Q$ and
$g: Q \to R$ are monotone functions. Then, for all $x, y \in P$,
$x \le y \implies h(x) \le h(y) \implies g(h(x)) \le g(h(y)) \implies
(g \circ h)(x) \le (g \circ h)(y)$, which shows $g \circ h: P \to R$ is
a monotone function. The identity map is the identity morphism, and the
associativity and identity axioms are satisfied by the property of
functions. This establishes $\catname{Pos}$ is a category.
($\catname{Top}$) The objects are topological spaces, and morphisms are
continuous maps between these spaces. Given continuous maps $f: (X, T_X)
\to (Y, T_Y)$ and $g: (Y, T_Y) \to (Z, T_Z)$, we can show that $g \circ f:
(X, T_X) \to (Z, T_Z)$ is also a continuous map. First, note that for any
$T \subset Z$, $x \in (g \circ f)^{-1}(T)$ iff $(g \circ f)(x) \in T$ iff
$g(f(x)) \in T$ iff $f(x) \in g^{-1}(T)$ iff $x \in f^{-1}(g^{-1}(T))$.
Thus,
\begin{center}
for all $T \subset Z, (g \circ f)^{-1}(T) = f^{-1}(g^{-1}(T))$.
\end{center}
Therefore, for any open set $T \in T_Z$, we have $g^{-1}(T) \in T_Y$,which
implies $f^{-1}(g^{-1}(T)) \in T_X$, which implies $(g \circ f)^{-1}(T)
\in T_X$ (by using the result above.) Hence, $g \circ f: (X, T_X) \to
(Z, T_Z)$ is a continuous map. The associativity and identity axioms follow
from the associativity and identity laws for functions. This establishes
$\catname{Top}$ is a category.
\end{solution}
\begin{Exercise}
Check carefully that monoids correspond exactly to one-object categories.
Make sure you understand the difference between such a category and
$\catname{Mon}$. (For example: how many objects does $\catname{Mon})$
have?)
\end{Exercise}
\begin{solution}
(\href{https://ncatlab.org/nlab/show/monoid#as_a_oneobject_category}
{Monoid as a one-object category}) Given a monoid $(M, \cdot, 1)$,
we can construct its corresponding category as follows. We write
$\catname{B}M$ for the corresponding category with a single object
$\bullet$, where $\catname{Hom}_{\catname{B}M}(\bullet, \bullet) := M$.
We note then that the composition map in $\catname{B}M$ is reflected in
the binary operation $\_ \cdot \_ : M \times M \to M$, where
$\mathbf{id}_{\bullet} := 1$. Then, the associative and identity laws for
the category $\catname{B}M$ follow directly from the associative and
identity laws, respectively, satisfied by the monoid $(M, \cdot, 1)$.
This shows any monoid can be seen or interpreted as a one-object category.
\end{solution}
\begin{Exercise}
Check carefully that preorders correspond exactly to categories in which
each homset has at most one element. Make sure you understand the
difference between such a category and $\catname{Pos}$. (For example: how
big can homsets in $\catname{Pos}$ be?)
\end{Exercise}
\begin{solution}
Let $(P, \le)$ be a preorder. Then, we define the corresponding category
$\catname{C}$ as follows. The objects of $\catname{C}$ are the elements of
the set $P$, and for all $x, y \in P$, we define a morphism $x \to y$ iff
$x \le y$. Then, for every object $x \in \catname{C}$, the identity
morphism $1_x: x \to x$ corresponds exactly to the reflexive property
$x \le x$ for all $x \in P$. Note that each homset in $\catname{C}$ has at
most one element. Also, for every $x \to y$ and $y \to z$ in $\catname{C}$,
$x \to z$ follows from the fact that $x \le y$ and $y \le z$ and the
transitivity of the $\le$ relation on $P$. This defines a composition map
for morphisms in $\catname{C}$. In addition, for all morphisms $x \to y$,
$y \to z$, and $z \to w$, their associativity follows immediately from the
transitivity of $\le$. Lastly, the unit laws also follow from the same
transitivity relation. Therefore, we conclude that every preorder
corresponds precisely to a category in which each homset has at most one
element.
\end{solution}
\setcounter{Exercise}{9}
\begin{Exercise}
Show that the inverse, if it exists, is unique.
\end{Exercise}
\begin{solution}
Suppose $i: A \to B$ is an isomorphism, with inverse $j: B \to A$, in a
category $\catname{C}$. Suppose $j': B \to A$ is also an inverse of $i$.
Then, $j = 1_A \circ j = (j' \circ i) \circ j = j' \circ (i \circ j) =
j' \circ 1_B = j'$, and we are done.
\end{solution}
\begin{Exercise}
Show that $\cong$ is an equivalence relation on the objects of a category.
\end{Exercise}
\begin{solution}
Let $\catname{C}$ be some category.\\
(\emph{Reflexivity}) For any object $X \in \catname{C}$, $X \cong X$
follows from the fact that the identity morphism $1_X: X \to X$ is an
isomorphism.\\
(\emph{Symmetry}) If $X \cong Y$, then there exists an isomorphism $i: X
\to Y$. But, the inverse, $i^{-1}: Y \to X$, of $i$ is also an isomorphism.
Hence, $Y \cong X$.\\
(\emph{Transitivity}) Suppose $X \cong Y$ and $Y \cong Z$. Then, there
exist isomorphisms $i: X \to Y$ and $j: Y \to Z$. Then, we claim that
$j \circ i: X \to Z$ is also an isomorphism. Indeed, its trivial to show
that its inverse is the morphism $i^{-1} \circ j^{-1}: Z \to X$. This
implies $X \cong Z$.\\
We thus conclude that $\cong$ is an equivalence relation on the objects of
a category.
\end{solution}
\begin{Exercise}
Verify the claims that isomorphisms in $\catname{Set}$ correspond exactly
to bijections, in $\catname{Grp}$ to group isomorphisms, in $\catname{Top}$
to homeomorphisms, and in $\catname{Pos}$ to isomorphisms.
\end{Exercise}
\begin{solution}
($\catname{Set}$) We claim the following:
\begin{enumerate}
\item $f: X \to Y$ is injective iff $f$ has a left inverse.
\item $f: X \to Y$ is surjective iff $f$ has a right inverse.
\end{enumerate}
We first show (1).
($\implies$) Suppose $f: X \to Y$ has a left inverse, $g: Y \to X$, say.
Then, $g \circ f = 1_X$. Assume for any $x, x' \in X, f(x) = f(x')$. Then,
$x = 1_X(x) = (g \circ f)(x) = g(f(x)) = g(f(x')) = (g \circ f)(x') =
1_X(x') = x'$, which implies $f$ is injective.
($\impliedby$) Suppose $f: X \to Y$ is injective. If $X$ is empty, then $f$
is an empty function corresponding to each $Y$. In this case, $1_X$ is also
an empty function, and we thus have $g \circ f = 1_X$ for any $g: Y \to X$.
That is, $f$ has a left inverse. On the other hand, if $X$ is nonempty,
choose some $x_0 \in X$. Define $g: Y \to X$ by
\begin{center}
$g(y) :=
\begin{cases}
x_0 & \text{if } y \in Y \setminus \mathbf{Im}(f) \\
f^{-1}(y) & \text{if } y \in \mathbf{Im}(f)
\end{cases}$
\end{center}
Then, for all $x \in X, (g \circ f)(x) = g(f(x)) = x = 1_X(x)$, which
implies $g \circ f = 1_X$, thus showing that $g$ is a left inverse of $f$.
We now show (2).
($\implies$) Suppose $f: X \to Y$ has a right inverse, $g: Y \to X$, say.
Then, $f \circ g = 1_Y$. Therefore, for all $y \in Y$, $y = 1_Y(y) =
(f \circ g)(y) = f(g(y)) = f(x)$, where $x = g(y)$. This shows $f$ is
surjective.
($\impliedby$) Suppose $f: X \to Y$ is surjective. Now, consider an indexed
family of nonempty sets $\{ f^{-1}(y)\}_{y \in Y}$. Then, using the axiom
of choice, we conclude there exists a function $g: Y \to X$, such that $g(y)
\in f^{-1}(y)$ for all $y \in Y$. Then, for all $y \in Y$, $(f \circ g)(y) =
f(g(y)) = y = 1_Y(y)$, which implies $f \circ g = 1_Y$, thus proving $f$ has
a right inverse.
Since in $\catname{Set}$ a bijection is a function which is both injective
and surjective, using (1) and (2), we immediately conclude that bijections
in $\catname{Set}$ correspond exactly to isomorphisms, and we are done.
In addition, in any category $\catname{C}$, if $f: X \to Y$ has both a left
inverse, $g: Y \to X$, say, and a right inverse, $h: Y \to X$, say, then
$g = h$. Indeed, $g = g \circ 1_Y = g \circ (f \circ h) = (g \circ f) \circ
h = 1_X \circ h = h$, and we are done.\\
% TODO
($\catname{Grp}$)
% TODO
($\catname{Top}$)
% TODO
($\catname{Pos}$)
\end{solution}
\subsection*{Opposite Categories and Duality}
Given a category $\catname{C}$, the opposite category $\catname{C}^{\mathbf{op}}$
is given by taking the same objects as $\catname{C}$, and
\begin{center}
$\catname{C}^{\mathbf{op}}(A, B) = \catname{C}(B, A)$.
\end{center}
Composition and identities are inherited from $\catname{C}$.\\
If we have
\begin{center}
$A \xrightarrow{f} B \xrightarrow{g} C$
\end{center}
in $\catname{C}^{\mathbf{op}}$, this means
\begin{center}
$A \xleftarrow{f} B \xleftarrow{g} C$
\end{center}
in $\catname{C}$. Therefore, composition $ g \circ f$ is
$\catname{C}^{\mathbf{op}}$ is defined as $f \circ g$ in $\catname{C}$. This
leads to the \emph{\textbf{principle of duality}}: a statement $S$ is true
about a category $\catname{C}$ iff its dual (\emph{i.e.} the one obtained
from $S$ by reversing all the arrows) is true about $\catname{C}^{\mathbf{op}}$.
For example, a morphism $f$ is monic in $\catname{C}^{\mathbf{op}}$ iff it is
epic in $\catname{C}$. We say monic and epic are \emph{dual notions}.
\setcounter{Exercise}{13}
\begin{Exercise}
If $P$ is a preorder, for example $(\R, \le)$, describe $P^{\mathbf{op}}$
explicitly.
\end{Exercise}
\begin{solution}
An arrow $a \le_{P^{\mathbf{op}}} b$ in $P^{\mathbf{op}}$ is precisely the
arrow $b \le_P a$ in $P$. When $P = (\R, \le)$, $P^{\mathbf{op}}$ describes
the ``greater than or equal" preorder relation on $\R$.
\end{solution}
\subsection*{Subcategories}
Let $\catname{C}$ be a category. Suppose we are given the collections
\begin{center}
$\mathbf{Ob}(\catname{D}) \subseteq \mathbf{Ob}(\catname{C})$,\\
$\forall A, B \in \mathbf{Ob}(\catname{D}).
\catname{D}(A, B) \subseteq \catname{C}(A, B)$.
\end{center}
We say $\catname{D}$ is a \emph{\textbf{subcategory}} of $\catname{C}$ if
it is itself a category. In particular, $\catname{D}$ is:
\begin{itemize}
\item A \emph{\textbf{full}} subcategory of $\catname{C}$ if for any
$A, B \in \mathbf{Ob}(\catname{D})$, $\catname{D}(A, B) = \catname{C}(A, B)$.
\item A \emph{\textbf{lluf}} subcategory of $\catname{C}$ if
$\mathbf{Ob}(\catname{D}) = \mathbf{Ob}(\catname{C})$.
\end{itemize}
For example, $\catname{Grp}$ is a full subcategory of $\catname{Mon}$, and
$\catname{Set}$ is a lluf subcategory of $\catname{Rel}$.
\setcounter{Exercise}{15}
\begin{Exercise}
How many categories $\catname{C}$ with $\mathbf{Ob}(\catname{C}) =
\{ \bullet \}$ are there? (Hint: what do such categories correspond to?)
\end{Exercise}
\begin{solution}
Each such category corresponds to a monoid. So, there are as many such
categories as there are monoids.
\end{solution}
\subsection*{Exercises}
\begin{enumerate}
\item Consider the following properties of an arrow $f$ in a category
$\catname{C}$.
\begin{itemize}
\item $f$ is \emph{split monic} if for some $g$, $g \circ f$ is an
identity arrow.
\item $f$ is \emph{split epic} if for some $g$, $f \circ g$ is an
identity arrow.
\end{itemize}
\begin{itemize}
\item[a.] Prove that if $f$ and $g$ are arrows such that $g \circ f$ is
monic, then $f$ is monic.
\item[b.] Prove that if $f$ is split epic then it is epic.
\item[c.] Prove that if $f$ and $g \circ f$ are iso then $g$ is iso.
\item[d.] Prove that if $f$ is monic and split epic then it is iso.
\item[e.] In the category $\catname{Mon}$ of monoids and monoid
homomorphisms, consider the inclusion map
\begin{center}
$i: (\N, +, 0) \to (\Z, +, 0)$
\end{center}
of natural numbers into the integers. Show that this arrow is both monic
and epic. Is it an iso?
\end{itemize}
The \textbf{Axiom of Choice} in Set Theory states that if
$\{ X_i \}_{i \in I}$ is a family of nonempty sets, we can form a set
$X = \{ x_i \mid i \in I \}$, where $x_i \in X_i$ for all $i \in I$.
\begin{itemize}
\item[f.] Show that in $\catname{Set}$ an arrow which is epic is split
epic. Explain why this needs the Axiom of Choice.
\item[g.] Is is always the case that an arrow which is epic is split
epic? Either prove that it is, or give a counterexample.
\end{itemize}
\item Give a description of partial orders as categories of a special kind.
\end{enumerate}
\begin{solution}
\leavevmode
\begin{enumerate}
\item \leavevmode
\begin{itemize}
\item[a.] Suppose $f: A \to B$ and $g: B \to C$ such that
$g \circ f$ is monic. Assume, for all $i, j: Z \to A$,
$f \circ i = f \circ j$. Then, $(g \circ f) \circ i = g \circ
(f \circ i) = g \circ (f \circ j) = (g \circ f) \circ j$, which
implies $i = j$, since $g \circ f$ is monic. This implies $f$ is
monic, and we are done.
\item[b.] Suppose $f: A \to B$ is split epic. Then, there exists a
$g: B \to A$ such that $f \circ g = 1_B$. Assume, for all $i, j: B
\to C$, $i \circ f = j \circ f$. Then, $i = i \circ 1_B = i \circ
(f \circ g) = (i \circ f) \circ g = (j \circ f) \circ g = j \circ
(f \circ g) = j \circ 1_B = j$, which shows $f$ is epic.
\item[c.] Suppose $f: A \to B$ and $g: B \to C$ such that $f$ and
$g \circ f$ are iso. We claim that the inverse of $g$ is
$f \circ (g \circ f)^{-1}: C \to B$. Indeed, $g \circ (f \circ
(g \circ f)^{-1}) = (g \circ f) \circ (g \circ f)^{-1} = 1_C$, and
$(f \circ (g \circ f)^{-1}) \circ g = f \circ (g \circ f)^{-1} \circ
(g \circ f) \circ f^{-1} = f \circ f^{-1} = 1_B$, which establishes
$g$ is also an iso.
\item[d.] Suppose $f: A \to B$ is monic and split epic. The latter
implies $f$ has a right inverse, $g: B \to A$, say, where $f \circ g
= 1_B$. Note that $g \circ f: A \to A$ and $1_A: A \to A$. Now,
$f \circ (g \circ f) = (f \circ g) \circ f = 1_B \circ f = f = f
\circ 1_A$, which implies $g \circ f = 1_A$, since $f$ is monic
(left cancellative). Thus, $g$ is also a left inverse of $f$, and
hence, $f$ is iso.
\item[e.] It is easy to prove the inclusion map $\N \hookrightarrow
\Z$ is really a monoid homomorphism. Indeed, $i(0) = 0$, and, for all
$n_1, n_2 \in \N$, $i(n_1 + n_2) = n_1 + n_2 = i(n_1) + i(n_2)$.\\
Next, we show that $i$ is monic. Assume, for all monoid homomorphisms
$g, h: X \to \N$, $i \circ g = i \circ h$. Then, for all $x \in X$,
$(i \circ g)(x) = (i \circ h) (x)$, which implies $i(g(x)) = i(h(x))$,
which implies $g(x) = h(x)$, which implies $g = h$. This shows the
inclusion map is monic.\\
We now show the inclusion map is epic. First, assume, for all
monoid homomorphisms $g, h: (\Z, +, 0) \to (X, \star, 1_X)$,
$g \circ i = h \circ i$. Then, for all $n \in \N$, $(g \circ i)(n)
= (h \circ i)(n)$, which
implies $g(i(n)) = h(i(n))$, which implies $g(n) = h(n)$. We now
claim that for all $n \ge 1$, $g(-n) = h(-n)$. To that end, we use
induction on $n$. Note that $g(-1) = g(-1) \star 1_X = g(-1) \star
h(0) = g(-1) \star h(1 + (-1)) = g(-1) \star h(1) \star h(-1) = g(-1)
\star g(1) * h(-1) = g(-1 + 1) \star h(-1) = g(0) \star h(-1) = 1_X
\star h(-1) = h(-1)$. Now, assume the proposition holds for some
$n \ge 1$. Then, $g(-(n + 1)) = g(-n + (-1)) = g(-n) \star g(-1) =
h(-n) \star h(-1) = h(-n + (-1)) = h(-(n + 1))$. Hence, by induction,
$g(-n) = h(-n)$ for all $n \ge 1$. Combining the results from above,
we thus conclude $g(z) = h(z)$ for all $z \in \Z$. In other words,
$g = h$, which implies $i$ is epic.\\
Clearly, the inclusion map $\N \hookrightarrow \Z$ is not iso.
\item[f.] Suppose $f: X \to Y$ is epic in $\catname{Set}$. Then,
from an earlier result about $\catname{Set}$, we conclude $f$ is
surjective. Now, consider the family of nonempty sets
$\{ f^{-1}(b) \}_{b \in B}$. Each of the sets in the family is
nonempty, because $f$ is surjective. Therefore, using the Axiom of
Choice, we can choose some element from each nonempty set in the
family to construct a function $g: Y \to X$, given by $g(y) := x$
if $x \in f^{-1}(b)$. In addition, for all $y \in Y$, $(f \circ g)(y)
= f(g(y)) = y = 1_Y(y)$, which implies $f \circ g = 1_Y$. This shows
$f$ has a right inverse, thus proving $f$ is split epic.
\item[g.] It isn't always the case that an arrow which is epic is
split epic. For example, in the category $\catname{Mon}$, the
inclusion map $\N \hookrightarrow \Z$ is epic (as shown in (e)
above.) Now, if we assume that it is also split epic, then there
exists a monoid homomorphism $g: \Z \to \N$, such that $i \circ g =
1_{\Z}$. This implies $(i \circ g)(-1) = 1_{\Z}(-1)$, which implies
$i(g(-1)) = -1$, which implies $g(-1) = -1$, which implies $-1 \in
\N$, which is absurd. We thus conclude the aforesaid inclusion map
is \emph{not} split epic, even though it is epic. And this proves
our original claim.
\end{itemize}
\item Suppose $(P, \le)$ is a poset. Then, its corresponding category
$\catname{C}$ is defined as follows. The objects of $\catname{C}$ are the
elements of $P$, and for all $x, y \in P$, $x \to y$ iff $x \le y$. The
reflexivity of $\le$ corresponds to the identity arrows, and transitivity
to arrow composition. Note that there is at most one arrow for every pair
of objects in the category. Anti-symmetry of $\le$ corresponds to the fact
that the only isomorphisms in $\catname{C}$ are the identity arrows.
\end{enumerate}
\end{solution}
\section{Some Basic Constructions}
\subsection*{Initial and Terminal Objects}
An object $I$ in a category $\catname{C}$ is \emph{\textbf{initial}} if, for
every object $A$, \emph{there exists a unique arrow} $I \to A$, which we write
$\iota_{A}: I \to A$.
An object $T$ in a category $\catname{C}$ is \emph{\textbf{terminal}} if, for
every object $A$, \emph{there exists a unique arrow} $A \to T$, which we write
$\tau_{A}: A \to T$.
Note that initial and terminal objects are dual notions: $T$ is terminal in
$\catname{C}$ iff it is initial in $\catname{C}^{\mathbf{op}}$. We sometimes
write $\1$ for the terminal object and $\0$ for the initial object.
\setcounter{Exercise}{17}
\begin{Exercise}
Verify the following claims. In each case, identify the canonical arrows.
\begin{enumerate}
\item In $\catname{Set}$, the empty set is an initial object while any
one-element set $\{ \bullet \}$ is terminal.
\item In $\catname{Pos}$, the poset $(\emptyset, \emptyset)$ is an
initial object while $(\{ \bullet \}, \{ (\bullet, \bullet) \})$ is
terminal.
\item In $\catname{Top}$, the space $(\emptyset, \{ \emptyset \})$ is
an initial object while $(\{ \bullet \}, \{ \emptyset, \{ \bullet \} \})$
is terminal.
\item In $\catname{Vect}_k$, the one-element space $\{ 0 \}$ is both
initial and terminal.
\item In a poset, seen as a category, an initial object is a least
element, while a terminal object is a greatest element.
\end{enumerate}
\end{Exercise}
\begin{solution}
\leavevmode
\begin{enumerate}
\item In $\catname{Set}$, for any set (object) $A$, the function
$(\emptyset, A, \emptyset)$ is the unique function (arrow) from
$\emptyset$ to $A$. Therefore, the empty set is (the) initial object in
$\catname{Set}$. And, for every set $A$, the function $A \to
\{ \bullet \}$ that maps every element of $A$ to $\bullet$ is the unique
function from $A$ to $\{ \bullet \}$. This establishes that any
one-element set is terminal in $\catname{Set}$.
\item For any poset $(P, \le)$, there exists a unique (empty) monotone
function $(\emptyset, \emptyset) \xrightarrow{(\emptyset, P, \emptyset)}
(P, \le)$. Hence, the poset $(\emptyset, \emptyset)$ is an initial object
in $\catname{Pos}$. And, for any poset $(P, \le)$, there exists a unique
monotone function $(P, \le) \to (\{ \bullet \}, \{ (\bullet, \bullet) \})$,
defined by $x \mapsto \bullet$ for all $x \in P$. Hence, $(\{ \bullet \},
\{ (\bullet, \bullet) \})$ is terminal in $\catname{Pos}$.
\item For any topological space $(X, T_X)$, the unique empty function
\begin{center}
$(\emptyset, \{ \emptyset \}) \xrightarrow{(\emptyset, X, \emptyset)}
(X, T_X)$
\end{center}
is continuous, since for every open set $T \in T_X$, its preimage under
the aforesaid function is the empty set, which is open. Hence,
$(\emptyset, \{ \emptyset \})$ is initial in $\catname{Top}$.\\
And, for any topological space $(X, T_X)$, the unique function
$(X, T_X) \to (\{ \bullet \}, \{ \emptyset, \{ \bullet \} \})$, defined by
$x \mapsto \bullet$ for all $x \in X$, is continuous, since the preimage
of $\emptyset$ under the aforesaid function is $\emptyset$, which is open,
and the preimage of $\{ \bullet \}$ is $X$, which is also open. Hence,
$(\{ \bullet \}, \{ \emptyset, \{ \bullet \} \})$ is terminal in
$\catname{Top}$.
\item Assuming the ground field is $k$, for any vector space $V$, the
unique linear map $\{ 0 \} \to V$, defined by $0 \mapsto 0_V$ is a unique
arrow from $\{ 0 \}$ to $V$ in $\catname{Vect}_k$. Also, the unique linear
map $V \to \{ 0\}$, defined by $v \mapsto 0$ for all $v \in V$, is a
unique arrow from $V$ to $\{ 0 \}$ in $\catname{Vect}_k$. This shows that
$\{ 0 \}$ is both initial and terminal in $\catname{Vect}_k$.
\item In a poset $(P, \le)$, seen as a category, if $\bot$ is an initial
object, then there exists a unique arrow $\bot \to p$ for all $p \in P$.
This implies $\bot \le p$ for all $p \in P$, when seen as a set. Hence,
an initial object in the category corresponding to $(P, \le)$ is a least
element in $P$. Arguing similarly, we conclude that a terminal object in
the category corresponding to $(P, \le)$ is a greatest element in $P$.
\end{enumerate}
\end{solution}
\begin{Exercise}
Identify the initial and terminal objects in $\catname{Rel}$.
\end{Exercise}
\begin{solution}
In $\catname{Rel}$, the empty set $\emptyset$ is both the initial object and
the terminal object. Indeed, for any set $A$, the empty relation $\emptyset$
($\subseteq \emptyset \times A$) is a unique relation from $\emptyset$ to
$A$, and the empty relation $\emptyset$ ($\subseteq A \times \emptyset$) is
also a unique relation from $A$ to $\emptyset$.
\end{solution}
\begin{Exercise}
Suppose a monoid, viewed as a category, has either an initial or a terminal
object. What must the monoid be?
\end{Exercise}
\begin{solution}
The category corresponding to a monoid $(M, \cdot, 1_M)$ contains just a
single object. If this object is initial, then all morphisms must be the
identity morphism on this initial object, which implies $M = \{ 1_M \}$.
The argument is similar if the aforesaid object is terminal, which would
again imply $M = \{ 1_M \}$. Thus, in either case, the monoid must be the
trivial monoid.
\end{solution}
A fundamental fact about initial and terminal objects is that they are
\emph{unique up to (unique) isomorphism}. This is characteristic of all such
``universal" definitions. Hence, if initial objects exist in a category, we
can speak of \emph{the} initial object. Similarly for terminal objects.
\setcounter{Exercise}{21}
\begin{Exercise}
Let $\catname{C}$ be a category with an initial object $\0$. For any object
$A$, show the following:
\begin{enumerate}
\item If $A \cong \0$, then $A$ is an initial object.
\item If there exists a monomorphism $f: A \to \0$, then $f$ is an iso,
and hence $A$ is initial.
\end{enumerate}
\end{Exercise}
\begin{solution}
\leavevmode
\begin{enumerate}
\item Suppose $A \cong \0$. Then, there exists an isomorphism $f: A
\xrightarrow{\sim} \0$. For any object $B$, there exists a unique
morphism $\iota_B: \0 \to B$, and hence, $\iota_B \circ f: A \to B$.
This proves the existence of a morphism $A \to B$ for any object $B$
in the category. We now show that such a morphism is indeed unique.
Let $g, h: A \to B$ be a pair of morphisms for any object $B$ in the
category $\catname{C}$. Then, we have
\begin{center}
$\0 \xrightarrow{f^{-1}} A \xrightarrow{g} B$
\end{center}
and
\begin{center}
$\0 \xrightarrow{f^{-1}} A \xrightarrow{h} B$.
\end{center}
Since $\0$ is initial, we must have $g \circ f^{-1} = h \circ f^{-1}$.
Therefore, $g = g \circ 1_A = g \circ (f^{-1} \circ f) = (g \circ f^{-1})
\circ f = (h \circ f^{-1}) \circ f = h \circ (f^{-1} \circ f) = h \circ
1_A = h$. This proves uniqueness, and we are done.
\item Suppose $A \xrightarrow{f} \0$ is a monomorphism. We claim
the unique arrow $\0 \xrightarrow{\iota_A} A$ is the inverse of $f$. To
that end, we show $\iota_A$ is both a left and a right inverse of $f$.
Indeed, $f \circ \iota_A : \0 \to \0$, and since $\0$ is initial, we
must have $f \circ \iota_A = 1_{\0}$, which implies $\iota_A$ is a
right inverse of $f$. Now, note $\iota_A \circ f: A \to A$ and
$1_A: A \to A$. Also, $f \circ (\iota_A \circ f) = (f \circ \iota_A)
\circ f = 1_{\0} \circ f = f = f \circ 1_A$, and since $f$ is left
cancellative, we have $\iota_A \circ f = 1_A$, which shows $\iota_A$ is
a left inverse of $f$. Thus, $f$ has both a left inverse and a right
inverse, implying it is iso, and hence, using the result obtained in (1)
above, we conclude $A$ is an initial object in $\catname{C}$.
\end{enumerate}
\end{solution}
\subsection*{Products and Coproducts}
We can express a general notion of product that is meaningful in any category,
such that, if a product exists, it is characterized uniquely up to unique
isomorphism. Given a particular mathematical context (\emph{i.e.} a category),
we can then verify if a product exists in that category. The concrete
construction appropriate to the context will enter only into the proof of
\emph{existence}; all of the useful \emph{properties} of a product follow from
the general definition.
\setcounter{Exercise}{23}
\begin{Exercise}
Verify $\catname{Pair}(A, B)$ is a category, where $A$ and $B$ are arbitrary
objects in some category.
\end{Exercise}
\begin{solution}
Let $A$ and $B$ be some arbitrary objects in some category $\catname{C}$.
Now, given morphisms $f: (P, p_1, p_2) \to (Q, q_1, q_2)$ and $g: (Q, q_1,
q_2) \to (R, r_1, r_2)$ in $\catname{Pair}(A, B)$, it is easy to check that
$g \circ f: P \to R$ in $\catname{C}$. Also, we have
\begin{center}
$q_1 \circ f = p_1$, $q_2 \circ f = p_2$
\end{center}
and
\begin{center}
$r_1 \circ g = q_1$, $r_2 \circ g = q_2$
\end{center}
So, $r_1 \circ (g \circ f) = (r_1 \circ g) \circ f = q_1 \circ f = p_1$, and,
$r_2 \circ (g \circ f) = (r_2 \circ g) \circ f = q_2 \circ f = p_2$, which
implies $g \circ f: (P, p_1, p_2) \to (R, r_1, r_2)$ in $\catname{Pair}(A,B)$.
Associativity of morphisms in $\catname{Pair}(A, B)$ follows directly from
the associativity of morphisms in $\catname{C}$. Finally, for all
$(P, p_1, p_2)$ in $\catname{Pair}(A, B)$, the identity morphism $1_P: P \to
P$ is the identity morphism for $(P, p_1, p_2)$, since $p_1 \circ 1_P = p_1$
and $p_2 \circ 1_P = p_2$. And, this proves that $\catname{Pair}(A, B)$ is
indeed a category.
\end{solution}
We say $(A \times B, \pi_1, \pi_2)$ is a \emph{\textbf{product}} of $A$ and $B$
if it is \emph{terminal} in $\catname{Pair}(A, B)$. Products are specified by
triples $A \xleftarrow{\pi_1} A \times B \xrightarrow{\pi_2}$, where $pi_i$'s are
called \emph{projections}. For economy (and if projections are obvious), we say
$A \times B$ is the product of $A$ and $B$. We say a category $\catname{C}$ has
\emph{\textbf{(binary) products}} if each pair of objects $A, B$ has a product
in $\catname{C}$. Since, products are terminal objects, they are unique up to
(unique) isomorphism.
Unpacking the uniqueness condition from $\catname{Pair}(A, B)$ back to
$\catname{C}$, we obtain the following more concise definition of products that
we use in practice.\\
(\textbf{Equivalent definition of product}) Let $A, B$ be objects in a category
$\catname{C}$. A product of $A$ and $B$ is an object $A \times B$ together with
a pair of arrows $A \xleftarrow{\pi_1} A \times B \xrightarrow{\pi_2} B$ such
that for every triple $A \xleftarrow{f} C \xrightarrow{g} B$, there exists a
\emph{unique} morphism
\begin{center}
$\langle f, g \rangle : C \to A \times B$
\end{center}
such that the corresponding diagram commutes. That is,
\begin{center}
$\pi_1 \circ \langle f, g \rangle = f$\\
$\pi_2 \circ \langle f, g \rangle = g$
\end{center}
We call $\langle f, g \rangle$ the \emph{pairing} of $f$ and $g$.
\setcounter{Exercise}{25}
\begin{Exercise}
Verify the following claims.
\begin{enumerate}
\item In $\catname{Set}$, products are the usual cartesian products.
\item In $\catname{Pos}$, products are cartesian products with the
pointwise order.
\item In $\catname{Top}$, products are cartesian products with the
product topology.
\item In $\catname{Vect}_k$, products are direct sums.
\item In a poset, seen as a category, products are \emph{greatest lower
bounds}.
\end{enumerate}
\end{Exercise}
\begin{solution}
\leavevmode
\begin{enumerate}
\item Let $A, B$ be arbitrary sets in $\catname{Set}$. We claim
$A \times B$ equipped with the canonical projection functions is the
cross product of $A$ and $B$. Indeed, given any $A \xleftarrow{f} C
\xrightarrow{g} B$, we show $\langle f, g \rangle : C \to A \times B$,
defined by
\begin{center}
$c \mapsto (f(c), g(c))$,
\end{center}
is the unique function that makes the following diagram commute:
\[
\begin{tikzcd}
& C \arrow[ddl, swap, "f"]
\arrow[dd, dashrightarrow, "{\langle f, g \rangle}" description]
\arrow[ddr, "g"] & \\
& & \\
A & A \times B \arrow[l, swap, "\pi_1"] \arrow[r, "\pi_2"] & B
\end{tikzcd}
\]
(\emph{Existence}) It is easy to check that $\langle f, g \rangle$ is
indeed a function from $C$ to $A \times B$.\\
(\emph{Commutativity}) For all $c \in C$, $(\pi_1 \circ \langle f, g
\rangle)(c) = f(c)$ and $(\pi_2 \circ \langle f, g \rangle)(c) = g(c)$,
which imply the above diagram commutes.\\
(\emph{Uniqueness}) Suppose $h: C \to A \times B$ such that $\pi_1 \circ
h = f$ and $\pi_2 \circ h = g$. Then, for all $c \in C$, $(\pi_1 \circ
h)(c) = f(c)$ and $(\pi_2 \circ h)(c) = g(c)$, which imply $\pi_1(h(c)) =
f(c)$ and $\pi_2(h(c)) = g(c)$, which imply $h(c) = (f(c), g(c)) =
\langle f, g \rangle (c)$, thus proving $h = \langle f, g \rangle$, and
thereby, showing the uniqueness of $\langle f, g \rangle$.\\
Hence, $A \xleftarrow{\pi_1} A \times B \xrightarrow{\pi_2} B$ is the
cross product of $A$ and $B$.
\item Let $(P, \le)$ and $(Q, \le)$ be posets. Let $(P \times Q, \le)$ be
the cartesian product of $P$ and $Q$ with the pointwise order. That is,
for all $a, c \in P$ and $b, d \in Q$, $(a, b) \le (c, d)$ iff $a \le c$
and $b \le d$. We claim $(P \times Q, \le)$ equipped with the canonical
projection functions (which are monotone) is the cross product of $(P,
\le)$ and $(Q, \le)$. Given any $(P, \le) \xleftarrow{f} (R, \le)
\xrightarrow{g} (Q, \le)$, where $f, g$ are monotone functions, the
function $\langle f, g \rangle : (R, \le) \to (P \times Q, \le)$, defined
by
\begin{center}
$r \mapsto (f(r), g(r))$
\end{center}
is the unique monotone function that makes the following diagram commute:
\[
\begin{tikzcd}
& (R, \le) \arrow[ddl, swap, "f"]
\arrow[dd, dashrightarrow, "{\langle f, g \rangle}" description]
\arrow[ddr, "g"] & \\
& & \\
(P, \le) & (P \times Q, \le) \arrow[l, swap, "\pi_1"]
\arrow[r, "\pi_2"] & (Q, \le)
\end{tikzcd}
\]
(\emph{Existence}) It is easy to check that $\langle f, g \rangle$ is
indeed a set function from $R$ to $P \times Q$. And, for all $r_1, r_2
\in R$, if $r_1 \le r_2$, then $f(r_1) \le f(r_2)$ and $g(r_1) \le
g(r_2)$ (since $f, g$ are monotone), which implies $(f(r_1), g(r_1)) \le
(f(r_2), g(r_2))$, which implies $\langle f, g \rangle (r_1) \le
\langle f, g \rangle (r_2)$, which implies $\langle f, g \rangle$ is
monotone.\\
(\emph{Commutativity}) For all $r \in R$, we have
\begin{center}
$(\pi_1 \circ \langle f, g \rangle)(r) = f(r)$,\\
$(\pi_2 \circ \langle f, g \rangle)(r) = g(r).$
\end{center}
The above implies that the above diagram does commute.\\
(\emph{Uniqueness}) Suppose $h: (R, \le) \to (P \times Q, \le)$ is a
monotone function such that $\pi_1 \circ h = f$ and $\pi_2 \circ h = g$.
Then, for all $r \in R$, $\pi_1 \circ h (r)= f(r)$ and $\pi_2 \circ h
(r)= g(r)$, which imply $\pi_1(h(r)) = f(r)$ and $\pi_2(h(r)) = g(r)$,
which imply $h(r) = (f(r), g(r))$, which implies $h(r) = \langle f, g
\rangle (r)$, which implies $h = \langle f, g \rangle$, thus showing
that $\langle f, g \rangle$ with the commutativity property is indeed
unique.\\
Hence, we conclude the cartesian product $(P \times Q, \le)$ with the
pointwise order is the product of any posets $(P, \le)$ and $(Q, \le)$.
\item % TODO
\item % TODO
\item In a poset $(P, \le)$, seen as a category, the product $a \times b$
of two elements $a, b \in P$ is an element in $P$ satisfying $a \times b
\le a$ and $a \times b \le b$, such that for all elements $c \in P$, if
$c \le a$ and $c \le b$, then $c \le a \times b$. This is precisely the
definition of the \emph{greatest lower bound} of any two elements $a, b
\in P$, seen as a set. Therefore, products are greatest lower bounds in
posets.
\end{enumerate}
\end{solution}
The following proposition shows that the uniqueness of the pairing arrow can be
specified purely equationally by the equation:
\begin{center}
$\forall h: C \to A \times B.\, h = \langle \pi_1 \circ h, \pi_2 \circ h
\rangle$
\end{center}
\setcounter{prop}{26}
\begin{prop}
For any triple $A \xleftarrow{\pi_1} A \times B \xrightarrow{\pi_2} B$, the
following statements are equivalent:
\begin{itemize}
\item[(I)] For any triple $A \xleftarrow{f} C \xrightarrow{g} B$, there
exists a unique morphism $\langle f, g \rangle : C \to A \times B$ such
that $\pi_1 \circ \langle f, g \rangle = f$ and $\pi_2 \circ \langle f,
g \rangle = g$.
\item[(II)] For any triple $A \xleftarrow{f} C \xrightarrow{g} B$, there
exists a morphism $\langle f, g \rangle : C \to A \times B$ such that
$\pi_1 \circ \langle f, g \rangle = f$ and $\pi_2 \circ \langle f, g
\rangle = g$, and moreover, for any $h: C \to A \times B$, $h =
\langle \pi_1 \circ h, \pi_2 \circ h \rangle$.
\end{itemize}
\end{prop}
\begin{proof}
((I) $\implies$ (II)) Suppose (I) holds. Assume $A \xleftarrow{f} C
\xrightarrow{g} B$. Then, by (I), there exists a (unique) morphism $\langle
f, g \rangle : C \to A \times B$ such that $\pi_1 \circ \langle f, g \rangle
= f$ and $\pi_2 \circ \langle f, g \rangle = g$. Now, let $h: C \to A
\times B$. Note $A \xleftarrow{\pi_1 \circ h} C \xrightarrow{\pi_2 \circ h}
B$. Thus, by (I), there exists a unique morphism $\langle \pi_1 \circ h,
\pi_2 \circ h \rangle : C \to A \times B$ such that
\begin{center}
$\pi_1 \circ \langle \pi_1 \circ h, \pi_2 \circ h \rangle =
\pi_1 \circ h$,\\
$\pi_2 \circ \langle \pi_1 \circ h, \pi_2 \circ h \rangle =
\pi_2 \circ h$.
\end{center}
The above implies $h = \langle \pi_1 \circ h, \pi_2 \circ h \rangle$. This
proves (II).
((II) $\implies$ (I)) Suppose (II) holds. Assume $A \xleftarrow{f} C
\xrightarrow{g} B$. Then, by (II), there exists a morphism $\langle f, g
\rangle : C \to A \times B$ such that $\pi_1 \circ \langle f, g \rangle =
f$ and $\pi_2 \circ \langle f, g \rangle = g$. We claim such a morphism is
unique. So, suppose $h: C \to A \times B$ such that $\pi_1 \circ h = f$ and
$\pi_2 \circ h = g$. Then, by (II), we have $h = \langle \pi_1 \circ h,
\pi_2 \circ h \rangle$, which implies $h = \langle f, g \rangle$. This
proves (I), and our proof is complete.
\end{proof}
\textbf{Cartesian product of morphisms.} Given $f_1 : A_1 \to B_1$ and $f_2 :
A_2 \to B_2$, we define the \emph{cartesian product of morphisms} $f_1$ and
$f_2$ by
\begin{center}
$f_1 \times f_2 := \langle f_1 \circ \pi_1, f_2 \circ \pi_2 \rangle :
A_1 \times A_2 \to B_1 \times B_2$.
\end{center}
The following proposition provides some useful properties of products.
\begin{prop}
For any $f: A \to B$, $g: A \to C$, $h: A' \to A$, and any $p: B \to B'$,
$q: C \to C'$, the following hold:
\begin{enumerate}
\item $\langle f, g \rangle \circ h = \langle f \circ h, g \circ h
\rangle$
\item $(p \times q) \circ \langle f, g \rangle = \langle p \circ f,
q \circ g \rangle$.
\end{enumerate}
\end{prop}
\begin{proof}
\leavevmode
\begin{enumerate}
\item Note $\langle f, h \rangle \circ h : A' \to B \times C$.
Therefore, by (II) of Proposition 27, $\langle f, h \rangle \circ h =
\langle \pi_1 \circ (\langle f, g \rangle \circ h), \pi_2 \circ
(\langle f, g \rangle \circ h) \rangle = \langle f \circ h, f \circ g
\rangle$.
\item $(p \times q) \circ \langle f, g \rangle = \langle p \circ \pi_1,
q \circ \pi_2 \rangle \circ \langle f, g \rangle = \langle p \circ
\pi_1 \circ \langle f, g \rangle, q \circ \pi_2 \circ \langle f, g
\rangle = \langle p \circ f, q \circ g \rangle$.
\end{enumerate}
\end{proof}
\textbf{General Products.} The notion of products can be generalized to
arbitrary arities as follows. In a category $\catname{C}$, a product for a
family of objects $\{ A_i \}_{i \in I}$ is an object $P$ and morphisms
\begin{center}
$p_i: P \to A_i$ ($i \in I$)
\end{center}
such that, for all objects $B$ and arrows
\begin{center}
$f_i: B \to A_i$ ($i \in I$)
\end{center}
there is a \emph{unique} arrow $g: B \to P$ such that, for all $i \in I$, the
following diagram commutes
\[
\begin{tikzcd}
B \arrow[rr, dashrightarrow, "g"] \arrow[ddr, swap, "f_i"]
& & P \arrow[ddl, "p_i"] \\
& & \\
& A_i &
\end{tikzcd}
\]
Again, if such a product exists, it is unique up to (unique) isomorphism. We
write $P = \prod_{i \in I} A_i$ for the product object, and $g = \langle f_i
\mid i \in I \rangle$ for the unique morphism in the definition.
\setcounter{Exercise}{28}
\begin{Exercise}
What is the product of the empty family?
\end{Exercise}
\begin{solution}
The product of the empty family is an object $T$, such that for every object
with arrows to (non-existent) members of the empty family, there is a
unique arrow from that object to $T$ making the corresponding diagram
commute. Since there are no diagrams, this means there is a unique arrow
from every object to $T$, and this is precisely the definition of a
terminal object. Hence, the product of an empty family is a terminal object.
\end{solution}
\begin{Exercise}
Show that if a category has binary and nullary products, then it has all
finite products.
\end{Exercise}
\begin{solution}
Suppose $\catname{C}$ is a category with binary and nullary products. We
claim, for all $n \in \N$, $P_n = \prod_{i=1}^{n} A_i$ with the
corresponding projection functions $p_i: P \to A_i$, where $A_i$ is an
object in $\catname{C}$, exists. We use induction on $n$ to prove our
claim. (\emph{Base case}) For $n = 0$, $P$ is the nullary product, which
exists by assumption. (\emph{Inductive case}) Now, suppose a product
$P_n$ exists for some $n \ge 0$. Then, $P_{n+1} = \prod_{i=1}^{n+1} A_i =
\prod_{i=1}^{n} A_i \times A_{n+1} = P_n \times A_{i+1}$, which is a binary
product of objects, which exists due to the fact that $\catname{C}$ has
binary products and that $P_n$ exists (from our inductive hypothesis.)
Hence, by induction, $P_n$ exists for all $n \in \N$.
\end{solution}
~\\
\emph{\textbf{Coproducts}}. The dual notion to products are coproducts.
Formally, coproducts in a category $\catname{C}$ are just products in
$\catname{C}^{\mathbf{op}}$, interpreted back in $\catname{C}$.
Let $A, B$ be objects in a category $\catname{C}$. A \emph{coproduct} of $A$
and $B$ is an object $A + B$ together with a pair of arrows $A \xrightarrow{i_A}
A + B \xleftarrow{i_B} B$, such that for every triple $A \xrightarrow{f} C
\xleftarrow{g} B$, there exists a unique morphism
\begin{center}
$[f, g]: A + B \to C$
\end{center}
such that the following diagram commutes.
\[
\begin{tikzcd}
A \arrow[r, "i_A"] \arrow[ddr, swap, "f"] &
A + B \arrow[dd, dashed, "{[f, g]}" description] &
B \arrow[l, swap, "i_B"] \arrow[ddl, "g"] \\
& & \\
& C &
\end{tikzcd}
\]
We call $i_A$ and $i_B$ \emph{injections} and $[f, g]$ the \emph{copairing} of
$f$ and $g$. As with pairings, the uniqueness of copairings can be specified