Monocurl Essays
Series Download

If-then statements: converse and contrapositive

When is "if P then Q" true? One table answers it, shows why the contrapositive says the same thing and the converse does not, and solves the four-card puzzle.

21 min·High school and early college·

AssumesTruth tables: and, or, not as calculation

Four cards, each with a letter on one side and a number on the other, showing A, K, 4 and 7. The rule to test says that a card with a vowel on one side has an even number on the other.
Monocurl source
let FACES = ["A", "K", "4", "7"]
let FCOL = [AZURE, AZURE, EMBER, EMBER]
let Pick = |x| FrameBox(x - 0.78, x + 0.78, -1.13, 0.93, GOLD, 5.5)
mesh rule = [
    center{[0, 1.85, 0]} Cap("Rule: if a card has a vowel on one side,", 0.8, INK),
    center{[0, 1.42, 0]} Cap("then it has an even number on the other.", 0.8, INK)
]
mesh cards = map(range(0, 4), |i| Card([CX[i], -0.1, 0], FACES[i], "", 0, FCOL[i], FCOL[i]))
mesh pick = []
mesh ask = []

slide "look"
    play Wait(0.5)
    pick = Pick(x: CX[0])
    play Fade(0.4, [&pick])
    play Wait(0.5)
    for (k in range(1, 4)) {
        pick.x = CX[k]
        play Lerp(0.6, [&pick])
        play Wait(0.5)
    }
    pick = []
    ask = center{[0, -1.72, 0]} Cap("Which cards must you turn over to test the rule?", 0.8, PLUM)
    play Fade(0.5, [&pick, &ask])
    play Wait(2.5)

Uses the shared definitions for this lesson's figures.

Four cards lie on a table. Each has a letter on one side and a number on the other, and the sides you can see show A, K, 4 and 7. Someone makes a claim about these four cards: “If a card has a vowel on one side, then it has an even number on the other.” You want to find out whether the claim is true, and you want to turn over as few cards as possible.

Pause and try

Which cards must you turn over? Write your answer down before opening this one.

Show answerHide answer

The A and the 7. Most people say “A and 4”, or only “A”. When the psychologist Peter Wason set this puzzle in the 1960s, fewer than one in ten of his subjects chose correctly, and the result has been repeated many times since. If you picked the 4 you are in good company, and the rest of this page is about why the 4 can tell you nothing while the 7 can sink the claim. We come back to the cards at the end.

The puzzle is hard because “if ... then” in conversation carries suggestions that are no part of what it says. To reason with it reliably we have to fix exactly when “if $P$ then $Q$” counts as true, in the way the previous lesson did for “and”, “or” and “not”. Recall the method. A statement is a sentence that is true (T) or false (F). A connective is defined by a truth table, which gives the truth value of the compound in each of the four combinations of truth values of $P$ and $Q$. Two compounds are logically equivalent, written $\equiv$, when their columns agree in every row.

When is a promise broken?

Your aunt says: “If you pass the exam, then I will buy you a bike.” Let $P$ be “you pass” and $Q$ be “she buys you a bike”. There are four ways things can go. In which of them has she lied?

  1. You pass and you get the bike. The promise was kept.
  2. You pass and there is no bike. This is the one outcome in which she lied.
  3. You fail. Bike or no bike, she has not broken her word, because the promise only covered the case where you pass.
  4. A statement is either true or false. The promise is false in one row, so it is true in the other three.
The four outcomes of the promise “if you pass the exam, I will buy you a bike”. Only one outcome breaks the promise: you pass and no bike appears. The last column records, for each row, whether the promise was kept.
Monocurl source
let XP = -3.1
let XQ = -2.2
let XV = 0.3
let XR = 2.9
let Y0 = 0.7
let DY = 0.74
let WORDS = ["promise kept", "promise broken", "not broken", "not broken"]
let WCOL = [LEAF, ROSE, SLATE, SLATE]
let RowK = |r| [
    TV([XP, Y0 - r * DY, 0], R2[r][0]),
    TV([XQ, Y0 - r * DY, 0], R2[r][1]),
    center{[XV, Y0 - r * DY, 0]} Cap(WORDS[r], 0.82, WCOL[r])
]
mesh heads = [
    center{[-0.6, 1.9, 0]} Cap("P: you pass      Q: she buys the bike", 0.76, INK),
    center{[XP, 1.38, 0]} Math("P", 0.85, AZURE),
    center{[XQ, 1.38, 0]} Math("Q", 0.85, AZURE)
]
mesh rows = []
mesh result = []

slide "You pass and you get the bike. The promise was kept."
    rows = [RowK(0)]
    play Fade(0.6)

slide "You pass and there is no bike. This is the one outcome in which she lied."
    rows = [RowK(0), RowK(1)]
    play Fade(0.6)

slide "You fail. Bike or no bike, she has not broken her word, because the promise only covered the case where you pass."
    rows = [RowK(0), RowK(1), RowK(2), RowK(3)]
    play Fade(0.6)

slide "A statement is either true or false. The promise is false in one row, so it is true in the other three."
    result = [
        center{[XR, 1.38, 0]} Math("P \to Q", 0.85, EMBER),
        Col(XR, Y0, DY, map(R2, |r| IMP(r[0], r[1])), EMBER)
    ]
    play Fade(0.6)

Uses the shared definitions for this lesson's figures.

She lied in exactly one case: you passed and no bike came. If you failed, she is free to buy the bike anyway or to keep her money, and either way nobody can call her a liar. A statement has to be true or false, with nothing in between, so a promise that was not broken counts as true.

In the bottom two rows, where the hypothesis is false, the conditional is said to be vacuously true. These rows bother everyone at first. They make “if $2 + 2 = 5$ then Paris is in Italy” a true statement. A table is a choice, and this choice needs defending. The promise was one argument. Here are two more that do not depend on it.

The argument from general statements

Everyone accepts that this is true: for every integer $n$, if $n$ is a multiple of 4, then $n$ is even. A statement about every integer is true only if it holds for each one. So put some integers in and see which rows of the table they land in.

