Mathematics for Computer Science 201-N11 • CEGEP, Montreal

Revision sheet: writing a mathematical proof (201-N11)

This revision sheet covers the proof techniques of Mathematics for Computer Science, 201-N11: direct proof, contrapositive, proof by contradiction, mathematical induction and the pigeonhole principle, the five structures the course outline prescribes by name. It does not redo the course, which you have in your class notes: it holds what costs marks on the exam, namely the diagnosis, choosing the structure before the first line, and the write-up the marker expects after that. It is written for CEGEP students in computer science programs; once it is read, the corrected exercise set on the same chapter puts every reflex to the test.

The thread: on this chapter, tests almost never lose marks on a computation, they lose them on the structure, and the same mistake comes back in five forms. Calling the converse the contrapositive. Believing that an example proves a universal statement. Announcing a contradiction and writing a contrapositive. Believing that induction proves the base case when it requires it. Making the pigeonhole principle say WHICH box is crowded. Each pitfall below gives the wrong sentence as it is written on a test, the right sentence to copy, and its cost on the marking scheme.

Mark this sheet as read or add it to your favourites: a free account, no password, keeps your read sheets and favourites from one visit to the next, tells you which chapter to tackle next and lets you ask for the method or exercise you are missing. Create your space, an email is enough.

The thread of the chapter

A proof is not a sequence of correct computations: it is a STRUCTURE chosen before the first line, and it is the FORM of the statement, never its subject, that tells you which one.

This chapter is part of 201-N11, Mathematics for Computer Science

The essentials

The five structures of the course outline, and what each one assumes

  • • Direct proof: assume PP, translate the hypothesis into something you can manipulate, arrive at QQ. It is the default choice when the hypothesis is RICH, that is, when it translates at once into an equation.
  • • Contrapositive: assume ¬Q\lnot Q ALONE and aim for exactly ¬P\lnot P. It exists only for an implication, and it is always equivalent to it.
  • • Contradiction: assume PP AND ¬Q\lnot Q, and aim for any contradiction. It also applies to statements that are not implications.
  • • Induction: base case at the first rank, THEN the inductive step from rank nn to rank n+1n+1. Reserved for statements INDEXED by an integer.
  • • Pigeonhole principle: n+1n+1 objects in nn boxes give a box with two objects; mm objects in nn boxes give one with ⌈m/n⌉\lceil m/n \rceil objects.
  • • Two tools that are not structures on their own: proof by cases, which splits the domain and whose list must be EXHAUSTIVE, and the counterexample, which disproves a universal statement without ever proving anything.

Naming the technique earns marks in its own right: “we prove the contrapositive”, “suppose, for the sake of contradiction, that”, “by the pigeonhole principle”. A sequence of correct computations without that sentence is not a written proof.

The square of the four implications

  • • From P⇒QP \Rightarrow Q four implications can be formed: the statement, the CONVERSE Q⇒PQ \Rightarrow P, the CONTRAPOSITIVE ¬Q⇒¬P\lnot Q \Rightarrow \lnot P, and ¬P⇒¬Q\lnot P \Rightarrow \lnot Q, the contrapositive of the converse, called the inverse.
  • • Only two columns coincide: the statement and its contrapositive. The converse differs from the statement on 2 of the 4 rows of the truth table, one row in two.
  • • The example to keep in mind: “nn divisible by 6 ⇒\Rightarrow nn divisible by 3” is true, so is its contrapositive, and its converse is false, as n=9n=9 shows.
  • • The negations to write without thinking: ¬(P⇒Q)=P∧¬Q\lnot(P \Rightarrow Q) = P \land \lnot Q, ¬(A∨B)=¬A∧¬B\lnot(A \lor B) = \lnot A \land \lnot B, ¬(A∧B)=¬A∨¬B\lnot(A \land B) = \lnot A \lor \lnot B.
(1) the statementP => Q(3) the contrapositivenot Q => not P(2) the converseQ => P(4) the inversenot P => not Qequivalentequivalentno link in truth value
On the left, the statement and its contrapositive ALWAYS have the same truth value. On the right, a second pair, independent of the first: moving from one column to the other means changing propositions.

