Relationship between bitwise XOR and the equations

648 Views Asked by At

I am studying bitwise XOR.

If a, b, c are integers ranging from 0 to 18,446,744,073,709,551,615, I belive the following work for both $=$ and $\neq$:

$1.\forall a,b,c(a=b\to a \oplus c=b \oplus c)$

$2.\forall a,b,c(a \oplus c=b \oplus c\to a=b)$

$3.\forall a,b,c(a\neq b\to a \oplus c\neq b \oplus c)$

$4.\forall a,b,c(a\oplus c\neq b\oplus c\to a\neq b)$

But the above will not work for $<, \le, >, \ge$.

Is that correct?

1

There are 1 best solutions below

2
On BEST ANSWER

For equality:

Statement $(1)$ is true.

Statement $(2)$ is true since if $a\oplus c = b \oplus c$ then we have $(a \oplus c)\oplus c = (b \oplus c) \oplus c$, using the associative property, we have

$$a \oplus (c \oplus c) = b \oplus (c \oplus c)$$

$$a = b$$

$(3)$ is true since $(2)$ an $(3)$ are equivalent.

$(1)$ and $(4)$ are equivalent, hence $(4)$ is correct as well.


It doesn't work on inequalities. To see counterexamples, choose $0$ to be the smaller element and pick $1$ to be the bigger element, picking $c=0$ would preserve the inequalities but picking $c=1$ would switch the direction of the inequalities.

For example.

  • Conjecture: if $\forall a, b, c , a < b$ then $a \oplus c < b \oplus c $.

This is false since $0 < 1$, but $0 \oplus 1 = 1$ and $1 \oplus 1 = 0$.