Lesson 2 of the mathematical toolkit. It starts with what a proof actually is, then covers direct proof and the contrapositive, and proof by contradiction through the irrationality of the square root of 2 and the infinitude of the primes. From there it works through weak and strong mathematical induction, the well-ordering principle, the pigeonhole principle, recursive definitions, and computing the reflexive, symmetric, and transitive closures of a relation. It targets the confusion between a converse and a contrapositive, the missing base case, and the one-round transitive-closure error. Every proof and computation was verified by hand.
Subject: Theory of Computation · 111 slides · symbolic lesson
Open the interactive version of this deck · Homework for this lesson
Title
Theory of Computation · Lesson 2
How we know a statement is true for every case — even infinitely many.
Objectives
Automata theory is a chain of proofs. This lesson gives you the proof techniques the whole field runs on. By the end you can:
Warm-up
Discussion prompt
Before we open Proof, Induction & Closures: without looking back, what was the main idea of Sets, Relations & Functions, and what could you do by the end of it that you could not do before?
Hint: One sentence for the idea, one for the skill. If the second one is blank, that is the part to revisit.
Answer:
Lesson 1 of the mathematical toolkit for automata theory: sets and set-builder notation, the algebra of union/intersection/complement, power sets and Cartesian products, binary relations and their properties, equivalence relations and partitions, partial orders, and functions classified as injective, surjective, and bijective. Targets the classic membership-vs-subset, codomain-vs-range, and (a,b)-vs-{a,b} confusions.
Section
Section 1
Concept
A theorem is a statement asserted to be true. A proof is an airtight argument that leaves no possible counterexample — it settles every case at once.
Most theorems have the shape 'if P then Q'. P is the hypothesis you get to assume; Q is the conclusion you must reach.
\[ P \Rightarrow Q \]
counterexample — A single case where the hypothesis holds but the conclusion fails. One counterexample destroys a universal claim; no number of examples can prove one.
Counterexample
Discussion prompt
A theorem is a statement asserted to be true. A proof is an airtight argument that leaves no possible counterexample — it settles every case at once.
That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.
Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.
Answer:
Most theorems have the shape 'if P then Q'. P is the hypothesis you get to assume; Q is the conclusion you must reach.
Intuition
Think of a proof as a chain of links running from what you assumed to what you want. Each link is a step so small that no reasonable person could deny it.
Testing examples is not proof — it only checks a few links you happened to look at. A proof guarantees the whole chain holds, for inputs you will never even list.
Analogy
Discussion prompt
Explain A proof is a chain no one can break by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.
Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.
Answer:
Think of a proof as a chain of links running from what you assumed to what you want. Each link is a step so small that no reasonable person could deny it.
Concept
A direct proof of 'if P then Q' simply assumes P and walks forward, step by justified step, until Q drops out.
\[ \text{Assume } P \ \longrightarrow\ \cdots \ \longrightarrow\ Q \]
It is the first thing to try. Translate the hypothesis into an equation or definition you can manipulate, then push toward the conclusion.
Explain it
Discussion prompt
Explain Direct proof to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.
Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.
Answer:
A direct proof of 'if P then Q' simply assumes P and walks forward, step by justified step, until Q drops out.
Ranking
Put in order
Put the moves of Direct proof: the sum of two even numbers is even into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. An even number is two times an integer.
Worked example
Claim: if a and b are both even, then their sum is even.
\[ P:\ a,b \text{ even} \qquad Q:\ a+b \text{ even} \]
Translate the hypothesis into algebra
Why: An even number is two times an integer. Give each even number that form with its own integer name.
\[ a = 2m, \quad b = 2n \quad (m,n \in \mathbb{Z}) \]
Add and factor out the 2
Why: Adding the two forms and pulling out a factor of 2 exposes the even structure directly.
\[ a + b = 2m + 2n = 2(m+n) \]
Recognize the conclusion
Why: Since m+n is an integer, the sum is two times an integer — the definition of even. That is Q.
\[ a+b = 2(m+n),\ (m+n)\in\mathbb{Z} \Rightarrow a+b \text{ even} \]
Verify on a concrete instance
Why: Take a = 4, b = 6: here m = 2, n = 3, so a+b = 10 = 2(5). The general form matches the specific case.
\[ 4 + 6 = 2(2+3) = 10\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Direct proof: the sum of two even numbers is even", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Take a = 4, b = 6: here m = 2, n = 3, so a+b = 10 = 2(5). The general form matches the specific case.
Concept
Every implication has a contrapositive — flip the two parts and negate both. The remarkable fact: a statement and its contrapositive are logically identical, always true together or false together.
\[ (P \Rightarrow Q) \equiv (\lnot Q \Rightarrow \lnot P) \]
So you may prove either one. When the negations are easier to work with than the originals, prove the contrapositive instead.
Intuition
'If it rained, the ground is wet' says exactly the same thing as 'if the ground is dry, it did not rain'. Deny the outcome and you have denied the cause.
That equivalence is a gift: sometimes assuming the conclusion is false gives you a concrete handle that assuming the hypothesis true does not.
Step zero
Discussion prompt
Contrapositive: if n² is even, then n is even — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Assume the negated conclusion: n is odd
Answer:
Worked example
Proving this directly is awkward. Its contrapositive is easy, so prove that instead.
\[ \text{Contrapositive: } n \text{ odd} \Rightarrow n^2 \text{ odd} \]
Assume the negated conclusion: n is odd
Why: An odd number is two times an integer plus one. Write n in that form.
\[ n = 2k + 1 \quad (k \in \mathbb{Z}) \]
Square it and reorganize
Why: Expand the square and factor a 2 out of the first two terms to expose the odd structure.
\[ n^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1 \]
Conclude n² is odd
Why: The result is two times an integer plus one, so n squared is odd. That proves the contrapositive, hence the original.
\[ n^2 = 2(2k^2+2k)+1 \Rightarrow n^2 \text{ odd} \]
Verify with a value
Why: Take n = 3 (odd): n squared is 9, which is odd. The contrapositive holds on this instance, consistent with the proof.
\[ n=3:\ n^2 = 9 = 2(4)+1 \text{ (odd)}\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Contrapositive: if n² is even, then n is even", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Take n = 3 (odd): n squared is 9, which is odd. The contrapositive holds on this instance, consistent with the proof.
Concept
Some theorems assert equivalence in both directions at once — 'P if and only if Q'. This biconditional is really two implications bundled together.
\[ P \iff Q \quad\equiv\quad (P \Rightarrow Q)\ \text{and}\ (Q \Rightarrow P) \]
To prove an 'if and only if', you must prove each direction separately. Proving only one leaves half the claim unestablished.
Estimation
Predict first
This needs both directions. One we already have; the other is a quick direct proof.
Commit before you compute: what does Prove a biconditional: n is even iff n² is even come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify both directions on an example
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. n = 6 is even and 6 squared = 36 is even; n = 5 is odd and 25 is odd.
Worked example
This needs both directions. One we already have; the other is a quick direct proof.
\[ n \text{ even} \iff n^2 \text{ even} \]
Forward direction: n even ⇒ n² even
Why: Write n = 2m; then n squared is 4m², which is two times 2m² — even. Direct and done.
\[ n = 2m \Rightarrow n^2 = 2(2m^2) \text{ (even)} \]
Backward direction: n² even ⇒ n even
Why: This is exactly the contrapositive result proved earlier — 'n odd ⇒ n² odd' gives it. So both arrows hold.
\[ n^2 \text{ even} \Rightarrow n \text{ even} \ (\text{contrapositive proof}) \]
Verify both directions on an example
Why: n = 6 is even and 6 squared = 36 is even; n = 5 is odd and 25 is odd. Neither direction has a counterexample, matching the two proofs.
\[ 6 \leftrightarrow 36,\quad 5 \leftrightarrow 25\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Prove a biconditional: n is even iff n² is even", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: n = 6 is even and 6 squared = 36 is even; n = 5 is odd and 25 is odd. Neither direction has a counterexample, matching the two proofs.
Anomaly
Predict first
A student writes this, and it looks reasonable:
To prove 'if P then Q', a student proves 'if Q then P' and thinks the job is done.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: The converse swaps the parts WITHOUT negating them, and it is a different, logically independent claim.
Only the contrapositive is equivalent. Flip AND negate both parts.
Why: The converse swaps the parts WITHOUT negating them, and it is a different, logically independent claim. Proving it says nothing about the original.
Trap
To prove 'if P then Q', a student proves 'if Q then P' and thinks the job is done.
\[ \text{Wanted: } P \Rightarrow Q \]
Prove the converse Q ⇒ P instead
Why: The converse swaps the parts WITHOUT negating them, and it is a different, logically independent claim. Proving it says nothing about the original.
\[ Q \Rightarrow P \ \not\equiv\ P \Rightarrow Q \]
Only the contrapositive is equivalent. Flip AND negate both parts.
\[ \text{Wanted: } P \Rightarrow Q \]
Prove the contrapositive
Why: Negate the conclusion, negate the hypothesis, and reverse the arrow. This is logically the same statement, so proving it proves the original.
\[ \lnot Q \Rightarrow \lnot P \ \equiv\ P \Rightarrow Q \]
See the difference on an example
Why: 'x > 2 ⇒ x > 0' is true, but its converse 'x > 0 ⇒ x > 2' is false (take x = 1). Converse and original can disagree.
\[ x>2 \Rightarrow x>0 \ (\text{true}); \quad x>0 \Rightarrow x>2 \ (\text{false}) \]
Notation
Annotate
From Trap: the converse is not the contrapositive — read this one piece at a time. What is each part doing?
On: \( \text{Wanted: } P \Rightarrow Q \)
Pattern
1. Try direct first
Why: Assume P, translate to definitions, and push toward Q. Most implications yield to this.
2. Stuck? Write the contrapositive
Why: If assuming P gives you nothing to grab, assume 'not Q' and aim for 'not P' — same claim, different handle.
3. Never prove the converse by accident
Why: Flip-and-negate is the contrapositive; flip-only is the converse, a different statement. Check which you wrote.
Check
Consider the statement below.
\[ \text{If } n \text{ is prime and } n > 2, \text{ then } n \text{ is odd.} \]
Check your understanding
Which statement is the contrapositive?
Answer: A
Why: The contrapositive negates the conclusion and the hypothesis and reverses the arrow. Negated conclusion: 'n is even' (not odd). Negated hypothesis: 'n is not prime OR n ≤ 2' (by De Morgan on 'prime AND >2'). So: if n is even, then n is not prime or n ≤ 2.
Section
Section 2
Concept
In a proof by contradiction, you assume the statement is false, then reason until you hit an impossibility. Since a true premise cannot lead to nonsense, your assumption must have been wrong — so the statement is true.
\[ \text{Assume } \lnot S \ \longrightarrow\ \text{contradiction} \ \Rightarrow\ S \]
It is powerful for proving something does not exist, or that a number is irrational — claims with no obvious thing to build directly.
Intuition
A contradiction proof is a trap you set. You let the enemy in — assume the statement is false — and then show that this assumption cannot survive in a consistent world.
The moment you derive two things that cannot both be true, the trap springs: the only loose thread was your assumption, so it snaps. The statement stands proven.
Hypothesis
Predict first
Contradiction: the square root of 2 is irrational is about to be worked. State your hypothesis first: which rule or definition decides this one, and what is the first move it forces? Then watch whether the example agrees with you.
Correct: Assume the opposite, in lowest terms
Why: Suppose root 2 IS rational. Then it equals a fraction reduced so the numerator and denominator share no common factor.
A hypothesis you wrote down is falsifiable; a vague sense of how it will go is not. If the example opens somewhere else, that gap is the thing worth chasing.
Worked example
Claim: root 2 cannot be written as a fraction of integers.
Assume the opposite, in lowest terms
Why: Suppose root 2 IS rational. Then it equals a fraction reduced so the numerator and denominator share no common factor.
\[ \sqrt{2} = \frac{a}{b}, \quad \gcd(a,b)=1 \]
Square and clear the denominator
Why: Squaring both sides and multiplying up shows a squared is even, so (by Section 1's result) a itself is even; write a = 2c.
\[ a^2 = 2b^2 \Rightarrow a \text{ even},\ a = 2c \]
Substitute back and find b is even too
Why: Replacing a with 2c gives 4c² = 2b², so b² = 2c², making b even as well.
\[ 4c^2 = 2b^2 \Rightarrow b^2 = 2c^2 \Rightarrow b \text{ even} \]
Verify the contradiction
Why: Both a and b are even, so 2 divides both — contradicting the assumption that the fraction was in lowest terms. The assumption collapses, so root 2 is irrational.
\[ 2 \mid a,\ 2 \mid b \ \Rightarrow\ \gcd(a,b)\geq 2\ \text{(contradiction)}\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Contradiction: the square root of 2 is irrational", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Both a and b are even, so 2 divides both — contradicting the assumption that the fraction was in lowest terms. The assumption collapses, so root 2 is irrational.
Step zero
Discussion prompt
Contradiction: there are infinitely many primes — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Assume only finitely many primes exist
Answer:
Worked example
Euclid's argument: assume the primes run out, then manufacture one you missed.
Assume only finitely many primes exist
Why: Suppose the complete list is p₁ through p_k, with nothing prime beyond them.
\[ p_1, p_2, \ldots, p_k \ (\text{all primes}) \]
Build one more number
Why: Multiply them all and add 1. This number leaves remainder 1 when divided by any prime on the list.
\[ N = p_1 p_2 \cdots p_k + 1 \]
N has a prime factor not on the list
Why: N is bigger than 1, so it has some prime divisor. But no listed prime divides N (each leaves remainder 1), so that divisor is a new prime.
\[ p_i \nmid N \ \text{for all } i \ \Rightarrow\ \exists\, \text{new prime} \]
Verify the contradiction
Why: We assumed the list was complete, yet produced a prime outside it. Impossible — so the primes cannot be finite. Concretely, 2·3·5·7·11·13 + 1 = 30031 = 59 × 509, exposing new primes.
\[ 2\cdot3\cdot5\cdot7\cdot11\cdot13 + 1 = 30031 = 59 \times 509\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Contradiction: there are infinitely many primes", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: We assumed the list was complete, yet produced a prime outside it. Impossible — so the primes cannot be finite. Concretely, 2·3·5·7·11·13 + 1 = 30031 = 59 × 509, exposing new primes.
Anomaly
Predict first
A student writes this, and it looks reasonable:
To prove by contradiction that 'every integer in the set is even', a student assumes 'every integer in the set is odd'.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: Wrongly negates a 'for all' as another 'for all'.
Negating a quantifier flips it: 'for all' becomes 'there exists', and the inside is negated.
Why: Wrongly negates a 'for all' as another 'for all'. The negation of 'every x is even' is 'SOME x is odd', not 'every x is odd'.
Trap
To prove by contradiction that 'every integer in the set is even', a student assumes 'every integer in the set is odd'.
\[ \text{Claim: } \forall x \in S,\ x \text{ even} \]
Assume 'all are odd'
Why: Wrongly negates a 'for all' as another 'for all'. The negation of 'every x is even' is 'SOME x is odd', not 'every x is odd'.
\[ \lnot(\forall x,\ P(x)) \neq \forall x,\ \lnot P(x) \]
Negating a quantifier flips it: 'for all' becomes 'there exists', and the inside is negated.
\[ \lnot(\forall x,\ P(x)) \equiv \exists x,\ \lnot P(x) \]
Assume 'some element is odd'
Why: The correct negation posits at least one odd element in S. You then derive a contradiction from that single witness.
\[ \text{Assume } \exists x \in S,\ x \text{ odd} \]
Also flip 'there exists' the same way
Why: Symmetrically, the negation of 'some x is even' is 'every x is odd'. Get the quantifier right before the proof even starts.
\[ \lnot(\exists x,\ P(x)) \equiv \forall x,\ \lnot P(x) \]
Translation
\( \lnot(\exists x,\ P(x)) \equiv \forall x,\ \lnot P(x) \)
Draw it
Translate both ways. First write the expression above as a sentence with no symbols in it at all. Then cover it, and write your sentence back as notation. If the two versions disagree, the disagreement is the thing to fix.
Pattern
1. Write the exact negation of the claim
Why: Flip every quantifier carefully; a wrong negation dooms the whole proof.
2. Assume that negation is true
Why: Treat it as a real premise and reason with it exactly as you would any hypothesis.
3. Derive an impossibility
Why: Reach something that cannot hold — a number both even and odd, a list both complete and incomplete, 0 = 1.
4. Conclude the original claim
Why: A valid argument from a true premise cannot yield nonsense, so the negation was false and the claim is true.
Check
Suppose you want to prove the statement below by contradiction.
\[ \text{Every integer greater than 1 has a prime divisor.} \]
Check your understanding
What is the correct opening assumption?
Answer: A
Why: The claim is 'for every n > 1, n has a prime divisor'. Its negation flips the 'for all' to 'there exists' and negates the inside: 'there exists an n > 1 with no prime divisor'. That single witness is what you assume and then refute.
Section
Section 3
Concept
Mathematical induction proves a statement for every natural number using just two pieces: a base case and an inductive step.
\[ \big[P(0) \ \text{and}\ \forall k\,(P(k)\Rightarrow P(k+1))\big] \Rightarrow \forall n\,P(n) \]
The base case proves the smallest instance. The inductive step proves that truth at any k forces truth at k+1. Together they cover all of them.
Intuition
Picture an infinite line of dominoes. The base case is knocking over the first one. The inductive step is the guarantee that each domino, when it falls, topples the next.
With both facts in hand, every domino falls — no matter how far down the line. You never push them one by one; you prove the two facts and let them cascade.
Concept
In the inductive step you get to assume the statement holds at k — this assumption is the inductive hypothesis — and use it to prove the statement at k+1.
\[ \text{Assume } P(k). \quad \text{Show } P(k+1). \]
This is not circular. You are not assuming what you want for all n; you are assuming one rung to reach the next, which is exactly the domino guarantee.
Sorting
Sort into buckets
These are the pieces of Proof, Induction & Closures, out of order. Put each one back under the part of the lesson it belongs to.
Missing information
Discussion prompt
Prove the closed form for the sum of the first n positive integers.
What do you need to know — or decide — before the first line can be written? List everything the problem has to hand you.
Hint: Anything you would have to invent to get started is a thing the problem must supply.
Answer:
The left side is just 1; the formula gives 1 times 2 over 2, which is 1. They match, so the base holds.
Worked example
Prove the closed form for the sum of the first n positive integers.
\[ 1 + 2 + \cdots + n = \frac{n(n+1)}{2} \]
Base case n = 1
Why: The left side is just 1; the formula gives 1 times 2 over 2, which is 1. They match, so the base holds.
\[ \text{LHS}=1,\quad \frac{1(2)}{2}=1\ \checkmark \]
Inductive hypothesis: assume it holds at k
Why: Suppose the first k integers sum to the closed form. This is the rung we stand on.
\[ 1 + 2 + \cdots + k = \frac{k(k+1)}{2} \]
Inductive step: add k+1 to both sides
Why: The sum to k+1 is the sum to k plus the new term. Substitute the hypothesis, then combine over a common denominator.
\[ \frac{k(k+1)}{2} + (k+1) = \frac{(k+1)(k+2)}{2} \]
Verify the target form
Why: The result is the original formula with n replaced by k+1, so P(k) implies P(k+1). Base plus step gives the claim for all n. Spot-check n = 4: 1+2+3+4 = 10 = 4·5/2.
\[ 1+2+3+4 = 10 = \frac{4\cdot 5}{2}\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Induction: sum of 1 through n", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The result is the original formula with n replaced by k+1, so P(k) implies P(k+1). Base plus step gives the claim for all n. Spot-check n = 4: 1+2+3+4 = 10 = 4·5/2.
Fill the middle
Fill in the blanks
From Induction: sum of the first n odd numbers — finish the line. Write what belongs on the right of the equals sign before you look.
1 + 3 + 5 + \cdots + (2n-1) = n^2
Why: Producing the right-hand side unprompted is the difference between recognising this line and being able to use it. The first odd number is 1, and 1 squared is 1.
Worked example
Prove that the first n odd numbers add up to a perfect square.
\[ 1 + 3 + 5 + \cdots + (2n-1) = n^2 \]
Base case n = 1
Why: The first odd number is 1, and 1 squared is 1. The base holds.
\[ 1 = 1^2\ \checkmark \]
Assume the sum to k equals k squared
Why: Inductive hypothesis: the first k odd numbers sum to k squared.
\[ 1 + 3 + \cdots + (2k-1) = k^2 \]
Add the next odd number, 2k+1
Why: The next odd number after 2k−1 is 2k+1. Add it to both sides and recognize the perfect-square trinomial.
\[ k^2 + (2k+1) = (k+1)^2 \]
Verify the step closes
Why: The right side is (k+1) squared, exactly the formula at n = k+1. Check n = 3: 1+3+5 = 9 = 3². The cascade covers all n.
\[ 1+3+5 = 9 = 3^2\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Induction: sum of the first n odd numbers", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: The right side is (k+1) squared, exactly the formula at n = k+1. Check n = 3: 1+3+5 = 9 = 3². The cascade covers all n.
Anomaly
Predict first
A student writes this, and it looks reasonable:
A student proves only the inductive step and declares victory — and 'proves' a false formula.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: The step alone can be valid for a false statement: adding k+1 to both sides of the bogus formula also 'works'.
Always check the base. It is the first domino — without it, the chain never starts falling.
Why: The step alone can be valid for a false statement: adding k+1 to both sides of the bogus formula also 'works'. Without a true base, nothing is anchored.
Trap
A student proves only the inductive step and declares victory — and 'proves' a false formula.
\[ \text{Bogus claim: } 1 + 2 + \cdots + n = \frac{n(n+1)}{2} + 1 \]
Show only that P(k) ⇒ P(k+1)
Why: The step alone can be valid for a false statement: adding k+1 to both sides of the bogus formula also 'works'. Without a true base, nothing is anchored.
\[ \frac{k(k+1)}{2}+1 + (k+1) = \frac{(k+1)(k+2)}{2}+1 \]
Always check the base. It is the first domino — without it, the chain never starts falling.
\[ \text{Test } n=1 \text{ in the bogus formula} \]
The base case exposes the fraud
Why: At n = 1 the true sum is 1, but the bogus formula gives 1 + 1 = 2. The base fails, so the 'theorem' is false despite a valid step.
\[ \text{LHS}=1 \neq \frac{1(2)}{2}+1 = 2 \]
Both parts are mandatory
Why: A valid step with no base proves nothing; a base with no step proves only one case. Induction needs both links.
Break the constraint
Discussion prompt
The rule this trap just fixed:
At n = 1 the true sum is 1, but the bogus formula gives 1 + 1 = 2. The base fails, so the 'theorem' is false despite a valid step.
Now break it on purpose. Build a case that violates it and follow the consequences until something visibly fails. Where does the failure first show up — and would you have noticed it if you had not been looking?
Hint: The dangerous rules are the ones whose violation still produces an answer. If yours fails loudly, try to find one that fails quietly.
Answer:
The step alone can be valid for a false statement: adding k+1 to both sides of the bogus formula also 'works'. Without a true base, nothing is anchored.
Concept
Strong induction hands you a bigger hypothesis: to prove P(k+1), you may assume P is true for all values up to k, not just at k.
\[ \big[P(0),\ldots,P(k)\big] \Rightarrow P(k+1) \]
It is logically equivalent to ordinary induction, but far more convenient when the case at k+1 depends on some earlier case, not necessarily the one right before it.
Intuition
Ordinary induction lets each domino topple only the very next one. Strong induction lets the whole fallen row behind push the next domino — you may cite any earlier result.
You reach for it when k+1 breaks into smaller pieces of unpredictable size, like splitting a number into two smaller factors.
Ranking
Put in order
Put the moves of Strong induction: every integer ≥ 2 factors into primes into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. 2 is itself prime, so it is a (one-factor) product of primes.
Worked example
Prove that every integer of at least 2 is a product of primes.
\[ \forall n \geq 2:\ n \text{ is a product of primes} \]
Base case n = 2
Why: 2 is itself prime, so it is a (one-factor) product of primes. The base holds.
\[ 2 = 2 \ (\text{prime})\ \checkmark \]
Assume the claim for all values from 2 up to k
Why: Strong hypothesis: every integer between 2 and k inclusive is a product of primes.
Split k+1 into cases
Why: If k+1 is prime, it is already a product of primes. If not, it factors as a·b with both factors strictly between 1 and k+1.
\[ k+1 = a \cdot b, \quad 2 \leq a,b \leq k \]
Verify by combining the smaller factorizations
Why: Both a and b fall in the range the strong hypothesis covers, so each is a product of primes; concatenating those gives one for k+1. Check 12 = 2·6 = 2·(2·3), all prime.
\[ 12 = 2 \cdot 6 = 2 \cdot 2 \cdot 3\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Strong induction: every integer ≥ 2 factors into primes", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Both a and b fall in the range the strong hypothesis covers, so each is a product of primes; concatenating those gives one for k+1. Check 12 = 2·6 = 2·(2·3), all prime.
Estimation
Predict first
Induction proves inequalities too. Show that two to the n exceeds n for every positive integer n.
Commit before you compute: what does Induction with an inequality: 2ⁿ > n come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify the step and an instance
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. So two to the k+1 exceeds k+1, closing the step.
Worked example
Induction proves inequalities too. Show that two to the n exceeds n for every positive integer n.
\[ 2^{n} > n \quad (n \geq 1) \]
Base case n = 1
Why: Two to the first power is 2, which is greater than 1. The base holds.
\[ 2^{1} = 2 > 1\ \checkmark \]
Assume it holds at k
Why: Inductive hypothesis: two to the k is greater than k.
\[ 2^{k} > k \]
Double both sides and bound below
Why: Doubling the hypothesis gives 2 to the k+1 greater than 2k, and for a positive integer k, 2k is at least k+1.
\[ 2^{k+1} = 2\cdot 2^{k} > 2k \geq k+1 \]
Verify the step and an instance
Why: So two to the k+1 exceeds k+1, closing the step. Check n = 4: 2 to the 4 is 16, well above 4.
\[ 2^{4} = 16 > 4\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Induction with an inequality: 2ⁿ > n", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: So two to the k+1 exceeds k+1, closing the step. Check n = 4: 2 to the 4 is 16, well above 4.
Pattern
1. State P(n) precisely
Why: Name exactly the statement you claim for each n; vagueness here causes every later error.
2. Prove the base case
Why: Verify P at the smallest value directly. Never skip it.
3. Assume P(k) (or all of P(0)..P(k) for strong)
Why: Write the inductive hypothesis explicitly so you can point to where you use it.
4. Derive P(k+1), using the hypothesis
Why: Build the next case out of the assumed one; the place you invoke the hypothesis is the heart of the proof.
Elimination
Eliminate the wrong options
In the inductive step, what are you allowed to assume and what must you prove?
3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.
Survives elimination: A
Why: Ordinary induction's step assumes the statement at k (the inductive hypothesis) and uses it to establish the statement at k+1. That single implication, plus the base case, makes the chain fall for every n.
Check
You are proving by ordinary induction that a formula holds for every positive integer.
Check your understanding
In the inductive step, what are you allowed to assume and what must you prove?
Answer: A
Why: Ordinary induction's step assumes the statement at k (the inductive hypothesis) and uses it to establish the statement at k+1. That single implication, plus the base case, makes the chain fall for every n.
Section
Section 4
Concept
The well-ordering principle says every non-empty set of natural numbers has a least element. Simple to state, surprisingly sharp as a tool.
\[ \varnothing \neq S \subseteq \mathbb{N} \Rightarrow S \text{ has a smallest element} \]
It is logically equivalent to induction. Proofs often use it by considering a smallest counterexample and showing it cannot exist.
Intuition
The naturals cannot descend forever. Any non-empty collection of them, however scattered, has a definite bottom rung you can point to.
That is exactly why 'take the smallest bad case' is a legal move: if bad cases existed, there would be a least one, and forcing a contradiction from it kills them all.
Step zero
Discussion prompt
Well-ordering: every n ≥ 2 has a prime divisor — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Let d be the smallest divisor of n above 1
Answer:
Worked example
Prove it using a smallest-counterexample argument.
\[ \forall n \geq 2:\ n \text{ has a prime divisor} \]
Let d be the smallest divisor of n above 1
Why: The set of divisors of n that exceed 1 is non-empty (n itself is in it), so by well-ordering it has a least element d.
\[ d = \min\{\, m > 1 : m \mid n \,\} \]
Argue d must be prime
Why: If d had a divisor e with 1 < e < d, then e would also divide n and be smaller than d — contradicting d's minimality.
\[ e \mid d,\ 1 < e < d \Rightarrow e \mid n \ (\text{contradiction}) \]
Verify the conclusion
Why: So d has no divisor strictly between 1 and itself: d is prime, and it divides n. Check n = 15: smallest divisor above 1 is 3, which is prime and divides 15.
\[ n=15:\ d = 3 \text{ (prime)},\ 3 \mid 15\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Well-ordering: every n ≥ 2 has a prime divisor", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: So d has no divisor strictly between 1 and itself: d is prime, and it divides n. Check n = 15: smallest divisor above 1 is 3, which is prime and divides 15.
Concept
The pigeonhole principle: if you put more objects into fewer boxes, some box holds at least two objects. Obvious — yet it proves things nothing else easily can.
\[ n \text{ items into } m \text{ boxes},\ n > m \Rightarrow \text{some box has} \geq 2 \]
The whole skill is naming the pigeons and the holes so that 'two in one hole' means exactly what you want to prove.
Intuition
Thirteen letters, twelve mailboxes: no matter how you distribute them, one box gets a second letter. There is nowhere else for it to go.
The trick in every application is the translation — decide what the letters are (people, numbers) and what the boxes are (months, remainders), and the collision writes your conclusion.
Missing information
Discussion prompt
Claim: in any group of 13 people, at least two were born in the same month.
What do you need to know — or decide — before the first line can be written? List everything the problem has to hand you.
Hint: Anything you would have to invent to get started is a thing the problem must supply.
Answer:
Pigeons are the 13 people; holes are the 12 months. Each person maps to their birth month.
Worked example
Claim: in any group of 13 people, at least two were born in the same month.
Name the pigeons and the holes
Why: Pigeons are the 13 people; holes are the 12 months. Each person maps to their birth month.
\[ \text{pigeons} = 13 \text{ people}, \quad \text{holes} = 12 \text{ months} \]
Apply the principle
Why: Since 13 pigeons exceed 12 holes, some hole receives at least two pigeons — some month is the birth month of two people.
\[ 13 > 12 \Rightarrow \text{some month has} \geq 2 \text{ people} \]
Verify the boundary is tight
Why: With only 12 people you could give each a distinct month, so 13 is the smallest count that forces a shared month. The bound is exactly right.
\[ 12 \text{ people} \to \text{possibly all distinct}; \ 13 \to \text{forced}\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Pigeonhole: two of 13 people share a birth month", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: With only 12 people you could give each a distinct month, so 13 is the smallest count that forces a shared month. The bound is exactly right.
Concept
The principle sharpens: with n objects in m boxes, some box must hold at least the ceiling of n over m. The plain version is just the case where that ceiling is 2.
\[ \text{some box holds} \geq \left\lceil \tfrac{n}{m} \right\rceil \text{ objects} \]
The reasoning is the same: if every box held fewer than that, the boxes together could not account for all n objects.
Estimation
Predict first
Claim: among 100 people, some birth month is shared by at least nine of them.
Commit before you compute: what does Generalized pigeonhole: a busy month come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.
Correct: Verify the bound is forced
Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. If every month had at most 8 people, the total would be at most 12 times 8 = 96, short of 100.
Worked example
Claim: among 100 people, some birth month is shared by at least nine of them.
Set pigeons and holes
Why: 100 people are the pigeons; the 12 months are the holes. Each person lands in their birth month.
\[ n = 100 \text{ people}, \quad m = 12 \text{ months} \]
Apply the ceiling bound
Why: The generalized principle guarantees some month holds at least the ceiling of 100 divided by 12.
\[ \left\lceil \tfrac{100}{12} \right\rceil = \lceil 8.33\ldots \rceil = 9 \]
Verify the bound is forced
Why: If every month had at most 8 people, the total would be at most 12 times 8 = 96, short of 100. So some month must reach 9 — the bound cannot be dodged.
\[ 12 \times 8 = 96 < 100 \Rightarrow \text{some month} \geq 9\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Generalized pigeonhole: a busy month", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: If every month had at most 8 people, the total would be at most 12 times 8 = 96, short of 100. So some month must reach 9 — the bound cannot be dodged.
Anomaly
Predict first
A student writes this, and it looks reasonable:
To show two of five integers share a remainder mod 4, a student makes the remainders the pigeons.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: Backwards. With 4 pigeons and 5 holes, nothing is forced — you can place 4 items in 5 boxes with room to spare.
The things you have MANY of are pigeons; the categories they fall into are holes.
Why: Backwards. With 4 pigeons and 5 holes, nothing is forced — you can place 4 items in 5 boxes with room to spare. The conclusion evaporates.
Trap
To show two of five integers share a remainder mod 4, a student makes the remainders the pigeons.
\[ \text{5 integers, remainders mod } 4 \]
Call the 4 remainders pigeons, the 5 numbers holes
Why: Backwards. With 4 pigeons and 5 holes, nothing is forced — you can place 4 items in 5 boxes with room to spare. The conclusion evaporates.
\[ 4 \text{ pigeons} < 5 \text{ holes} \Rightarrow \text{no collision forced} \]
The things you have MANY of are pigeons; the categories they fall into are holes.
\[ \text{5 integers, remainders } \{0,1,2,3\} \]
5 numbers are pigeons; 4 remainders are holes
Why: You want two numbers alike, so numbers are pigeons and their possible remainders are the holes.
\[ \text{pigeons}=5, \quad \text{holes}=4 \]
Now the collision is exactly the goal
Why: 5 numbers into 4 remainder-classes forces two numbers into the same class — two integers with the same remainder mod 4, which is what we wanted.
\[ 5 > 4 \Rightarrow \text{two share a remainder}\ \checkmark \]
Notation
Annotate
From Trap: mixing up pigeons and holes — read this one piece at a time. What is each part doing?
On: \( 5 > 4 \Rightarrow \text{two share a remainder}\ \checkmark \)
Pattern
1. Identify what you want two of
Why: The objects you want to collide are the pigeons — usually the larger, more numerous set.
2. Choose holes so that 'same hole' means your goal
Why: Design the boxes so two pigeons sharing one says exactly the statement to prove.
3. Count and compare
Why: Confirm pigeons outnumber holes. Then the principle forces the collision automatically.
Elimination
Eliminate the wrong options
What is the smallest number of integers that guarantees two share the same remainder mod 3?
3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.
Survives elimination: A
Why: There are exactly 3 possible remainders (0, 1, 2) — these are the holes. To force two integers into the same remainder class you need more pigeons than holes: 3 + 1 = 4 integers guarantees a repeat.
Check
Every integer leaves a remainder of 0, 1, or 2 when divided by 3.
Check your understanding
What is the smallest number of integers that guarantees two share the same remainder mod 3?
Answer: A
Why: There are exactly 3 possible remainders (0, 1, 2) — these are the holes. To force two integers into the same remainder class you need more pigeons than holes: 3 + 1 = 4 integers guarantees a repeat.
Section
Section 5
Concept
A recursive definition builds a set (or function) from a basis — the starting atoms — and a recursive rule that makes new members from old ones.
Example: the non-negative even numbers. Basis: 0 is even. Rule: if x is even, so is x + 2. Nothing else is even.
\[ 0 \in E; \qquad x \in E \Rightarrow x + 2 \in E \]
Intuition
A recursive definition is a factory: it stocks a few raw parts (the basis) and gives one rule for assembling new parts from parts you already have. Repeatedly apply the rule and the whole set appears.
This is how we will define strings, expressions, and grammars — and because the objects are built in steps, induction is the natural way to prove things about them.
Step zero
Discussion prompt
Build a member from a recursive definition — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.
Hint: It starts with: Start from the basis
Answer:
Worked example
Using the even-number definition, show that 6 is even by construction.
\[ 0 \in E; \quad x \in E \Rightarrow x+2 \in E \]
Start from the basis
Why: 0 is in E by the basis clause — the only member we get for free.
\[ 0 \in E \]
Apply the rule three times
Why: Each application adds 2 to a known member: 0 gives 2, 2 gives 4, 4 gives 6.
\[ 0 \to 2 \to 4 \to 6 \]
Verify 6 belongs
Why: 6 was produced by a finite chain of legal steps from the basis, so it is in E. And 6 is indeed two times 3, an even number — consistent.
\[ 6 = 2 \cdot 3 \in E\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Build a member from a recursive definition", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: 6 was produced by a finite chain of legal steps from the basis, so it is in E. And 6 is indeed two times 3, an even number — consistent.
Concept
When a set is defined recursively, you prove properties of its members by structural induction — the same idea as ordinary induction, matched to the construction.
Prove the property holds for the basis objects, then prove the recursive rule preserves it. Every member is built by finitely many rule applications, so the property propagates to all of them.
\[ P(\text{basis}) \ \text{and}\ \big[P(x) \Rightarrow P(\text{rule}(x))\big] \Rightarrow \forall x\, P(x) \]
Concept
The closure of a relation with respect to a property is the smallest relation that contains it and has that property. You add exactly the pairs you are forced to, and no more.
Three closures matter most, one per property from Lesson 1: reflexive, symmetric, and transitive.
\[ R \subseteq \text{closure}(R), \quad \text{closure}(R) \text{ minimal with the property} \]
Explain it
Discussion prompt
Explain Closure of a relation to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.
Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.
Answer:
The closure of a relation with respect to a property is the smallest relation that contains it and has that property. You add exactly the pairs you are forced to, and no more.
Concept
The reflexive closure throws in every missing self-loop — the identity pairs — and stops.
\[ r(R) = R \cup \{\,(a,a) : a \in A\,\} \]
The symmetric closure adds the reverse of every pair already present — the inverse relation.
\[ s(R) = R \cup R^{-1}, \quad R^{-1} = \{(b,a):(a,b)\in R\} \]
Analogy
Discussion prompt
Explain Reflexive and symmetric closure by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.
Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.
Answer:
The reflexive closure throws in every missing self-loop — the identity pairs — and stops.
Concept
The transitive closure adds a direct pair for every path of any length in the relation — reachability, not just one-step neighbors.
\[ R^{+} = R \cup R^2 \cup R^3 \cup \cdots = \bigcup_{i \geq 1} R^{i} \]
On a set of size n you never need powers beyond n: any path can be shortened to length at most n, so the union stops there.
\[ R^{+} = \bigcup_{i=1}^{n} R^{i} \quad (|A| = n) \]
Counterexample
Discussion prompt
The transitive closure adds a direct pair for every path of any length in the relation — reachability, not just one-step neighbors.
That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.
Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.
Answer:
On a set of size n you never need powers beyond n: any path can be shortened to length at most n, so the union stops there.
Ranking
Put in order
Put the moves of Compute a transitive closure into the order they have to happen.
Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. R squared holds the pairs reachable in exactly two hops: 1 to 3 (via 2) and 2 to 4 (via 3).
Worked example
Find the transitive closure of the chain relation below.
\[ A=\{1,2,3,4\},\ R=\{(1,2),(2,3),(3,4)\} \]
Compose R with itself for two-step paths
Why: R squared holds the pairs reachable in exactly two hops: 1 to 3 (via 2) and 2 to 4 (via 3).
\[ R^2 = \{(1,3),(2,4)\} \]
Take three-step paths
Why: R cubed holds the one three-hop path, 1 to 4 (via 2 then 3). R to the fourth is empty — no longer paths exist.
\[ R^3 = \{(1,4)\}, \quad R^4 = \varnothing \]
Union all the powers
Why: Combine R, R squared, and R cubed to get every reachable pair.
\[ R^{+} = \{(1,2),(2,3),(3,4),(1,3),(2,4),(1,4)\} \]
Verify the result is transitive
Why: Check a sample chain: (1,2) and (2,4) are present and so is the shortcut (1,4). Every two-step path in the result has its shortcut, so it is transitive — and minimal, since each added pair came from a real path.
\[ (1,2),(2,4)\in R^{+} \Rightarrow (1,4)\in R^{+}\ \checkmark \]
Picture it
Animation
Shows: Each line of the worked example "Compute a transitive closure", appearing one at a time.
The same working the example does, in the order a tutor would write it.
Takeaway: Check a sample chain: (1,2) and (2,4) are present and so is the shortcut (1,4). Every two-step path in the result has its shortcut, so it is transitive — and minimal, since each added pair came from a real path.
Anomaly
Predict first
A student writes this, and it looks reasonable:
A student adds only the two-step shortcuts once and calls it the transitive closure.
It is wrong. Say what breaks — and say it before you turn the page.
Correct: Adding just the two-hop pairs misses longer paths.
Keep adding shortcuts until nothing new appears — close over ALL path lengths.
Why: Adding just the two-hop pairs misses longer paths. The pair (1,4) needs three hops, so a single round of shortcuts never creates it.
Trap
A student adds only the two-step shortcuts once and calls it the transitive closure.
\[ R=\{(1,2),(2,3),(3,4)\} \]
Add R² only, then stop
Why: Adding just the two-hop pairs misses longer paths. The pair (1,4) needs three hops, so a single round of shortcuts never creates it.
\[ R \cup R^2 = \{(1,2),(2,3),(3,4),(1,3),(2,4)\}\ \text{— missing }(1,4) \]
Keep adding shortcuts until nothing new appears — close over ALL path lengths.
\[ R^{+} = \bigcup_{i \geq 1} R^{i} \]
Iterate to a fixed point
Why: After adding R², the new pair (1,3) combines with (3,4) to force (1,4). Repeat until a full pass adds nothing; only then is it transitive.
\[ (1,3)\ \&\ (3,4) \Rightarrow (1,4) \]
The complete closure
Why: Now every path, of every length, has its direct pair. This is the smallest transitive relation containing R.
\[ R^{+} = \{(1,2),(2,3),(3,4),(1,3),(2,4),(1,4)\} \]
Two truths and a lie
Sort into buckets
Some of these hold up and some are the exact mistakes this lesson is built to prevent. Sort them.
Pattern
1. Reflexive: add all identity pairs
Why: Union in (a,a) for every element of the set — one pass, done.
2. Symmetric: add every reverse pair
Why: Union in R inverse; for each (a,b) present, ensure (b,a) is too — one pass, done.
3. Transitive: union the powers until stable
Why: Keep composing and unioning until a full pass adds no new pair — the fixed point is the transitive closure.
4. Minimality check
Why: Every pair you added should trace to a forced requirement (an identity, a reverse, or a path). If not, you added too much.
Real world
Discussion prompt
Outside this lesson: where does Proof, Induction & Closures actually turn up? Name one concrete situation — a job, a piece of software someone ships, a decision somebody has to make — and say which part of Computing any closure is doing the work in it.
Hint: Vague is the failure mode here. "Engineering" is not a situation; "deciding whether this build is fast enough to ship" is.
Answer:
Lesson 2 of the math toolkit: what a proof is, direct proof and the contrapositive, proof by contradiction (irrationality of root 2, infinitude of primes), weak and strong mathematical induction, the well-ordering principle, the pigeonhole principle, recursive definitions, and computing the reflexive/symmetric/transitive closures of a relation. Targets converse-vs-contrapositive confusion, the missing base case, and the one-round transitive-closure error.
Check
Consider this relation on a three-element set.
\[ A=\{1,2,3\},\ R=\{(1,2),(2,3)\} \]
Check your understanding
What is the transitive closure R⁺?
Answer: A
Why: There is a two-step path 1 → 2 → 3, so transitivity forces the shortcut (1,3). No other paths exist, so the closure is the original two pairs plus (1,3).
Connect it up
Draw it
One page, no notation unless you need it: draw how these connect — Direct Proof & the Contrapositive · Proof by Contradiction · Mathematical Induction · Well-Ordering & Pigeonhole · Recursive Definitions & Closures. Put an arrow wherever one of them is what makes another possible, and label the arrow with why.
Recap
You now hold the proof toolkit the rest of the course assumes at every turn.
| Technique | The one move |
|---|---|
| Contrapositive | Flip AND negate both parts |
| Contradiction | Assume the negation; reach nonsense |
| Induction | Base case, then P(k) ⇒ P(k+1) |
| Transitive closure | Union powers until nothing new |
Want this taught 1-on-1? Alexander tutors Theory of Computation — $55/session, free consultation.