21
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

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

  • Upload
    lehuong

  • View
    241

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 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

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.

[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. 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. . .

That will take forever, which is too long.

[email protected] (1W2.1) CM10196 Topic 3: Induction 3 / 63

Page 2: 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

Induction

Mathematical induction lets us prove a statement about all naturalnumbers by proving only two facts:

I the statement is true of the number 0

I if the statement is true of some number n, then it is true of n + 1.

[email protected] (1W2.1) CM10196 Topic 3: Induction 4 / 63

Like toppling dominoes

Suppose we can establish that these two statements are true:

I The first domino (which we call domino 0) is going to fall.

I If domino n is going to fall, so is domino n + 1.

Then we can conclude that all the dominoes are going to fall.

[email protected] (1W2.1) CM10196 Topic 3: Induction 5 / 63

Proving that the dominoes will fall

How can we prove that all the dominoes will fall?

I Establish directly that the first one is going to fall. For example, wecould just knock it over ourselves!

I Establish that the dominoes are sufficiently close together that whenone falls, the next one does.

The second point is essentially saying that the dominoes have a particularproperty. It is this property that makes them all fall down.

[email protected] (1W2.1) CM10196 Topic 3: Induction 6 / 63

Page 3: 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

Never mind the dominoes, here’s the natural numbers

Here’s a property of the natural numbers:

∀n ∈ N.n3 − n is divisible by 6.

To prove this by induction, we need to prove:

I 0 satisfies the property, i.e. 03 − 0 is divisible by 6.

I if some n satisfies the property then so does n + 1, i.e. if n3 − n isdivisible by 6 then so is (n + 1)3 − (n + 1).

[email protected] (1W2.1) CM10196 Topic 3: Induction 7 / 63

Why will this work?

If we can prove these two things, then we will know that every n3 − n isdivisible by 6. Why?

I We know that 03 − 0 is divisible by 6: that was the first thing we’veproved.

I We know that if 03 − 0 is divisible by 6, so is 13 − 1. Putting thesetwo things together we can conclude that 13 − 1 is divisible by 6.

I We know that if 13 − 1 is divisible by 6, so is 23 − 2. Putting thistogether with the last fact, we can conclude that 23 − 2 is divisible by6.

I We know that if 23 − 2 is divisible by 6, so is 33 − 3. Putting thistogether with the last fact, we can conclude that 33 − 3 is divisible by6.

I . . .

That’s why proof by induction is a valid [email protected] (1W2.1) CM10196 Topic 3: Induction 8 / 63

Let’s do the proof

For the first part, called the “base case” or the “basis” of the induction,we simply notice that 03 − 0 = 0 which is divisible by 6.

The second part requires more work.

[email protected] (1W2.1) CM10196 Topic 3: Induction 9 / 63

Page 4: 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

The inductive step

For the second part, called the “inductive step”, we reason as follows.

(n + 1)3 − (n + 1) = n3 + 3n2 + 3n + 1− n − 1 = (n3 − n) + 3n2 + 3n

If n3 − n is divisible by 6, then this number will be divisible by 6 as long as

3n2 + 3n

is divisible by 6. But3n2 + 3n = 3n(n + 1)

which will be divisible by 6 as long as one of n or n + 1 is divisible by 2.

For any natural number n, either n is divisible by 2 or n + 1 is, so ourproof is complete.

[email protected] (1W2.1) CM10196 Topic 3: Induction 10 / 63

Writing down an inductive proof

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 11 / 63

Inductive hypothesis

In the inductive step, we only have to show that (n + 1)3 − (n + 1) isdivisible by 6 if n3 − n is.

That means we can use the fact that n3 − n is divisible by 6 in ourargument that (n + 1)3 − (n + 1) is.

When we do this, we are “using the inductive hypothesis”.

This is what makes inductive proofs work.

[email protected] (1W2.1) CM10196 Topic 3: Induction 12 / 63

Page 5: 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

A classic example: summing the naturals

For every natural number n,x=n∑x=0

x =n(n + 1)

2.

We prove this by induction.

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(

P(0) ∧ ∀n ∈ N.(P(n)→ P(n + 1)))→ ∀n ∈ N.P(n).

I Basis

I Inductive step

I Conclusion

[email protected] (1W2.1) CM10196 Topic 3: Induction 14 / 63

Proving the inductive step

The inductive step requires us to prove that

∀n ∈ N.(P(n)→ P(n + 1))

is true.

The way we do this in practice is:

I let n be any natural number

I show that P(n + 1) holds provided P(n) does.

What this means is we show that P(n + 1) holds using the “fact” thatP(n) holds.

We don’t know that P(n) is true; we just show that, if it is, then so isP(n + 1).

[email protected] (1W2.1) CM10196 Topic 3: Induction 15 / 63

Page 6: 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

Example: the size of powersets

If A is a finite set, we write |A| for the number of elements in A.

Let’s prove that|PA| = 2|A|.

What we will show is in fact this:

For all natural numbers n, for all B ⊆ A such that |B| = n, |PB| = 2n.

See how we’ve turned a property of sets into something quantified over allnatural numbers. . .

[email protected] (1W2.1) CM10196 Topic 3: Induction 16 / 63

Size of powersets

Basis. We must show that for every B ⊆ A with |B| = 0, it is the casethat |PB| = 20 = 1.

The only set with size 0 is ∅, the empty set. Its powerset is {∅}, which hassize 1, so the base case is complete.

[email protected] (1W2.1) CM10196 Topic 3: Induction 17 / 63

Size of powersets

Inductive step. We must show that if the property holds for all B ⊆ Awith |B| = n, then it also holds for those B ⊆ A with |B| = n + 1.

Suppose |B| = n + 1. Since this is at least 1, there must be an elementb ∈ B.

Consider the set B \ {b}. This is a subset of A and its size is n. Thereforeby the inductive hypothesis

|P(B \ {b})| = 2n.

[email protected] (1W2.1) CM10196 Topic 3: Induction 18 / 63

Page 7: 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

Size of powersets

What subsets of B are there? To help us analyze them, let’s consider asmall example.

If B is the set {a, b, c}, then the subsets of B are:I those that do not contain b:

1 ∅2 {a}3 {c}4 {a, c}

I those that do contain b:1 {b} = {b} ∪ ∅2 {a, b} = {b} ∪ {a}3 {b, c} = {b} ∪ {c}4 {a, b, c} = {b} ∪ {a, c}

[email protected] (1W2.1) CM10196 Topic 3: Induction 19 / 63

Inductive step

In general, there are

I subsets that do not contain b

I subsets that contain b.

The subsets that do not contain b are exactly the same as the subsets ofB \ {b}, so there are 2n of them.

Every subset that does contain b is of the form {b} ∪ S , where S is asubset that does not contain b. So, there are 2n of these too.

So in total there are 2n + 2n = 2× 2n = 2n+1 subsets of B.

The inductive step is complete.

[email protected] (1W2.1) CM10196 Topic 3: Induction 20 / 63

Concluding

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 21 / 63

Page 8: 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

Different base cases

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 22 / 63

A logical example: generalized distributive law

Show that, for any formulae x and y1, . . . , yn, (with n ≥ 1),

x ∧ (y1 ∨ · · · ∨ yn) ≡ (x ∧ y1) ∨ · · · ∨ (x ∧ yn).

Basis. The base case here is n = 1, and in that case both sides of theequivalence are x ∧ y1 so the equivalence holds.Inductive step.

x ∧ (y1 ∨ · · · ∨ yn ∨ yn+1) ≡ x ∧ ((y1 ∨ · · · ∨ yn) ∨ yn+1)

using associativity of ∨≡ (x ∧ (y1 ∨ · · · ∨ yn)) ∨ (x ∧ yn+1)

using distributivity

≡ (x ∧ y1) ∨ · · · ∨ (x ∧ yn) ∨ (x ∧ yn+1)

using the inductive hypothesis.

[email protected] (1W2.1) CM10196 Topic 3: Induction 23 / 63

Divisibility by primes

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 24 / 63

Page 9: 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

Uh oh!

But wait!

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 25 / 63

Course-of-values induction aka strong induction

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 26 / 63

Course-of-values induction

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 27 / 63

Page 10: 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

Prime divisibility again

We can now prove our statement about the natural numbers usingcourse-of-values induction.

Basis. We need to show that 2 is either prime or divisible by a prime. It’sprime so we’re done.

Inductive step. We need to show that, if every m ≤ n has this property,then so does n + 1.

I If n + 1 is prime, we are done.I If not, n + 1 must be divisible by some m ≤ n. By the inductive

hypothesis, m is either prime or divisible by some prime p.I If m is prime, we’ve shown that n + 1 is divisible by the prime m, so

we’re done.I If not, m is divisible by p and n + 1 is divisible by m, so n + 1 is

divisible by p, so we’re done.

[email protected] (1W2.1) CM10196 Topic 3: Induction 28 / 63

Course-of-values induction follows from ordinary induction

The principle of induction is this:(P(0) ∧ ∀n ∈ N.P(n)→ P(n + 1)

)→ ∀n ∈ N.P(n).

Course-of-values induction is this:(P(0) ∧ ∀n ∈ N.(∀m ∈ N.m ≤ n→ P(m))→ P(n + 1)

)→ ∀n ∈ N.P(n).

It turns out that the course-of-values induction formula follows from theordinary induction formula.

[email protected] (1W2.1) CM10196 Topic 3: Induction 29 / 63

Course-of-values induction from ordinary induction

Take the ordinary induction formula, and replace the predicate P(n) by thepredicate ∀m ∈ N.m ≤ n→ P(m).

The base case,P(0)

becomes∀m ∈ N.m ≤ 0→ P(m)

which is equivalent to P(0).

[email protected] (1W2.1) CM10196 Topic 3: Induction 30 / 63

Page 11: 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

Course-of-values induction from ordinary induction

The inductive step,∀n ∈ N.P(n)→ P(n + 1)

becomes

∀n ∈ N.(

(∀m ∈ N.m ≤ n→ P(m))→ ( ∀m ∈ N.m ≤ n + 1→ P(m) ))

This is equivalent to

∀n ∈ N.

(∀m ∈ N.m ≤ n→ P(m))→

∀m ∈ N.m ≤ n→ P(m)∧

P(n + 1)

[email protected] (1W2.1) CM10196 Topic 3: Induction 31 / 63

Simplifying the inductive step

The formula for the inductive step is

∀n ∈ N.

(∀m ∈ N.m ≤ n→ P(m)) →

∀m ∈ N.m ≤ n→ P(m)

∧P(n + 1)

Using the logical law

X → ( X ∧ Y ) ≡ X → Y

this is equivalent to

∀n ∈ N.(

(∀m ∈ N.m ≤ n→ P(m)) → P(n + 1))

[email protected] (1W2.1) CM10196 Topic 3: Induction 32 / 63

The conclusion

The conclusion∀n ∈ N.P(n)

becomes∀n ∈ N.∀m ∈ N.m ≤ n→ P(m).

These two statements are logically equivalent.

[email protected] (1W2.1) CM10196 Topic 3: Induction 33 / 63

Page 12: 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

Course-of-values induction

Putting all this together, we find that taking the formula for induction:(P(0) ∧ ∀n ∈ N.P(n)→ P(n + 1)

)→ ∀n ∈ N.P(n).

and replacing P(n) with ∀m ∈ N.m ≤ n→ P(m), we get a formulaequivalent to(

P(0) ∧ ∀n ∈ N.(∀m ∈ N.m ≤ n→ P(n))→ P(n + 1)

)→ ∀n ∈ N.P(n)

which is our course-of-values induction principle. Phew!

[email protected] (1W2.1) CM10196 Topic 3: Induction 34 / 63

A stronger fact about primes

Exercise

Use course-of-values induction to show that every natural number can bewritten as a product of prime numbers.

That is to say, every natural number n is equal to

p1 × p2 × · · · × pk

for some collection of prime numbers p1, . . . , pk .

[email protected] (1W2.1) CM10196 Topic 3: Induction 35 / 63

Inductive definitions

In programming, you have surely seen definitions of functions which look alittle bit like this:

factorial 0 = 1factorial (n+1) = (factorial n) * (n+1)

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!

[email protected] (1W2.1) CM10196 Topic 3: Induction 36 / 63

Page 13: 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

Recursion and induction

In programming, we know that we can compute functions like that oneusing recursion: when we ask the computer to evaluate

factorial 10

I it goes off and tries to compute (factorial 9) * 10

I which makes it compute (factorial 8) * 9 * 10

I which makes it compute (factorial 7) * 8 * 9 * 10

I . . .

I which makes it compute (factorial 0) * 1 * ... * 9 * 10

I which makes it compute 1 * 1 * ... * 9 * 10

which has a value.

[email protected] (1W2.1) CM10196 Topic 3: Induction 37 / 63

Recursion and induction

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.

Induction helps us do that.

[email protected] (1W2.1) CM10196 Topic 3: Induction 38 / 63

Well-definedness of factorial

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 39 / 63

Page 14: 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

The Fibonacci sequence

What about a definition like this one?

fib(0) = 1fib(1) = 1fib(n+2) = fib(n+1) + fib(n)

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. . .

[email protected] (1W2.1) CM10196 Topic 3: Induction 40 / 63

Well-definedness of Fibonacci

Uh-oh. Here we need to know that fib(n-1) is well-defined, but theinductive hypothesis does not help.

The solution should be clear from previous examples: use course-of-valuesinduction.

In fact we can get away with a slightly weaker form: we only need ourinductive hypothesis to apply to the last two values.

[email protected] (1W2.1) CM10196 Topic 3: Induction 41 / 63

“Double” induction

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 42 / 63

Page 15: 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

Another proof of the DNF theorem

In earlier lectures, we gave a slightly informal proof of the fact that everyBoolean formula is equivalent to one in disjunctive normal form.

Now that we have induction to help us, we can give a much more preciseproof.

We will prove the theorem by induction on the size of the formula. Thatis, what we are really proving is 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 ′.

[email protected] (1W2.1) CM10196 Topic 3: Induction 43 / 63

DNF and CNF theorem

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 44 / 63

DNF/CNF theorem

Basis. The only formulae with 1 symbol are variables X , Y etc. These arealready in DNF and in CNF, so we can take F ′ = F ′′ = F and we are done.

Inductive step. A Boolean formula with more than one symbol must beof one of the following forms:

I (F1 ∧ F2)

I (F1 ∨ F2)

I (F1 → F2)

I ¬F .

We will consider these cases one by one.

[email protected] (1W2.1) CM10196 Topic 3: Induction 45 / 63

Page 16: 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

DNF/CNF theorem: conjunction case

Consider the case of a formula F = (F1 ∧ F2).

The formulae F1 and F2 have fewer symbols than F , so by the inductivehypothesis, they have DNFs F ′

1 and F ′2 and CNFs F ′′

1 and F ′′2 .

Then the formula (F ′′1 ∧ F ′′

2 ) is a CNF which is equivalent to F , so we cantake F ′′ to be this, completing the CNF part of the inductive step in thiscase.

For the DNF part, we will transform the formula (F ′1 ∧ F ′

2) into a DNFusing the distributive law.

[email protected] (1W2.1) CM10196 Topic 3: Induction 46 / 63

Distributing

F ′1 is a DNF so it has the form

G1 ∨ · · · ∨ Gk

where each Gi is a conjunction of literals

Gi = L1 ∧ · · · ∧ Lki.

Similarly, F ′2 has the form

H1 ∨ · · · ∨ Hl .

Therefore F ′1 ∧ F ′

2 is equivalent to

(F ′1 ∧ H1) ∨ · · · ∨ (F ′

1 ∧ Hl)

by the generalized distributive law.

[email protected] (1W2.1) CM10196 Topic 3: Induction 47 / 63

Distributing

Applying distributivity again we find that F ′1 ∧ F ′

2 is equivalent to

(G1 ∧ H1) ∨ (G2 ∧ H1) ∨ · · · ∨ (Gk ∧ H1)

∨(G1 ∧ H2) ∨ (G2 ∧ H2) ∨ · · · ∨ (Gk ∧ H2)

∨...

∨(G1 ∧ Hl) ∨ (G2 ∧ Hl) ∨ · · · ∨ (Gk ∧ Hl)

This is in DNF so this part of the proof is complete.

[email protected] (1W2.1) CM10196 Topic 3: Induction 48 / 63

Page 17: 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

DNF/CNF theorem: negation case

Consider the case of a formula F = ¬F1.

The formula F1 has fewer symbols, so by the inductive hypothesis, it canbe written in both DNF, F ′

1, and CNF, F ′′1 .

We will use de Morgan’s laws to transform ¬F ′1 into a CNF, and ¬F ′′

2 intoa DNF. In both cases we will end up with a formula equivalent to ¬F1

which is F , so this will complete the proof for this case.

Notice that it’s the DNF of F1 which gives rise to the CNF of F and viceversa. That is why it is “easier” to prove the DNF and CNF theoremstogether.

[email protected] (1W2.1) CM10196 Topic 3: Induction 49 / 63

DNF/CNF theorem: negation case

If F ′1 = G1 ∨ · · · ∨ Gk where each Gi has the form L1 ∧ · · · ∧ Lki

, then ¬F ′1

is equivalent to(¬G1 ∧ · · · ∧ ¬Gk)

using de Morgan’s law.

Using de Morgan’s law again, each ¬Gi is equivalent to something of theform

¬L1 ∨ · · · ¬Lki.

Finally, where Li = ¬Xi we can replace ¬¬Xi in the above by Xi andfinally we obtain a CNF equivalent to ¬F ′

1.

Similarly we can use de Morgan’s laws to transform ¬F ′′2 into a DNF.

[email protected] (1W2.1) CM10196 Topic 3: Induction 50 / 63

DNF/CNF theorem: other cases

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).

