// reference · XOR
⊕ Exclusive Disjunction_
Exclusive disjunction, known as XOR, expresses "either p or q, but not both". The expression p ⊕ q is true when exactly one of the two propositions is true and false when they agree. It is the everyday exclusive "or" made formal.
Truth table: p ⊕ q
| p | q | p ⊕ q★ |
|---|---|---|
| T | T | F |
| T | F | T |
| F | T | T |
| F | F | F |
Classification: Contingency · 4 rows
Definition
p ⊕ q is true when p and q have different truth values and false when they have the same. Unlike inclusive disjunction ∨, exclusive disjunction rejects the case where both are true.
Alternative symbols: p ⊻ q, p XOR q, p ≢ q (not equivalent), and some texts call p ⊕ q "addition modulo 2" because it matches adding bits and keeping the remainder after dividing by 2. The calculator accepts ⊕ and ⊻.
How to read it
p ⊕ q is read "either p or q", "p or else q", "p or q but not both", or "exactly one of p and q". In English, "either... or..." usually signals exclusivity.
Example: "the set menu comes with either soup or salad" formalizes as p ⊕ q because you cannot pick both.
When it is true
The table has four rows. With p = T and q = T, p ⊕ q = F. With p = T and q = F, p ⊕ q = T. With p = F and q = T, p ⊕ q = T. With p = F and q = F, p ⊕ q = F.
Two true rows and two false rows: it is a contingency. Compare with ∨: the only difference is the first row, where both are true (∨ gives T, ⊕ gives F).
Everyday example
A hallway light with a switch at each end works like XOR: the light is on when exactly one switch is up. If both are up or both are down, the light is off. Flipping either switch toggles the state.
In cryptography, a bit is encrypted with a key using XOR: message ⊕ key = ciphertext, and ciphertext ⊕ key = message. This works because p ⊕ q ⊕ q ≡ p.
Properties and equivalences
Equivalent definitions: p ⊕ q ≡ (p ∨ q) ∧ ¬(p ∧ q), p ⊕ q ≡ (p ∧ ¬q) ∨ (¬p ∧ q), and p ⊕ q ≡ ¬(p ⇔ q). It also matches the negated biconditional: p ⊕ q ≡ p ⇎ q.
It is commutative and associative. Identity: p ⊕ 0 ≡ p. Negation: p ⊕ 1 ≡ ¬p. Self-inverse: p ⊕ p ≡ 0 (always false). These properties make it central to adder circuits and parity checkers.
Common mistakes
Using ∨ when the statement is exclusive. If the problem says "but not both", inclusive disjunction gives the wrong result in the (T, T) row.
Assuming XOR of three variables means "exactly one is true". In fact p ⊕ q ⊕ r is true when an odd number of variables are true (one or all three), because it is addition modulo 2.
Equivalent expressions
Try it yourself
Edit the expression in the calculator and watch how every step of the table changes.
Open in the calculator →Related laws and rules
Logical equivalence
Definition of XOR
(p ⊕ q) ⇔ ((p ∨ q) ∧ ¬(p ∧ q))
Logical equivalence
Definition of the biconditional
(p ⇔ q) ⇔ ((p ⇒ q) ∧ (q ⇒ p))
Logical equivalence
De Morgan's law (conjunction)
¬(p ∧ q) ⇔ (¬p ∨ ¬q)
Logical equivalence
Distributive law of ∧ over ∨
(p ∧ (q ∨ r)) ⇔ ((p ∧ q) ∨ (p ∧ r))
Frequently asked questions
What is the difference between ⊕ and ∨? ▼
They differ only when p and q are both true: ∨ gives true and ⊕ gives false. Inclusive disjunction allows "one or both"; exclusive disjunction demands "exactly one".
Why is XOR called addition modulo 2? ▼
Because if you write T as 1 and F as 0, p ⊕ q equals the remainder of (p + q) divided by 2: 1 + 1 = 2 ≡ 0, 1 + 0 = 1, 0 + 0 = 0.
How is XOR related to the biconditional? ▼
They are each other's negation: p ⊕ q ≡ ¬(p ⇔ q). One is true exactly when the other is false.
