Composition of monoid and category - which one is more generic?

145 Views Asked by At

My questions is about difference (if any) of compositions delivered by monoid and category from the category theory (i.e. objects + morphisms between them). Clearly, both are associative. Both are closed under some type. The only difference I see is that monoid supposed to compose it's elements into yet another element of the same type, however category composes morphisms - some kind of relation holding for a pair of it's objects.

Thus, for monoid $\mathbb{M}$ I would define composition as $f : (a \in \mathbb{M}, b \in \mathbb{M}) \mapsto c \in \mathbb{M}$. Category's composition looks slightly "more generic": let $\mathbb{C}$ denote a category, then composition is $f : ( \underbrace{(a \in \mathbb{C}, b \in \mathbb{C})}_\text{morphism} , \underbrace{(b \in \mathbb{C}, c \in \mathbb{C})}_\text{morphism} ) \mapsto (a \in \mathbb{C}, c \in \mathbb{C})$.

Assuming I am not mistaken so far, does that minor difference make category "more generic" in any sense? Is there any definition of being "more generic"? Do I miss something here?

2

There are 2 best solutions below

3
On BEST ANSWER

As a prelude, I strongly recommend using more common notation. I would go further and say that the notation you are using (in this and other questions) is not only not common but actually wrong/meaningless, and whatever is motivating you to use this notation is the cause of some of your confusions. Specifically, when we talk about a function (or generally an arrow) between two sets (objects), we usually use the notation $f:X \to Y$. If we wanted to concretely define what $f$ did on elements of $X$, we would usually write something like $f(x)=(\dots)$, but we could equivalently write $f = x\mapsto(\dots)$. The $\mapsto$ notation lets us specify a function without needing to give it a name, e.g. we could write $x \mapsto x^2 : \mathbb R \to \mathbb R$. You correctly do this in a previous answer where you write $a\mapsto a^{-1}$, but you also write things like $A\mapsto A$ for $A\to A$ which is misleading. Functors, for example, are often written as functions on objects so $A\mapsto A$ looks like the identity functor (e.g. $A\mapsto A:\mathcal C \to \mathcal C$). In this question, you have $f:(a\in\mathbb M,b\in\mathbb M)\mapsto c\in\mathbb M$. It's not clear what you mean with this. It seems to be some attempt to combine $f:\mathbb M\times\mathbb M\to\mathbb M$ and $f(a,b)=c$ (i.e. $f=(a,b)\mapsto c$). The latter is either ambiguous or useless or just wrong. It looks like you're saying that $f$ is the constantly $c$ function, but that is clearly not your intent. My impression is you intend it to mean something like: "$f$ maps $(a,b)\in\mathbb M\times\mathbb M$ to some $c\in\mathbb M$", but this says nothing more than $f:\mathbb M\times\mathbb M\to\mathbb M$. In your attempted description of the categorical composition it just becomes convoluted and rather unclear what you are trying to say. Trying to generalize from your monoid example, you seem to be saying that $f((a,b),(b,c))=(a,c)$ which, ignoring the misunderstanding of hom-sets momentarily, doesn't fully define $f$, i.e. what happens for $f((a,b),(b',c))$ where $b\neq b'$? Using the more common notation, it seems like you are saying categorical composition is a function $f:(\mathbb C\times\mathbb C)\times(\mathbb C\times \mathbb C)\to\mathbb C\times\mathbb C$ where $\mathbb C$ is the set of objects of the category. This is not the case at all.

Now to start addressing your specific question, there are two more or less equivalent ways of presenting the definition of a (small) category. One approach states that a category $\mathbb C$ is a set of object $\mathsf{Ob}(\mathbb C)$ and an $\mathsf{Ob}(\mathbb C)\times\mathsf{Ob}(\mathbb C)$-indexed family of sets, the hom-sets, written $\mathsf{Hom}(A,B)$ for $A,B\in\mathsf{Ob}(\mathbb C)$. Additionally, for each $A\in\mathsf{Ob}(\mathbb C)$ we have an element of $\mathsf{Hom}(A,A)$ which we write as $id_A$, and we have a family of functions indexed by triples of objects, the compositions $c_{ABC}:\mathsf{Hom}(B,C)\times\mathsf{Hom}(A,B)\to\mathsf{Hom}(A,C)$ for $A,B,C\in\mathsf{Ob}(\mathbb C)$ which satisfies some laws which I'll omit here. An arbitrary hom-set for any $A,B\in\mathsf{Ob}(\mathbb C)$, $\mathsf{Hom}(A,B)$, can be any set. An arrow is just an element $f\in\mathsf{Hom}(A,B)$ for some pair of objects $A$ and $B$. We write $f\in\mathsf{Hom}(A,B)$ equivalently as $f:A\to B$. Since $\mathsf{Hom}(A,B)$ can be any set, $f\in\mathsf{Hom}(A,B)$ can be anything at all. In particular, $f$ does not need to be a function. Similarly, $\mathsf{Ob}(\mathbb C)$ is also an arbitrary set, so an $A\in\mathsf{Ob}(\mathbb C)$ can also be anything at all. In the particular case where the category is the category of sets (which isn't small), then $\mathsf{Hom}(A,B)$ for sets $A$ and $B$ is the set of functions from $A$ to $B$, and so viewing $f:A\to B$ as $f\in\mathsf{Hom}(A,B)$ is a strict generalization of the use of that notation for set functions. All told, all this structure looks nothing like a monoid, but it degenerates to (almost) a monoid in the case that $\mathsf{Ob}(\mathbb C)=\{X\}$ for some arbitrary $X$.

