These are my lecture notes on Bartosz Milewski's course on category theory. These are not meant as a comprehensive guide but rather a loose collection of definitions and short summaries.

A category has two properties:

Morphisms between any two objects form a set called the

A morphism \(f: a \rightarrow b\) is called

- an
**epimorphism**(or**epic**) if it is right-cancellable, i.e. \(g_1 \circ f = g_2 \circ f\) implies \(g_1 = g_2\) for all \(c\) and all \(g_1, g_2: b \rightarrow c\) - a
**monomorphism**(or**monic**) if it is left-cancellable, i.e. \(f \circ g_1 = f \circ g_2\) implies \(g_1 = g_2\) for all \(c\) and all \(g_1, g_2: c \rightarrow a\) - a
**bimorphism**if it is both a monomorphism and an epimorphism - An
**isomorphism**if it has an inverse, i.e. if there exists an morphism \(f^{-1}: b \rightarrow a\) with \(f^{-1} \circ f = id_a\) and \(f \circ f^{-1} = id_b\).

In

Also notice the distinction between isomorphisms and bimorphisms. While in set theory a function that is bijective (both injective and surjective) is invertible, in category theory a bimorphism (which is both epic and monic) is not necessarily invertible (an isomorphism).

- Boolean represents the set \( \{True, False\}\)
- Int represents a subset of \(\mathbb{N}\)
- Float/Double represents a subset of \(\mathbb{Q}\)

If we go in the other direction we can ask which type in programming specific (special) sets correspond to:

We can define the following (uncallable) functions with Void in Haskell:

```
absurd :: Void → a
id_void :: Void → Void
```

`a → Void`

. (If we called it with any argument, what could it return?)In mathematical logic, types/objects correspond to propositions and functions correspond to proofs. Therefore, the existence of a function between two propositions is equivalent to the existence of a proof. This ties in well with the functions we defined above if we take the type Void to correspond to

- The function
`absurd :: Void → a`

exists, this corresponds to the fact that we can proof anything from starting from false assumptions. ("All even numbers are primes \(\implies\) 20 is a prime") - There exists no function of type
`a → Void`

, we cannot prove falsity. (You cannot prove something that's false, it has no proof)

`()`

and we can build the `unit`

function with it:```
unit :: a → ()
```

`() → a`

. These individual functions are constant. In this way we can express elements of a set as functions, or in category theory as morphisms.For example for type Bool we can define the functions

```
true :: () → Bool
true _ = True
false :: () → Bool
false _ = False
```

`() → a`

correspond to picking elements of sets.Such an object

`()`

(called `Bool`

. It can also be defined as the sum of two units.
A function that returns a boolean is called a predicate.Sidenote: There is an important difference between pure functions in programming and mathematical functions. Mathematical functions instantly evaluate to a certain result while functions in programming may not terminate. To avoid this issue a special element called

Therefore weak and strong typing aren't actually distinct concepts but instead is weak typing inside strong typing.

- Add identiy arrows to each node/object (if they do not exist yet).
- For every pair of composable arrows \(f, g\), add their composition \(g \circ f\). Keep in mind that because of associativity, not all compositions have to be added (\((f \circ g) \circ h = f \circ (g \circ h)\)).

This method of creating a category is called

An algebraic monoid is a set along with an associative operation and a neutral element.

- Each element in the set along with the operation corresponds to a morphism from and to the single object.
- The neutral element corresponds to the identity morphism.
- The associativity of the operation corresponds to the associativity of morphism composition.

For example take the algebraic monoid of the natural numbers under addition. The associated monoid in category theory is a single object along with arrows, each corresponding to an element from \(A = \{+0, +1, +2, +3, \ldots\}\). We choose \(+0\) to be the identity morphism (\(\forall a \in A[ (+0)\circ a = a \land a\circ (+0) = a]\)). Since addition is associative, morphism composition is also associative.

In this way we can always create a category monoid from an algebraic monoid and vice versa.

In a thin category a bimorphism is not necessarily invertible (i.e. an isomorphism).

- A
**preorder**is an order that is reflexive and composable (transitive). Every preorder is a thin category since for every pair of objects \((a, b)\) the hom-set is either empty (when \(a \nleq b\)) or a singleton set (when \(a \le b\)). - A
**partial order**is a preorder that is also antisymmetric. (It is therefore relexive, transitive and antisymmetric) A partial order induces a directed acyclic graph. A partially ordered set is called a poset. - A
**total order**is a partial order that is also connex (defined for any two objects - either \(a \le b\) or \(b \le a\)).

\(\le\) is a total order on \(\mathbb{R}\). It satisfies the requirements for categories (associative composability and identity) since it is a transitive and reflexive relation (composition is associative because there can never be more than one arrow between a pair of objects). It furthermore is transitive, antisymmetric and defined for any two real numbers.

The mapping from \(a\) to \((m, a)\) is called a

The singleton set has the

Any sequence of arrows that lead from \(a\) to the terminal object \((\,)\) can be reduced through composition to a single arrow from \(a\) to \((\,)\). By the definition of the terminal object, this arrow is unique (for all paths, the composition is the same unique arrow). From this follows that all paths from \(a\) to \((\,)\) are in some sense equal.

Since orders are thin categories and in thin categories there can be at most one arrow from \(a\) to \(b\), only the condition for existence above is relevant. In an order there exists an arrow \(a → b\) if \(a \le b\). Therefore for \(\forall a\, \exists f\colon a →(\,)\) to hold we know that \(\forall a\colon a \le (\,)\) must be true. From this follows that the terminal object of an order is largest object in the order. Such an object does not necessarily exist (for example in \(\mathbb{N}\)).

The empty set has the universal and uniquely defining property that it has exactly one outgoing arrow (the function

This motivates the definition of

A category can have any number of terminal or initial objects.

Let \(a\) and \(b\) be terminal objects of a category. Then by the definition of terminal objects there exist unique morphisms \(f\colon a→b\) and \(g\colon b→a\). Let \(h=g\circ f\). Therefore \(h\) goes from \(a\) to \(a\). By the definition of a terminal object there can only be a single arrow from \(a\) to \(a\) so the identity \(\text{id}_a\) and \(h\) must be the same. Analogous for \(k=f\circ g\).

Therefore \(f \circ g = \text{id}_b\) and \(g \circ f = \text{id}_a\) which is the definition of an isomorphism. This isomorphism is unique since \(f\) and \(g\) are unique.