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 Induction Mathematical induction lets us prove a statement about all natural numbers 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, we could just knock it over ourselves! I Establish that the dominoes are sufficiently close together that when one falls, the next one does. The second point is essentially saying that the dominoes have a particular property. It is this property that makes them all fall down. [email protected] (1W2.1) CM10196 Topic 3: Induction 6 / 63 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 is divisible 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 is divisible by 6. Why? I We know that 03 − 0 is divisible by 6: that was the first thing we’ve proved. I We know that if 03 − 0 is divisible by 6, so is 13 − 1. Putting these two 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 this together with the last fact, we can conclude that 23 − 2 is divisible by 6. I We know that if 23 − 2 is divisible by 6, so is 33 − 3. Putting this together with the last fact, we can conclude that 33 − 3 is divisible by 6. I ... That’s why proof by induction is a valid principle. [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 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. But 3n2 + 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 our proof 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 basis and one for the inductive step. Like this. Basis. We must show that 03 − 0 = 0 is divisible by 6, which is trivially true. Inductive step. We must show that (n + 1)3 − (n + 1) is divisible by 6 if n3 − 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 suffices to 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) is divisible by 6 if n3 − n is. That means we can use the fact that n3 − n is divisible by 6 in our argument 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 A classic example: summing the naturals For every natural number n, x=n X x= x=0 n(n + 1) . 2 We prove this by induction. Basis. We must prove that the sum of naturals from 0 to 0 is equal to 0(0 + 1)/2 = 0, which is true. Inductive step. We must prove that the sum of naturals from 0 to n + 1 is n(n + 1) 2(n + 1) n(n + 1) (n + 1)(n + 2) = + = + (n + 1). 2 2 2 2 Px=n By the inductive hypothesis, n(n + 1)/2 = x=0 x so the expression above is equal to ! x=n X x + (n + 1) x=0 which is clearly the required sum. [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) is any 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” that P(n) holds. We don’t know that P(n) is true; we just show that, if it is, then so is P(n + 1). [email protected] (1W2.1) CM10196 Topic 3: Induction 15 / 63 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 all natural 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 case that |PB| = 20 = 1. The only set with size 0 is ∅, the empty set. Its powerset is {∅}, which has size 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 ⊆ A with |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 element b ∈ B. Consider the set B \ {b}. This is a subset of A and its size is n. Therefore by the inductive hypothesis |P(B \ {b})| = 2n . [email protected] (1W2.1) CM10196 Topic 3: Induction 18 / 63 Size of powersets What subsets of B are there? To help us analyze them, let’s consider a small example. If B is the set {a, b, c}, then the subsets of B are: I those that do not contain b: 1 2 3 4 I ∅ {a} {c} {a, c} those that do contain b: 1 2 3 4 {b} = {b} ∪ ∅ {a, b} = {b} ∪ {a} {b, c} = {b} ∪ {c} {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 of B \ {b}, so there are 2n of them. Every subset that does contain b is of the form {b} ∪ S, where S is a subset 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 statement about 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 of A. [email protected] (1W2.1) CM10196 Topic 3: Induction 21 / 63 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 from the standard principle of induction. Hint: given a predicate P(n), consider the predicate P 0 (n) defined to be P(n + 6), i.e. P 0 (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 the equivalence 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 divisible by 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 does for n. The number n + 1 is either prime or not. If it is, then it satisfies the property. If it’s not, then. . . what? We know it must be divisible by something. If it’s divisible by n then we can use our inductive hypothesis: n is itself a prime, or divisible by a prime. So if n + 1 is divisible by n, then n + 1 is divisible by a prime—either n itself or the prime that n is divisible by. [email protected] (1W2.1) CM10196 Topic 3: Induction 24 / 63 Uh oh! But wait! We don’t know that n + 1 is divisible by n, and in fact it won’t be, except when 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 have proved what we need) or it’s divisible by some number m. We also know that m ≤ n. If we could apply our inductive hypothesis to m, we’d be fine: the reasoning from the last slide would work. But the principle of induction only gives us an inductive hypothesis for the number n, not for every m ≤ 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, by the time domino n + 1 is ready to fall, not only has domino n fallen, all dominoes 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 hypothesis on every m ≤ n. The principle of course-of-values induction, also known as strong induction, 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 for every 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) for any m ≤ n. As with ordinary induction we can use different base values if we only need a property to hold for numbers greater than a certain minimum. [email protected] (1W2.1) CM10196 Topic 3: Induction 27 / 63 Prime divisibility again We can now prove our statement about the natural numbers using course-of-values induction. Basis. We need to show that 2 is either prime or divisible by a prime. It’s prime so we’re done. Inductive step. We need to show that, if every m ≤ n has this property, then so does n + 1. I I If n + 1 is prime, we are done. 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 I If m is prime, we’ve shown that n + 1 is divisible by the prime m, so we’re done. 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 the ordinary 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 the predicate ∀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 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)) → [email protected] (1W2.1) ∀m ∈ N.m ≤ n → P(m) ∧ P(n + 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. [email protected] (1W2.1) (∀m ∈ N.m ≤ n → P(m)) → P(n + 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 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 formula equivalent 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 be written 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 a little bit like this: factorial 0 = 1 factorial (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 and immediately react by thinking “Is that well-defined?”, you have become a mathematician! [email protected] (1W2.1) CM10196 Topic 3: Induction 36 / 63 Recursion and induction In programming, we know that we can compute functions like that one using 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 * ... I which makes it compute 1 * 1 * ... * 9 * 10 * 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 one possible answer. In principle, a recursive “function definition” could define nothing at all, or define a “function” which has more than one possible answer for some inputs. (This would not actually be a function.) A mathematician, or a conscientious programmer, would want to be sure that 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 a unique 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 the equations, then there is a unique fn+1 . But the second equation tells us that 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 The Fibonacci sequence What about a definition like this one? fib(0) = 1 fib(1) = 1 fib(n+2) = fib(n+1) + fib(n) How can we be sure that this is well-defined? If we try to use induction as before, the inductive step looks like this: Inductive step. We must show that if fib(n) is well defined, so is fib(n+1). If n = 0 this is easy: fib(1) = 1 by definition. For n > 0, the definition tells us that fib(n+1) = fib(n) + fib(n-1). Our inductive hypothesis 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 the inductive hypothesis does not help. The solution should be clear from previous examples: use course-of-values induction. In fact we can get away with a slightly weaker form: we only need our inductive 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 Fibonacci sequence 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), can be seen as the base case P 0 (0) of the ordinary induction principle with a different predicate. [email protected] (1W2.1) CM10196 Topic 3: Induction 42 / 63 Another proof of the DNF theorem In earlier lectures, we gave a slightly informal proof of the fact that every Boolean formula is equivalent to one in disjunctive normal form. Now that we have induction to help us, we can give a much more precise proof. We will prove the theorem by induction on the size of the formula. That is, 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 0 in disjunctive normal form such that F ≡ F 0 . [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 theorems at 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 0 in disjunctive normal form such that F ≡ F 0 , and a formula F 00 in conjunctive normal form such that F ≡ F 00 . Our base case will be n = 1, because there are no formulae with zero symbols. 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 are already in DNF and in CNF, so we can take F 0 = F 00 = F and we are done. Inductive step. A Boolean formula with more than one symbol must be of 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 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 inductive hypothesis, they have DNFs F10 and F20 and CNFs F100 and F200 . Then the formula (F100 ∧ F200 ) is a CNF which is equivalent to F , so we can take F 00 to be this, completing the CNF part of the inductive step in this case. For the DNF part, we will transform the formula (F10 ∧ F20 ) into a DNF using the distributive law. [email protected] (1W2.1) CM10196 Topic 3: Induction 46 / 63 Distributing F10 is a DNF so it has the form G1 ∨ · · · ∨ Gk where each Gi is a conjunction of literals Gi = L1 ∧ · · · ∧ Lki . Similarly, F20 has the form H1 ∨ · · · ∨ Hl . Therefore F10 ∧ F20 is equivalent to (F10 ∧ H1 ) ∨ · · · ∨ (F10 ∧ Hl ) by the generalized distributive law. [email protected] (1W2.1) CM10196 Topic 3: Induction 47 / 63 Distributing Applying distributivity again we find that F10 ∧ F20 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 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 can be written in both DNF, F10 , and CNF, F100 . We will use de Morgan’s laws to transform ¬F10 into a CNF, and ¬F200 into a 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 vice versa. That is why it is “easier” to prove the DNF and CNF theorems together. [email protected] (1W2.1) CM10196 Topic 3: Induction 49 / 63 DNF/CNF theorem: negation case If F10 = G1 ∨ · · · ∨ Gk where each Gi has the form L1 ∧ · · · ∧ Lki , then ¬F10 is equivalent to (¬G1 ∧ · · · ∧ ¬Gk ) using de Morgan’s law. Using de Morgan’s law again, each ¬Gi is equivalent to something of the form ¬L1 ∨ · · · ¬Lki . Finally, where Li = ¬Xi we can replace ¬¬Xi in the above by Xi and finally we obtain a CNF equivalent to ¬F10 . Similarly we can use de Morgan’s laws to transform ¬F200 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 the conjunction case. The case of a formula of the form (F1 → F2 ) can be handled by means of the 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 Structural induction What we did in that proof was very typical of many proofs about things like formulae or simple data structures in programs: I we noticed that every formula is built up out of smaller formulae using certain constructions I we proved our statement by breaking a formula up into its smaller formulae and applying the inductive hypothesis to the smaller formulae. It seems a bit silly to bother with the business of turning this into an induction on numbers: talking about the number of symbols in the formula 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 you take any natural number n and keep subtracting 1 from it, you reach zero after finitely many steps. Similarly, for any Boolean formula, if you keep breaking it down into its subformulae, 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 some predicate 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 it holds for (F1 ∧ F2 ), (F1 ∨ F2 ), (F1 → F2 ) and ¬F1 . (In practice, such proofs look just the same as the one we just wrote for the DNF/CNF theorem.) [email protected] (1W2.1) CM10196 Topic 3: Induction 54 / 63 Why does it work? This works because, in some sense, Boolean formulae are inductively defined: 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 terms of smaller ones. Whenever you see a collection of things defined in this way, there will be a structural 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. A natural 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 is as follows. To prove that some property P(n) holds for every natural, we need to prove 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 Peano arithmetic The idea of defining the natural numbers using 0 and S is used in the most popular axiomatization of arithmetic, called Peano arithmetic after its 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 a + S(b) = S(a + b) [email protected] (1W2.1) CM10196 Topic 3: Induction (basis) (inductive case) 58 / 63 Peano arithmetic Using only this structural definition, we can establish a lot of facts about arithmetic quite easily, via induction. For example, we can show that our inductive (or is it recursive?) definition of + 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 definition of +. 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 inductive hypothesis, 0 + a = a, so our result follows. [email protected] (1W2.1) CM10196 Topic 3: Induction 60 / 63 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) as required. Inductive step. We must show that S(a) + S(b) = S(a + S(b)). By definition of +, S(a) + S(b) = S(S(a) + b) and by the inductive hypothesis, 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 by our first lemma, 0 + a = a so we’re done. Inductive step. We must show that if a + b = b + a then a + S(b) = S(b) + a. By definition of +, a + S(b) = S(a + b). By our second 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 Exercise I Show that this definition of + satisfies the commutative law. I Give an inductive definition of the operation of multiplication on natural 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
© Copyright 2026 Paperzz