How are objects abstracted from concrete concepts in category theory

category-theoryprogramming

I've started reading Category Theory for programmers with the objective of understanding the basics of category theory (and how it can instruct programming patterns).
I've so far understood the basic concepts of categories objects and morphisms mapping to graphs with named edges that need to compose and the need to always have an identity morphism per object.
The thing I can't seem to wrap my head around is how these categories are constructed from less abstract concepts like sets.
In particular, the book uses different more concrete concepts to ease the reader into thinking in term of categories.
I will use chapters from the book as reference in addition to resuming my understanding.

In the chapter 3.3, the writer introduce a category formed from a set of integers and the relation "$<=$". I understand that in this case objects are the different numbers of the set, and the morphisms are the relations between the numbers, with the identity morphism and the composition that it brings.

In the chapter 3.4, the writer brings us to the concept of a monoid as a category, and it is here I get confused.
He describes the monoid as a category with one object and a multitude of morphisms on this object — with for example the monoid of the addition having the morphisms "+0" (identity), "+1", …

I understand that object can be sets (or anything really), but I can't understand why the category of a monoid needs to be represented with only one object. It seems to me that the category for a monoid can also be represented with an object for each element of the set, and morphisms (in the case of the addition monoid, the +0, +1, …) going between the different objects.
We keep the identity on each object (the +0), and we keep the composability of the morphisms between objects (a morphism of +2 from object A to object B and a morphism of +3 from B to C will correspond to a morphism of +5 from A to C).

I understand that I'm not supposed to care about the objects themselves, and that only their relation to the morphisms matter, but I can't see how I should decide whether to convert elements or sets or whatever.

What am I missing the make this question nonsensical;
Or am I just supposed to try to abstract the objects until I can't anymore, and then say it's the category of what I am studying (so in the example of a monoid for the addition on integers, while I could do it with integers as objects, since I could also do it with the set of integers as object, I should go with the more abstract one)?

Best Answer

It's a mistake (or at least imprecise) to say a monoid is a category with 1 element. But there is a canonical equivalence between monoids and 1-element (small) categories.

Recall that a monoid consists of a set $M$, together with a binary operation $\cdot$ and an element $e$, which satisfies the three equational laws $x \cdot e = x$, $e \cdot x = x$ and $(x \cdot y) \cdot z = x \cdot (y \cdot z)$.

Let's immediately note that for any (locally small) category $C$ and any object $A \in C$, there is a monoid structure on $Hom_C(A, A)$. The composition law is $\cdot = \circ$, and the identity is $e = 1_A$. So categories are filled with monoids. Call this monoid $M_{C, A}$.

On the other hand, for any monoid $M$, consider the category $C_M$ with one object $\star$, and with $Hom_{C_M}(\star, \star) = M$, with $1_\star = e$, and with $a \circ b = a \cdot b$ for all $a, b \in Hom_{C_M}(\star, \star) = M$. It's easy to verify the category laws on $C$ - they are just the three laws of the monoid.

And of course, you get that

$$M_{C_M, \star} = M$$

by definition. Furthermore, for any 1-element category $C$ where the 1-element is $\star$, you have

$$C = C_{M_{C, \star}}$$

again by definition.

This means that any theorem you can prove about all categories can be specialised to the case of 1-element categories, which can then become a theorem about monoids.

This is not to say that we "need" to represent monoids in this way. But it is a very helpful way to represent monoids.

Another way of taking a monoid $M$ and producing a category from it is considering the category $D_M$ where the objects are elements $m \in M$, and $Hom_{D_M}(n, m) = \{j \mid j \cdot n = m\}$, with the composition law being $\cdot$. It turns out that this representation can be obtained from the 1-element category representation $C_M$ using two general categorical constructions - the Yoneda functor and the "category of elements" - which you probably haven't learned about yet. So there isn't really a good reason to use this representation as far as I know.

Related Question