// laws and rules · Logical equivalence
Definition of XOR_
Exclusive disjunction or XOR (p ⊕ q) is true when exactly one of the two propositions is true. It is defined from the basic operators as “p or q, and not (p and q)”: (p ⊕ q) ⇔ ((p ∨ q) ∧ ¬(p ∧ q)) is a tautology. It is the everyday “or” when we mean “one or the other”.
Example
(p ⊕ q) ⇔ ((p ∨ q) ∧ ¬(p ∧ q))
What the variables mean
- ▸ p: “I pay by card”
- ▸ q: “I pay in cash”
In plain words
“I pay by card or in cash, but not both” is exactly p ⊕ q.
Truth table
| p | q | p ⊕ q | p ∨ q | p ∧ q | ¬(p ∧ q) | (p ∨ q) ∧ ¬(p ∧ q) | (p ⊕ q) ⇔ ((p ∨ q) ∧ ¬(p ∧ q))★ |
|---|---|---|---|---|---|---|---|
| T | T | F | T | T | F | F | T |
| T | F | T | T | F | T | T | T |
| F | T | T | T | F | T | T | T |
| F | F | F | F | F | T | F | T |
Classification: Tautology · 4 rows
Statement
(p ⊕ q) ⇔ ((p ∨ q) ∧ ¬(p ∧ q)). The right-hand side decomposes XOR: the disjunction guarantees at least one is true and the negated conjunction forbids both being true.
Other equivalent forms: (p ∧ ¬q) ∨ (¬p ∧ q), and also ¬(p ⇔ q).
Why it is a tautology: reading the table
Row p = T, q = T: p ⊕ q is F. p ∨ q is T but p ∧ q is T, its negation F and the final conjunction F. They agree. Row p = F, q = F: p ⊕ q is F; p ∨ q is F and the conjunction is F. They agree.
Rows p = T, q = F and p = F, q = T: p ⊕ q is T. The disjunction is T, the conjunction p ∧ q is F, its negation T, and T ∧ T is T. The two columns are identical.
How it is used in proofs
When a formal system only has ¬, ∧ and ∨, this equivalence is the definition of ⊕ and lets you eliminate it from any formula.
In Boolean algebra XOR is addition modulo 2: p ⊕ q = (p + q) mod 2. That is why it is associative and p ⊕ p = 0.
Examples
Circuits: the XOR gate is the heart of the binary adder; the sum of two bits without carry is exactly their XOR.
Programming: `a ^ b` in C, Java or JavaScript. Classic uses are swapping two variables without a temporary or detecting that two flags differ: `if (isAdmin ^ isGuest)`.
Everyday: “The set menu includes soup or salad” at a restaurant is usually exclusive: you cannot order both.
Relation to other laws
It is the negation of the biconditional: p ⊕ q ⇔ ¬(p ⇔ q). That is why the ⇎ operator (“negated biconditional”) has the same table as ⊕.
Applying De Morgan to the right-hand side gives (p ∨ q) ∧ (¬p ∨ ¬q), a conjunctive normal form of XOR.
Try it yourself
Edit the expression in the calculator and watch how every step of the table changes.
Open in the calculator →Related operators
Frequently asked questions
What is the difference between ∨ and ⊕? ▼
∨ is true if at least one part is true (both included); ⊕ is true only if exactly one is. They differ only in the T, T row.
Is XOR associative? ▼
Yes: (p ⊕ q) ⊕ r is equivalent to p ⊕ (q ⊕ r), and the result is T when an odd number of variables are T.
Which symbols does the calculator accept for XOR? ▼
⊕ and ⊻. Both evaluate the same way.
