Truth Tables

A truth table lists every possible combination of inputs to a logic circuit or Boolean expression, together with the output for each one. It is the most reliable way to describe a digital function, because it leaves nothing out. If two circuits have the same truth table, they do exactly the same job, however different their gates look.

In this lesson you will build truth tables from expressions and from word descriptions, use them to prove that two expressions are equal, and read an expression back off a table. You should know the AND, OR and NOT gates and the order of operations.

Learning objectives

After this lesson you will be able to:

  • Work out how many rows a truth table needs.
  • List input combinations in the standard binary order.
  • Build a truth table for an expression using intermediate columns.
  • Prove two expressions equivalent by comparing their tables.
  • Write a sum-of-products expression from a truth table.

How many rows?

Each input can be 0 or 1, so n inputs give 2^n different combinations. Two inputs need 4 rows, three inputs need 8, four inputs need 16, and five inputs need 32. The table grows fast, which is one reason we use Boolean algebra and Karnaugh maps to simplify functions instead of enumerating them.

The standard row order

Write the input columns so that the rows count upward in binary: 000, 001, 010, 011, 100, 101, 110, 111 for three variables. The leftmost variable is the most significant bit. Row number k, counting from 0, is then the binary code of k, which is also the minterm number m(k) of that row. This ordering guarantees that you never skip or repeat a combination.

Building a table step by step

  1. List the variables and write all 2^n input combinations in binary order.
  2. Add one column for each sub-expression, starting with the innermost parts: complements first, then AND terms, then OR.
  3. Fill in the final column. This is the output.

Intermediate columns take a little more space, but they make errors much less likely.

Example 1: a table from an expression

Build the truth table of F = A'B + AC.

A B C A'B AC F = A'B + AC
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 1 0 1
0 1 1 1 0 1
1 0 0 0 0 0
1 0 1 0 1 1
1 1 0 0 0 0
1 1 1 0 1 1

Result: F = 1 for minterms 2, 3, 5 and 7, so there are four rows with output 1. Notice that F equals 1 whenever A = 0 and B = 1, or whenever A = 1 and C = 1, which is exactly what the expression says.

Example 2: proving two expressions are equal

Two expressions are equivalent if they have the same output for every input combination. Show that A + A'B = A + B.

A B A'B A + A'B A + B
0 0 0 0 0
0 1 1 1 1
1 0 0 1 1
1 1 0 1 1

The last two columns are identical in all four rows.

Result: A + A'B = A + B. The simpler form needs one gate less, and the truth table proves the simplification is safe. This method works for any identity, as long as the number of variables is small.

Example 3: a table from a word problem

A voting circuit has three inputs A, B and C, and its output is 1 when at least two of them are 1 (a majority vote).

A B C Majority
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

The output is 1 in rows 3, 5, 6 and 7, so the function is m(3, 5, 6, 7).

To turn the table into an expression, write one AND term for each row where the output is 1, using the variable when its value is 1 and its complement when its value is 0, then OR the terms together:

F = A'BC + AB'C + ABC' + ABC

This is the sum-of-products form read straight off the table. It can be simplified, and the result is the well-known majority function:

F = AB + AC + BC

Result: a majority circuit needs just three AND gates and one OR gate. You can confirm that both expressions give the same table with the truth table generator.

Special cases

Some expressions are always 1, whatever the inputs. These are tautologies, and A + A' is the simplest example. Others are always 0, such as A A', and are called contradictions. Most useful functions are neither of these.

Common mistakes

  • Writing rows in a random order. Always count in binary, otherwise it is easy to miss a combination.
  • Skipping intermediate columns. Filling in the final column in one go leads to mistakes with complements.
  • Using the wrong number of rows. For n inputs the table has 2^n rows, not 2n.
  • Reading a minterm number backwards. The leftmost variable is the most significant bit.
  • Writing the AND terms for the rows with output 0. The sum-of-products form uses the rows where the output is 1.

Practice problems

Check your answers with the truth table generator.

  1. How many rows does the truth table of a five-input function have?

    Answer: 2^5 = 32 rows.

  2. For which input combinations is F = (A + B)C' equal to 1?

    Answer: F = 1 for minterms 2, 4 and 6 (ABC = 010, 100 and 110).

  3. Are AB' + A'B and (A + B)(AB)' equivalent?

    Answer: Yes. Both are 0 when A = B and 1 when A differs from B, so both give the XOR function.

  4. A function of A, B and C is 1 only when exactly one input is 1. Write it as a sum of products.

    Answer: F = A'B'C + A'BC' + AB'C', which is m(1, 2, 4).

Frequently asked questions

What is a truth table used for? It defines a digital function completely, and it is used to design circuits, to test them, and to prove that two expressions are equal.

How many different functions can n variables make? There are 2^(2^n) of them, because each of the 2^n rows can independently be 0 or 1. For two variables that is 16 functions, and for three variables it is 256.

Is a truth table the same as a Karnaugh map? They hold the same information. A Karnaugh map rearranges the truth table into a grid so that neighbouring cells differ by one variable, which makes simplification easy to see.

For larger expressions, let the truth table generator do the work, and use the Boolean calculator to simplify them.

Next lesson: Boolean Laws and Theorems