Proving the contrapositive proves the statement. Proving the converse proves nothing about the statement: it is another proposition, with its own proof.

The pigeonhole principle, in both its forms

  • • Simple form: n+1n+1 objects placed in nn boxes give at least one box with two objects.
  • • Generalized form: mm objects in nn boxes give at least one box with ⌈m/n⌉\lceil m/n \rceil objects, the CEILING.
  • • The proof of both is the same, and it is worth knowing: negate the conclusion, the negation puts an UPPER BOUND on each box, add up the nn bounds and the total becomes too small.
  • • What the principle does NOT say: which box, or which objects. It is a NONCONSTRUCTIVE existence proof, just like a proof by cases that is left unsettled.
  • • The difficulty of a pigeonhole exercise is never the computation: it is deciding what plays the role of the boxes, that is, which characteristic takes only a small number of values.
⌈7/3⌉ = 37 objects, 3 boxes
If each box held at most 22 objects, it would take only 66: with 77 objects, at least one box receives ⌈7/3⌉=3\lceil 7/3\rceil=3, without our knowing which.

The pigeonhole principle gives a WORST-CASE certainty. A probability computation gives a frequency: with 23 people two birthdays coincide with more than a one-in-two chance, with 367 it is forced. The two registers neither contradict nor replace each other.

The mistakes that cost marks

These are the errors I correct most often in session. Each one costs marks on a paper, even when the reasoning behind it is right.

1. Starting to write before choosing the structure

the whole question: a page of correct computations that proves nothing is worth zero

What not to write

“Let us prove that if n3+5n^{3}+5 is odd, then nn is even. We have n3+5n^{3}+5 odd, so n3n^{3} is even, so n3=2kn^{3}=2k, so n×n×n=2kn \times n \times n = 2k, so...”

What to write

“The conclusion “nn is even” negates into “nn odd”, which is rich. We prove the contrapositive: if nn is odd, then n3+5n^{3}+5 is even. n=2k+1n=2k+1 makes n3n^{3} odd, and the sum of two odd numbers is even.”

Why: The hypothesis is about a CONSTRUCTED expression and the conclusion about the basic object: that is the signal for the contrapositive. Starting from the hypothesis keeps relaunching the same problem one step further along.

2. Calling the converse the contrapositive

the whole question, even when all the computation that follows is correct

What not to write

“We know that if nn is divisible by 6 then nn is divisible by 3. By contraposition, if nn is divisible by 3 then nn is divisible by 6.”

What to write

“By contraposition: if nn is not divisible by 3, then nn is not divisible by 6. The converse would be “divisible by 3 so by 6”, and it is false: n=9n=9 disproves it.”

divisible by 3divisible by 66129
The multiples of 66 lie inside the multiples of 33: the statement and its contrapositive hold; 99 (red), divisible by 33 and not by 66, disproves the converse.

Why: The contrapositive negates AND swaps, the converse only swaps. On the 4 rows of the truth table, the converse differs from the statement on 2: getting the form wrong is a one-in-two chance of reasoning about a false proposition.

3. Believing that an example, however well chosen, proves a universal statement

all the marks for the proof; there is no such thing as half a proof

What not to write

“3+5=83+5=8, 7+11=187+11=18 and 101+3=104101+3=104: so the sum of two odd integers is even.”

What to write

“Let n=2k+1n=2k+1 and m=2j+1m=2j+1 with kk and jj integers. Then n+m=2(k+j+1)n+m=2(k+j+1), which is 2 times an integer, so even.” The three equalities are only a check done before writing.

Why: A universal statement covers infinitely many cases and no finite list exhausts them. Fermat had checked five numbers, F0F_{0} to F4F_{4}, all prime, and F5=4,294,967,297=641×6,700,417F_{5}=4{,}294{,}967{,}297=641\times 6{,}700{,}417 is composite.

4. Announcing a contradiction and writing a contrapositive

1 to 2 marks for rigour, and the whole question if the marker looks for the announced contradiction

What not to write

