COMPSCI 120:
Mathematics for Computer Science

Proofs

Exercise 7.1. You’re about to leave on holiday, but you forgot to pack socks! You’ve ran back to your room, but the light’s burnt out, so you can’t see the colours of your socks.

You know that in your sock drawer that there are ten pairs of green socks, ten pairs of black socks, and eleven pairs of blue socks (all mixed up.)

How many of your socks do you need to take before you can be sure you’ve grabbed at least one matching pair?

Exercise 7.2. You’re a mad scientist! You’ve conducted an experiment on yourself to get superpowers. It worked, but to keep the powers you need to take two different tablets each day; if you forget one, or take more than one of either type, you’ll, um, explode.

Unfortunately, they look completely identical, and you’ve just dropped your last two days of supply (four tablets) on the floor.

What can you do?

Proofs: Motivation and Fundamentals

Throughout this coursebook, we’ve stressed the importance of clear, logical explanations for why things are true. In our previous chapters, we motivated the need for these arguments in a number of ways:

These motivations aren’t just hypotheticals! Here’s a pair of stories that illustrate why knowing how to make logical arguments is a useful skill:

Story 7.1. Janelle Shane is a researcher in optics who works with neural networks and machine learning. Roughly speaking, the way that a neural network works is the following:

“Show” is hard to define in words, but there are some great YouTube videos: see SethBling’s Mar I/O videos for a fun and accessible introduction!

People are often tempted to just use the results of a neural network directly, without checking whether its discovered rules make sense. Doing so, as Janelle notes, leads to some fascinatingly weird behaviour:

In short: just because something works for a bunch of examples doesn’t mean it’s good!

Story 7.2. A somewhat darker story on the importance of being able to read and understand proofs comes from the NSA, and something called a Dual Elliptic Curve Deterministic Random Bit Generator. This was an algorithm, designed by the NSA (a USA security agency,) that they claimed was a cryptographically secure way to generate random numbers.

However, this algorithm was one that the NSA had built a “backdoor” into. That is, they designed the algorithm around certain secret values so that anyone with knowledge of those values (i.e. the NSA) could predict the randomly-generated numbers with a higher-than-normal degree of accuracy and thereby defeat cryptographic systems using this algorithm.

The NSA managed to get their algorithm used as a “standard” for over seven years. However, many mathematicians and computer scientists were suspicious of the NSA’s algorithm from the very start, in large part because it was not something that was proven to work! Their research led to the eventual revocation of the NSA’s algorithm as a standard.

See the New York Times for an article summarizing the scandal.

Also, check out Kleptography: Using Cryptography Against Cryptography and Cryptanalysis of the Dual Elliptic Curve Pseudorandom Generator, if you’d like to read through some research papers describing the NSA’s algorithm/its weaknesses.

So: we have some motivation for why we would want to write clear, logical arguments. The next question for us, then, is what counts as a valid argument?

Every major field of study in academia, roughly speaking, has a way of “showing” that something is true. In English, if you wanted to argue that the whale in Melville’s Moby Dick was intrinsically tied up with mortality, you would write an essay that quoted Melville’s story alongside some of of his other writings and perhaps some contemporary literature, and logically argue (using these quotations as “evidence”) that your claim holds. Similarly, if you were a physicist and you wanted to show that the speed of light is roughly 3.01083.0 \cdot 10^8 meters per second, you’d set up a series of experiments, collect data, and see if it supports your claim.

In mathematics, a proof is an argument that mathematicians use to show that something is true. However, the concepts of “argument” and “truth” aren’t quite as precise as you might like; certainly, you’ve had lots of “arguments” with siblings or classmates that haven’t proven something is true!

In mathematics, the same sort of thing happens: there are many arguments that (to an outsider) look like a convincing reason for why something is true, but fail to live up to the standards of a mathematician. In Chapter 1, we already studied a pair of “failed” proofs: namely, our first attempts at proving Claim 1.1 and Exercise 1.1. We said that these arguments failed because they did not work in general: that is, they only considered a few cases, and did not consider all of the possible ways to put dominoes on a chessboard, or to pick a pair of integers.

This, however, is not the only way in which a proof might fail us! Here’s another dodgy proof:

Claim 7.1.Link copied Given any two nonnegative real numbers x,yx, y , we have x+y2xy\frac{x+y}{2} \geq \sqrt{xy} .

“Bad” proof:

xyx+y2xy(x+y)244xy(x+y)24xyx2+2xy+y20x22xy+y20(xy)2.\begin{array}{rl} \sqrt{xy} &\leq \frac{x+y}{2} \\ xy &\leq \frac{(x+y)^2}{4} \\ 4xy &\leq (x+y)^2 \\ 4xy &\leq x^2 + 2xy + y^2\\ 0 &\leq x^2 - 2xy + y^2 \\ 0 &\leq (x-y)^2.\\ \end{array} \square

A defense of the “bad” proof: We’re not using examples; we’re working in general! Also, we totally showed that this claim is true: after all, we started with our claim and turned it into a true thing!

Why this proof is not acceptable in mathematics:

1=201=020=0.\begin{array}{ll} & 1 = 2 \\ \Rightarrow & 0 \cdot 1 = 0 \cdot 2 \\ \Rightarrow & 0 = 0. \\ \end{array}

This doesn’t prove that 1=2, though! As we said above, proofs need to start with true things, and then through argument get to what you’re trying to show.

This sort of thing is often easy to fix, though! If your proof is “backwards,” simply try starting from the end and reasoning your way backwards to the start. If your logic was flawed, somewhere along the way you’ll encounter a nonreversible step.

For example, if we tried to reverse our proof that 1=21=2 , we could go from 0=00=0 to 01=020 \cdot 1 = 0 \cdot 2 , but would see that we can’t “divide by 0” to get to the desired conclusion (and thus that this doesn’t work.)

With this in mind, let’s try a “fixed” version of this proof:

Theorem 7.1. (The arithmetic mean-geometric mean inequality.) For any two nonnegative real numbers x,yx,y , we have that the geometric mean of xx and yy is less than or equal to the arithmetic mean of xx and yy : in other words, we have that

xyx+y2\sqrt{xy} \leq \frac{x+y}{2}

Proof. Take any pair of nonnegative real numbers x,yx,y . We know that any squared real number is nonnegative: so, in specific, we have that the square of xyx-y , (xy)2(x-y)^2 is nonnegative. If we take the equation 0(xy)20 \leq (x-y)^2 and perform some algebraic manipulations, we can deduce that

0(xy)20x22xy+y24xyx2+2xy+y24xy(x+y)2xy(x+y)24.\begin{array}{rl} 0 &\leq (x-y)^2\\ \Rightarrow 0 &\leq x^2 - 2xy + y^2 \\ \Rightarrow 4xy &\leq x^2 + 2xy + y^2\\ \Rightarrow4xy &\leq (x+y)^2 \\ \Rightarrow xy &\leq \frac{(x+y)^2}{4}. \\ \end{array}

Because xx and yy are both nonnegative, we can take square roots of both sides to get

xyx+y2.\sqrt{xy} \leq \frac{|x+y|}{2}.

Again, because both xx and yy are nonnegative, we can also remove the absolute-value signs on the sum x+yx+y , which gives us

xyx+y2,\sqrt{xy} \leq \frac{x+y}{2},

which is what we wanted to prove.

\square

Much better! This proof doesn’t have logical flaws, it’s easier to read, and we’ve justified all of our steps so that even a skeptical reader would believe us.

Direct Proofs

In our past chapters, we’ve seen a number of useful techniques for writing such arguments while studying new mathematical concepts. In this chapter, we’re reversing this structure a bit: instead of focusing on new mathematics, we’re going to focus our sections on new argument techniques. By doing this, we’re hoping that the arguments you’ve been reading in the past few chapters will become ones that you’re comfortable with writing and reading on your own!

The proof we just wrote serves as a nice example of the first proof technique we’ll study in this class: the idea of a direct proof. To prove that a given claim is true, the most straightforward path we’ve used in this class has been the following:

A particularly common form of direct proof comes up when people want to prove a statement of the form “if A holds, then B must follow” for two propositions A and B (or equivalently, “A implies B,” which we write in symbols as ABA \Rightarrow B .)

To write a direct proof of such a statement, we proceed as before, but also throw in the assumption that A holds! That is, to prove “A implies B,” we assume thaat A is true, and try to combine this assumption with other known true things to deduce that B is true. (Logically speaking, this is because ABA \Rightarrow B holds as long as we’re never in the situation where AA is true and BB is false. Therefore, if we can show that AA being true forces BB to also be true, then we know that our claim must hold!)

We illustrate this with a pair of examples here:

Claim 7.2.Link copied If nn is an odd integer, then n2n^2 can be written as a multiple of 4 plus one.

Proof. We start by “assuming” the part by the “if:” that is, we assume that nn is an odd integer. By definition, this means that we can write n=2k+1n = 2k+1 for some other integer kk .

We seek to study n2n^2 . By our observation above, this is just (2k+1)2=4k2+4k+1=4(k2+k)+1(2k+1)^2 = 4k^2 + 4k+1 = 4(k^2+k)+1 . This is a multiple of 4 plus 1, as claimed! Therefore we have completed our proof.

\square
Claim 7.3.Link copied If GG is a graph, then GG must have an even number of vertices with odd degrees; that is, it is impossible to have a graph GG with an odd number of vertices with odd degrees.

Proof. We start this proof by thinking about all of the facts that we know about graphs and degrees. There’s one result that should immediately jump to mind, namely the degree-sum formula: for any graph GG ,

The sum of the degreesof the vertices in G\boxed{\begin{array}{c} \textrm{The sum of the degrees} \\ \textrm{of the vertices in G} \\ \end{array}} =Twice the numberof the edges in G\boxed{\begin{array}{c} \textrm{Twice the number} \\ \textrm{of the edges in G} \\ \end{array}}

Let’s use this result! Specifically: in this problem, we’re studying vertices with odd degree. How can we turn this result into something that talks about odd-degree vertices? Well: from our work in our first chapter, we know that every integer is either even or odd. If we apply this idea to our degree-sum formula, we get the following:

The sum of theodd degrees ofvertices in G\boxed{\begin{array}{c} \textrm{The sum of the} \\ \textbf{odd}\textrm{ degrees of} \\ \textrm{vertices in G} \\ \end{array}} +The sum of theeven degrees ofvertices in G\boxed{\begin{array}{c} \textrm{The sum of the} \\ \textbf{even}\textrm{ degrees of} \\ \textrm{vertices in G} \\ \end{array}} =Two times thenumber of theedges in G\boxed{\begin{array}{c} \textrm{Two times the} \\ \textrm{number of the} \\ \textrm{edges in G} \\ \end{array}}

We wanted to study the odd-degree vertices, so let’s get them isolated on one side of our equation:

The sum of theodd degrees ofvertices in G\boxed{\begin{array}{c} \textrm{The sum of the} \\ \textbf{odd}\textrm{ degrees of} \\ \textrm{vertices in G} \\ \end{array}} =Two times thenumber of theedges in G\boxed{\begin{array}{c} \textrm{Two times the} \\ \textrm{number of the} \\ \textrm{edges in G} \\ \end{array}} -The sum of theeven degrees ofvertices in G\boxed{\begin{array}{c} \textrm{The sum of the} \\ \textbf{even}\textrm{ degrees of} \\ \textrm{vertices in G} \\ \end{array}}

On the right-hand side, notice that we have an even number (twice the number of edges) minus a bunch of even numbers (the degrees of all even-degree vertices in GG ); therefore, the right-hand-side is even!

As a result, the left-hand-side is also even. But this means that the sum of all odd-degree vertices is an even number.

We know that summing an odd number of odd numbers is always odd, and that summing an even number of odd numbers is always even. Because the left-hand side is even, we know we must be in the second case; that is, that we have an even number of vertices of odd degree, as claimed!

\square

Proof by Cases

Our second proof technique is best illustrated by an example:

Theorem 7.2. For every natural number nn , if nn is a square number, then n≢2mod3n \not\equiv 2 \mod 3 .

An integer nn is said to be a square number if we can write n=k2n = k^2 for some other integer kk . For example, 0,1,4,9,16,250,1,4,9,16,25\ldots are all square numbers!

Proof. As always, we start by expanding our definitions. If nn is a square number, then by definition we know that n=k2n = k^2 for some integer kk .

From here, we use the particularly clever trick that this section is devoted to: we consider cases. That is: we want to look at what nn is congruent to modulo 3.

We don’t have any information about what nn or kk theirselves are modulo 3, so it would seem hard to introduce this information into our proof! However, by the definition of the modulus operator %\% , we know that every number is congruent to one of 0, 1 or 2 modulo 3. By definition, then, this means that we most always be in one of the following three cases:k0mod3k \equiv 0 \mod 3 , k1mod3k \equiv 1 \mod 3 or k2mod3k \equiv 2 \mod 3 .

In each of these cases, we can now expand our definitions and use our knowledge of modular arithmetic to proceed further:

In all three of these cases, we’ve seen that n=k2n = k^2 is not congruent to 2 modulo 3. These cases cover all of the possibilities! Therefore, we know that nn is simply never congruent to 2 modulo 3 in any situation, and have therefore proven our claim.

\square

The trick to the proof above was that we were able to introduce additional information about kk (namely, its remainder on division by 3) by simply considering all possible remainders as separate cases! This technique, called proof by cases, is a powerful technique in several situations:

We practice this in the examples below:

Claim 7.4.Link copied For any real number xx , we claim that x+7x7|x+7| - x \geq 7 .

Proof by cases is an excellent technique whenever you see an absolute value, as it lets you get rid of the absolute value in each case.

Proof. We proceed by considering cases:

Because every number is either greater than or equal to 7 or less than 7, we’ve considered all possible cases. As our claim was true in each possible case, this completes our proof!

\square
Claim 7.5.Link copied For every two numbers x,yx,y , we always have that max(x,y)+min(x,y)=x+y\max(x,y) + \min(x,y) = x+y .

_Proof._We consider two possible cases:

This covers all possible cases, as for any two numbers x,yx,y either x>yx > y or xyx \leq y ! Therefore, we’ve proven our claim.

\square

In the next example, we return to the tricks we used to calculate the last digit of a number in Claim 1.10:

Claim 7.6.Link copied For any integer kk , we have that (k4)%10(k^4) \% 10 is always either 0, 1, 5, or 6.

Proof by cases is also usually a good idea if you see the modulus operator!

Proof. We saw before in our chapter on integers that if d0d_0 is the last digit of an integer nn , then nm%10n^m \% 10 is equal to d0m%10d_0^m \% 10 for any positive integer power mm .

Therefore, in our claim, we don’t have to actually consider every possible integer kk ; we can just consider the ten different possible last digits kk could have, and calculate the cubes of each of those! We do so here:

In all ten cases, our remainders are always 0, 1, 5, or 6, as claimed! Therefore, we’ve proven our claim.

\square

Finally, we can use a proof by cases to prove one of our exercises:

Answer to Exercise 7.1. Even though there are lots of socks in the drawer, there are only 3 colours. Therefore, we can just take 4 socks to make sure that at least 2 of them are the same colour. To understand why, let’s look at the colours of three first socks.

There are two possible cases here:

In this case, however, our fourth sock is guaranteed to match at one of our three previously chosen socks!

In any case, we’ve grabbed a pair of socks, as desired.

