CMP-250 · Lesson 6 of 12 · 35 min
Proof techniques II: contradiction, cases and existence
Direct proof and the contrapositive handle many theorems, but some statements resist them. This lesson adds three more tools. Proof by contradiction shows that assuming a statement is false leads to an impossibility. Proof by cases splits a problem into parts that are each easier. Existence and uniqueness proofs show that an object exists, sometimes by building it and sometimes without ever finding it, and that there is only one. Two famous theorems, the irrationality of \(\sqrt{2}\) and the infinitude of the primes, show contradiction at its best.
Proof by contradiction
To prove a statement \(S\) by contradiction, assume \(\neg S\) and derive a contradiction: a statement of the form \(R \wedge \neg R\), which can never be true. Since a true assumption cannot lead to a false conclusion by valid steps, the assumption \(\neg S\) must be false, so \(S\) is true. In symbols, \((\neg S \to F) \equiv S\), which you can check with a two-row truth table.
Contradiction is especially useful for statements that say something does not exist or that a quantity is not of some form: there is no largest prime, \(\sqrt{2}\) is not rational, no algorithm solves every instance of some problem. Negating such a statement gives you something concrete to work with: a largest prime, a fraction equal to \(\sqrt{2}\), an algorithm.
Worked problem
The square root of 2 is irrational
Prove that √2 is not a rational number.
Show solution
- Assume, for contradiction, that √2 is rational. Then √2 = a/b for integers a and b with b ≠ 0, and we may choose the fraction in lowest terms, so a and b have no common factor greater than 1.
- Squaring gives 2 = a²/b², so a² = 2b². Hence a² is even.
- By the result of lesson 5 (if n² is even then n is even), a is even: a = 2c for some integer c.
- Substitute: (2c)² = 2b², so 4c² = 2b² and b² = 2c². Hence b² is even, so b is even.
- Now a and b are both even, so 2 is a common factor, contradicting lowest terms.
- The assumption was false, so √2 is irrational.
Answer: √2 is irrational. The contradiction is between "a and b have no common factor" and "a and b are both even".
This proof, known to the ancient Greeks, is one of the oldest in mathematics. Look closely at its structure. The assumption gave us concrete integers \(a\) and \(b\). The extra condition, lowest terms, was free to impose because every fraction can be reduced, and it became the statement that was contradicted. Many contradiction proofs work this way: assume a smallest, largest or simplest counterexample, then produce a smaller, larger or simpler one.
Worked problem
There are infinitely many primes
Prove that there is no largest prime number.
Show solution
- Assume, for contradiction, that there are only finitely many primes, p₁, p₂, ..., pₙ.
- Let N = p₁ × p₂ × ... × pₙ + 1.
- N > 1, so N has at least one prime factor q (every integer greater than 1 is a product of primes).
- q must be one of the pᵢ, since the list contains every prime. Then q divides the product p₁ ⋯ pₙ.
- q also divides N. So q divides N − p₁ ⋯ pₙ = 1. But no prime divides 1. Contradiction.
- Therefore there are infinitely many primes.
Answer: Infinitely many primes exist. This is Euclid's proof, about 2,300 years old.
A common misreading of Euclid's proof is that \(N\) itself must be prime. It need not be: \(2 \times 3 \times 5 \times 7 \times 11 \times 13 + 1 = 30031 = 59 \times 509\). What the proof shows is that \(N\) has a prime factor not in the list. Python can check both the claim and the misreading.
def smallest_factor(n):
d = 2
while d * d <= n:
if n % d == 0:
return d
d += 1
return n
primes = [2, 3, 5, 7, 11, 13]
prod = 1
for i, p in enumerate(primes):
prod *= p
N = prod + 1
f = smallest_factor(N)
status = "prime" if f == N else f"composite, factor {f}"
print(f"product of first {i+1} primes + 1 = {N:6d}: {status}; new prime factor {f} not in list: {f not in primes[:i+1]}")product of first 1 primes + 1 = 3: prime; new prime factor 3 not in list: True product of first 2 primes + 1 = 7: prime; new prime factor 7 not in list: True product of first 3 primes + 1 = 31: prime; new prime factor 31 not in list: True product of first 4 primes + 1 = 211: prime; new prime factor 211 not in list: True product of first 5 primes + 1 = 2311: prime; new prime factor 2311 not in list: True product of first 6 primes + 1 = 30031: composite, factor 59; new prime factor 59 not in list: True
Contradiction versus contrapositive
Proof by contrapositive and proof by contradiction look similar, since both begin by assuming something is false. The difference is in what you aim for. In a contrapositive proof of \(P \to Q\), you assume \(\neg Q\) and aim specifically for \(\neg P\). In a contradiction proof of \(P \to Q\), you assume both \(P\) and \(\neg Q\) and aim for any contradiction at all. Contradiction is more flexible, because any impossibility will do; contrapositive is more focused and often clearer. If a contradiction proof ends by contradicting the hypothesis \(P\), it can usually be rewritten as a cleaner contrapositive proof.
| Method | To prove P → Q, assume | Then derive | Best when |
|---|---|---|---|
| Direct | P | Q | P gives a concrete form |
| Contrapositive | ¬Q | ¬P | ¬Q gives a concrete form |
| Contradiction | P and ¬Q | any contradiction R ∧ ¬R | The conclusion says something does not exist or is not of a form |
| Cases | P, split into cases | Q in every case | The objects fall naturally into a few kinds |
Proof by cases
Sometimes a hypothesis naturally splits into several situations, and each is easier to handle on its own. If \(P \equiv P_1 \vee P_2 \vee \cdots \vee P_k\) and you prove \(P_i \to Q\) for every \(i\), then \(P \to Q\) follows. The cases must be exhaustive, meaning they cover every possibility; they do not have to be exclusive, though usually they are.
Worked problem
Cases on parity
Prove: for every integer n, n² + n is even.
Show solution
- Every integer is even or odd, so two cases cover everything.
- Case 1: n even, n = 2k. Then n² + n = 4k² + 2k = 2(2k² + k), which is even.
- Case 2: n odd, n = 2k + 1. Then n² + n = (4k² + 4k + 1) + (2k + 1) = 4k² + 6k + 2 = 2(2k² + 3k + 1), which is even.
- In both cases n² + n is even.
Answer: Proved by two exhaustive cases. A slicker proof notes n² + n = n(n + 1), a product of consecutive integers, one of which is even.
Worked problem
Cases on remainders
Prove: the square of any integer leaves remainder 0 or 1 when divided by 4.
Show solution
- Split by parity again. Case 1: n = 2k, so n² = 4k², remainder 0.
- Case 2: n = 2k + 1, so n² = 4k² + 4k + 1 = 4(k² + k) + 1, remainder 1.
- So n² mod 4 is always 0 or 1.
- Corollary: no integer of the form 4m + 3, such as 3, 7 or 11, is a perfect square.
Answer: n² mod 4 ∈ {0, 1}. This kind of argument is how many impossibility results in number theory are proved.
With a finite number of cases, a computer can check every case directly. This is called proof by exhaustion, and it is completely rigorous when the cases really are finite. A famous example is the Four Color Theorem: every map can be colored with four colors so that neighboring regions differ. Kenneth Appel and Wolfgang Haken proved it in 1976 by reducing it to 1,936 configurations checked by computer. A smaller example is checking a claim about remainders.
# Proof by exhaustion over remainders: n**2 mod 8 depends only on n mod 8,
# so checking the 8 residues proves the claim for every integer n.
squares = sorted({(r * r) % 8 for r in range(8)})
print("possible values of n^2 mod 8:", squares)
odd_squares = sorted({(r * r) % 8 for r in range(1, 8, 2)})
print("possible values of n^2 mod 8 for odd n:", odd_squares)possible values of n^2 mod 8: [0, 1, 4] possible values of n^2 mod 8 for odd n: [1]
This program is a proof, not just evidence, because of the argument in its comment: the remainder of \(n^2\) modulo 8 depends only on the remainder of \(n\) modulo 8, and there are only eight remainders. Lesson 11 explains why this holds. The general lesson is that a computer check proves a universal claim only when you can show the infinite domain reduces to finitely many cases.
Existence proofs
To prove \(\exists x\, P(x)\), the most satisfying method is a constructive proof: exhibit a specific \(x\), or give an algorithm that finds one, and verify \(P(x)\). A non-constructive proof shows that some \(x\) must exist without identifying which one, often by contradiction or by cases.
Worked problem
A non-constructive existence proof
Prove that there exist irrational numbers a and b such that a to the power b is rational.
Show solution
- Consider x = √2 raised to the power √2. Either x is rational or it is not.
- Case 1: x is rational. Then a = b = √2 works, since √2 is irrational.
- Case 2: x is irrational. Take a = x and b = √2. Then a to the b = √2 to the power (√2 × √2) = √2 squared = 2, which is rational.
- In either case suitable a and b exist.
Answer: Such a and b exist, though this proof does not tell us which case holds. (It is in fact known that √2 to the √2 is irrational, so case 2 applies.)
Computer scientists generally prefer constructive proofs because a construction is an algorithm. A proof that a schedule exists is useful; a proof that also builds the schedule is far more useful. Some mathematicians, the constructivists, accept only constructive existence proofs, and proof assistants based on constructive logic can extract working programs from proofs.
Uniqueness proofs
A uniqueness claim \(\exists! x\, P(x)\) has two parts. Existence: some \(x\) has property \(P\). Uniqueness: if \(x\) and \(y\) both have property \(P\), then \(x = y\). The uniqueness part is usually proved by assuming two objects with the property and showing they are equal.
Worked problem
Existence and uniqueness
Prove: for real numbers a ≠ 0 and b, the equation ax + b = 0 has exactly one solution.
Show solution
- Existence: x = −b/a works, since a(−b/a) + b = −b + b = 0.
- Uniqueness: suppose ax + b = 0 and ay + b = 0. Subtract: a(x − y) = 0.
- Since a ≠ 0, divide by a to get x − y = 0, so x = y.
- Both parts hold, so there is exactly one solution.
Answer: Exactly one solution, x = −b/a. The hypothesis a ≠ 0 was needed in both parts.
Common fallacies in proofs
Learning to spot errors is as important as learning to write proofs. The fake proofs below each contain a single flaw. Finding the flaw sharpens your sense of what a valid step requires.
| Fallacy | Example | What went wrong |
|---|---|---|
| Dividing by zero | a = b, so a² − b² = ab − b², so (a + b)(a − b) = b(a − b), so a + b = b, so 2 = 1 | Dividing by a − b, which is 0 |
| Assuming the conclusion | To prove x > 0, assume x > 0 and note that then x > 0 | Circular reasoning |
| Affirming the consequent | Primes greater than 2 are odd; 15 is odd; so 15 is prime | Invalid inference form |
| Hidden case | Prove |x| ≥ x only for x ≥ 0 | The negative case was skipped |
| Generalizing from examples | 1, 3, 5 and 7 are not divisible by 2, so no number is | Examples do not prove universals |
| Square-root sign slip | x² = 4 so x = 2 | Missed x = −2 |
Common mistakes
MistakeIn a contradiction proof, failing to say what is being assumed.
InsteadBegin with 'Assume, for contradiction, that ...' and state the negation precisely.
MistakeConcluding that Euclid's number p₁⋯pₙ + 1 is always prime.
InsteadIt has a prime factor outside the list; it may itself be composite, like 30031.
MistakeUsing cases that do not cover every possibility.
InsteadCheck that the cases are exhaustive, for example even or odd, positive, zero or negative.
MistakeTreating a computer check of many cases as proof of an infinite claim.
InsteadExhaustion proves a claim only when the domain is finite or provably reduces to finitely many cases.
MistakeProving existence but not uniqueness for an 'exactly one' claim.
InsteadProve both: something works, and any two things that work are equal.
MistakeDividing both sides by an expression that might be zero.
InsteadCheck that the divisor is non-zero, or split into cases.
Summary and key terms
- Proof by contradiction assumes ¬S, derives an impossibility, and concludes S.
- √2 is irrational and there are infinitely many primes: two classic contradiction proofs.
- Contrapositive aims for ¬P; contradiction aims for any contradiction.
- Proof by cases splits the hypothesis into exhaustive parts and proves each one.
- Proof by exhaustion is rigorous only when the cases are genuinely finite.
- Constructive existence proofs build the object; non-constructive proofs show it must exist.
- Uniqueness proofs assume two objects with the property and show they are equal.
- Proof by contradiction
- A proof that assumes the negation of the statement and derives a contradiction.
- Contradiction
- A statement of the form R ∧ ¬R, which is always false.
- Irrational number
- A real number that cannot be written as a ratio of integers.
- Proof by cases
- A proof that splits into exhaustive cases and proves the claim in each.
- Exhaustive cases
- Cases that together cover every possibility.
- Proof by exhaustion
- A proof that checks every one of finitely many cases.
- Constructive proof
- An existence proof that exhibits the object or an algorithm to find it.
- Non-constructive proof
- An existence proof that shows an object exists without identifying it.
- Uniqueness
- The property that at most one object satisfies a condition.
- Lowest terms
- A fraction whose numerator and denominator share no factor greater than 1.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Prove by contradiction that there is no largest even integer.
Show answer
If m were the largest, m + 2 would be an even integer larger than m.
Prove that √3 is irrational.
Show answer
Assume √3 = a/b in lowest terms; then a² = 3b², so 3 | a; write a = 3c to get b² = 3c², so 3 | b, contradiction.
Prove by cases: |xy| = |x||y| for real x, y.
Show answer
Consider the four sign cases of x and y; in each, both sides equal the product of the absolute values.
Show no perfect square ends in the digit 7.
Show answer
Squares of 0 to 9 end in 0, 1, 4, 9, 6, 5, 6, 9, 4, 1; the last digit of n² depends only on that of n.
Is 2 × 3 × 5 × 7 + 1 prime?
Show answer
Yes, 211 is prime; but the pattern does not continue forever, since 2 × 3 × 5 × 7 × 11 × 13 + 1 = 30031 = 59 × 509.
Give a constructive proof that there is an integer n with n² = 2n.
Show answer
n = 2 (or n = 0).
Prove the uniqueness of the additive identity: if a + z = a for every a, then z = 0.
Show answer
Take a = 0: 0 + z = 0, so z = 0.
Find the flaw: x² = x, so x = 1.
Show answer
Dividing by x ignores x = 0; the solutions are 0 and 1.
Prove that among any three integers, two have the same parity.
Show answer
There are only two parities; by cases (or the pigeonhole principle of lesson 8), two must match.
Why is 'assume ¬S and derive ¬P' a contrapositive proof rather than a contradiction proof?
Show answer
It targets ¬P specifically, proving ¬Q → ¬P with S being Q.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.