The general theory of categories. A category is a tuple $$\mathcal{C} = (O,A,\circ,dom,cod)$$ where

- $O$ is a collection of objects.
- $A$ is a collection of arrows. These are also called morphisms.
- $dom$ and $cod$ assigns to each arrow $f$ an object. For $dom$ the object is called the domain of the arrow. For $cod$ it is called the co-domain. For $dom\ f = A$ and $cod\ f = B$ we write $f : A \rightarrow B$. The collection of arrow with $A$ as domain and $B$ as codomain is written as $\textbf{C}(A,B)$.
- $\circ$ is a binary operator that assigns to each pair of arrows $f : A \rightarrow B$ and $g: B \rightarrow C$ a composite arrow $g \circ f : A \rightarrow C$. Note that in order for this operator to be well defined, we must have that $cod\ f = dom\ g$. For arrows we have the following two axioms:
- Associativity: For any objects $A,B,C,D \in \mathcal{C}$ and any arrows $f : A \rightarrow B,g : B \rightarrow C, h : C \rightarrow D \in \mathcal{C}$ we have that $$ f \circ (g \circ h) = (f \circ g) \circ h $$
- Identity: We have one arrow $id \in \mathcal{C}$ for which for every $f \in \mathcal{C}$ we have that $$ f \circ id = id \circ f = f $$

- Associativity: For any objects $A,B,C,D \in \mathcal{C}$ and any arrows $f : A \rightarrow B,g : B \rightarrow C, h : C \rightarrow D \in \mathcal{C}$ we have that $$ f \circ (g \circ h) = (f \circ g) \circ h $$

The axioms closely resembles those for a a monoid.

The category **Set** has sets as objects and total functions between these sets as arrows. That is

- $O$ is a collection of sets. Or the set of all sets.
- $A$ are total functions between sets. This is how we normally define a function between sets, eg. $$ f : \mathbb{R} \rightarrow \mathbb{R} $$ for the function that maps elements real numbers to real number.
- The composition of two arrows are as expected when composing two functions. That is for $f : A \rightarrow B$ and $g : B \rightarrow C$ we get $$ g \circ f : A \rightarrow C $$ where for $a \in A$ we have $g(f(a)) \in C$.
- For any set $A$ we have $id_A$ - that is a total function that maps elements from $A$ to itself.

For any algebra we have a category where the objects are instances of this algebra, and where the arrows are homomorphisms between these instances. For example for monoids we have the category **Mon** for which:

- The objects are monoids.
- The arrows are monoid homomorphism. That is a function $\varphi : M_1 \rightarrow M_2$ from a monoid to a monoid for which $$ \varphi(a \star b) = \varphi(a) \diamond \varphi(b) $$ where $a,b \in M_1$ and $\varphi(a),\varphi(b) \in M_2$.

A partial order $\leq$ on a set $P$ is a relation that is *reflexive*, *transitive* and *anti-symmetrical*. That is

*reflexive*: For $a \in P$ we have that $a \leq a$*transitive*: For $a,b,c \in P$ we have that $a \leq b \land b \leq c \Rightarrow a \leq c$.*anti-symmetrical*: For $a,b \in P$ we have that $a \leq b \land b \leq a \Rightarrow a = b$.

This gives rise to a category with partial ordered sets as objects and order preserving (monotone) total functions as arrows.

The category $0$ has no objects and no arrows.

The category $1$ has one object and one arrow - the arrow $id$ from the one objects to itself.

The category $2$ has two objects, two identity arrows and one extra arrow from the one object to the other.

The category $3$ has three objects, three identity arrows and three arrows between objects. Say the objects are $A,B,C$. Then the three arrows are $$f : A \rightarrow B, h : A \rightarrow C, g : B \rightarrow C$$

As stated earlier the axioms for arrows within a category resembles those of a monoid. For a monoid $(M,\cdot,e)$ we can form a category where

- We have one object, namely the set $M$.
- The arrows are elements of $M$.
- $e$ is represented by the identity arrow.
- The operator $\cdot$ is represented by the composition of arrows, that is $\circ$.

This goes the other way too: Every category with a single object gives rise to a monoid. For example the category $1$ could be interpreted as the monoid $$ (\{1\},\cdot,1) $$ where the operator is normal multiplication.

Given a partial ordered set $(P,\leq)$ we can construct a category where the objects are elements of $P$ and there is a arrow from objects $p$ and $p'$ if and only if $p \leq p'$. Now we have that

- Given two arrows $f : p \rightarrow p',g : p' \rightarrow p''$ we must have $g \circ f : p \rightarrow p''$. Hence if $p \leq p'$ and $p' \leq p''$, we have that $p \leq p''$.
- We have $id : p \rightarrow p$ in this category. Hence we are ensured to have $p \leq p$.

We disregard anti symmetry. This is called a preorder. Every preorder set gives rise to a category.