Truth Tables
A truth table lists every possible combination of truth values for the variables in a statement, one combination per row, and shows whether the whole statement is true or false in each row. A statement with n variables needs 2n rows. Truth tables also show when a statement is a tautology or a contradiction.
Before this lesson: Propositional Logic
What is a truth table?
A compound proposition is built from simpler ones, so its truth value depends only on the truth values of its variables. A truth table checks every case at once. Each row is one possible situation, and the last column gives the truth value of the whole statement in that situation.
Each variable is either T or F, so one variable gives 2 rows, two variables give 2 · 2 = 4 rows and three variables give 2 · 2 · 2 = 8 rows. This is the multiplication principle from permutations and combinations: n variables give 2n rows.
Truth tables for the connectives
These are the definitions of the connectives from propositional logic, written as one table. Every larger truth table is built from these columns.
| p | q | \lnot p | p \land q | p \lor q | p \oplus q | p \to q | p \leftrightarrow q |
|---|---|---|---|---|---|---|---|
| T | T | F | T | T | F | T | T |
| T | F | F | F | T | T | F | F |
| F | T | T | F | T | T | T | F |
| F | F | T | F | F | F | T | T |
Notice that p → q has only one F, in the row where p is true and q is false. The biconditional p ↔ q is true exactly when p and q match, so its column is the opposite of the exclusive or column.
How to build a truth table
- Count the variables. With n variables, make 2n rows.
- Fill the variable columns in the standard order. The first variable alternates in blocks of half the rows (T for the top half, F for the bottom half), the next in blocks half as long, and the last variable alternates T, F, T, F.
- Break the statement into parts, following the order of operations: ¬ first, then ∧, then ∨, then →, then ↔.
- Add one column for each part, from the innermost part out, and fill it one row at a time using the connective table.
- The last column is the whole statement. Read off the answer from it.
The diagram shows why the standard order lists every case exactly once: each variable splits every earlier case into a T branch and an F branch.
Tautologies, contradictions and contingencies
A tautology is a compound proposition that is true in every row of its truth table, such as p ∨ ¬p. A contradiction is false in every row, such as p ∧ ¬p. A statement that is true in some rows and false in others is a contingency.
To classify a statement, build its truth table and look only at the final column: all T means tautology, all F means contradiction, and a mix means contingency. One row with a different value is enough to rule out a tautology or a contradiction.
Truth table examples
Example 1: A truth table for ¬p ∨ q
Build the truth table for ¬p ∨ q and compare its final column with the column for p → q.
2^2 = 4
Two variables, so 4 rows.
\lnot p:\ \text{F, F, T, T}Negate the p column (T, T, F, F).
\lnot p \lor q:\ \text{T, F, T, T}Combine ¬p with q (T, F, T, F) row by row: an “or” is false only when both parts are false, which happens in row 2.
| p | q | \lnot p | \lnot p \lor q | p \to q |
|---|---|---|---|---|
| T | T | F | T | T |
| T | F | F | F | F |
| F | T | T | T | T |
| F | F | T | T | T |
Answer: ¬p ∨ q has the column T, F, T, T, which matches p → q in every row. Statements with identical final columns are called logically equivalent, the topic of the next lesson.
Example 2: A tautology and a contradiction
Classify (p ∧ q) → p and p ∧ ¬(p ∨ q) as a tautology, a contradiction or a contingency.
| p | q | p \land q | (p \land q) \to p | p \lor q | \lnot(p \lor q) | p \land \lnot(p \lor q) |
|---|---|---|---|---|---|---|
| T | T | T | T | T | F | F |
| T | F | F | T | T | F | F |
| F | T | F | T | T | F | F |
| F | F | F | T | F | T | F |
(p \land q) \to p:\ \text{T, T, T, T}Row 1 is T → T; in rows 2–4 the hypothesis p ∧ q is false, so the conditional is true.
\lnot(p \lor q):\ \text{F, F, F, T}Negate the p ∨ q column (T, T, T, F).
p \land \lnot(p \lor q):\ \text{F, F, F, F}The only row where ¬(p ∨ q) is true is row 4, and there p is false.
Answer: (p ∧ q) → p is a tautology (all T), and p ∧ ¬(p ∨ q) is a contradiction (all F).
Example 3: A truth table with three variables
Build the truth table for (p ∨ q) → r and classify it.
2^3 = 8
Three variables, so 8 rows.
p \lor q:\ \text{T, T, T, T, T, T, F, F}The “or” is false only in rows 7 and 8, where p and q are both false.
(p \lor q) \to r:\ \text{T, F, T, F, T, F, T, T}False only when p ∨ q is T and r is F: rows 2, 4 and 6.
| Row | p | q | r | p \lor q | (p \lor q) \to r |
|---|---|---|---|---|---|
| 1 | T | T | T | T | T |
| 2 | T | T | F | T | F |
| 3 | T | F | T | T | T |
| 4 | T | F | F | T | F |
| 5 | F | T | T | T | T |
| 6 | F | T | F | T | F |
| 7 | F | F | T | F | T |
| 8 | F | F | F | F | T |
Answer: the final column is T, F, T, F, T, F, T, T. It has both values, so (p ∨ q) → r is a contingency.
Example 4: Checking an argument form
Show that [(p → q) ∧ p] → q is a tautology. This is the pattern behind the law of detachment in deductive reasoning: if p → q is true and p is true, then q must be true.
| p | q | p \to q | (p \to q) \land p | [(p \to q) \land p] \to q |
|---|---|---|---|---|
| T | T | T | T | T |
| T | F | F | F | T |
| F | T | T | F | T |
| F | F | T | F | T |
p \to q:\ \text{T, F, T, T}False only in row 2 (p true, q false).
(p \to q) \land p:\ \text{T, F, F, F}Both parts are true only in row 1.
[(p \to q) \land p] \to q:\ \text{T, T, T, T}Row 1 is T → T; rows 2–4 have a false hypothesis.
Answer: the final column is all T, so the statement is a tautology. Whenever both premises are true (row 1 only), the conclusion q is true too.
Example 5: When does the porch light turn on? (word problem)
A porch light turns on when it senses motion and it is dark, or when the manual switch is on. Let m be “motion is sensed,” d be “it is dark” and s be “the switch is on.” Write a statement L for “the light is on,” build its truth table and count the situations in which the light is on.
L = (m \land d) \lor s
“and” joins motion and darkness; “or” adds the switch.
2^3 = 8
Three variables, so 8 rows.
m \land d:\ \text{T, T, F, F, F, F, F, F}True only in rows 1 and 2, where m and d are both true.
(m \land d) \lor s:\ \text{T, T, T, F, T, F, T, F}True when m ∧ d is true (rows 1, 2) or s is true (rows 1, 3, 5, 7).
2 + 3 = 5
Rows 1 and 2, plus rows 3, 5 and 7.
| Row | m | d | s | m \land d | L = (m \land d) \lor s |
|---|---|---|---|---|---|
| 1 | T | T | T | T | T |
| 2 | T | T | F | T | T |
| 3 | T | F | T | F | T |
| 4 | T | F | F | F | F |
| 5 | F | T | T | F | T |
| 6 | F | T | F | F | F |
| 7 | F | F | T | F | T |
| 8 | F | F | F | F | F |
Answer: L = (m ∧ d) ∨ s, and the light is on in 5 of the 8 situations. Row 2 is the only one where the motion sensor alone turns it on; in rows 4, 6 and 8 it stays off.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Too few rows | Using 6 rows for a statement with p, q and r | n variables need 2n rows, so 3 variables need 8. |
| Rows in a random order | Listing TTF twice and leaving out FTF | Use the standard order: halves for the first variable, then quarters, and so on. |
| Making p → q false when p is false | Writing F for p → q in the row p = F, q = F | A conditional is false only when p is T and q is F. |
| Skipping the middle columns | Filling in [(p → q) ∧ p] → q in one step and making a slip | Add one column for each connective, from the inside out. |
| Calling a statement a tautology after a few rows | Checking only rows 1 and 2 of p ∨ q | Check every row; one F is enough to rule out a tautology. |
| Thinking “not a tautology” means “a contradiction” | Calling (p ∨ q) → r a contradiction | A mix of T and F is a contingency; a contradiction must be F in every row. |
Related ideas
Truth tables also describe digital circuits; see logic gates.
Two statements with the same final column, like ¬p ∨ q and p → q in Example 1, are logically equivalent. The next lesson, Logical Equivalence, uses truth tables and laws such as De Morgan’s laws to prove equivalences. Truth tables also describe the behavior of digital circuits, and they settle the converse, inverse and contrapositive of conditional statements: a conditional always has the same column as its contrapositive.
Practice problems
- How many rows does a truth table need for a statement with 4 variables?
- Build the truth table for p → ¬q.
- Build the truth table for ¬(p ∧ q).
- Build the truth table for (p ⊕ q) ∧ q.
- Is p → (q → p) a tautology, a contradiction or a contingency?
- Is (p → q) ∧ (p ∧ ¬q) a tautology, a contradiction or a contingency?
- Build the truth table for p ∧ (q ∨ r) and give its final column.
- In how many of the 8 rows is (p ∧ ¬q) ∨ r true?
- Show that (p ↔ q) ∨ (p ⊕ q) is a tautology.
- A club admits a student who is a member (m) or who has a guest pass (g), as long as the student is not banned (b). Write the rule as a statement A, and decide whether A is true for a banned member with no guest pass.
Show answers
1.
2^4 = 16
Each of the 4 variables doubles the number of rows.
Answer: 16 rows
2.
\lnot q:\ \text{F, T, F, T}Rows TT, TF, FT, FF: negate the q column (T, F, T, F).
p \to \lnot q:\ \text{F, T, T, T}False only in row 1, where p is T and ¬q is F.
Answer: the column for p → ¬q is F, T, T, T
3.
p \land q:\ \text{T, F, F, F}Both are true only in row 1.
\lnot(p \land q):\ \text{F, T, T, T}Negate each entry.
Answer: the column for ¬(p ∧ q) is F, T, T, T
4.
p \oplus q:\ \text{F, T, T, F}True when exactly one of p, q is true (rows 2 and 3).
(p \oplus q) \land q:\ \text{F, F, T, F}Both parts are true only in row 3 (p = F, q = T).
Answer: the column is F, F, T, F; the statement is true only when p is false and q is true
5.
q \to p:\ \text{T, T, F, T}False only in row 3 (q true, p false).
p \to (q \to p):\ \text{T, T, T, T}Rows 1–2 have conclusion T; rows 3–4 have a false hypothesis p.
Answer: a tautology
6.
p \to q:\ \text{T, F, T, T}False only in row 2.
\lnot q:\ \text{F, T, F, T}Negate the q column.
p \land \lnot q:\ \text{F, T, F, F}Both parts are true only in row 2.
(p \to q) \land (p \land \lnot q):\ \text{F, F, F, F}No row has both parts true.
Answer: a contradiction
7.
q \lor r:\ \text{T, T, T, F, T, T, T, F}False only in rows 4 and 8, where q and r are both false.
p \land (q \lor r):\ \text{T, T, T, F, F, F, F, F}Rows 5–8 have p false.
Answer: T, T, T, F, F, F, F, F (true in rows 1, 2 and 3)
8.
\lnot q:\ \text{F, F, T, T, F, F, T, T}Negate the q column (T, T, F, F, T, T, F, F).
p \land \lnot q:\ \text{F, F, T, T, F, F, F, F}True only in rows 3 and 4.
(p \land \lnot q) \lor r:\ \text{T, F, T, T, T, F, T, F}True in rows 3 and 4, or wherever r is true (rows 1, 3, 5, 7).
5
True in rows 1, 3, 4, 5 and 7.
Answer: 5 rows
9.
p \leftrightarrow q:\ \text{T, F, F, T}True when p and q match.
p \oplus q:\ \text{F, T, T, F}True when p and q differ.
(p \leftrightarrow q) \lor (p \oplus q):\ \text{T, T, T, T}In every row exactly one part is true.
Answer: the final column is all T, so it is a tautology
10.
A = (m \lor g) \land \lnot b
“or” joins member and guest pass; “as long as not banned” adds ∧ ¬b.
m = \text{T},\quad g = \text{F},\quad b = \text{T}A banned member with no guest pass.
m \lor g = \text{T} \lor \text{F} = \text{T}At least one part is true.
\lnot b = \text{F}b is true.
A = \text{T} \land \text{F} = \text{F}Not both parts are true.
Answer: A = (m ∨ g) ∧ ¬b, which is false: the banned member is not admitted
Truth tables FAQ
How many rows are in a truth table?
A statement with n variables needs 2n rows, because each variable can be true or false. That gives 4 rows for two variables, 8 for three and 16 for four.
What is a tautology in a truth table?
A tautology is a statement whose final column is T in every row, such as p ∨ ¬p. It is true no matter what truth values its variables have.
What is the difference between a contradiction and a contingency?
A contradiction is false in every row, such as p ∧ ¬p. A contingency is true in at least one row and false in at least one row.
What order should the rows of a truth table go in?
Most textbooks start with all T and end with all F. The first variable fills the top half with T and the bottom half with F, the next variable alternates in quarters, and the last variable alternates T, F in every row.
Summary
- A truth table lists every combination of truth values, one per row, and gives the statement’s truth value in each row.
- A statement with n variables needs 2n rows, filled in the standard order.
- Add one column per connective, from the inside out, using the connective table.
- All T is a tautology, all F is a contradiction, and a mix is a contingency.
- Statements with identical final columns are logically equivalent.
Previous lesson: Propositional Logic
Next lesson: Logical Equivalence
Back to the Discrete Math Index