Monday, April 29, 2013

How exclusive is your or?

An operation shared by Boolean algebras such as propositional logic, switching theory, conditional statements in programming, and computer logic design is the 'exclusive or'.  It also occurs in set theory and geometric modeling as 'symmetric difference'. It is defined as x + y = (x v y) ^ ~(x ^ y) = (x v y) ^ (~x v ~y) and is usually represented by a plus sign inside a circle, but to avoid the need for a formula-drawing editor, it will be represented as a plus sign, '+'.

 'Exclusive or' is commutative and associative, that is, x + y = y + x and (x + y) + z = x + (y + z).  Also, x + x = 0, so if an operand in a sequence of 'exclusive or's occurs twice, both can be eliminated.

A major property of 'exclusive or' is that when the result is exclusive-ored with either of the operands, the result is the other operand, that is, (x + y) + x = y and (x + y) + y = x. This allows us to recover an operand, which is useful in correction of errors in transmitted or stored data and can be used to obfuscate data, but such obfuscation is not strong encryption unless one operand is random and known only the the sender and intended receiver.

'Exclusive or' is used in circuit design to implement one-bit (arithmetic) addition with carry by combining two 'exclusive or's (x + y and the sum bit (x + y) + c) with an 'and'  ( (x v y) ^ c) and an 'or' ( (x ^ y) v ( (x v y) ^ c), which is the carry into the next bit), where c is the carry from the previous bit (and re-using the 'and' and 'or' parts of the x + y 'exclusive or').  In set theory, 'symmetric difference' can be used to form a set (partition) of mutually exclusive and collectively exhaustive subsets (blocks of the partition) from a set. In computer programming, 'exclusive or' can be used to swap the contents of two storage locations or registers, error correction (as explained above), and creating a short 'hash key' or lookup key from a longer bit string.

0 Comments:

Post a Comment

Please enter your comment here. Comments wil be reviewed before being published.

Subscribe to Post Comments [Atom]

<< Home