CM10196 Topic 3: Proof by Induction Guy McCusker 1W2.1 The Mathematics of Infinity One of the most powerful and fascinating aspects of mathematics is the ability to reason about infinite objects. Examples of simple infinite objects that we can “tame” using simple mathematical techniques include I the set N of natural numbers 0, 1, 2, . . . I the set of all boolean formulae I the set of all elements of a given data structure: all lists, all trees, etc. The technique we will use to reason about these infinite sets is mathematical induction. [email protected](1W2.1) CM10196 Topic 3: Induction 2 / 63 What’s the problem? Suppose we want to prove some property about every natural number. For instance every natural number greater than 1 is either a prime, or divisible by a prime. That is, ∀n ∈ N.n > 1 → (“n is prime” ∨ “n is divisible by a prime”) Since this statement says something about every natural number, proving that it is true could be hard work. A simple-minded approach would try to prove that it’s true for 0, and for 1, and for 2, and for 3, and for 4... That will take forever, which is too long. [email protected](1W2.1) CM10196 Topic 3: Induction 3 / 63
21
Embed
CM10196 Topic 3: Proof by Induction - Bath Topic 3: Proof by Induction Guy McCusker 1W2.1 The Mathematics of In nity One of the most powerful and fascinating aspects of mathematics
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CM10196Topic 3: Proof by Induction
Guy McCusker
1W2.1
The Mathematics of Infinity
One of the most powerful and fascinating aspects of mathematics is theability to reason about infinite objects.
Examples of simple infinite objects that we can “tame” using simplemathematical techniques include
I the set N of natural numbers 0, 1, 2, . . .
I the set of all boolean formulae
I the set of all elements of a given data structure: all lists, all trees, etc.
The technique we will use to reason about these infinite sets ismathematical induction.
Suppose we want to prove some property about every natural number. Forinstance
every natural number greater than 1 is either a prime, or divisibleby a prime.
That is,
∀n ∈ N.n > 1→ (“n is prime” ∨ “n is divisible by a prime”)
Since this statement says something about every natural number, provingthat it is true could be hard work. A simple-minded approach would try toprove that it’s true for 0, and for 1, and for 2, and for 3, and for 4. . .
Inductive proofs are normally laid out in two paragraphs, one for the basisand one for the inductive step. Like this.
Basis. We must show that 03 − 0 = 0 is divisible by 6, which is triviallytrue.
Inductive step. We must show that (n + 1)3 − (n + 1) is divisible by 6 ifn3 − n is. But
(n + 1)3 − (n + 1) = (n3 − n) + 3n(n + 1).
We know n3 − n is divisible by 6 by the inductive hypothesis, so it sufficesto show that 3n(n + 1) is divisible by 6, i.e. that n(n + 1) is divisible by 2.But one of n and n + 1 must be even, so this is the case.
Basis. We must prove that the sum of naturals from 0 to 0 is equal to0(0 + 1)/2 = 0, which is true.
Inductive step. We must prove that the sum of naturals from 0 to n + 1 is
(n + 1)(n + 2)
2=
n(n + 1)
2+
2(n + 1)
2=
n(n + 1)
2+ (n + 1).
By the inductive hypothesis, n(n + 1)/2 =∑x=n
x=0 x so the expressionabove is equal to (
x=n∑x=0
x
)+ (n + 1)
which is clearly the required [email protected] (1W2.1) CM10196 Topic 3: Induction 13 / 63
The principle of induction as a logical formula
We can formulate the principle of induction as a logical formula: if P(n) isany predicate on the natural numbers, the principle of induction states that(
We’ve shown that for every subset B of A, if |B| = n then |PB| = 2n.
A is a subset of itself, so we can conclude that
|PA| = 2|A|
as required.
What we’ve done here is to turn a statement about sets into a statementabout natural numbers by measuring something in our original statement.We then use induction on this measurement to get our proof done.
In this case, we say we’ve proved the statement by induction on the size ofA.
If we’re only interested in showing that P(n) holds for n > 5, for instance,we can set our induction up slightly differently:
Basis. Show that P(6) holds.
Inductive step. Show that if P(n) holds for some n > 5 then P(n + 1)holds.
Exercise
Give a formula that expresses this principle, and show that it follows fromthe standard principle of induction. Hint: given a predicate P(n), considerthe predicate P ′(n) defined to be P(n + 6), i.e. P ′(n) holds if P(n + 6)holds.
We motivated the need for the principle of induction with this example:we’d like to prove that
every natural number greater than 1 is either a prime, or divisibleby a prime.
Let’s try to prove it by induction.
Basis. This is the case n = 2. It is prime, so it satisfies the property.
Inductive step. We must prove that the property holds for n + 1 if it doesfor n. The number n + 1 is either prime or not. If it is, then it satisfies theproperty. If it’s not, then. . . what?
We know it must be divisible by something. If it’s divisible by n then wecan use our inductive hypothesis: n is itself a prime, or divisible by aprime. So if n + 1 is divisible by n, then n + 1 is divisible by aprime—either n itself or the prime that n is divisible by.
We don’t know that n + 1 is divisible by n, and in fact it won’t be, exceptwhen n is 1. (Can you see why?)
So we can’t use our inductive hypothesis. Oh no!
What we know is that either n + 1 is prime (which would mean we haveproved what we need) or it’s divisible by some number m. We also knowthat m ≤ n.
If we could apply our inductive hypothesis to m, we’d be fine: thereasoning from the last slide would work. But the principle of inductiononly gives us an inductive hypothesis for the number n, not for everym ≤ n.
It seems like there should be a way to rescue the situation. After all, bythe time domino n + 1 is ready to fall, not only has domino n fallen, alldominoes up to n, including domino m, have fallen.
That is to say, our property should be true of every m ≤ n.
To put it another way, we should be able to use our inductive hypothesison every m ≤ n.
The principle of course-of-values induction, also known as stronginduction, allows just this.
Course-of-values induction tells us that, to prove that a property P(n)holds for every n ∈ N, it’s enough to:
Basis. Prove that P(0) holds, and
Inductive step. Prove that, for any natural number n, if P(m) holds forevery m ≤ n, then P(n + 1) holds.
This gives us a stronger inductive hypothesis to use in the inductive step:instead of just using the hypothesis that P(n) holds, we can use P(m) forany m ≤ n.
As with ordinary induction we can use different base values if we only needa property to hold for numbers greater than a certain minimum.
How do we know that such a “definition” really does define a function?
Remark
If you reach a stage in your life when you see something like the above andimmediately react by thinking “Is that well-defined?”, you have become amathematician!
But a recursive program might not terminate, and it will only compute onepossible answer.
In principle, a recursive “function definition” could define nothing at all, ordefine a “function” which has more than one possible answer for someinputs. (This would not actually be a function.)
A mathematician, or a conscientious programmer, would want to be surethat the definition really did define a function.
We can prove by induction that for every natural number n, there is aunique natural number fn such that
f0 = 1
fn+1 = fn × (n + 1)
Basis. We must show that there is a unique number f0 such that f0 = 1.This is obvious!Inductive step. We must show that, if there is a unique fn satisfying theequations, then there is a unique fn+1. But the second equation tells usthat fn+1 must be fn × (n + 1), so if fn is well-defined, so is fn+1.
How can we be sure that this is well-defined? If we try to use induction asbefore, the inductive step looks like this:
Inductive step. We must show that if fib(n) is well defined, so isfib(n+1). If n = 0 this is easy: fib(1) = 1 by definition. For n > 0, thedefinition tells us that fib(n+1) = fib(n) + fib(n-1). Our inductivehypothesis tells us that fib(n) is well-defined. . .
Here’s the induction principle we can use to prove that the Fibonaccisequence is well-defined.
P(0) ∧ P(1) ∧(∀n ∈ N.(P(n) ∧ P(n + 1))→ P(n + 2)
)→ ∀n ∈ N.P(n).
Exercise
Use this principle to show that the Fibonacci sequence is well-defined.
Harder exercise
Show that this principle follows from the standard induction principle.Hint: think about how the “base case” of this principle, P(0) ∧ P(1), canbe seen as the base case P ′(0) of the ordinary induction principle with adifferent predicate.
In fact it turns out to be easier to prove both the DNF and CNF theoremsat the same time, so we’re really going to show that:
Theorem
For every natural number n, if F is a Boolean formula with n symbols,then there is a formula F ′ in disjunctive normal form such that F ≡ F ′,and a formula F ′′ in conjunctive normal form such that F ≡ F ′′.
Our base case will be n = 1, because there are no formulae with zerosymbols. We will use course-of-values induction.
The case of a formula of the form (F1 ∨ F2) is symmetric to theconjunction case.
The case of a formula of the form (F1 → F2) can be handled by means ofthe cases for negation and disjunction, using the fact that(F1 → F2) ≡ (¬F1 ∨ F2).
The property of natural numbers that makes induction valid is that if youtake any natural number n and keep subtracting 1 from it, you reach zeroafter finitely many steps.
Similarly, for any Boolean formula, if you keep breaking it down into itssubformulae, eventually you reach a collection of variables.
This gives us an induction principle for Boolean formulae: let P be somepredicate on formulae (e.g. “this formula has a disjunctive normal form”).We can show that P holds for every formula by showing the following.
Basis. Show that P holds for Boolean variables X .
Inductive step. Show that, if P holds for formulae F1 and F2 then itholds for (F1 ∧ F2), (F1 ∨ F2), (F1 → F2) and ¬F1.
(In practice, such proofs look just the same as the one we just wrote forthe DNF/CNF theorem.)
The idea of defining the natural numbers using 0 and S is used in themost popular axiomatization of arithmetic, called Peano arithmetic afterits inventor.
Peano arithmetic includes axioms saying things like
I S(n) 6= 0
I S(n) = S(m)→ n = m
I P(0) ∧ ∀n ∈ N.P(n)→ P(S(n))→ ∀n ∈ N.P(n)
We can then go on to define arithmetic operations like + and ×inductively. For instance:
Basis. We must show that 0 + 0 = 0, but that follows from the definitionof +.
Inductive step. We must show that if 0 + a = a then 0 + S(a) = S(a).But by definition of +, 0 + S(a) = S(0 + a), and by the inductivehypothesis, 0 + a = a, so our result follows.
For any natural numbers a and b, S(a) + b = S(a + b).
We prove this by induction on b.
Basis. We must show that S(a) + 0 = S(a + 0). By the previous lemma,S(a) + 0 = S(a), and by definition of +, a + 0 = a so S(a + 0) = S(a) asrequired.
Inductive step. We must show that S(a) + S(b) = S(a + S(b)). Bydefinition of +, S(a) + S(b) = S(S(a) + b) and by the inductivehypothesis, S(a) + b = S(a + b), so
Finally we show that a + b = b + a by induction on b.
Basis. We must show that a + 0 = 0 + a. By definition, a + 0 = a, and byour first lemma, 0 + a = a so we’re done.
Inductive step. We must show that if a + b = b + a thena + S(b) = S(b) + a. By definition of +, a + S(b) = S(a + b). By oursecond lemma, S(b) + a = S(b + a). By our inductive hypothesis,b + a = a + b so S(b + a) = S(a + b) and the proof is complete.