13

Call a finite metric space $(X,d_X)$ a distinct distance space if all the nonzero distances in $X$ are distinct, i.e., the set of nonzero distances has size exactly ${|X|\choose 2}$.

The answer to the following question has implications for my research:

For any finite metric space $(X,d_X)$ and $\epsilon > 0$, does there exist a metric $d_Y$ on $X$ such that $(X,d_Y)$ is a distinct distance space, and for all $x,y\in X$ we have $|d_X(x,y)-d_Y(x,y)| < \epsilon$?

Intuitively (with intuition coming from Euclidean space), it seems like if the distance function is not injective, then since the metric is finite, we should be able to perturb all the points a little bit to make all the distances distinct. However, arbitrary metric spaces can be quite unlike Euclidean space, so maybe there is some such space where this is not possible.

What I tried

  • The main approach I tried was assigning weights $\delta_{xy}=\delta_{yx}$ for each pair $\{x,y\}$ in $X$ in such a way where the weights are distinct and all less than $\epsilon$. However, no matter how I tried defining the weights so far, I couldn't figure out how to get the triangle inequality to hold.
  • I also considered an approach by induction. We can construct $d_Y$ in an ad-hoc way for, e.g., $|X|=3$. Then adding another point adds a smaller number of new distances, so perhaps dealing with only these distances is somehow easier. But it again reduces to the same problem of perturbing the distances in such a way where the triangle inequality holds.
  • I know that every finite metric space can be isometrically embedded in $\mathbb R^{|X|}$ with the $\ell_\infty$ metric, using the Kuratowski embedding. If we do this, then we can just perturb the points in the ambient space and take the induced metric. I tried various ways of perturbing the points coordinate-wise but this didn't work out so far either.
Adam Rubinson
  • 24,300

6 Answers6

15

