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 Bis1only when bothAandBare1.A OR Bis1when at least one input is1, including when both are1.NOT AreversesA:0becomes1, and1becomes0.
Here are the complete truth tables for the three operators.
A | B | A AND B | A OR B |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
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 inputs | Number of input combinations |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
This can be written as 2^n, where n is the number of inputs. For three inputs, a reliable row order is:
A | B | C |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| 1 | 1 | 1 |
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.
A | B | C | A AND B AND C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
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.
A | B | C | A OR B | NOT C | X = (A OR B) AND (NOT C) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Work through the row A = 0, B = 1, C = 0:
A OR Bis0 OR 1, so the first intermediate result is1.NOT CisNOT 0, so the second intermediate result is1.- The final operation is
1 AND 1, soX = 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 = 1means supervisor approval has been given.K = 1means the key is valid.C = 1means the code is valid.U = 1means 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.
S | K | C | K OR C | U = S AND (K OR C) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
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:
- Define what
1and0mean for every input and output. - Translate the rule into a parenthesised Boolean expression.
- List all input combinations once.
- Complete one intermediate column for each smaller operation.
- Use the intermediate results to complete the final output, then check the rows against the original rule.