# The Unapologetic Mathematician

## Products and Coproducts

Let’s consider the Cartesian product $X\times Y$ of two sets $X$ and $Y$. Classically we think of this as the set of all pairs $(x,y)$ with $x\in X$ and $y\in Y$. But we can also characterize it just in terms of functions.

Specifically, $X\times Y$ comes with two projection functions $\pi_X:X\times Y\rightarrow X$ and $\pi_Y:X\times Y\rightarrow Y$, defined by $\pi_X(x,y)=x$ and $\pi_Y(x,y)=y$. If we take any other set $S$ with functions $f_X:S\rightarrow X$ and $f_Y:S\rightarrow Y$ we can define the function $(f_X,f_Y):S\rightarrow X\times Y$ by $\left[(f_X,f_Y)\right](s)=(f_X(s),f_Y(s))$. Then we see that $\pi_X\circ(f_X,f_Y)=f_X$ and $\pi_Y\circ(f_X,f_Y)=f_Y$. Further, this function from $S$ to $X\times Y$ is the only such function.

Now let’s do away with those nasty elements altogether and draw this diagram:

What does this mean? Well, it’s like the diagram I drew for products of groups. The product of $X$ and $Y$ is a set $X\times Y$ with functions $\pi_X$ and $\pi_Y$ so that for any other set $S$ with functions to $X$ and $Y$ there exists a unique arrow to $X\times Y$ making the diagram commute. Since we’ve written this definition without ever really referring to elements we can just pick it up and drop it into any other category. Many descriptions of categorical products stop here, but let’s push a bit further.

Let’s consider a category $\mathcal{C}$ containing (among others) objects $X$ and $Y$. From this we’re going to build a new category. An object of our category will be a diagram that looks like $X\leftarrow^{f_X}S\rightarrow^{f_Y}Y$ in $\mathcal{C}$. A morphism from $X\leftarrow^{f_X}S\rightarrow^{f_Y}Y$ to $X\leftarrow^{f'_X}S'\rightarrow^{f'_Y}Y$ will be a morphism $S\rightarrow^{g}S'$ in $\mathcal{C}$ so that $f_X=f'_X\circ g$ and $f_Y=f'_Y\circ g$.

Now what’s a product in $\mathcal{C}$? It’s a terminal object of this category we’ve constructed! That is, it’s one of these diagrams so that every other diagram has a unique morphism (as defined above) to it. This definition makes sense in any category $\mathcal{C}$, though the category we build from a given pair of objects may not have a terminal object, so a given pair of objects of $\mathcal{C}$ may not have a product in $\mathcal{C}$. If every pair of objects of $\mathcal{C}$ has a product in $\mathcal{C}$, we say that $\mathcal{C}$ “has products”.

So, the existence of Cartesian products of sets shows that $\mathbf{Set}$ has products. Similarly, $\mathbf{Grp}$ has products, as do $\mathbf{Ring}$, $\mathbf{Gpd}$ (groupoids), $\mathbf{Cat}$ (small categories), and pretty much all our familiar categories from algebra.

What about something like a preordered set $(P,\preceq)$, considered as a category? What would “product” mean, when written in this language? Well, given elements $a$ and $b$ the product $a\times b$ will have arrows to $a$ and $b$, so $a\times b\preceq a$ and $a\times b\preceq b$. Also, for any other element $c$ with $c\preceq a$ and $c\preceq b$ we have $c\preceq a\times b$$c$ has an arrow to both $a$ and $b$, so it has an arrow to $a\times b$. That is, $a\times b$ is a greatest lower bound of $a$ and $b$, and the category has products if and only if every pair of elements has such a greatest lower bound.

And it gets better. If we consider a category $\mathcal{C}$ that has products, the product defines a functor $\times:\mathcal{C}\times\mathcal{C}\rightarrow\mathcal{C}$! If we have arrows $f_1:X_1\rightarrow Y_1$ and $f_2:X_2\rightarrow Y_2$ then I say we’ll have an arrow $f_1\times f_2:X_1\times X_2\rightarrow Y_1\times Y_2$. Indeed, if we consider $f_1\circ\pi_{X_1}:X_1\times X_2\rightarrow Y_1$ and $f_2\circ\pi_{X_2}:X_1\times X_2\rightarrow Y_2$ then we’ll get an arrow from $X_1\times X_2$ to $Y_1\times Y_2$. And this construction preserves compositions and identities. For compositions, start with this diagram:

and draw in the induced arrows $f_1\times f_2$, $g_1\times g_2$, and $(g_1\circ f_1)\times(g_2\circ f_2)$. Then use the uniqueness part of the universal property to show that the composite of the first two must be the same as the third. Do a similar thing to verify that identities are also preserved.

Finally, we can flip all the arrows in what we’ve said to get the dual notion: coproducts. Use this diagram:

and define the coproduct to be an initial object in a certain category of diagrams. Check that in $\mathbf{Set}$ this property is satisfied by disjoint unions. In $\mathbf{Grp}$ coproducts are free products. In a preorder, coproducts are least upper bounds. And, of course, the coproduct defines a functor from $\mathcal{C}\times\mathcal{C}$ to $\mathcal{C}$.

There’s a fair bit to digest here, but it’s worth it. The next few ideas are really very similar. Alternatively, you could take this to mean that if you don’t completely get it now there are a few more examples in the pipe that may help.

June 11, 2007 Posted by | Category theory | 10 Comments