\part{Fundamentals}





\chapter{Categories}

MacLane and Eilenberg were algebraicists and algebraic topologists respectively who discovered a similar vein of methods being used in their respective fields.

Many objects in mathematics may have 'similar' behaviour in some specific sense, or in special cases, 'equal up to an isomorphism' (they have identical behaviour). Category theory studies these types of relationships between mathematical objects in the most abstract, fundamental setting possible.

We will develop category theory in NBG set theory, though it is also possible to develop category theory as a foundation for mathematics itself.


Functions have been extremely important in our study of mathematics; . Category theory focuses on the algebraic structure of functions like homomorphisms rather than the mappings themselves. They way they do this is by defining functions synthetically as \emph{morphisms}; elements of an algebraic tructure called a \emph{category}.

One cannot apply a domain element to a morphism, because a morphism has no mappings; it is an object that represents algebraic behaviour under the category's composition operation.




\begin{definition}[Object]
An \emph{object} is an element of a category's 'object class'.
\end{definition}

\begin{definition}[Morphism]
A \emph{categorical homomorphism} or just \emph{morphism} is an element of a category's 'morphism class' $f : X \to Y$. The object $X$ is called the domain and $Y$ the codomain. There may be multiple distinct morphisms in a category with identical domain and codomain.
\end{definition}

Note that morphisms share some notation with functions, but they are just sythetic objects that will be used in the category algebra. Indeed, they may actually be objects used to represent functions semantically, but we will also see examples where they are not interpreted as functions at all!



\begin{definition}[Category]
A \emph{category} $\mathcal{C}$ is a 3-tuple $(\mathrm{ob}(\mathcal{C}), \mathrm{hom}(\mathcal{C}), \circ)$ of a class of objects, clas of morphisms on these objects, and a binary morphism composition operation.
\begin{itemize}
	\item $\mathrm{ob}(\mathcal{C})$ is a class of objects
	\item $\mathrm{hom}(\mathcal{C})$ is a class of morphisms on objects of $\mathrm{ob}(\mathcal{C})$ (if $x,y \in \mathrm{ob}(\mathcal{C})$, then $\mathrm{hom}_{\mathcal{C}}(X,Y)$ are the morphisms from domain $X$ to codomain $Y$)
	\item $\circ : \mathrm{hom}_{\mathcal{C}}(X,Y) \to \mathrm{hom}_{\mathcal{C}}(Y,Z)$ is the binary composition operator defined on the morphisms
\end{itemize}
$\circ$ has the following properties:
\begin{itemize}
	\item $h \circ (g \circ f) = (h \circ g) \circ f$
	\item For any  $f \in \mathrm{hom}_{\mathcal{C}}(X,Y)$, there exist $1_X \in \mathrm{hom}_{\mathcal{C}}(X,X) , 1_Y \in \mathrm{hom}_{\mathcal{C}}(Y,Y)$ such that $f \circ 1_X = 1_Y \circ f = f$
\end{itemize}
\end{definition}

Note that the only thing in the definition of a category that is a function from classic set theory is $\circ$.

We remind you that a class is a type of collection in NBG that satisfy a property (or predicate). Classes of objects and morphism will require the axiom of comprehension over just the axiom of specification, and recall that we may run into paradoxes if we naiively treat classes as sets in the ZFC sense; this is why we work in NBG. If we used sets instead of categories, the category of sets $\mathbf{Set}$ would have $\mathrm{ob}(\mathbf{Set})$ as the universal set, which leads to paradoxes.

Having acknowledged this technical point, categories are often used represent classes mathematical structures and spaces, where structures and spaces are modelled as objects, and the 'homomorphism-like' function is modelled as a morphism. Cagtegories may be able to model specific instances of structures and spaces (groups, presets, etc.).



For every $\mathrm{hom}_{\mathcal{C}}(X,X)$ there exists a unique identity morphism


A small category is a category whose class of objects and morphisms are actually both sets.
A locally small category is a category whose morphism classes $\mathrm{Hom}(X,Y)$ are all sets.

\section{Commutative diagrams}

Commutative diagrams will be a powerful tool for studying category theory.

A commutative diagram is a diagram mapping arrows




\section{Examples of categories}