This completes the proof.

[email protected] (1W2.1) CM10196 Topic 3: Induction 51 / 63

Page 18: 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

Structural induction

What we did in that proof was very typical of many proofs about thingslike formulae or simple data structures in programs:

I we noticed that every formula is built up out of smaller formulaeusing certain constructions

I we proved our statement by breaking a formula up into its smallerformulae and applying the inductive hypothesis to the smallerformulae.

It seems a bit silly to bother with the business of turning this into aninduction on numbers: talking about the number of symbols in theformula etc.

[email protected] (1W2.1) CM10196 Topic 3: Induction 52 / 63

Structural induction

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 53 / 63

Structural induction

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.)

[email protected] (1W2.1) CM10196 Topic 3: Induction 54 / 63

Page 19: 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

Why does it work?

This works because, in some sense, Boolean formulae are inductivelydefined: something is a Boolean formula if it is

I a variable, X , or

I a formula (F1 ∧ F2), (F1 ∨ F2), (F1 → F2) or ¬F1 where F1 and F2

are Boolean formulae.

This is an inductive definition because larger formulae are defined in termsof smaller ones.

Whenever you see a collection of things defined in this way, there will be astructural induction principle that can be used.

[email protected] (1W2.1) CM10196 Topic 3: Induction 55 / 63