Proof by Contradiction

Contradiction - i.e. the “if we’re stuck on a problem, suppose we’re wrong and see what happens” proof technique --- is a method we’ve already used to considerable success throughout this coursebook! In this section, we study several more examples of proof by contradiction, and talk a bit about the trickier aspects of this proof method.

To start, let’s examine one of the most famous proofs by contradiction! In this proof, we’re going to really pick apart the structure of a proof by contradiction, so that we can see why this method works:

Claim 7.7.Link copied The number 2\sqrt{2} is not rational.

Proof. As always, let’s start by unpacking our definitions:

With this done, our claim can be unpacked to the following:

“For a real number xx , if x=2x = \sqrt{2} , then there are no values of m,nZm, n \in \mathbb{Z} with n0n \neq 0 such that x=mnx = \frac{m}{n} .”

So: how do we do this? Because the problem wants us to show that we cannot write 2=mn\sqrt{2} = \frac{m}{n} for any integers m,nm, n with n0n \neq 0 , we can’t just check a few examples: we’d have to look at all of them, and this could be quite difficult! We’d have to find some useful property that makes all examples of this form fail, and this could be quite hard to find.

Instead, consider the following way to “side-step” these difficulties. Instead of looking at all pairs m,nm, n and trying to show that each one fails, let’s assume that we have one such pair m,nm, n such that 2=mn\sqrt{2} = \frac{m}{n} !

With this assumption in hand, let’s now show that this assumption “breaks mathematics” in some way: that starting from this assumption, we can get to something we know is impossible, like 1+1=01+1=0 . If we can do this, then we know that our original assumption that there was such a fraction mn\frac{m}{n} must have been nonsense (i.e. false), and therefore that our claim that no such fraction exists is true!

We do this here. Suppose that we can find two integers m,nm, n with n0n \neq 0 such that 2=mn\sqrt{2} = \frac{m}{n} . If mm and nn have common factors, divide through by those factors to write mn\frac{m}{n} in its simplest possible form: that is, don’t write something like 36\frac{3}{6} or 1224\frac{12}{24} , write 12\frac{1}{2}

Then if we square both sides, we get 2=m2n22 = \frac{m^2}{n^2} . Multiplying both sides by n2n^2 gives us 2n2=m22n^2 = m^2 , which means that m2m^2 is even (because it is a multiple of 2)!

This means that mm is even (see the tutorials from earlier in this course!), and therefore that we can write m=2km = 2k for some integer kk . If we plug this into our equation 2n2=m22n^2 = m^2 , we get 2n2=(2k)2=4k22n^2 = (2k)^2 = 4k^2 , and by dividing by 22 we have n2=2k2n^2 = 2k^2 .

This means that n2n^2 is even, and therefore that nn is even as well (same logic as before.)

But this means that both nn and mm are multiples of 2; that is, that they have a common factor! We said earlier that we’d divided through by any common factors to get rid of them, so this is a contradiction: from our initial assumption we got to something that is both true and false. As a result, our original assumption (that we could write 2=mn\sqrt{2} = \frac{m}{n} ) must be false; that is, we have shown that 2mn\sqrt{2} \neq \frac{m}{n} for any integers m,nm, n with n0n \neq 0 , as desired. Yay!

\square

We can generalize the form of the argument we just made above as follows:

This is how a proof by contradiction works. You take your claim PP , assume it’s false, and use “not PP ” to deduce contradictory statements, which you know mathematics cannot contain.

A beautiful quote about proofs by contradiction, by the mathematician G. H. Hardy: “Proof by contradiction”, which Euclid loved so much, is one of a mathematician’s finest weapons. It is a far finer gambit than any chess gambit: a chess player may offer the sacrifice of a pawn or even a piece, but a mathematician offers the game.

We consider another example here:

Claim 7.8.Link copied There are two irrational numbers aa and bb such that aba^b is rational.

Proof. In the example we’re studying here, we want to show that it’s impossible for aba^b to be irrational for every pair of irrational numbers a,ba,b . To do this via a proof by contradiction, we do the following: first, assume that aba^b is irrational for every pair of irrational numbers a,ba,b ! If we apply this knowledge to one of the few numbers (2\sqrt{2} ) we know is irrational, our assumption tells us that in specific

22\sqrt{2}^{\sqrt{2}} is irrational.

What do we do from here? Well: pretty much the only thing we have is our assumption, our knowledge that 2\sqrt{2} is irrational, and our new belief that 22\sqrt{2}^{\sqrt{2}} is also irrational. The only thing really left to do, then, is to let a=22a = \sqrt{2}^{\sqrt{2}} , b=2b = \sqrt{2} , and apply our hypothesis again. But this is excellent! On one hand, our we have that aba^b is irrational by our hypothesis. On the other hand, we have that aba^b is

(22)2=222=22=2,(\sqrt{2}^{\sqrt{2}})^{\sqrt{2}} = \sqrt{2}^{\sqrt{2} \cdot \sqrt{2}} = \sqrt{2}^2 = 2,

which is clearly rational. This is a contradiction! Therefore, we know that our hypothesis must be false: there must be a pair of irrational numbers a,ba,b such that aba^b is rational.

\square

An interesting quirk of the above proof is that it didn’t actually give us a pair of irrational numbers a,ba,b such that aba^b is rational! It simply told us that either

but it never actually tells us which pair satisfies our claim! This is a weird property of proofs by contradiction: they are often nonconstructive proofs, in that they will tell you that a statement is true or false without necessarily giving you an example that demonstrates the truth of that statement.

To stick with the classical route, let’s study another one of the first proofs by induction, that we considered all the way back in our first chapter:

Claim 7.9.Link copied (Euclid) There are infinitely many prime numbers.

Proof. As we did with our argument that no number can be both even and odd at the same time, let’s approach this with a bit of a thought experiment: what would happen if there were not infinitely many prime numbers?

Well: if this were to happen, then there would be some fixed number of primes in existence. Let’s give that number a name, and say that there were nn primes in existence. Then, if we had a piece of paper with nn lines on it, we could in theory write down all of the prime numbers that existed!

If we labeled those lines 1,2,n1,2,\ldots n , we could then refer to those prime numbers by their labels: that is, we could refer to our prime numbers by calling them p1,p2,p3,pnp_1, p_2, p_3, \ldots p_n . (Giving things names: a very useful technique!)

In this world where we have all of these prime numbers, what can we do with them? Well: as we saw before, a particularly useful property about prime numbers is that they form the building blocks out of which we can make all integers. Therefore, we’re motivated to take our primes and stick them together, and see what happens!

After a lot of effort, you might eventually hit on the clever combination of our prime numbers that Euclid discovered: think about what happens if we multiply all of our prime numbers together, and then add 1 to that entire sum. That is: look at the number

M=1+(p1p2p3pn)M = 1 + (p_1 \cdot p_2 \cdot p_3 \cdot \ldots \cdot p_n)

On one hand: take any of the prime numbers on our list. To indicate that we’re taking a general prime number from our list, let’s refer to that prime number as pip_i , where ii could be any index. Look at Mpi\frac{M}{p_i} . By definition, this is equal to

1pi+(p1p2pnall of the primes except for pi).\frac{1}{p_i} + \left(\overbrace{p_1 \cdot p_2 \cdot \ldots \cdot p_n}^{\textrm{all of the primes except for }p_i}\right).

In particular, notice that this is not an integer! 1pi\frac{1}{p_i} is some fraction strictly between 0 and 1, because pip_i is a prime and therefore at least 2, while the right-hand-bit is a product of integers and therefore is an integer itself.

Therefore, we’ve shown that if we multiply pip_i by a number to get MM , that number cannot be an integer; in other words, we have shown that pip_i is not a factor of MM . This holds for any of our primes, because pip_i was an arbitrary prime; therefore MM is not a multiple of any of our prime numbers!

On the other hand, though, we know that MM is an integer. Therefore, we know that we can factor MM into prime numbers! Do so, and write MM as a product of prime numbers.

Our argument above tells us that that none of those prime numbers can be from our list p1,pnp_1, \ldots p_n . But this list was supposed to contain all of the prime numbers! Therefore, we know that our original assumption that we could write down all of the prime numbers must have been false: that is, there must have been infinitely many prime numbers.

\square

Common Contradiction Mistakes: Not Understanding Negation

In a proof by contradiction, we’re trying to prove that a claim PP is true by showing that “not-PP ” cannot be false. Perhaps surprisingly, the most common mistake people make when using a proof by contradiction is in their very first step: specifically, in writing just what “not-PP ” is for a given claim!

For example, consider the following claim:

Claim 7.10.Link copied For every pair of integers x,yx,y such that xx and yy are both odd, we have that xyx\cdot y is also odd.

Here are a number of incorrect ways that people will try to negate this claim:

As such, the correct negation of Claim 7.10, is the following:

“There is a pair of integers x,yx,y such that both x,yx,y are odd, and yet xyx \cdot y is even.”

Much more reasonable!

Using similar logic, the clam

Claim 7.11.Link copied “There is an even prime number.”

should negate to the following:

“Every prime number is odd.”

This is because the opposite of a claim about something existing is that there are no counterexamples (i.e. a claim about everything). As well, the universe of numbers we’re studying (primes) should remain the same, leaving only the conclusion (even) to flip to “odd.”

Let’s consider another claim:

Claim 7.12.Link copied If GG is a graph containing 2\geq 2 vertices, then GG contains two vertices whose degrees are equal.

There are many tempting and incorrect ways to negate this claim:

By using this, the correct negation of Claim 7.12,. is the following:

“There is a graph GG on n2n\geq 2 vertices, such that GG does not contain two vertices with the same degree.”

We can summarise the observations we made above as follows:

Observation 7.16.Link copied The phrases “For every” and “There exist” get switched around when writing a proof by negation. This is because we disprove a claim about everything by finding a single counterexample, and we prove that no example of a thing can exist by showing that everything is not a counterexample!

Observation 7.17.Link copied The “universe” of a claim remains the same: i.e. we don’t disprove a claim about all even numbers by studying odd numbers.

Observation 7.18.Link copied The opposite of an “if A then B” statement is “there is a situation where AA holds and BB fails.” That is: if someone tells you that when it rains outside the sidewalk gets wet, you just need to find a situation where (1) it’s raining and (2) some bit of sidewalk is still dry to disprove their claim!

To finish this section and put this to use, let’s prove Claim 7.12!

Proof of Claim 7.12,. As noted above, the contradictive assumption here would be that GG is a graph on n2n\geq 2 vertices in which all of the vertices have different degrees.

We know that the maximum degree of any vertex in GG is n1n-1 , because any vertex is at most adjacent to every other vertex. As well, the minimum degree of any vertex is trivially 0. Therefore, there are in theory nn different possible degrees for the nn vertices in GG , namely the values 0,1,n10,1,\ldots n-1 .

If no degrees are repeated in GG , then (because there are nn vertices and nn different possible degrees) there is exactly one vertex with degree ii , for every i{0,1,n1}i \in \{0,1,\ldots n-1\} . If n2n \geq 2 , note that in particular n11n-1 \geq 1 , and so the degree-0 and degree-(n1)(n-1) vertices are different.

Now, notice that if there is a vertex with degree n1n-1 , it is connected to every other vertex in our graph. In particular it must be connected to the vertex that has degree 0, which contradicts the property that this vertex is supposed to have degree 0.

Therefore we have a contradiction, and can conclude that our original claim must hold.

\square

Proof by Construction

In many of the proofs above, we’ve been focused on proving claims about “all” numbers x,yx,y , or “all” odd integers nn , or other sorts of “universal” claims about things. When we’re proving claims of these forms, we need to use techniques and arguments like the ones above where we work in general / don’t get to use examples to prove our claim!

Sometimes, however, we’ll find ourselves with claims of the form “There exists a number nn such that…” or “There is a value xx with the property…” In this sort of situation, we’re not being asked to show that something is true for all values: instead, we’re just asked to find a single example!

In situations like this, a common technique is proof by construction, where we simply create an object with the desired properties. We illustrate this with an example:

Claim 7.13.Link copied _ There is an odd integer that is a power of two._

Proof. Notice that 20=12^0 = 1 . Therefore, 11 is a power of 2. 1 is also odd, as we can write it in the form 1+2k1+2k for some integer kk (specifically, k=0k=0 .) Therefore we’ve constructed the claimed integer, as desired.

\square

Notice the following two aspects of this proof:

We give a second example, to illustrate how these sorts of things come up in combinatorics and/or “puzzle” mathematics:

Claim 7.14.Link copied Take the aces and face cards from a standard 52-card deck. Can you arrange them in a 4×44 \times 4 grid so that no suits or symbols are repeated in any row or column?

Proof. Behold!

\square

In this proof, we don’t have much to really explain: the solution presented self-evidently has the desired property (just check every row and column.) If it was unclear, though, we’d have to have some explanation along with our answer!

We close by giving a pair of slightly trickier examples for how construction can work, by using processes and algorithms:

Definition 7.1.Link copied Given a graph GG , a vertex coloring of G with kk colors is any way to assign each vertex of GG one of kk different colors, so that no two adjacent vertices get the same color.

Claim 7.15.Link copied We can vertex-color any tree TT with at most 2 colors.

Proof. Consider the following algorithm to paint any connected graph GG ’s vertices with the colors red and blue:

Algorithm 7.13. Init: Choose any vertex vv in GG , and paint it red.

  1. Take all currently uncolored vertices that are connected to any red vertices by an edge, and color them blue.
  2. Take all currently uncolored vertices that are connected to any blue vertices by an edge, and color them red.
  3. If there are any uncolored vertices left, go back to (i) and repeat.

We claim that this algorithm will always succeed at coming up with a valid vertex coloring of any tree GG ; indeed, more generally, we claim that this algorithm will always succeed at making a valid 2-coloring of any graph GG that doesn’t contain an odd-length circuit as a subgraph! Because any tree does not have an odd-length circuit as a subgraph (indeed, it doesn’t contain a cycle subgraph of any length), this would prove our claim.

To see why, we use a second proof technique: contradiction! Think about what would happen if this algorithm would fail, given a connected graph GG with no odd-length circuit subgraphs.

Because GG is connected, the above process will eventually color every vertex of GG ; we first color vv , then its neighbors, then its neighbor’s neighbors, and so on/so forth, coloring every vertex within a walk of kk edges by the kk -th pass. So if the algorithm fails, it does so because in its coloring there must be an edge {x,y}\{x,y\} in which x,yx, y both get the same color.

Notice that if a vertex ww is colored blue, it is because we can walk to to ww from our starting vv in either one step, or three steps, or five steps … or in general an odd number of steps. This is because we alternated between red and blue in our algorithm. Similarly, if a vertex ww is colored red, it is because we can walk to ww in either 0 or 2 or 4 or 6 or … or an even number of edges.

Take any walk PxP_x from vv to xx , and any other walk PyP_y from vv to yy . We have proven that either Px,PyP_x, P_y both have an even number of edges, or that they both have an odd number of edges. Therefore, the circuit formed by starting at vv , walking along PxP_x to xx , using the {x,y}\{x,y\} edge to go to yy , and then reversing PyP_y to return to vv has either (even+1+even)(\textrm{even} + 1 + \textrm{even}) or (odd+1+odd)(\textrm{odd} + 1 + \textrm{odd}) length. Both of the quantities, in particular, are odd! This contradicts our assumption that GG had no odd-length circuits.

As a result, our original claim (that GG is bipartite) must be true!

\square
Claim 7.16.Link copied A Hamiltonian circuit in a graph GG is a walk that starts and ends at the same vertex, and along the way visits every other vertex exactly once. For example, the cube graph Q3Q_3 below has a Hamiltonian circuit (highlighted.) The n×nn \times n grid graphs are defined by drawing a n×nn \times n grid of vertices and connecting adjacent vertices, as drawn below: Prove for all nNn \in \mathbb{N} that G2n,2nG_{2n, 2n} has a Hamiltonian circuit.

Proof. Consider the following constructive process for generating such a circuit:

By construction we have visited all vertices in our graph exactly once, and thus created a Hamiltonian circuit, as desired.

\square

Finally, we can answer one our earlier exercises by using construction:

Answer to Exercise 7.2. This has a nice constructive answer: take half of each of the four tablets today, and the other half tomorrow.

Because this is constructive, we don’t have to explain how we came up with this clever idea: we can just present it as an answer! (Though if you did something clever to come up with an idea, it is good to mention how you did this.) We just have to explain why this works, which is pretty simple: half of each tablet gives us half of the tablets of each type, and thus exactly one dose for each kind.

Proof by Induction: First Examples

Sometimes, in mathematics, we will want to study a statement P(n)P(n) that depends on some variable nn . For example:

For any fixed nn , we can usually use our earlier proof methods to prove that the claim holds! For instance, let P(n)P(n) be the fourth example above, and consider P(3)P(3) , which is the claim that if we take a 8×88 \times 8 grid of squares and delete the top-right-hand corner square, we can tile the rest of the shape with tiles. We can prove this by construction by just giving an explicit way to do it: see the drawing below!

However, sometimes we will want to prove that one of these statements holds for every value nNn \in \mathbb{N} . How can we do this?

The answer here is mathematical induction! Mathematical induction is just a formal way of writing up our “building-block plus preserved property” process, in a way that will hopefully let us avoid everyone having the same shoe size. We describe it here:

If our claim PP is true for all values up to some nn , \then it will continue to be true at the next value n+1n+1 .

Because this is an implication, i.e. an if-then proof, we usually prove it directly by assuming that our claim holds for all values up to some nn , and then use this assumption to prove that our claim holds when we have n+1n+1 in our claim.

Just doing these two steps shows that your claim PP is true for every natural number nn ! To see why, just examine what these two steps tell you:

The way we usually think of inductive proofs is to think of topping dominoes. Specifically, think of each of your P(n)P(n) propositions as individual dominoes - one labeled P(0)P(0) , one labeled P(1)P(1) , one labeled P(2)P(2) , and so on/so forth. With our inductive step, we are insuring that all of our dominoes are lined up - in other words, that if we’ve knocked over some of them, the “next one” will also be knocked over. Then, we can think of the base step as “knocking over” the first domino. Once we do that, the inductive step makes it so that all of the later dominoes also have to fall, and therefore that our proposition must be true for all nn (because all the dominoes fell!)

To illustrate how these kinds of proofs go, let’s go back to our tiling problem, and prove that we can tile this grids for every nNn \in \mathbb{N} ! (As an added bonus, let’s prove it for grids where we remove one square from anywhere, not just the top-right-hand corner!)

Claim 7.17.Link copied For any nNn \in \mathbb{N} , take a 2n×2n2^n \times 2^n grid of unit squares, and remove one square from somewhere in your grid. The resulting grid can be tiled by - shapes.

Proof. As suggested by the section title, we proceed by induction, where our proposition P(n)P(n) is “we can tile a 2n×2n2^n \times 2^n grid of 1×11 \times 1 squares with one square deleted by using - shapes.”

Base case: we want to prove P(0)P(0) . So: what is P(0)P(0) ?

Well: for n=0n=0 , we have a 20×20=1×12^0 \times 2^0 = 1 \times 1 grid, which we’ve removed a 1×11 \times 1 square from. In other words, we have nothing. If you want, you can think of “nothing” as being something we can trivially cover by placing no three-square shapes!

Alternately, you can decide that 0 is a stupid case and look at n=1n=1 instead. For n=1n = 1 , we simply have a 2×22 \times 2 grid with one square punched out. As this is one of our three-square shapes, we are done here; just place a tile on top of our grid!

Either starting place is fine. In general, we recommend doing as many base cases as you need to do in order to feel comfortable with the pattern and believe that you’ve done something concrete! Most of the time, though, the base case will feel kinda silly; don’t worry about this! The inductive step will do all of the heavy lifting for us.

Inductive step: We want to prove that if we know that our claim holds up to nn , then it holds for n+1n+1 as well; formally, this means that we want to show that if P(0)P(0) and P(1)P(1) and … and P(n)P(n) all hold, then P(n+1)P(n+1) must follow.

In this problem in particular, this means that we’re assuming that we can tile a 2k×2k2^{k} \times 2^{k} -grid with a square deleted for any knk \leq n , and want to use this assumption to tile a 2n+1×2n+12^{n+1} \times 2^{n+1} grid with a square deleted.

To do this, take any 2n+1×2n+12^{n+1} \times 2^{n+1} grid with a square deleted. Divide it into four 2n×2n2^n \times 2^n squares by cutting it in half horizontally and vertically. Finally, by rotating our grid if needed, make it so that the one missing square is in the upper-right hand corner.

Take this grid, and carefully cut out one three-square shape in the center as drawn below.

Now, look at each of the four 2n×2n2^n \times 2^n squares in this picture. They all are missing exactly one square: the upper-right hand one because of our original setup, and the other three because of our placed three-square-shape.

By our inductive hypothesis P(n)P(n) we know that all of these smaller squares can be tiled! Doing so then gives us a tiling of the whole shape; in other words, we’ve shown how to use our P(n)P(n) results to get a tiling of the 2n+1×2n+12^{n+1} \times 2^{n+1} grid.

As this completes our inductive step, we are thus done with our proof by induction.

\square

The claim we proved above - one where we were some sense “growing” or “extending” a result on small values of nn to get to larger values of nn - is precisely the kind of question that induction is set up to solve! The Fibonacci numbers, which we introduce in the next question, is another object where this sort of “extension” approach is useful to consider.

Definition 7.2.Link copied The Fibonacci numbers fnf_n are defined by a recurrence relation as follows:- f0=0f_0 = 0 , f1=1f_1 = 1 .- For any n2n \geq 2 , fn=fn2+fn1f_n = f_{n-2} + f_{n-1} .

To illustrate how it works, let’s use it to calculate the first few values of the Fibonacci sequence! We know that f0=0,f1=1f_0 = 0, f_1 = 1 by definition.

To find f2f_2 , we can use the fact that for any n2n \geq 2 , fn=fn2+fn1f_n = f_{n-2} + f_{n-1} to calculate that.

f2=f0+f1=0+1=1.f_2= f_0 + f_1 = 0+1 = 1.

We can calculate further values of fnf_n similarly:

When doing this, you’ll likely notice a number of interesting properties about the Fibonacci sequence: see for a ton of weird/beautiful properties these numbers have! We prove one of these properties here:

Claim .Link copied For any nNn \in \mathbb{N} , the nn -th Fibonacci number is even if and only if nn is a multiple of 3.

Proof. Let P(n)P(n) denote the claim “(the nn -th Fibonacci number is even) \Leftrightarrow (nn is a multiple of 3).” We want to prove that P(n)P(n) holds for all nNn \in \mathbb{N} , and proceed to prove this claim by induction.

Our base cases are pretty easy to check! We calculated the Fibonacci numbers from f0f_0 to f12f_{12} above, and we can see that the only ones that are even are f0,f3,f6,f9f_0, f_3, f_6, f_9 and f12f_{12} ; so we know that P(0),P(3),P(6),P(9),P(0), P(3), P(6), P(9), and P(12)P(12) all hold.

We now move to the inductive step: here, we want to prove P(0)P(0) and P(1)P(1) and P(2)P(2) and … and P(n)P(n) , when all combined together, imply P(n+1)P(n+1) . We start with what we’re assuming, namely that all of P(0),P(1),P(n)P(0), P(1),\ldots P(n) are all true: that is, we’re assuming that the kk -th Fibonacci number is even if and only if it is a multiple of 3, for every k{0,1,n}k \in \{0,1,\ldots n\} .

We want to prove P(n+1)P(n+1) , i.e. that the n+1n+1 -th Fibonacci number is even if and only if it is a multiple of 3.

So: let’s consider cases! There are two possible cases for the value n+1n+1 : either it is a multiple of 3, or it’s not.

So, by using strong induction, we have proven that fnf_n is even if and only if it is a multiple of 3!

\square

Induction: Two Recurrence Relations

As we just saw in the section above, induction is a useful tool to study recurrence relations! In this section, we continue with this theme, and use induction to prove Claim 4.2 and Claim 4.6 from our algorithms chapter.

Claim 7.18.Link copied (Claim 4.2) For every positive integer nn , we have SelectionSortSteps(n)=3n2+9n102\texttt{SelectionSortSteps}(n) = \dfrac{3n^2+9n-10}{2} .

Proof. We proceed by induction. First, we can notice that the table of values we calculated earlier validates our claim for the first few values of nn :

n1234567SelectionSortSteps(n)11022375576100 3n2+9n2210211022375576100\begin{array}{c||c|c|c|c|c|c|c} n & 1 & 2 & 3 & 4 & 5 & 6 & 7\\\hline \texttt{SelectionSortSteps}(n) & 1 & 10 & 22 & 37 & 55 & 76 & 100\\\ \dfrac{3n^2+9n^{2^2}-10}{2} & 1 & 10 & 22 & 37 & 55 & 76 & 100\\ \end{array}

This gives us our base case.

For the inductive step, we proceed as always: we assume that our claim holds up to some value nn , and seek to prove it for n+1n+1 .

In particular, if our claim holds up to some value nn , we have SelectionSortSteps(n)=3n2+9n102.\texttt{SelectionSortSteps}(n) = \dfrac{3n^2+9n-10}{2}.

As well, by Claim 4.1, we know that

SelectionSortSteps(n+1)=3(n+2)+SelectionSortSteps(n).\texttt{SelectionSortSteps}(n+1) = 3(n+2) + \texttt{SelectionSortSteps}(n).

By combining these together, we get

SelectionSortSteps(n+1)=3(n+2)+3n2+9n102=6(n+2)2+3n2+9n102=3n2+15n+22.\texttt{SelectionSortSteps}(n+1) = 3(n+2) + \dfrac{3n^2+9n-10}{2} = \dfrac{6(n+2)}{2} + \dfrac{3n^2+9n-10}{2} = \dfrac{3n^2 + 15n +2}{2}.

But we know that

3(n+1)2+9(n+1)102=3n2+6n+3+9n+9102=3n2+15n+22\dfrac{3(n+1)^2+9(n+1)-10}{2} = \dfrac{3n^2 + 6n + 3 + 9n + 9-10}{2} = \dfrac{3n^2 + 15n +2}{2}

In other words, we’ve shown that our claim holds at n+1n+1 , and have thus proven our claim by induction!

\square

We can study MergeSort\texttt{MergeSort} in the same way:

Claim 7.19.Link copied (Claim 4.6,) MergeSortSteps(2k)=k2k+2+2k+11\texttt{MergeSortSteps}(2^k) = k \cdot 2^{k+2} + 2^{k+1} - 1 , for every natural number kk .

Proof. We again proceed by induction. Again, as before, our previously-calculated table of values suffices for a base case:

k1234567MergeSortSteps(2k)113911128770316633839k2k+2+2k+11113911128770316633839\begin{array}{c||c|c|c|c|c|c|c} k & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline \texttt{MergeSortSteps}(2^k) & 11 & 39 & 111 & 287 & 703 & 1663 & 3839\\ k \cdot 2^{k+2} + 2^{k+1} - 1 & 11 & 39 & 111 & 287 & 703 & 1663 & 3839\\ \end{array}

With this established, we turn to the inductive step. Here, we again assume that our claim holds up to some value kk , and seek to prove it for k+1k+1 .

In particular, if our claim holds up to some value kk , we have MergeSortSteps(2k)=k2k+2+2k+11\texttt{MergeSortSteps}(2^k) =k \cdot 2^{k+2} + 2^{k+1} - 1

As well, by Claim 4.5, we know that

MergeSortSteps(2k+1)=1+42k+1+2MergeSortSteps(2k).\texttt{MergeSortSteps}(2^{k+1}) = 1 + 4\cdot 2^{k+1} + 2\cdot\texttt{MergeSortSteps}( 2^k).

Again, by combining these together, we get

MergeSortSteps(2k+1)\texttt{MergeSortSteps}(2^{k+1})
=1+42k+1+2(k2k+2+2k+11)=1 + 4\cdot 2^{k+1} + 2(k \cdot 2^{k+2} + 2^{k+1} - 1)
=1+2k+3+2k2k+2+22k+12= 1 + 2^{k+3} + 2k2^{k+2} + 2 \cdot 2^{k+1} - 2
=k2k+3+2k+3+2k+21,= k\cdot 2^{k+3} + 2^{k+3} + 2^{k+2} -1,

But we know that

(k+1)2(k+1)+2+2(k+1)+11=k2k+3+2k+3+2k+21(k+1) \cdot 2^{(k+1)+2} + 2^{(k+1)+1} - 1 = k\cdot 2^{k+3} + 2^{k+3} + 2^{k+2} - 1

In other words, we’ve shown that our claim holds at k+1k+1 , and have thus proven our claim by induction!

\square

Induction, Graphs, and Trees

Induction is a particularly useful technique to use when studying graphs and trees! We prove three claims here, two of which you may recall from our section on trees:

Claim 7.20.Link copied If GG is a connected multigraph with loops (i.e. we allow multiple edges, and also allow an edge to have both of its endpoints be equal) on nn vertices, then GG contains at least n1n-1 edges.

Proof. We proceed by induction on nn . For n=0,1n=0,1 , this claim is trivially true, as we always have that EE is a nonnegative number.

This establishes our base cases, so we now turn to the inductive step: here, we assume that our claim holds for all connected graphs on at most nn vertices, and seek to use that assumption to prove that our claim holds for connected graphs on n+1n+1 vertices.

To do this, consider the following operation, called edge contraction. We define this as follows: take any graph GG and any edge ee in GG with two distinct endpoints. We define GeG_e , the graph that this edge, as follows: take GG , delete ee , and then combine ee ’s two endpoints together into a single vertex, preserving all of the other edges that the graph has along the way.

We draw examples of this process below: here, we have started with a graph on six vertices, and then contracted one by one the edges highlighted in red at each step.

Notice that contracting an edge decreases the number of vertices by 1 at each step, as it “squishes together” two adjacent vertices into one vertex. It also decreases the number of edges by 1 at each step, as we are contracting an edge to a point!

Finally, notice that contracting an edge preserves the property that our graph is connected. To see why, take any walk

{v0,v1},{v1,v2},{vi1,vi},{vi,vi+1},{vi+1,vi+2},{vn1,vn}\{v_0, v_1\}, \{v_1, v_2\}, \ldots \{v_{i-1}, v_i\}, \{v_i, v_{i+1}\}, \{v_{i+1}, v_{i+2}\}, \ldots \{v_{n-1}, v_n\}

in our graph. Notice that if we contracted an edge {vi,vi+1}\{v_i, v_{i+1}\} in this walk, this would collapse the vertices vi,vi+1v_{i}, v_{i+1} into some new vertex vii+1v_{i\oplus i+1} and preserve all of the edges other than {vi,vi+1}\{v_i, v_{i+1}\} . As a result, our walk would just become

{v0,v1},{v1,v2},{vi1,vii+1},{vii+1,vi+2},{vn1,vn},\{v_0, v_1\}, \{v_1, v_2\}, \ldots \{v_{i-1}, v_{i\oplus i+1}\}, \{v_{i\oplus i+1}, v_{i+2}\}, \ldots \{v_{n-1}, v_n\},

and thus still connects the vertices v0,vnv_0, v_n . Therefore, edge contraction cannot “break” any pre-existing walks, and so preserves the property that our graph is connected.

We can use this process to prove our claim via induction:

\square

Notice that this result applies to simple graphs as well, as any simple graph is certainly a multigraph!

We can also use induction to prove Theorem 6.2! We split this result into two parts, as it’s a longish equivalence proof:

Theorem 7.3(Half of Theorem 6.2) If TT is a tree on nn vertices, then TT contains exactly n1n-1 edges.

Proof. We proceed by induction. Our base case is straightforward: any tree on 1 vertex clearly has no edges (as it’s a simple graph.) If you want, you can also consider 2-vertex graphs as well; the only connected two-vertex graph is , which has one edge as desired.

For the inductive step, let’s assume that our property holds for all trees on up to nn vertices. Let TT be any tree on n+1n+1 vertices; we want to use our assumption to prove that TT contains exactly (n+1)1=n(n+1) - 1 = n edges.

To do this, let ll be a leaf vertex in TT (we know that ll exists by our earlier theorem.) Delete ll and the edge connecting ll to the rest of TT from TT ; call the resulting graph TlT-l .

TlT-l contains nn vertices, because we started with n+1n+1 vertices and deleted one vertex. It is also still connected (because ll was degree 1, the only walk that would need to use the edge to ll is a walk going directly to ll , and we deleted ll .) Finally TlT-l contains no cycle subgraphs, because TT contained no cycle subgraphs and deleting things from TT cannot have somehow caused a cycle to exist.

Therefore TlT-l is a tree! By induction, TlT-l contains n1n-1 edges.

Therefore TT itself contains (n1)+1=n(n-1)+1 = n edges, because TT is just TlT-l plus the vertex ll and the single edge connecting ll to the rest of TT . In other words, we’ve proven our inductive claim!

\square

Theorem 7.4(The other half of Theorem 6.2).If GG is a connected graph on nn vertices containing exactly n1n-1 edges, then GG is a tree.

Proof. We proceed by contradiction; suppose that GG is a connected graph on nn vertices containing n1n-1 edges that is somehow not a tree.

Because GG is connected, the only way that GG can fail to be a tree is if it contains a cycle subgraph. Let {v1,v2},{v2,v3},{vk,v1}\{v_1, v_2\}, \{v_2, v_3\}, \ldots \{v_k, v_1\} be such a cycle subgraph.

Take GG and delete the edge {v1,v2}\{v_1, v_2\} from GG . We claim that GG is still connected.

To see why, take any walk in GG that uses the edge {v1,v2}\{v_1, v_2\} , and replace each use of {v1,v2}\{v_1, v_2\} with the sequence of edges {v1,vk},{vk,vk1},{v3,v2}\{v_1, v_k\}, \{v_k, v_{k-1}\}, \ldots \{v_3, v_2\} . In other words, every time you’d go directly from v1v_1 to v2v_2 along that edge, instead use the cycle to go the “other” way around!

As a result, if two vertices x,yx,y used to be connected by a walk in GG , they are still connected after deleting {v1,v2}\{v_1, v_2\} ; in other words, G{v1,v2}G - \{v_1, v_2\} is still connected.

But G{v1,v2}G - \{v_1, v_2\} is a graph on nn vertices containing n2n-2 edges, as we had n1n-1 edges and deleted one. But in Claim 7.20, we proved that a connected graph on nn vertices must contain at least n1n-1 edges! In other words, we have a contradiction, and so our claim that GG was a tree must have been correct.

\square

Proof Methods: How to Choose

With all of these proof methods at our fingertips, a natural question is this: how do you choose a method? One answer is the following:

Just try methods one-by-one until something works!

Paper is cheap, and it’s usually just a lot faster to try stuff and see which things break than to predict ahead of time which method is “best.” Also, most problems in maths can be solved by a number of different methods: there’s rarely a single “correct” approach to a problem! Instead, many problems can be solved with many different techniques, and each different proof can help illustrate a new way of thinking about the task at hand.

With that said, though, there are clues or signs in a problem statement that can indicate that certain techniques might be useful. There are no hard-and-fast rules here, but the following observations often come in handy:

To get some practice with this, we solve a few problems below, and in each proof explain why we picked the methods that we did!

Claim 7.21.Link copied For every positive integer nn , 16n116^n - 1 is a multiple of 15.

Proof. Let’s think about which of our proof methods we want to try:

So, amongst our proof methods, a direct proof and induction look promising. Let’s try induction first!

Base case: we saw in our table in the margins that our case holds for n=0,1,2,3n=0,1,2,3 and 44 . So we’ve established our claim for a number of base cases.

Inductive step: For the inductive step, we assume that we’ve proven our claim for nn : i.e. that 16n116^n - 1 is a multiple of 15. We seek to use this claim to prove that our claim holds for the “next” value n+1n+1 : i.e. that 16n+1116^{n+1} - 1 is also a multiple of 15.

This is not too hard to do! Notice that as we observed above,

16n+11=16n+116+15=16(16n1)+15.16^{n+1} - 1 = 16^{n+1} - 16 + 15 = 16(16^n - 1) + 15.

If 16n116^n - 1 is a multiple of 15, then by definition we can write 16n1=15k16^n - 1 = 15k for some integer kk . Doing so tells us that the right-hand-side is

16(15k)+15=15(16k)+15=15(16k+1)=a multiple of 15. 16(15k) + 15 = 15(16k) + 15 = 15(16k+1) = \textrm{a multiple of 15}.

Therefore, 16n+1116^{n+1}-1 is also a multiple of 15! As a result, we’ve proven our claim by induction: we showed that it holds for the first few values of nn , and then showed that it will stay true, as if it is true for some value of nn it must stay true for the “next” value n+1n+1 .

\square

This is not the only way you could prove this result! We could also use a direct proof:

Proof. We want to show that 16n116^n - 1 is always a multiple of 15, for any positive integer nn .

By definition, this holds true if and only if 16n1mod1516^n \equiv 1 \mod 15 .

So: we know that 161mod1516 \equiv 1 \mod 15 , because 16116-1 is itself a multiple of 15. We also know from Claim that for any positive integers a,b,c,na,b,c,n that if abmodca \equiv b \mod c , then anbnmodca^n \equiv b^n \mod c as well.

Combining these facts tells us that for any positive integer nn , we have 16n1nmod1516^n \equiv 1^n \mod 15 . Because 1n=11^n = 1 for all nn , this gives us 16n1mod1516^n \equiv 1 \mod 15 . By definition, this means that for every positive integer nn we’ve shown that 16n116^n - 1 is a multiple of 15, as desired!

\square
Claim 7.22.Link copied Consider the following program puzzle(n)\texttt{puzzle(n)} , which is a slightly modified version of the algorithm you studied in Practice Problem 5 on page 74. It takes in as input a nonnegative integer nn , and does the following:
  • If nn is either 0, 1, or 6, output nn and stop. Otherwise, go to (ii).
  • If nn has two or more digits, replace nn with its last digit and go to (i). Otherwise, go to (iii).
  • Replace nn with n2n^2 and go to (i).

