Electronics
Boolean algebra rules, with worked examples
Boolean algebra is algebra with only two values, 1 and 0. A dot means AND, a plus means OR, and a bar means NOT. A handful of rules let you rewrite any logic expression into a simpler one with the same truth table, which means fewer gates in a circuit and fewer conditions in code.
The rules
| Law | AND form | OR form |
|---|---|---|
| Identity | A · 1 = A | A + 0 = A |
| Null | A · 0 = 0 | A + 1 = 1 |
| Idempotent | A · A = A | A + A = A |
| Complement | A · Ā = 0 | A + Ā = 1 |
| Absorption | A · (A + B) = A | A + A · B = A |
| De Morgan | NOT(A · B) = Ā + B̄ | NOT(A + B) = Ā · B̄ |
Two NOTs cancel, so NOT(Ā) = A. AND and OR can each take their inputs in any order, and brackets of the same operator can move freely. And AND spreads over OR the way multiplying spreads over adding: A · (B + C) = A · B + A · C.
There's no 2 in Boolean algebra, so A + A is A, not 2A.
Simplify, step by step
Take Y = A · B + A · B̄. Factor out the A, then use the complement law:
Two ANDs and an OR collapse into a single wire. Or take Y = A · B + A · B · C. Whenever A · B is 1, the first term already makes Y 1, so the second adds nothing. That's absorption: Y = A · B.
Live experiment
Push the bubble through
The same two switches feed two gates: a NOR or NAND on top, lighting Pip, and its rewrite underneath, lighting Dot. Break the bar and they disagree on two rows of the table. Change the sign too, OR for AND, and they agree on every row.
“Boolean algebra” is lesson 3 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 44 before it first.
De Morgan: break the bar, change the sign
A NOT over a whole bracket can be pushed inside. Every input gets its own NOT, and AND swaps with OR:
"Not tea or coffee" means no tea and no coffee. Forget to change the sign and the rule breaks: with A = 1 and B = 0, NOT(1 · 0) = 1, but Ā · B̄ = 0 · 1 = 0.
From a truth table to gates
Any truth table becomes an expression in two steps, called sum of products:
- For each row with a 1 out, write an AND term that is 1 on that row only, with a NOT on each input that's 0 there.
- OR the terms together.
A table with 1s only at A = 0, B = 1 and A = 1, B = 0 gives:
That's XOR. The same recipe builds a multiplexer, Y = S̄ · A + S · B, which passes A when the select bit S is 0 and B when it's 1.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“Boolean algebra” is lesson 3 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 44 before it first.
Or start from the very first lesson, no account neededPractice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: no tea and no coffee. Pushing the NOT inside swaps OR for AND, so NOT(tea OR coffee) is (NOT tea) AND (NOT coffee). That's De Morgan's law in a café.
- Why not “no tea or no coffee”? No tea or no coffee is true when you'd still take one of them. Pushing the NOT inside swaps OR for AND.
- Why not “tea and coffee”? That's the opposite of the sentence. NOT(tea OR coffee) rules out both drinks.
Show the answer
Answer: A OR (B AND C). The last two are the same rule written in two orders, with the OR inside the AND. The first has the AND inside the OR, and its table has more 1s, since A alone is enough.
- Why not “(A OR B) AND C”? (A OR B) AND C is the same rule as C AND (A OR B): AND gives the same answer whichever order its inputs come in.
- Why not “C AND (A OR B)”? C AND (A OR B) is (A OR B) AND C with its two sides swapped, and swapping an AND's inputs changes nothing.
Show the answer
Answer: The original input back. Flip, then flip again: back where you started.
- Why not “Always 1”? A 0 flips to 1 and back to 0, so the output isn't stuck at 1 either.
- Why not “Always 0”? The output still follows the input: a 1 flips to 0 and back to 1, so it isn't stuck at 0.
- Why not “Its opposite”? One NOT gives the opposite. A second NOT flips it back again, so the two cancel.
“Boolean algebra” is lesson 3 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 44 before it first.
Questions people ask
What does + mean in Boolean algebra?
OR. A + B is 1 when A or B or both are 1, and A · B is AND. That's why 1 + 1 = 1 in Boolean algebra: there's no 2, only true and false.
How do I simplify a Boolean expression?
Look for a variable ANDed with both itself and its complement, like A · B + A · B̄, and factor it out to get A. Absorption, A + A · B = A, removes whole terms. For more than three or four inputs, a Karnaugh map finds these pairs by eye.
How do I check that two Boolean expressions are equal?
Write out both truth tables. With two inputs that's four rows, with three it's eight. If the outputs match on every row, the expressions are equal, whatever they look like on paper.
Related topics
- De Morgan's laws explainedPush a NOT through a gate: every input flips and AND swaps with OR.
- Why is NAND called a universal gate?NOT, AND, OR and XOR from one kind of gate, and why chips love it.
- Logic gates explainedAND, OR, NOT, XOR and their bubbled twins: each one's rule is a truth table.
- How to make a truth tableEvery input combination and its output: the complete, unarguable description of a logic circuit.