The previous section has introduced the following key concepts:

These are the concepts manipulated in category theory.

Categories are defined over mathematical sets of objects and morphisms. Sets are different from simple “collections” (or “bag”) of things from the real world: all their elements are distinct, according to some equivalence relation.

So in order to talk about categories over things from the real world, we must first choose how to define the mathematical sets. This choice is called a model and multiple models are possible for the same collection of things.

The most focus should be given to the set of morphisms. The set of objects is simply derived from it once the morphisms are properly identified. For example, in our pipes example, considering what happens to data streams. What does it mean for two processes to be equal or different?

We can choose for example “data stream equality”. By this standard, two processes that filter out lines containing the text “foo” over any data stream are the “same thing.” So “ sed '/foo/d' ” and “ grep -v foo ” are the same morphism.

If we choose this definition for morphisms, then the objects are not individual files (or time-particular datastreams over FIFOs), but rather entire classes of all possible data streams that compare equal to each other byte by byte. For example, a stream that delivers “helloworld” in one go is the same stream as another that delivers “hello” and then “world” 5 seconds later.

Another possible choice for a definition is “physical equality”. By this standard, two processes that run at different times or in different physical regions of the system are distinct, even if they perform the same task. So two processes run from the same command (eg cat ) at different times end up as different morphisms in the set.

If we choose this definition, then the mathematical objects are not only data streams, but also where and when the bytes are physically encoded. So two streams that deliver “helloworld” in different places/times are distinct objects.

The rule of thumb while choosing a definition is the following: if one wants to talk about categories over sets of objects and morphisms that are already mathematically defined, then all is well. If one wants to use category theory over things that are not yet mathematical, be careful to explain clearly and explicitly how they are modeled using mathematical sets, and which equivalence relation is used.

For the next sections, we use the following definitions: