Logic and proofs — exam-style exercises with truth tables, arguments with a catch and a divisibility induction (and the neighbour who did not call)

One night the alarm went off at half past eleven and my neighbour Andrés, who always calls when he hears it, did not call. My first reasoning was “if it rings, Andrés calls; he hasn’t called; so it didn’t ring and I imagined it”, and it is a perfect argument: it is called modus tollens. The problem was the first premise: Andrés was away travelling. Logic does not get the steps wrong, but it cannot fix a false hypothesis. In these exercises you will separate the two things: valid arguments from the ones that only look valid, and well-built tables from the ones with a row out of place.

How to use this article

  1. Read each statement and solve it on paper before opening the solution, which is folded just below it. The exercises go from easy to hard: level 1 (basic), level 2 (intermediate) and level 3 (challenge), and the last one has the format of the classroom problems exam.
  2. Then, in “What is wrong here?”, there are three solutions by other students, each with a mistake inside. Try to find it before reading the explanation.
  3. At the end there is the topic 1 theory quiz, with the Campus rules: in single-answer questions each wrong answer subtracts a third; in multiple-answer ones, you only score if you tick them all. Its questions are the ones the MD theory mock exam uses.
  4. To check your tables, use the “Truth table and equivalences” simulator or this article’s “Check it with Python”. If something does not work out, go back to the theory or the guided practice.

Throughout I use the alarm’s letters: pp, the door is open; qq, the sensor detects motion; rr, night mode is on; ss, the alarm rings.

Exercise 1 (level 1): formalising and a table

a) Formalise: “the alarm rings whenever the door is open in night mode”, “the alarm does not ring if night mode is off” and “there is motion but the alarm does not ring”.

b) Build the truth table of ¬p→(q∧¬r)\neg p \to (q \land \neg r) and classify it.

“whenever XX” introduces the hypothesis. “But” is an “and” with a note of contrast. In the table, the final implication is only F when ¬p\neg p is T and q∧¬rq \land \neg r is F.

See the solution to exercise 1

a) “Whenever XX, YY” is X→YX \to Y, with X=p∧rX = p \land r:

(p∧r)→s (p \land r) \to s

“It does not ring if night mode is off”: the hypothesis is “night mode is off”:

¬r→¬s(≡s→r) \neg r \to \neg s \quad (\equiv s \to r)

“There is motion but it does not ring”: the “but” is a conjunction:

q∧¬s q \land \neg s

b) Columns: ¬p\neg p, ¬r\neg r, q∧¬rq \land \neg r and the last one.

pqr¬p¬rq ∧ ¬r¬p → (q ∧ ¬r)
TTTFFFT
TTFFTTT
TFTFFFT
TFFFTFT
FTTTFFF
FTFTTTT
FFTTFFF
FFFTTFF

In the first four rows ¬p\neg p is F, so the last column is T without looking further (an implication with a false hypothesis). In the last four, the last column copies q∧¬rq \land \neg r. Last column: T T T T F T F F. There are T and F: contingency.

Why it is done like this: the rule “F → anything = T” fills half the table in one go. In the exam, do it this way and you save half the working.

Exercise 2 (level 1): propositions and negations

a) Which are propositions? “It is three in the morning”, “x2≥0x^2 \ge 0“, “for every real number xx, x2≥0x^2 \ge 0“, “turn the alarm off!”.

b) Write the negation of “all the sensors work and some window is open”, with W(x)W(x): sensor xx works, and O(y)O(y): window yy is open. Express it in English.

A sentence with a free variable is not a proposition; if the variable is quantified, it is. To negate a conjunction of two quantifiers, first De Morgan and then each quantifier.

See the solution to exercise 2

a)

SentenceProposition?Why
“It is three in the morning”YesAt a given moment it is T or F
“x2≥0x^2 \ge 0“Noxx is free: it is a predicate
“For every real xx, x2≥0x^2 \ge 0“Yes (T)xx is bound by ∀\forall
“Turn the alarm off!”NoIt is an order

