3.1.5 · D2Boolean Algebra & Logic Gates

Visual walkthrough — Truth tables construction

2,255 words10 min readBack to topic

Before anything else, two plain-word anchors we will lean on:


Step 1 — One switch: the smallest possible table

WHAT. We start with a single input, call it . is one switch, so it has exactly two settings: (off) or (on).

WHY start here. You cannot understand a table with 8 rows if you have not seen why a table with 1 switch has exactly 2 rows. We build the "doubling" idea from its seed.

PICTURE. Look at the figure: one switch drawn twice — once down (0), once up (1). Those two drawings are the two rows. There is no third setting, so there is no third row.

Figure — Truth tables construction
  • — the name of our single switch.
  • — the only two values a bit may take; the curly braces mean "the set of".
  • The arrow means "therefore": two settings force two rows.

Step 2 — Add a second switch: rows DOUBLE

WHAT. We add a second input . For each setting of , the switch can independently be 0 or 1. So each of the 2 old rows splits into 2 new rows.

WHY doubling and not adding. Here is the crux most people trip on. The switches are independent — setting tells you nothing about . So we are not counting "2 switches + 2 values". We are counting combinations: 2 choices for , and for each of those, 2 choices for . Choices that stack multiply.

PICTURE. The figure shows a tree: the trunk splits into and (2 branches). Each of those branches splits again into and . Count the leaves at the bottom — there are . Each leaf is one row.

Figure — Truth tables construction
  • The is the multiplication principle: independent choices multiply, they never add.
  • Follow one path from trunk to leaf — that path spells out one complete input row, e.g. .

Step 3 — Generalise: switches give rows

WHAT. Every time we add one more independent switch, the tree grows one more level and the number of leaves doubles. Starting from 1 switch (2 rows) and doubling more times gives:

WHY the exponent. The little superscript in is not decoration — it literally counts how many switches we multiplied together. It is shorthand for "multiply 2 by itself, once per input". That is exactly the tree from Step 2 grown to levels.

PICTURE. The figure stacks three trees side by side — 1, 2, and 3 switches — so you can watch the leaf-count go . Each new switch is a new fork on every existing branch.

Figure — Truth tables construction
  • — a name for "number of rows when there are inputs".
  • — read aloud as "two to the ". For it is .
Rows
, because each of the independent switches multiplies the count by 2.

Step 4 — List the rows without missing any: COUNT IN BINARY

WHAT. We now need to write down all rows with none missing and none repeated. The trick: treat each row as a number and count — but in binary, where the only digits are 0 and 1.

WHY binary and not "make them up". If you list combinations from memory you will skip one or write one twice, and you will never know. Counting is a built-in checksum: the numbers cannot repeat and cannot skip, so the rows cannot either. For the counts written as 2-bit binary are — all four combos, guaranteed once each.

PICTURE. The figure shows the odometer / counter: each column is a "digit wheel". The rightmost wheel flips every row (), the next flips half as fast (), the next half as fast again (). Slower wheels to the left.

Figure — Truth tables construction
  • The leftmost column is the most significant bit (MSB) — it changes slowest, like the hundreds digit of a car odometer.
  • The rightmost is the least significant bit (LSB) — it flips every single row.

Step 5 — Divide and conquer: intermediate columns

WHAT. A real expression like has pieces. We refuse to evaluate it in one giant mental leap. Instead we add one extra column per piece: one for , one for , and then one for the final .

WHY split it. Two reasons. First, precedence: computing pieces separately forces the correct order — NOT first, then AND, then OR. Second, error-hunting: if the final answer is wrong you can look at each small column and see exactly which piece broke.

PICTURE. The figure shows the expression as a little circuit flowing left to right: inputs enter, a NOT gate makes , an AND gate makes , and an OR gate merges them into . Each gate = one intermediate column.

Figure — Truth tables construction

Recall the three gate rules we are about to use:

  • (NOT) flips the bit: .
  • (AND) is 1 only when both are 1.
  • (OR) is 1 when at least one is 1; it is 0 only when both are 0.

Step 6 — Fill the table for

WHAT. Three inputs, so rows (Step 3). We lay out by the odometer rule (Step 4), then fill , then , then combine with OR into .

WHY this exact order of columns. We fill the two intermediate columns first because the final OR is then trivial: look across the row, if either intermediate is 1, write 1.

PICTURE. The figure is the finished table, colour-coded: the AND column and the NOT column feed arrows into the amber column. Follow the arrows on any row to see where its answer came from.

Figure — Truth tables construction
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 1 1 1
1 1 1 1 0 1
  • Row 1 (): but , so . The light is on because of the NOT branch.
  • Row 2 (): and , so — the only kind of row OR turns off.
  • Row 8 (): , so regardless of . Once AND fires, OR is on.

Step 7 — The edge cases: never leave a stone unturned

WHAT. We check the extreme rows and the degenerate zero-input idea, so no reader ever meets a case we skipped.

WHY. A table is only a "complete promise" if it truly covers everything — including the boring corners where mistakes hide.

PICTURE. The figure highlights three special situations: the all-zeros row, the all-ones row, and the strange "no inputs at all" case.

Figure — Truth tables construction
  • All-zeros row (): , , so . A common surprise — with no switches on, the light is still ON because of the NOT term. Always test this row.
  • All-ones row (): , , so . Test this too; it catches AND/OR mix-ups.
  • Zero inputs (): the formula gives row. That single row is the empty combination — a constant function that is just one fixed value. The table never vanishes; the minimum is one row, not zero.
Recall Why

and not means "multiply 2 together zero times". Multiplying nothing leaves you at the starting value 1 (the same reason an empty product is 1). So a function with no inputs still has exactly one row — its constant output.


The one-picture summary

Everything on this page collapses into a single flow: count switches → get rows → list them by binary odometer → split the expression into gate-columns → OR the pieces into → verify the corner rows.

Figure — Truth tables construction
Recall Feynman retelling — say it to a 12-year-old

Imagine a lamp wired to some switches. First I ask: how many switches? Say three. Each switch is either up or down, and the switches don't care about each other, so I have different ways to set them — that's why the table has 8 rows, not 6.

To make sure I write down all 8 ways and never repeat, I count like a robot: 0,1,2,3,… but using only 0s and 1s (binary). The right-hand switch flips every time, the middle one every two counts, the left one every four — like the wheels of an odometer spinning at different speeds.

Now for each row I don't try to figure out the whole rule in my head. I break it into little jobs: one column for " and ", one column for "not ". I fill those tiny columns, then I combine them with OR — which just asks "is at least one of these a 1?" Finally I double-check the boring corners: all switches off, all switches on. If those two look right, I trust the whole table. That's it — no guessing, every case listed once, the light's answer written for every possible day.


Connections

Why do rows double when you add one input?
The new switch is independent, so each existing row splits into two (new switch = 0 and = 1).
What does the exponent in literally count?
The number of independent input switches multiplied together.
What is the output of on the all-zeros row?
1, because makes the OR true.
How many rows does a table with 0 inputs have?
One, since — a single constant row.
Which OR situation gives output 0?
Only when every operand is 0.