# 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.

February 11, 2008 -

1. Is there a standard term for something that satisfies the axioms of a pseudometric space except for symmetry?
The Wikipedia page on pseudometric spaces doesn’t list any more general concept.

Comment by Jeremy Henty | February 12, 2008 | Reply

2. I really don’t know whether there is or not. Tom certainly didn’t mention one in the post that reminded me about this fact.

Comment by John Armstrong | February 12, 2008 | Reply

3. Aha! It’s a quasimetric space:

http://en.wikipedia.org/wiki/Quasimetric_space

http://planetmath.org/?op=getobj&from=objects&name=QuasimetricSpace

Comment by Jeremy Henty | February 14, 2008 | Reply

4. Sorry, Jeremy, the links triggered the spam demon. Fixed now.

Anyhow, that’s brilliant. Thanks for turning up that term.

Comment by John Armstrong | February 14, 2008 | Reply

5. Incidentally, on a closer look it seems that quasimetric spaces keep the condition that $d(x,y)=0$ if and only if $x=y$. That is, maybe what we’re looking at are pseudoquasimetric spaces. Or vice versa.

Comment by John Armstrong | February 14, 2008 | Reply

6. Or almost pseudoquasimetric, since the Lawvere definition you’re using includes $\infty$ as a possible distance.

Comment by Todd Trimble | February 15, 2008 | Reply

7. You might want to check out Dictionary of Distances by Deza & Deza (Elsevier, 2006) for names for various almost-metrics. They aren’t quite consistent with those listed in Wikipedia (which I liked, because they had a name for every subset of the metric axioms, including hemimetric and prametric, for example). It also seems that the names pseudo-, quasi- and (especially) semi-metric aren’t used 100% consistently in the literature.

Comment by Magnus Lie Hetland | February 29, 2008 | Reply