Mathematical induction as structural induction

The ordinary induction principle can also be seen as having this form.

To do this, we have to see the natural numbers as “having structure”which we can break down.

One important way of defining the natural numbers is as follows. Anatural number is

I The number 0, or

I A number S(n), where n is a natural number.

Here S stands for successor. We think of S(n) as meaning n + 1.

[email protected] (1W2.1) CM10196 Topic 3: Induction 56 / 63

Structural induction on naturals

The structural induction principle for natural numbers defined like that isas follows.

To prove that some property P(n) holds for every natural, we need toprove that

I P(0) holds

I If P(n) holds for some n then P(S(n)) also holds.

In a formula:

P(0) ∧ ∀n ∈ N.P(n)→ P(S(n))→ ∀n ∈ N.P(n)

[email protected] (1W2.1) CM10196 Topic 3: Induction 57 / 63

Page 20: 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

Peano arithmetic

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:

a + 0 = a (basis)

a + S(b) = S(a + b) (inductive case)

[email protected] (1W2.1) CM10196 Topic 3: Induction 58 / 63

Peano arithmetic

Using only this structural definition, we can establish a lot of facts aboutarithmetic quite easily, via induction.

For example, we can show that our inductive (or is it recursive?) definitionof + is commutative. That is, show that for all natural numbers a and b,

a + b = b + a.

Let’s do it!

[email protected] (1W2.1) CM10196 Topic 3: Induction 59 / 63

Commutativity of addition

Lemma

For any natural a, 0 + a = a.

We prove this by induction on a.

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 60 / 63

Page 21: 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

Commutativity of addition

Lemma

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

S(a) + S(b) = S(S(a + b)) = S(a + S(b))

as required.

[email protected] (1W2.1) CM10196 Topic 3: Induction 61 / 63

Commutativity of addition

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.

[email protected] (1W2.1) CM10196 Topic 3: Induction 62 / 63

More fun with Peano arithmetic

ExerciseI Show that this definition of + satisfies the commutative law.

I Give an inductive definition of the operation of multiplication onnatural numbers. You may use the + operation defined above.

I Show that S(0) is an identity for multiplication, i.e. that

a× S(0) = a.

I Show that multiplication is commutative.

[email protected] (1W2.1) CM10196 Topic 3: Induction 63 / 63