INDUCTION AND RECURSION Lecture 7 - Ch. 4
4. Introduction Any mathematical statements assert that a property is true for all positive integers Examples: for every positive integer n: n! <= n n n3 -n is divisible by 3 a set with n elements has n subsets the sum of the first n positive integers is n(n + 1 ) This chapter goal is to understand the mathematical induction, and how it is used to prove results of this kind
4.1 Mathematical Induction 3 Mathematical Induction is used to show that P(n) is true for every positive integer n. Example: Suppose we have an infinite ladder, and we want to know whether we can reach every step on the ladder. We know two things 1. We can reach the first rung of the ladder.. If we can reach a particular rung of the ladder, then we can reach the next rung.
4.1 Mathematical Induction 4 PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function, we complete two steps. 1. BASIS STEP: We verify that P(1) is true.. INDUCTIVE STEP: We show that the conditional statement P(k) P(k+1) is true for all positive integers k. q The assumption that P(k) is true is called the inductive hypothesis. q To complete the inductive step of a proof using the principle of mathematical induction, we assume that P(k) is true for an arbitrary positive integer k and show that under this assumption, P(k+1) must also be true. The proof technique is stated as [P(1)Λ k(p(k) P(k+1) )] np(n) where the domain is the set of positive integers
5 4.1 Mathematical Induction Show that if n is a positive integer, then Solution: 1 (1 + 1) BASIS STEP: because P(1)=1 (LHS), =1 (RHS). Thus, P(1) is true INDUCTIVE STEP: a) Assume P(k) is true for an arbitrary positive integer k. That is, we assume that P(k)= b) Under assumption (a), it must be shown that P(k+1) is true, i.e.: P(k+1)= Example 1 1+ +... + k = c) Comparing LHS in (a) and (b), we add k+1 to both sides of the equation in P(k) P(k)+k+1= =P(k+1) 1+ +... + k + ( k 1+ +... + k + ( k k( k + 1) + 1) = + 1) = ( k 1+ +... + n + 1)[( k + 1) + 1] k( k + 1) + ( k + 1) = ( k = k( k n( n + 1) = + 1)( k + ) + 1) + ( k + 1) ( k = + 1)( k + ) This shows that P(k+1) is true under the assumption that P(k) is true. 5
4.1 Mathematical Induction Example : 6 For all nonnegative integers n. Use mathematical induction to show that: 1 + + + + n = n+1 1 Solution: BASIS STEP: because P(1)= 0 = 1 (LHS), 1 1 =1 (RHS). Thus, P(1) is true INDUCTIVE STEP: a) Assume P(k) is true for an arbitrary positive integer k. That is, we assume that P(k)= 1 + + + + k = k+1 1 b) Under assumption (a), it must be shown that P(k+1) is true, i.e.: P(k+1)=1 + + + + k + k+1 = (k+1)+1 1 = k+ 1 c) Comparing LHS in (a) and (b), we add k+1 to both sides of the equation in P(k) P(k)+ k+1 = 1 + + + + k + k+1 = ( k+1 1) + k+1 = k+1 1 = k+ 1 =P(k+1) This shows that P(k+1) is true under the assumption that P(k) is true.
4. Strong Induction 7 PRINCIPLE OF STRONG INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function, we complete two steps: 1. BASIS STEP : We verify that the proposition P(1) is true.. INDUCTIVE STEP: We show that the conditional statement [P(1) /\ P() /\... /\ P(k)] à P(k + 1) is true for all positive integers k. Note: When we use strong induction to prove that P (n) is true for all positive integers n, our inductive hypothesis is the assumption that P(j) is true for j = 1,,..., k. That is, the inductive hypothesis includes all k statements P(1), P(),..., P(k). Because we can use all k statements P(1), P(),..., P(k) to prove P(k + 1), rather than just the statement P(k) as in a proof by mathematical induction, strong induction is a more flexible proof technique.
4. Strong Induction Example 1: 8 Show that if n is an integer greater than 1, then n can be written as the product of primes. Solution: BASIS STEP: because the first case is P()= (prime#).thus, P() is true INDUCTIVE STEP: a) The inductive hypothesis is the assumption that P(j) is true for all positive integers j k b) We show that P(k+1) is true under assumption (a), that is, we must show that k+1 is the product of primes. There are two cases to consider: 1. k+1 is prime à P (k+1) is true. k+1 is compositeà P (k+1)= a*b ( a b<k+1) By the inductive hypothesis, both a and b can be written as the product of primes. Thus, if k + 1 is composite, it can be written as the product of primes, namely, those primes in the factorization of a and those in the factorization of b.
4. Strong Induction Example : 9 Use strong induction to show that if you can run one mile or two miles, and if you can always run two more miles once you have run a specified number of miles, then you can run any number of miles. Solution: BASIS STEP: because we are told we can run one mile, so P (1) is true INDUCTIVE STEP: a) The inductive hypothesis is the assumption that P(j) is true; which is we can run any number of miles from 1 to k. [P(j) is true for all positive integers 1 j k] b) We show that P(k+1) is true under assumption (a), that is, we must show that we can run k + 1 miles: If k = 1, then we are already told that we can run two miles. If k > 1, then the inductive hypothesis tells us that we can run k-1 miles, so we can run (k-1) + = k + 1 miles.
10 4.3 Recursive Definitions and Structural Induction Introduction
4.3 Recursive Definitions and Structural Induction 11 Sometimes it s easier to define an object in terms of itself. This process is called Recursion. Example: The sequence of powers of : 1,, 4, 8, 16, 3, 64, 18, can be found by: Using the sequence given by the formula a n = n for n = 0, 1,, Or, using recursion: 1. Find first term of the sequence, namely, a 0 = 1, then. find a term of the sequence from the previous one, namely, a n = a n -1, for n = 1,,.
1 4.3 Recursive Definitions and Structural Induction Recursively Defined Functions Use two steps to define a function with the set of nonnegative integers as its domain: BASIS STEP: Specify that value of the function at zero. (f(0)) RECURSIVE STEP: Give a rule for finding its value at an integer from its values at smaller integers. (f(n)=g(n-1)) Such a definition is called a recursive or inductive definition. Examples: Suppose that f is defined recursively by f(0) = 3, f(n) = f(n-1) + 3 Find f(1), f(), f(3), and f(4). Solution: f(1) = f(0) + 3 = *3 + 3 = 9 f() = f(1) + 3 = *9 + 3 = 1 f(3) = f() + 3 = *1 + 3 = 45 f(4) = f(3) + 3 = *45 + 3 = 93
4.3 Recursive Definitions and Structural Induction 13 Example1: Give an recursive definition of the factorial function f(n) = n!. Then find f(5) Solution: The recursive definition is: Basis Step: f(0) = 1 Recursive Step: f(n) = (n)*f(n-1) F(5) =5 F(4) =5*4F(3) =5*4*3 F() =5 * 4 * 3 * F(1) =5 * 4 * 3 * * 1F(0) = 5 * 4 * 3 * * 1 * 1 = 10
4.3 Recursive Definitions and Structural Induction 14 Example: Give a recursive definition of. n å k = 0 Solution: a k Basis Step: å k = 0 = a 0 + a 1 + a + a 3 + a n 0 å k = 0 a k = a 0 n a k Inductive Step: ' '+, # a % = # a % + a ' %() %()
4.3 Recursive Definitions and Structural Induction 15 DEFINITION 1 The Fibonacci numbers, f 0, f 1, f,, are defined by the equations Basis step: f 0 = 0, f 1 =1 Recursive step: f n = f n-1 + f n- for n =, 3, 4,. Example: Find the Fibonacci numbers f, f 3, f 4, f 5, and f 6. Solution: f = f 1 + f 0 = 1 + 0 = 1, f 3 = f + f 1 = 1 + 1 =, f 4 = f 3 + f = + 1 = 3, f 5 = f 4 + f 3 = 3 + = 5, f 6 = f 5 + f 4 + 5 + 3 = 8. Example: Find the Fibonacci numbers f 7. Solution?
f f 1 f 1 f 0 4.3 Recursive Definitions and Structural Induction 16 f 4 f 3 f f n+1-1 addition to find f n f 1 f 0 (f 5-1) addition to find f 4 = (5-1) = 4 additions