Mathematics for Computer Science 201-N11 • CEGEP, Montreal

Corrected exercises: writing a mathematical proof (201-N11)

This is the corrected exercise set on proof techniques for Mathematics for Computer Science, 201-N11, the discrete mathematics course taken at CEGEP by students in computer science programs (Computer Science Technology, and Computer Science and Mathematics). Part A sets up the first four structures: the direct proof and what it demands of a write-up, the square of the four implications that separates the contrapositive from the converse, the criterion for choosing the contrapositive, proof by contradiction with the irrationality of 2\sqrt{2} and of log⁡23\log_{2} 3, then proof by cases and disproof by counterexample. Part B moves up to exam level: the pigeonhole principle, proved by contradiction and then generalized, mathematical induction placed among the five techniques with the variant that proves an algorithm terminates, the impossibility of a universal lossless compressor, and four write-ups of the same proof, only one of which holds.

The thread of the set: a proof is not a sequence of correct computations, it is a STRUCTURE chosen before the first line, and the form of the statement tells you which one. A rich hypothesis calls for a direct proof; a conclusion that is easy to negate calls for the contrapositive; an irrationality, a uniqueness or a nonexistence calls for contradiction; a statement indexed by an integer calls for induction; an existence you cannot construct calls for the pigeonhole principle. A student who starts writing before choosing produces a page of computations that proves nothing.

The pitfalls named explicitly in the solutions: calling the converse the contrapositive, believing that a well-chosen example proves a universal statement, forgetting to take the fraction in lowest terms before squaring, taking the floor instead of the ceiling in the generalized pigeonhole principle, and handing in a circular proof that nevertheless reads very smoothly.

10 corrected exercises • 100 points • 150 minutes

This chapter is part of 201-N11, every chapter with its set and sheet Before you start Revision sheet: the traps and the method for this chapter

Self-checking set Type your answers and check them question by question: the page tells you right or wrong before you open the solution. With an account, every answer right on the first try earns points, and your right answers stay filled in when you come back.

Course recap

  • • Direct proof: start from the hypothesis, translate it into something you can manipulate, and arrive at the conclusion. Choose it when the hypothesis is RICH.
  • • Contrapositive of P⇒QP \Rightarrow Q: ¬Q⇒¬P\lnot Q \Rightarrow \lnot P, always equivalent. Converse: Q⇒PQ \Rightarrow P, with no link at all to the truth value of the statement.
  • • Negation of an implication: ¬(P⇒Q)=P∧¬Q\lnot(P \Rightarrow Q) = P \land \lnot Q. It is not an implication.
  • • Negation of an OR: ¬(A∨B)=¬A∧¬B\lnot(A \lor B) = \lnot A \land \lnot B. Negation of an AND: ¬(A∧B)=¬A∨¬B\lnot(A \land B) = \lnot A \lor \lnot B.
  • • Contradiction: to prove AA, assume ¬A\lnot A; to prove P⇒QP \Rightarrow Q, assume PP AND ¬Q\lnot Q, and look for any contradiction at all.
  • • Words that signal a proof by contradiction: there is no, none, at most one, is unique, is irrational, is impossible.
  • • Proof by cases: the list of cases must be EXHAUSTIVE. It does not need to be disjoint. Modulo nn, there are nn cases.
  • • Counterexample: a single one is enough to disprove a universal statement; no number of examples proves it.
  • • Induction: base case AND inductive step. The inductive step alone proves nothing: the property “n=n+1n=n+1” is inherited from one rank to the next and false everywhere.
  • • Termination of an algorithm: exhibit a positive INTEGER variant that strictly decreases. A rational variant proves nothing.
  • • Pigeonhole principle, simple form: n+1n+1 objects in nn boxes give a box with two objects. Generalized form: mm objects in nn boxes give a box with ⌈m/n⌉\lceil m/n \rceil objects.
  • • The pigeonhole principle proves an EXISTENCE without saying which box or which objects: it is a nonconstructive proof.

Part A: the basics (/50)

Exercise 1: The direct proof: what you assume, what you establish

A proof is not a sequence of correct computations: it is a STRUCTURE chosen before the first line, and the form of the statement tells you which one. The course outline prescribes five: direct proof, contrapositive, contradiction, induction, pigeonhole principle. We start with the simplest, the one you choose when the hypothesis is rich, that is, when it translates at once into something you can manipulate.

Definitions used throughout the exercise: an integer nn is even if there is an integer kk such that n=2kn=2k, and odd if there is an integer kk such that n=2k+1n=2k+1; the integer aa divides the integer bb, written a∣ba \mid b, if there is an integer kk such that b=akb=ak.

  • a) Prove that the sum of two odd integers is even, then state in one line what you ASSUMED and what you ESTABLISHED.
  • b) Prove that if a∣ba \mid b and a∣ca \mid c, then a∣(bu+cv)a \mid (bu+cv) for all integers uu and vv.
  • c) A student justifies question a) by writing 3+5=83+5=8, 7+11=187+11=18 and 101+3=104101+3=104. What exactly has he proved?
  • d) Another one begins with “let n=2k+1n=2k+1 and m=2k+1m=2k+1”. Why does this write-up not prove the statement?
  • e) A program sets out to establish question a) by testing every pair of odd integers from 1 to 10610^{6}. How many pairs is that, and would the statement then be proved?

Type your answers, the page tells you right or wrong 0/8

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) n+m=2(k+j+1)n+m=2(k+j+1), so even. Assumed: nn and mm odd; established: n+mn+m even
  • b) bu+cv=a(ku+lv)bu+cv=a(ku+lv), so a∣(bu+cv)a \mid (bu+cv)
  • c) Three particular cases only: no finite list proves a universal statement
  • d) The same letter forces n=mn=m: only the case of two equal odd numbers is handled
  • e) 500,0002=2.5×1011500{,}000^{2}=2.5\times 10^{11} pairs, that is, 250 billion, and the statement is still not proved
a)

You recognize a direct proof by this: the hypothesis is RICH, it translates at once into an equation, and everything else is computation. Let nn and mm be two odd integers. By definition, there are integers kk and jj such that n=2k+1n=2k+1 and m=2j+1m=2j+1. Then n+m=(2k+1)+(2j+1)=2k+2j+2=2(k+j+1)n+m=(2k+1)+(2j+1)=2k+2j+2=2(k+j+1). Since k+j+1k+j+1 is an integer, n+mn+m is 2 times an integer: it is even. Assumed: nn and mm odd. Established: n+mn+m even. Check on one case: n=7n=7 and m=11m=11 give k=3k=3, j=5j=5, k+j+1=9k+j+1=9 and n+m=18=2×9n+m=18=2\times 9. The write-up pitfall, which costs half the marks on a question of this kind: concluding “so n+mn+m is even” without having exhibited the factor 2. A direct proof is finished only when the DEFINITION of the conclusion is satisfied word for word, here when the number appears in the form 2 times an integer. Writing “the sum of two odd numbers is obviously even” is worth no marks: obviousness is not a proof structure, and the marker grades the structure.

b)

Same structure, a rich hypothesis once again. From a∣ba \mid b we get an integer kk such that b=akb=ak, and from a∣ca \mid c an integer ll such that c=alc=al. Watch the letter: kk and ll have no reason to be equal, and confusing them would amount to assuming b=cb=c. Then bu+cv=aku+alv=a(ku+lv)bu+cv=aku+alv=a(ku+lv). Since ku+lvku+lv is an integer, we do have a∣(bu+cv)a \mid (bu+cv). Check: a=7a=7, b=21b=21, c=35c=35, u=2u=2 and v=−1v=-1 give bu+cv=42−35=7=7×1bu+cv=42-35=7=7\times 1. This result has a name, the linear combination lemma, and it is what makes Euclid's algorithm work: every common divisor of bb and cc also divides the remainder b−qcb-qc, which is a linear combination of bb and cc. Euclid's algorithm comes back in exercise 7. Remember the move: a divisibility hypothesis is useless as long as it stays written with the vertical bar; it always translates into an equation with a named integer.

c)

He has proved three particular cases, and nothing more. The statement is UNIVERSAL, it is about infinitely many pairs, and no finite list exhausts them. Three correct examples are not a proof: they are checks, and checking is good for only two things, convincing yourself before writing and catching yourself when you got a sign wrong. The point to remember is the complete asymmetry between proving and disproving. To DISPROVE a universal statement, a single counterexample is enough and settles the matter; that is the subject of exercise 5. To PROVE it, no number of examples is ever enough. It is exactly the difference between testing a program and proving it: a thousand passing tests do not establish that a program is correct, they establish that it is correct on a thousand inputs, and the input that breaks it is precisely the one nobody thought of.

d)

Because using the same letter forces the two numbers to be equal. Writing n=2k+1n=2k+1 and m=2k+1m=2k+1 assumes n=mn=m, so it only handles pairs of EQUAL odd numbers, such as (7,7)(7, 7), whereas the statement is about any two odd numbers. The computation that follows is correct, it gives n+m=4k+2=2(2k+1)n+m=4k+2=2(2k+1), but its scope is wrong: it does not cover the pair (3,5)(3, 5). A marker takes away almost all the marks here, not for the computation but for the scope. The write-up rule: a fresh letter for each object you know nothing about, and two distinct objects never get the same letter until you have proved they are equal. It is the same mistake as calling both counters of two nested loops ii, and it does the same kind of damage: the program runs, and it computes something other than what you think.

e)

Between 1 and 10610^{6} there are 500,000500{,}000 odd integers, so 500,0002=2.5×1011500{,}000^{2}=2.5\times 10^{11} pairs, that is, 250 billion checks. At a billion tests per second, that takes about 250 seconds, a little over four minutes. And at the end of those four minutes the statement is still NOT proved: we will know that it is true for the odd numbers below a million, and we will know nothing about 106+110^{6}+1. The proof of question a) takes three lines and covers every integer at once, including those that will never fit in any memory. That is the argument for learning, in a mathematics course for computer science, to write proofs rather than to test: the machine runs through cases, the proof quantifies over all of them. The practical corollary: when a statement is about an infinite set, looking for a proof structure is not a mathematician's luxury, it is the only way.

Tick the exercises you have done or want to review: a free account, no password, keeps your ticks and your right answers from one visit to the next, tells you which chapter to tackle next and lets you ask for the exercise you are missing. Create your space, an email is enough.

Exercise 2: The square of the four implications: contrapositive and converse

We work with the following statement P⇒QP \Rightarrow Q, where nn stands for any integer: PP is “nn is divisible by 6” and QQ is “nn is divisible by 3”. With two propositions you can form four implications, which the figure shows numbered (1) to (4). The whole issue of the chapter is here: two of these four implications ALWAYS have the same truth value as the original statement, and the other two have no link with it.

(1)P => Q(2)Q => P(3)not Q => not P(4)not P => not Q
  • a) Name each of the four implications in the figure, then write (2) and (3) out in words for this statement.
  • b) Build the truth table of columns (1), (2) and (3) and say which ones coincide.
  • c) How many rows does a truth table with two propositions have? On how many of these rows does the converse differ from the statement? How many rows would a table with five propositions have?
  • d) A student writes: “I have proved that if xx is a perfect square then x≥0x \geq 0; so if x≥0x \geq 0 then xx is a perfect square”. Name the mistake and give the smallest positive integer counterexample.
  • e) Here (1) is true and (2) is false. What would be needed to have the right to write an equivalence, and what true equivalence can be written about divisibility by 6?

Type your answers, the page tells you right or wrong 0/10

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) (1) statement, (2) converse, (3) contrapositive, (4) contrapositive of the converse; (2) is false, n=9n=9 disproves it
  • b) (1) and (3) read 1,0,1,11,0,1,1 and coincide; (2) reads 1,1,0,11,1,0,1
  • c) 4 rows, and the converse differs on 2 of them; 32 rows for five propositions
  • d) Affirming the converse; counterexample x=2x=2
  • e) Both (1) and (2) would have to be true; correct equivalence: divisible by 6 if and only if divisible by 2 and by 3
a)

(1) P⇒QP \Rightarrow Q is the original statement. (2) Q⇒PQ \Rightarrow P is its CONVERSE. (3) ¬Q⇒¬P\lnot Q \Rightarrow \lnot P is its CONTRAPOSITIVE. (4) ¬P⇒¬Q\lnot P \Rightarrow \lnot Q is the contrapositive of the converse (often called the inverse), so it is equivalent to (2). In words: (2) says “if nn is divisible by 3, then nn is divisible by 6”, which is FALSE, as n=9n=9 shows in one line. (3) says “if nn is not divisible by 3, then nn is not divisible by 6”, which is true, and it is in fact the form in which it gets used: a number whose digit sum is not a multiple of 3 cannot be a multiple of 6, without any division at all. The exact name matters: on a test, writing “contrapositive” for Q⇒PQ \Rightarrow P loses the marks for the whole question, even if the rest of the reasoning is correct, because what follows then rests on a statement that does not have the announced truth value.

b)

See the table in the solution. On the four rows, in the order (P,Q)=(1,1),(1,0),(0,1),(0,0)(P,Q)=(1,1),(1,0),(0,1),(0,0): column (1) reads 1,0,1,11,0,1,1; column (3) reads 1,0,1,11,0,1,1; column (2) reads 1,1,0,11,1,0,1. Columns (1) and (3) are identical row by row: a statement and its contrapositive are the SAME proposition, and that is what allows you to prove one in order to get the other. Column (2) differs from the other two on rows 2 and 3. The computation of row 2 is worth redoing by hand: P=1P=1, Q=0Q=0 give ¬Q=1\lnot Q=1 and ¬P=0\lnot P=0, so (3) is 1⇒01 \Rightarrow 0, that is, 0, like (1). The table is the judge, and it is the only proof of equivalence that counts: no intuition drawn from ordinary language replaces the comparison of two columns.

c)

Two propositions give 22=42^{2}=4 rows. The converse differs from the statement on TWO of these four rows, exactly half, which is the best argument against the confusion: getting the form wrong is not a small imprecision, it is a one-in-two chance of reasoning about a false proposition. More generally, a table with nn propositions has 2n2^{n} rows, so 8 for three propositions and 32 for five. The point to remember for the rest of the course: when an announced equivalence looks doubtful, do not argue, write out the four rows; it takes thirty seconds and it settles the question.

d)

The mistake is called affirming the converse. The student has proved P⇒QP \Rightarrow Q and concludes Q⇒PQ \Rightarrow P, which is never allowed. The smallest positive integer counterexample is x=2x=2: it satisfies x≥0x \geq 0 and it is not a perfect square, since 12=11^{2}=1 and 22=42^{2}=4 bracket it strictly. What he was allowed to write is the contrapositive: if x<0x<0, then xx is not a perfect square. This mistake is the most frequent of the whole chapter, and it does not show in the computations, it shows in the concluding sentence, which makes it treacherous on an exam. It has an exact counterpart in computing: from “if the input is valid then the test returns true”, nothing can be concluded from a test that returns true, whereas a test that returns false guarantees that the input was invalid.

e)

Both (1) AND (2) would have to be true, because an equivalence is the conjunction of an implication and its converse. That is not the case here, since n=9n=9 disproves (2). A true equivalence about divisibility by 6 does exist, though: nn is divisible by 6 if and only if nn is divisible by 2 AND by 3. The forward direction is immediate, and the reverse direction requires 2 and 3 to be relatively prime, which is Euclid's lemma (called Gauss's theorem in French textbooks). The numerical check: 9 is divisible by 3 but not by 2, so not by 6; 4 is divisible by 2 but not by 3, so not by 6; 12 is divisible by both, so by 6. The write-up lesson: “if and only if” is a promise of TWO proofs, and a test that announces it without supplying two loses the marks for the missing direction.

PQ(1) P => Q(3) not Q => not P(2) Q => P11111100010111000111

Exercise 3: When to choose the contrapositive

The contrapositive is not a stylistic variant: it is the choice you make when the hypothesis PP is POOR, that is, impossible to translate into anything useful, while the negation of the conclusion can be handled effortlessly. The move is always the same: write ¬Q\lnot Q, see whether it is rich, and if so prove ¬Q⇒¬P\lnot Q \Rightarrow \lnot P, which has exactly the same truth value by exercise 2.

One negation rule comes back in every question: the negation of “AA or BB” is “¬A\lnot A and ¬B\lnot B”, and the negation of “AA and BB” is “¬A\lnot A or ¬B\lnot B”.

  • a) Let nn be an integer. Prove: if 3n+23n+2 is odd, then nn is odd. Start by writing the negation of the conclusion.
  • b) Let xx and yy be two positive integers. Prove: if xy>1,000xy>1{,}000, then x>31x>31 or y>31y>31.
  • c) Let nn be an integer. Prove: if n3+5n^{3}+5 is odd, then nn is even.
  • d) In all three cases, say what made the direct proof painful.
  • e) The contrapositive and proof by contradiction both begin by assuming the conclusion is false. What sets them apart?

Type your answers, the page tells you right or wrong 0/8

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Contrapositive: n=2kn=2k gives 3n+2=2(3k+1)3n+2=2(3k+1), even. The statement is true
  • b) Negation of the conclusion: x≤31x \leq 31 and y≤31y \leq 31, so xy≤961≤1,000xy \leq 961 \leq 1{,}000. The statement is true
  • c) Contrapositive: nn odd gives n3n^{3} odd, so n3+5n^{3}+5 even. The statement is true
  • d) The hypothesis is about a constructed expression, the negation of the conclusion is about nn itself
  • e) The contrapositive assumes ¬Q\lnot Q alone and aims for ¬P\lnot P; contradiction assumes PP and ¬Q\lnot Q and aims for any contradiction
a)

The negation of “nn is odd” is “nn is even”, and that is a rich hypothesis: it reads n=2kn=2k. The contrapositive to prove is therefore: if nn is even, then 3n+23n+2 is even. Proof: n=2kn=2k gives 3n+2=6k+2=2(3k+1)3n+2=6k+2=2(3k+1), which is 2 times an integer, so even. Since the contrapositive is equivalent to the statement, the statement is proved. Check: n=4n=4 gives 3n+2=143n+2=14, even, as expected; n=5n=5 gives 17, odd, and 5 is indeed odd. Compare with the direct route: starting from “3n+23n+2 is odd” gives 3n+2=2k+13n+2=2k+1, so 3n=2k−13n=2k-1, and you then have to argue that 3n3n odd forces nn odd, which is a second statement of the same type, not proved. The direct route goes around in circles, the contrapositive takes one line. This contrast is exactly the criterion for choosing.

b)

The conclusion is an OR, and the negation of an OR is an AND: “x≤31x \leq 31 AND y≤31y \leq 31”. That is where everything happens, because this negation is rich, it gives two usable upper bounds, whereas the original conclusion, an OR, cannot be manipulated. Contrapositive to prove: if x≤31x \leq 31 and y≤31y \leq 31, then xy≤1,000xy \leq 1{,}000. Proof: since xx and yy are positive, xy≤31×31=961≤1,000xy \leq 31 \times 31 = 961 \leq 1{,}000. So the statement is true. The bound is sharp: 312=96131^{2}=961 fits, and 322=1,02432^{2}=1{,}024 does exceed 1,000, which shows that the threshold 31 is not chosen at random. The pitfall, penalized on every exam: writing the negation as “x≤31x \leq 31 or y≤31y \leq 31”. With that or, the pair (10,200)(10, 200) satisfies the hypothesis and gives xy=2,000xy=2{,}000, the proof collapses and the student wrongly concludes that the statement is false.

c)

Negation of the conclusion: nn is odd, so n=2k+1n=2k+1, a rich hypothesis again. Contrapositive: if nn is odd, then n3+5n^{3}+5 is even. Proof: nn odd makes n3=n×n×nn^{3}=n \times n \times n odd, since a product of odd numbers is odd, then n3+5n^{3}+5 is the sum of two odd numbers, so even by exercise 1. Check: n=3n=3 gives 27+5=3227+5=32, even. To spell everything out, n=2k+1n=2k+1 gives n3=8k3+12k2+6k+1=2(4k3+6k2+3k)+1n^{3}=8k^{3}+12k^{2}+6k+1=2(4k^{3}+6k^{2}+3k)+1, then n3+5=2(4k3+6k2+3k+3)n^{3}+5=2(4k^{3}+6k^{2}+3k+3). The direct route would require starting from “n3+5n^{3}+5 odd”, so from “n3n^{3} even”, and proving that an even cube forces nn even, which is again a statement of the same family: you would be off on another contrapositive, one step further along.

d)

In all three cases, the starting hypothesis is POOR: it is about a compound expression (3n+23n+2, xyxy, n3+5n^{3}+5) and not about the object nn itself, so translating it into an equation gives nothing usable. The conclusion, on the contrary, is directly about nn, or negates into an AND of two upper bounds. The criterion for choosing can therefore be stated as follows: compare the RICHNESS of PP and that of ¬Q\lnot Q, and prove starting from the richer of the two. Three signals almost always announce a contrapositive: the conclusion is a negation, the conclusion is an OR, or the conclusion is about the basic object while the hypothesis is about an expression built from it.

e)

They differ in what you assume and in what you are looking for. In the contrapositive, you assume ¬Q\lnot Q ALONE and try to establish ¬P\lnot P: nothing false is ever assumed, you prove a statement equivalent to the original one, and the proof is as solid as a direct proof. In a proof by contradiction, you assume PP AND ¬Q\lnot Q, that is, the complete negation of the implication, and you look for any contradiction, not necessarily ¬P\lnot P. Contradiction is therefore more permissive, and that is both its strength, since it applies to statements that are not implications, and its weakness: you reason in a false world, where any computational error produces a contradiction that looks like a conclusion. The rule of use: if the contrapositive is enough, prefer it, it is shorter and safer; keep contradiction for statements of nonexistence, uniqueness and irrationality, which are the subject of exercise 4.

Exercise 4: Proof by contradiction

Contradiction is the technique for statements that cannot be attacked head-on: nonexistence, uniqueness, irrationality. Its structure is fixed. To prove a proposition AA, assume ¬A\lnot A, reason normally, and reach a contradiction, that is, a proposition and its negation at the same time; conclude that ¬A\lnot A is impossible, so AA is true.

Three write-ups of Euclid's proof are given in question d). Only one is valid.

  • a) To prove an implication “if PP then QQ” by contradiction, what exactly do you assume at the start?
  • b) Write out the proof that 2\sqrt{2} is irrational and say which precise assumption is contradicted at the end.
  • c) Prove that log⁡23\log_{2} 3 is irrational, then give its value to two decimal places and its interpretation in bits.
  • d) Here are three write-ups of “there are infinitely many prime numbers”. R1: “suppose there are only finitely many, p1,…,pkp_{1},\dots,p_{k}; then N=p1⋯pk+1N=p_{1}\cdots p_{k}+1 is one more prime, a contradiction”. R2: “suppose there are only finitely many, p1,…,pkp_{1},\dots,p_{k}; N=p1⋯pk+1N=p_{1}\cdots p_{k}+1 is greater than 1, so it has a prime divisor pp; this pp cannot be any of the pip_{i}, which all leave remainder 1; a contradiction”. R3: “there are infinitely many integers, so infinitely many primes”. Which one is valid, and what is wrong with the other two? You are given 2×3×5×7×11×13+1=30,031=59×5092\times 3\times 5\times 7\times 11\times 13+1=30{,}031=59\times 509.
  • e) Does contradiction apply only to implications? Base your answer on questions b), c) and d).

Type your answers, the page tells you right or wrong 0/9

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Assume PP AND ¬Q\lnot Q, the complete negation of the implication
  • b) a2=2b2a^{2}=2b^{2} gives aa even then bb even: the lowest terms of ab\frac{a}{b} are contradicted
  • c) 2a=3b2^{a}=3^{b} sets an even number against an odd one; log⁡23≈1.58\log_{2} 3 \approx 1.58 bits per symbol
  • d) R2; R1 believes NN is prime, which 30,031=59×50930{,}031=59\times 509 disproves; R3 is not a proof
  • e) No: irrationality and existence are not implications, and contradiction handles them
a)

You assume PP AND ¬Q\lnot Q, that is, exactly the negation of the implication, since ¬(P⇒Q)\lnot(P \Rightarrow Q) is P∧¬QP \land \lnot Q. So you keep the hypothesis of the statement, which is the point students forget: in a proof by contradiction you do not throw PP away, you add it to ¬Q\lnot Q and so have TWO assumptions instead of one, which explains why contradiction succeeds where the contrapositive, which only has ¬Q\lnot Q, sometimes fails. Then you look for any contradiction at all: a number that is both even and odd, a fraction in lowest terms whose numerator and denominator are both even, an integer strictly between two consecutive integers. The required write-up has three markers: the announcement “suppose, for the sake of contradiction, that”, the contradiction explicitly named when it arrives, and the conclusion that restates the original statement. A test that finds the contradiction and stops there loses the marks for the conclusion.

b)

Suppose, for the sake of contradiction, that 2\sqrt{2} is rational. It can then be written 2=ab\sqrt{2}=\frac{a}{b} with aa and bb integers, bb nonzero, and the fraction chosen in LOWEST TERMS, which is always possible by simplifying. Squaring, 2=a2b22=\frac{a^{2}}{b^{2}}, so a2=2b2a^{2}=2b^{2}: a2a^{2} is even, so aa is even, by contraposition, since aa odd would make a2a^{2} odd (the move of exercise 3), and we write a=2ca=2c. Then 4c2=2b24c^{2}=2b^{2}, so b2=2c2b^{2}=2c^{2}, so bb is even for the same reason. The assumption contradicted is precisely the LOWEST TERMS: aa and bb are both even, so both divisible by 2, whereas they were assumed to have no common factor. So 2\sqrt{2} is irrational. The classic pitfall is forgetting to take the fraction in lowest terms: without that precaution, getting “aa and bb even” is no contradiction at all, it is an ordinary piece of information, and the proof proves nothing. Check of the order of magnitude: 2≈1.41421\sqrt{2}\approx 1.41421, and 9970≈1.414286\frac{99}{70}\approx 1.414286 is an excellent approximation of it, but only an approximation.

c)

Suppose, for the sake of contradiction, that log⁡23=ab\log_{2} 3=\frac{a}{b} with aa and bb positive integers, which is legitimate since log⁡23>1>0\log_{2} 3>1>0. By definition of the base-2 logarithm, 2a/b=32^{a/b}=3, so raising to the power bb: 2a=3b2^{a}=3^{b}. The left side is even, since a≥1a \geq 1; the right side is odd, since 3 is odd and a product of odd numbers is odd. An integer cannot be both even and odd: a contradiction. So log⁡23\log_{2} 3 is irrational. Its value is log⁡23≈1.58\log_{2} 3 \approx 1.58, and it is the average number of bits needed to encode a symbol taken from an alphabet of three equally likely letters. Irrationality then says something concrete: no fixed-length code putting bb symbols on aa bits can be exactly optimal, whatever grouping is chosen; you get closer without ever getting there. The write-up pitfall: forgetting the condition a≥1a \geq 1, without which 2a2^{a} could equal 1, which is odd, and the contradiction disappears.

d)

R2 is the only valid one. R1 makes a substantive mistake: nothing guarantees that NN is prime, and the given example proves it, 2×3×5×7×11×13+1=30,031=59×5092\times 3\times 5\times 7\times 11\times 13+1=30{,}031=59\times 509 is not prime. What the proof obtains is more modest and sufficient: NN has a prime divisor, and that divisor is missing from the list. In the example, 59 and 509 are indeed two primes absent from the list 2, 3, 5, 7, 11, 13. R3 is not a proof at all, it is an assertion: infinitely many integers do not imply infinitely many elements in a subset; there are infinitely many integers and yet only one even prime. The proofreading lesson: in a proof by contradiction, the contradiction must be EXHIBITED, not announced, and every step that asserts an existence must say which theorem it comes from, here the fact that every integer greater than 1 has a prime divisor.

e)

No, and that is even its main advantage over the contrapositive, which requires an implication. None of the statements b), c) and d) is an implication: “2\sqrt{2} is irrational” is a negation, “there are infinitely many prime numbers” is an existence claim. Contradiction applies to any statement AA, since all it asks is that you can write ¬A\lnot A. That is why you recognize it from key words in the statement: there is no, none, at most one, is unique, is irrational, is impossible. They all designate a proposition whose negation is an EXISTENCE, hence a rich hypothesis: assuming an object exists lets you name it and compute with it, whereas the original statement, which denies, gives you nothing to manipulate. It is the same criterion as in exercise 3, applied to a statement that is not an implication.

Exercise 5: Proof by cases, and disproof by counterexample

Two structures complete the list. A proof by cases splits the domain into pieces and proves the statement on each one: the figure shows its anatomy. A disproof by counterexample, for its part, proves nothing, it DESTROYS a universal statement, and a single value is enough.

statement to prove on Dcase 1: D1case 2: D2case 3: D3conclusion trueconclusion trueconclusion true
  • a) Prove that the square of an integer is congruent to 0 or 1 modulo 4. Deduce that no integer of the form 4k+34k+3 is a perfect square, and check on 7, 11 and 15.
  • b) In the figure, what condition must the list of cases satisfy for the proof to hold? Must the cases be pairwise disjoint?
  • c) Prove that there are two irrational numbers aa and bb such that aba^{b} is rational, by discussing two cases on the number 22\sqrt{2}^{\sqrt{2}}. What does the proof not tell you?
  • d) Disprove: “every Fermat number Fk=22k+1F_{k}=2^{2^{k}}+1 is prime”. You are given F5=4,294,967,297=641×6,700,417F_{5}=4{,}294{,}967{,}297=641\times 6{,}700{,}417. How many cases had Fermat checked?
  • e) How many cases does an argument on the remainders modulo 3 have? Modulo nn? Why is the split “nn even or nn odd” always legitimate?

Type your answers, the page tells you right or wrong 0/10

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) n2≡0n^{2} \equiv 0 or 1(mod4)1 \pmod 4; so 7, 11 and 15, all of the form 4k+34k+3, are not squares
  • b) Exhaustive, necessarily; disjoint, no, an overlap does no harm
  • c) The pair exists: (2,2)(\sqrt{2}, \sqrt{2}) or (22,2)(\sqrt{2}^{\sqrt{2}}, \sqrt{2}), but the proof does not say which
  • d) F5=641×6,700,417F_{5}=641\times 6{,}700{,}417 disproves the statement; Fermat had checked 5 cases, F0F_{0} to F4F_{4}
  • e) 3 cases modulo 3, nn cases modulo nn; the division algorithm guarantees exhaustiveness
a)

Every integer is even or odd: that is two cases, and they exhaust the integers. Case 1, n=2kn=2k: then n2=4k2n^{2}=4k^{2}, so n2≡0(mod4)n^{2} \equiv 0 \pmod 4. Case 2, n=2k+1n=2k+1: then n2=4k2+4k+1=4(k2+k)+1n^{2}=4k^{2}+4k+1=4(k^{2}+k)+1, so n2≡1(mod4)n^{2} \equiv 1 \pmod 4. In both cases the remainder is 0 or 1, it is NEVER 3. An immediate consequence, by contraposition: an integer of the form 4k+34k+3, whose remainder modulo 4 is 3, cannot be a perfect square. Check: 7=4×1+37=4\times 1+3, and 22=42^{2}=4, 32=93^{2}=9 bracket it; 11=4×2+311=4\times 2+3, bracketed by 9 and 16; 15=4×3+315=4\times 3+3, bracketed by 9 and 16. This result is the standard tool for showing that an equation has no integer solution: look at the possible remainders of each side, and if the two sets do not meet, the equation is impossible. The proof by cases is the engine here, and the number of cases is fixed by the modulus chosen.

b)

The list must be EXHAUSTIVE: the union of the cases must give back the whole domain DD, otherwise the statement remains unproved on whatever is missing. It is the most frequent mistake, and it goes unnoticed because each case, taken on its own, is correct. On the other hand, the cases have no need to be pairwise disjoint: an overlap costs nothing, it only makes you prove the same thing twice on the intersection. So you can handle “x≤0x \leq 0” then “x≥0x \geq 0” without worrying about zero being counted twice, whereas handling “x<0x<0” then “x>0x>0” leaves a gap and ruins the proof. On a test, the sentence that earns the marks is the one that checks exhaustiveness out loud, such as “every integer is even or odd, so the two cases above cover all integers”.

c)

Let x=22x=\sqrt{2}^{\sqrt{2}} and discuss two cases, which exhaust the possibilities. Case 1, xx is rational: then the pair a=b=2a=b=\sqrt{2} works, since 2\sqrt{2} is irrational by exercise 4. Case 2, xx is irrational: then take a=xa=x and b=2b=\sqrt{2}, both irrational; we compute ab=(22)2=2 2×2=22=2a^{b}=\left(\sqrt{2}^{\sqrt{2}}\right)^{\sqrt{2}}=\sqrt{2}^{\,\sqrt{2}\times\sqrt{2}}=\sqrt{2}^{2}=2, which is rational. In both cases a pair works, so such a pair exists. What the proof does NOT tell you: WHICH of the two pairs works, because it does not settle whether xx is rational. It is a NONCONSTRUCTIVE existence proof, and it is exactly the profile of the pigeonhole principle in exercise 6, which guarantees that a box contains two objects without ever saying which box. Remember this kinship: an unsettled proof by cases and the pigeonhole principle are the two ways of proving an existence without exhibiting it.

d)

A single counterexample is enough, and it is given: F5=4,294,967,297=641×6,700,417F_{5}=4{,}294{,}967{,}297=641\times 6{,}700{,}417 is not prime, so the claim “every Fermat number is prime” is false. Fermat had checked FIVE cases, F0=3F_{0}=3, F1=5F_{1}=5, F2=17F_{2}=17, F3=257F_{3}=257 and F4=65,537F_{4}=65{,}537, all prime, and conjectured the rest. Euler found the factor 641 in 1732, some ninety years after Fermat stated his conjecture in 1640. The story is the best argument against reckless generalization: five correct cases in a row, on numbers that grow very fast, guarantee nothing. The expected write-up for a disproof: give the value, check that it satisfies the hypothesis, check that it violates the conclusion, and conclude that the universal statement is false. Three lines, and no other technique is needed: it is the only case where a numerical value on its own constitutes a complete proof.

e)

Modulo 3, there are THREE cases, the remainders 0, 1 and 2, and modulo nn there are nn, the remainders 0 to n−1n-1: it is precisely the division algorithm that guarantees exhaustiveness, since every integer has one and only one remainder. The split “even or odd” is the case n=2n=2, so it is always legitimate, and that is in fact why it is used without justification. Choosing the modulus is a strategic decision, not a matter of taste: take the smallest one that separates what you want to separate. For question a), modulo 4 is enough and gives only two remainder values, whereas modulo 8 would give three for a barely finer result. The practical rule: the larger the modulus, the more precise the information, and the longer the write-up; stop at the first one that settles the question.

Part B: problems and reasoning (/50)

Exercise 6: The pigeonhole principle, from the simple form to the generalized form

The fifth and last technique of the course outline, the pigeonhole principle (Dirichlet's box principle) is the only tool in the chapter that proves an EXISTENCE without constructing the object. The figure shows its simple form: five objects placed in four boxes. You use it whenever a statement claims that two things necessarily coincide, without saying which.

The vocabulary: the objects are what you place, the boxes are the possible values of some characteristic, and the difficulty of a pigeonhole exercise is never the computation, it is deciding what plays the role of the boxes.

5 objects4 boxes
  • a) State the simple form of the principle and prove it by contradiction.
  • b) State the generalized form for mm objects in nn boxes, prove it by contradiction, and apply it to 2,000 files stored in 30 folders.
  • c) A 16-bit checksum is computed for 1,000-bit frames. Prove that two distinct frames receive the same checksum, and say how many frames are enough to guarantee it.
  • d) Choose 10 distinct integers between 1 and 100. Prove that two distinct nonempty subsets have the same sum.
  • e) How many students are needed to be CERTAIN that two were born on the same day of the year? Another exercise set of the course gets a result with 23 people: do these two results contradict each other?

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) n+1n+1 objects in nn boxes force a box with two; the negation bounds each box by 1 and the total by nn
  • b) Some box contains at least ⌈m/n⌉\lceil m/n \rceil objects; here ⌈2,000/30⌉=67\lceil 2{,}000/30 \rceil = 67 files
  • c) 216=65,5362^{16}=65{,}536 checksums for 210002^{1000} frames: a collision is forced, guaranteed from 65,53765{,}537 frames
  • d) 1,0231{,}023 subsets for at most 955 sums: two have the same sum, and they can be made disjoint
  • e) 367 students; no contradiction, the pigeonhole principle gives a worst-case certainty, probability a frequency
a)

Simple form: if n+1n+1 objects are placed in nn boxes, then at least one box contains at least two objects. Proof by contradiction, and that is the first point of the question: suppose no box contains two objects, that is, each box contains at most one. Then the total number of objects is at most 1+1+⋯+1=n1+1+\cdots+1=n, the sum running over the nn boxes. But this total is n+1n+1, and n+1>nn+1>n: a contradiction. So at least one box contains two objects. Remember the structure, it is the skeleton of all the following questions: negate the conclusion, the negation imposes an UPPER BOUND on each box, add up these bounds and end up with a total that is too small. The principle says nothing more, and above all it does not say WHICH box: it is a nonconstructive existence, exactly like the unsettled proof by cases of exercise 5.

b)

Generalized form: if mm objects are placed in nn boxes, then at least one box contains at least ⌈m/n⌉\lceil m/n \rceil objects, where ⌈⋅⌉\lceil \cdot \rceil denotes the ceiling function. Same proof: if every box contained at most ⌈m/n⌉−1\lceil m/n \rceil - 1 objects, the total would be at most n(⌈m/n⌉−1)n\left(\lceil m/n \rceil - 1\right), which is strictly less than mm since ⌈m/n⌉<mn+1\lceil m/n \rceil < \frac{m}{n}+1. A contradiction. Application: ⌈2,000/30⌉=⌈66.67⌉=67\lceil 2{,}000/30 \rceil = \lceil 66.67 \rceil = 67, so at least one folder contains 67 files or more. The pitfall, which costs a mark every time: writing 66, that is, taking the FLOOR, or worse the average 66.6766.67, which is the number of files in no folder at all. The bound is sharp, in the sense that a distribution exists with one folder at 67 and the others at 66 or 67: nothing stronger can be claimed.

c)

The objects are the frames and the boxes are the possible checksums. A 16-bit checksum takes 216=65,5362^{16}=65{,}536 values, whereas there are 210002^{1000} frames of 1,000 bits, an astronomically larger number. Since 21000>2162^{1000}>2^{16}, the pigeonhole principle applies: at least two distinct frames carry the same checksum. For the guarantee, 65,53765{,}537 distinct frames are enough, that is, 216+12^{16}+1: it is the smallest number that forces a collision, and with 65,53665{,}536 frames nothing is forced, since a one-to-one assignment remains conceivable. The practical consequence is the point to remember: a checksum NEVER proves that a frame is intact, it only makes it unlikely that an error goes unnoticed. No choice of checksum function changes that; it is a counting result, not a matter of algorithm quality.

d)

The objects are the nonempty subsets of the 10 chosen integers: there are 210−1=1,0232^{10}-1=1{,}023 of them. The boxes are the possible sums. The smallest sum is at least 1, and the largest is obtained with the ten largest integers available, 91+92+⋯+100=95591+92+\cdots+100=955. So there are at most 955 possible sums for 1,0231{,}023 subsets: two distinct subsets have the same sum. If these two subsets overlap, remove their intersection from both, which takes away the same amount on each side, and you get two DISJOINT subsets with the same sum, both nonempty since the sums were equal and the sets distinct. The strength of the result is that it holds for ANY choice of ten integers: no way to cheat by choosing them cleverly, even though no example would make it obvious.

e)

367 students are needed: the boxes are the 366 possible dates, February 29 included, and 366+1=367366+1=367 objects force a coincidence. The two results do not contradict each other at all; they do not answer the same question. The pigeonhole principle gives a worst-case CERTAINTY: with 367, no arrangement avoids the coincidence. The probability computation says that with 23 people the coincidence already has more than a one-in-two chance of happening, which is a statement about FREQUENCY and leaves entirely possible a group of 300 people whose dates are all distinct. Keeping the two registers apart is one of the most useful reflexes of the course: forced and probable are two different words, and confusing them leads to false sentences about computer security.

Exercise 7: Where induction stops, and what a variant proves

Mathematical induction is the fourth technique of the course outline. It has its own chapter in the course, with strong induction, sequences and recursion: we do not redo it here, we PLACE it among the five structures, that is, we learn to recognize the statements that call for it and those that do not.

A neighbouring principle serves in the same breath: every nonempty subset of N\mathbb{N} has a least element. It is called the well-ordering principle, it is equivalent to the principle of induction, and it is what proves that algorithms terminate.

  • a) Which of these statements call for induction? (i) for all n≥1n \geq 1, 1+2+⋯+n=n(n+1)21+2+\cdots+n=\frac{n(n+1)}{2}; (ii) 3\sqrt{3} is irrational; (iii) for all n≥0n \geq 0, 7n−17^{n}-1 is divisible by 6; (iv) among 13 integers, two have the same remainder modulo 12; (v) if n2n^{2} is divisible by 4, then nn is even.
  • b) The statement “the sum of the first nn odd integers is n2n^{2}” admits two proof structures. Give both, say which one is quicker to write, and check for n=6n=6.
  • c) Euclid's algorithm replaces the pair (a,b)(a, b) with (b,a mod b)(b, a \bmod b) until the remainder is zero. Prove that it terminates, then run it on (1,071,462)(1{,}071, 462), counting the divisions.
  • d) Would the same argument hold if the decreasing quantity were a positive rational number, for example 12n\frac{1}{2^{n}}?
  • e) Where does induction hide in the proof that 2\sqrt{2} is irrational in exercise 4?

Type your answers, the page tells you right or wrong 0/10

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) (i) and (iii) call for induction; (ii) contradiction, (iv) pigeonhole, (v) contrapositive
  • b) Induction or regrouping; regrouping takes one line, and 1+3+5+7+9+11=36=621+3+5+7+9+11=36=6^{2}
  • c) The remainder strictly decreases in N\mathbb{N}, so the algorithm terminates; 3 divisions and GCD =21=21
  • d) No: 12n\frac{1}{2^{n}} strictly decreases without ever stopping; the variant must be an integer
  • e) In choosing the fraction in lowest terms, which is well-ordering, so a forbidden infinite descent
a)

Statements (i) and (iii) call for induction, and they alone. The signal is twofold: the statement is INDEXED by an integer nn, and going from rank nn to rank n+1n+1 takes a small computation, here adding n+1n+1 to the sum, there factoring 7n+1−1=7(7n−1)+67^{n+1}-1=7(7^{n}-1)+6. Statement (ii) is an irrationality, so a contradiction, and nothing in it is indexed by an integer. Statement (iv) is an existence claim without construction: it is a pigeonhole case, 13 objects for 12 possible remainders. Statement (v) is an implication whose conclusion is easy to negate: it is a contrapositive, if nn is odd then n2n^{2} is odd, so not divisible by 4. This sorting is the central move of the chapter, and it is done by reading the FORM of the statement, never its subject: four of these five statements are about integers, and they call for three different structures.

b)

Structure 1, induction: at rank 1, 1=121=1^{2}; assuming 1+3+⋯+(2n−1)=n21+3+\cdots+(2n-1)=n^{2}, add the next term 2n+12n+1 to get n2+2n+1=(n+1)2n^{2}+2n+1=(n+1)^{2}, which is the statement at rank n+1n+1. Structure 2, a direct proof by regrouping: the sum of the first nn odd numbers is ∑k=1n(2k−1)=2×n(n+1)2−n=n2+n−n=n2\sum_{k=1}^{n}(2k-1)=2\times\frac{n(n+1)}{2}-n=n^{2}+n-n=n^{2}. The second one takes one line to write, provided you know the sum of the first integers. Check for n=6n=6: 1+3+5+7+9+11=36=621+3+5+7+9+11=36=6^{2}. The lesson is the thread of the set: induction is not compulsory just because a statement is about all integers, it is one choice among others, and it is often the longer of the two paths. Keep it for statements whose rank n+1n+1 can ONLY be computed from rank nn, typically recursively defined sequences, handled in the chapter devoted to them.

c)

The remainder r=a mod br=a \bmod b satisfies 0≤r<b0 \leq r < b: it is a natural number and it is STRICTLY less than the previous bb. The sequence of successive remainders is therefore a strictly decreasing sequence of natural numbers. Such a sequence cannot be infinite: the set of its values would be a nonempty subset of N\mathbb{N} with no least element, which contradicts the well-ordering principle. So the algorithm stops after finitely many steps. Run: 1,071=2×462+1471{,}071=2\times 462+147, then 462=3×147+21462=3\times 147+21, then 147=7×21+0147=7\times 21+0. Three divisions, and the last nonzero remainder, 21, is the GCD. Check: 1,071=21×511{,}071=21\times 51 and 462=21×22462=21\times 22, and 5151 and 2222 are relatively prime. The decreasing quantity has a name, the variant, and exhibiting it is the whole termination proof: that is what is asked for on a test, not a sentence such as “clearly it ends”.

d)

No, and that is precisely where the difference between N\mathbb{N} and Q\mathbb{Q} comes into play. The sequence 12n\frac{1}{2^{n}} is strictly decreasing, strictly positive, and yet infinite: it never stops. So the termination argument does not rest on the decrease, it rests on the fact that the variant lives in N\mathbb{N}, where there is no room for an infinite descent. The practical consequence in programming: to prove that a loop terminates, exhibit a positive INTEGER quantity that strictly decreases at each iteration. A decreasing real quantity proves nothing, and it is the source of a classic family of infinite loops, the ones that wait for a floating-point number to reach exactly zero.

e)

It hides in the sentence “the fraction can always be chosen in lowest terms”. That sentence is a consequence of well-ordering: among all the ways of writing the same number as ab\frac{a}{b} with b>0b>0, there is one whose denominator is the SMALLEST, and that is the one you take. You can in fact write the proof without ever mentioning lowest terms; this is infinite descent: if 2=ab\sqrt{2}=\frac{a}{b}, you build cd\frac{c}{d} with d<bd<b representing the same number, then start again, and you get an infinite strictly decreasing sequence of natural numbers, which well-ordering forbids. Induction, well-ordering and infinite descent are three formulations of the same principle, and being able to move from one to another is what lets you recognize an induction in disguise in a statement that does not look like one.

Exercise 8: Five claims to correct

Each of the following five claims is FALSE. Say why and give the correct statement.

  • 1) “The contrapositive of a statement is its converse.”
  • 2) “A well-chosen example is enough to prove a universal statement.”
  • 3) “Proof by contradiction and proof by contrapositive are the same thing.”
  • 4) “Induction proves the base case.”
  • 5) “The pigeonhole principle says which box contains two objects.”

Type your answers, the page tells you right or wrong 0/7

1)
2)
3)
4)
5)
Show the solution

Answers

  • 1) The contrapositive is ¬Q⇒¬P\lnot Q \Rightarrow \lnot P, always equivalent; the converse Q⇒PQ \Rightarrow P is independent
  • 2) An example proves only an existence statement; F5F_{5}, composite after five prime cases, is the reminder
  • 3) The contrapositive assumes ¬Q\lnot Q alone; contradiction assumes PP and ¬Q\lnot Q and aims for any contradiction
  • 4) Induction requires the base case, it does not prove it; the inductive step alone proves nothing
  • 5) The principle asserts that some box contains two objects, without saying which box or which objects
1)

FALSE, and it is the costliest confusion of the chapter. The contrapositive of P⇒QP \Rightarrow Q is ¬Q⇒¬P\lnot Q \Rightarrow \lnot P; its converse is Q⇒PQ \Rightarrow P. The first ALWAYS has the same truth value as the statement, the second has no link with it: on the four rows of the truth table in exercise 2, the converse differs from the statement on two rows, one in two. An example that settles it: “if nn is divisible by 6 then nn is divisible by 3” is true, its contrapositive “if nn is not divisible by 3 then nn is not divisible by 6” is true as well, and its converse “if nn is divisible by 3 then nn is divisible by 6” is false, as n=9n=9 shows. Correct statement: the contrapositive of a statement is equivalent to it; its converse is an independent proposition that needs its own proof.

2)

FALSE, and no choice of example changes that. A universal statement covers infinitely many cases, and a finite list never exhausts them. The story of the Fermat numbers in exercise 5 shows it starkly: five cases checked, F0F_{0} to F4F_{4}, all prime, and the sixth, F5=4,294,967,297=641×6,700,417F_{5}=4{,}294{,}967{,}297=641\times 6{,}700{,}417, is composite. The asymmetry between the two directions is total: to DISPROVE a universal statement, a single counterexample is enough and closes the question; to PROVE it, you need a structure valid for all cases at once. Correct statement: an example illustrates, it does not prove, except for an EXISTENCE statement, where exhibiting an object really is a complete proof.

3)

FALSE, even though both begin by assuming the conclusion is false. The contrapositive assumes ¬Q\lnot Q ALONE and aims for exactly ¬P\lnot P: nothing false is assumed, and it applies only to implications. Contradiction assumes PP AND ¬Q\lnot Q, hence the complete negation of the implication, and aims for any contradiction; it applies to any statement, including those that are not implications, such as the irrationality of 2\sqrt{2} or the infinitude of the primes. Correct statement: the contrapositive is a very disciplined special case, contradiction is more general and more dangerous, since you reason in a false world where the slightest computational error produces a contradiction that looks like a conclusion.

4)

FALSE: induction does NOT prove the base case, it REQUIRES it. Its two steps are the base case, where you check the property at the first rank, and the inductive step, where you prove that rank nn implies rank n+1n+1. The inductive step alone proves nothing: the property “n=n+1n=n+1” passes from each rank to the next, since n=n+1n=n+1 yields n+1=n+2n+1=n+2, and it is false at every rank, for lack of a base case. Conversely, a base case alone proves only one case. Correct statement: induction proves the statement at every rank from the verified base case on, and that base case must be established separately. The chapter of this course devoted to induction details both pitfalls, along with strong induction and recursively defined sequences.

5)

FALSE, and that is precisely what the principle does NOT say. The pigeonhole principle guarantees the EXISTENCE of a crowded box, without ever designating which one or exhibiting the two objects: it is a nonconstructive existence proof, of the same type as the unsettled proof by cases of exercise 5. In the checksum question, we know that two 1,000-bit frames share a 16-bit checksum, and that certainty provides no means of finding such a pair. That is why computer security relies on the DIFFICULTY of exhibiting a collision and not on its absence, which is impossible. Correct statement: the pigeonhole principle asserts that some box contains at least two objects, and it gives neither the box nor the objects.

Exercise 9: Problem: no lossless compressor shrinks every file

A lossless compressor is a program that 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. The figure sets up the count that will settle the matter.

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

sequencesof 10 bitssequences oflength 0 to 9compression
  • a) How many 10-bit sequences are there?
  • b) How many bit sequences are there with length between 0 and 9?
  • c) What does “lossless” mean for the function that sends a file to its compressed version?
  • d) Conclude, and name precisely the proof structure or structures used.
  • e) What would happen if the announced compressor were applied twice, then three times, then nn times? And why do real compressors work anyway?

Type your answers, the page tells you right or wrong 0/7

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) 210=1,0242^{10}=1{,}024 sequences of 10 bits
  • b) 210−1=1,0232^{10}-1=1{,}023 sequences of length 0 to 9
  • c) Lossless means injective: two distinct files cannot give the same compressed version
  • d) 1,0241{,}024 objects for 1,0231{,}023 boxes: the announced compressor does not exist. Contradiction plus pigeonhole, on a count
  • e) After ten applications every file would be 0 bits long; real compressors lengthen files without structure
a)

Each bit takes two values and the choices are independent, so there are 210=1,0242^{10}=1{,}024 sequences of 10 bits. That is the multiplication principle, and it is the only counting computation in the whole problem.

b)