“Let us prove that if 3n+23n+2 is odd then nn is odd. Suppose, for the sake of contradiction, that nn is even. Then 3n+2=2(3k+1)3n+2=2(3k+1) is even. Contradiction.”

What to write

“We prove the CONTRAPOSITIVE: if nn is even, then 3n+23n+2 is even. n=2kn=2k gives 3n+2=2(3k+1)3n+2=2(3k+1), so 3n+23n+2 is not odd. Since the contrapositive is equivalent to the statement, the statement is proved.”

CONTRAPOSITIVEassumenot Q, aloneaim forexactly not Pnothing false assumedCONTRADICTIONassumeP and not Qaim forany contradictionassumes a falsehood
On the left, you assume only one thing, ¬Q\lnot Q, and aim for exactly ¬P\lnot P: everything written is true. On the right, you assume TWO things, PP and ¬Q\lnot Q, and any contradiction ends the proof.

Why: The wrong test never assumed PP: without “3n+23n+2 is odd” among the assumptions, “3n+23n+2 is even” is not a contradiction, it is merely ¬P\lnot P. It was a correct contrapositive, wrongly labelled.

5. Negating an OR as if it were an OR

the whole question, and on top of that the student concludes that the statement is false

What not to write

“The conclusion is “x>31x>31 or y>31y>31”. Its negation is “x≤31x \leq 31 or y≤31y \leq 31”.”

What to write

“The negation of “AA or BB” is “¬A\lnot A AND ¬B\lnot B”: here “x≤31x \leq 31 and y≤31y \leq 31”, hence xy≤31×31=961≤1,000xy \leq 31 \times 31 = 961 \leq 1{,}000.”

102030405060102030405060x ≤ 31and y ≤ 31x > 31or y > 31xy
“x>31x>31 or y>31y>31” covers everything except the green square; its negation is that square, “x≤31x\leq 31 AND y≤31y\leq 31”.

Why: With the wrong “or”, the pair (10,200)(10, 200) satisfies the hypothesis and gives xy=2,000xy=2{,}000: the proof collapses on a counterexample that is not one. The negation goes on the first line of your scratch work, before any computation.

6. Forgetting to take the fraction in lowest terms before squaring

3 marks out of 5: the proof is fully written and proves nothing

What not to write

“Suppose 2=ab\sqrt{2}=\frac{a}{b}. Then a2=2b2a^{2}=2b^{2}, so aa is even, a=2ca=2c, then b2=2c2b^{2}=2c^{2}, so bb is even. Contradiction.”

What to write

“Suppose 2=ab\sqrt{2}=\frac{a}{b} with the fraction in LOWEST TERMS, which is always possible by simplifying. [...] aa and bb are both even, so both divisible by 2, which contradicts the lowest terms assumed at the start.”

Why: Without lowest terms, “aa and bb even” is not a contradiction but a commonplace: 42\frac{4}{2} and 84\frac{8}{4} are two perfectly legitimate ways of writing the same number. The contradiction must clash with an assumption that was STATED.

7. Believing that induction proves the base case

up to half the marks: the base case alone is typically worth 1 mark out of 4, and the conclusion “for all nn”, which rests on it, goes with it

What not to write

“The inductive step is established: if the property holds at rank nn, it holds at rank n+1n+1. So the property holds for all nn.”

What to write

“Base case: at rank 1, 1=1×221=\frac{1\times 2}{2}, the property holds. Inductive step: [...] Conclusion: by induction, the property holds for all n≥1n \geq 1.”

base case checkedthe property holds at every rankbase case forgottenthe inductive step alone proves nothingtrue?true?true?true?true?
At the top, a single rank checked by hand, and the chain carries the truth all the way. At the bottom, the same chain, intact, carries NOTHING: it only passes on what it is given, and it was given nothing.

Why: Induction does not establish the first rank, it REQUIRES it. The property “n=n+1n=n+1” passes from each rank to the next, since n=n+1n=n+1 implies n+1=n+2n+1=n+2, and it is false at every rank: the inductive step alone proves nothing.

8. Not saying where the induction hypothesis is used

1 to 2 marks: it is the line the marker looks for first in the inductive step

What not to write

“At rank n+1n+1: 1+2+⋯+(n+1)=(n+1)(n+2)21+2+\cdots+(n+1)=\frac{(n+1)(n+2)}{2}, which is indeed the property at rank n+1n+1.”

What to write

“1+2+⋯+n+(n+1)=n(n+1)2+(n+1)1+2+\cdots+n+(n+1) = \frac{n(n+1)}{2}+(n+1) BY THE INDUCTION HYPOTHESIS, then =(n+1)(n+2)2=\frac{(n+1)(n+2)}{2} after putting over a common denominator.”

Why: An inductive step that does not use the induction hypothesis proves rank n+1n+1 directly, in which case induction was unnecessary, or else, far more often, it is wrong and the student has written the conclusion in place of the reasoning.

9. Making the pigeonhole principle say WHICH box contains two objects

1 mark, and the whole next question if the reasoning relies on it

What not to write

“By the pigeonhole principle, the first folder contains at least 67 files.”

What to write

“By the pigeonhole principle, THERE IS a folder that contains at least ⌈2,000/30⌉=67\lceil 2{,}000/30 \rceil = 67 files. The principle does not say which one, and it gives no way of finding it.”

5 objects, 4 boxesarrangement 1arrangement 22 objects2 objects
Both arrangements have 5 objects for 4 boxes, and both have a box with two objects. It is not the same box: the principle guarantees that one exists, it never designates it.

Why: The pigeonhole principle proves an existence without constructing the object: the conclusion is “there exists”, never “it is this one”. That is exactly why a checksum collision is certain without being computable.

10. Taking the floor in the generalized form

1 mark every time, and it is the most mechanical mistake of the chapter

What not to write

“2,0002{,}000 files in 30 folders: one folder contains at least 2,000/30≈66.672{,}000/30 \approx 66.67 files, so 66.”

What to write

“At least one folder contains ⌈2,000/30⌉=67\lceil 2{,}000/30 \rceil = 67 files: the CEILING, because no folder contains 66.67 files.”

20 more files: some folder gets 6730 folders of 66: only 1,980 files
3030 folders of 6666 files hold only 1,9801{,}980: the remaining 2020 go somewhere, so some folder contains at least 67=⌈2000/30⌉67=\lceil 2000/30\rceil.

Why: If all 30 folders contained at most 66 files, the total would be at most 30×66=1,980<2,00030 \times 66 = 1{,}980 < 2{,}000: that is precisely the argument that proves the generalized form, and you can redo it in your head to check the rounding.

11. Handing in a circular proof that nevertheless reads very smoothly

the whole question, and it is the hardest mistake to see when proofreading

What not to write

“Since two sessions have the same ID, there are more sessions than IDs, so two sessions have the same ID.”

What to write

“There are 163=4,09616^{3}=4{,}096 possible IDs; there are 5,0005{,}000 sessions, so more of them; by the pigeonhole principle, at least two sessions carry the same ID.”

Why: Each sentence does follow from the previous one, and the first one is what had to be proved. The proofreading test is mechanical: does the conclusion appear anywhere BEFORE its justification?

12. Forgetting to conclude, or concluding on something other than the statement

1 mark for the conclusion, taken off systematically, on every proof question

What not to write

“... so aa and bb are both even.” And the test stops there.

What to write

“... so aa and bb are both even, which contradicts the fact that ab\frac{a}{b} is in lowest terms. The initial assumption is therefore impossible: 2\sqrt{2} is irrational.”

Why: A proof ends with the original statement, not with the last line of the computation. Finding the contradiction and stopping there hands in an unfinished question; concluding “so a collision” without coming back to the sessions of the statement does too.

Which method to choose

Which structure, from the FORM of the statement

Before the first line, two questions: what do we assume, what are we looking for? The branches can be recognized without having understood the mathematical content, solely from the form of the sentence.

  • If the hypothesis translates at once into an equation (n=2kn=2k, b=akb=ak) → direct proof: start from PP and compute until you reach the DEFINITION of QQ

    Example: if a∣ba \mid b and a∣ca \mid c, then a∣(bu+cv)a \mid (bu+cv), because bu+cv=a(ku+lv)bu+cv=a(ku+lv)

    a FRESH letter for each object you know nothing about: b=akb=ak and c=alc=al, never kk twice

  • If the conclusion is a negation, an OR, or is about nn while the hypothesis is about 3n+23n+2 → contrapositive: assume ¬Q\lnot Q and aim for ¬P\lnot P

    Example: if 3n+23n+2 is odd then nn is odd: start from n=2kn=2k

    the criterion is RICHNESS: prove starting from the richer of the two, the hypothesis or the negation of the conclusion

  • If the statement contains there is no, none, at most one, is unique, is irrational, is impossible → contradiction: assume PP AND ¬Q\lnot Q, and look for any contradiction

    Example: 2\sqrt{2} is irrational; log⁡23\log_{2} 3 is irrational; there are infinitely many prime numbers

    these words designate a proposition whose NEGATION is an existence, hence a rich hypothesis: you can name the object and compute with it

  • If the statement is indexed by an integer nn, and rank n+1n+1 follows from rank nn by a small computation → induction: base case, inductive step, conclusion

    Example: for all n≥0n \geq 0, 7n−17^{n}-1 is divisible by 6, because 7n+1−1=7(7n−1)+67^{n+1}-1=7(7^{n}-1)+6

    induction is not compulsory just because a statement is about all integers: 1+3+⋯+(2n−1)=n21+3+\cdots+(2n-1)=n^{2} is proved in one line by regrouping

  • If the statement claims that two objects coincide, or that a value repeats, without asking which → pigeonhole principle: name the objects, name the boxes, count both

    Example: among 13 integers, two have the same remainder modulo 12

    simple form if you want two objects, generalized form with ⌈m/n⌉\lceil m/n \rceil if you want more

  • If the statement is universal and you suspect it is FALSE → counterexample: a single value, checked against the hypothesis AND the conclusion

    Example: F5=4,294,967,297=641×6,700,417F_{5}=4{,}294{,}967{,}297=641\times 6{,}700{,}417 disproves “every Fermat number is prime”

    it is the only case where a numerical value on its own constitutes a complete proof

  • If the domain splits naturally: even or odd, remainders modulo nn, sign → proof by cases, set up INSIDE one of the structures above

    Example: n2≡0n^{2} \equiv 0 or 1(mod4)1 \pmod 4, so no 4k+34k+3 is a perfect square

    the list must be EXHAUSTIVE; it does not need to be disjoint, an overlap costs nothing

No branch settles it? Write the negation of the conclusion and compare its richness with that of the hypothesis: it is the only criterion that decides between the direct proof and the contrapositive. And if the contrapositive is enough, prefer it to contradiction: it is shorter and nothing false is assumed.

Which negation to write, on the first line of your scratch work

The contrapositive and contradiction both begin by negating. Getting the negation wrong ruins the proof without a single wrong computation, so the negation is written separately, before reasoning.

  • If the conclusion is “AA or BB” → negate as “¬A\lnot A AND ¬B\lnot B”

    Example: the negation of “x>31x>31 or y>31y>31” is “x≤31x \leq 31 and y≤31y \leq 31”

  • If the conclusion is “AA and BB” → negate as “¬A\lnot A OR ¬B\lnot B”

    Example: the negation of “nn even and n>4n>4” is “nn odd or n≤4n \leq 4”

  • If the conclusion is an implication “if AA then BB” → negate as “AA AND ¬B\lnot B”, which is no longer an implication

    Example: ¬(P⇒Q)=P∧¬Q\lnot(P \Rightarrow Q) = P \land \lnot Q, and never P⇒¬QP \Rightarrow \lnot Q

    a test that writes “suppose, for the sake of contradiction, that PP implies not QQ” has already lost the question

  • If the conclusion is “for all xx, P(x)P(x)” → negate as “there exists xx such that ¬P(x)\lnot P(x)”: that is exactly a counterexample

    Example: negating “every FkF_{k} is prime” gives “some FkF_{k} is composite”, and F5F_{5} is

  • If the conclusion is “there exists xx such that P(x)P(x)” → negate as “for all xx, ¬P(x)\lnot P(x)”, which gives a uniform UPPER BOUND

    Example: negating “some box contains 2 objects” gives “each box contains at most 1”, hence a total ≤n\leq n

The last row is the skeleton of the proof of the pigeonhole principle itself: negate, the negation bounds each box, add up the bounds, and the total becomes too small. Knowing how to negate is already half the proofs of the chapter.

How the answer is expected to be written

A marker ticks steps. Here they are in order, with the concluding sentence expected word for word.

A proof by contrapositive

When to use it: The conclusion is a negation or an OR, or it is directly about the basic object while the hypothesis is about an expression built from it.

  1. 1 Announce the structure: “We prove the contrapositive.”
  2. 2 Write the contrapositive IN FULL before proving it, negations included: “if nn is even, then 3n+23n+2 is even”.
  3. 3 Translate the hypothesis ¬Q\lnot Q into something you can manipulate, with a fresh letter: “nn is even, so there is an integer kk such that n=2kn=2k”.
  4. 4 Compute until the DEFINITION of ¬P\lnot P appears: “3n+2=6k+2=2(3k+1)3n+2=6k+2=2(3k+1), and 3k+13k+1 is an integer”.
  5. 5 Conclude in two stages: first the contrapositive, then the original statement.

Concluding sentence

“So 3n+23n+2 is even, which establishes the contrapositive. Since the contrapositive is equivalent to the statement, if 3n+23n+2 is odd then nn is odd.”

The trap: Skipping the second step. A test that proves the contrapositive without having written it leaves the marker guessing which proposition it is working on, and the marker does not guess.

Marking: Typically 1 mark for announcing and writing the contrapositive, 2 marks for the computation, 1 mark for the two-stage conclusion.

A proof by contradiction

When to use it: The statement contains there is no, none, at most one, is unique, is irrational, is impossible; or the contrapositive has failed for lack of a usable hypothesis.

  1. 1 Announce: “Suppose, for the sake of contradiction, that...”, and write the COMPLETE negation. For an implication, it is PP AND ¬Q\lnot Q: you keep the hypothesis of the statement, you do not throw it away.
  2. 2 Set up the objects with all their writing precautions: fraction in LOWEST TERMS, positive integers, list assumed COMPLETE. That is where the contradiction will be found.
  3. 3 Reason normally, never using what you want to prove, and justifying every existence by a named theorem.
  4. 4 Exhibit the contradiction and NAME it: “aa and bb are both even, which contradicts the lowest terms assumed at the start”.
  5. 5 Conclude on the original statement, not on the contradiction.

Concluding sentence

“The initial assumption is therefore impossible: 2\sqrt{2} is irrational.”

The trap: Finding the contradiction and stopping there. The marker expects the sentence that comes back to the statement; without it, the question is not finished.

Marking: 1 mark for the correct negation, 1 mark for the writing precautions, 2 marks for the contradiction exhibited and named, 1 mark for the conclusion.

A proof by the pigeonhole principle

When to use it: The statement claims that two objects coincide, or that a value repeats, without asking which.

  1. 1 Name the OBJECTS and the BOXES in words: “the objects are the 5,0005{,}000 sessions, the boxes are the possible IDs”.
  2. 2 Count both, with the computation shown: “an ID is written with 3 hexadecimal digits, so there are 163=4,09616^{3}=4{,}096 of them”.
  3. 3 Compare and cite the form used: “5,000>4,0965{,}000>4{,}096, so by the pigeonhole principle...”, or the generalized form with ⌈m/n⌉\lceil m/n \rceil.
  4. 4 Conclude by coming back to the objects of the statement, and only on what the principle gives.

Concluding sentence

“So at least two sessions received the same ID. The principle does not say which ones.”

The trap: Naming the crowded box, or writing the average 5,000/4,096≈1.225{,}000/4{,}096 \approx 1.22 instead of ⌈1.22⌉=2\lceil 1.22 \rceil = 2.

