Home
3Boolean Algebra & Logic Gates
3

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.

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

LawFormDual form
IdentityA+0 = AA·1 = A
NullA+1 = 1A·0 = 0
IdempotentA+A = AA·A = A
ComplementA+A = 1A·A = 0
CommutativeA+B = B+AAB = BA
Associative(A+B)+C = A+(B+C)(AB)C = A(BC)
DistributiveA(B+C) = AB+ACA+BC = (A+B)(A+C)
AbsorptionA+AB = AA(A+B) = A
Involution(A′)′ = A(A′)′ = A
UsefulA+AB = A+BXY+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

A + B = A·B
AB = A + B

Steps: A + B = A·B

  1. Start with the negated OR: A + B.
  2. Swap the operator: OR becomes AND.
  3. Complement every literal: A → A, B → B.
  4. Result: A · B = A·B.

Steps: AB = A + B

  1. Start with the negated AND: AB.
  2. Swap the operator: AND becomes OR.
  3. Complement every literal: A → A, B → B.
  4. 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 · XNOR gate

XNOR in real life: sensors agree

Real life

Basic gates and their real-life examples

GateReal-life exampleRule
ANDMicrowave: door closed AND start pressedBoth inputs 1
ORBurglar alarm: door OR window sensorAt least one input 1
NOTStreet lamp: on when NOT daylightOpposite of the input
NANDLift warning lamp: on unless doors locked AND load OK0 only when both inputs 1
NORVacant sign: neither door NOR motion sensor active1 only when both inputs 0
XORTwo-way staircase light1 when inputs differ
XNORRedundant sensors agree1 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

ANOT ABuffer
010
101

All two-input gates

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

Minterms and maxterms of A, B, C

#ABCMintermMaxterm
0000A·B·C(A+B+C)
1001A·BC(A+B+C)
2010ABC(A+B+C)
3011ABC(A+B+C)
4100AB·C(A+B+C)
5101ABC(A+B+C)
6110ABC(A+B+C)
7111ABC(A+B+C)

Truth tables

Truth tables (2 of 2)

DeMorgan check: A + B = A·B

ABA+BA+BABA·B
0001111
0110100
1010010
1110000

The highlighted columns match in every row, so A + B = A·B.

DeMorgan check: AB = A + B

ABABABABA+B
0001111
0101101
1001011
1110000

The highlighted columns match in every row, so AB = A + B.

Interactive

Demo: Boolean expression simplifier

Interactive

Demo: gates, switches and LEDs

Worked example 1 of 4

Worked example 1

Simplify A + AB.
Show the solution
  1. A + AB = (A + A)(A + B), by the distributive law.
  2. = 1·(A + B)
  3. = A + B

Worked example 2 of 4

Worked example 2

Apply DeMorgan to AB + C.
Show the solution
  1. AB + C = AB · C
  2. = (A + B)C

Worked example 3 of 4

Worked example 3

Simplify XY + XZ + YZ.
Show the solution
  1. YZ = YZ(X + X) = XYZ + XYZ.
  2. XYZ is absorbed by XY, and XYZ is absorbed by XZ.
  3. Result XY + XZ.

Worked example 4 of 4

Worked example 4

Expand the standard SOP f(a,b,c) = a′b′c + bc′ + ac′ into canonical SOP (a sum of minterms).
Show the solution
  1. a′b′c already has all 3 variables, so it is already a minterm: m₁.
  2. bc′ is missing a, so multiply by (a+a′): bc′ = abc′ + a′bc′.
  3. ac′ is missing b, so multiply by (b+b′): ac′ = abc′ + ab′c′.
  4. Collect all the terms and drop the duplicate abc′: f = a′b′c + abc′ + a′bc′ + ab′c′.
Result f = a′b′c + a′bc′ + ab′c′ + abc′ = Σm(1,2,4,6).

Practice

Practice (1 of 2)

Try each one on paper first, then check your answer.

1. Simplify A + AB.
Show the answer
A, by absorption.
2. Apply DeMorgan to AB + C.
Show the answer
(A + B)C
3. A 2-input function is 1 only for inputs 01 and 10. Write its canonical SOP and POS.
Show the answer
SOP: AB + AB = Σm(1,2). POS: (A+B)(A+B) = ΠM(0,3). This is XOR.

Practice

Practice (2 of 2)

Try each one on paper first, then check your answer.

4. Write the dual of A + BC.
Show the answer
A(B + C)
Practice in Gate Forge

Wire each gate yourself and check it with the Truth table tester. Try building AB and A + B side by side.

Open Gate ForgeGate 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.