b) The sentence is ∀x W(x)∧∃y O(y)\forall x\, W(x) \land \exists y\, O(y). Negating:

¬(∀x W(x)∧∃y O(y))≡¬∀x W(x)∨¬∃y O(y)(De Morgan) \neg\big(\forall x\, W(x) \land \exists y\, O(y)\big) \equiv \neg \forall x\, W(x) \lor \neg \exists y\, O(y) \quad \text{(De Morgan)}
≡∃x ¬W(x)∨∀y ¬O(y)(negating quantifiers) \equiv \exists x\, \neg W(x) \lor \forall y\, \neg O(y) \quad \text{(negating quantifiers)}

In English: “some sensor does not work or no window is open”.

Why it is done like this: the ∧\land becomes ∨\lor before you touch the quantifiers; if you negate the quantifiers and keep the “and”, you get a stronger sentence than the negation.

Exercise 3 (level 2): equivalences with laws

a) Prove with laws, naming each one, that ¬(p→q)∨q≡p∨q\neg(p \to q) \lor q \equiv p \lor q.

b) Is (p→q)→r(p \to q) \to r equivalent to p→(q→r)p \to (q \to r)? Justify your answer with one row.

In a), remove the arrow and apply De Morgan; then the distributive law of ∨\lor and the negation law. In b), look for a row where one is F and the other T: it is usually among the rows with rr F.

See the solution to exercise 3

a)

¬(p→q)∨q≡¬(¬p∨q)∨q(p→q≡¬p∨q) \neg(p \to q) \lor q \equiv \neg(\neg p \lor q) \lor q \quad (p \to q \equiv \neg p \lor q)
≡(p∧¬q)∨q(De Morgan and double negation) \equiv (p \land \neg q) \lor q \quad \text{(De Morgan and double negation)}
≡(p∨q)∧(¬q∨q)(distributive law of ∨) \equiv (p \lor q) \land (\neg q \lor q) \quad \text{(distributive law of } \lor \text{)}
≡(p∨q)∧T(negation)≡p∨q(identity) \equiv (p \lor q) \land \mathbf{T} \quad \text{(negation)} \qquad \equiv p \lor q \quad \text{(identity)}

b) They are not equivalent. With pp F and rr F (and any qq, for example T):

  • (p→q)→r(p \to q) \to r: p→qp \to q = F → T = T; T → F = F.
  • p→(q→r)p \to (q \to r): the hypothesis pp is F, so it is T.

One row where they differ is enough to say they are not equivalent. The implication is not associative: the brackets change the formula.

Why it is done like this: to claim an equivalence you need the whole table or a chain of laws; to deny it, one row (it is a counterexample to “they agree on every row”).

Exercise 4 (level 2): valid argument or fallacy?

For each argument, say whether it is valid. If it is, name the rule; if not, give a situation in which the hypotheses are T and the conclusion F.

a) If the alarm rings, Andrés calls. Andrés has not called. Therefore, the alarm has not rung. b) If there is motion in night mode, the alarm rings. The alarm has rung. Therefore, there was motion in night mode. c) All the ground-floor sensors are infrared. S2 is on the ground floor. Therefore, S2 is infrared. d) The door is open or there is motion. The door is not open. Therefore, there is motion.

Write each argument with letters before deciding. If it looks like a rule but “backwards”, be suspicious.

See the solution to exercise 4
Two valid rules and a fallacyModus ponens and modus tollens are valid; affirming the consequent looks the same but is not.Modus ponensp → qp∴ qvalidModus tollensp → q¬q∴ ¬pvalidAffirming the consequentp → qq∴ p ?NOT valid
From p → q and q you cannot deduce p: the alarm also rings when there is motion.

a) s→as \to a, ¬a\neg a ∴ ¬s\neg s: valid, modus tollens. (In my story it failed because of the premise: Andrés being away made s→as \to a false. A valid argument with a false premise can give a false conclusion.)

b) (q∧r)→s(q \land r) \to s, ss ∴ q∧rq \land r: not valid, it is affirming the consequent. Counterexample: door open, no motion, night mode on (pp T, qq F, rr T). The alarm rings because of the door, both hypotheses are T (the first because q∧rq \land r is F) and the conclusion is F.

c) ∀x (G(x)→I(x))\forall x\, (G(x) \to I(x)), G(S2)G(S2) ∴ I(S2)I(S2): valid. Universal instantiation (from ∀x\forall x to x=S2x = S2) and then modus ponens.

d) p∨qp \lor q, ¬p\neg p ∴ qq: valid, disjunctive syllogism.

Why it is done like this: to show that an argument is not valid, saying “I’m not convinced” is not enough: you have to give the row (the situation) with hypotheses T and conclusion F.

Exercise 5 (level 3): induction and a counterexample

a) Prove by induction that, for every integer n≥1n \ge 1, n3+2nn^3 + 2n is a multiple of 3.

b) A classmate claims: “for every integer n≥1n \ge 1, n2−n+11n^2 – n + 11 is prime; I checked it up to n=10n = 10“. Show that it is false.

In a), expand (k+1)3+2(k+1)(k+1)^3 + 2(k+1) and look inside it for the piece k3+2kk^3 + 2k; what is left over must be a multiple of 3. In b), try an nn that makes the three terms share a factor.

See the solution to exercise 5

a) Let P(n)P(n): “3 divides n3+2nn^3 + 2n“.

Base case (n=1n = 1): 1+2=31 + 2 = 3, which is a multiple of 3.

Inductive step. Assume P(k)P(k): k3+2k=3mk^3 + 2k = 3m for some integer mm. Expand the case k+1k + 1:

(k+1)3+2(k+1)=k3+3k2+3k+1+2k+2 (k+1)^3 + 2(k+1) = k^3 + 3k^2 + 3k + 1 + 2k + 2
=(k3+2k)+3k2+3k+3=3m+3(k2+k+1)=3(m+k2+k+1) = (k^3 + 2k) + 3k^2 + 3k + 3 = 3m + 3(k^2 + k + 1) = 3(m + k^2 + k + 1)

where the hypothesis has been used in k3+2k=3mk^3 + 2k = 3m. Since m+k2+k+1m + k^2 + k + 1 is an integer, the case k+1k+1 is a multiple of 3. By induction, P(n)P(n) is true for every n≥1n \ge 1. ∎

Check: n=4n = 4 → 64+8=72=3⋅2464 + 8 = 72 = 3 \cdot 24.

b) With n=11n = 11: 121−11+11=121=11⋅11121 – 11 + 11 = 121 = 11 \cdot 11, which is not prime. It is a counterexample and the statement is false. Checking ten cases does not prove a “for all”.

Why it is done like this: in a), grouping k3+2kk^3 + 2k is what lets you use the hypothesis; if you expand everything and try to see “by eye” that it is a multiple of 3, it is not a proof. In b), n=11n = 11 makes n2n^2, nn and 11 all multiples of 11.

Exercise 6 (level 3): this is how it comes up in the exam

Problem (1 point). Build the truth table of   (p↔¬q)∨(q→r)  \;(p \leftrightarrow \neg q) \lor (q \to r)\; with the rows in the usual order (TTT to FFF). The last column, read from top to bottom, is: a) T T T T T T T T · b) T F T T T T T T · c) T F T T T F T T · d) F F T T T T F F. Is it a tautology, a contradiction or a contingency?

The last column is a disjunction: it is F only when both sides are F. First find the rows with q→rq \to r F (there are only two) and look at the biconditional only in those.

See the solution to exercise 6

q→rq \to r is F when qq is T and rr is F: rows 2 and 6. In those two, the last column depends on p↔¬qp \leftrightarrow \neg q (with qq T, ¬q\neg q is F):

  • Row 2 (pp T): T ↔ F = F. Last: F ∨ F = F.
  • Row 6 (pp F): F ↔ F = T. Last: T ∨ F = T.

In the remaining rows q→rq \to r is T and the last column is T.

pqr¬qp ↔ ¬qq → rLast
TTTFFTT
TTFFFFF
TFTTTTT
TFFTTTT
FTTFTTT
FTFFTFT
FFTTFTT
FFFTFTT

Last column: T F T T T T T T, option b. There is one F, so it is a contingency (not a tautology, although it looks very much like one).

How it is marked (a rough guide, not official): the correct option is worth the full point; a is the trap for anyone who misses row 2, and c the trap for anyone who gets the biconditional wrong in row 6.

For the curious. Since there is only one F row (T, T, F), the formula is equivalent to the disjunction that “forbids” exactly that row: ¬p∨¬q∨r\neg p \lor \neg q \lor r. It is its conjunctive normal form, the one this topic’s simulator gives you.

What is wrong here?

Three solutions by classmates, each with one mistake. Predict what it is before opening the explanation.

Snippet 1: the negation of the promise

Exercise: negate "if there is motion, the alarm rings".
Answer:   ¬(q → s) ≡ ¬q → ¬s
          "if there is no motion, the alarm does not ring".
See what is wrong

The negation of an implication is not another implication: that is the inverse, and the inverse is not the negation. The implication is only false in the row qq T, ss F, so its negation is true exactly there:

¬(q→s)≡q∧¬s \neg(q \to s) \equiv q \land \neg s

“There is motion and the alarm does not ring”. You can also check it with laws: ¬(¬q∨s)≡q∧¬s\neg(\neg q \lor s) \equiv q \land \neg s.

Negating an implication by negating both sides. The negation of “if A, then B” has no “if”: it is “A and not B”.

Snippet 2: the induction that does not induce

Exercise: prove that 1 + 2 + 4 + … + 2^(n−1) = 2^n − 1 for n ≥ 1.
Answer:   n = 1: 1 = 2 − 1. Yes.
          n = 2: 1 + 2 = 3 = 4 − 1. Yes.
          n = 3: 1 + 2 + 4 = 7 = 8 − 1. Yes.
          It holds for every n by induction.
See what is wrong

That is not induction: it is three examples. The inductive step is missing. Done properly: assume 1+2+⋯+2k−1=2k−11 + 2 + \dots + 2^{k-1} = 2^k – 1 and add the next term, 2k2^k:

(1+⋯+2k−1)+2k=(2k−1)+2k=2⋅2k−1=2k+1−1 (1 + \dots + 2^{k-1}) + 2^k = (2^k – 1) + 2^k = 2 \cdot 2^k – 1 = 2^{k+1} – 1

which is the formula for k+1k + 1. With the base case (n=1n = 1), it is now a proof.

If the letter kk never appears in your “induction”, you have not done the inductive step.

Snippet 3: the quantifiers left the wrong way round

Exercise: negate ∀x ∃y (x + y = 0).
Answer:   ∀x ∃y (x + y ≠ 0)
See what is wrong

The predicate has been negated but not the quantifiers. Every quantifier the negation “passes through” flips: ∀\forall becomes ∃\exists and ∃\exists becomes ∀\forall.

¬∀x ∃y (x+y=0)≡∃x ¬∃y (x+y=0)≡∃x ∀y (x+y≠0) \neg \forall x\, \exists y\, (x + y = 0) \equiv \exists x\, \neg \exists y\, (x + y = 0) \equiv \exists x\, \forall y\, (x + y \ne 0)

“There is an xx that, whatever you add to it, never gives 0″. The classmate’s answer says something different (and over the integers, also true: for each xx there is some yy with a sum other than 0), so it cannot be the negation of a statement that is also true.

Always check your negation with a truth value: a statement and its negation can never both be true.

Check it with Python

Exercises 1, 3, 5 and 6, checked in one go. Open the block in the playground and swap the formulas for yours:

from itertools import product

def imp(a, b):
    return (not a) or b

def column(f, n=3):
    return "".join("T" if f(*v) else "F" for v in product([True, False], repeat=n))

print("ex. 1b:", column(lambda p, q, r: imp(not p, q and not r)))
print("ex. 6 :", column(lambda p, q, r: (p == (not q)) or imp(q, r)))

# ex. 3b: are (p→q)→r and p→(q→r) the same?
a = column(lambda p, q, r: imp(imp(p, q), r))
b = column(lambda p, q, r: imp(p, imp(q, r)))
print("ex. 3b:", a, "versus", b, "->", "equivalent" if a == b else "different")

# ex. 5: n^3 + 2n a multiple of 3, and the counterexample to n^2 - n + 11
print("ex. 5a:", all((n**3 + 2*n) % 3 == 0 for n in range(1, 1000)))
is_prime = lambda m: m > 1 and all(m % d for d in range(2, int(m**0.5) + 1))
print("ex. 5b: first n that fails:", next(n for n in range(1, 100) if not is_prime(n*n - n + 11)))

Output:

ex. 1b: TTTTFTFF
ex. 6 : TFTTTTTT
ex. 3b: TFTTTFTF versus TFTTTTTT -> different
ex. 5a: True
ex. 5b: first n that fails: 11

The two columns in 3b differ in two rows (the ones with pp and rr F), and the first nn that fails in 5b is 11, the same one we found by hand.

Topic 1 theory quiz

These questions are like the topic 1 theory quiz in the Campus exam: single-answer (a wrong answer subtracts a third), multiple-answer (you only score if you tick all the correct ones and no wrong one), true or false, and matching. In the real exam there are 3 or 4 in 8 minutes; here you have more to practice, and you can repeat it as often as you like. They are also the ones the MD theory mock exam uses.

Question 1Single choice

Which of these sentences is a proposition?

  1. Is the alarm on?
  2. 15 is a prime number.
  3. x + 3 = 7
  4. Close the door when you leave.
Solution

Answer: 15 is a prime number.

A proposition is a declarative sentence that is either true or false, never both. “15 is prime” is false (15 = 3 · 5), but it is a proposition.

Question 2Single choice

The implication p→qp \to q is false when:

  1. p is true and q is false
  2. p is false and q is true
  3. p and q are both false
  4. p and q have different values
Solution

Answer: p is true and q is false

The implication is false in only one row: true hypothesis and false conclusion. It is like a promise that is only broken if the condition happens and what was promised does not.

Question 3Single choice

“The alarm rings only if night mode is on”, with ss: the alarm rings, and rr: night mode is on, is formalised as:

  1. r→sr \to s
  2. s→rs \to r
  3. s↔rs \leftrightarrow r
  4. s∧rs \land r
Solution

Answer: s→rs \to r

“p only if q” is p→qp \to q: the necessary condition goes on the right of the arrow. If it rings, night mode was on.

Question 4Match

Match each variant of p→qp \to q with its formula:

Converse
Inverse
Contrapositive
Negation

Definitions:

  • ¬p → ¬q
  • p ∧ ¬q
  • ¬q → ¬p
  • q → p
  • ¬p ∧ q
Solution
  • Converse → q→pq \to p
  • Inverse → ¬p→¬q\neg p \to \neg q
  • Contrapositive → ¬q→¬p\neg q \to \neg p
  • Negation → p∧¬qp \land \neg q

The converse turns the arrow round, the inverse negates both sides and the contrapositive does both. The negation of an implication is not another implication: it is p∧¬qp \land \neg q.

Question 5Multiple · wrong ticks subtract

Tick the formulas that are logically equivalent to p→qp \to q:

  1. ¬p∨q\neg p \lor q
  2. ¬q→¬p\neg q \to \neg p
  3. q→pq \to p
  4. ¬p→¬q\neg p \to \neg q
Solution

Answer: ¬p∨q\neg p \lor q · ¬q→¬p\neg q \to \neg p

An implication is equivalent to ¬p∨q\neg p \lor q (removing the arrow) and to its contrapositive. The converse and the inverse are equivalent to each other, but not to the original.