Marking: 1 mark for naming objects and boxes, 1 mark for the count, 1 mark for citing the technique, 1 mark for the conclusion.

Check before you hand in

Five minutes of checking recover more marks than one more problem started in a hurry.

The typical problem, taken apart

No lossless compressor shortens every file

A lossless compressor turns a sequence of bits into another sequence of bits, in such a way that decompression recovers the original sequence EXACTLY. A company announces a format that shortens any file by at least one bit. Prove that this program cannot exist.

We reason on 10-bit files, which is enough: if the claim is false at that size, it is false.

every file comes out shortersequencesof 10 bitssequencesof 0 to 9 bitscompression
On the left what goes in, on the right what must come out: the announced compressor sends each sequence of 1010 bits to a strictly shorter sequence.

Step 1

The objects are the 10-bit sequences. Each bit takes two values and the choices are independent, so there are 210=1,0242^{10}=1{,}024 of them.

Why

The count comes BEFORE the proof structure: without the two numbers, no technique can get started. It is the only counting line in the whole problem.

Step 2

The boxes are the strictly shorter sequences, ALL lengths combined: 20+21+⋯+29=210−1=1,0232^{0}+2^{1}+\cdots+2^{9}=2^{10}-1=1{,}023, by the sum of a geometric sequence with ratio 2.

Why

The claim promises at least one bit less, not exactly one: lengths 0 to 8 count as much as length 9. Keeping only the 9-bit sequences would give 512 and leave half the problem untreated.

Step 3

“Lossless” means that two DIFFERENT files cannot give the same compressed version: otherwise the decompressor, faced with that version, would not know which one to return. The function is therefore INJECTIVE.

Why

It is the step everyone skips, because the word injective is not in the statement: it has to be produced by reading. Without it, the two counts are useless.

Step 4

“Suppose, for the sake of contradiction, that this compressor exists.”

Why

The statement is a NONEXISTENCE, a word that calls for contradiction according to the decision tree. And the negation of a nonexistence is an existence, hence a rich hypothesis: you can name the object and compute with it.

Step 5

It sends each of the 1,0241{,}024 sequences of 10 bits to one of the 1,0231{,}023 shorter sequences. We place 1,0241{,}024 objects in 1,0231{,}023 boxes: by the pigeonhole principle, two distinct sequences receive the same compressed version.

every file comes out shorter1,024sequencesof 10 bits1,023sequencesof 0 to 9 bitscompressioninjective

Why

The contradiction is PRODUCED by a second structure, the pigeonhole principle, nested inside the first. It is the standard pattern of impossibility proofs in computer science: assume the object, count what it would have to tell apart, and one place is missing.

Step 6

This contradicts the injectivity established in step 3.

Why

The contradiction is named and must point to a property written above. The word “contradiction” used on its own is worth no marks, because it does not say what is contradicted.

Step 7

Check: 1,024−1,023=11{,}024-1{,}023=1, a single place is missing and that is enough. On 5 bits, 25=322^{5}=32 sequences for 25−1=312^{5}-1=31 shorter ones: the gap is still 1.

Why

The identity 20+⋯+2n−1=2n−12^{0}+\cdots+2^{n-1}=2^{n}-1 is easy to recover in your head and the gap is always 1, whatever the size: an error by a factor of 2 in the count would show immediately.

The conclusion, written out

“The announced compressor does not exist: no lossless program can shorten every file. The proof is a proof by contradiction whose contradiction is produced by the pigeonhole principle, applied to a count.”

The classic mistake on this problem: Counting 512 boxes, that is, only the 9-bit sequences. The inequality 1,024>5121{,}024>512 still holds and the proof seems to work, but it has only handled the files shortened by exactly one bit, whereas the claim promises at least one.

