# Why the triangle inequality?

[Maybe this is asking to be closed; but I thought I'd risk it.]

A metric satisfies the axioms:

• $d(x,y)=0$ if and only if $x=y$.
• $d(x,y) = d(y,x)$.
• $d(x,y) \leq d(x,z) + d(z,y)$.

Similarly (and motivationally) a uniformity on $X$ on a filter $F$ on $X\times X$ with:

• $\Delta = \{ (x,x) : x\in X \} \subseteq D$ for all $D\in F$.
• $D=\{ (y,x) : (x,y)\in D\}$ for all $D\in F$.
• for all $D\in F$ there is $E\in F$ with $E^2\subseteq F$.

It seems to me that if you drop the triangle-inequality (or the third axiom for a uniformity) then you can still do most basic topology, can still show, for example, that the space of bounded (uniformly) continuous functions $X\rightarrow\mathbb R$ or $\mathbb C$ is a Banach space (of interest to an Analyst like me) and so forth. My question is, why don't we study metrics/uniformities which doesn't satisfy the triangle inequality? (I see from Spaces with a quasi triangle inequality that such a thing is a semi-metric space).

Some reasons I thought of:

i) "Most" metrics arise from other structures-- e.g. norms on a vector space-- and the triangle-inequality comes from an axiom which seems more natural (e.g. the triangle-inequality for a norm really seems important-- it gives some coupling between the additive structure of the vector space and the distance).

ii) If your space is quite nice (e.g. compact) in the topology induced by your semi-metric, then there is an actual metric giving the topology. So why not just assume you have a metric? This is especially true for uniform spaces, as you only need to be completely regular to be uniformisable.

iii) It seems to me that you really do need the triangle-inequality to talk about Cauchy-sequences in a sensible way, and so to talk about completeness.

I suppose I'm slightly motivated by the recent(ish) question on whether definitions in maths are "correct". What makes the triangle-inequality so useful that pretty much everyone assumes it, even though you can do a lot of point-set topology without it?

• triangle inequality -> Hausdorff – user5810 May 20 '11 at 10:07
• Ah! Now that is quite embarrassing... Yes, surely I want Hausdorff, and surely this does need some form of Triangle Inequality. Actually, maybe that alone answers my question! Hmm; I'll leave this for a bit, but I might delete if I don't get an answer soon. – Matthew Daws May 20 '11 at 10:15
• actually this is a nice question; i have also sought to learn fundamental reasons as to "why the $\Delta$-inequality?" – Suvrit May 20 '11 at 10:31
• There was a related question on math.SE: math.stackexchange.com/q/37455 – Theo Buehler May 20 '11 at 13:10
• @Matthew: thanks; I can see what you're saying now. I just thought your question was more precise and more mathematical than a lot of questions which aren't made CW. – Todd Trimble May 20 '11 at 14:30

The triangle inequality is natural. In any setting where the metric is related to some kind of optimization problem, for example if $d(a, b)$ measures the "length" of the "shortest path" between points $a$ and $b$ (and this can be interpreted quite abstractly, for example if $a$ and $b$ are states of some physical system and $d(a, b)$ describes the amount of energy that needs to be expended to get from $a$ to $b$), then $d(a, c) \le d(a, b) + d(b, c)$ because an optimal "path" from $a$ to $b$, together with an optimal "path" from $b$ to $c$, can be no better than the optimal "path" from $a$ to $c$.