\subsection{Basic categories}

\subsection{Classes of strucutres and spaces}
- Category of sets and functions
- Category of groups and group homomorphisms
- Category of rings and ring homomorphisms
- Category of topological spaces and homeomorphisms
- Category of smooth manifolds and diffeomorphisms

\[\mathbf{Set}\] Category of sets
\[\mathbf{Ord}\] Category of posets
\[\mathbf{Mon}\] Category of monoids
\[\mathbf{Grp}\] Category of group
\[\mathbf{Grph}\] Category of graphs
\[\mathbf{Ring}\] Category of rings
\[\mathbf{Mod}(R)\] Category of R-modules
\[\mathbf{Vect}(F)\] Category of F-linear spaces
\[\mathbf{Rep}(F,G)\]?
\[\mathbf{Met}\] Category of metric spaces
\[\mathbf{Meas}\] Category of measure spaces
\[\mathbf{Stoch}\] Category of Markov processes
\[\mathbf{Top}\] Category of topological spaces
\[\mathbf{Man}(p)\] Category of $n$-differentiable manifolds
\[\mathbf{Sch}\]?
\[\mathbf{Cat}\] Category of small categories
\[\mathbf{Matr}(F)\]	Category of F-matrixes

Damn... that's like most of mathematics!


\subsection{Alternative definition of structures and spaces}
Though this is one way to use categories, one can define algebraic structures purely using categorical formalism.
















\section{Types of morphisms}


Categories will eventually be used to model classes of various structures, for. The objects are the structures themselves, whereas the morphisms will be the homomorphisms between structures. A special class of morphisms are 'bijective' isomorphisms, but our definition of a category doesn't actually define morphisms as classical functions, but rather synthetic objects whose categorical algebra on $\circ$ acts like composition of homomorphisms. Furthermore, bijectivity has nothing to do with the 'isomorphisms' of topological spaces (homeomorphisms).

Therefore instead of relying on bijectivity to introduce an analogue to isomorphisms, we define categorical isomorphisms as morphisms with inverse morphisms; this is a concept easily expressed in algebraic terms.

\begin{definition}[Categorical isomorphism]
%If there exists a categorical isomorphism between objects $X,Y$ then we say that $X$ and $Y$ are \emph{isomorphic}.
Let $\mathcal{C}$ be a category, a \emph{categorical isomorphism} is a morphism $f \in \mathrm{hom}_{\mathcal{C}} (X,Y)$ that has some 'inverse morphism' $f^{-1}$ in the following sense.
\[f^{-1} \circ f = 1_{X} \]
\[f \circ f^{-1} = 1_{Y} \]
%\[f \in \mathrm{hom}_{\mathcal{C}}(X,Y) \text{ is a categorical isomorphism } \iff X \cong Y \iff \exists f \in \mathrm{hom}_{\mathcal{C}}(X,Y), f^{-1} \in \mathrm{hom}_{\mathcal{C}}(Y,X) [ f \circ f^{-1} =1_Y \land f^{-1} \circ f = 1_X ]\]
\end{definition}


We may also use morphisms to injective functions by algebraic behaviour
\begin{definition}[Categorical monomorphism]
	\[ f \in \mathrm{hom}_{\mathcal{C}}(X,Y) \text{ is a categorical monomorphism } \iff \forall U \in \mathrm{ob}(\mathcal{C}) [ \forall g_1 , g_2 \in \mathrm{hom}_{\mathcal{C}}(U,X) (f \circ g_1 = f \circ g_2 \implies g_1 = g_2 )  ] \]
\end{definition}


one can do something similar for surjectivity

\begin{definition}[Categorical epimorphism]
\[ f \in \mathrm{hom}_{\mathcal{C}}(X,Y) \text{ is a categorical monomorphism } \iff \forall U \in \mathrm{ob}(\mathcal{C}) [ \forall g_1 , g_2 \in \mathrm{hom}_{\mathcal{C}}(U,X) ( g_1 \circ f =  g_2 \circ f \implies g_1 = g_2 )  ] \]
\end{definition}


and then bijectivity being an injective and surjective function means an isomorphism is a monomorphism epimorphism