Basic idea Step $1:$ Add a distance of $\frac{\varepsilon}{2}$ to each distance between two points in $(X,d_X):$ this gives rise to the metric space $d_Y{'}$ defined below. Step $2:$ Perturb these distances by a small enough amount to guarantee their distinctness. The first step gives us a safety net/wiggle room such that the second step will not cause a violation of the triangle inequality.


Given $\varepsilon>0,$ define $d_Y{'}(x,y) := d_X(x,y)+\frac{\varepsilon}{2}$ for every pair of points $x,y\in X.$ Then the first $2$ or $3$ axioms of "metric space" hold for $d_Y{'}(x,y),$ so we check that the triangle inequality holds for $d_Y{'}(x,y).$ Well,

$$ d_Y{'}(x,z) = d_X(x,z)+\frac{\varepsilon}{2} \leq d_X(x,y) + d_X(y,z) + \frac{\varepsilon}{2}$$

$$= \left(d_Y{'}(x,y)-\frac{\varepsilon}{2}\right) + \left(d_Y{'}(y,z)-\frac{\varepsilon}{2}\right) + \frac{\varepsilon}{2}$$

$$ = d_Y{'}(x,y) + d_Y{'}(y,z) - \frac{\varepsilon}{2} \leq d_Y{'}(y,z) + d_Y{'}(y,z).$$

Furthermore, we have the desired $\ \vert d_X(x,y)-d_Y{'}(x,y)\vert =\frac{\varepsilon}{2} < \epsilon.$

The only issue now is that some of the distances between points in our newly-defined metric space $Y{'}$ may not be distinct, and therefore we must perturb them slightly to ensure their distinctness. However, since $\ \vert d_X(x,y)-d_Y{'}(x,y)\vert \leq\frac{\varepsilon}{2},$ we have some wiggle room, because we only require $ \vert d_X(x,y)-d_Y(x,y)\vert < \varepsilon.$

There are $n:= \vert X \vert $ points in $X,$ and $\displaystyle\binom{n}{2}$ distances between different pairs of points in the metric space $(X,d_X),$ and therefore $(X,d_Y{'})$ also. So we want the $\displaystyle\binom{n}{2}$ distances to all be distinct, and $\vert d_Y(x,y) - d_Y{'}(x,y)\vert < \frac{\varepsilon}{2}\ \forall\ x,y\in X, $ for then we would also have the desired

$$\ \vert d_Y(x,y)-d_X(x,y)\vert = \vert d_Y(x,y)- d_Y{'}(x,y) + d_Y{'}(x,y)-d_X(x,y)\vert$$

$$ \leq \vert d_Y(x,y)- d_Y{'}(x,y)\vert + \vert d_Y{'}(x,y)-d_X(x,y)\vert < \frac{\varepsilon}{2} + \frac{\varepsilon}{2} = \varepsilon.$$

To this end, carry out the following procedure. List each of the $\displaystyle\binom{n}{2}$ pair of points of $X$ in any order:

$(x_1,x_2)$

$(x_1,x_3)$

$\ldots$

$(x_{n-1},x_n).$

Starting by letting $d_Y(x_1,x_2) := d_Y{'}(x_1,x_2).$

Next, look at the second pair $(x_1,x_3),$ and find $t_1\in \left[0,\frac{\varepsilon}{2}\right)$ such that $d_Y{'}(x_1,x_3) + t_1$ is different to $d_Y(x_1,x_2).$ Then we let $d_Y(x_1,x_3) := d_Y{'}(x_1,x_3) + t_1.$

Next, look at the third pair $(x_1,x_4),$ and find $t_2\in \left[0,\frac{\varepsilon}{2}\right)$ such that $d_Y{'}(x_1,x_4) + t_2$ is different to both $d_Y(x_1,x_2)$ and $d_Y(x_1,x_3).$ Then we let $d_Y(x_1,x_4) := d_Y{'}(x_1,x_4) + t_2.$

And so on.

Now the distances between different pairs of points, in our new metric space $(X,d_Y),$ are distinct. But we still need to check two things: $1)$ Does the triangle inequality hold in $d_Y?$ and $2)$ Do we have $\vert d_Y(x,y)-d_X(x,y)\vert < \varepsilon?$

Let $x,y,z\in X.$ Then:

$1)$

$$d_Y(x,z) = d_Y{'}(x,z) + t_1 \leq d_Y{'}(x,z) + \frac{\varepsilon}{2} = d_X(x,z) + \frac{\varepsilon}{2} + \frac{\varepsilon}{2}$$

$$= d_X(x,z) + \varepsilon \leq d_X(x,y) + d_X(y,z) + \varepsilon = \left(d_Y{'}(x,y) - \frac{\varepsilon}{2}\right) + \left(d_Y{'}(y,z) - \frac{\varepsilon}{2}\right)+ \varepsilon$$

$$ = d_Y{'}(x,y) + d_Y{'}(y,z) \leq d_Y(x,y) + d_Y(y,z).$$

$2)\quad \vert d_Y(x,y) - d_Y{'}(x,y)\vert < \frac{\varepsilon}{2}\ \forall\ x,y\in X, $ so from a previous remark, we have $\vert d_Y(x,y)-d_X(x,y)\vert < \varepsilon.$

Adam Rubinson
  • 24,300
  • 1
    Much better idea to add wiggle room than what I did! – Ingix Oct 16 '24 at 15:33
  • (+1) Excellent! It seems to me that this procedure will still work even if $X$ is countably infinite, since the set of pairs will then also be countable. (For each $n$, when we choose $t_n$, only finitely many values out of $[0,\varepsilon/2)$ will be forbidden.) Yes? – mathmandan Oct 17 '24 at 22:29
5

The perturbation idea works. As you say, using the Kuratowski embedding we can assume WLOG that $X$ is a finite set of points in $\mathbb{R}^n$ equipped with the $\ell_{\infty}$ metric. Now perturb the points in $X$ by an arbitrarily small amount such that every coordinate of every point in $X$ is linearly independent over $\mathbb{Q}$.

Edit: In more detail, say $X$ consists of $n$ points (so we start with the Kuratowski embedding) and we want a perturbation of size less than $\varepsilon$. So the points of $X$ have $n^2$ coordinates in total which collectively describes a point in $\mathbb{R}^{n^2}$.

Lemma: For any positive integer $m$, the subset $L$ of $\mathbb{R}^m$ consisting of tuples $(y_1, \dots y_m)$ which are linearly independent over $\mathbb{Q}$ is dense in the Euclidean topology (hence with respect to any vector space norm on $\mathbb{R}^m$, e.g. the $\ell_{\infty}$ norm).

Proof. The complement of $L$ consists of a countable union of hyperplanes through the origin, namely those hyperplanes given by equations of the form $\sum q_i y_i = 0$ where the $q_i$ are all rational. So $L$ is a countable intersection of dense open sets (the complements of these hyperplanes) and hence dense by the Baire category theorem.

So to get the desired perturbation we can apply the lemma to the coordinates of $X$, with $m = n^2$. There is also a more hands-on argument where we just perturb each coordinate by less than $\frac{\varepsilon}{2}$ one by one and show that we can always make each coordinate linearly independent from the previous ones (which is clear since the set of coordinates which are linearly dependent on the previous ones is countable).

Now if $x, y, z, w$ are any four points then $d(x, y) = \pm (\alpha - \beta)$ and $d(z, w) = \pm (\gamma - \delta)$ where $\alpha$ is a coordinate of $x$, $\beta$ is a coordinate of $y$, etc. By construction $\alpha, \beta, \gamma, \delta$ are linearly independent if they are distinct. So if $d(x, y) = d(z, w)$ then some of them are not distinct. We can ignore the cases $\alpha = \beta$ and $\gamma - \delta$ so WLOG $\alpha = \gamma$, meaning that $x = z$. If $\alpha - \beta = \gamma - \delta$ subtracting gives $\beta = \delta$, meaning that $y = w$ which is a case we can ignore. Otherwise, if $\alpha - \beta = - (\gamma - \delta)$ this contradicts that $x, y, w$ are distinct.

So $d(x, y) \neq d(z, w)$ except in degenerate cases, as desired.

As you say, the issue with perturbing the distances straight up is that it's not obvious the triangle inequality continues to hold, and the issue specifically is the possibility that some of the triangle inequalities might start out equalities.

(Also, the lemma is overkill; as the argument shows we actually only have to avoid every hyperplane of the form $\pm (x_i - x_j) = \pm (x_k - x_{\ell})$ where $i, j, k, \ell$ are distinct, and there are finitely many of these, which makes the argument easier.)

Qiaochu Yuan
  • 468,795
  • For the actual perturbations, I think we can just do something like: add $\epsilon_i \pi$ to every coordinate of every point, where the $\epsilon_i$ are sufficiently small and distinct? Or maybe it requires more care than that. This seems like the important step to me though. Can you say more about how to do the perturbing? – R. H. Vellstra Oct 15 '24 at 23:57
  • 1
    @pyridoxal: I've added some details. Your suggestion isn't enough because you don't specify anything about the $\epsilon_i$'s so the factor of $\pi$ doesn't do anything for you. – Qiaochu Yuan Oct 16 '24 at 03:17
5

A solution without embedding goes as follows.

As has been pointed out in the answer by Lee Mosher, the problematic part in just changing the length of all distances by a small amount such that all become different are instances where the triangle inequality is an equality.

That means if you have 3 points $A,B,C$ with $d(A,B) = 1, d(B,C) = 2, d(A,C) = 3$ and you need to change the distance between $A$ and $C$ because the distance $3$ exists between points in $X$ somewhere else, and you choose to increase $d(A,C)$, then you must also change either $d(A,B)$ or $d(B,C)$, as otherwise the triangle inequality isn't true any more.

I'll call such a triangle of 3 points (all assumed to be different) where the triangle inequality is actually an equality a flat triangle and it has a long side and two short sides. If you need to change the length of one side of a flat triangle, you'd rather want to increase short sides and decrease long sides. But since each side can be in multiple flat triangles and sometimes be a short side in them and sometimes a long side, that isn't trivially possible.

So it would be nice to have a coordinated change of multiple side length such that afterwards the distances still form a metric space but there are no more flat triangles. If we can do that (with changes to each distance say less than $\frac\epsilon{2}$), we can then just change distances that are duplicates one after the other just 'a little bit', because we no longer need to worry about triangle inequalities being broken for even arbitrary small changes.

To get that coordinated change, we use the complete graph $K_X$ with vertices being the points of $X$ and edges $e_{\{A,B\}}$ between $A, B \in X$ and construct an integer edge evaluation $V$ for it, that means $V$ is a function that assigns each edge an integer value. That evaluation $V$ will later dictate which distances need to be changed and by how much.

We construct that evaluation iteratively and start with every edge having value $0$. Then we look through all the sides that are the long side of at least one flat triangle and order them increasing by length (e.g the distance between the end points). If we have duplicate lengths, the internal order between them doesn't matter.

We now start with the first such side $l$ (the shortest of the long sides) and want to change its valuation. We initially gather all flat triangles where it is a long side, say triangles $T_1, T_2,\ldots, T_k$. Each such triangle has 2 short sides $s_1$ and $s_2$ and we calculate $r_i = V(s_1) + V(s_2) + 1$ for each triangle $T_i, i=1,\ldots,k$. Finally we set $V(l)=\max(r_1,\ldots,r_k)$.

We now repeat this algorihm with the next side from our ordered list of long sides, do the same calculations and end up with an evaluation of that long side, a.s.o until we have exhausted the list.

This algorithm has a few properties:

  1. After initially setting every value to $0$, it then sets the value of a side at most once.
  2. In every flat triangle, the long side is set last.

From those properties it follows that in every flat triangle (short sides $s_1, s_2$ and long side $l$) we have

$$V(l) > V(s_1) + V(s_2) \label{val_inequ} \tag{1}$$.

For 3 different points $A, B, C \in X$, we define $$w(A,B,C) =|d(A,B) + d(B,C) - d(A,C)|,$$ in other words how much you can change one of the distances in the triangle and still keep that instance of the triangle inequality satisfied. If $A,B,C$ form a flat triangle with $AC$ being the long side, $w(A,B,C)$ is zero, otherwise it is positive.

Let $$w_X = \min(\{w(A,B,C) > 0\}),$$ where the minimum is taken over all ordered triples $(A,B,C)$, and ignoring zero values of $w$.

$w_X$ describes the wiggle room we have when dealing with any non-flat triangle; changing one side length by less than $w_X$ is guaranteed not to violate the triangle inequality in any non-flat triangle.

Let $S$ be the shortes distance between any two different points of $X$. Let $M$ be the maximum evaluation $V$ of any edge. We can now define

$$\delta = \frac12 \min \left(\frac{w_X}{3M}, \frac\epsilon{M}, \frac{S}{M}\right).$$

We can now define new distances between points as follows:

For each set $\{A, B\}$ of different points of $X$, let

$$d_{nf}(A,B) = d(A,B) - V(e_{\{A,B\}})\delta.$$

As can be seen, the new disctances are smaller or equal to the old ones. Since a distance changes by at most $M\delta$, we can see that the choice of $\delta$ makes sure no distance becomes negative or zero and each distance change is at most than $\frac\epsilon{2}$.

What needs to be verified is that the new distances are also a metric. Positive definiteness has just been mentioned, the definition make it symmetric as well. So the triangle inequalities are left to be checked.

For all non-flat triangles, since each side changes by less than $\frac{w_X}3$, the triangle inequality is guaranteed to be true, and the triangle remains non-flat. The same is true for the 'non-critical' triangle inequalities in flat triangles.

For the triangle inequality of the long side $AC$ of a flat triangle $ABC$ we have, using \eqref{val_inequ}

$$d_{nf}(A,C) = d(A,C) - V(e_{\{A,C\}})\delta < d(A,C) - (V(e_{\{A,B\}}) + V(e_{\{B,C\}}))\delta = d(A,B) + d (B,C) - V(e_{\{A,B\}})\delta - V(e_{\{B,C\}})\delta = d_{nf}(A,B) + d_{nf}(B,C)$$

That means that not only is the triangular inequality true, it has changed the triangle into a non-flat one.

So we are now at the point we hoped to get: We have a new metric defined on $X$, with the values at most $\frac\epsilon{2}$ away from the original, where there are no longer flat triangles.

As explained above, we can now change each distance that is a duplicate of another 'a little bit' and need not worry about having to adjust other distances to correct for a no longer true triangular inequality.

Ingix
  • 15,665
3

I would suggest pursuing the perturbation idea.

Start with a known metric on $X$ for which there are "no lines", by which I mean that for each distinct triple of points, each of the three triangle inequalities for that triple is strict. For example, start the discrete metric where every nonzero distance equals $1$ (this is actually realized by the vertices of an appropriate simplex in Euclidean space).

Now kick it: choose some tiny $\epsilon > 0$, and replace each of the "$|X|$ choose $2$" distances by some number within $\epsilon$. Make sure all of these replacements are pairwise nonequal. Because there are no lines, the triangle inequality is an open condition, so as long as $\epsilon$ is sufficiently small, the triangle inequality is still satisfied under small kicks.

Lee Mosher
  • 135,265
2

Here is a nearly entirely non-symbolic proof.

  1. The sum of two metric spaces is a metric space.

  2. There exists a metric on any finite set that is a distinct distance space.

This isn't begging the question because we aren't required to make our metric space related to $d_X$ in any way. It just has to exist.

  1. Given a metric on a finite set, you can scale its norm (max distance between any two elements) to be as small as you want.

Let $\epsilon'$ be less than half the minimum non-zero difference in distance in $(X,d_X)$ - ie, $inf\{||d_X(a,b) - d_X(c,d)|| \mid a,b,c,d \in X, d_X(a,b) \neq d_X(c,d)\}$ , and also less than $\epsilon$. This is the "granularity" of $d_X$, how close pairs of distances get to each other. Distances that are equal to each other are easy to solve - it is distances that are "almost equal" that can cause a problem. We are setting $\epsilon'$ to be sufficiently smaller than the delta of "almost equal" distances. (Ie, if we have $d_X(a,b)$ equal to $d_X(c,d)$, it doesn't contribute to $\epsilon'$, but if they are not equal $\epsilon'$ must be smaller than their difference. This is guaranteed to exist because we have finite number of points, hence a finite number of differences, hence a finite number of pairs of difference - just list them all, find the smallest non-zero one, and halve it).

Let $(X,d_{Z_{\epsilon'}})$ be a distinct distance space on X with norm of $\epsilon'$ or smaller. This is our "perturbation" distance space. By making our perturbation be sufficiently smaller than the "granularity" of our $d_X$ we ensure that adding them produces a distinct distance space:

Take $d_Y = d_X + d_{Z_{\epsilon'}}$.

$d_Y$ is the sum of two metrics, so is a metric. This short-cut means we can skip checking the triangle inequality etc.

The only thing remaining to check is if this is a distinct metric space. While $d_{Z_{\epsilon'}}$ is a distinct metric space, possibly adding $d_X$ to it caused some collisions in the set of distances.

We don't get collisions because either two $d_X$ distances are exactly equal (in which case adding the $d_{Z_{\epsilon'}}$ to both results in distinct values), or the $d_X$ distances differ by more than $2 \epsilon'$. The two $d_{Z_{\epsilon'}}$ components add at most $2 \epsilon'$ to them, which cannot "catch up" to the gap that exists.

To show this symbolically, take 2 pairs of points, subtract the $d_Y$ of them and show it isn't equal to 0; either delta $d_X$ is zero or it isn't, and both result in a non-zero difference.

Yakk
  • 1,581
1

We can construct the desired distinct metric as the shortest-path distance metric on a weighted complete graph $G = (X, E, l)$, where the edge lengths are chosen to satisfy $d_X(x, y) \leq l(x, y) \leq d_X(x, y) + \epsilon$ for all $x, y \in X$, and no two different paths in the graph have the same total length.

As a concrete example, define $\epsilon' = \frac{\epsilon}{2}$ and $l(x,y) = \epsilon' ( \lceil \frac{d_X(x,y)}{\epsilon'} \rceil + 2^{-(x|X|+y)} )$ for $x < y$, assuming $X$ is labeled by integers $\{0, 1, \dots, |X|-1\}$.

For every path, their total length modulo $\epsilon'$ will be the sum of $2^{-(x|X|+y)}$ terms, uniquely encoding the set of edges, so no two different paths can have the same total length. We can also check the approximation $d_X(x,y) \leq d_G(x,y) \leq l(x,y) \lt d_X(x,y) + \epsilon$, as desired.

pcpthm
  • 211