TITLE: Is there an associative metric on the non-negative reals?
QUESTION [34 upvotes]: Recall that a function $f\colon X\times X \to \mathbb{R}_{\ge 0}$ is a metric if it satisfies:

definiteness: $f(x,y) = 0$ iff $x=y$,
symmetry: $f(x,y)=f(y,x)$, and
the triangle inequality: $f(x,y) \le f(x,z) + f(z,y)$.

A function $f\colon X\times X \to X$ is associative if it satisfies:

associativity: $f(x,f(y,z)) = f(f(x,y),z)$.

If $X=\mathbb{R}_{\ge 0}$, then it might be possible for the same function to be a metric and associative.
Is there an associative  metric on the non-negative reals?
Note that these demands actually make $X$ into a group.  The element $0$ is the identity because $f(f(0,x),x) = f(0,f(x,x)) = f(0,0) = 0$ by associativity and definiteness, so again by definiteness $f(0,x) = x$.  Every element is its own inverse because $f(x,x)=0$.  
In fact, the following question is equivalent.  Is there an abelian group on the non-negative reals such that the group operation satisfies the triangle inequality?
Note also that the answer is yes if $X=\mathbb{N}$, the non-negative numbers!  Click here for a spoiler.
"Also known as nim-sum."
The question is originally due to John H. Conway.  To my knowledge, the question is unsolved even for $X = \mathbb{Q}_{\ge 0}$, but he does not seem to care about that case.  The spoiler above does extend to the non-negative dyadic rationals $\mathbb{N}[\frac 12]$, but apparently not to $\mathbb{N}[\frac 13]$.

REPLY [3 votes]: I'd like to present a proof without transfinite induction. As has been mentioned, such a commutative group is a vector space over $\mathbb{F}_2$. It seems we cannot write down a Hamel basis explicitly, which means this proof is not constructive either. But by the Axiom of Choice, a Hamel basis exists. Denote this basis by $\mathcal{B}$. By definition, each $x \in \mathbb{R_{\geq 0}}$ can be uniquely identified with a finite subset $X \subset \mathcal{B}$ such that $x = \sum X$. (Here and throughout we write $\sum X := \sum_{x \in X}x$ as a shorthand; read $\sum X$ as 'sum the elements of $X$').
Claim: Let $x = \sum X$ and $y = \sum Y$ such that $X,Y$ are finite subsets of the aforementioned Hamel basis $\mathcal{B}$. Then $f(x,y) = \sum X \triangle Y$ is an associative metric on $\mathbb{R}_{\geq 0}$ where $\triangle$ is the symmetric difference $X \triangle Y := (X \cup Y)\setminus (X \cap Y)$.
Proof: First we check associativity, which follows from the associativity of the symmetric difference: \begin{align*} f(f(x,y),z) &= f\left(\sum X \triangle Y, z\right) \\ &= \sum X \triangle Y \triangle Z \\ &= f\left(x, \sum Y \triangle Z\right) \\ &= f(x,f(y,z)).\end{align*}
To check the metric axioms is much quicker:

Definiteness: $f(x,x) = \sum X \triangle X = \sum \varnothing = 0$, and for the other direction $f(x,y) = 0 \implies X \triangle Y = \varnothing \implies X = Y \implies x=y$.
Symmetry: $f(x,y) = \sum X \triangle Y = \sum Y \triangle X = f(y,x)$.
Subadditivity: $f(x,y) = \sum X \triangle Y \leq \left(\sum X\right) + \left(\sum Y\right) = x+y$ which suffices.

And just like that, we are done. Note that although this answer is different to the accepted one, it also uses the Axiom of Choice. It would be interesting to know whether AC is not only sufficient but also necessary for such a metric to exist.


The question is unsolved even for $X = \mathbb{Q}_{\geq 0}$

Fortunately, not only is there such a metric, but it's also explicit! The Minkowski question-mark function is a continuous, strictly increasing bijection $?:\mathbb{Q}_{\geq 0} \to \mathbb{N}[\frac{1}{2}]$
given by
$$?(q) = a_0 + 2\sum_{k=1}^n \frac{(-1)^{k+1}}{2^{a_1 + \cdots + a_k}}$$ where $q = [a_0 ; a_1,...,a_n]$ is the finite continued fraction representation. Since the bitwise exclusive-or operation $\oplus$ is a well-defined metric on the dyadic rationals, the composition $$f(p,q) = ?^{-1}(?(p) \oplus ?(q))$$ is an associative metric for all $p,q \in \mathbb{Q}_{\geq 0}$.