Topic 3 of 13
Boolean Algebra & Logic Gates
The algebra behind every circuit: laws, DeMorgan, gates, minterms and canonical forms.
← → move between slides · F full screen · M slide list
Before we start
Why this matters
Ever flicked a light switch downstairs and watched the same lamp turn off from a switch upstairs, like the house was gaslighting you?
Relax, it's not haunted — it's a logic gate hiding inside your wall, and by the end of this chapter you'll know exactly which one (spoiler: it's the drama queen of gates). Boolean algebra turns out to be the exact same rules you already use to win an argument, except now a light bulb has to obey them too.
Outline
Topics in this chapter
Select a topic to jump to the slide that explains it.
Concept 1 of 5
Variables and operations
A Boolean variable is 0 or 1. The three operations are AND (A·B or AB), OR (A+B) and NOT (A). NOT binds tightest, then AND, then OR.
Concept 2 of 5
Laws and identities
| Law | Form | Dual form |
|---|---|---|
| Identity | A+0 = A | A·1 = A |
| Null | A+1 = 1 | A·0 = 0 |
| Idempotent | A+A = A | A·A = A |
| Complement | A+A = 1 | A·A = 0 |
| Commutative | A+B = B+A | AB = BA |
| Associative | (A+B)+C = A+(B+C) | (AB)C = A(BC) |
| Distributive | A(B+C) = AB+AC | A+BC = (A+B)(A+C) |
| Absorption | A+AB = A | A(A+B) = A |
| Involution | (A′)′ = A | (A′)′ = A |
| Useful | A+AB = A+B | XY+XZ+YZ = XY+XZ |
Concept 2 of 5
Laws and identities (cont.)
Duality: swap + with ·, and 0 with 1. Every law has a dual that is also true.
Concept 3 of 5
DeMorgan’s theorems
AB = A + B
Steps: A + B = A·B
- Start with the negated OR: A + B.
- Swap the operator: OR becomes AND.
- Complement every literal: A → A, B → B.
- Result: A · B = A·B.
Steps: AB = A + B
- Start with the negated AND: AB.
- Swap the operator: AND becomes OR.
- Complement every literal: A → A, B → B.
- Result: A + B.
They extend to any number of variables: A + B + C = A·B·C. To complement a whole function, complement every literal and swap AND with OR.
Interactive circuit
DeMorgan: AB equals A + B
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Concept 4 of 5
Logic gates
XOR outputs 1 when its inputs differ, XNOR when they are equal. Switch analogy: AND is two switches in series (both must close), OR is two switches in parallel (either may close).
Real life
Switch analogy: series and parallel
Click the switches. Two switches in series behave like AND. Two switches in parallel behave like OR.
Real life
Switch analogy: buffer and NOT
Click the switch. A buffer wires it in series with the lamp, so the lamp just repeats it. A NOT wires the same switch in parallel with the lamp instead — closing it shorts the lamp out, so the lamp shows the opposite.
Real life
Switch analogy: NAND and NOR
The exact same series (AND) and parallel (OR) switch pairs as before, but now wired in parallel with the lamp instead of in its path — so closing the AND pair shorts the lamp out for NAND, and closing the OR pair shorts it out for NOR.
Real life
Switch analogy: XOR and XNOR
A single series/parallel pair can't tell “A and B differ” from “A and B agree”. Wire up their SOP form directly — two series pairs in parallel — and you get exactly that: the two-way staircase-light switch.
Real life · AND gate
AND in real life: microwave oven
Real life · OR gate
OR in real life: burglar alarm
Real life · NOT gate
NOT in real life: street light
Real life · NAND gate
NAND in real life: lift warning lamp
Real life · NOR gate
NOR in real life: vacant sign
Real life · XOR gate
XOR in real life: staircase light
Real life · XNOR gate
XNOR in real life: sensors agree
Real life
Basic gates and their real-life examples
| Gate | Real-life example | Rule |
|---|---|---|
| AND | Microwave: door closed AND start pressed | Both inputs 1 |
| OR | Burglar alarm: door OR window sensor | At least one input 1 |
| NOT | Street lamp: on when NOT daylight | Opposite of the input |
| NAND | Lift warning lamp: on unless doors locked AND load OK | 0 only when both inputs 1 |
| NOR | Vacant sign: neither door NOR motion sensor active | 1 only when both inputs 0 |
| XOR | Two-way staircase light | 1 when inputs differ |
| XNOR | Redundant sensors agree | 1 when inputs are equal |
Concept 5 of 5
Minterms, maxterms and canonical forms
A minterm is a product term in which every variable appears once. It is 1 for exactly one input combination. m₃ for A,B,C is ABC (011). A maxterm is a sum term that is 0 for exactly one combination. M₃ = A+B+C.
- Canonical SOP: OR of the minterms where F = 1, written Σm(…).
- Canonical POS: AND of the maxterms where F = 0, written ΠM(…).
- Standard forms are SOP or POS with fewer literals than canonical form. They are not unique.
Concept 5 of 5
Minterms, maxterms and canonical forms (cont.)
To get an expression from a truth table, take each row with output 1, write its product term, and OR them. To get a circuit from an expression, generate complements, build the product terms, then OR them.
For any index j, minterm and maxterm are complements of each other: mj = Mj′. Because of this, a canonical SOP converts to canonical POS (or back) by swapping Σ for Π and replacing the list of indices with the ones missing from it: Σm(1,2,4,6) on 3 variables = ΠM(0,3,5,7).
Truth tables
Truth tables (1 of 2)
NOT and buffer
| A | NOT A | Buffer |
|---|---|---|
| 0 | 1 | 0 |
| 1 | 0 | 1 |
All two-input gates
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Minterms and maxterms of A, B, C
| # | A | B | C | Minterm | Maxterm |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | A·B·C | (A+B+C) |
| 1 | 0 | 0 | 1 | A·BC | (A+B+C) |
| 2 | 0 | 1 | 0 | ABC | (A+B+C) |
| 3 | 0 | 1 | 1 | ABC | (A+B+C) |
| 4 | 1 | 0 | 0 | AB·C | (A+B+C) |
| 5 | 1 | 0 | 1 | ABC | (A+B+C) |
| 6 | 1 | 1 | 0 | ABC | (A+B+C) |
| 7 | 1 | 1 | 1 | ABC | (A+B+C) |
Truth tables
Truth tables (2 of 2)
DeMorgan check: A + B = A·B
| A | B | A+B | A+B | A | B | A·B |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
The highlighted columns match in every row, so A + B = A·B.
DeMorgan check: AB = A + B
| A | B | AB | AB | A | B | A+B |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
The highlighted columns match in every row, so AB = A + B.
Interactive
Demo: Boolean expression simplifier
Worked example 1 of 4
Worked example 1
Show the solution
- A + AB = (A + A)(A + B), by the distributive law.
- = 1·(A + B)
- = A + B
Worked example 2 of 4
Worked example 2
Show the solution
- AB + C = AB · C
- = (A + B)C
Worked example 3 of 4
Worked example 3
Show the solution
- YZ = YZ(X + X) = XYZ + XYZ.
- XYZ is absorbed by XY, and XYZ is absorbed by XZ.
- Result XY + XZ.
Worked example 4 of 4
Worked example 4
Show the solution
- a′b′c already has all 3 variables, so it is already a minterm: m₁.
- bc′ is missing a, so multiply by (a+a′): bc′ = abc′ + a′bc′.
- ac′ is missing b, so multiply by (b+b′): ac′ = abc′ + ab′c′.
- Collect all the terms and drop the duplicate abc′: f = a′b′c + abc′ + a′bc′ + ab′c′.
Practice
Practice (1 of 2)
Try each one on paper first, then check your answer.
Show the answer
Show the answer
Show the answer
Practice
Practice (2 of 2)
Try each one on paper first, then check your answer.
Show the answer
Wire each gate yourself and check it with the Truth table tester. Try building AB and A + B side by side.
Gate ForgeA free circuit simulator — place and wire gates, generate truth tables and timing diagrams, and work through 90+ guided problems.Check yourself
Quiz
Summary
Summary
- Precedence: NOT, then AND, then OR.
- DeMorgan: A+B = A·B and AB = A + B.
- A minterm is 1 for one row. Σm lists the 1 rows, ΠM lists the 0 rows.
- XOR is 1 when inputs differ. XNOR is 1 when they are equal.
- Truth table, expression and circuit describe the same function three ways.