We defined categorical isomoprhisms as those with inverse morphisms; this implies isomoprhisms are both epi and mono morphisms, but this condition doesn't imply an isomoprhism. Indeed in Set isomorphisms are the mrophisms that are both monomorphisms and epimorphisms but this is rather a necessary condition of isomophisms than a sufficient one in general categories.



\begin{definition}[Categorical endomorphism]
Morphism whose domain and codomain are the same
\end{definition}

\begin{definition}[Categorical automorphism]
Categorical isomorphism whose domain and codomain are the same
\end{definition}




\section{Types of categories}
Discrete category
A discrete category is a category whose morphisms are all identity


\begin{definition}[Subcategory]
A \emph{subcategory of $\mathcal{C}$} is a category $\mathcal{D}$ with the following
\begin{itemize}
	\item $\mathrm{ob}(\mathcal{D}) \subseteq \mathrm{ob}(\mathcal{C})$
	\item $\forall x,y \in \mathrm{ob}(\mathcal{D}) [ \mathrm{hom}_{\mathcal{D}}(X,Y) \subseteq \mathrm{hom}_{\mathcal{D}}(X,Y) ] $
\end{itemize}
\end{definition}


\[\mathbf{Finset}\] Category of finite sets
\[\mathbf{Nonset}\] 



\begin{definition}[Product category]
$\mathcal{C}\times \mathcal{D}$
Objects $(X,Y)$ X in obj(C) Y in obj(D)
Morphisms $(f,g) : (X_1,Y_1) \to (X_2,Y_2)$ f in hom(C) g in hom(D)
$(f_2,g_2) \circ (f_1 , g_1) = (f_2 \circ f_1 , g_2 \circ g_1)$
\end{definition}


\begin{definition}[Morphism category]
$\mathrm{Arr}(\mathcal{C})$
Objects $f : X \to Y$ in hom(C)
Morphisms $(u,v) : f \to g$ with $u : dom(f) \to dom(g)$ and $v : codom(f) \to codom(g)$ such that the following commutes
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJYXzEiXSxbMCwxLCJZXzEiXSxbMSwwLCJYXzIiXSxbMSwxLCJZXzIiXSxbMCwxLCJmIiwyXSxbMiwzLCJnIl0sWzAsMiwidSJdLFsxLDMsInYiLDJdXQ==
\[\begin{tikzcd} {X_1} & {X_2} \\ {Y_1} & {Y_2} \arrow["u", from=1-1, to=1-2] \arrow["f"', from=1-1, to=2-1] \arrow["g", from=1-2, to=2-2] \arrow["v"', from=2-1, to=2-2] \end{tikzcd}\]



$(f_2,g_2) \circ (f_1 , g_1) = (f_2 \circ f_1 , g_2 \circ g_1)$

\end{definition}

\begin{definition}[Comma category]
\end{definition}

\begin{definition}[Skeletal category]
category where isomorphic objects are equal.
\end{definition}

\subsection{Dual category}

\begin{definition}[Dual category]
category with morphism domains and codomains swapped to codomains and domains
\[\mathcal{C}^{\mathrm{op}}\]
\end{definition}

Dual of dual is the category itself
Dual of a discrete category is the category itself





\section{Universal constructions}

Abstract constructions.

\subsection{Initial and terminal objects}

\begin{definition}[Initial object]
object $0$ such that for any other object $X$ there is a unique morphism with $f : 0 \to X$
% https://q.uiver.app/#q=WzAsMixbMCwwLCIwIl0sWzAsMSwiWCJdLFswLDEsImYiXV0=
\[\begin{tikzcd} 0 \\ X \arrow["f", dashed, from=1-1, to=2-1] \end{tikzcd}\]
\end{definition}


\begin{definition}[Terminal object]
object 1 such that for any other object $X$ there is a unique morphism with $f : X \to 1$
\[\begin{tikzcd} 1 \\ X \arrow["f", dashed, from=2-1, to=1-1] \end{tikzcd}\]
\end{definition}


\begin{definition}[Zero object]
object that is both initial and terminal
\end{definition}



\begin{proposition}
Initial objects of $\mathcal{C}$ are terminal objects of $\mathcal{C}^{\mathrm{op}}$
\end{proposition}