It was Lawvere who first realized that the above sounds like composition of morphisms in a category, and this leads to Lawvere's definition of a metric space as a category enriched over the monoidal category $([0, \infty], +)$. From this perspective it's the other two axioms that aren't natural: the first axiom corresponds to ignoring isomorphisms, and the second axiom doesn't hold in some natural cases of the above argument (for example the "energy cost" metric won't always be symmetric). It's also not natural to require that metrics don't take the value $\infty$; this corresponds to no path existing between $a$ and $b$.

Perhaps the following example is useful. Given any graph $G$, there is a natural metric $d(a, b)$ given by the length of the shortest path from $a$ to $b$. If $G$ is a directed graph there is no reason to have $d(a, b) = d(b, a)$. On the other hand, given any graph $G$ we can construct the free category on its arrows.

(And if you're going to question why definitions in mathematics are correct, I find it curious that you'd question the triangle inequality before the definition of a topology.)

• So you could argue that my mistake is viewing metrics as just being "nice topologies". Rather, metrics are natural in their own right, and happen to induce topologies... – Matthew Daws May 20 '11 at 10:34

From a conceptual standpoint, the triangle inequality per se is NOT what you really need. What I always emphasize when I teach metric spaces is that what gets used over and over again is that "two things that are close to the same thing are close to each other". This is what the triangle inequality is really saying, and what you need to prove all the standard theorems.

• I'm curious how far you can relax the triangle inequality and get a genuinely larger class of spaces for which (mostly) the same theorems hold. Can you relax it by an additive constant (so $d(a, c) \le d(a, b) + d(b, c) + C$)? An additive and multiplicative constant (so $d(a, c) \le C_1 d(a, b) + C_1 d(b, c) + C_2$)? – Qiaochu Yuan May 20 '11 at 17:52
• I think what you want is $d(a,c)\le f(d(a,b),d(b,c))$, where $f$ is a continuous function with $f(0,0)=0$. – Michael Renardy May 20 '11 at 18:28
• Qiauchu: I don't think an additive constant will work---you could make both a and c arbitrarily close to b and they still wouldn't necessarily be as close as you want to each other. However even with your $C1=10^100$ (which is pretty far away from the triangle inequality :-) it is still true that given $\eps$ there is a δ such that if a and c are both within δ of b then they are within $\eps$ of each other, so I'm pretty sure that's OK. Also I think the more general inequality that Michael Renary suggests is probably OK too for the same reason. – Dick Palais May 20 '11 at 20:06
• I'm a little bit worried what would happen to "all the standard theorems" if the f of Michael Renardy is not uniformly continuous with respect to the standard metric. (Maybe everything works out okay, but I haven't checked.) – Todd Trimble May 20 '11 at 21:52
• Also, D Palais, it seems to me that there are some circumstances where one wants the ‘soft’ reverse triangle inequality: “if you're close to something that's far from me, then you're far from me”. This is stronger than the contrapositive of your ‘soft’ (forward) triangle inequality. A suitable version of M Renardy's condition (for example, requiring something like $f(x, 0) = x$ for all $x \in [0, +\infty)$) would do, though then we might need the uniformity that T Trimble proposed. – LSpice May 21 '11 at 19:23

I'd like to expand on Qiaochu's answer: it has been known for some time by categorical topologists that there is a completely uniform (ha ha) abstract setting which unites metric spaces, uniform structures, topologies, and other fundamental topological concepts under the same conceptual umbrella. See for example this paper by Clementino, Hofmann, and Tholen, and especially section 5 where the abstract nonsense is applied to yield these concepts.

The point is that the triangle inequality, which is like the associativity condition for algebras over a monad, is crucial in all these examples.

Without going into full detail, but still to give a taste of this unification: the axioms for a metric space a la Lawvere are

$$0 \to d(x, x)$$

$$d(x, y) + d(y, z) \to d(x, z)$$

where $d$ is valued in the monoidal closed category (poset) $([0, \infty], +, \geq)$. The axioms for a topological space via ultrafilter convergence are

$$\top \to d(u_X(x), x)$$

$$d(\mathcal{F}, U) \wedge d(U, x) \to d(m_X(\mathcal{F}), x)$$

where $d(U, x)$ denotes the truth value of "an ultrafilter $U$ converges to a point $x$" in a space $X$. Here $d$ is valued in the monoidal closed category of truth values $(\{\bot, \top\}, \wedge, \leq)$. The $u$ in the first axiom refers to the unit $u: 1 \to M$ where $M: Set \to Set$ is the ultrafilter monad; $u_X$ takes a point $x \in X$ to the principal ultrafilter generated by $x$, and the first axiom says that the principal ultrafilter generated by a point $x$ converges to $x$. The $m$ in the second axiom refers to the multiplication $m: MM \to M$ of the monad (so here $\mathcal{F}$ belongs to $MMX$, and $U$ belongs to $MX$), and $d(\mathcal{F}, U)$ refers to the canonical topology on $MX$ as the Stone space of ultrafilters attached to the Boolean algebra $2^X$. This point of view on topological spaces goes back to Barr sometimes in the sixties; see his article "Relational Algebras" in Reports of the Midwest Category Seminar IV, Springer LNM 137, pages 39-55.

