A cute theorem involving xor
Define , and , where is the bitwise xor function. We want to know something about .
Lemma1
Proof
is easy to see as is binary addition without carries. Assume for some and , then A contradiction. Therefore .
Remark
, binary addition without carries, and binary subtraction without borrows are the same operation. The lemma is trivial by notice that equivalence.
Theorem2
If a surjection such that , then
Proof
is a surjection implies all values in any integer interval gets taken.
- If , .
- If , .
Let , noting that is a bijection, we derive the result we want for xor.
Corollary3
- .
- .