Skip to content

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

LawAND formOR form
IdentityA · 1 = AA + 0 = A
NullA · 0 = 0A + 1 = 1
IdempotentA · A = AA + A = A
ComplementA · Ā = 0A + Ā = 1
AbsorptionA · (A + B) = AA + A · B = A
De MorganNOT(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:

Y = A · (B + B̄) = A · 1 = A

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.

Try it yourself: free lesson

“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(A + B) = Ā · B̄

"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:

  1. 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.
  2. OR the terms together.

A table with 1s only at A = 0, B = 1 and A = 1, B = 0 gives:

Y = Ā · B + A · B̄

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.

Try it yourself: free lesson

“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 needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3"I don't want tea or coffee" means…
    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.
  2. Question 2 of 3Which is different from the other two?
    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.
  3. Question 3 of 3A NOT gate fed from another NOT gate gives…
    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.
Keep practising: free lesson

“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.

Every topic