Prove that for every nonnegative odd number nn , if puzzle(n)\texttt{puzzle(n)} stops, it outputs 1.

Proof. We consider proof methods:

Cases looked like the strongest approach: so let’s try that!

Take any nonnegative odd number nn . Because nn is a nonnegative integer, this means that n=1,3,5,7,9n = 1,3,5,7,9 or nn is a two-digit number (whose last digit is 1,3,5,7 or 9.)

After one iteration of our program, if nn was a two-digit number it will be replaced with one of 1,3,5,7,9; so it suffices to just understand those five cases:

In all of these cases, we either run forever or output 1, as claimed!

\square

Again, we can use a more direct approach if we see it:

Proof. Take any nonnegative odd number nn . Notice that if nn is odd, then no matter what our program does nn will stay odd! This is because the square of an odd number is odd, and the last digit of an odd number is odd.

Therefore, nn will never be reduced to either of 0 or 6. As a result, the only possibilities that remain are “the program halts when n=1n=1 ” or “the program runs forever,” as there are no other conditions that cause our program to halt.

\square

We close this section with a third problem about graphs:

Claim 7.23.Link copied Given a graph G, an edge coloring of G with k colors is any way to assign each edge of G one of k different colors, so that no two edges of the same color share an endpoint in common. An example of an edge coloring is given below. Show that there is a graph G in which all vertices have degree 3, and yet at least four colors are needed to create an edge-coloring of G.

Proof. While we could go through all of the proof methods again, we’ll shortcut the process and explain why we know this is a constructive proof: it’s asking us to show that there is a graph with some property! This isn’t a “show all graphs have property foofoo problem or a “take any graph GG , show that it cannot be blahblah ” task: this is just asking us to find some single graph with a given property.

So, uh: behold the graph below!

This is the Petersen graph PP , a particularly useful counterexample to many claims in graph theory. We claim that PP is a graph that needs four colors to properly color its edges; i.e. you cannot edge-color PP with three colors. Note that to complete our proof, we need to explain why using just 3 colors to edge-color this grap is impossible: that is, it’s not enough to just give our object, we also need to show that it has the desired property!

To do this, we now need a new proof technique. We claim that if you went through your list of proof techniques, none would stand out and you’d get stuck for a while. In this situation, contradiction is what we’d go to!

Here, a proof by contradiction would start as follows: suppose that we could use only three colors to color the edges of PP . Call them red, green and blue.

Make the following observations:

Because {x,y}\{x,y\} is red, the edge {a,x}\{a,x\} is not red. Therefore, the red edge that (1) told us must be connected to aa is on this inner star.

Similarly, because {x,y}\{x,y\} is red, {b,y}\{b,y\} is not red. Therefore, the red edge that (1) told us must be connected to bb is also on this inner star.

Finally, because aa and bb are not adjacent, these red edges are different: that is, there are two red edges in this inner star.

… but it only has five edges! Therefore this is impossible; i.e. we’ve reached a contradiction, and our original claim (that at least four colors are required) has been proven.

\square

Practice Problems

  1. You’re a programmer! You’ve found yourself dealing with a program mystery(n)\texttt{mystery(n)} that has no comments in its code, and you want to know what it does. After some experimentation, you’ve found that mystery(n)\texttt{mystery(n)} takes in as input a natural number nn , and does the following:

    • If nn is either 0, 1, 2, or 3, output nn and stop. Otherwise, go to (ii).
    • If nn is even, replace nn with n/2n/2 and go back to (i). Otherwise, go to (iii).
    • Replace nn with n+5n+5 and go to (i).

    Come up with the following proofs about mystery(n)\texttt{mystery(n)} :

        (a) Use contradiction to prove the claim “if this program outputs 3 on input nn , then nn is not a power of 2.”

        (b) Disprove the claim “Given any natural number nn as input, this program will eventually stop” by finding a counterexample.

        (c) Prove by construction the claim “There is some input to this program that causes it to output 0.”

        (d) Write a direct proof that if “the output of this program is 1” then “the input to this program was 1.”

  2. (-) Let a,b,ca,b,c be three integers, such that aa divides bb and aa divides cc . Write a direct proof that aa also divides bcb-c .

  3. (-) Write a proof by cases that for any integer nn , the number 3n2+n163n^2+n-16 is even.

  4. (-) Prove by contradiction that the number 19\sqrt{19} is irrational.

  5. Suppose that aa , bb are a pair of real numbers with the following property: if xx is any number greater than bb , then xx must also be greater than aa . Prove by contradiction that aba \leq b .

  6. (+) The game of generalized nn -tic-tac-toe is played as follows: on a n×nn \times n grid, two players XX and OO take turns placing their respective symbols x,ox, o into cells of the grid. No cell can be repeated. The game ends whenever any player gets nn consecutive copies of their symbol on the same row /column / diagonal, or when the grid is completely filled in without any player having any such nn consecutive symbols. (Normal tic-tac-toe is where n=3n = 3 .)

    Prove that there is no strategy in generalized tic-tac-toe where the second player to move is guaranteed to win.

  7. A queen in the game of chess is a piece, shaped like . In the game of chess, when moved, a queen (when placed in a given cell in a chessboard) can go to any cell within the same row, any cell within the same column, or any cell along the two diagonals through the cell that it starts from. We illustrate this below.

    The nn -queens problem is the following task: Take a n×nn \times n chessboard. Can you place nn distinct queens on this chessboard, so that no queen can capture any other (i.e.\ so that there is no way to move any one queen into a cell currently occupied by another queen?): (a) Prove by cases that there are no solutions to the 33 -queens problem. (b) Prove by construction that there is a solution to the 44 -queens problem. (c) Prove by construction that there is a solution to the 88 -queens problem.

  8. Prove or disprove the following claim: if GG is a graph in which the degree of every vertex is 3, then GG cannot be bipartite.

  9. Prove or disprove the following claim: if GG is a graph in which the degree of every vertex is at least 2, then GG is connected.

  10. Consider the following two-player game: starting with the single number 123, two players alternately subtract numbers from the set {1,2,3}\{1,2,3\} from this value. The player who first gets this sum to 0 wins.

If you want to win this game, should you go first or second? Prove that your chosen player has a winning strategy. (Hint: try induction!)

  1. Take an equilateral triangle with side length 2n2^n . Divide it up into side-length 1 equilateral triangles, and delete the top triangle. Call this shape TnT_n :

Take three side-length 1 equilateral triangles. Join them together to form the following tile: Prove that you can tile TnT_n with tiles, for every nNn \in \mathbb{N} .

  1. Consider the following inductive “proof:”

Claim: If GG is a graph containing at least 3 vertices, and every vertex in GG has degree at least 2, then GG contains a C3C_3 subgraph

Proof. We proceed by induction on the number of vertices in GG . To start: we assume that our claim holds for all graphs on up to nn vertices, and seek to prove that it holds for all graphs on n+1n+1 vertices as well. To do this: for any n>3n > 3 , take any graph GG on nn vertices in which every vertex has degree at least 2. Add a new vertex vv to this graph, and connect vv to at least two other vertices in GG ; this gives us a new graph GG' on n+1n+1 vertices. We know by our inductive assumption that GG itself contains a C3C_3 subgraph. Therefore this new graph GG' on n+1n+1 vertices also contains a C3C_3 subgraph! This is what we wanted to prove, and thus finishes our inductive proof.

\square

Find every logical flaw in this proof. Explain why the flaws you have found are indeed mistakes. (Hint: there are at least two flaws here!)

  1. Consider the following solitaire game:

The picture above contains three circles drawn in the plane. In each of the bounded regions formed by the intersections of these circles, we’ve placed a coin, which is white on one side and black on the other. All of the coins start with their black side up.

The moves you’re allowed to perform in this game are the following: