Skip to content

Functional equality

How do I know whether two morphisms are equal?




category theory philosophy math yoneda

While learning about basic category theory a reocurring question kept coming up again and again:

How do I know whether two morphisms are equal?

This is the question this essay explores.

Let’s start somewhere familiar, $\mathbf{Set}$. We know the morphisms in this category very well, they are just functions. And we have a very good notion of equality of functions. Two functions $f : A \to B$ and $g : A \to B$ are equal when for all $x \in A$ we have that $f(x) = g(x)$. In other words, if when evaluated at every point of $A$ they are equal then we know that $f$ and $g$ are equal. We don’t want equality of functions though, we want to define equality of morphisms. So, we need to abstract this using categorical terms.

The first thing we need to abstract should be the notion of elements of a set. In Category Theory, we don’t have always have the convenience to be talking about the elements of the objects of a category. So we use a clever trick, look at this function $f : \{1\} \to \mathbb{R}$ defined as $f(1) = 42$. Notice that because the domain of this function is a set with just one element, we can only evaluate it like $f(1)$ and because of the definition $f(1) = 42$. In other words, this function represents the number $42$ and for all intents and purposes1, $42$ and $f$ are indistinguishable. We can do this for any set and any element of that set you can think of: define a function that, when evaluated at $1$ gives you that element and make the domain of that function $\{1\}$. More generally, this set is called a singleton set, but I’ll refer to it as the singleton set because what’s important is the fact it has just 1 element and any set with 1 element will do. Because of that last point I’ll also refer to it as $\mathbb{1}$.

How many functions are there from a set $X$ to a set $Y$? Well we know that for each element of $X$ we have $Y$ choices of where to send it. So, $Y$ choices $X$ times gives us that the number of functions from $X$ to $Y$ has to be $|Y|^{|X|}$. I won’t spend time confirming this fact and move on to its applications. What happens with the previous function $f : \mathbb{1} \to \mathbb{R}$, how many functions do we have given this formula? We’d have $|\mathbb{R}|^{|\mathbb{1}|}$. This is just $|\mathbb{R}|$, which is what we expected if we want to be able to represent all elements of $\mathbb{R}$ using these functions.

Coming back to the topic at hand, let’s go back into abstraction. First, fix $x : \mathbb{1} \to X$ and let $f : X \to Y$. We know that $x$ is essentially just an element of $f$, but since we have encoded it as a morphism we can write an expression like: $f \circ x$. This means we can restate the earlier statement about functional equality as:

$$ f = g \iff f \circ x = g \circ x $$

for all $x : \mathbb{1} \to X$. Now that everything is morphisms, we are closer to being able to define this categorically. Now what remains is $\mathbb{1}$. Categories that don’t have something similar to singleton sets will have issues defining this. The property here is called well-pointedness and more specifically, it relies on generator objects whose literal definition is being able to be utilized to distinguish morphisms. A category that is not well-pointed is $\mathbf{Ab}$, its terminal object (which is a zero object really) is the trivial group $\mathbb{0} := (\{0\}, +)$ and there is only one map out of $\mathbb{0}$ to any other object in $\mathbf{Ab}$. This means that you can’t use this object to select an element inside other objects (more specifically, it’s not a generator object).

Since $\mathbf{Ab}$ is the prime example of an additive category, a natural2 question to ask is whether the well-pointedness can’t happen in additive categories in general? It turns out that additive categories cannot be well-pointed. But a more interesting fact is that one can still separate morphisms in additive categories. This is due to the fact that, although well-pointedness relies on the generator being a terminal object (namely $\mathbb{1}$), any generator can be used to identify whether morphisms are equal or not. In $\mathbf{Ab}$, the generator object is $(\mathbf{Z}, +)$, in $\mathbf{R}$-$\text{Mod}$, the generator object is $\mathbf{R}$.

Corollary

There’s a really pretty generalization to be done when looking at the original proposition that expresses when two morphisms are equal. As we saw, generator objects don’t have to necessarily be the terminal object, they can be any other object. More generally, one can have a family of generators3. So a way to generalize the “equal morphism” proposition would be to let the domain of $x : \mathbb{1} \to X$ be any object in the category. In other words, we are looking at a family of morphisms of the form $x : I \to X$ for any $I$ object in the category. This is more commonly referred to as the hom-functor $\hom(-, X)$ and I’ll refer to it as $\chi := \hom(-, X)$. Since we aren’t limitting the objects that the domain of $\chi$ can take, in fact we are letting the domain be the whole category, we can now separate morphisms always in any category. Look at the proposition

$$ f = g \iff \forall I, \forall x : I \to X, f \circ x = g \circ x $$

and notice that $(\Rightarrow)$ is proven trivially and $(\Leftarrow)$ is proven by letting $I$ be $X$ and taking $x$ to be $\text{id}_X$ giving: $f \circ \text{id}_X = g \circ \text{id}_X = f = g$. Separating morphisms is no longer the focus here, so forget this for now.

Bare with me but I will also introduce a new of morphism into the mix $h : J \to I$. In this case, $I$ represents a sort of “picture” you want to paint of $X$ and $J$ selects which parts of that picture you actually want to see. Finally, we’ll turn $h$ into a family of morphisms of the form $- \circ h : \hom(I, -) \to \hom(J, -)$ and $f$ into a family of morphisms of the form $f \circ - : \hom(-, X) \to \hom(-, Y)$. We’ll call this family of morphisms using the shorthand notation $h^\flat_X : \hom(I, X) \to \hom(J, X)$ and $f^\sharp_I : \hom(I, X) \to \hom(I, Y)$. To be entirely clear, forget the original proposition, these are the objects we are playing around with now:

  • Fix $f : X \to Y$.
  • Define the natural transformation $h^\flat_X : \hom(I, X) \to \hom(J, X)$ for all $X$ object in the category.
  • Define the natural transformation $f^\sharp_I : \hom(I, X) \to \hom(I, Y)$ for all $I$ object in the category.
  • Define the functor $\chi := \hom(-, X)$.
$$ \begin{CD} \hom(I, X) @>{f^\sharp_I}>> \hom(I, Y) \\ @V{h^\flat_X}VV @VV{h^\flat_Y}V \\ \hom(J, X) @>>{f^\sharp_J}> \hom(J, Y) \end{CD} $$

Notice that the functor applying $\chi$ to $I$ lets us take an object $x \in \chi (I)$ so that $x : I \to X$ which fits exactly the domain of $h^\flat_X$. Evaluating this we have that $h^\flat_X(x) = x \circ h : J \to X$ In turn, this also fits the domain of $f^\sharp_J$. So evaluating that we get that $f^\sharp_J(h^\flat_X(x)) = f^\sharp_J(x \circ h) = f \circ (x \circ h)$. But now notice that since composition is associative we can write this as $f \circ (x \circ h) = (f \circ x) \circ h$. But the inner part of this composition is just $f^\sharp_I (x)$. So $(f \circ x) \circ h = (f^\sharp_I (x)) \circ h$ and using the definition of $h^\flat_Y$ this simplifies to $(f^\sharp (x)) \circ h = h^\flat_Y (f^\sharp_I (x))$. In other words,

$$ f^\sharp_J(h^\flat_X(x)) = h^\flat_Y (f^\sharp_I (x)). $$

This is equivalent to stating that the above diagram commutes, which it obviously does because composition is associative and because the sides are natural transformations. Now, for the big payoff. Notice that we fixed $f : X \to Y$ at the start. Lets try and do the converse here and instead of starting with $f : X \to Y$, we’ll try to recover it from a natural transformation of the form $\alpha_I : \hom(I, X) \to \hom(I, Y)$ whose square commutes for any $h : J \to I$.

We can do the same trick we used when proving that letting the family of generators be all the objects in the category always lets you separate. In this case, let $I := X$. So $\alpha_X : \hom(X, X) \to \hom(X, Y)$ and $h : J \to X$. We can do the previous precomposition trick with $h$ and define the natural transformation $h^\flat_X : \hom(X, X) \to \hom(J, X)$ We have $\hom(X, X)$ which we know is always populated by $\text{id}_X$. If you know what the Yoneda Lemma is, you know exactly what we are about to do. So finally we have that,

$$ h^\flat_X(\text{id}_X) : J \to X, $$

and

$$ \alpha_X(\text{id}_X) : X \to Y. $$

Now notice that $\alpha_J : \hom(J, X) \to \hom(J, Y)$ and $h^\flat_Y : \hom(X, Y) \to \hom(J, Y)$. So we apply these to the previous morphisms we got and get,

$$ \alpha_J (h^\flat_X (\text{id}_X)) : J \to Y, $$

and

$$ h^\flat_Y (\alpha_X (\text{id}_X)) : J \to Y. $$

Because $\alpha$ is a natural transformation and $h$ is just an arbitrary morphism, these morphisms are naturally4 equal! But since we are using $\text{id}_X$ we can actually simpliify $h^\flat_X (\text{id}_X) = \text{id}_X \circ h = h$. So then, we end up with,

$$ \alpha_J (h) = \alpha_X (\text{id}_X) \circ h. $$

Interestingly, we have a morphism $\alpha_X(\text{id}_X) : X \to Y$ so define this as $f := \alpha_X (\text{id}_X)$ and since we picked arbitrary $h : J \to X$ and an arbitrary $J$ let’s relabel them to what we originally had: $J$ becomes $I$ and $h : J \to X$ becomes $x : I \to X$. We finally get that, $ \alpha_I (x) = f \circ x. $ Or in other words, $\alpha_I = f^\sharp_I$. The previous logical steps are, although not entirely rigorous, the steps one would you use to prove the Yoneda Lemma.

The intuition I’d like to finish this essay is with this, we already know that objects are uniquely determined by the relations they hold with every other object via morphisms, and now we see that a morphism is uniquely determined by the action it takes on every other object, which we know can be encoded equivalently as maps. This intuition silently permeates all of category theory, cropping up everywhere albeit with different names and different conditions. Seeing as how categories model structures that we see and interact with so well, ignoring this fact would be doing a grave disservice the neverending search all researchers, mathematicians, scientests and general lay-people have.


  1. they are naturally isomorphic ↩︎

  2. not that kind of natural ↩︎

  3. definition 3.2 specifies “family of separators” but I talk about these as “generators” they are the same. ↩︎

  4. yes, that kind of natural ↩︎