Another, equivalent presentation of the definition of categories is the following. A category $\mathbb C$ consists of a set of objects $\mathsf{Ob}(\mathbb C)$, a set of arrows $\mathsf{Arr}(\mathbb C)$, and a pair of functions $\mathsf{src},\mathsf{tgt}:\mathsf{Arr}(\mathbb C)\to\mathsf{Ob}(\mathbb C)$. Additionally, we have a function $id_{(-)}:\mathsf{Ob}(\mathbb C)\to\mathsf{Arr}(\mathbb C)$ satisfying $\mathsf{src}(id_A)=A=\mathsf{tgt}(id_A)$ for all $A\in\mathsf{Ob}(\mathbb C)$, and we have a partial function $c:\mathsf{Arr}(\mathbb C)\times\mathsf{Arr}(\mathbb C)\rightharpoonup\mathsf{Arr}(\mathbb C)$ defined on pairs $(f,g)\in\mathsf{Arr}(\mathbb C)\times\mathsf{Arr}(\mathbb C)$ where $\mathsf{tgt}(g)=\mathsf{src}(f)$. Again, when $\mathsf{Ob}(\mathbb C)=\{X\}$ for some arbitrary $X$, then $\mathsf{tgt}(g)=\mathsf{src}(f)$ for all $f,g\in\mathsf{Arr}(\mathbb C)$ so $c$ becomes a total function and we get a monoid. From this perspective, the difference between a category and a monoid is almost exactly that the composition of a category is not necessarily closed or even defined for all inputs.

You should, as an exercise, spell out the details of how each of these presentations of the definition of a category map onto one another. As a concrete example that is designed to thwart many mistaken intuitions (and is also an important and useful example in and of itself), consider a category $\mathbb G$ defined in the following way given a directed graph $\mathcal G\subset V\times V$ where $V$ is a set of vertices. (I'll use the first presentation of the definition of category, as I think it is the better one.) Let $\mathsf{Ob}(\mathbb G)=V$ and for each vertex $u,v\in V$, let $\mathsf{Hom}(u,v)$ be the set of paths from $u$ to $v$, i.e. whose elements are finite lists, say $\langle x_1,\dots,x_n\rangle$, such that $(u,x_1)\in\mathcal G$ and $(x_n,v)\in\mathcal G$ and for any adjacent components in the list, we have $(x_i,x_{i+1})\in\mathcal G$. For precision, we also need to exclude the empty list unless $u=v$. For example, $\langle x,y\rangle\in\mathsf{Hom}(u,v)$ if $(u,x)\in\mathcal G$, $(x,y)\in\mathcal G$, and $(y,v)\in\mathcal G$. The empty list, $\langle\rangle$, is the identity element for every hom-set of the form $\mathsf{Hom}(u,u)$ for $u\in V$. Each composition function is just (flipped) list concatenation. You should, as another exercise, adapt this definition to the other presentation style of categories. A few minor wrinkles will present themselves.

0
On

Morphisms are "elements" of the category too.

A difficulty people sometimes have when learning about categories is they are overly focused on the objects, and conceive of a category as being made out of objects, with the morphisms some sort of derivative notion.

But that's not how it works; morphisms are just as important as elements of the category as the objects are. Arguably they are more important — one can actually define categories in a natural way entirely in terms of morphisms, but one cannot do so in terms of objects.

So, to help dispel this misconception, it is good to have examples of categories that are more focused on the morphisms. My favorite example is matrix algebra.

Explicitly, matrix algebra forms a category by defining

  • The morphisms are matrices
  • Composition of arrows is the matrix product
  • The objects are natural numbers
  • The source and target of an $m \times n$ matrix are $n$ and $m$ respectively

The matrix product is simply "matrix times matrix is matrix, when composable".

However, it is rather common to partition matrix algebra by dimension, and we express composition as "$m \times n$ matrix times $n \times p$ matrix is $m \times p$ matrix".

That's what's going on with abstract categories too. Composition is simply "morphism times morphism is morphism, when composable". But we usually prefer to partition the morphisms into hom-sets by their source and target, and express it as "a morphism from $a$ to $b$ times a morphism from $b$ to $c$ is a morphism from $a$ to $c$".

Categories are "more generic" than monoids in the sense that the notion of "monoid" is equivalent to the notion of "category with one object".


As an aside, if you're curious about the role of addition in matrix algebra, the relevant notion is "abelian category".