1.3.1 - Truth tables and Boolean logic

1.3.1 - Truth tables and Boolean logic

A truth table is a small grid with no room for guesswork: every possible input combination must appear once. In this lesson, you will apply AND, OR and NOT accurately in truth tables with up to three inputs, then use them to solve short logic problems.

Boolean building blocks

Imagine a system that records whether a door is open. For this decision, there are only two relevant states: the door is open or it is not open. Boolean logic represents choices like this using two values.

Boolean value

A value with exactly two possible states: TRUE or FALSE. In truth tables, these may be written as 1 and 0, where 1 means TRUE and 0 means FALSE.

The letters A, B and C can stand for Boolean inputs. A logical operator takes one or more Boolean values and produces a Boolean result.

Truth table

A table that shows the output of a logical expression for every possible combination of its input values.

The three operators in this lesson have precise meanings:

  • A AND B is 1 only when both A and B are 1.
  • A OR B is 1 when at least one input is 1, including when both are 1.
  • NOT A reverses A: 0 becomes 1, and 1 becomes 0.

Here are the complete truth tables for the three operators.

ABA AND BA OR B
0000
0101
1001
1111
ANOT A
01
10

The last row of the first table is the important test for OR: 1 OR 1 is 1. This is inclusive OR, not “exactly one”. Also, logical AND describes a combination of conditions; it does not mean “and then” or put events in a time order.

Complete input rows

A truth table is complete only if it contains every possible input combination exactly once. Each input has two possible values, so the number of rows doubles whenever one more input is added:

Number of inputsNumber of input combinations
12
24
38

This can be written as 2^n, where n is the number of inputs. For three inputs, a reliable row order is:

ABC
000
001
010
011
100
101
110
111

Read the columns like counters: C changes every row, B every two rows, and A every four rows. A different row order is valid if all eight combinations appear once, but this pattern makes a missing or duplicated row easier to spot.

Now apply AND to all three inputs. The expression A AND B AND C can be read as (A AND B) AND C, so its output is 1 only when all three inputs are 1.

ABCA AND B AND C
0000
0010
0100
0110
1000
1010
1100
1111

Combined Boolean expressions

A truth table can evaluate several operators in one expression. Do not try to jump straight from the inputs to the final answer. Use parentheses to identify the smaller operations, give each one an intermediate column, and then combine those results.

Consider:

X = (A OR B) AND (NOT C)

The expression has two smaller parts: A OR B and NOT C. The final AND combines those two intermediate results.

ABCA OR BNOT CX = (A OR B) AND (NOT C)
000010
001000
010111
011100
100111
101100
110111
111100

Work through the row A = 0, B = 1, C = 0:

  1. A OR B is 0 OR 1, so the first intermediate result is 1.
  2. NOT C is NOT 0, so the second intermediate result is 1.
  3. The final operation is 1 AND 1, so X = 1.

NOT changes only the value or parenthesised group attached to it. In this expression it changes C, not A, B, or the whole expression. Writing parentheses removes any doubt about what should be evaluated together.

Logic in context

Boolean expressions can represent rules in a system. Start by defining exactly what each input means, translate the rule with parentheses, and then evaluate every row.

A secure cabinet unlocks only when supervisor approval has been given and at least one of two credentials is valid:

  • S = 1 means supervisor approval has been given.
  • K = 1 means the key is valid.
  • C = 1 means the code is valid.
  • U = 1 means the cabinet unlocks.

The rule becomes:

U = S AND (K OR C)

First evaluate K OR C. Then combine that result with S using AND.

SKCK OR CU = S AND (K OR C)
00000
00110
01010
01110
10000
10111
11011
11111

The first four outputs are 0 because supervisor approval is absent. When S = 1, either valid credential makes the output 1; if both are valid, K OR C is still 1 because OR is inclusive.

A reliable problem-solving routine is:

  1. Define what 1 and 0 mean for every input and output.
  2. Translate the rule into a parenthesised Boolean expression.
  3. List all input combinations once.
  4. Complete one intermediate column for each smaller operation.
  5. Use the intermediate results to complete the final output, then check the rows against the original rule.