Opentopia Directory Encyclopedia Tools

Exclusive disjunction

Encyclopedia : E : EX : EXC : Exclusive disjunction


"XOR" redirects here. For , see .

Exclusive disjunction, also known as exclusive or and symbolized by XOR or EOR, is a logical operation on two operands that results in a logical value of true if and only if one of the operands, but not both, has a value of ''true.

Definition

In many natural languages, English included, the interpretation of the word "or" requires a certain amount of care. The exclusive disjunction of a pair of propositions, (p, q), means that p is true or q is true, but not both. For example, the normal intention of a statement like "You can follow the rules or be disqualified" is to stipulate that exactly one of the conditions can be true. In logic, however, the default meaning of the word "or" is the inclusive disjunction, which signifies that at least one of the alternatives is true. Other languages, such as Latin, may have different words for these different types of "or".

Exclusive disjunction is an operation on two logical values, typically the values of two propositions, that produces a value of true if and only if one but not both of its operands is true.

The truth table of p XOR q (also written as p + q, p ⊕ q, or p ≠ q) is as follows:

Truth Table: Exclusive Disjunction
p q p XOR q
F F F
F T T
T F T
T T F

The following equivalents can then be deduced:

[\beginp + q & = & (p \land \lnot q) & \lor & (\lnot p \land q) \\\\ & = & (p \lor q) & \land & (\lnot p \lor \lnot q) \\\\ & = & (p \lor q) & \land & \lnot (p \land q)\end]
Generalized or n-ary XOR is true when the number of 1-bits is odd.

Alternative symbols

The symbol used for exclusive disjunction varies from one field of application to the next, and even depends on the properties being emphaisized in a given context of discussion. In addition to the abbreviation "XOR", any of the following symbols may also be seen:
Operation Table: Sum Modulo 2
p q p + q
0 0 0
0 1 1
1 0 1
1 1 0

Equivalent expressions

The exclusive disjunction [p + q\!] can be expressed in terms of the conjunction (∧), the disjunction (∨), and the negation (¬) as follows:

[\beginp + q & = & (p \land \lnot q) \lor (\lnot p \land q)\end]
The exclusive disjunction [p + q\!] can also be expressed in the following way:

[\beginp + q & = & \lnot (p \land q) \land (p \lor q)\end]
This representation of XOR may be found useful when constructing a circuit or network, because it has only one ¬ operation and small number of ∧ and ∨ operations. The proof of this identity is given below:

[\beginp + q & = & (p \land \lnot q) & \lor & (\lnot p \land q) \\& = & ((p \land \lnot q) \lor \lnot p) & \and & ((p \land \lnot q) \lor q) \\& = & ((p \lor \lnot q) \land (\lnot q \lor \lnot p)) & \land & ((p \lor q) \land (\lnot q \lor q)) \\& = & (\lnot p \lor \lnot q) & \land & (p \lor q) \\& = & \lnot (p \land q) & \land & (p \lor q)\end]
It is sometimes useful to write p XOR q in the following way:

[\beginp + q & = & \lnot ((p \land q) \lor (\lnot p \land \lnot q))\end]
This equivalence can be established by applying De Morgan's laws twice to the fourth line of the above proof.

Associativity and commutativity

In view of the isomorphism between addition modulo 2 and exclusive disjunction, it is clear that XOR is both an associative and a commutative operation. Thus parentheses may be omitted in successive operations and the order of terms makes no difference to the result. For example, we have the following equations:

[\beginp + q & = & q + p \\\\(p + q) + r & = & p + (q + r) & = & p + q + r\end]

Properties

This section uses the following symbols:

[\begin0 & = & \mbox \\1 & = & \mbox \\\lnot p & = & \mbox\ p \\p + q & = & p\ \mbox\ q \\p \land q & = & p\ \mbox\ q \\p \lor q & = & p\ \mbox \ q\end]
The following equations follow from logical axioms:

[\beginp + 0 & = & p \\p + 1 & = & \lnot p \\p + p & = & 0 \\p + \lnot p & = & 1 \\\\p + q & = & q + p \\p + q + p & = & q \\p + (q + r) & = & (p + q) + r \\p + q & = & \lnot p + \lnot q \\\lnot (p + q) & = & \lnot p + q & = & p + \lnot q \\\\p + (\lnot p \land q) & = & p \lor q \\p + (p \land \lnot q) & = & p \land q \\p + (p \lor q) & = & \lnot p \land q \\\lnot p + (p \lor \lnot q) & = & p \lor q \\p \land (p + \lnot q) & = & p \land q \\p \lor (p + q) & = & p \lor q\end]

Bitwise operation

Exclusive disjunction is often used for bitwise operations. Examples:

Computer science

In computer science, exclusive disjunction has several uses:

On some computer architectures, it is more efficient to store a zero in a register by xor-ing the register with itself (bits xor-ed with themselves are always zero) instead of loading and storing the value zero. In simple threshold activated neural networks, modelling the 'xor' function requires a second layer because 'xor' is not a linearly-separable function.

Exclusive-or is sometimes used as a simple mixing function in cryptography, for example, with one-time pad or Feistel network systems.

XOR is used in RAID 3–6 for creating parity information. For example, RAID can "back up" bytes 10011100 and 01101100 from two (or more) hard drives by XORing (11110000) and writing to an another drive. Under this method, if any one of the four hard drives are lost, the lost byte can be re-created by XORing bytes from the remaining drives. If the drive containing 01101100 is lost, 10011100 and 11110000 can be XORed to recover the lost byte.

XOR is also used to detect an overflow in the result of a signed binary arithmetic operation. If the leftmost retained bit of the result is not the same as the infinite number of digits to the left, then that means overflow occurred. XORing those two bits will give a "one" if there is an overflow..

See also

Other operators

| width="" align="" valign="" style="padding-left:;"|

| width="" align="" valign="" style="padding-left:;"|

|}

Related topics

| width="" align="" valign="" style="padding-left:;"|

| width="" align="" valign="" style="padding-left:;"|

| width="" align="" valign="" style="padding-left:;"|

|}

External Links

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: