Similarity between integer and logical operations through parity

412 Views Asked by At

Lets observe the parity property of integers while adding them or multiplying. It's simple to notice that when we add two numbers, the parity of the result depends on parity of summands:

x   y   x+y
-----------
E   E    E
E   O    O
O   E    O
O   O    E

(Here "E" stands for "even", and "O" for "odd"). There is an obvious similarity with logical XOR function (when oddness is taken as True).

Ox  Oy    Ox xor Oy
-------------------
F   F        F
T   F        T
F   T        T
T   T        F

(Ox and Oy means "oddness of x" and "... of y" resp.)

And the same thing is with multiplication, as it behaves like logical conjunction (AND).


And now the question is: why?
Thanks in advance :)

2

There are 2 best solutions below

1
On

If you replace $\top$ and $\bot$ with 1 and 0, as you noticed you can apply the rules of standard arithmetic. In fact you get a complete algebraic structure. $\bot$ is the neutral element with regards to $\lor$, $\top$ the neutral element with regards to $\land$. There also laws for combining $\lor$ and $\land$: A $\lor$ (B $\land$ C) = (A $\lor$ B) $\land$ (B $\lor$ C). See http://en.wikipedia.org/wiki/Boolean_algebra_(structure) for the full details.

Another observation you made is that subsets of $\mathbb{N}$ (or $\mathbb{Z}$), can have algebraic structures on their own. In higher algebra this is an reoccuring theme. For example prime numbers, as a subset of the natural numbers have all kinds of interesting properties. The odd and even numbers are studied in modular arithmetic. For example everybody knows that a clock has it's own arithmetic: 23 hours + 2 hour = 1 hour.

Algebra is the study of these related properties across all kinds of structures. This is not only true for logical operations (Boolean algebra), but for geometry as well (algebraic geometric). The fact that all these phenomena can be studied in a formal way is one of the most important insight of modern mathematics.

0
On

There is an isomorphism between Boolean algebras and algebras over the fields $\{0,1\}$.

Therefore calculations of parity resemble, for a very good reason, to Boolean operations on the $\{T,F\}$ Boolean algebra which is often used in mathematics.

Note that multiplication $\bmod 2$ is very much like $\lor$ (or), if either one is even (true) then the result is even (true). Addition is slightly trickier, can you find the analogue? (Hint: It's not $\land$ (and) since both $\land$ and $\lor$ are distributive over one another, which is not true for $+,\cdot$ in a field).