Here's a real life example of something that fails the triangle inequality, but that is still interesting: the space $L^p(X)$ for $0\lt p\lt 1$. For example, the product $fg$ of two functions $f,g\in L^1(X)$ is in $L^{1/2}(X)$.

This is an example of a quasi-Banach space and thus satisfies Dick Palais's condition "two things that are close to the same thing are close to each other".

• There is some work of Kalton (among others) which seems, to my casual eye, to suggest that quasi-Banach spaces can be much nastier than Banach spaces, due to the failure of local convexity. – Yemon Choi May 21 '11 at 0:37

UPDATE: this isn't quite right. I'll leave it up for the moment and try to fix it properly later.

Suppose you have $d$ satisfying your first two axioms, and you define $d'$ to be the inf of all possible sums $d(x,a_1)+d(a_1,a_2)+\dotsb+d(a_{n-1},y)$. This will satisfy $d'(x,x)\geq 0$ and $d'(x,y)=d'(y,x)$ and $d'(x,z)\leq d'(x,y)+d'(y,z)$, so it is a pseudometric. The topology defined by this pseudometric will be the same as the one defined by your original $d$, so you have not really gained any generality. It could happen that $d'(x,y)=0$ for some $x,y$ with $x\neq y$, in which case the topology is not Hausdorff, as Ricky mentioned.

One case you could consider is $d(x,y)=(x-y)^2$ on $\mathbb{R}$. Here $d'=0$, so the topology is indiscrete.

Alternatively, you can take $X=[0,1]^2$ and $d((x,y),(u,v))=$ usual distance when $x=u$ or $y=v$, and $d((x,y),(u,v))=42$ otherwise. In this case $d'((x,y),(u,v))=|x-u|+|y-v|$ and the resulting topology is the usual one.

• But... I think you're first example is wrong: surely $d(x,y) = (x-y)^2 = |x-y|^2 < \epsilon$ if and only if $|x-y|<\sqrt\epsilon$, and so I get the usual topology? – Matthew Daws May 20 '11 at 11:27
• I think the problem is actually that $d'$ might give rather fewer open sets than $d$. The first example shows this occurring in an extreme way. Do $d'$ might not give the same topology as $d$... – Matthew Daws May 20 '11 at 11:50

If you do not assume some kind of "modified" triangle inequality, you cannot guarantee that d generates a topology.

Edit: We can still define a subset $A\subseteq X$ to be open if for each $a\in A$ there is $\epsilon>0$ such that $B(a,\epsilon) = \{ x\in X : d(a,x)<\epsilon\} \subseteq A$. This is a topology. But without the triangle inequality, it's quite possible for an "open" ball $B(x,\epsilon)$ to fail to be open!

• $\{S\in 2^X : (\forall x)(x\in S \implies (\exists \epsilon)(0<\epsilon \text{ and } \{y\in X : d(x,y)<\epsilon \} \subseteq S))\}$ is guaranteed to be a topology on $X$. – user5810 May 20 '11 at 10:21
• Yeah, I'm pretty sure I'm with Ricky here-- the usual definition of the metric topology never uses the triangle inequality (which is sort of what sparked my question...) – Matthew Daws May 20 '11 at 10:30
• Perhaps Michael means that you need the triangle inequality to show that open balls are open, and so the metric topology is generated by the open balls. – Chris Eagle May 20 '11 at 10:46
• @Chris-- yes, that's a nice observation! – Matthew Daws May 20 '11 at 10:49
• Yes, what I meant was that the open balls, defined in the usual way, generate a topology. – Michael Renardy May 20 '11 at 13:02