Continuous extension of XOR

The $\text{XOR}$ function is a function from $\{0,1\}^2$ to $\{0,1\}$, defined as:

$\text{XOR}(0,0)=\text{XOR}(1,1)=0$

$\text{XOR}(1,0)=\text{XOR}(0,1)=1$

I am interested in finding an extension of this function to $\mathbb{R}$. To be more specific, I am looking for a function $f$ from $\mathbb{R}^2$ to $\mathbb{R}$ with the following properties (for all $x,y,z\in\mathbb{R}$):

  • $f(x,y)=f(y,x)$

  • $f(x,0)=x$

  • $f(x,x)=0$

  • $f(x,f(y,z))=f(f(x,y),z)$

  • $f$ is continuous

Does such a function exist? If yes, how do I construct it? If not, how do I prove so?


Solution 1:

Let's denote $f(x,y) = x \circ y$. We have:

1)$x \circ y = y \circ x$

2)$x \circ x = 0$

3) $x \circ 0 = x$

4)$(x \circ y)\circ z = x \circ (y \circ z)$

Setting $x = y$ in $(4)$ we get $(x \circ x)\circ z = x \circ (x \circ z) \rightarrow 0 \circ z = x \circ (x \circ z) \implies z = x \circ (x \circ z) $.

$$x \circ (x \circ z) = z$$ $$f(x,f(x,z)) = z$$

This means $\circ$ behaves on $R$ like the composition for an abelian group where every non-trivial element is of order $2$. Our $f$ can be defined by pulling back the group composition operation trough a bijection between $\mathbb{R}$ and an uncountable product of $Z_{2}$ (where the trivial element corresponds to $0$). We shall now prove that such an $f$ cannot be continuous.

Consider $g(x) = f(1,x)$. If $f$ is continuous, so is $g$. We have $g(0) = 1$ and $g(1) = 0$. Consider $h(x) = g(x) - x$. We have $h(0) = 1$ and $h(1) = -1$. By the intermediate value theorem, there exists $y\in (0,1)$ such that $h(y) = 0$ . Therefore, there exists $y \in (0,1)$ such that $g(y) = y$. So $f(1,y) = y$. But $f(f(1,y),y) = f(y,y)$. So $1 = 0$ . Contradiction. A continuous $f$ satisfying $1-4$ does not exist.


Edit: Imho $\text{XOR}$ behaves like bit addition. We can identify every real number with its remainder mod. 2. That is $3.31 \rightarrow 1.31$ and $8.161616 \rightarrow 0.161616$, etc. Then $a$ $\text{XOR}$ $b$ becomes $a + b$. This is informally defined on $[0,2)$. The alternative would be to simply make bit-wise $\text{XOR}$ with numbers written as base $2$ sequences. Eg. $0.101101...\:\:\text{XOR}\:\:0.011 = 0.110101... $.