Lesson 2: XOR: exclusive OR and parity (beginner, 10 min)
Exclusive or in three steps: how A XOR B differs from A OR B, why a stairwell light is downstairs XOR upstairs, and why A XOR B XOR C means odd parity rather than “exactly one”. Beginner level, about ten minutes.
Tell inclusive OR from exclusive OR, use XOR for toggles, and see why a chain of XORs means odd parity, not “exactly one”.
The first step sets inclusive and exclusive or side by side on one four-row table; they agree on three rows and part on the row where both inputs are TRUE. The second step makes XOR physical: a light with a switch at the bottom and the top of the stairs, where flipping either switch changes the light whatever the other is set to. The third step is the one people need most, the chain. A XOR B XOR C is TRUE when one or three inputs are TRUE, and the step compares it with the written-out “exactly one of three” to show the row where they differ.
Both comparisons in the lesson are verified claims: the engine re-checks at build time that the pairs differ exactly where the text says. The exercises ask for the value of a three-way XOR when all inputs are TRUE, a truth-table column for the stairwell light, a rewrite of XOR using only AND, OR and NOT, and the assignment on which OR and XOR disagree.
The lesson connects to two pitfall pages (inclusive versus exclusive or, and the parity trap) and to the XOR identities, which prove A XOR A = FALSE and A XOR TRUE = NOT A, the two facts behind toggles and parity bits.
Do this lesson interactively in the app
Steps
1. Inclusive or exclusive?
A OR B is TRUE when at least one input is TRUE. A XOR B is TRUE when the inputs differ: one or the other, but not both.
The two operators agree on three of the four rows and disagree only when both inputs are TRUE.
inclusive := A OR B · outputexclusive := A XOR B · output | # | A | B | inclusive | exclusive |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | TRUE | TRUE | TRUE |
| 2 | TRUE | FALSE | TRUE | TRUE |
| 3 | TRUE | TRUE | TRUE | FALSE |
Set A and B to TRUE and compare inclusive with exclusive.
not-equivalent inclusive / exclusive · holds
2. XOR as a toggle
A stairwell light with one switch at the bottom and one at the top: light := downstairs XOR upstairs. Flipping either switch changes the light, whatever the other switch shows.
That is the key property of XOR: changing a single input always flips the output.
light := downstairs XOR upstairs · output downstairs: the switch at the bottom of the stairs is on; upstairs: the switch at the top of the stairs is on; light: the stairwell light is on;
| # | downstairs | upstairs | light |
|---|---|---|---|
| 0 | FALSE | FALSE | FALSE |
| 1 | FALSE | TRUE | TRUE |
| 2 | TRUE | FALSE | TRUE |
| 3 | TRUE | TRUE | FALSE |
Start with both switches FALSE, then flip them one at a time and watch light.
3. Chains of XOR: odd parity
A XOR B XOR C is TRUE when an odd number of inputs are TRUE: one or three. It does not mean “exactly one of A, B, C”: with all three TRUE, the chain is TRUE.
“Exactly one” needs its own formula, such as exactly_one here. Compare both outputs on the row where every input is TRUE.
parity := A XOR B XOR C · outputexactly_one := (A AND NOT B AND NOT C) OR (NOT A AND B AND NOT C) OR (NOT A AND NOT B AND C) · output | # | A | B | C | parity | exactly_one |
|---|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | TRUE | TRUE |
| 2 | FALSE | TRUE | FALSE | TRUE | TRUE |
| 3 | FALSE | TRUE | TRUE | FALSE | FALSE |
| 4 | TRUE | FALSE | FALSE | TRUE | TRUE |
| 5 | TRUE | FALSE | TRUE | FALSE | FALSE |
| 6 | TRUE | TRUE | FALSE | FALSE | FALSE |
| 7 | TRUE | TRUE | TRUE | TRUE | FALSE |
Set A, B, and C all to TRUE: parity is TRUE, while exactly_one is FALSE.
not-equivalent parity / exactly_one · holds
Exercises
- With
A=TRUE, B=TRUE, C=TRUE, what isA XOR B XOR C? (predict-output) - Fill in the
lightcolumn fordownstairs XOR upstairs(downstairsfirst). (truth-table) - Write a formula equivalent to
A XOR Busing onlyAND,OR, andNOT. (write-equivalent) - Find the assignment on which
A OR BandA XOR Bdisagree:inclusiveis TRUE butexclusiveis FALSE. (find-assignment)
Do this lesson interactively in the app
Questions
Is XOR the “or” of everyday speech?
Often, which is the problem: “tea or coffee” is exclusive, while logic's OR is inclusive. The lesson's first step is the table that settles which one a rule needs.
What is XOR with AND, OR and NOT?
(A AND NOT B) OR (NOT A AND B), one term per way the inputs can differ. The third exercise asks for exactly this rewrite, and the XOR elimination law proves it.
Related
Laws
- XOR identities: A XOR FALSE = A, A XOR TRUE = NOT A, A XOR A = FALSE
- XOR elimination: A XOR B = (A AND NOT B) OR (NOT A AND B)
- XNOR elimination: XNOR(A, B) = A ↔ B
Tools
See also
- XOR gate: truth table for 2, 3 and 4 inputs (odd parity, not “exactly one”)
- XOR identities: A XOR FALSE = A, A XOR TRUE = NOT A, A XOR A = FALSE
- XOR elimination: A XOR B = (A AND NOT B) OR (NOT A AND B)
- Inclusive vs exclusive or (OR vs XOR), with truth table
- XOR of three inputs is odd parity, not “exactly one”
- Staircase light with three switches: A XOR B XOR C
- Exactly one of three: why XOR is the wrong tool
Lessons
Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.