Exclusive disjunction
Jump to navigation
Jump to search
Exclusive disjunction
Exclusive disjunction (often abbreviated as XOR) is the logical operation that returns true if exactly one of the propositions is true, but not both.
Symbols
- p ⊕ q (standard notation)
- p XOR q (common in computer science)
- (p ∨ q) ∧ ¬(p ∧ q) (definition using basic operators)
Definition
The exclusive disjunction p ⊕ q is true if either p or q is true, but false if both are true or both are false.
Truth Table
| p | q | p ⊕ q |
|---|---|---|
| T | T | F |
| T | F | T |
| F | T | T |
| F | F | F |
Examples
- If p = "I go jogging" and q = "I go swimming",
then p ⊕ q = "I go jogging or swimming, but not both".
- In Python:
p ^ q(when p and q are booleans) - In Java:
p ^ q(when p and q are booleans)