Propositions, Connectives and Truth Tables
Identify propositions, combine them with and, or, not, if-then and if-and-only-if, and evaluate any compound statement with a truth table.
Welcome back!
Step 1 of 13Learn
Statements that are true or false
A website's checkout code contains this line: if the cart is not empty and (the user is logged in or checking out as a guest), show the payment page. Get the logic slightly wrong and either nobody can pay or anybody can skip a step. Logic is where discrete math begins, because it's how both mathematicians and computers make decisions precise.
A proposition is a declarative sentence that is either true or false, not both.
- "7 is a prime number" is a proposition (true).
- "Paris is the capital of Spain" is a proposition (false).
- "Close the door" is not; it's a command.
- "Is it raining?" is not; it's a question.
- "x + 2 = 5" is not, yet: its truth depends on x. It becomes a proposition once x has a value. Statements like this are predicates, covered in the third lesson.
We name propositions with letters such as p, q and r, and build bigger ones with connectives:
- Negation ¬p ("not p") flips the truth value.
- Conjunction p ∧ q ("p and q") is true only when both are true.
- Disjunction p ∨ q ("p or q") is true when at least one is true. This is the inclusive or: it's true when both are true. The exclusive or, written p ⊕ q, is true when exactly one is true.
In code, these are !, && and || (or not, and, or), and the same rules apply.
Step 2 of 13Flashcards
The five connectives
Tap a card to flip it.
Step 3 of 13Practice · Sort into groups
Which of these sentences are propositions?
Tap an item, then tap its group (or drag it there).
Step 4 of 13Learn
The conditional: if p, then q
The connective that causes the most confusion is the conditional, p → q, read "if p, then q." Here p is the hypothesis and q is the conclusion.
Think of it as a promise. A parent says: "If you finish your homework, then you can play video games." When has the parent broken the promise? Only when the child finishes the homework (p true) and still can't play (q false). If the homework isn't finished, the promise says nothing, so it isn't broken whatever happens.
That gives the truth table:
| p | q | p → q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
The last two rows surprise people: a conditional with a false hypothesis is true. "If 2 + 2 = 5, then pigs can fly" is a true statement in logic. It's called vacuously true. This isn't a trick; it's what makes statements like "every element of the empty set is purple" work smoothly in mathematics.
English has many ways to say p → q: "p implies q," "q if p," "p only if q," "q whenever p," "p is sufficient for q," "q is necessary for p." The phrase "only if" is a frequent trap: "p only if q" means p → q, not q → p.
The biconditional p ↔ q ("p if and only if q") is true when p and q have the same truth value. Mathematicians abbreviate "if and only if" as iff.
Step 5 of 13Compare
The truth table of p → q, row by row
| Aspect | p | q | p → q |
|---|---|---|---|
| Promise kept | T | T | T |
| Promise broken | T | F | F |
| Hypothesis false (q true) | F | T | T (vacuously) |
| Hypothesis false (q false) | F | F | T (vacuously) |
Step 6 of 13Practice · Choose one
Let p be "it is raining" and q be "the ground is wet." When is p → q false?
Step 7 of 13Learn
Building truth tables
A truth table lists every possible combination of truth values for the basic propositions and evaluates the compound statement in each. With n propositions there are 2ⁿ rows: 4 rows for two variables, 8 for three, 16 for four.
A systematic way to list the rows: in the first column alternate blocks of half the rows (T…T then F…F), in the next column blocks of a quarter, and so on, until the last column alternates T, F, T, F.
Example. Evaluate (p ∨ q) ∧ ¬p. Add helper columns for the pieces:
| p | q | p ∨ q | ¬p | (p ∨ q) ∧ ¬p |
|---|---|---|---|---|
| T | T | T | F | F |
| T | F | T | F | F |
| F | T | T | T | T |
| F | F | F | T | F |
The compound is true only in row 3, when p is false and q is true. That matches intuition: "p or q, and not p" forces q. This little pattern is a famous rule of inference called disjunctive syllogism: if you know "the bug is in the frontend or the backend" and "it's not in the frontend," you conclude it's in the backend.
Order of operations. Without parentheses, ¬ binds tightest, then ∧, then ∨, then → and ↔. So ¬p ∨ q means (¬p) ∨ q, not ¬(p ∨ q). When in doubt, use parentheses; programmers do the same.
Truth tables always work, but they grow fast: 20 variables means over a million rows. That's why the next lesson develops algebraic laws for simplifying logic without tables.
Step 8 of 13Explore
Truth-table rows double with each variable
A truth table with n variables has 2n rows. Drag the slider and watch how quickly tables become impossible to write by hand.
- Rows for n variables
- 8
Step 9 of 13Practice · Work it out
How many rows does a truth table for a compound statement with 5 different propositional variables have?
Step 10 of 13Practice · Fill in the blanks
Fill in the blanks
Let p be true, q be false and r be true. Then p ∧ q is , ¬q ∨ r is , and (p ∨ q) → ¬r is .
Step 11 of 13Note
Step 12 of 13Practice · True or false
The statement "If 5 is even, then 5 is prime" is true.
Step 13 of 13Practice · Choose one
Which statement means the same as "You can enroll only if you have paid the fee"?
Lesson complete!