If a function $d(x,y)$ fulfills triangle inequality, is the same true for $|d(x,y)|$?

226 Views Asked by At

Suppose we have a function $d\colon X\times X\to\mathbb R$ such that $$d(x,z)\le d(x,y)+d(y,z).$$ But we do not require other properties of metric (non-negativity, symmetry). If it helps, in the situation which motivated this question we have $d(x,x)=0$.

Do we get that then also $$|d(x,z)|\le |d(x,y)|+|d(y,z)|,$$ (triangle inequality for the absolute value of $d$) holds?


Of course, we immediately have $$d(x,z)\le d(x,y)+d(y,z) \le |d(x,y)|+|d(y,z)|,$$ so it would suffice to show the same upper bound for $-d(x,z)$. If we had symmetry we could say that $$-d(x,z) \le d(y,x) - d(y,z) = d(x,y) - d(y,z) \le |d(x,y)|+|d(y,z)|,$$ but it is not clear whether we can do something similar without symmetry, too.


This was motivated by my previous question: Does a metric-like space generate a topology if open balls are defined as $B_\sigma(X,\varepsilon)=\{y\in X; |\sigma(x,y)-\sigma(x,x)|<\varepsilon\}$? (You can find there further links including a paper from which the definition mentioned in the question was taken.)

The question dealt with function similar to metric but with the condition $p(x,x)=0$ omitted.

  • $p(x,y)\ge0$
  • $p(x,y)=0$ $\Rightarrow$ $x=y$
  • $p(x,y)=p(y,x)$
  • $p(x,z) \le p(x,y) + p(y,z)$

It was pointed out that the suggested way of generating topology, by taking the sets of the form $B(x,r)=\{y\in X; |p(x,y)-p(x,x)|<r\}$, does not give a base of topology. An answer suggested to use this version of triangle inequality: $$p(x,z) \le p(x,y)+p(y,z)-p(y,y).$$ This is the version of the triangle inequality which is used in the definition of partial metric space. Still some conditions from the definition of partial metric space are missing (for example, we do not have $p(x,x)\le p(x,y)$ or that "indistancy implies equality".)1

If we want to define topology using the base consisting of sets $B(x,r)$ defined above, it is natural to look at the function $d(x,y)=p(x,y)-p(x,x)$ and its absolute value. We have \begin{align*} p(x,z) &\le p(x,y)+p(y,z)-p(y,y)\\ p(x,z)-p(x,x) &\le (p(x,y)-p(x,x))+(p(y,z)-p(y,y))\\ d(x,z)&\le d(x,y)+d(y,z) \end{align*} So, the function $d$ fulfills triangle inequality. If the same is true for $|d|$, we would at least have some information about the system $B(x,r)$.

Notice that if $p(x,x)\ne p(y,y)$ for some $x$, $y$ than we do not have symmetry.


1You can find more information on partial metric spaces on website created by Steve Matthews or in the papper Michael Bukatin, Ralph Kopperman, Steve Matthews and Homeira Pajoohesh: Partial Metric spaces, The American Mathematical Monthly, Vol. 116, No. 8 (Oct., 2009), pp. 708-718 (author's website, jstor).

2

There are 2 best solutions below

1
On

One might observe that this question reduces to whether the property holds on every set of three elements. Then, we can normalize $d$ by the norm $\sum_{x,y\in X}|d(x,y)|$ to reduce ourselves to a question about a bounded, convex set defined by linear inequalities. Further, the function $d\mapsto |d(x,z)|-|d(x,y)|-|d(y,z)|$ is piecewise linear, with eight pieces. We wish to try to maximize this function on the unit ball with respect to the given norm. The implication asked about in the question is true if and only if this maximum is $0$.

This is all very easy to make a computer do. So, I had Mathematica do it, and it found a counterexample, which I multiplied everything by $4$ to make it prettier:

Set $d(x,z)=-1$ and $d(y,x)$ to $1$ and $d(z,x)$ to $1$ and $d(z,y)$ to $1$. Let $d$ be zero on every other pair. This satisfies the desired property, but $|d(x,z)|=1$ and $|d(x,y)|=|d(y,z)|=0$.


Here's the code I ran to find the counterexample:

> Maximize[{Abs[d[x, z]] - Abs[d[x, y]] - 
   Abs[d[y, z]], (Plus @@ (Abs[d @@ #] & /@ Tuples[{x, y, z}, 2])) <= 
    1 &&
   And @@ (d[#[[1]], #[[3]]] <= 
        d[#[[1]], #[[2]]] + d[#[[2]], #[[3]]] & /@ 
      Tuples[{x, y, z}, 3])
  }, d @@ # & /@ Tuples[{x, y, z}, 2]]

Note that I just had it maximize the piecewise linear function directly; apparently it's smart enough to deal with that on its own (and easy enough to verify that it's done it correctly)

0
On

I will offer here another presentation of the counterexample given by Milo Brandt.

The minor difference is that triangle inequality is proved here, not verified by computer. However, the proof is still by cases, so perhaps it is not such a big improvement. Still, it is more difficult to find a counterexample than to offer a different presentation.

Let us define $$d(x,y)= \left\lceil \frac{x-y}2 \right\rceil$$ for $x,y\in\mathbb Z$.

To show that this function fulfills triangle inequality, i.e., that \begin{align*} d(x,z) &\le d(x,y)+d(y,z)\\ \left\lceil \frac{x-z}2 \right\rceil &\le \left\lceil \frac{x-y}2 \right\rceil + \left\lceil \frac{y-z}2 \right\rceil \end{align*} it suffices to check that $$\left\lceil\frac{a+b}2\right\rceil \le \left\lceil\frac{a}2\right\rceil + \left\lceil\frac{b}2\right\rceil$$ for any $a,b\in\mathbb Z$. Which follows immediately from the facts that $\frac{a+b}2=\frac{a}2+\frac{b}2\le\left\lceil\frac{a}2\right\rceil + \left\lceil\frac{b}2\right\rceil$ and that $\left\lceil\frac{a}2\right\rceil + \left\lceil\frac{b}2\right\rceil$ is an integer. (Originally I have a more complicated argument here, I have replaced it by an easier proof taken from this answer.)

And, as mentioned in the other post, we have $d(1,0)=d(0,-1)=0$ while $d(1,-1)=-1$ and $|d(1,-1)|=1$, which means that $|d|$ does not fulfill triangle inequality.


The same argument can be generalized in this way: If we take a subadditive function $f\colon\mathbb R\to\mathbb R$, then $d(x,y)=f(x-y)$ satisfies triangle inequality. From $f(a+b)\le f(a)+f(b)$ we immediately get $d(x,z)=f(z-x)\le f(y-x)+f(z-y)=f(z-x)$.

However, if $|f|$ is not subadditive, then $|d|$ does not satisfy triangle inequality. (Namely if $f(a+b)>f(a)+f(b)$ then the triangle inequality fails for $x=0$, $y=a$ and $z=a+b$.)