TactivergeLite

Lite / Discovering How the World Works / Week 16

Truth tables: checking every possibility

A machine with three sensors has eight possible situations. How do you make sure it does the right thing in every single one?

About 30 min · 3 goals · Reviewed by the founders' mentors · Full interactive version

Why should I care?

A truth table is a machine's complete promise: for every possible input, here is the output. Engineers write them before building, and test against them afterwards, so that no situation is forgotten.

Predict

How many rows does a truth table need for a circuit with 3 inputs?

  1. 3
  2. 6
  3. 8
Guess first, then reveal

8. Each input can be 0 or 1, so 3 inputs give 2 × 2 × 2 = 8 combinations, the same doubling as bits in week 14.

Discover

Open the digital logic lab. Build A AND (NOT B): put a NOT on input B and feed it into an AND with A. Fill in your truth table on paper first, then let the lab check every row. Which single row gives a 1?

What the interactive shows (text version)

The digital logic lab lets you place gates, wire inputs to them and see a live truth table. For A AND (NOT B), the rows 00, 01, 10 and 11 give outputs 0, 0, 1 and 0: only A = 1 with B = 0 gives a 1.

You can also open the interactive on the full site when you have a faster connection.

Understand

List every input combination

Write the inputs as columns and count up in binary down the rows: for two inputs, 00, 01, 10, 11. Counting in binary guarantees you never miss or repeat a combination. Three inputs: 000 to 111, eight rows.

Work out the middle, then the output

For a combination like A AND (NOT B), add a helper column for NOT B first, then combine it with A. Doing one gate at a time, column by column, avoids mistakes.

| A | B | NOT B | A AND NOT B | |---|---|---|---| | 0 | 0 | 1 | 0 | | 0 | 1 | 0 | 0 | | 1 | 0 | 1 | 1 | | 1 | 1 | 0 | 0 |

A table is a test

To check a circuit, set the inputs for every row and compare its output with your table. If even one row disagrees, the circuit is wrong. This is exactly how the Tactiverge labs and Builds check your circuits: row by row, every row.

Explain it another way

Intuitive

A truth table is like a checklist for a robot butler: for every possible situation (raining or not, guests or not), it says exactly what to do. No situation is left to guesswork.

Technical

A truth table fully specifies a combinational function of n inputs with 2ⁿ rows. Two circuits are equivalent if, and only if, their truth tables match on every row, which is how NAND-only versions of gates are proved correct.

Mathematical

NOT (A AND B) and (NOT A) OR (NOT B) have identical tables (1, 1, 1, 0), so they are equal. This is one of De Morgan's laws. With 4 inputs a table has 2⁴ = 16 rows; with 10 inputs, 1,024 rows.

Applied

Before writing code for a machine's safety logic, engineers often write the full truth table with the client. Rows the client never thought about (such as 'both sensors broken') come to light early.

Worked example 1

Fill in the truth table for (NOT A) OR B and count the 1s.

Rows AB: 00 → NOT A = 1, so 1. 01 → 1. 10 → NOT A = 0, B = 0, so 0. 11 → B = 1, so 1. Three rows give 1.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

rows

Practice 4. A mystery gate's truth table output column (rows 00, 01, 10, 11) is 0, 1, 1, 0. Which gate is it?
Practice 5. Why do engineers list truth table rows by counting in binary (00, 01, 10, 11)?

Apply it

Write the full 8-row truth table for a 'majority vote' circuit with inputs A, B and C: output 1 if at least two inputs are 1. How many rows give 1? (You'll meet this circuit again in the Sorting Machine Build.)

Reflect

Why might a 20-input machine be hard to test with a truth table? (Hint: how many rows?)

Write your answer on paper or in your own notes. Lite never stores what you write.

← AND, OR, NOT: the three little decidersGates at work: safety interlocks and sorting rules →