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.
Table of Contents
How to use this article
- 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.
- 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.
- 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.
- 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: , the door is open; , the sensor detects motion; , night mode is on; , 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 and classify it.
“whenever ” introduces the hypothesis. “But” is an “and” with a note of contrast. In the table, the final implication is only F when is T and is F.
See the solution to exercise 1
a) “Whenever , ” is , with :
“It does not ring if night mode is off”: the hypothesis is “night mode is off”:
“There is motion but it does not ring”: the “but” is a conjunction:
b) Columns: , , and the last one.
| p | q | r | ¬p | ¬r | q ∧ ¬r | ¬p → (q ∧ ¬r) |
|---|---|---|---|---|---|---|
| T | T | T | F | F | F | T |
| T | T | F | F | T | T | T |
| T | F | T | F | F | F | T |
| T | F | F | F | T | F | T |
| F | T | T | T | F | F | F |
| F | T | F | T | T | T | T |
| F | F | T | T | F | F | F |
| F | F | F | T | T | F | F |
In the first four rows 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 . 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”, ““, “for every real number , “, “turn the alarm off!”.
b) Write the negation of “all the sensors work and some window is open”, with : sensor works, and : window 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)
| Sentence | Proposition? | Why |
|---|---|---|
| “It is three in the morning” | Yes | At a given moment it is T or F |
| ““ | No | is free: it is a predicate |
| “For every real , “ | Yes (T) | is bound by |
| “Turn the alarm off!” | No | It is an order |
b) The sentence is . Negating:
In English: “some sensor does not work or no window is open”.
Why it is done like this: the becomes 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 .
b) Is equivalent to ? Justify your answer with one row.
In a), remove the arrow and apply De Morgan; then the distributive law of 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 F.
See the solution to exercise 3
a)
b) They are not equivalent. With F and F (and any , for example T):
- : = F → T = T; T → F = F.
- : the hypothesis 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
a) , ∴ : valid, modus tollens. (In my story it failed because of the premise: Andrés being away made false. A valid argument with a false premise can give a false conclusion.)
b) , ∴ : not valid, it is affirming the consequent. Counterexample: door open, no motion, night mode on ( T, F, T). The alarm rings because of the door, both hypotheses are T (the first because is F) and the conclusion is F.
c) , ∴ : valid. Universal instantiation (from to ) and then modus ponens.
d) , ∴ : 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 , is a multiple of 3.
b) A classmate claims: “for every integer , is prime; I checked it up to “. Show that it is false.
In a), expand and look inside it for the piece ; what is left over must be a multiple of 3. In b), try an that makes the three terms share a factor.
See the solution to exercise 5
a) Let : “3 divides “.
Base case (): , which is a multiple of 3.
Inductive step. Assume : for some integer . Expand the case :
where the hypothesis has been used in . Since is an integer, the case is a multiple of 3. By induction, is true for every . ∎
Check: → .
b) With : , 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 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), makes , 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 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 F (there are only two) and look at the biconditional only in those.
See the solution to exercise 6
is F when is T and is F: rows 2 and 6. In those two, the last column depends on (with T, is F):
- Row 2 ( T): T ↔ F = F. Last: F ∨ F = F.
- Row 6 ( F): F ↔ F = T. Last: T ∨ F = T.
In the remaining rows is T and the last column is T.
| p | q | r | ¬q | p ↔ ¬q | q → r | Last |
|---|---|---|---|---|---|---|
| T | T | T | F | F | T | T |
| T | T | F | F | F | F | F |
| T | F | T | T | T | T | T |
| T | F | F | T | T | T | T |
| F | T | T | F | T | T | T |
| F | T | F | F | T | F | T |
| F | F | T | T | F | T | T |
| F | F | F | T | F | T | T |
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: . 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 T, F, so its negation is true exactly there:
“There is motion and the alarm does not ring”. You can also check it with laws: .
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 and add the next term, :
which is the formula for . With the base case (), it is now a proof.
If the letter 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: becomes and becomes .
“There is an that, whatever you add to it, never gives 0″. The classmate’s answer says something different (and over the integers, also true: for each there is some 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 and F), and the first 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.
Which of these sentences is a proposition?
- Is the alarm on?
- 15 is a prime number.
- x + 3 = 7
- 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.
The implication is false when:
- p is true and q is false
- p is false and q is true
- p and q are both false
- 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.
“The alarm rings only if night mode is on”, with : the alarm rings, and : night mode is on, is formalised as:
Solution
Answer:
“p only if q” is : the necessary condition goes on the right of the arrow. If it rings, night mode was on.
Match each variant of with its formula:
| Converse | |
| Inverse | |
| Contrapositive | |
| Negation |
Definitions:
- ¬p → ¬q
- p ∧ ¬q
- ¬q → ¬p
- q → p
- ¬p ∧ q
Solution
- Converse →
- Inverse →
- Contrapositive →
- Negation →
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 .
Tick the formulas that are logically equivalent to :
Solution
Answer: ·
An implication is equivalent to (removing the arrow) and to its contrapositive. The converse and the inverse are equivalent to each other, but not to the original.
How many rows does the truth table of a formula with 4 different propositional variables have?
- 8
- 16
- 4
- 32
Solution
Answer: 16
Each variable can be T or F, so there are combinations. With 4 variables, rows.
Say whether each statement is true or false:
- is a tautology.
- is a contradiction.
- is a tautology.
- The negation of a tautology is a contradiction.
Solution
- T — is a tautology.
- T — is a contradiction.
- F — is a tautology.
- T — The negation of a tautology is a contradiction.
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.
The last column of the truth table of , in the order TT, TF, FT, FF, is:
- F T T T
- T T T T
- F F T T
- T F F F
Solution
Answer: F T T T
The hypothesis is only T in row TT, and there is F: T → F = F. In the other three rows the hypothesis is F and the implication is T.
By De Morgan’s laws, is equivalent to:
Solution
Answer:
The negation goes in and the disjunction becomes a conjunction: , and by double negation, .
Match each equivalence with the name of its law:
Definitions:
- Identity
- Absorption
- Idempotent
- Distributive
- Domination
Solution
- → Absorption
- → Distributive
- → Domination
- → Identity
Identity: the neutral element changes nothing. Domination: the absorbing element wins. Absorption: “swallows” a term that already contains it. Idempotent would be .
The negation of “all the sensors in the house work” is:
- No sensor works.
- Some sensor does not work.
- All the sensors fail.
- Some sensor works.
Solution
Answer: Some sensor does not work.
: “not all of them work” means there is at least one that does not.
Over the integers, which of these statements is false?
Solution
Answer:
In the same would have to work for every : no integer added to any other gives 0. The order of the quantifiers matters.
Tick the valid rules of inference:
- From and we deduce
- From and we deduce
- From and we deduce
- From and we deduce
Solution
Answer: From and we deduce · From and we deduce · From and we deduce
They are modus ponens, modus tollens and the disjunctive syllogism. From and you cannot deduce : may be true for another reason.
To prove “if is even, then is even”, the most convenient thing is to prove:
- If n is odd, then n² is odd.
- If n is even, then n² is even.
- If n² is odd, then n is odd.
- 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 , which you can work with: .
About proof methods, say whether it is true or false:
- A single counterexample is enough to show that a statement of the form “for all x” is false.
- Checking a statement for many values proves that it is true for all of them.
- In a proof by contradiction you assume the opposite of what you want to prove and reach a contradiction.
- 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.
In a proof by induction of for every , the inductive step consists of proving that:
- P(1) is true
- For every k ≥ 1, if P(k) is true, P(k + 1) is true as well
- P(k + 1) implies P(k)
- 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 for an arbitrary . Together with the base case, it guarantees for every , like dominoes knocking each other over.
Let be the domain. Tick the true statements:
Solution
Answer: · ·
, and . With , . 1 is less than or equal to everything in the domain. 2 is not odd.
About equivalence and consistency, say whether it is true or false:
- Two formulas P and Q are equivalent if P ↔ Q is a tautology.
- The symbol ≡ is one more connective, like ∧ or ∨.
- A set of specifications is consistent if some assignment of values makes them all true.
- 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.
Cheat sheet: logic and proofs
The essentials in 30 seconds: is only F in T → F. Truth table: rows, fixed order, one column per subformula. Tautology = all T; contradiction = all F; contingency = mixed. . . Induction = base + .
| I want to… | How | Result |
|---|---|---|
| Remove an arrow | Only , , | |
| Negate an implication | “A and not B” | |
| Negate an / | De Morgan | / |
| Negate a biconditional | Exactly one T | |
| Negate “all” | “Some do not” | |
| Negate “some” | “None” | |
| Prove | Direct, contrapositive or contradiction | Pick according to the hypothesis |
| Knock down a | One counterexample | One case is enough |
| Prove | Induction | Base + step |
| Sentence | Formula |
|---|---|
| only if · is necessary for | |
| is sufficient for · whenever | |
| unless · not unless | · |
| if and only if | |
| but |
| Rule | Scheme |
|---|---|
| Modus ponens | , ∴ |
| Modus tollens | , ∴ |
| Hypothetical syllogism | , ∴ |
| Disjunctive syllogism | , ∴ |
| Resolution | , ∴ |
| Fallacies | Affirming the consequent; denying the antecedent |
| Symptom | Likely cause |
|---|---|
| The table has 7 rows (or 9) | You did not count or follow the fixed order |
| No option matches your column | An intermediate column is wrong; check the second to last |
| Your negation is also true | You did not change the connective or the quantifier |
| Your induction has no | You only gave examples: the inductive step is missing |
| “I formalised it backwards” | You mixed up “if” and “only if” |
Before handing in, ask yourself:
- Does my table have rows in the order TTT to FFF?
- Have I looked at the implication only in the T → F rows?
- Does every step of my equivalence carry the name of a law?
- Can my negation and the original statement both be true? (If so, it is wrong.)
Did this article help you? Here is how you can support SergioLearns →


