Terms
To define what a category is, we need to clarify a few terms. In many cases, we will use the term set, a collection of unique elements, and class for collections of sets. The use of the term class may depend on the foundational context, such as Zermelo–Fraenkel set theory or von Neumann–Bernays–Gödel set theory. For simplicity, we will use the term set if its elements have no additional properties and the term class if the elements represent structures with properties. Thus, we can define what a category is.
Definition: Category
A category is composed of:
- a set whose elements are called objects
- a set whose elements are called arrows or morphisms
- for each morphism there is a pair of objects called the domain and codomain of
- for every pair of morphisms where there is always a morphism (read after ) called the compound
- for each object there is always a morphism
- so that the following properties are satisfied:
- source and destination respect the composition: and
- source and destination respect the identity: and
- the composition is associative:
- the composition satisfies left and right unity:
An example of a category might be the following:
In principle, a category is a quiver, a directed graph with any number of edges between any two nodes. Here, two properties of the category are important: the fact that the composition of the morphisms is associative and preserves the identity. These properties will be used in the next concept, which is more related to functional programming, namely the functor.