-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasedefinitions.tex
More file actions
1936 lines (1668 loc) · 68.1 KB
/
basedefinitions.tex
File metadata and controls
1936 lines (1668 loc) · 68.1 KB
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
%% -*- coding:utf-8 -*-
\chapter{Base definitions}
\section{Definitions}
The chapter provides you with base definitions that will be widely used in the
book later.
We will give you definition for \mynameref{def:object}, \mynameref{def:morphism},
\mynameref{def:category} and also provide you several important exaxmples,
such as the \mynameref{def:setcategory}.
\subsection{Object}
\begin{definition}[Class]
A class is a collection of sets (or sometimes other mathematical
objects) that can be unambiguously defined by a property that all
its members share.
\label{def:class}
\end{definition}
\begin{definition}[Object]
\label{def:object}
In category theory object is considered as something that does not
have internal structure (aka point) but has a property that makes
different objects belong to the same \mynameref{def:class}
\end{definition}
\begin{remark}[Class of Objects]
\label{rem:objclass}
The \mynameref{def:class} of \mynameref{def:object}s will be marked as
$\catob{C}$ (see \cref{fig:class_of_objects}).
\end{remark}
\begin{figure}
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,4) {$\cat{C}$};
\node[ele,label=left:$a$] (a) at (2,2) {};
\node[ele,label=left:$b$] (b) at (2,1) {};
\node[ele,label=left:$c$] (c) at (0,2) {};
\node[ele,label=left:$d$] (d) at (0,1) {};
\node[draw,fit= (a) (b) (c) (d),minimum width=4cm, minimum
height=4cm] {} ;
\end{tikzpicture}
\caption{Class of objects $\catob{C}=\{a,b,c,d\}$}
\label{fig:class_of_objects}
\end{figure}
\subsection{Morphism}
\begin{figure}
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,4) {$\cat{C}$};
\node[ele,label=left:$a$] (a) at (1,1) {};
\node[ele,label=right:$b$] (b) at (2,1) {};
\node[draw,fit= (a) (b),minimum width=4cm, minimum
height=4cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (b);
\end{tikzpicture}
\caption{Morphism (arrow) $f: a \to b $}
\label{fig:morphism}
\end{figure}
Morphism is a kind of relation between 2 \mynameref{def:object}s.
\begin{definition}[Morphism]
\label{def:morphism}
A relation between two \mynameref{def:object}s $a$ and $b$
\[
f: a \rightarrow b
\]
is called as \textit{morphism}. Morphism assumes a direction i.e. one
\mynameref{def:object}
($a$) is called \textit{source} or \mynameref{def:domain} and another one ($b$)
\textit{target} or \mynameref{def:codomain}.
The \mynameref{def:set} of all morphisms between objects $a$ and $b$
is denoted as $\catmset{a}{b}$.
\end{definition}
\begin{definition}[Arrow]
\label{def:arrow}
\mynameref{def:morphism}s are also called as \textit{Arrows} (see
\cref{fig:morphism}).
\end{definition}
The important remark about morphisms is below
\begin{remark}[Morphism]
\label{rem:morphism}
The morphism has to be considered as a relation between objects. We
will avoid standard (from set theory) notation for morphisms: $f(a) =
b$. The reason for this is the following. Let $f_1: a \to b$ and $f_2:
a \to b$ are two different morphisms. The notation $f_1(a) = b, f_2(a) =
b$ leads to incorrect conclusion that $f_1 = f_2$.
For instance if $a
= b = \mathbb{R}$ then two functions $f_1(x) = x, f_2(x) = -x$ define two
different ordering on $\mathbb{R}$ and as result have not to be
considered as the same \mynameref{def:morphism}s.
\end{remark}
\begin{definition}[Domain]
\label{def:domain}
Given a \mynameref{def:morphism} $f: a \to b$, the
\mynameref{def:object} $a$ is called \textit{domain} and denoted as $\dom f$.
\end{definition}
\begin{definition}[Codomain]
\label{def:codomain}
Given a \mynameref{def:morphism} $f: a \to b$, the
\mynameref{def:object} $b$ is called \textit{codomain} and denoted as $\cod f$.
\end{definition}
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=left:$a$] (a) at (1,1) {};
\node[ele,label=right:$b$] (b) at (3,1) {};
\node[ele,label=right:$c$] (c) at (3,3) {};
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,below]{$f_{ab}$} (b);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (b) to
node[pos=0.5,right]{$f_{bc}$} (c);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f_{ac}$} (c);
\end{tikzpicture}
\caption{Composition $f_{ac} = f_{bc} \circ f_{ab}$}
\label{fig:composition}
\end{figure}
\mynameref{def:morphism}s have several properties. \footnote{The
properties don't have any proofs and are postulated as axioms}
\begin{axiom}[Composition]
\label{axm:composition}
If there are 3 \mynameref{def:object}s $a, b, c$ and 2
\mynameref{def:morphism}s
\begin{eqnarray}
f_{ab} : a \rightarrow b,
\nonumber \\
f_{bc} : b \rightarrow c
\nonumber
\end{eqnarray}
then there exists a \mynameref{def:morphism} (see \cref{fig:composition})
\[
f_{ac} : a \rightarrow c
\]
such that
\[
f_{ac} = f_{bc} \circ f_{ab}
\]
\end{axiom}
\begin{remark}[Composition]
\label{rem:composition}
The equation
\[
f_{ac} = f_{bc} \circ f_{ab}
\]
means that we apply $f_{ab}$ first and then we apply $f_{bc}$ to the
result of the application i.e. if our objects are sets and $x \in a$
then
\[
f_{ac} ( x ) = f_{bc} ( f_{ab} ( x ) ),
\]
where $f_{ab} ( x ) \in b, f_{ac} ( x ) \in c$.
\end{remark}
\begin{axiom}[Associativity]
\label{axm:associativity}
The \mynameref{def:morphism} \mynameref{axm:composition} should
follow associativity property:
\[
f_{ce} \circ (f_{bc} \circ f_{ab}) = (f_{ce} \circ f_{bc}) \circ
f_{ab} = f_{ce} \circ f_{bc} \circ f_{ab}.
\]
\end{axiom}
\begin{definition}[Identity morphism]
\label{def:id}
For every \mynameref{def:object} $a$ there is a special
\mynameref{def:morphism} $\idm{a} : a \rightarrow a$ with the
following properties: $\forall f_{ba} : b \rightarrow a$ (see \cref{fig:left_idm})
\begin{equation}
\idm{a} \circ f_{ba} = f_{ba}
\label{eq:leftid}
\end{equation}
and
$\forall f_{ab} : a \rightarrow b$ (see \cref{fig:right_idm})
\begin{equation}
f_{ab} \circ \idm{a} = f_{ab}.
\label{eq:rightid}
\end{equation}
This morphism is referred to as \textit{identity morphism}.
\end{definition}
Note that \mynameref{def:id} is unique, see
\mynameref{thm:identity_unique} below.
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=below:$a$] (a) at (0,0) {};
\node[ele,label=below:$b$] (b) at (2,0) {};
\draw[->] (b) to node[pos=0.5,above]{$f_{ba}$} (a);
\draw[->] (a) to [out=45,in=135,looseness=20] node[above] {$\idm{a}$} (a);
\end{tikzpicture}
\caption{Identity morphism property: $\idm{a} \circ f_{ba} = f_{ba}$}
\label{fig:left_idm}
\end{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=below:$a$] (a) at (2,0) {};
\node[ele,label=below:$b$] (b) at (0,0) {};
\draw[->] (a) to node[pos=0.5,above]{$f_{ab}$} (b);
\draw[->] (a) to [out=45,in=135,looseness=20] node[above] {$\idm{a}$} (a);
\end{tikzpicture}
\caption{Identity morphism property: $f_{ab} \circ \idm{a} = f_{ab}$}
\label{fig:right_idm}
\end{figure}
\begin{definition}[Diagram]
\label{def:diagram}
A \textit{diagram} in a category $\cat{C}$ is a collection of
vertices and directed edges where the vertices correspond to the
objects of $\cat{C}$ and edges consistently correspond to the
morphisms (see \ref{fig:diagramm}).
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=left:$a$] (a) at (1,1) {};
\node[ele,label=right:$b$] (b) at (3,1) {};
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (b);
\draw[thick,dashed] (a) -- (1,3);
\draw[thick,dashed] (b) -- (3,3);
\end{tikzpicture}
\caption{Diagram in category $\cat{C}$. Vertexes $a$ and $b$ are
objects in the category $\cat{C}$, $f$ is a morphism from the category.}
\label{fig:diagramm}
\end{figure}
Consistently means that for an edge named as $f$ has endpoints
labeled $a$ and $b$, where $f$ is a morphism of $\cat{C}$, $a$ is \mynameref{def:domain} of $f$ and
$b$ is \mynameref{def:codomain} of $f$.
\end{definition}
\begin{definition}[Commutative diagram]
\label{def:commutative_diagram}
A \mynameref{def:diagram} of category $\cat{C}$ is said to
\textit{commute} if all directed paths in the diagram with the same
start and endpoint lead to the same result by composition.
\end{definition}
\begin{example}
\label{ex:commutative_diagram}
The trivial example of \mynameref{def:commutative_diagram} is
\mynameref{axm:composition} for $f_{ab} = f_{cb} \circ f_{ac}$:
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=left:$a$] (a) at (1,1) {};
\node[ele,label=right:$b$] (b) at (3,1) {};
\node[ele,label=right:$c$] (c) at (3,3) {};
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f_{ac}$} (c);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (c) to
node[pos=0.5,right]{$f_{cb}$} (b);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,below]{$f_{ab}$} (b);
\end{tikzpicture}
\caption{Commutative diagram for composition $f_{ab} = f_{cb} \circ f_{ac}$}
\label{fig:composition_commutative_diagramm}
\end{figure}
\end{example}
\begin{remark}[Class of Morphisms]
\label{rem:morphclass}
The \mynameref{def:class} of \mynameref{def:morphism}s will be marked as
$\cathom{C}$ (see \cref{fig:class_of_morphisms})
\end{remark}
\begin{figure}
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,4) {$\cat{C}$};
\node[ele,label=left:$a$] (a) at (0,2) {};
\node[ele,label=left:$b$] (b) at (0,1) {};
\node[ele,label=right:$c$] (c) at (2,2) {};
\node[ele,label=right:$d$] (d) at (2,1) {};
\node[draw,fit= (a) (b) (c) (d),minimum width=4cm, minimum
height=4cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (c);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (b) to
node[pos=0.5,left]{$g$} (a);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (b) to
node[pos=0.5,right]{$h$} (c);
\end{tikzpicture}
\caption{Class of morphisms $\cathom{C}=\{f,g,h\}$, where $h = f
\circ g$}
\label{fig:class_of_morphisms}
\end{figure}
\begin{definition}[Monomorphism]
\label{def:monomorphism}
If $\forall g_1, g_2$ the equation
\[
f \circ g_1 = f \circ g_2
\]
leads to
\[
g_1 = g_2
\]
then $f$ is called \textit{monomorphism} (see
\cref{fig:monomorphism}). The monomorphism between
$a$ and $b$ is denoted as $f: a \hookrightarrow b$ (see also
\mynameref{def:injection} or ``one-to-one'' functions).
\index{``one-to-one'' function}
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=below:$c$] (c) at (0,0) {};
\node[ele,label=below:$a$] (a) at (2,0) {};
\node[ele,label=below:$b$] (b) at (4,0) {};
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (b);
\draw[->,thick,shorten <=2pt,shorten >=2pt] ([yshift=5pt] c.east) to
node[pos=0.5,above]{$g_1$} ([yshift=5pt] a.west);
\draw[->,thick,shorten <=2pt,shorten >=2pt] ([yshift=-5pt]c.east) to
node[pos=0.5,below]{$g_2$} ([yshift=-5pt]a.west);
\end{tikzpicture}
\caption{Monomorphism $f: a \hookrightarrow b$: $\forall g_1, g_2$: $f \circ g_1 = f \circ g_2$ leads to $g_1 = g_2$}
\label{fig:monomorphism}
\end{figure}
\end{definition}
\begin{definition}[Epimorphism]
\label{def:epimorphism}
If $\forall g_1, g_2$ the equation (see \cref{fig:epimorphism})
\[
g_1 \circ f = g_2 \circ f
\]
leads to
\[
g_1 = g_2
\]
then $f$ is called \textit{epimorphism} (see also
\mynameref{def:surjection} or ``onto'' functions).
\index{``onto'' function}
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
\node[ele,label=below:$c$] (c) at (4,0) {};
\node[ele,label=below:$a$] (a) at (0,0) {};
\node[ele,label=below:$b$] (b) at (2,0) {};
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (b);
\draw[->,thick,shorten <=2pt,shorten >=2pt] ([yshift=5pt]b.east) to
node[pos=0.5,above]{$g_1$} ([yshift=5pt]c.west);
\draw[->,thick,shorten <=2pt,shorten >=2pt] ([yshift=-5pt]b.east) to
node[pos=0.5,below]{$g_2$} ([yshift=-5pt]c.west);
\end{tikzpicture}
\caption{Epimorphism $f$: $g_1 \circ f = g_2 \circ f$ leads to $g_1 = g_2$}
\label{fig:epimorphism}
\end{figure}
\end{definition}
\begin{definition}[Isomorphism]
\label{def:isomorphism}
A \mynameref{def:morphism} $f: a \to b$ is called \textit{isomorphism} if
$\exists g: b \to a$ such that $f \circ g = \idm{b}$
and $g \circ f = \idm{a}$.
If there is an isomorphism $f$ between objects $a$ and $b$
then it is denoted by $a \cong_f b$.
\end{definition}
\begin{remark}[Isomorphism]
\label{rem:isomorphism}
There can be many different \mynameref{def:isomorphism}s between 2
\mynameref{def:object}s.
If there is an unique isomorphism between 2 objects $a$ and $b$ then the objects
can be treated as the same object i.e. $a = b$.
\end{remark}
\subsection{Category}
\begin{definition}[Category]
\label{def:category}
A category $\cat{C}$ consists of
\begin{itemize}
\item \mynameref{def:class} of
\mynameref{def:object}s $\catob{C}$
\item \mynameref{def:class} of \mynameref{def:morphism}s $\cathom{C}$
defined for $\catob{C}$, i.e. each morphism $f_{ab}$ from
$\cathom{C}$ has both source
$a$ and target $b$ from $\catob{C}$
\end{itemize}
For any \mynameref{def:object} $a$ there should be unique
\mynameref{def:id} $\idm{a}$. Any morphism should satisfy
\mynameref{axm:composition} and \mynameref{axm:associativity} axioms
(see example in \cref{fig:category}).
\end{definition}
\begin{figure}
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,4.5) {$\cat{C}$};
\node[ele,label=left:$a$] (a) at (0,2) {};
\node[ele,label=left:$b$] (b) at (0,1) {};
\node[ele,label=right:$c$] (c) at (2,2) {};
\node[ele,label=right:$d$] (d) at (2,1) {};
\node[draw,fit= (a) (b) (c) (d),minimum width=5cm, minimum
height=5cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,above]{$f$} (c);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (b) to
node[pos=0.5,left]{$g$} (a);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (b) to
node[pos=0.5,right]{$h$} (c);
\draw (a) to [out=45,in=135,looseness=20] node[above] {$\idm{a}$} (a);
\draw (b) to [out=-45,in=-135,looseness=20] node[below] {$\idm{b}$} (b);
\draw (c) to [out=45,in=135,looseness=20] node[above] {$\idm{c}$} (c);
\draw (d) to [out=-45,in=-135,looseness=20] node[below] {$\idm{d}$} (d);
\end{tikzpicture}
\caption{Category $\cat{C}$. It consists of 4 objects
$\catob{C} = \{a,b,c,d\}$ and 7 morphisms
$\catob{C} = \{f,g,h = f \circ g, \idm{a}, \idm{b},
\idm{c}, \idm{d}\}$}
\label{fig:category}
\end{figure}
\begin{definition}[Set of morphisms]
\label{def:morphism_set}
The set of morphisms between objects $a$ and $b$ in the category $\cat{C}$
will be denoted as $\catmset[C]{a}{b}$. The set will be denoted
as $\catmset{a}{b}$ if the exact category does not matter.
\end{definition}
The \mynameref{def:category} can be considered as a way to represent a
structured data. \mynameref{def:object}s are the data and
\mynameref{def:morphism}s form the structure that connects the data.
\begin{definition}[Opposite category]
\label{def:op_category}
\index{Category!opposite}
\index{Category!dual}
If $\cat{C}$ is a \mynameref{def:category} then opposite (or dual) category
$\cat{C}^{op}$ is constructed in the following way: \mynameref{def:object}s
are the same, but the \mynameref{def:morphism}s are inverted i.e.
if $f \in \cathom{C}$ and $\dom f = a, \cod f = b$ (see
\mynameref{def:domain}, \mynameref{def:codomain}), then the
corresponding morphism $f^{op} \in \cathom{C^{op}}$ has $\dom f^{op} =
b, \cod f^{op} = a$ (see \cref{fig:op_category})
\end{definition}
\begin{figure}
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,4.5) {$\cat{C}$};
\node[ele,label=left:$a$] (a) at (0,2) {};
\node[ele,label=left:$b$] (b) at (0,1) {};
\node[ele,label=right:$c$] (c) at (2,2) {};
\node[ele,label=right:$d$] (d) at (2,1) {};
\node[draw,fit= (a) (b) (c) (d),minimum width=5cm, minimum
height=5cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (c) to
node[pos=0.5,above]{$f^{op}$} (a);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a) to
node[pos=0.5,left]{$g^{op}$} (b);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (c) to
node[pos=0.5,right]{$h^{op}$} (b);
\draw (a) to [out=45,in=135,looseness=20] node[above] {$\idm{a}$} (a);
\draw (b) to [out=-45,in=-135,looseness=20] node[below] {$\idm{b}$} (b);
\draw (c) to [out=45,in=135,looseness=20] node[above] {$\idm{c}$} (c);
\draw (d) to [out=-45,in=-135,looseness=20] node[below] {$\idm{d}$} (d);
\end{tikzpicture}
\caption{Opposite category $C^{op}$ to the category from
\cref{fig:category} . It consists of 4 objects
$\catob{C^{op}} = \catob{C} = \{a,b,c,d\}$ and 7 morphisms
$\cathom{C^{op}} = \{f^{op},g^{op},h^{op} = g^{op} \circ
f^{op}, \idm{a}, \idm{b},
\idm{c}, \idm{d}\}$}
\label{fig:op_category}
\end{figure}
\begin{remark}{Composition on $C^{op}$}
\label{rem:op_composition}
\index{Composition!opposite category}
As you can see from \cref{fig:op_category} the
\mynameref{axm:composition} is reverted for
\mynameref{def:op_category}. If $f,g,h = f \circ g \in
\cathom{C}$ then $f \circ g$ translated into $g^{op} \circ
f^{op}$ in opposite category.
\end{remark}
\begin{definition}[Small category]
\label{def:small_category}
\index{Category!small}
A category $\cat{C}$ is called \textit{small} if both $\catob{C}$ and
$\cathom{C}$ are \nameref{def:set}s
\end{definition}
\begin{definition}[Locally small category]
\label{def:localy_small_category}
\index{Category!locally small}
A category $\cat{C}$ is called \textit{locally small} if
$\cathom{C}$ is a \nameref{def:set}. The set is called \mynameref{def:homset}.
\end{definition}
\begin{definition}[Homset]
\label{def:homset}
The \textit{homset} is the \mynameref{def:set} of morphisms in a
\mynameref{def:localy_small_category}.
\end{definition}
\begin{definition}[Large category]
\label{def:large_category}
\index{Category!large}
A category $\cat{C}$ is not \mynameref{def:small_category} then it is
called \textit{large}. The example of large category is
\mynameref{def:setcategory}
\end{definition}
\begin{definition}[Empty category]
\label{def:empty_category}
The category that does not contain any \mynameref{def:object}s and as
result does not contain any \mynameref{def:morphism}s is called
\textit{Empty category} \cite{bib:stackexchange:empty_category}.
\end{definition}
\begin{definition}[Trivial category]
\label{def:trivial_category}
The category that contains only one \mynameref{def:object} and only
one \mynameref{def:morphism} (\mynameref{def:id}) is called
\textit{Trivial category}.
\end{definition}
There are several examples of categories below that will also be
actively used later in the book:
\begin{itemize}
\item $\cat{Set}$ category example: see \cref{sec:setcategory_example}
\item Programming languages (Haskell, C\texttt{++}, Scala) examples: see
\cref{sec:plcategory_example}
\item Quantum mechanics example: see \cref{sec:qmcategory_example}
\end{itemize}
\section{$\cat{Set}$ category example}
\label{sec:setcategory_example}
The category of sets is the most important example because it
connects our usual knowledge about sets with the category theory.
\begin{definition}[Set]
\label{def:set}
\textit{Set} is a collection of distinct objects. The objects are called
the elements of the set.
The set will be denoted by a capital letter in
the book, for instance $A$. The elements of a set will be denoted by
small letters: $a \in A$.
\end{definition}
\begin{remark}[Set]
\label{rem:set}
The definition of \mynameref{def:set} was given
above is incomplete. There are several additional axioms should be
applied for the complete definition. Different sets of axioms can be
used. In our case we consider so called \textit{Zermelo—Fraenkel set theory
with the axiom of Choice} or \textit{ZFC} \cite{wiki:zfc}. The
system of axioms allows us to avoid different logical paradoxes of
the set theory, for instance well known Russell's
paradox \cite{wiki:russell_paradox}.
\end{remark}
\begin{definition}[Cardinality]
\label{def:cardinality}
The number of elements in the \mynameref{def:set} $A$ is called
\textit{cardinality} and is denoted as $\left|A\right|$.
\end{definition}
\begin{definition}[Cartesian product]
\label{def:cartesian_product}
If $A$ and $B$ are two sets then we can define a new set $A \times B
= \left\{(a,b)|a \in A, b \in B\right\}$ that is called as the
\textit{cartesian product}.
\end{definition}
\begin{definition}[Binary relation]
\label{def:binary_relation}
If $A$ and $B$ are 2 \mynameref{def:set}s then a subset of the
\mynameref{def:cartesian_product} $A \times B$ is
called as \textit{binary relation} $R$ between the 2 sets, i.e. $R
\subset A \times B$.
\end{definition}
\begin{example}[Binary relation]
Example of binary relation is shown on
\cref{fig:binary_relation}. There is a relation $R$ between 2 sets
$A$ and $B$. The relation maps $a_1$ into two different values
$b_1$ and $b_2$.
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,5) {$A$};
\node at (4,5) {$B$};
\node[ele,label=left:$a_1$] (a1) at (0,3.5) {};
\node[ele,label=left:$a_2$] (a2) at (0,2.5) {};
\node[ele,,label=right:$b_1$] (b1) at (4,4) {};
\node[ele,,label=right:$b_2$] (b2) at (4,3) {};
\node[ele,,label=right:$b_3$] (b3) at (4,2) {};
\node[draw,fit= (a1) (a2) ,minimum height=3cm, minimum width=2cm] {} ;
\node[draw,fit= (b1) (b2) (b3),minimum width=2cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (a1) -- (b2);
\draw[->,thick,shorten <=2pt,shorten >=2] (a1) -- (b1);
\draw[->,thick,shorten <=2pt,shorten >=2] (a2) -- (b3);
\end{tikzpicture}
\caption{Binary relation $R$ between 2 sets $A$ and $B$. $a_1$ is
mapped into 2 values $b_1, b_2$}
\label{fig:binary_relation}
\end{figure}
\end{example}
\begin{definition}[Function]
\label{def:function}
\textit{Function} $f$ is a special type of \mynameref{def:binary_relation}. I.e.
if $A$ and $B$ are 2 \mynameref{def:set}s then a subset of $A \times B$ is
called function $f$ between the 2 sets if $\forall a \in A \, \exists!
b \in B$ such that $(a,b) \in f$.
\end{definition}
\begin{remark}[Function vs Binary relation]
The main difference between \mynameref{def:function} and
\mynameref{def:binary_relation} is that
\mynameref{def:binary_relation} allows mapping an argument into
more than one value (see \cref{fig:binary_relation}). From other side \mynameref{def:function}
definition does not allow such ``multi value''.
\end{remark}
\begin{definition}[$\cat{Set}$ category]
\label{def:setcategory}
\index{Object!$\cat{Set}$ category}
\index{Morphism!$\cat{Set}$ category}
\index{Category!$\cat{Set}$}
In the \textit{Set category} we consider a
\mynameref{def:set} of
\mynameref{def:set}s where
\mynameref{def:object}s are the \mynameref{def:set}s and
\mynameref{def:morphism}s are \mynameref{def:function}s between the
sets.The \mynameref{def:id} is the trivial function such that $\forall x \in
X: \idm{X}(x) = x$.
\mynameref{axm:composition} is the functions composition (see \cref{fig:function_composition})
\end{definition}
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,5) {$X$};
\node at (3,5) {$Y$};
\node at (6,5) {$Z$};
\node[ele,label=left:$x_1$] (x1) at (0,4) {};
\node[ele,label=left:$x_2$] (x2) at (0,3) {};
\node[ele,label=left:$x_3$] (x3) at (0,2) {};
\node[ele,label=left:$x_4$] (x4) at (0,1) {};
\node[ele,label=above:$y_1$] (y1) at (3,4) {};
\node[ele,label=above:$y_2$] (y2) at (3,3) {};
\node[ele,label=above:$y_3$] (y3) at (3,2) {};
\node[ele,label=above:$y_4$] (y4) at (3,1) {};
\node[ele,,label=right:$z_1$] (z1) at (6,4) {};
\node[ele,,label=right:$z_2$] (z2) at (6,3) {};
\node[ele,,label=right:$z_3$] (z3) at (6,2) {};
\node[draw,fit= (x1) (x2) (x3) (x4),minimum width=2cm] {} ;
\node[draw,fit= (y1) (y2) (y3) (y4),minimum width=2cm] {} ;
\node[draw,fit= (z1) (z2) (z3),minimum width=2cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (x1) -- (y2);
\draw[->,thick,shorten <=2pt,shorten >=2] (x2) -- (y1);
\draw[->,thick,shorten <=2pt,shorten >=2] (x3) -- (y4);
\draw[->,thick,shorten <=2pt,shorten >=2] (x4) -- (y3);
\draw[->,thick,shorten <=2pt,shorten >=2pt] (y1) -- (z2);
\draw[->,thick,shorten <=2pt,shorten >=2] (y2) -- (z1);
\draw[->,thick,shorten <=2pt,shorten >=2] (y3) -- (z3);
\draw[->,thick,shorten <=2pt,shorten >=2] (y4) -- (z3);
\end{tikzpicture}
\caption{Function composition. The function $f_{X \to Z}: X \to Z$ is the
composition of 2 functions $f_{X \to Y} : X \to Y$ and $f_{Y \to
Z}: Y \to Z$ }
\label{fig:function_composition}
\end{figure}
\begin{remark}[$\cat{Set}$ category]
In general case when we say $\cat{Set}$ category we assume the set
of all sets. But the result is inconsistent because famous Russell's
paradox \cite{wiki:russell_paradox} can be applied. To avoid such
situations we consider a limitation that is applied on our
construction as it was mentioned at \cref{rem:set}, especially
ZFC \cite{wiki:zfc} is applied. If we take into consideration the
limitation then we have a set of
all sets is not a set itself and as result the $\cat{Set}$
category is a \mynameref{def:large_category}
\index{Category!large}
\end{remark}
\begin{definition}[Singleton]
\label{def:singleton_set}
The \textit{singleton} is a \mynameref{def:set} with only one element.
\end{definition}
\begin{example}[Domain]
\label{ex:domain_set}
Given a function $f: X \to Y$, the set $X$ is the domain. I.e. $\dom
f = X$
\end{example}
\begin{example}[Codomain]
\label{ex:codomain_set}
Given a function $f: X \to Y$, the set $Y$ is the codomain. I.e.
$\cod f = Y$
\end{example}
\begin{definition}[Image]
\label{def:function_image}
The \textit{image} of a function $f: X \to Y$ is a subset of
\mynameref{def:codomain} $Y$ such that for every element in the subset
there is an element in \mynameref{def:domain} $X$ that maps into the
subset:
\[
\Ima{f} = \{y \in Y| y = f(x) \mbox{ for some } x \in X\}
\]
\end{definition}
\begin{definition}[Surjection]
\label{def:surjection}
\index{``onto'' function}
The function $f: X \rightarrow Y$ is \textit{surjective} (or ``onto'') if
$\forall y \in Y$, $\exists x \in X$ such that
$f\left(x\right) = y$ (see \cref{fig:surjection,fig:bijection}).
\end{definition}
\begin{example}[Surjection]
An example of a surjective function is shown in \cref{fig:surjection}.
Note that the function in the figure is not an
\mynameref{def:injection}. You can find an example of a function that
is \mynameref{def:surjection} as well as \mynameref{def:injection} (aka
\mynameref{def:bijection}) in \cref{fig:bijection}.
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,5) {$X$};
\node at (4,5) {$Y$};
\node[ele,label=left:$x_1$] (x1) at (0,4) {};
\node[ele,label=left:$x_2$] (x2) at (0,3) {};
\node[ele,label=left:$x_3$] (x3) at (0,2) {};
\node[ele,label=left:$x_4$] (x4) at (0,1) {};
\node[ele,,label=right:$y_1$] (y1) at (4,4) {};
\node[ele,,label=right:$y_2$] (y2) at (4,3) {};
\node[ele,,label=right:$y_3$] (y3) at (4,2) {};
\node[draw,fit= (x1) (x2) (x3) (x4),minimum width=2cm] {} ;
\node[draw,fit= (y1) (y2) (y3),minimum width=2cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (x1) -- (y2);
\draw[->,thick,shorten <=2pt,shorten >=2] (x2) -- (y1);
\draw[->,thick,shorten <=2pt,shorten >=2] (x3) -- (y3);
\draw[->,thick,shorten <=2pt,shorten >=2] (x4) -- (y3);
\end{tikzpicture}
\caption{A surjective (non-injective) function from domain $X$ to
codomain $Y$ }
\label{fig:surjection}
\end{figure}
\end{example}
\begin{remark}[Surjection vs Epimorphism]
\label{rem:surjection_epimorphism}
\mynameref{def:surjection} and \mynameref{def:epimorphism} are
related each other. Consider a non-surjective function $f: X
\rightarrow Y' \subset Y$ (see \cref{fig:surjection_epimorphism}). One can
conclude that there is not an \mynameref{def:epimorphism} because
$\exists g_1: Y' \to Y'$ and $g_2 : Y \to Y$ such
that $g_1 \ne g_2$ because they operates on different
\mynameref{def:domain}s but from other hand $g_1(y) = g_2(y),
\forall y \in Y'$. For
instance we can choose $g_1 = \idm{Y'}, g_2=\idm{Y}$. As
soon as $Y'$ is \mynameref{def:codomain} of $f$ we always have
$g_1(f(x)) = g_2(f(x))$, $\forall x \in X$. I.e.
\[
g_1 \circ f = g_2 \circ f,
\]
but $g_1 \ne g_2$. As result one can say that a
\mynameref{def:surjection} is an
\mynameref{def:epimorphism} in the $\cat{Set}$ category. Moreover
there is a proof
\cite{bib:proofwiki:Surjection_iff_Epimorphism_in_Category_of_Sets}
of that fact.
% https://tex.stackexchange.com/questions/19987/
% drawing-a-bijective-map-with-tikz
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,5) {$X$};
\node at (4,5) {$Y$};
\node at (5.5,3.5) {$Y'$};
\node[ele,label=left:$x_1$] (x1) at (0,4) {};
\node[ele,label=left:$x_2$] (x2) at (0,3) {};
\node[ele,label=left:$x_3$] (x3) at (0,2) {};
\node[ele,label=left:$x_4$] (x4) at (0,1) {};
\node[ele,,label=right:$y_1$] (y1) at (4,4) {};
\node[ele,,label=right:$y_2$] (y2) at (4,3) {};
\node[ele,,label=right:$y_3$] (y3) at (4,2) {};
\node[ele,,label=right:$y_4$] (y4) at (4,1) {};
\node[draw,fit= (x1) (x2) (x3) (x4),minimum width=2cm] {} ;
\node[draw,fit= (y1) (y2) (y3) (y4),minimum width=2cm] {} ;
\node[draw,fit= (y1) (y2) (y3),minimum width=2cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (x1) -- (y2);
\draw[->,thick,shorten <=2pt,shorten >=2] (x2) -- (y1);
\draw[->,thick,shorten <=2pt,shorten >=2] (x3) -- (y3);
\end{tikzpicture}
\caption{Surjection vs epimorphism: A non-surjective function $f$ from domain $X$ to
codomain $Y' \subset Y$.
$\exists g_1: Y' \rightarrow Y', g_2: Y \rightarrow Y$ such that
$g_1(y) = g_2(y), \forall y \in Y'$, but as soon as $Y'
\ne Y$ we have $g_1 \ne g_2$. Using the fact that $Y'$ is codomain
of $f$ we got $g_1 \circ f = g_2 \circ f$.
I.e. the function $f$ is not epimorphism. }
\label{fig:surjection_epimorphism}
\end{figure}
\end{remark}
\begin{definition}[Injection]
\label{def:injection}
\index{``one-to-one'' function}
The function $f: X \rightarrow Y$ is injective (or ``one-to-one'' function) if
$\forall x_1, x_2 \in X$, such that $x_1 \ne x_2$ then
$f\left(x_1\right) \ne f\left(x_2\right)$ (see
\cref{fig:injection,fig:bijection}).
\end{definition}
\begin{example}[Injection]
% https://tex.stackexchange.com/questions/19987/
% drawing-a-bijective-map-with-tikz
An example of an injective function is shown in \cref{fig:injection}.
Note that the function in the figure is not a
\mynameref{def:surjection}. You can find an example of a function that
is \mynameref{def:surjection} as well as \mynameref{def:injection} (aka
\mynameref{def:bijection}) in \cref{fig:bijection}.
\begin{figure}[H]
\centering
\begin{tikzpicture}[ele/.style={fill=black,circle,minimum
width=.8pt,inner sep=1pt},every fit/.style={ellipse,draw,inner
sep=-2pt}]
% the texts
\node at (0,5) {$X$};
\node at (4,5) {$Y$};
\node[ele,label=left:$x_1$] (x1) at (0,4) {};
\node[ele,label=left:$x_2$] (x2) at (0,3) {};
\node[ele,label=left:$x_3$] (x3) at (0,2) {};
\node[ele,label=left:$x_4$] (x4) at (0,1) {};
\node[ele,,label=right:$y_1$] (y1) at (4,4) {};
\node[ele,,label=right:$y_2$] (y2) at (4,3) {};
\node[ele,,label=right:$y_3$] (y3) at (4,2) {};
\node[ele,,label=right:$y_4$] (y4) at (4,1) {};
\node[draw,fit= (x1) (x2) (x3) (x4),minimum width=2cm] {} ;
\node[draw,fit= (y1) (y2) (y3) (y4),minimum width=2cm] {} ;
\draw[->,thick,shorten <=2pt,shorten >=2pt] (x1) -- (y2);
\draw[->,thick,shorten <=2pt,shorten >=2] (x2) -- (y1);
\draw[->,thick,shorten <=2pt,shorten >=2] (x3) -- (y3);
\end{tikzpicture}
\caption{A injective (non-surjective) function from domain $X$ to
codomain $Y$ }
\label{fig:injection}
\end{figure}
\end{example}
\begin{remark}[Injection vs Monomorphism]
\label{rem:injection_monomorphism}
\mynameref{def:injection} and \mynameref{def:monomorphism} are
related each other. Consider a non-injective function $f: X