-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat-set.tex
2914 lines (2253 loc) · 122 KB
/
cat-set.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
%% http://math.stackexchange.com/questions/359693/overview-of-basic-results-about-images-and-preimages
% \documentclass[11pt]{article}
% \title{The Category of Sets}
% \usepackage{array,multirow,amsthm,amsmath,amssymb,url,eucal}
% \usepackage{bussproofs}
% \usepackage{tikz-cd}
% \usepackage{natbib}
% \newtheorem{prop}{Proposition}[section]
% \newtheorem{lemma}[prop]{Lemma}
% \newtheorem{thm}[prop]{Theorem}
% \newtheorem{cor}[prop]{Corollary}
% \theoremstyle{definition}
% \newtheorem*{defn}{Definition}
% \newtheorem{axiom}{Axiom}
% \newtheorem{exercise}[prop]{Exercise}
% \newtheorem*{exercises}{Exercises}
% \newtheorem*{example}{Example}
% \newtheorem{facts}[prop]{Facts}
% \newtheorem{fact}[prop]{Fact}
% \theoremstyle{remark}
% \newtheorem*{disc}{Discussion}
% \newtheorem*{note}{Note}
% \usepackage{mathrsfs}
% % \usepackage{showlabels}
% \usepackage[framemethod=TikZ]{mdframed}
% \author{Hans Halvorson}
% \date{\today}
% \begin{document}
% \newcommand{\RA}{\vdash}
% \newcommand{\7}{\mathbb}
% \newcommand{\2}{\mathscr}
% \newcommand{\cl}{\overline}
% \renewcommand{\emph}{\textbf}
% \maketitle
%%% TO DO 10/16
%% -- reintroduce Boolean structure Omega
%% -- regular categories -- graph of function -> function AxE!y
%% -- pullback of subobjects (instead of equalizer), comprehension
%% -- Cartesian closed. X^0 = 1 ?
%%% TO DO on prop metatheory
%% -- show f conservative => f^* surjective
%% -- show f equivalence <=> f conservative & f eso
%% -- show f equivalence <=> CDE
%%% TO DO on Boolean algebras
%% -- example: finite-cofinite algebra
% TO DO:
% \begin{itemize}
% \item complement of a subobject
% \item Boolean operations on $\Omega$.
% \item $\mathrm{Sub}(1)\cong \Omega$
% \item $\Omega$ has four subobjects.
% \item right adjoint to pullback (universal quantifier)
% \item Show that $X\times 2\cong X\times (1+1)\cong X+X$.
% \item Lattice of subobjects
% \item union of subobjects
% \item Power sets. Boolean operations on power sets!
% \item Exponential objects
% \item distributive law: Show $(A_0\cup A_1)\cap B=(A_0\cap B)\cup (A_1\cap B)$.
% Relation to the fact that images exist?
% \item Sketch construction of rational numbers, real numbers
% \end{itemize}
%% TO DO: define union of subsets
%% TO DO: subsets form a (complete) Boolean algebra
\chapter{The Category of Sets} \label{cat-set}
\section{Introduction}
In the previous chapter we started to reason about theories (in
propositional logic) without explicitly saying anything about the
rules of reasoning that we would be permitted to use. Now we need to
talk more explicitly about the theory we will use to talk about
theories, i.e.\ our {\it metatheory}. We want our metatheory $M$ to
be able to describe theories, which we can take in the first instance
to be ``collections of sentences,'' or better, ``structured
collections of sentences.''\footnote{I don't mean to be begging the
question here about what a theory is. We could just as well think
of a theory as a structured collection of models. And just as
sentences can be broken down into smaller components until we reach
undefined primitives, so models can be broken down into smaller
components until we reach undefined primitives. In both cases,
metatheory bottoms out in undefined primitives. We can call these
primitives ``symbols,'' or ``sets,'' or anything else we want. But
the name we choose doesn't affect the inferences we're permitted to
draw.} What's more, sentences themselves are structured collections
of symbols. Fortunately, we won't need to press the inquiry further
into the question of the nature of symbols. It will suffice to assume
that there are enough symbols, and that there is some primitive notion
of identity of symbols. For example, I assume that you understand
that ``$p$'' is the same symbol as ``$p$'', and is different from
``$q$''.
Fortunately, there is a theory of collections of things lying close to
hand, namely ``the theory of sets.'' At the beginning of the 20th
century, much effort was given to clarifying the theory of sets, since
it was intended to serve as a foundation for all of mathematics.
Amazingly, the theory of sets can be formalized in first-order logic
with only one non-logical symbol, viz. a binary relation symbol
``$\in$''. In the resulting first-order theory --- usually called
Zermelo-Frankel set theory --- the quantifiers can be thought of as
ranging over sets, and the relation symbol $\in$ can be used to define
further notions such as subset, Cartesian products of sets, functions
from one set to another, etc..
Set theory can be presented informally (sometimes called ``naive set
theory''), or formally (``axiomatic set theory''). In both cases, the
relation $\in$ is primitive. However, we're going to approach things
from a different angle. We're not concerned as much with what sets
{\it are}, but with what we can {\it do} with them. Thus, I'll
present a version of ETCS, the elementary theory of the category of
sets.\footnote{All credit to William Lawvere for introducing this
approach to set theory. For a gentle introduction, see
\citep{lawvere-sets}.} Here ``elementary theory'' indicates that
this theory can be formalized in elementary (i.e.\ first-order) logic.
The phrase ``category of sets'' indicates that this theory treats the
collection of sets as a structured object --- a category consisting of
sets and functions between them.
\begin{axi}[Sets is a category]{ax:set-cat} $\cat{Sets}$ is a
\emph{category}, i.e.\ it consists of two kinds of things: objects,
which we call \textbf{sets}, and arrows, which we call
\textbf{functions}. To say that $\cat{Sets}$ is a category means
that:
\begin{enumerate}
\item Every function $f$ has a domain set $d_0f$ and a codomain set
$d_1f$. We write $f:X\to Y$ to indicate that $X=d_0f$ and $Y=d_1f$.
\item Compatible functions can be composed. For example, if $f:X\to
Y$ and $g:Y\to Z$ are functions, then $g\circ f:X\to Z$ is a
function. (We frequently abbreviate $g\circ f$ as $gf$.)
\item Composition of functions is associative:
\[ h\circ (g\circ f) \: = \: (h\circ g)\circ f \]
when all these compositions are defined.
\item For each set $X$, there is a function $1_X:X\to X$ that acts as
a left and right identity relative to composition.
\end{enumerate}
\label{ax:set-cat} \end{axi}
\begin{disc} If our goal was to formalize ETCS rigorously in
first-order logic, we might use two-sorted logic, with one sort for
sets, and one sort for functions. We will introduce the apparatus
of many-sorted logic in Chapter \ref{chap-second}. The primitive
vocabulary of this theory would include symbols $\circ ,d_0,d_1,1$,
but it would \textit{not} include the symbol $\in$. In other words,
containment is \textit{not} a primitive notion of ETCS. \end{disc}
Set theory makes frequent use of bracket notation, such as:
\[ \{ n\in N \mid n>17 \} .\] These symbols should be read as, ``the
set of $n$ in $N$ such that $n>17$.'' Similarly, $\{ x,y\}$ designates
a set consisting of elements $x$ and $y$. But so far, we have no
rules for reasoning about such sets. In the following sections, we
will gradually add axioms until it becomes clear which rules of
inference are permitted vis-a-vis sets.
Suppose for a moment that we understand the bracket notation, and
suppose that $X$ and $Y$ are sets. Then given an element $x\in X$,
and an element $y\in Y$, we can take the set $\{ x,\{ x,y\}\}$ as an
``ordered pair'' consisting of $x$ and $y$. The pair is ordered
because $x$ and $y$ play asymmetric roles: the element $x$ occurs by
itself, as well as with the element $y$. If we could then gather
together these ordered pairs into a single set, we would designate it
by $X\times Y$, which we call the \emph{Cartesian product} of $X$ and
$Y$. The Cartesian product construction should be familiar from high
school mathematics. For example, the plane (with $x$ and $y$
coordinates) is the Cartesian product of two copies of the real number
line.
In typical presentations of set theory, the existence of product sets
is derived from other axioms. Here we will proceed in the opposite
direction: we will take the notion of a product set as primitive.
\bigskip
\begin{axi}[Cartesian products]{ax:set-prod} For any two sets $X$ and
$Y$, there is a set $X\times Y$, and functions $\pi _0:X\times Y\to
X$ and $\pi _1:X\times Y\to Y$, such that: for any other set $Z$ and
functions $f:Z\to X$ and $g:Z\to Y$, there is a unique function
$\langle f,g\rangle :Z\to X\times Y$ such that $\pi _0\langle
f,g\rangle = f$ and $\pi _1\langle f,g\rangle =g$.
\label{ax:set-prod} \end{axi}
Here the angle brackets $\langle f,g\rangle$ are not intended to
indicate anything about the internal structure of the denoted
function. This notation is chosen merely to indicate that $\langle
f,g\rangle$ is uniquely determined by $f$ and $g$.
The defining conditions of a product set can be visualized by means of
an arrow diagram. \[ \begin{tikzcd}
& Z \arrow[ddl,bend right,"f"'] \arrow[ddr,bend left,"g"] \arrow[dashed,d,"{\langle f,g\rangle}"] \\
& X\times Y \arrow[dl,"\pi _0"] \arrow[dr,"\pi _1"'] \\
X & & Y
\end{tikzcd} \] Here each node represents a set, and arrows between
nodes represent functions. The dashed arrow is meant to indicate that
the axiom asserts the existence of such an arrow (dependent on the
existence of the other arrows in the diagram).
\begin{disc} There is a close analogy between the defining conditions
of a Cartesian product and the introduction and elimination rules
for conjunction. If $\phi\wedge\psi$ is a conjunction, then there
are arrows (i.e.\ derivations) $\phi\wedge\psi\to \phi$ and
$\phi\wedge\psi\to \psi$. That's the $\wedge$ elimination
rule.\footnote{Here I'm intentionally being ambiguous between the
relation $\vdash$ and the connective $\to$. The analogy is more
clear if we use the symbol $\to$ the latter.} Moreover, for any
sentence $\theta$, if there are derivations $\theta\to\phi$ and
$\theta\to\psi$, then there is a unique derivation
$\theta\to\phi\wedge \psi$. That's the $\wedge$ introduction rule.
\end{disc}
\begin{defn} Let $\gamma$ and $\gamma '$ be paths of arrows in a
diagram that begin and end at the same node. We say that $\gamma$
and $\gamma '$ \emph{commute} just in case the composition of the
functions along $\gamma$ is equal to the composition of the
functions along $\gamma '$. We say that the diagram as a whole
\emph{commutes} just in case any two paths between nodes are equal.
Thus, for example, the product diagram above commutes. \end{defn}
The functions $\pi _0:X\times Y\to X$ and $\pi _1:X\times Y\to Y$ are
typically called \emph{projections} of the product. What features do
these projections have? Before we say more on that score, let's pause
to talk about features of functions.
You may have heard before of some properties of functions such as
being one-to-one, or onto, or continuous, etc.. For bare sets, there
is no notion of continuity of functions, per se. And, with only the
first two axioms in place, we do not yet have the means to define what
it means for a function to be one-to-one or onto. Indeed, recall that
a function $f:X\to Y$ is typically said to be one-to-one just in case
$f(x)=f(y)$ implies $x=y$ for any two ``points'' $x$ and $y$ of $X$.
But we don't yet have a notion of points!
Nonetheless, there are point-free surrogates for the notions of being
one-to-one and onto.
\begin{defn} A function $f:X\to Y$ is said to be a \emph{monomorphism}
just in case for any two functions $g,h:Z\rightrightarrows X$, if
$fg=fh$ then $g=h$. \end{defn}
\begin{defn} A function $f:X\to Y$ is said to be a \emph{epimorphism}
just in case for any two functions $g,h:Y\to Z$, if $gf=hf$ then
$g=h$. \end{defn}
We will frequently say, ``\dots is monic'' as shorthand for ``\dots is
a monomorphism,'' and ``\dots is epi'' for ``\dots is an
epimorphism.''
\begin{defn} A function $f:X\to Y$ is said to be an \emph{isomorphism}
just in case there is a function $g:Y\to X$ such that $gf=1_X$ and
$fg=1_Y$. If there is an isomorphism $f:X\to Y$, we say that $X$
and $Y$ are \emph{isomorphic}, and we write $X\cong Y$. \end{defn}
\begin{exercise} \label{comps} Show the following:
\begin{enumerate}
\item If $gf$ is monic, then $f$ is monic.
\item If $fg$ is epi, then $f$ is epi.
\item If $f$ and $g$ are monic, then $gf$ is monic.
\item If $f$ and $g$ are epi, then $gf$ is epi.
\item If $f$ is an isomorphism, then $f$ is epi and
monic. \end{enumerate} \end{exercise}
\begin{prop} Suppose that both $(W,\pi _0,\pi _1)$ and
$(W',\pi '_0,\pi '_1)$ are Cartesian products of $X$ and $Y$. Then
there is an isomorphism $f:W\to W'$ such that $\pi '_0f=\pi _0$ and
$\pi '_1f=\pi _1$. \end{prop}
\begin{proof} Since $(W',\pi '_0,\pi '_1)$ is a Cartesian product of
$X$ and $Y$, there is a unique function $f:W\to W'$ such that
$\pi '_0f= \pi _0$ and $\pi '_1f= \pi _1$. Since
$(W,\pi _0,\pi _1)$ is also a product of $X$ and $Y$, there is a
unique function $g:W'\to W$ such that $\pi _0g=\pi '_0$ and
$\pi _1g=\pi '_1$. We claim that $f$ and $g$ are inverse to each
other. Indeed,
\[ \pi '_i\circ (f\circ g) \: = \: \pi _i\circ g \: = \: \pi '_i ,\]
for $i=0,1$. Thus, by the uniqueness clause in the definition of
Cartesian products, $f\circ g=1_{W'}$. A similar argument shows
that $g\circ f=1_W$. \end{proof}
%% TO DO: define f\times g
%% TO DO: define diagonal
\newcommand{\dl}{\delta}
\begin{defn} If $X$ is a set, we let $\dl :X\to X\times X$ denote the
unique arrow $\langle 1_X,1_X\rangle$ given by the definition of
$X\times X$. We call $\dl$ the \emph{diagonal} of $X$, or the
\emph{equality relation} on $X$. Note that $\dl$ is monic, since
$\pi _0\dl =1_X$ is monic. \end{defn}
\begin{defn} Suppose that $f:W\to Y$ and $g:X\to Z$ are functions.
Consider the following diagram:
\[ \begin{tikzcd}
W \arrow[d,"f"'] & W\times X \arrow[l,"q_0"] \arrow[r,"q_1"']
\arrow[dashed,d,"f\times g"] & X
\arrow[d,"g"] \\
Y & Y\times Z \arrow[l,"\pi _0"] \arrow[r,"\pi _1"'] & Z
\end{tikzcd} \]
We let $f\times g=\langle fq_0,gq_1\rangle$ be the unique
function from $W\times X$ to $Y\times Z$ such that
\[ \pi _0(f\times g) = fq_0,\qquad \pi _1(f\times g)=gq_1 .\] Recall
here that, by the definition of products, a function into $Y\times Z$
is uniquely defined by its compositions with the projections $\pi _0$
and $\pi _1$.
\label{unravel} \end{defn}
\begin{prop} Suppose that $f:A\to B$ and $g:B\to C$ are functions.
Then $1_X\times (g\circ f)=(1_X\times g)\circ (1_X\times
f)$. \end{prop}
\begin{proof} Consider the following diagram
\[ \begin{tikzcd}
X \arrow[d,"1_X"'] & X\times A \arrow[l] \arrow[r] \arrow[d,"1_X\times f"]
& A \arrow[d,"f"] \\
X \arrow[d,"1_X"'] & X\times B \arrow[l] \arrow[r] \arrow[d,"1_X\times g"]
& B \arrow[d,"g"] \\
X & X\times C \arrow[l] \arrow[r] & C
\end{tikzcd} \] where $1_X\times f$ and $1_X\times g$ are constructed
as in Defn \ref{unravel}. Since the top and bottom squares both
commute, the entire diagram commutes. But then the composite arrow
$(1_X\times g)\circ (1_X\times f)$ satisfies the defining properties
of $1_X\times (g\circ f)$. \end{proof}
\begin{exercise} Show that $1_X\times 1_Y=1_{X\times
Y}$. \end{exercise}
\begin{defn} Let $X$ be a fixed set. Then $X$ induces two mappings,
as follows:
\begin{enumerate}
\item A mapping $Y\mapsto X\times Y$ of sets to sets.
\item A mapping $f\mapsto 1_X\times f$ of functions to functions.
That is, if $f:Y\to Z$ is a function, then $1_X\times f:X\times Y\to
X\times Z$ is a function. \end{enumerate} By the previous results,
the second mapping is compatible with the composition structure on
arrows. In this case, we call the pair of mappings a \emph{functor}
from $\cat{Sets}$ to $\cat{Sets}$. \end{defn}
\begin{exercise} Suppose that $f:X\to Y$ is a function. Show that the
following diagram commutes.
\[ \begin{tikzcd}
X \arrow[r,"f"] \arrow[d,"\dl _X"'] & Y \arrow[d,"\dl _Y"] \\
X\times X \arrow[r,"f\times f"'] & Y\times
Y \end{tikzcd} \] \end{exercise}
We will now recover the idea that sets consist of points by requiring
the existence of a single-point set $1$, which plays the privileged
role of determining identity of functions.
\begin{axi}[Terminal Object]{ax:terminal} There is a set $1$
with the following two features:
\begin{enumerate}
\item For any set $X$, there is a unique function
\[ \begin{tikzcd} X \arrow[r,"\beta _X"] & 1 \end{tikzcd} \] In this
case, we say that $1$ is a \emph{terminal object} for $\cat{Sets}$.
\item For any sets $X$ and $Y$, and functions $f,g:X\rightrightarrows
Y$, if $f\circ x=g\circ x$ for all functions $x:1\to X$, then $f=g$.
In this case, we say that $1$ is a \emph{separator} for
$\cat{Sets}$. \end{enumerate} \label{ax:terminal} \end{axi}
%%
%% introduce elements
%%
The reader may wish to note that for a general category, a
\emph{terminal object} is required only to have the first of the two
properties above. So, we are not merely requiring that $\cat{Sets}$
has a terminal object; we are requiring that it has a terminal object
that also serves as a separator for functions.
\begin{exercise} Show that if $X$ and $Y$ are terminal objects in a
category, then $X\cong Y$. \end{exercise}
\begin{defn} We write $x\in X$ to indicate that $x:1\to X$ is a
function, and we say that $x$ is an \emph{element} of $X$. We say
that $X$ is \emph{non-empty} just in case it has at least one
element. If $f:X\to Y$ is a function, we sometimes write $f(x)$ for
$f\circ x$. With this notation, the statement that $1$ is a
separator says: $f=g$ if and only if $f(x)=g(x)$, for all $x\in X$.
\end{defn}
\begin{disc} In ZF set theory, equality between functions is
completely determined by equality between sets. Indeed, in ZF,
functions $f,g:X\rightrightarrows Y$ are defined to be certain
subsets of $X\times Y$; and subsets of $X\times Y$ are defined to be
equal just in case they contain the same elements. In the ETCS
approach to set theory, equality between functions is primitive, and
Axiom \ref{ax:terminal} stipulates that this equality can be
detected by checking elements.
Some might see this difference as arguing in favor of ZF: it is more
parsimonious, because it derives $f=g$ from something more
fundamental. However, the defender of ETCS might claim in reply
that her theory defines $x\in y$ from something more fundamental.
Which is {\it really} more fundamental, equality between arrows
(functions), or containment of objects (sets)? We'll leave that for
other philosophers to think about. \end{disc}
\begin{exercise} Show that any function $x:1\to X$ is
monic. \end{exercise}
\begin{prop} A set $X$ has exactly one element if and only if $X\cong
1$. \end{prop}
\begin{proof} The terminal object $1$ has exactly one element, since
there is a unique function $1\to 1$.
Suppose now that $X$ has exactly one element $x:1\to X$. We will
show that $X$ is a terminal object. First, for any set $Y$, there
is a function $x\circ \beta _Y$ from $Y$ to $X$. Now suppose that
$f,g$ are functions from $Y$ to $X$ such that $f\neq g$. By Axiom
\ref{ax:terminal}, there is an element $y\in Y$ such that $fy\neq
gy$. But then $X$ has more than one element, a contradiction.
Therefore, there is a unique function from $Y$ to $X$, and $X$ is a
terminal object. \end{proof}
\begin{prop} In any category with a terminal object $1$, any object
$X$ is itself a Cartesian product of $X$ and $1$. \end{prop}
\begin{proof} We have the obvious projections $\pi _0=1_X:X\to X$ and
$\pi _1=\beta _X:X\to 1$. Now let $Y$ be an object, and let
$f:Y\to X$ and $g:Y\to 1$ be arrows. We claim that $f:Y\to X$ is
the unique arrow such that $1_Xf=f$ and $\beta _Xf=g$. To see that
$f$ satisfies this condition, note that $g:Y\to 1$ must be
$\beta _Y$, the unique arrow from $Y$ to the terminal object. If
$h$ is another arrow that satisfies this condition, then
$h=1_Xh=f$. \end{proof}
\begin{prop} Let $a$ and $b$ be elements of $X\times Y$. Then $a=b$
if and only if $\pi _0(a)=\pi _0(b)$ and $\pi _1(a)=\pi
_1(b)$. \end{prop}
\begin{proof} Suppose that $\pi _0(a)=\pi _0(b)$ and $\pi _1(a)=\pi
_1(b)$. By the uniqueness property of the product, there is a
unique function $c:1\to X\times Y$ such that $\pi _0(c)=\pi _0(a)$
and $\pi _1(c)=\pi _1(a)$. Since $a$ and $b$ both satisfy this
property, $a=b$.
\end{proof}
\begin{note} The previous proposition justifies the use of the
notation
\[ X\times Y \: = \: \{ \langle x,y\rangle \mid x\in X,y\in Y \} .\]
Here the identity condition for ordered pairs is given by
\[ \langle x,y\rangle = \langle x',y'\rangle \qquad \text{iff}
\qquad x=x'\;\text{and}\; y=y' .\] \end{note}
\begin{prop} Let $(X\times Y,\pi _0,\pi _1)$ be the Cartesian product
of $X$ and $Y$. If $Y$ is non-empty, then $\pi _0$ is an
epimorphism. \label{proj-epi} \end{prop}
\begin{proof} Suppose that $Y$ is non-empty, and that $y:1\to Y$ is an
element. Let $\beta _X:X\to 1$ be the unique map, and let $f=y\circ
\beta _X$. Then $\langle 1_X,f\rangle :X\to X\times Y$ such that
$\pi _0\langle 1_X,f\rangle =1_X$. Since $1_X$ is epi, $\pi _0$ is
epi. \end{proof}
\begin{defn} We say that $f:X\to Y$ is \emph{injective} just in case:
for any $x,y\in X$ if $f(x)=f(y)$, then $x=y$. Written more
formally:
\[ \forall x\forall y[f(x)=f(y)\to x=y ] \] \end{defn}
\begin{note} ``Injective'' is synonymous with
``one-to-one''. \end{note}
\begin{exercise} Let $f:X\to Y$ be a function. Show that if $f$ is
monic, then $f$ is injective. \end{exercise}
\begin{prop} Let $f:X\to Y$ be a function. If $f$ is injective then
$f$ is monic. \label{inj-mon} \end{prop}
\begin{proof} Suppose that $f$ is injective, and let $g,h:A\to X$ be
functions such that $f\circ g=f\circ h$. Then for any $a\in A$, we
have $f(g(a))=f(h(a))$. Since $f$ is injective, $g(a)=h(a)$. Since
$a$ was an arbitrary element of $A$, Axiom \ref{ax:terminal} entails
that $g=h$. Therefore, $f$ is monic. \end{proof}
\begin{defn} Let $f:X\to Y$ be a function. We say that $f$ is
\emph{surjective} just in case: for each $y\in Y$, there is an $x\in
X$ such that $f(x)=y$. Written formally:
\[ \forall y\exists x[f(x)=y] \]
And in diagrammatic form:
\[ \begin{tikzcd}
& 1 \arrow[dashed,dl,"x"'] \arrow[dr,"y"] \\
X \arrow[rr,"f"] & & Y \end{tikzcd} \]
\end{defn}
\begin{note} ``Surjective'' is synonymous with ``onto''. \end{note}
\begin{exercise} Show that if $f:X\to Y$ is surjective then $f$ is an
epimorphism. \end{exercise}
We will eventually establish that all epimorphisms are surjective.
However, first we need a couple more axioms. Given a set $X$, and
some definable condition $\phi$ on $X$, we would like to be able to
construct a subset consisting of those elements in $X$ that satisfy
$\phi$. The usual notation here is $\{ x\in X\mid \phi (x) \}$, which
we read as, ``the $x$ in $X$ such that $\phi (x)$.'' But the
important question is: which features $\phi$ do we allow? As an
example of a definable condition $\phi$, consider the condition of,
``having the same value under the functions $f$ and $g$,'' that is,
$\phi (x)$ just in case $f(x)=g(x)$. We call the subset $\{ x\in
X\mid f(x)=g(x) \}$ the \emph{equalizer} of $f$ and $g$.
\begin{axi}[Equalizers]{ax:set-eq} Suppose that
$f,g:X\rightrightarrows Y$ are functions. Then there is a set $E$
and a function $m:E\to X$ with the following property: $fm=gm$, and
for any other set $F$ and function $h:F\to X$, if $fh=gh$, then
there is a unique function $k:F\to E$ such that $mk=h$.
\[ \begin{tikzcd}
E \arrow[r,"m"] & X \arrow[shift left,r,"f"] \arrow[shift right,r,"g"']
& Y \\
F \arrow[dashed,u,"k"] \arrow[ur,"h"']
\end{tikzcd} \] We call $(E,m)$ an \emph{equalizer} of $f$ and $g$.
If we don't need to mention the object $E$, we will call the arrow $m$
the equalizer of $f$ and $g$. \label{ax:set-eq} \end{axi}
\begin{exercise} Suppose that $(E,m)$ and $(E',m')$ are both
equalizers of $f$ and $g$. Show that there is an isomorphism
$k:E\to E'$. \end{exercise}
\begin{defn} Let $A,B,C$ be sets, and let $f:A\to C$ and $g:B\to C$ be
functions. We say that $g$ \emph{factors through} $f$ just in case
there is a function $h:B\to A$ such that $fh=g$. \end{defn}
\begin{exercise} Let $f,g:X\rightrightarrows Y$, and let $m:E\to X$ be
the equalizer of $f$ and $g$. Let $x\in X$. Show that $x$ factors
through $m$ if and only if $f(x)=g(x)$. \end{exercise}
\begin{prop} In any category, if $(E,m)$ is the equalizer of $f$ and
$g$. Then $m$ is a monomorphism. \end{prop}
\begin{proof} Let $x,y:Z\to E$ such that $mx=my$. Since $fmx=gmx$,
there is a unique arrow $z:Z\to E$ such that $mz=mx$. Since both
$mx=mx$ and $my=mx$, it follows that $x=y$. Therefore, $m$ is
monic. \end{proof}
\begin{defn} Let $f:X\to Y$ be a function. We say that $f$ is a
\emph{regular monomorphism} just in case $f$ is the equalizer (up to
isomorphism) of a pair of arrows $g,h:Y\rightrightarrows
Z$. \end{defn}
\begin{exercise} Show that if $f$ is an epimorphism and a regular
monomorphism, then $f$ is an
isomorphism. \label{herman} \end{exercise}
%% Can now construct pullbacks and preimages
In other approaches to set theory, one uses $\in$ to define a relation
of inclusion between sets:
\[ X\subseteq Y \: \Longleftrightarrow \: \forall x(x\in X\to x\in Y )
.\] We cannot define this exact notion in our approach since, for us,
elements are attached to some particular set. However, for typical
applications, every set under consideration will come equipped with a
canonical monomorphism $m:X\to U$, where $U$ is some fixed set. Thus,
it will suffice to consider a relativized notion.
\begin{defn} A \emph{subobject} or \emph{subset} of a set $X$ is a set
$B$ and a monomorphism $m:B\to X$, called the \emph{inclusion} of
$B$ in $X$. Given two subsets $m:B\to X$ and $n:A\to X$, we say
that $B$ is a subset of $A$ (relative to $X$), written $B\subseteq
_X A$ just in case there is a function $k:B\to A$ such that $nk=m$.
When no confusion can result, we omit $X$ and write $B\subseteq
A$. \end{defn}
Let $m:B\to Y$ be monic, and let $f:X\to Y$. Consider the following
diagram:
\[ \begin{tikzcd} f^{-1}(B) \arrow{r}{k} & X\times B \arrow[shift
left=0.5ex]{r}[above]{fp _0} \arrow[shift
right=0.5ex]{r}[below]{mp _1} & Y \end{tikzcd} \] where
$f^{-1}(B)$ is defined as the equalizer of $f\pi _0$ and $mp_1$.
Intuitively, we have
\[ \begin{array}{l l l}
f^{-1}(B) & = & \{ \langle x,y\rangle \in X\times B\mid f(x)=y \} \\
& = & \{ \langle x,y\rangle \in X\times Y \mid f(x)=y \; \text{and} \; y\in B \} \\
& = & \{ x\in X \mid f(x)\in B \} .\end{array} \]
Now we verify that $f^{-1}(B)$ is a subset of $X$.
\begin{prop} The function $p_0k:f^{-1}(B)\to X$ is monic. \end{prop}
\begin{proof} To simplify notation, let $E=f^{-1}(B)$. Let $x,y:Z\to
E$ such that $p_0kx=p_0ky$. Then $fp_0kx=fp_0ky$, and hence
$mp_1kx=mp_1ky$. Since $m$ is monic, $p_1kx=p_1ky$. Thus, $kx=ky$.
(The identity of a function into $X\times B$ is determined by the
identity of its projections onto $X$ and $B$.) Since $k$ is monic,
$x=y$. Therefore, $p_0k$ is monic.
\end{proof}
\begin{defn} Let $m:B\to X$ be a subobject, and let $x:1\to X$. We
say that $x\in B$ just in case $x$ factors through $m$ as follows:
\[ \begin{tikzcd}
& B \arrow{d}{m} \\
1 \arrow{r}{x} \arrow[dashed]{ur} &
X \end{tikzcd} \] \end{defn}
\begin{prop} Let $A\subseteq B\subseteq X$. If $x\in A$ then $x\in
B$. \end{prop}
\begin{proof}
\[ \begin{tikzcd}
& A \arrow{d} \arrow{r}{k} & B \arrow{d} \\
1 \arrow[r,"x"'] \arrow[dashed] {ur} & X \arrow[r,"1_X"'] & X \end{tikzcd} \]
\end{proof}
Recall that $x\in f^{-1}(B)$ means: $x:1\to X$ factors
through the inclusion of $f^{-1}(B)$ in $X$. Consider the following
diagram:
\[ \begin{tikzcd}
1 \arrow{ddr}[left]{x} \arrow[dashed]{dr} \\
& f^{-1}(B) \arrow{r}{p} \arrow{d}{m^*} & B \arrow{d}[right]{m} \\
& X \arrow{r}[below]{f} & Y \end{tikzcd} \] First look just at the
lower-right square. This square commutes, in the sense that following
the arrows from $f^{-1}(B)$ clockwise gives the same answer as
following the arrows from $f^{-1}(B)$ counterclockwise. The square
has another property: for any set $Z$, and functions $g:Z\to X$ and
$h:Z\to B$, there is a unique function $k:Z\to f^{-1}(B)$ such that
$m^{*}k=g$ and $pk=h$. [To understand better, draw a picture!] When
a commuting square has this property, then it's said to be a
\emph{pullback}.
\begin{prop} Let $f:X\to Y$, and let $B\subseteq Y$. Then $x\in
f^{-1}(B)$ if and only if $f(x)\in B$. \end{prop}
\begin{proof} If $x\in f^{-1}(B)$, then there is an arrow
$\hat{x}:1\to f^{-1}(B)$ such that $m^*\hat{x}=x$. Thus,
$fx=mp\hat{x}$, which entails that the element $f(x)\in Y$ factors
through $B$, i.e.\ $f(x)\in B$. Conversely, if $f(x)\in B$, then
since the square is a pullback, $x:1\to X$ factors through
$f^{-1}(B)$, i.e.\ $x\in f^{-1}(B)$. \end{proof}
\begin{defn} Given functions $f:X\to Z$ and $g:Y\to Z$, we define
\[ X\times _ZY \: = \: \{ \langle x,y\rangle \in X\times Y \mid
f(x)=g(y) \} .\] In other words, $X\times _ZY$ is the equalizer of
$f\pi _0$ and $g\pi _1$. The set $X\times _ZY$, together with the
functions $\pi _0:X\times _ZY\to X$ and $\pi _1:X\times _ZY\to Y$ is
called the \emph{pullback} of $f$ and $g$, alternatively the
\emph{fibered product} of $f$ and $g$. \end{defn}
The pullback of $f$ and $g$ has the following distinguishing property:
for any set $A$, and functions $h:A\to X$ and $k:A\to Y$ such that
$fh=gk$, there is a unique function $j:A\to X\times _ZY$ such that
$\pi _0j=h$ and $\pi _1j=k$.
\[ \begin{tikzcd}
A \arrow[ddr,"h"'] \arrow[drr,"k"] \arrow[dr,dashed] \\
& X\times _ZY \arrow[d,"\pi _0"] \arrow[r,"\pi _1"'] & Y
\arrow[d,"g"]
\\
& X \arrow[r,"f"'] & Z \end{tikzcd} \] The following is an
interesting special case of a pullback.
\begin{defn} Let $f:X\to Y$ be a function. Then the \emph{kernel
pair} of $f$ is the pullback $X\times _YX$, with projections
$p_0:X\times _YX\to X$ and $p_1:X\times _YX\to X$. Intuitively,
$X\times _YX$ is the relation, ``having the same image under $f$.''
Written in terms of braces,
\[ X\times _YX \: = \: \{ \langle x,x'\rangle \in X\times X \mid
f(x)=f(x') \} .\] In particular, $f$ is injective if and only if,
``having the same image under $f$'' is coextensive with the equality
relation on $X$. That is, $X\times _YX=\{ \langle x,x\rangle \mid
x\in X \}$, which is the diagonal of $X$. \end{defn}
\begin{exercise} Let $f:X\to Y$ be a function, and let
$p_0,p_1:X\times _YX\rightrightarrows X$ be the kernel pair of $f$.
Show that the following are equivalent:
\begin{enumerate}
\item $f$ is a monomorphism.
\item $p_0$ and $p_1$ are isomorphisms.
\item $p_0=p_1$. \end{enumerate} \label{kkp} \end{exercise}
\section{Truth values and subsets}
\newcommand{\true}{\mathsf{t}} \newcommand{\false}{\mathsf{f}}
\newcommand{\tr}{\mathsf{t}} \newcommand{\f}{\mathsf{f}}
\begin{axi}[Truth-value object]{ax:classify} There is a set $\Omega$
with the following features:
\begin{enumerate}
\item $\Omega$ has exactly two elements, which we denote by $\true
:1\to \Omega$ and $\false :1\to \Omega$.
\item For any set $X$, and subobject $m:B\to X$, there is a unique
function $\ch{B}:X\to \Omega$ such that the following diagram is a
pullback:
\[ \begin{tikzcd}
B \arrow[d, "m"'] \arrow{r} & 1 \arrow{d}{\true} \\
X \arrow[r, "\ch{B}"'] & \Omega \end{tikzcd} \] In other words,
$B=\{ x\in X\mid \ch{B}(x)=\tr \}$.
\end{enumerate} \label{ax:classify}
\end{axi}
Intuitively speaking, the first part of Axiom \ref{ax:classify} says
that $\Omega$ is a two-element set, say $\Omega = \{ \f,\tr\}$. The
second part of Axiom \ref{ax:classify} says that $\Omega$ classifies
the subobjects of a set $X$. That is, each subobject $m:B\to X$
corresponds to a unique \emph{characteristic function} $\ch{B}:X\to
\{\f,\tr\}$ such that $\ch{B}(x)=\tr$ if and only if $x\in B$.
The terminal object $1$ is a set with one element. Thus, it should be
the case that $1$ has two subsets, the empty set and $1$ itself.
\begin{prop} The terminal object $1$ has exactly two
subobjects. \label{sub-one} \end{prop}
\begin{proof} By Axiom \ref{ax:classify}, subobjects of $1$ correspond
to functions $1\to\Omega$, that is, to elements of $\Omega$. By
Axiom \ref{ax:classify}, $\Omega$ has exactly two elements.
Therefore, $1$ has exactly two subobjects. \end{proof}
Obviously the function $\tr:1\to\Omega$ corresponds to the subobject
$\mathrm{id}_1:1\to 1$. Can we say more about the subobject $m:A\to1$
corresponding to the function $\f:1\to \Omega$? Intuitively, we
should have $A=\{ x\in 1\mid \tr = \f\}$, in other words, the empty
set. To confirm this intuition, consider the pullback diagram:
\[ \begin{tikzcd}
1 \arrow[dashed,dr,"x"] \\
& A \arrow[d,"m"'] \arrow[r,"k"] & 1 \arrow[d,"\tr"] \\
& 1 \arrow[r,"\f"'] & \Omega
\end{tikzcd} \] Note that $m$ and $k$ must both be the unique function
from $A$ to $1$, that is $m=k=\beta _A$. Suppose that $A$ is
nonempty, i.e.\ there is a function $x:1\to A$. Then $\beta _A\circ
x$ is the identity $1\to 1$, and since the square commutes, $\tr =\f$,
a contradiction. Therefore, $A$ has no elements.
% Conversely, suppose that $A$ is a set with no elements. Then in the
% diagram above we can take $m=k=\beta _A$, and since $A$ has no
% elements, the diagram trivially commutes. We claim that it is a
% pullback. Indeed, for an arbitrary set $X$, there is only one
% function $\beta _X:X\to 1$. But $\tr\circ \beta _X\neq \f\circ\beta
% _X$. Thus, the conditions for a pullback a trivially satisifed. By
% the uniqueness of pullbacks, it follows that there is a unique object
% in $\cat{Sets}$ that has no elements.
\begin{exercise} Show that $\Omega\times\Omega$ has exactly four
elements. \end{exercise}
% Axiom \ref{ax:terminal} tells us that functions are individuated by
% their values on elements. The next proposition tells us that
% subobjects of a set $X$ are also individuated by their elements.
% \begin{prop} Let $m:A\to X$ and $n:B\to X$ be subobjects of $X$. Then
% the following are equivalent:
% \begin{enumerate}
% \item $A$ and $B$ are the same subobject; i.e. there is an isomorphism
% $k:A\to B$ such that $nk=m$.
% \item For all $x\in X$, $x\in A$ if and only if $x\in B$.
% \item $\ch{A}=\ch{B}$. \end{enumerate} \end{prop}
% \begin{proof} ($1\Rightarrow 2$) Let $k:A\to B$ be an isomorphism such
% that $m=nk$. Then $x:1\to X$ factors through $A$ if and only if it
% factors through $B$.
% ($2\Rightarrow 3$) Suppose that $x:1\to X$ factors through $A$ if
% and only if it factors through $B$. We claim that
% $\ch{A}(x)=\ch{B}(x)$. Indeed, $\ch{A}(x)=t$ iff $x$ factors
% through $A$, iff $x$ factors through $B$, iff $\ch{B}(x)=t$.
% ($3\Rightarrow 1$) This is just a restatement of Axiom
% \ref{ax:classify}, which says that subobjects are in one-to-one
% correspondence with characteristic functions.
% \end{proof}
We now use the existence of a truth-value object in $\cat{Sets}$ to
demonstrate further properties of functions.
\begin{exercise} Show that in any category, if $f:X\to Y$ is a regular
monomorphism, then $f$ is monic. \end{exercise}
\begin{prop} Every monomorphism between sets is regular, i.e.\ an
equalizer of a pair of parallel
arrows. \label{set-regular-monic} \end{prop}
\begin{proof} Let $m:B\to X$ be monic. By Axiom \ref{ax:classify},
the following is a pullback diagram:
\[ \begin{tikzcd}
B \arrow[d,"m"'] \arrow{r} & 1 \arrow{d}{t} \\
X \arrow[r,"\ch{B}"'] & \Omega \end{tikzcd} \] A straightforward
verification shows that $m$ is the equalizer of $X\stackrel{\beta
_X}{\to} 1\stackrel{\tr}{\to}\Omega$ and $\ch{B}:X\to\Omega$.
Therefore, $m$ is regular monic.
\end{proof}
Students with some background in mathematics might assume that if a
function $f:X\to Y$ is both a monomorphism and an epimorphism, then it
is an isomorphism. However, that isn't true in all categories! [For
example, it's not true in the category of monoids.] Nonetheless,
$\cat{Sets}$ is a special category, and in this case we have the
result:
\begin{prop} In $\cat{Sets}$, if a function is both a monomorphism and
an epimorphism, then it is an
isomorphism. \label{sets:balanced} \end{prop}
\begin{proof} In any category, if $m$ is regular monic and epi, then
$m$ is an isomorphism (Exercise \ref{herman}). \end{proof}
\begin{defn} Let $f:X\to Y$ be a function, and let $y\in Y$. The
\emph{fiber} over $y$ is the subset $f^{-1}\{ y\}$ of $X$ given by
the following pullback:
\[ \begin{tikzcd} f^{-1}\{ y\} \arrow[d] \arrow[r] & 1 \arrow[d,"y"] \\
X \arrow[r,"f"] & Y \end{tikzcd} \] \end{defn}
\begin{prop} Let $p:X\to Y$. If $p$ is not a surjection, then there
is a $y_0\in Y$ such that the fiber $p^{-1}\{ y_0\}$ is
empty. \label{empty-fiber} \end{prop}
\begin{proof} Since $p$ is not a surjection, there is a $y_0\in Y$
such that for all $x\in X$, $p(x)\neq y_0$. Now consider the
pullback:
\[ \begin{tikzcd}
1 \arrow[dashed]{rd}{z} \\
& {p^{-1}\{ y_0 \}} \arrow{d}{m} \arrow{r} & 1 \arrow{d}{y_0} \\
& X \arrow{r}{p} & Y
\end{tikzcd} \] If there were a morphism $z:1\to p^{-1}\{ y_0\}$, then
we would have $p(m(z))=y_0$, a contradiction. Therefore, $p^{-1}\{
y_0\}$ is empty.
\end{proof}
\begin{prop} In $\cat{Sets}$, epimorphisms are
surjective. \label{sets:es} \end{prop}
\begin{proof} Suppose that $p:X\to Y$ is not a surjection. Then there
is a $y_0\in Y$ such that for all $x\in X$, $p(x)\neq y_0$. Since
$1$ is terminal, the morphism $y_0:1\to Y$ is monic. Consider the
following diagram:
\[ \begin{tikzcd}
1 \arrow[ddr,"x"'] \arrow{rrd} \\
& p^{-1}\{ y_0\} \arrow{d} \arrow{r} & 1 \arrow{d}{y_0} \arrow{r} & 1 \arrow{d}{\tr} \\
& X \arrow{r}{p} & Y \arrow{r}{g} & \Omega \end{tikzcd} \] Here
$g$ is the characteristic function of $\{ y_0\}$; by Axiom
\ref{ax:classify}, $g$ is the unique function that makes the right
hand square a pullback. Let $x\in X$ be arbitrary. If we had
$g(p(x))=\tr$, then there would be an element $x'\in p^{-1}\{y_0\}$,
in contradiction with the fact that the latter is empty (Proposition
\ref{empty-fiber}). By Axiom \ref{ax:classify}, either
$g(p(x))=\tr$ or $g(p(x))=\f$; therefore, $g(p(x))=\f$. Now let $h$
be the composite $Y\to 1\stackrel{\f}{\to} \Omega$. Then, for any
$x\in X$, we have $h(p(x))=\f$. Since $g\circ p$ and $h\circ p$
agree on arbitrary $x\in X$, we have $g\circ p=h\circ p$. Since
$g\neq h$, it follows that $p$ is not an epimorphism.
\end{proof}
In a general category, there is no guarantee that an epimorphism pulls
back to an epimorphism. However, in $\cat{Sets}$, we have the
following:
\begin{prop} In $\cat{Sets}$, the pullback of an epimorphism is an
epimorphism. \label{sets-pullback-epi} \end{prop}
\begin{proof} Suppose that $f:Y\to Z$ is epi, and let $x\in X$.
Consider the pullback diagram:
\[ \begin{tikzcd}
1 \arrow{ddr}[left]{x} \arrow{drr}{y} \arrow[dashed]{dr} \\
& \ast \arrow{d}{q_0} \arrow[r,"q_1"'] & Y \arrow{d}{f} \\
& X \arrow[r,"g"'] & Z \end{tikzcd} \] By Proposition
\ref{sets:es}, $f$ is surjective. In particular, there is a $y\in
Y$ such that $f(y)=g(x)$. Since the diagram is a pullback, there is
a unique $\langle x,y\rangle :1\to \ast$ such that $q_0\langle
x,y\rangle =x$ and $q_1\langle x,y\rangle =y$. Therefore, $q_0$ is
surjective, and hence epi.
\end{proof}
\begin{prop} If $f:X\to Y$ and $g:W\to Z$ are epimorphisms, then so is
$f\times g:X\times W\to Y\times Z$. \end{prop}
\begin{proof} Since $f\times g=(f\times 1)\circ (1\times g)$, it will
suffice to show that $f\times 1$ is epi when $f$ is epi. Now, the
following diagram is a pullback:
\[ \begin{tikzcd}
X\times W \arrow{r}{p_0} \arrow[d,"f\times 1"'] & X \arrow{d}{f} \\
Y\times W \arrow{r}{p_0} & Y \end{tikzcd} \] By Proposition
\ref{sets-pullback-epi}, if $f$ is epi, then $f\times 1$ is
epi. \end{proof}
Suppose that $f:X\to Y$ is a function, and that $p_0,p_1:X\times
_YX\rightrightarrows X$ is the kernel pair of $f$. Suppose also that
$h:E\to Y$ is a function, that $q_0,q_1:E\times _YE\rightrightarrows
E$ is the kernel pair of $h$, and that $g:X\epi E$ is an epimorphism.
Then there is a unique function $b:X\times _YX\to E\times _YE$, such
that $q_0b=gp_0$ and $q_1b=gp_1$.
\[ \begin{tikzcd} X\times _Y X \arrow[d,dashed,"b"'] \arrow[r,shift
left,"p_0"] \arrow[shift
right,r,"p_1"'] & X \arrow[d,->>,"g"] \arrow[r,"f"] & Y \\
E\times _Y E \arrow[shift left,r,"q_0"] \arrow[shift right,r,"q_1"']
& E \arrow[ur,"h"'] \end{tikzcd} \] An argument similar to the one
above shows that $b$ is an epimorphism. We will use this fact below
to describe the properties of epimorphisms in $\cat{Sets}$.
\section{Relations}
\subsection*{Equivalence relations and equivalence classes}
%% TO DO: subobject defined??
%% TO DO: for this we need image factorizations (regular category)
%% regular epis are stable under pullback
A relation $R$ on a set $X$ is a subset of $X\times X$; i.e.\ a set of
ordered-pairs. A relation is said to be an equivalence relation just
in case it is reflexive, symmetric, and transitive. One particular
way that equivalence relations on $X$ arise is from functions with $X$
as domain: given a function $f:X\to Y$, let say that $\langle
x,y\rangle \in R$ just in case $f(x)=f(y)$. [Sometimes we say that,
``$x$ and $y$ lie in the same fiber over $Y$.''] Then $R$ is an
equivalence relation on $X$.
Given an equivalence relation $R$ on $X$, and some element $x\in X$,
let $[x]=\{ y\in X \mid \langle x,y\rangle \in R \}$ denote the set of
all elements of $X$ that are equivalent to $X$. We say that $[x]$ is
the {\bf equivalence class} of $x$. It's straightforward to show that
for any $x,y\in X$, either $[x]=[y]$ or $[x]\cap [y]=\emptyset$.
Moreover, for any $x\in X$, we have $x\in [x]$. Thus the equivalence
classes form a {\bf partition} of $X$ into disjoint subsets.
We'd like now to be able to talk about the set of these equivalence
classes, i.e.\ something that might intuitively be written as $\{
[x]\mid x\in X \}$. The following axiom guarantees the existence of
such a set, called $X/R$, and a canonical mapping $q:X\to X/R$ that
takes each element $x\in X$ to its equivalence class $[x]\in X/R$.
% Intuitively speaking, we can gather together the fibers of $f$ into a
% set:
% \[ X/R \: = \: \{ f^{-1}\{ y\} \mid y\in Y \} .\] These fibers are
% called \emph{equivalence classes} of the relation $R$. The set $E$
% has the following special properties: (1) there is a canonical
% epimorphism $q:X\to X/R$ that assigns each $x\in X$ its equivalence
% class in $X/R$, and (2) given a function $g:X\to Z$ that is constant
% on the equivalence classes [i.e.\ if $x$ and $y$ are equivalent, then
% $h(x)=h(x')$], there is a unique function $k:E\to Z$ such that $kg=h$.
Our next axiom guarantees the existence of the set of equivalence
classes.
\begin{axi}[Equivalence classes]{}
Let $R$ be an equivalence relation on $X$. Then there is a
set $X/R$, and a function $q:X\to X/R$ with the properties:
\begin{enumerate}
\item $\langle x,y\rangle \in R$ if and only if $q(x)=q(y)$.
\item For any set $Y$ and function $f:X\to Y$ that is constant on
equivalence classes, there is a unique function $\overline{f}:X/R\to
Y$ such that $\overline{f}\circ q=f$. \end{enumerate}
\[ \begin{tikzcd} X \arrow[r,"f"] \arrow[d,"q"'] & Y \\
X/R \arrow[dashed,ur,"\overline{f}"'] \end{tikzcd} \] Here $f$ is
constant on equivalence classes just in case $f(x)=f(y)$ whenever
$\langle x,y\rangle \in R$. \label{ax:eq}
\end{axi}
An equivalence relation $R$ can be thought of as a subobject of
$X\times X$, i.e.\ a subset of ordered pairs. Accordingly, there are
two functions $p_0:R\to X$ and $p_1:R\to X$ given by: $p_0\langle
x,y\rangle = x$ and $p_1\langle x,y\rangle =y$. Then condition (1) in
the above axiom says that $q\circ p_0=q\circ p_1$. And condition (2)
says that for any function $f:X\to Y$ such that $f\circ p_0=f\circ p
_1$, there is a unique function $\overline{f}:X/R \to Y$ such that
$\overline{f}\circ q=f$. In this case, we say that $q$ is a
\emph{coequalizer} of $p_0$ and $p_1$.
\begin{exercise} Show that in any category, coequalizers are unique up
to isomorphism. \end{exercise}
\begin{exercise} Show that in any category, a coequalizer is an
epimorphism. \end{exercise}
\begin{exercise} For a function $f:X\to Y$, let $R=\{ \langle
x,y\rangle \in X\times X \mid f(x)=f(y) \}$. That is, $R$ is the
kernel pair of $f$. Show that $R$ is an equivalence
relation. \end{exercise}
\begin{defn} A function $f:X\to Y$ is said to be a \emph{regular
epimorphism} just in case $f$ is a coequalizer. \end{defn}
\begin{exercise} Show that in any category, if $f:X\to Y$ is both a
monomorphism and a regular epimorphism, then $f$ is an
isomorphism. \end{exercise}
\begin{prop} Every epimorphism in $\cat{Sets}$ is regular. In
particular, every epimorphism is the coequalizer of its kernel
pair. \label{regs} \end{prop}