Truth Tables
Learn to build a truth table for any compound expression step by step and use it to find tautologies, contradictions and equivalent expressions.
Definition
- 1.Count the variables and write empty rows.
- 2.Fill the variable columns in a fixed order: the first column is half T, then half F; each next column switches twice as often; the last column alternates T, F, T, F.
- 3.Add a helper column for every part of the expression, innermost part first (a NOT on a single variable, then the brackets).
- 4.Combine the helper columns into the final column.
| T | T | F | F |
| T | F | T | T |
| F | T | F | F |
| F | F | T | F |
- All T: the expression is a tautology (always true).
- All F: it is a contradiction (always false).
- Two expressions with the same final column in every row are logically equivalent.
Try it now
Worked Examples
Build the truth table for .
Count the rows
There are 2 variables, and , so we need rows
Fill the variable columns
: T, T, F, F (half T, half F). : T, F, T, F (alternating) → All 4 combinations appear once
Add the helper column
Flip every value of : T, F, T, F becomes F, T, F, T → : F, T, F, T
Combine with OR
Row by row: T OR F = T, T OR T = T, F OR F = F, F OR T = T → : T, T, F, T
Answer: The final column is T, T, F, T. The expression is false only in row 3, where is false and is true.
Common Mistakes
Writing too few rows, for example 6 rows for 3 variables
Why it's wrong: The number of rows is not . Each variable doubles the number of combinations, so 3 variables give rows.
Correct: Always use rows: 4 for 2 variables, 8 for 3 variables, 16 for 4 variables.
Filling the variable columns in a random order
Why it's wrong: Without a system it is easy to write the same combination twice and miss another one. The table then gives a wrong verdict.
Correct: Use the fixed pattern: first column in blocks of half the rows, each next column in blocks half as long, last column alternating T, F.
Treating as if it were
Why it's wrong: Without brackets, NOT applies only to the variable right after it. The bracketed version flips the result of the whole AND.
Correct: Make a helper column for exactly what NOT touches: alone, or first and then its negation.
Calling two expressions equivalent after checking only a few rows
Why it's wrong: Two expressions can agree on several rows and still differ in one. and agree in rows 1 and 4 but not in rows 2 and 3.
Correct: Compare the final columns in every single row. Equivalent means identical in all rows.
Interactive Visual
Truth Table
| P | Q | R | P ∧ Q | ¬R | P ∧ Q ∨ ¬R |
|---|---|---|---|---|---|
| T | T | T | T | F | T |
| T | T | F | T | T | T |
| T | F | T | F | F | F |
| T | F | F | F | T | T |
| F | T | T | F | F | F |
| F | T | F | F | T | T |
| F | F | T | F | F | F |
| F | F | F | F | T | T |
T= TrueF= False
Truth Table
| P | Q | P ∨ ¬Q |
|---|---|---|
| T | T | |
| T | F | |
| F | T | |
| F | F |
T= TrueF= False
Interactive Sandbox
Expression Calculator
Try these:
History
No calculations yet
Practice Problems
18 problemsHow many rows does a truth table with 3 variables have?
Why It Matters
- Programming: before shipping a condition like (member OR coupon) AND NOT blocked, testers check every combination of inputs
- Electronics: engineers use truth tables to design circuits and to replace a complicated circuit with a simpler, cheaper one that does the same job
- Security and alarms: an alarm with 4 sensors has possible states, and every one of them must behave correctly
- Arguments and debates: a truth table shows whether two sentences really say the same thing or only sound alike
- Puzzles and games: logic puzzles are solved by ruling out rows that cannot be true
Real World Applications
Alarm Systems
Security engineers list every state of the sensors to make sure the alarm reacts correctly in each one.
Example:
An alarm with 3 door sensors has states, from all doors closed to all doors open.
A house alarm has 4 sensors, and each one is either on (T) or off (F). The alarm rings if at least one sensor is on (OR).
How many rows does the truth table have, and in how many of them does the alarm ring?
Step 1: Write the mathematical expression
Write the number of rows as a power of 2:
Testing Software
Programmers test a condition with every combination of inputs, which is exactly a truth table.
Example:
A login rule (correct password AND NOT locked) needs test cases to be fully checked.
An online shop gives a discount if , where = is a member, = has a coupon, = account is blocked.
In how many of the input combinations does the customer get the discount?
Step 1: Write the mathematical expression
Write the number of test cases as a power of 2:
Simplifying Circuits
If two circuits have the same truth table, engineers can use the one with fewer or cheaper parts.
Example:
De Morgan's laws let a designer swap a NOT-AND for an OR of two NOTs without changing what the circuit does.
Circuit A computes . Circuit B computes .
Do the two circuits always give the same output?
Step 1: Write the mathematical expression
Write the number of rows as a power of 2:
Key Takeaways
- 1A truth table lists every combination of truth values and the value of the expression in each row
- 2With variables the table has rows: 4 for 2 variables, 8 for 3 variables
- 3Fill the variable columns in a fixed order: blocks of half the rows first, last column alternating T, F
- 4Use helper columns for each part of the expression, innermost part first
- 5All T in the final column means a tautology, all F means a contradiction
- 6Two expressions are equivalent when their final columns match in every row
Frequently Asked Questions
Glossary
- Truth table
- A table that shows the value of an expression for every combination of its variables
- Compound expression
- An expression built from variables and operators, such as
- Helper column
- An extra column for one part of an expression, used to build the final column step by step
- Tautology
- An expression that is true in every row, such as
- Contradiction
- An expression that is false in every row, such as
- Logically equivalent
- Two expressions with the same value in every row, written with
Formula Card
Number of rows
$n$ is the number of variables: $2^2 = 4$, $2^3 = 8$, $2^4 = 16$
Tautology
Always true: the final column is all T
Contradiction
Always false: the final column is all F
De Morgan's laws
Two equivalences you can prove with a truth table