Find a course

Module 2: Propositional LogicLesson 4 of 1314 min

Truth Tables

Build truth tables row by row, find the main connective, and use them to identify tautologies, contradictions, equivalences and valid arguments.

Step 1 of 13Learn

A machine that checks reasoning

Is "Either I'm on time, or I'm not" always true? Is "It's not the case that I'm both on time and late" the same as "I'm not on time or I'm not late"? You could argue about these, or you could compute the answer. A truth table lists every possible combination of truth values for the simple statements and works out the compound statement in each case.

Here are the tables for the five connectives (T = true, F = false):

PQ¬PP ∧ QP ∨ QP → QP ↔ Q
TTFTTTT
TFFFTFF
FTTFTTF
FFTFFTT

Memorize the patterns rather than the grid:

  • ∧ is true only when both are true.
  • ∨ is false only when both are false.
  • → is false only when the antecedent is true and the consequent false.
  • ↔ is true when both sides match.

That third rule surprises people, and the next lesson spends time on it. For now, notice the logic: a promise "If you finish, I'll pay you" is only broken when you finish and I don't pay.

Step 2 of 13Learn

How many rows?

Each simple statement can be true or false, so every new letter doubles the number of rows. One letter needs 2 rows, two letters need 4, three letters need 8. In general, n letters need 2 multiplied by itself n times rows.

To make sure you cover every combination, use a standard pattern. With three letters P, Q, R and 8 rows:

  • Under P, write 4 T's then 4 F's.
  • Under Q, alternate in pairs: T T F F T T F F.
  • Under R, alternate one at a time: T F T F T F T F.

Then work from the inside out. For (P ∨ Q) → ¬R you'd first compute P ∨ Q, then ¬R, and finally the arrow, which is the main connective: the one that applies to the whole statement. The main connective's column is the answer column.

Truth tables grow fast. Ten letters need 1,024 rows, and twenty need over a million. That's why logicians also use shortcut methods, and why computer scientists care about how hard such problems are. Checking whether a formula can ever be true, the famous SAT problem, is a central question in computer science.

Step 3 of 13Practice · Chart

Rows in a truth table

Every new letter doubles the rows: 2, 4, 8, 16…

Tap the first table that needs more than 50 rows.

Tap the bar that answers the question, then press Check.

Rows in a truth tableBar chart with 6 categories: 1 letter: 2; 2 letters: 4; 3 letters: 8; 4 letters: 16; 5 letters: 32; 6 letters: 64.020406080Rows needed1 letter2 letters3 letters4 letters5 letters6 lettersSimple statements248163264
Rows in a truth table
Simple statementsRows
1 letter2
2 letters4
3 letters8
4 letters16
5 letters32
6 letters64

Step 4 of 13Try the calculator

Truth table size

Each new simple statement doubles the rows. Try 3, 5 and 10 letters.

Rows needed
8
Cells in the letter columns alone
24

Step 5 of 13Practice · Work it out

How many rows does a complete truth table need for a statement containing the letters A, B, C and D?

Step 6 of 13Learn

Tautologies, contradictions and contingencies

Once a table is done, look at the main connective's column.

  • If it's all T, the statement is a tautology: true in every possible situation. P ∨ ¬P ("I'm on time or I'm not") is the simplest one. Tautologies are true by logic alone, so they tell you nothing about the world.
  • If it's all F, the statement is a contradiction: P ∧ ¬P ("I'm on time and I'm not on time"). No situation makes it true.
  • If it's mixed, the statement is contingent: its truth depends on the facts. Most claims worth arguing about are contingent.

Two statements are logically equivalent when their columns match in every row. They say the same thing in different words. The most useful equivalences are De Morgan's laws:

  • ¬(P ∧ Q) is equivalent to ¬P ∨ ¬Q. ("Not both" = "at least one is false.")
  • ¬(P ∨ Q) is equivalent to ¬P ∧ ¬Q. ("Neither" = "both are false.")

Programmers use these daily. The condition !(loggedIn && isAdmin) means the same as !loggedIn || !isAdmin. Getting it wrong, for example writing !loggedIn && !isAdmin, is a classic bug that locks out ordinary logged-in users.

Step 7 of 13Practice · Diagram

Read the main connective's column

A main column reads T, F, T, T. Which kind of statement is it?

Tap the shape that answers the question, then press Check.

Read the main connective's columnHierarchy diagram: Main connective column, All T: tautology, All F: contradiction, Mixed: contingent.Main connectivecolumnAll T: tautologyAll F: contradictionMixed: contingent
Main connective column
All T: tautology

True in every situation, like P ∨ ¬P.

All F: contradiction

True in no situation, like P ∧ ¬P.

Mixed: contingent

Depends on the facts. Most claims worth arguing about.

Step 8 of 13Practice · Match the pairs

Match each statement with its classification.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. P ∨ ¬P
  2. P ∧ ¬P
  3. P → Q
  4. ¬(P ∧ Q) ↔ (¬P ∨ ¬Q)

Step 9 of 13Practice · Choose one

Which statement is logically equivalent to "It is not the case that the café is open or the library is open," ¬(C ∨ L)?

Step 10 of 13Learn

Testing validity with a truth table

Truth tables also test arguments. Put the premises and the conclusion in columns and look for a bad row: a row where every premise is true and the conclusion is false. If there's even one bad row, the argument is invalid. If there are none, it's valid.

Test: P → Q, Q, therefore P.

PQP → QQP
TTTTT
TFFFT
FTTTF
FFTFF

Row 3 has both premises true and the conclusion false. Invalid. In English: "If it's a robin, it's a bird. It's a bird. So it's a robin." Row 3 is the situation where it's a sparrow.

Now test P → Q, P, therefore Q. The only row where both premises are true is row 1, and there Q is true. No bad row, so the argument is valid. This form is called modus ponens, and you'll meet it formally soon.

The method is mechanical, which is its beauty. It doesn't care whether you like the conclusion, so it's immune to belief bias. Its cost is size: for many letters, smarter methods win.

Step 11 of 13Note

Step 12 of 13Practice · What would you do?

What would you do?

Test this argument with the bad-row shortcut: "P ∨ Q. ¬P. Therefore Q." You assume Q is false and both premises true. What happens?

Step 13 of 13Practice · True or false

If a truth table for an argument has no row where all the premises are true, the argument is valid.