There is 20=12^{0}=1 sequence of length 0, the empty sequence, then 21=22^{1}=2 sequences of length 1, and so on up to 29=5122^{9}=512 sequences of length 9. The total is 1+2+4+⋯+512=210−1=1,0231+2+4+\cdots+512=2^{10}-1=1{,}023, by the sum of a geometric sequence with ratio 2. This number deserves a look: all the sequences shorter than 10 bits, ALL lengths combined, are fewer than the 10-bit sequences alone. It is this one-unit inequality that will do all the work, and it is no accident of the example: 20+⋯+2n−1=2n−12^{0}+\cdots+2^{n-1}=2^{n}-1 for every nn.

c)

“Lossless” means that decompression recovers the original file, so two DIFFERENT files cannot give the same compressed version: otherwise the decompressor, faced with that compressed version, would not know which of the two to return. The function that sends a file to its compressed version is therefore INJECTIVE. That is the whole translation of the problem, and it is the step students skip: the word “injective” does not appear in the company's claim, it has to be produced by reading. Without it, the counts of questions a) and b) are useless.

d)

Suppose, for the sake of contradiction, that the announced compressor exists. It sends each of the 1,0241{,}024 sequences of 10 bits to a strictly shorter sequence, so one of length between 0 and 9, and there are 1,0231{,}023 of those. We place 1,0241{,}024 objects in 1,0231{,}023 boxes: by the pigeonhole principle, two distinct 10-bit sequences receive the same compressed version. This contradicts the injectivity established in c), so the announced compressor does not exist. The structures used are therefore TWO, nested: a proof by contradiction whose contradiction is produced by the pigeonhole principle, the whole thing resting on a count. It is the most frequent pattern of impossibility proofs in computer science, and it is worth remembering as is: assume the object, count what it would have to tell apart, and observe that there are more objects than places.

e)

If such a compressor existed, applying it nn times would reduce any 10-bit file to a length of at most 10−n10-n bits, so after ten applications to 0 bits, the empty sequence. All the files would have become the same, and no decompression could tell them apart: it is the same contradiction, in a more spectacular form. Real compressors work because they do NOT claim to shrink every file: they shrink the ones that carry structure, text, images, server logs, and they ENLARGE the others by a few bits, which you can see by compressing an already compressed file or a sequence of random bits. So the theorem does not say that compression is useless, it says that it is a trade-off: what is gained on frequent files is lost on rare files, and the average gain depends entirely on the actual distribution of files, never on the algorithm alone.

Exercise 10: Problem: four write-ups of the same proof, only one holds

A server gives each visitor a session ID written with 3 hexadecimal digits, drawn at random. It served 5,000 sessions during the day. The statement to prove is: at least two sessions received the same ID.

Four students hand in four write-ups. R1: “since two sessions have the same ID, there are more sessions than IDs, so two sessions have the same ID”. R2: “I simulated the day in Python and found two identical sessions, so it is proved”. R3: “if two sessions have the same ID, then there are more sessions than IDs; that is indeed the case here, so two sessions have the same ID”. R4: “there are 4,096 possible IDs; there are 5,000 sessions, so more of them; by the pigeonhole principle, at least two sessions carry the same ID”.

  • a) How many distinct IDs are there? From how many sessions on is a repetition certain? At least how many sessions share the same ID?
  • b) Say which of the four write-ups is valid and name the mistake in each of the other three.
  • c) Write out the proof, showing the four elements a marker looks for.
  • d) The developer replies that switching to 4 hexadecimal digits is enough. Does that remove the risk of a collision?
  • e) What would have to change to guarantee that there is no collision, and what proof structure would that then require?

Type your answers, the page tells you right or wrong 0/10

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) 163=4,09616^{3}=4{,}096 IDs; certainty from 4,0974{,}097 sessions on; ⌈5,000/4,096⌉=2\lceil 5{,}000/4{,}096 \rceil = 2 sessions at least
  • b) R4; R1 is circular, R2 reasons by example, R3 proves the converse
  • c) Starting point with numbers, technique named, chain of reasoning, conclusion that restates the claim
  • d) No: 164=65,536>5,00016^{4}=65{,}536>5{,}000 removes the certainty, not the risk
  • e) A counter instead of a random draw, and a direct proof of injectivity instead of a count
a)

A hexadecimal digit takes 16 values, so three digits give 163=4,09616^{3}=4{,}096 distinct IDs. A repetition becomes certain from 4,0974{,}097 sessions on, by the simple form of the pigeonhole principle. With 5,0005{,}000 sessions, the generalized form confirms it, without giving more: at least one ID is carried by ⌈5,000/4,096⌉=2\lceil 5{,}000/4{,}096 \rceil = 2 sessions. This 2 is indeed the ceiling of 1.221.22, and not 1: that is why rounding is never to the nearest integer in this kind of question. Note that the conclusion looks weak, only two sessions, whereas a probability computation would predict a very large number of collisions; but it has a quality that probability lacks: it is CERTAIN.

b)

R4 is the only valid one. R1 is CIRCULAR: it begins by assuming what it wants to prove, “since two sessions have the same ID”, so its conclusion rests on nothing. It is the hardest mistake to spot when proofreading, because the text reads very smoothly. R2 reasons BY EXAMPLE: a simulation exhibits one case, and one case does not prove a statement about every possible day; besides, if the simulation had found nothing, that would not have disproved anything either. R3 proves the CONVERSE: the implication it establishes goes from the collision to the count, whereas it should go from the count to the collision, and the sentence “that is indeed the case here” then applies the implication backwards, which is the mistake of affirming the converse from exercise 2. Three STRUCTURE mistakes, no computational mistake: that is the chapter in a nutshell.

c)

Expected write-up. First element, the starting point: the IDs are written with 3 hexadecimal digits, so there are 163=4,09616^{3}=4{,}096 of them, and the server served 5,0005{,}000 sessions. Second element, the technique, named: apply the pigeonhole principle, the objects being the sessions and the boxes the possible IDs. Third element, the chain of reasoning: since 5,000>4,0965{,}000>4{,}096, there are strictly more objects than boxes, so at least one box contains two objects. Fourth element, the conclusion that restates the claim: at least two sessions received the same ID. Four sentences, and each one is worth marks. What does NOT count as a written proof: a sequence of correct computations without the sentence that names the technique, and a conclusion that stops at “so a collision” without coming back to the sessions of the statement.

d)

No, it does not remove the risk, it only removes the CERTAINTY. With 4 hexadecimal digits there are 164=65,53616^{4}=65{,}536 IDs for 5,0005{,}000 sessions, so more boxes than objects, and the principle no longer applies: it concludes nothing. But concluding nothing is not concluding that there is no collision. Since the IDs are drawn at random, a collision remains possible, and the birthday paradox computation, covered in the counting and probability set of the course, even shows that it is likely long before the number of IDs is reached. It is the most common misreading of the pigeonhole principle: it gives a SUFFICIENT condition for a collision, never a necessary one, and its negation says nothing.

e)

You would have to stop drawing at random and assign the IDs with a COUNTER that increments, or with any process that never assigns the same value twice. The proof structure would then change completely: you would no longer count, you would prove that the function from sessions to IDs is injective, which is done by a direct proof, or by contrapositive in the form “if two sessions have the same ID, then they have the same counter number, so they are the same session”. You would gain the guarantee and lose the unpredictability, which is exactly what you want for a session ID: a counter can be guessed, and guessing another visitor's ID is a security hole. The real engineering answer is therefore to lengthen the ID until a collision becomes negligible, accepting that it remains possible, which is exactly what this chapter teaches you to say correctly.

Something missing from this set? A type of exercise your teacher gives, a problem you are stuck on, 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 chapter Boolean and mathematical logic, 201-N11 Next chapter Number systems in computing, 201-N11

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

See also

Looking for a discrete mathematics 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