# The Unapologetic Mathematician

## Metric Spaces are Categories!

A guest post by Tom Leinster over at The n-Category Café reminded me of an interesting fact I haven’t mentioned yet: a metric space is actually an example of an enriched category!

First we’ll need to pick out our base category $\mathcal{V}$, in which we’ll find our hom-objects. Consider the set of nonnegative real numbers with their real-number order, and add in a point called $\infty$ that’s above all the other points. This is a totally ordered set, and orders are categories. Let’s take the opposite of this category. That is, the objects of our category $V$ are the points in the “interval” $\left[0,\infty\right]$, and we have an arrow $x\rightarrow y$ exactly when $x\geq y$.

This turns out to be a monoidal category, and the monoidal structure is just addition. Clearly this gives a monoid on the set of objects, but we need to check it on morphisms to see it’s functorial. But if $x_1\geq y_1$ and $x_2\geq y_2$ then $x_1+x_2\geq y_1+y_2$, and so we can see addition as a functor.

So we’ve got a monoidal category, and we can now use it to form enriched categories. Let’s keep out lives simple by considering a small $\mathcal{V}$-category $\mathcal{C}$. Here’s how the definition looks.

We have a set of objects $\mathrm{Ob}(\mathcal{C})$ that we’ll call “points” in a set $X$. Between any two points $p_1$ and $p_2$ we need a hom-object $\hom_\mathcal{C}(p_1,p_2)\in\mathrm{Ob}(\mathcal{V})$. That is, we have a function $d:X\times X\rightarrow\left[0,\infty\right]$.

For a triple $(p_1,p_2,p_3)$ of objects we need an arrow $\hom_\mathcal{C}(p_2,p_3)\otimes\hom_\mathcal{C}(p_1,p_2)\rightarrow\hom_\mathcal{C}(p_1,p_3)$. In more quotidian terms, this means that $d(p_2,p_3)+d(p_1,p_2)\geq d(p_1,p_3)$.

Also, for each point $p$ there is an arrow from the identity object of $\mathcal{V}$ to the hom-object $\hom_\mathcal{C}(p,p)$. That is, $0\geq d(p,p)$, so $d(p,p)=0$.

These conditions are the first, fourth, and half of the second conditions in the definition of a metric space! In fact, there’s a weaker notion of a “pseudometric” space, wherein the second condition is simply that $d(p,p)=0$, and so we’re almost exactly giving the definition of a pseudometric space.

The only thing we’re missing is the requirement that $d(p_1,p_2)=d(p_2,p_1)$. The case can be made (and has been, by Lawvere) that this requirement is actually extraneous, and that it’s in some sense more natural to work with “asymmetric” (pseudo)metric spaces that are exactly those given by this enriched categorical framework.