Learn by heart

  • • Contrapositive of P⇒QP \Rightarrow Q: ¬Q⇒¬P\lnot Q \Rightarrow \lnot P, ALWAYS equivalent. Converse: Q⇒PQ \Rightarrow P, no link in truth value.
  • • ¬(P⇒Q)=P∧¬Q\lnot(P \Rightarrow Q) = P \land \lnot Q. ¬(A∨B)=¬A∧¬B\lnot(A \lor B) = \lnot A \land \lnot B. ¬(A∧B)=¬A∨¬B\lnot(A \land B) = \lnot A \lor \lnot B.
  • • Contradiction: assume PP AND ¬Q\lnot Q, any contradiction will do. Contrapositive: assume ¬Q\lnot Q ALONE and aim for ¬P\lnot P.
  • • A counterexample DISPROVES a universal statement. No number of examples PROVES it.
  • • Induction: base case AND inductive step. The inductive step alone proves nothing: “n=n+1n=n+1” passes from each rank to the next and is false everywhere.
  • • Pigeonhole: n+1n+1 objects in nn boxes give a box with 2 objects; mm objects in nn boxes give one with ⌈m/n⌉\lceil m/n \rceil objects, the CEILING.
  • • The pigeonhole principle gives an EXISTENCE: never the box, never the objects.
  • • A proof by cases must be EXHAUSTIVE, and does not need to be disjoint. Modulo nn, there are exactly nn cases.
  • • Termination of an algorithm: a positive, strictly decreasing INTEGER variant. A rational variant proves nothing: 12n\frac{1}{2^{n}} decreases without ever stopping.

Frequently asked questions

What is the difference between the contrapositive and the converse?

The contrapositive negates both parts AND swaps them: from if P then Q, you go to if not Q then not P. It always has the same truth value as the statement, so proving it proves the statement. The converse only swaps them, if Q then P. It is another proposition, which can be false when the statement is true, and which needs its own proof.

How do you know which proof technique to choose?

Read the form of the statement, never its subject. A hypothesis that translates at once into an equation: direct proof. A conclusion that is easier to negate than the hypothesis is to use: contrapositive. Nonexistence, uniqueness or irrationality: contradiction. A statement indexed by an integer: induction. An existence you cannot construct: the pigeonhole principle.

When should you argue by contradiction rather than by contrapositive?

By contrapositive whenever the statement is an implication and the negation of the conclusion is easy to handle: the proof is shorter and nothing false is assumed. By contradiction when the statement is not an implication, or when it contains the words there is no, none, at most one, is unique, is irrational, is impossible.

Is one example enough to prove a mathematical statement?

No, except for an existence statement, where exhibiting an object is a complete proof. A universal statement covers infinitely many cases and no finite list exhausts them. Fermat had checked five numbers, all prime, before Euler showed that the sixth is composite. On the other hand, a single counterexample is enough to disprove a universal statement.

What exactly does the pigeonhole principle say?

If you place more objects than boxes, at least one box contains two objects. With m objects in n boxes, at least one box contains m over n of them, rounded up to the next integer. The principle only asserts that such a box exists: it says neither which one, nor which objects are in it. It is a nonconstructive existence proof.

Why do you have to check the base case in an induction?

Because induction does not prove it, it requires it. The inductive step only says that the property passes from one rank to the next; without a starting rank checked by hand, it passes nothing on. The property n equals n plus 1 does pass from each rank to the next, and it is false at every rank: that is the example that settles the question.

Practise it

Corrected exercises: Proof techniques, 201-N11

A method is proved on a paper, not on a sheet. The set for the same chapter takes each of these traps into a problem, with the solution written out step by step.

  • 10 corrected exercises
  • 100 points
  • 150 minutes
Do the exercises
Something missing from this sheet? A method, a trap, an exercise to practise it, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

Previous sheet Boolean and mathematical logic Next sheet Number systems in computing

© Ahmed Squalli Houssaini. Revision sheet published at www.letuteurscientifique.ca/en/fiches/cegep-n11-proof-techniques. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

See also

Looking for a 201-N11 tutor in Montreal?

Get in touch for a first session. With a B.Sc. in computer science from McGill and an M.Sc. in applied computer science from Concordia, I train students to write a proof the way it will be graded: choose the structure before writing the first line, and name it.

Site by Studio Squalli