The integers 1 to 12 sorted by the truth values of $P$, “n is a multiple of 4”, and $Q$, “n is even”. Three of the four boxes fill up. The box for $P$ true and $Q$ false stays empty, and that empty box is all that the if-then statement claims.
Monocurl source
let isP = |n| mod(n, 4) == 0
let isQ = |n| mod(n, 2) == 0
let bucket = |n| to_int((1 - isP(n)) * 2 + (1 - isQ(n)))
let BX = [-2.7, -0.9, 0.9, 2.7]
let rank = |n| len(filter(range(1, n), |m| bucket(m) == bucket(n)))
let home = |n| [-3.3 + (n - 1) * 0.6, 1.68, 0]
let slot = |n| [BX[bucket(n)] - 0.5 + mod(rank(n), 3) * 0.5, -0.4 - (rank(n) // 3) * 0.55, 0]
let Scan = |s| map(range(1, 13), |n| {
    let u = clamp(0, s - (n - 1) * 0.5, 1)
    let e = u * u * (3 - 2 * u)
    return NumTile(lerp(home(n), slot(n), e), n, AZURE)
})
mesh boxes = [
    center{[0, 1.08, 0]} Cap("P: n is a multiple of 4        Q: n is even", 0.76, INK),
    map(range(0, 4), |b| [
        FrameBox(BX[b] - 0.82, BX[b] + 0.82, -1.3, 0.72, SLATE, 2.5),
        center{[BX[b] - 0.62, 0.36, 0]} Math("P", 0.76, SLATE),
        TV([BX[b] - 0.27, 0.36, 0], R2[b][0], AZURE, 0.38, 0.38, 0.7),
        center{[BX[b] + 0.17, 0.36, 0]} Math("Q", 0.76, SLATE),
        TV([BX[b] + 0.52, 0.36, 0], R2[b][1], AZURE, 0.38, 0.38, 0.7)
    ])
]
mesh scan = Scan(s: 0)
mesh verdict = []

slide "sort"
    play Wait(0.6)
    scan.s = 6.6
    play Lerp(7, [&scan], linear)
    verdict = [
        FrameBox(BX[1] - 0.82, BX[1] + 0.82, -1.3, 0.72, LEAF, 5),
        center{[BX[1], -0.55, 0]} Cap("empty", 0.82, LEAF),
        center{[0, -1.78, 0]} Cap("no integer makes P true and Q false", 0.8, LEAF)
    ]
    play Fade(0.6, [&verdict])
    play Wait(2.2)

Uses the shared definitions for this lesson's figures.

The number 8 is a multiple of 4 and even: row one. The number 6 is not a multiple of 4 but is even: row three. The number 7 is neither: row four. If the conditional were false in row three or in row four, the general statement would be false at $n = 6$ or at $n = 7$, and we would have to say that “multiples of 4 are even” is refuted by the number 7. Nobody wants that. The one row that no integer occupies is row two, and that is the row the statement forbids.

The argument by elimination

Rows one and two are not in dispute: T, then F. There are four ways to complete the column, and three of them are something else that we already have.

rows 3 and 4full columnwhat it is
F, FT, F, F, F$P \land Q$: “if” would mean “and”
F, TT, F, F, Tunchanged when $P$ and $Q$ swap: “if $P$ then $Q$” would mean “if $Q$ then $P$”
T, FT, F, T, Fthe column of $Q$ alone: the hypothesis would do nothing
T, TT, F, T, Tthe definition

“If” is weaker than “and”, it has a direction, and its hypothesis matters. Only the last line keeps all three.

You might object that with $P$ false there is no connection between $P$ and $Q$ at all. That is correct, and the table never claimed one. The arrow says nothing about causes or reasons.

In symbols this is two equivalences, both read off the columns:

$$ P \to Q \;\equiv\; \lnot P \lor Q, \qquad \lnot(P \to Q) \;\equiv\; P \land \lnot Q. $$

The column of $\lnot P \lor Q$ is $\text{F} \lor \text{T}$, $\text{F} \lor \text{F}$, $\text{T} \lor \text{T}$, $\text{T} \lor \text{F}$, which is T, F, T, T. The second follows from the first by De Morgan’s law, $\lnot(A \lor B) \equiv \lnot A \land \lnot B$.

Pause and try

Write the negation of “if it rains, then the match is canceled”. Is it “if it rains, then the match is not canceled”?

Show answerHide answer

The negation is “it rains and the match is not canceled”, $R \land \lnot C$. The other sentence, $R \to \lnot C$, is a different statement: on a dry day both $R \to C$ and $R \to \lnot C$ are vacuously true, so one cannot be the negation of the other.

A picture: one region inside another

Many conditionals are about a whole collection of things: all integers, all cards. For those there is a picture. Draw a region for the things that make $P$ true and another for those that make $Q$ true. “For every $x$, if $P$ holds for $x$ then $Q$ holds for $x$” says that no point lies inside the first region and outside the second, which means the first region sits inside the second.

A point moves around a box in which the region where $P$ is true lies inside the region where $Q$ is true. The table on the right highlights the row the point is in. It visits three rows, and it can never be in the row with $P$ true and $Q$ false.
Monocurl source
let CB = [-1.5, 0, 0]
let RB = 1.55
let CA = [-1.85, -0.15, 0]
let RA = 0.75
let XS = [1.45, 2.2, 3.15]
let Y0 = 0.7
let DY = 0.64
# an ellipse from the top right corner of the box down through the P region
let spot = |t| [-0.8 + 1.037 * cos(t) - 0.271 * sin(t), 0.6 + 0.784 * cos(t) + 0.359 * sin(t), 0]
let row_of = |p| to_int((1 - (dist(p, CA) < RA)) * 2 + (1 - (dist(p, CB) < RB)))
let Band = |t| center{[2.3, Y0 - row_of(spot(t)) * DY, 0]} fill{tint(GOLD, 0.45)} stroke{tint(GOLD, 0.45), 1} Rect([2.75, 0.6])
let Dot = |t| [Pt(spot(t), PAPER, 0.17), Pt(spot(t), INK, 0.12)]
mesh regions = [
    center{[-1.5, 0, 0]} fill{PAPER} stroke{SLATE, 3} Rect([4.2, 3.7]),
    Disc(CB, RB, EMBER, 0.16, 3.5),
    Disc(CA, RA, AZURE, 0.3, 3.5),
    center{[-2.15, 0.95, 0]} Cap("Q true", 0.8, EMBER),
    center{[-1.85, -0.6, 0]} Cap("P true", 0.76, AZURE)
]
mesh band = Band(t: 0)
mesh table = [
    map(range(0, 3), |c| center{[XS[c], 1.45, 0]} Math(["P", "Q", "P \to Q"][c], 0.8, [AZURE, EMBER, INK][c])),
    Col(XS[0], Y0, DY, map(R2, |r| r[0]), AZURE, 0.6, 0.44),
    Col(XS[1], Y0, DY, map(R2, |r| r[1]), EMBER, 0.6, 0.44),
    Col(XS[2], Y0, DY, map(R2, |r| IMP(r[0], r[1])), SLATE, 0.6, 0.44),
    Seg([1.0, Y0 - DY, 0], [3.6, Y0 - DY, 0], ROSE, 3.5),
    center{[2.3, -1.85, 0]} Cap("row 2: no such point", 0.76, ROSE)
]
mesh dot = Dot(t: 0)

slide "roam"
    band.t = TAU
    dot.t = TAU
    play Lerp(10, [&band, &dot], linear)

Uses the shared definitions for this lesson's figures.

The picture also shows what the conditional does not say. There may be plenty of points in the outer region that are not in the inner one, where $Q$ is true and $P$ is false. Keep this picture in mind for the next two sections.

Converse, inverse and contrapositive

From one conditional you can make three others by swapping the two parts, negating them, or both. Try all three on the statement about multiples of 4, for an integer $n$.

  • Swap: “if $n$ is even, then $n$ is a multiple of 4.” False at $n = 6$.
  • Negate both: “if $n$ is not a multiple of 4, then $n$ is not even.” False at $n = 6$.
  • Swap and negate: “if $n$ is not even, then $n$ is not a multiple of 4.” True for every $n$.

Pause and try

“If it is raining, then the ground is wet.” Form the same three variations. Which of them must be true whenever the original is? For each one that need not be, describe a situation where the original is true and the variation is false.

Show answerHide answer

Swap: “if the ground is wet, it is raining”. Negate both: “if it is not raining, the ground is not wet”. Both fail when a sprinkler is on under a clear sky, although the original still holds. Swap and negate: “if the ground is dry, then there is no rain”. This one must be true whenever the original is, because rain on dry ground is exactly what the original rules out.

  1. The original conditional is false only in row two.
  2. The contrapositive is false only when not Q is true and not P is false, which is row two again. Same column.
  3. The converse is false only when Q is true and P is false, which is row three. It disagrees with the original in rows two and three.
  4. The inverse has the same column as the converse.
Truth tables of a conditional and its three variations. The contrapositive has the same column as the original. The converse and the inverse have a different column, which they share with each other.
Monocurl source
let XS = [-3.3, -2.6, -1.4, 0.05, 1.55, 2.95]
let Y0 = 0.6
let DY = 0.68
let Head = |c, name, tex, col| [
    center{[XS[c], 1.9, 0]} Cap(name, 0.74, col),
    center{[XS[c], 1.38, 0]} Math(tex, 0.76, col)
]
let col_of = |f| map(R2, |r| f(r[0], r[1]))
let Around = |c, col| FrameBox(XS[c] - 0.5, XS[c] + 0.5, Y0 - 3 * DY - 0.38, Y0 + 0.38, col)
mesh frames = []
mesh base = [
    center{[XS[0], 1.38, 0]} Math("P", 0.8, AZURE),
    center{[XS[1], 1.38, 0]} Math("Q", 0.8, AZURE),
    Col(XS[0], Y0, DY, col_of(|p, q| p), AZURE, 0.58),
    Col(XS[1], Y0, DY, col_of(|p, q| q), AZURE, 0.58)
]
mesh c1 = []
mesh c2 = []
mesh c3 = []
mesh c4 = []

slide "The original conditional is false only in row two."
    c1 = [Head(2, "original", "P \to Q", EMBER), Col(XS[2], Y0, DY, col_of(|p, q| IMP(p, q)), EMBER)]
    play Fade(0.6)

slide "The contrapositive is false only when not Q is true and not P is false, which is row two again. Same column."
    c2 = [Head(3, "contrapositive", "\lnot Q \to \lnot P", EMBER), Col(XS[3], Y0, DY, col_of(|p, q| IMP(1 - q, 1 - p)), EMBER)]
    frames = [Around(2, LEAF), Around(3, LEAF)]
    play Fade(0.6)

slide "The converse is false only when Q is true and P is false, which is row three. It disagrees with the original in rows two and three."
    c3 = [Head(4, "converse", "Q \to P", PLUM), Col(XS[4], Y0, DY, col_of(|p, q| IMP(q, p)), PLUM)]
    play Fade(0.6)

slide "The inverse has the same column as the converse."
    c4 = [Head(5, "inverse", "\lnot P \to \lnot Q", PLUM), Col(XS[5], Y0, DY, col_of(|p, q| IMP(1 - p, 1 - q)), PLUM)]
    frames = [Around(2, LEAF), Around(3, LEAF), Around(4, PLUM), Around(5, PLUM)]
    play Fade(0.6)

Uses the shared definitions for this lesson's figures.

In the picture of regions, the contrapositive says that everything outside the outer region is outside the inner one, which is the same drawing described from the outside. The converse says that the outer region sits inside the inner one, which is a different drawing.

“Only if”, “necessary”, “sufficient”, “if and only if”

English has several other ways of saying $P \to Q$, and they are easy to read backwards.

Only if. “You may vote only if you are at least 18” does not promise a vote to every adult. It says that voting without being 18 does not happen: if you vote ($V$), then you are at least 18 ($E$). So “$P$ only if $Q$” means $P \to Q$. The word “if” introduces the hypothesis, and the words “only if” introduce the conclusion.

Sufficient and necessary. When $P \to Q$ is true, we say $P$ is sufficient for $Q$, because having $P$ is enough to get $Q$. We also say $Q$ is necessary for $P$, because without $Q$ there is no $P$ (this is the contrapositive). Being a multiple of 4 is sufficient for being even and not necessary, as 6 shows. Being even is necessary for being a multiple of 4 and not sufficient. In the picture, the inner region is the sufficient condition and the outer region the necessary one.

If and only if. When both directions hold we say so with a new connective.

For example, an integer is even if and only if its last digit is even. To prove an “if and only if” you must prove two conditionals, one in each direction, and a common error is to prove one and stop.

Valid and invalid arguments

An argument has premises and a conclusion. Its form is valid if the conclusion is true in every row of the truth table in which all the premises are true. Three forms involving a conditional come up constantly.

Three argument forms tested on the truth table of P \to Q. The shaded rows are those where both premises are true, and the framed cells show the conclusion there. Modus ponens and modus tollens never lead from true premises to a false conclusion. Affirming the consequent does, in the row where P is false and Q is true.
Three argument forms tested on the truth table of $P \to Q$. The shaded rows are those where both premises are true, and the framed cells show the conclusion there. Modus ponens and modus tollens never lead from true premises to a false conclusion. Affirming the consequent does, in the row where $P$ is false and $Q$ is true.
Monocurl source
let Y0 = 0.3
let DY = 0.58
let Form = |cx, name, tex, prem, concl, target, lift = 0| {
    let hot = filter(range(0, 4), |r| prem(R2[r][0], R2[r][1]) == 1)
    let ok = len(filter(hot, |r| concl(R2[r][0], R2[r][1]) == 0)) == 0
    let xs = [cx - 0.72, cx - 0.02, cx + 0.75]
    return [
        map(hot, |r| center{[cx, Y0 - r * DY, 0]} fill{tint(GOLD, 0.4)} stroke{tint(GOLD, 0.4), 1} Rect([2.25, 0.54])),
        center{[cx, 1.9 + lift, 0]} Cap(name, 0.74, INK),
        center{[cx, 1.42, 0]} Math(tex, 0.76, INK),
        map(range(0, 3), |c| center{[xs[c], 0.9, 0]} Math(["P", "Q", "P \to Q"][c], 0.74, SLATE)),
        Col(xs[0], Y0, DY, map(R2, |r| r[0]), AZURE, 0.56, 0.42),
        Col(xs[1], Y0, DY, map(R2, |r| r[1]), AZURE, 0.56, 0.42),
        Col(xs[2], Y0, DY, map(R2, |r| IMP(r[0], r[1])), SLATE, 0.56, 0.42),
        map(hot, |r| FrameBox(xs[target] - 0.36, xs[target] + 0.36, Y0 - r * DY - 0.28, Y0 - r * DY + 0.28, [ROSE, LEAF][concl(R2[r][0], R2[r][1])], 4.5)),
        center{[cx, -1.9, 0]} Cap(["invalid", "valid"][ok], 0.85, [ROSE, LEAF][ok])
    ]
}
mesh forms = [
    Form(-2.55, "modus ponens", "P \to Q,\;\; P \;\therefore\; Q", |p, q| IMP(p, q) * p, |p, q| q, 1),
    Form(0, "modus tollens", "P \to Q,\;\; \lnot Q \;\therefore\; \lnot P", |p, q| IMP(p, q) * (1 - q), |p, q| 1 - p, 0, 0.015),
    Form(2.55, "affirming the consequent", "P \to Q,\;\; Q \;\therefore\; P", |p, q| IMP(p, q) * q, |p, q| p, 0)
]

Uses the shared definitions for this lesson's figures.

Modus tollens is modus ponens applied to the contrapositive. Affirming the consequent is modus ponens applied to the converse, which is why it fails. “If it rains the ground is wet; the ground is wet; so it rained” forgets the sprinkler. There is a fourth form, denying the antecedent (from $P \to Q$ and $\lnot P$, infer $\lnot Q$), which is invalid by the same row three.

The four cards again

The rule on the table is $P \to Q$ with $P$: “the card has a vowel on its letter side” and $Q$: “the card has an even number on its number side”. By the KEY statement, the only thing that can break the rule is a card that is a vowel and odd. So a card needs turning exactly when its hidden side could complete that combination.

  1. The A is a vowel, so the rule makes a demand on its other side. Turn it over. Here the number is even and the rule survives, but an odd number would have broken it.
  2. The K is a consonant. The rule says nothing about consonants, so no number behind it can break the rule. Leave it.
  3. The 4 is even. Turn it anyway: a consonant. A vowel would have been fine too, so this card could never break the rule.
  4. The 7 is odd. Turn it: a vowel. This card has a vowel on one side and an odd number on the other, and the rule is false.
The four-card puzzle solved. The A must be turned because an odd number behind it would break the rule. The 7 must be turned because a vowel behind it would break the rule. Nothing behind the K or the 4 can break it.
Monocurl source
let Cards = |t0, t1, t2, t3| [
    Card([CX[0], 0.1, 0], "A", "6", t0, AZURE, EMBER),
    Card([CX[1], 0.1, 0], "K", "3", t1, AZURE, EMBER),
    Card([CX[2], 0.1, 0], "4", "B", t2, EMBER, AZURE),
    Card([CX[3], 0.1, 0], "7", "E", t3, EMBER, AZURE)
]
let Tag = |i, top, bottom, col| [
    center{[CX[i], -1.15, 0]} Cap(top, 0.8, col),
    center{[CX[i], -1.6, 0]} Cap(bottom, 0.72, col)
]
mesh rule = [
    center{[0, 1.9, 0]} Cap("Rule: vowel on one side, then even number on the other", 0.76, INK),
    map(range(0, 4), |i| center{[CX[i], 1.32, 0]} Cap(["A: P true", "K: P false", "4: Q true", "7: Q false"][i], 0.76, SLATE))
]
mesh cards = Cards(t0: 0, t1: 0, t2: 0, t3: 0)
mesh tags = []

slide "The A is a vowel, so the rule makes a demand on its other side. Turn it over. Here the number is even and the rule survives, but an odd number would have broken it."
    cards.t0 = 1
    play Lerp(1, [&cards])
    tags = [Tag(0, "must turn", "even: fine", LEAF)]
    play Fade(0.4, [&tags])

slide "The K is a consonant. The rule says nothing about consonants, so no number behind it can break the rule. Leave it."
    tags = [Tag(0, "must turn", "even: fine", LEAF), Tag(1, "leave it", "rule is silent", SLATE)]
    play Fade(0.4, [&tags])

slide "The 4 is even. Turn it anyway: a consonant. A vowel would have been fine too, so this card could never break the rule."
    cards.t2 = 1
    play Lerp(1, [&cards])
    tags = [Tag(0, "must turn", "even: fine", LEAF), Tag(1, "leave it", "rule is silent", SLATE), Tag(2, "leave it", "cannot break it", SLATE)]
    play Fade(0.4, [&tags])

slide "The 7 is odd. Turn it: a vowel. This card has a vowel on one side and an odd number on the other, and the rule is false."
    cards.t3 = 1
    play Lerp(1, [&cards])
    tags = [Tag(0, "must turn", "even: fine", LEAF), Tag(1, "leave it", "rule is silent", SLATE), Tag(2, "leave it", "cannot break it", SLATE), Tag(3, "must turn", "vowel: rule broken", ROSE)]
    play Fade(0.4, [&tags])

Uses the shared definitions for this lesson's figures.

Go through the cards as rows of the table. The A has $P$ true, so it is in row one or row two, and row two is the bad one: turn it. The K has $P$ false, so it is in row three or four, both vacuously true: leave it. The 4 has $Q$ true, so it is in row one or three, both true: leave it. The 7 has $Q$ false, so it is in row two or four, and row two is the bad one: turn it.

Turning the A is modus ponens, and turning the 7 is modus tollens. Choosing the 4 is affirming the consequent: it treats the rule as if it also said “an even number has a vowel behind it”, which is the converse.

The difficulty is in the abstraction more than in the logic. In 1982 Richard Griggs and James Cox gave students the same puzzle as a bar scene: each card is a customer, with a drink on one side and an age on the other, showing beer, cola, 22 and 16, and the rule is “if a person is drinking beer, then the person must be over 19”. About three quarters of their subjects correctly checked the beer drinker and the 16-year-old. The table for $\to$ is what everyone already uses when the content is familiar.

Worked examples

What the arrow does not mean

The arrow is not “causes” and not “and then”. “If the moon is made of cheese, then $2 + 2 = 4$” is true, with no link between the parts. In mathematics this rarely does harm, because almost every conditional that matters sits inside a “for every”: for every integer $n$, if ... then .... There the vacuous rows are the cases the theorem is not about, and the next lesson, on quantifiers, makes that precise.

Parentheses matter more with $\to$ than with $\land$ or $\lor$. When $P$, $Q$, $R$ are all false, $(P \to Q) \to R$ is $\text{T} \to \text{F}$, which is F, while $P \to (Q \to R)$ is $\text{F} \to \text{T}$, which is T.

Stepping back

One row of one table did all the work. A conditional forbids “hypothesis true, conclusion false” and forbids nothing else. From that came vacuous truth, the equivalence with the contrapositive, the failure of the converse, the two valid argument forms, and the answer to the cards. When a conditional confuses you, ask what would refute it.

Check yourself

Which statement is logically equivalent to “if a shape is a square, then it is a rectangle”?

Problems

Problems 1 to 3 repeat the moves of the lesson, 4 to 6 combine them, and 7 and 8 go further.

Problem 1

Compute the column of $\lnot P \to Q$ and identify it as a connective you already know. Then translate “I will go unless it rains” using it.

Show solutionHide solution

In the rows (T, T), (T, F), (F, T), (F, F) the hypothesis $\lnot P$ is F, F, T, T. A conditional with a false hypothesis is true, so the first two rows give T. Row three is $\text{T} \to \text{T}$, which is T, and row four is $\text{T} \to \text{F}$, which is F. The column T, T, T, F is that of $P \lor Q$. “I will go unless it rains” says: if it does not rain, I will go, $\lnot R \to G$, which is $R \lor G$: it rains or I go.

Problem 2

For a triangle $T$, consider “if $T$ is equilateral, then $T$ is isosceles” (an isosceles triangle has at least two equal sides). State the converse, inverse, contrapositive and negation, and say which of the five statements are true for every triangle $T$.

Show solutionHide solution

Original: true for every triangle, since three equal sides include two equal sides. Converse: “if $T$ is isosceles, then $T$ is equilateral”; false for the triangle with sides 5, 5, 3. Inverse: “if $T$ is not equilateral, then $T$ is not isosceles”; false for the same triangle. Contrapositive: “if $T$ is not isosceles, then $T$ is not equilateral”; true for every triangle, being equivalent to the original. Negation: “$T$ is equilateral and $T$ is not isosceles”; false for every triangle.

Problem 3

Write each as a conditional $A \to B$, saying what $A$ and $B$ are. (a) “You get dessert only if you finish dinner.” (b) “Passing the final is sufficient for passing the course.” (c) “Oxygen is necessary for fire.”

Show solutionHide solution

(a) “Only if” introduces the conclusion: if you get dessert, then you finished dinner. It does not promise dessert to everyone who finishes. (b) The sufficient condition is the hypothesis: if you pass the final, then you pass the course. (c) The necessary condition is the conclusion: if there is fire, then there is oxygen. Equivalently, by the contrapositive, no oxygen means no fire.

Problem 4

Four cards each have a number on one side and a letter on the other, and they show 3, 8, E and T. The rule is “if a card has an odd number on one side, then it has a vowel on the other”. Which cards must be turned over to test the rule?

Show solutionHide solution

Here $P$ is “the number is odd” and $Q$ is “the letter is a vowel”. The rule can be broken only by a card with an odd number and a consonant. The 3 has $P$ true: a consonant behind it would break the rule, so turn it. The 8 has $P$ false: leave it. The E has $Q$ true: whatever number is behind it, the rule holds for this card, so leave it. The T has $Q$ false: an odd number behind it would break the rule, so turn it. Answer: 3 and T.

Problem 5

Decide whether each argument is valid, and name its form. (a) “If the alarm rings, there is smoke or heat. The alarm is ringing. There is no smoke. So there is heat.” (b) “If a number is divisible by 6, it is divisible by 3. The number 9 is divisible by 3. So 9 is divisible by 6.”

Show solutionHide solution

(a) Valid. From $A \to (S \lor H)$ and $A$, modus ponens gives $S \lor H$. A true “or” needs at least one true part, and $S$ is false, so $H$ is true. (b) Invalid: this is affirming the consequent. Both premises are true and the conclusion is false, which no valid form allows.

Problem 6

Show that $P \to (Q \to R) \equiv (P \land Q) \to R$ without writing eight rows, by finding the rows where each side is false.

Show solutionHide solution

The left side is false exactly when $P$ is true and $Q \to R$ is false, and $Q \to R$ is false exactly when $Q$ is true and $R$ is false. So the left side is false in the single row $P$ true, $Q$ true, $R$ false. The right side is false exactly when $P \land Q$ is true and $R$ is false, which is the same row. The two columns have their only F in the same place, so they are equal.

Problem 7

Let $a$ and $b$ be integers. Prove by contrapositive: if $ab$ is odd, then $a$ is odd and $b$ is odd.

Show solutionHide solution

The contrapositive is: if it is not the case that both are odd, then $ab$ is not odd. By De Morgan’s law, “not ($a$ odd and $b$ odd)” is “$a$ is even or $b$ is even”. Suppose $a$ is even, say $a = 2k$. Then $ab = 2(kb)$ is even. If instead $b$ is even, $b = 2m$, then $ab = 2(am)$ is even. In both cases $ab$ is not odd, which proves the contrapositive and therefore the statement.

Problem 8

Prove that $\bigl((P \to Q) \land (Q \to R)\bigr) \to (P \to R)$ is a tautology. Then explain what is wrong with this chain: “If it is a dog, it is a mammal. If it is a cat, it is a mammal. So if it is a dog, it is a cat.”

Show solutionHide solution

Suppose some row made the formula false. Then in that row the hypothesis $(P \to Q) \land (Q \to R)$ is true and the conclusion $P \to R$ is false. The second says $P$ is true and $R$ is false. Since $P \to Q$ is true and $P$ is true, $Q$ is true (modus ponens). Since $Q \to R$ is true and $Q$ is true, $R$ is true. But $R$ is false. No such row exists, so the formula is a tautology. The chain about dogs has premises $D \to M$ and $C \to M$, which do not have the shape $P \to Q$, $Q \to R$: the middle term $M$ is the conclusion of both. To chain them one would need $M \to C$, the converse of the second premise, and that is false.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

let R2 = [[1, 1], [1, 0], [0, 1], [0, 0]]
let IMP = |p, q| max(1 - p, q)
# a truth value tile: T is solid, F is hollow
let TV = |pos, v, col = AZURE, w = 0.7, h = 0.48, size = 0.8| [
    center{pos} fill{[PAPER, col][to_int(v)]} stroke{[SLATE, col][to_int(v)], 2.5} Rect([w, h]),
    center{pos} Cap(["F", "T"][to_int(v)], size, [SLATE, PAPER][to_int(v)])
]
let Col = |x, y0, dy, vals, col, w = 0.7, h = 0.48, size = 0.8| map(range(0, len(vals)), |r| TV([x, y0 - r * dy, 0], vals[r], col, w, h, size))
let FrameBox = |x0, x1, y0, y1, col, w = 4.5| Outline([[x0, y0, 0], [x1, y0, 0], [x1, y1, 0], [x0, y1, 0]], col, w)
let NumTile = |pos, n, col = AZURE, w = 0.46, size = 0.76| [
    Box(pos, [w, w], col, 0.15, 2.5),
    center{pos} Math(to_string(n), size, col)
]
let dist = |p, q| sqrt((p[0] - q[0]) ^ 2 + (p[1] - q[1]) ^ 2)
# a card that turns over as t goes from 0 (front) to 1 (back)
let Card = |pos, front, back, t, fcol, bcol, w = 1.3, h = 1.8| {
    let c = max(0.04, abs(cos(PI * t)))
    let side = to_int(t > 0.5)
    var parts = [center{pos} fill{tint([fcol, bcol][side], 0.1)} stroke{[fcol, bcol][side], 3.5} Rect([w * c, h])]
    if (c > 0.3) {
        parts .= center{pos} scale{[c, 1, 1]} Cap([front, back][side], 2.2, [fcol, bcol][side])
    }
    return parts
}
let CX = [-2.4, -0.8, 0.8, 2.4]