Question 6Single choice

How many rows does the truth table of a formula with 4 different propositional variables have?

  1. 8
  2. 16
  3. 4
  4. 32
Solution

Answer: 16

Each variable can be T or F, so there are 2n2^n combinations. With 4 variables, 24=162^4 = 16 rows.

Question 7True or false

Say whether each statement is true or false:

  1. p∨¬pp \lor \neg p is a tautology.
  2. p∧¬pp \land \neg p is a contradiction.
  3. p→qp \to q is a tautology.
  4. The negation of a tautology is a contradiction.
Solution
  • T — p∨¬pp \lor \neg p is a tautology.
  • T — p∧¬pp \land \neg p is a contradiction.
  • F — p→qp \to q is a tautology.
  • T — The negation of a tautology is a contradiction.

p→qp \to q is a contingency: it is false in the T → F row and true in the other three. Negation turns every T into F, so a negated tautology is a contradiction.

Question 8Single choice

The last column of the truth table of (p∧q)→¬p(p \land q) \to \neg p, in the order TT, TF, FT, FF, is:

  1. F T T T
  2. T T T T
  3. F F T T
  4. T F F F
Solution

Answer: F T T T

The hypothesis p∧qp \land q is only T in row TT, and there ¬p\neg p is F: T → F = F. In the other three rows the hypothesis is F and the implication is T.

Question 9Single choice

By De Morgan’s laws, ¬(p∨¬q)\neg(p \lor \neg q) is equivalent to:

  1. ¬p∨q\neg p \lor q
  2. ¬p∧q\neg p \land q
  3. p∧¬qp \land \neg q
  4. ¬p∧¬q\neg p \land \neg q
Solution

Answer: ¬p∧q\neg p \land q

The negation goes in and the disjunction becomes a conjunction: ¬p∧¬¬q\neg p \land \neg\neg q, and by double negation, ¬p∧q\neg p \land q.

Question 10Match

Match each equivalence with the name of its law:

p∨(p∧q)≡pp \lor (p \land q) \equiv p
p∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r)
p∨T≡Tp \lor \mathbf{T} \equiv \mathbf{T}
p∧T≡pp \land \mathbf{T} \equiv p

Definitions:

  • Identity
  • Absorption
  • Idempotent
  • Distributive
  • Domination
Solution
  • p∨(p∧q)≡pp \lor (p \land q) \equiv p → Absorption
  • p∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r) → Distributive
  • p∨T≡Tp \lor \mathbf{T} \equiv \mathbf{T} → Domination
  • p∧T≡pp \land \mathbf{T} \equiv p → Identity

Identity: the neutral element changes nothing. Domination: the absorbing element wins. Absorption: pp “swallows” a term that already contains it. Idempotent would be p∨p≡pp \lor p \equiv p.

Question 11Single choice

The negation of “all the sensors in the house work” is:

  1. No sensor works.
  2. Some sensor does not work.
  3. All the sensors fail.
  4. Some sensor works.
Solution

Answer: Some sensor does not work.

¬∀x W(x)≡∃x ¬W(x)\neg \forall x\, W(x) \equiv \exists x\, \neg W(x): “not all of them work” means there is at least one that does not.

Question 12Single choice

Over the integers, which of these statements is false?

  1. ∀x ∃y (x+y=0)\forall x\, \exists y\, (x + y = 0)
  2. ∃y ∀x (x+y=0)\exists y\, \forall x\, (x + y = 0)
  3. ∀x ∃y (y>x)\forall x\, \exists y\, (y > x)
  4. ∃x (x2=x)\exists x\, (x^2 = x)
Solution

Answer: ∃y ∀x (x+y=0)\exists y\, \forall x\, (x + y = 0)

In ∃y ∀x\exists y\, \forall x the same yy would have to work for every xx: no integer added to any other gives 0. The order of the quantifiers matters.

Question 13Multiple · wrong ticks subtract

Tick the valid rules of inference:

  1. From p→qp \to q and pp we deduce qq
  2. From p→qp \to q and ¬q\neg q we deduce ¬p\neg p
  3. From p→qp \to q and qq we deduce pp
  4. From p∨qp \lor q and ¬p\neg p we deduce qq
Solution

Answer: From p→qp \to q and pp we deduce qq · From p→qp \to q and ¬q\neg q we deduce ¬p\neg p · From p∨qp \lor q and ¬p\neg p we deduce qq

They are modus ponens, modus tollens and the disjunctive syllogism. From p→qp \to q and qq you cannot deduce pp: qq may be true for another reason.

Question 14Single choice

To prove “if n2n^2 is even, then nn is even”, the most convenient thing is to prove:

  1. If n is odd, then n² is odd.
  2. If n is even, then n² is even.
  3. If n² is odd, then n is odd.
  4. That n² is even for n = 2, 4 and 6.
Solution

Answer: If n is odd, then n² is odd.

It is the contrapositive, which is equivalent to the original. It starts from n=2k+1n = 2k + 1, which you can work with: n2=2(2k2+2k)+1n^2 = 2(2k^2 + 2k) + 1.

Question 15True or false

About proof methods, say whether it is true or false:

  1. A single counterexample is enough to show that a statement of the form “for all x” is false.
  2. Checking a statement for many values proves that it is true for all of them.
  3. In a proof by contradiction you assume the opposite of what you want to prove and reach a contradiction.
  4. If the hypothesis of an implication is false, the implication is true.
Solution
  • T — A single counterexample is enough to show that a statement of the form “for all x” is false.
  • F — Checking a statement for many values proves that it is true for all of them.
  • T — In a proof by contradiction you assume the opposite of what you want to prove and reach a contradiction.
  • T — If the hypothesis of an implication is false, the implication is true.

Examples can refute a “for all” or prove a “there exists”, but never prove a “for all”. The last one is the vacuous proof.

Question 16Single choice

In a proof by induction of P(n)P(n) for every n≥1n \ge 1, the inductive step consists of proving that:

  1. P(1) is true
  2. For every k ≥ 1, if P(k) is true, P(k + 1) is true as well
  3. P(k + 1) implies P(k)
  4. P(n) is true for n = 1, 2 and 3
Solution

Answer: For every k ≥ 1, if P(k) is true, P(k + 1) is true as well

The inductive step is P(k)→P(k+1)P(k) \to P(k+1) for an arbitrary kk. Together with the base case, it guarantees P(n)P(n) for every n≥1n \ge 1, like dominoes knocking each other over.

Question 17Multiple · wrong ticks subtract

Let D={1,2,3}D = \{1, 2, 3\} be the domain. Tick the true statements:

  1. ∀x (x2≥x)\forall x\, (x^2 \ge x)
  2. ∃x (x+x=x⋅x)\exists x\, (x + x = x \cdot x)
  3. ∀x (x is odd)\forall x\, (x \text{ is odd})
  4. ∃x ∀y (x≤y)\exists x\, \forall y\, (x \le y)
Solution

Answer: ∀x (x2≥x)\forall x\, (x^2 \ge x) · ∃x (x+x=x⋅x)\exists x\, (x + x = x \cdot x) · ∃x ∀y (x≤y)\exists x\, \forall y\, (x \le y)

1≥11 \ge 1, 4≥24 \ge 2 and 9≥39 \ge 3. With x=2x = 2, 2+2=2⋅22 + 2 = 2 \cdot 2. 1 is less than or equal to everything in the domain. 2 is not odd.

Question 18True or false

About equivalence and consistency, say whether it is true or false:

  1. Two formulas P and Q are equivalent if P ↔ Q is a tautology.
  2. The symbol ≡ is one more connective, like ∧ or ∨.
  3. A set of specifications is consistent if some assignment of values makes them all true.
  4. Implication is associative: (p → q) → r ≡ p → (q → r).
Solution
  • T — Two formulas P and Q are equivalent if P ↔ Q is a tautology.
  • F — The symbol ≡ is one more connective, like ∧ or ∨.
  • T — A set of specifications is consistent if some assignment of values makes them all true.
  • F — Implication is associative: (p → q) → r ≡ p → (q → r).

≡ is not a connective: it is a statement about two formulas. Implication is not associative: with p and r false, the first is F and the second T.

What comes next?

Logic gives you the language for everything that follows. In topic 2, the union of sets is an “or”, the intersection an “and”, the complement a “not”, and set identities are proved with membership tables that are truth tables with 1 and 0. And if you want to review this topic’s tables, the “Truth table and equivalences” simulator lets you type any formula and solves it column by column.

MD exam coming up?The theory and classroom-problem packs with new solved questions and problems, their cheat sheets, two blank mock exams and Python functions, for free.See the pack

Cheat sheet: logic and proofs

The essentials in 30 seconds: p→qp \to q is only F in T → F. Truth table: 2n2^n rows, fixed order, one column per subformula. Tautology = all T; contradiction = all F; contingency = mixed. p→q≡¬p∨q≡¬q→¬pp \to q \equiv \neg p \lor q \equiv \neg q \to \neg p. ¬∀≡∃¬\neg \forall \equiv \exists \neg. Induction = base + P(k)→P(k+1)P(k) \to P(k+1).

I want to…HowResult
Remove an arrowp→q≡¬p∨qp \to q \equiv \neg p \lor qOnly ¬\neg, ∧\land, ∨\lor
Negate an implication¬(p→q)≡p∧¬q\neg(p \to q) \equiv p \land \neg q“A and not B”
Negate an ∧\land / ∨\lorDe Morgan¬p∨¬q\neg p \lor \neg q / ¬p∧¬q\neg p \land \neg q
Negate a biconditional¬(p↔q)≡p⊕q\neg(p \leftrightarrow q) \equiv p \oplus qExactly one T
Negate “all”¬∀x P≡∃x ¬P\neg \forall x\, P \equiv \exists x\, \neg P“Some do not”
Negate “some”¬∃x P≡∀x ¬P\neg \exists x\, P \equiv \forall x\, \neg P“None”
Prove p→qp \to qDirect, contrapositive or contradictionPick according to the hypothesis
Knock down a ∀\forallOne counterexampleOne case is enough
Prove ∀n≥1\forall n \ge 1InductionBase + step
SentenceFormula
pp only if qq · qq is necessary for ppp→qp \to q
pp is sufficient for qq · qq whenever ppp→qp \to q
qq unless ¬p\neg p · not qq unless ppp→qp \to q · q→pq \to p
pp if and only if qqp↔qp \leftrightarrow q
pp but qqp∧qp \land q
RuleScheme
Modus ponenspp, p→qp \to q ∴ qq
Modus tollens¬q\neg q, p→qp \to q ∴ ¬p\neg p
Hypothetical syllogismp→qp \to q, q→rq \to r ∴ p→rp \to r
Disjunctive syllogismp∨qp \lor q, ¬p\neg p ∴ qq
Resolutionp∨qp \lor q, ¬p∨r\neg p \lor r ∴ q∨rq \lor r
FallaciesAffirming the consequent; denying the antecedent
SymptomLikely cause
The table has 7 rows (or 9)You did not count 2n2^n or follow the fixed order
No option matches your columnAn intermediate column is wrong; check the second to last
Your negation is also trueYou did not change the connective or the quantifier
Your induction has no kkYou only gave examples: the inductive step is missing
“I formalised it backwards”You mixed up “if” and “only if”

Before handing in, ask yourself:

  1. Does my table have 2n2^n rows in the order TTT to FFF?
  2. Have I looked at the implication only in the T → F rows?
  3. Does every step of my equivalence carry the name of a law?
  4. Can my negation and the original statement both be true? (If so, it is wrong.)
Keep goingAll Discrete mathematics articles

Did this article help you? Here is how you can support SergioLearns →