initial and terminal objects are unique up to isomorphism


Grp has a zero object






\subsection{Product}


Note that in various areas on mathematics, there are various constructions faithful to the idea of 'product spaces', cartesian product of sets, direct product of algebraic structures, product of topological spaces etc.
Let's use category theory to generalize the idea of these constructions.

The idea from a set theoretic view is that these product constructions are built upon the idea of \emph{projections}, and that any function is equivalent to some composition of a function to the cartesian product with appropriate projection. The idea is that any function can be represented as one to a cartesian product space and then projected back onto the propert codomain.
\begin{definition}[Product of 2 objects]
A \emph{product of $X_1,X_2$} is the 3-tuple $(X_1 \times X_2,\pi_1 , \pi_2)$ of an object $X_1 \times X_2$ with projection morphisms $\pi_1 : X_1 \times X_2 \to X_1,\pi_2 : X_1 \times X_2 \to X_2$ that obeys the commutative diagram (if it exists), where there exists a unique $f$ for any $f_1,f_2$.	
\[\begin{tikzcd}
& Y & \\
{X_1} & {X_1 \times X_2} & {X_2}
\arrow["{f_1}"', from=1-2, to=2-1]
\arrow["f", dashed, from=1-2, to=2-2]
\arrow["{f_2}", from=1-2, to=2-3] 
\arrow["{pi_1}", from=2-2, to=2-1] 
\arrow["{pi_2}"', from=2-2, to=2-3] 
\end{tikzcd}\]
\end{definition}


Products are unique up to isomorphism

Product in Set are cartesian products
Product in $(\mathbb{N},|)$ is GCD

We can also define product maps;






\begin{definition}[Product of a family of objects (category theory)]
A \emph{product of $(X_{i})_{i \in I}$} is following object $X$ with projection morphisms $\pi_i : X \to X_i$ that obeys the commutative diagram (if it exists),.	
\[\begin{tikzcd}
& Y & \\
{X_i} & {X}
\arrow["{f_i}"', from=1-2, to=2-1]
\arrow["f", dashed, from=1-2, to=2-2]
\arrow["{pi_i}", from=2-2, to=2-1] 
\end{tikzcd}\]
	\[X=\prod_{i \in I} X_i\]
\end{definition}


\subsection{Equalizer}


Recall that equalizers in mathematics are a subset of some family of function's domain such that all functions map to the same image elemet (have the same mapping).
\[\mathrm{Eq}(f,g) = \{ x \in X : f(x)=g(x) \}\]
\[\mathrm{Eq}(\mathcal{F}) = \{ x \in X : \forall f,g \in \mathcal{F} [  f(x)=g(x) ] \}\]


One can extend the notion of an equalizer set to exist in general categories, just as the cartesian product set was generalized to other categories.
Given morphisms $f : X \to Y,g : X \to Y$ with equalizer $\mathrm{Eq}(f,g)$, we can use the inclusion function $i : \mathrm{Eq}(f,g) \to X$ (takes elements of equalizer to the larger domain) from some equalizer object to the commond domain. For $\mathrm{Eq}(f,g)$ to act as an equalizer, we want $f \circ i = g \circ i$.

The equalizer set is also maximal in the sense that it contains all the domain elements with equal mappings, rather than a portion of them. To handle this, we ensure that any other function $u$ with $f \circ u = g \circ u$ can be 'factored' (broken down as a unique composition) by some $u=i \circ k$. $i$

To generalize this, use an equalizer object $E$ and equalizer morphism $i$ to ensure the domain is the set acting like the equalizer. Futhermore, we want that any other morphism where $f \circ u = g \circ u$ can be represented in terms a unique morphism composed with our equalizer $u = i \circ k$


we call $i$ the equalizer, this is defined in such a way that all 'equalizing morphisms' must go through $E$
$i$ is a equalizer of $f,g$ iff for any $h$ in this commutative diagram is the composition of some unique function with $i$

%\[\begin{tikzcd}  E && X && Y \  & Z  \arrow["i", hook, from=1-1, to=1-3]  \arrow["g"', shift right, from=1-3, to=1-5]  \arrow["f", shift left, from=1-3, to=1-5]  \arrow["k", dashed, from=2-2, to=1-1]  \arrow["h"', from=2-2, to=1-3] \end{tikzcd}\]


\begin{definition}[Equalizer]
Given 2 morphisms $f,g \in \mathrm{Hom}(X,Y)$ an \emph{equalizer of $f,g$} is a ordered pair $(\mathrm{Eq}(f,g),i)$ of an object $\mathrm{Eq}(f,g)$ and inclusion morphism $i :\mathrm{Eq}(f,g) \to X $ that satisfies the following univeral property.

% https://q.uiver.app/#q=WzAsNCxbMCwwLCJcXG1hdGhybXtFcX0oZixnKSJdLFsxLDAsIlgiXSxbMiwwLCJZIl0sWzAsMSwiQyJdLFswLDEsImkiXSxbMSwyLCJnIiwyLHsib2Zmc2V0IjoxfV0sWzEsMiwiZiIsMCx7Im9mZnNldCI6LTF9XSxbMywxLCJoIiwyXSxbMywwLCJrIiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d \[\begin{tikzcd} {\mathrm{Eq}(f,g)} & X & Y \\ C \arrow["i", from=1-1, to=1-2] \arrow["g"', shift right, from=1-2, to=1-3] \arrow["f", shift left, from=1-2, to=1-3] \arrow["k", dashed, from=2-1, to=1-1] \arrow["h"', from=2-1, to=1-2] \end{tikzcd}\]

\end{definition}

\begin{proposition}
Equalizers are monomorphisms
\end{proposition}


\begin{proposition}
epimorphism equalizers are isomorphism
\end{proposition}


\subsection{Pullback}


Given 2 morphism, the idea is that one can use composition 'pull back' the domain of either morphisms to receive a common morphism. with functions $f$ and $g$, a pullback is the pair of morphisms $p_1 , p_2$  that allow $f \circ p_1 = g \circ p_2$.

\begin{definition}[Pullback]

Given 2 morphisms $f \in \mathrm{Hom}(X,Z), g \in \mathrm{Hom}(Y,Z)$, a \emph{pullback of $f,g$} is a 3-tuple $(X\times_Z Y,p_1 ,p_2)$ such that the following commutative diagram commutes
% https://q.uiver.app/#q=WzAsNCxbMSwwLCJYIl0sWzEsMSwiWiJdLFswLDEsIlkiXSxbMCwwLCJQIl0sWzIsMSwiZyIsMl0sWzAsMSwiZiJdLFszLDIsInBfMiIsMl0sWzMsMCwicF8xIl1d
	\[\begin{tikzcd} P & X \\ Y & Z \arrow["{p_1}", from=1-1, to=1-2] \arrow["{p_2}"', from=1-1, to=2-1] \arrow["f", from=1-2, to=2-2] \arrow["g"', from=2-1, to=2-2] \end{tikzcd}\]

Furthermore all other pullbacks $(Q,q_1,q_2)$ satisfies the following commutative diagram
% https://q.uiver.app/#q=WzAsNSxbMiwxLCJYIl0sWzIsMiwiWiJdLFsxLDIsIlkiXSxbMSwxLCJQIl0sWzAsMCwiUSJdLFsyLDEsImciLDJdLFswLDEsImYiXSxbMywyLCJwXzIiLDJdLFszLDAsInBfMSJdLFs0LDAsInFfMSIsMCx7Im9mZnNldCI6LTJ9XSxbNCwyLCJxXzIiLDIseyJvZmZzZXQiOjJ9XSxbNCwzLCJxIiwxLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiZGFzaGVkIn19fV1d 
\[\begin{tikzcd} Q && \\ & P & X \\ & Y & Z \arrow["q"{description}, dashed, from=1-1, to=2-2] \arrow["{q_1}", shift left=2, from=1-1, to=2-3] \arrow["{q_2}"', shift right=2, from=1-1, to=3-2] \arrow["{p_1}", from=2-2, to=2-3] \arrow["{p_2}"', from=2-2, to=3-2] \arrow["f", from=2-3, to=3-3] \arrow["g"', from=3-2, to=3-3] \end{tikzcd}\]
\end{definition}

This second commutative diagram narrows our definition of pullbacks to be unique up to isomorphism.
