Mathematical Induction And Recursion Discrete Math Team KS091201 MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.

Slides:



Advertisements
Similar presentations
Mathematical Induction
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Discrete Mathematics Math 6A Homework 9 Solution.
Recursive Definitions and Structural Induction
Mathematical Induction
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
Induction and recursion
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CSE115/ENGR160 Discrete Mathematics 03/22/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen Induction.
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
1 Strong Mathematical Induction. Principle of Strong Mathematical Induction Let P(n) be a predicate defined for integers n; a and b be fixed integers.
1 Mathematical Induction. 2 Mathematical Induction: Example  Show that any postage of ≥ 8¢ can be obtained using 3¢ and 5¢ stamps.  First check for.
Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.
Induction and recursion
Induction and recursion
Discrete Mathematics Chapter 4 Induction and Recursion 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
Induction and recursion
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 4 Induction and Recursion 歐亞書局.
Chapter 4: Induction and Recursion
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
Discrete Mathematics Chapter 3 Mathematical Reasoning, Induction, and Recursion 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
INDUCTION AND RECURSION. PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function,
Module #14: Recursion Rosen 5 th ed., §§ In this class, we will study recursion, one of the most important topics in computer science. In the last.
Induction and recursion
Chapter 5 With Question/Answer Animations. Section 5.1.
Chap 3 –A theorem is a statement that can be shown to be true –A proof is a sequence of statements to show that a theorem is true –Axioms: statements which.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Mathematical Induction CS 202 Epp, chapter 4. 2.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Chapter 5 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki, Copyright.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Induction and Recursion CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
3.3 Mathematical Induction 1 Follow me for a walk through...
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
1 Mathematical Induction. 2 What is induction? A method of proof It does not generate answers: it only can prove them Three parts: Base case(s): show.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Chapter 4: Induction and Recursion
Induction and recursion
Recursive Algorithms Section 5.4.
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Induction and Recursion Chapter 5
Advanced Algorithms Analysis and Design
CS2210:0001Discrete Structures Induction and Recursion
Induction and recursion
Induction and Recursion
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Recursively Defined Functions
Mathematical Induction Recursion
Chapter 5 Induction and Recursion
Induction and recursion
Applied Discrete Mathematics Week 9: Integer Properties
Induction Chapter
Advanced Analysis of Algorithms
Mathematical Induction
Induction and recursion
Recursion.
Presentation transcript:

Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1

Outline 2 -- KS Simulation Game : Hanoi Tower Induction Definition Induction Example (Weak Induction) Strong Induction

3 -- KS091201

Simulation Game: Hanoi Tower The objective of the puzzle is to move the entire stack to another rod, obeying the following rules: 1.Only one disk may be moved at a time. 2.Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod. 3.No disk may be placed on top of a smaller disk. 4

What is induction?  A method of proof  It does not generate answers: it only can prove them  Three parts:  Base case(s): show it is true for one element  Inductive hypothesis: assume it is true for any given element  Must be clearly labeled!!!  Show that if it true for the next highest element 5

 Show that the sum of the first n odd integers is n 2  Example: If n = 5, = 25 = 5 2  Formally, Show  n P(n) where P(n) =  n i=1 2i-1= n 2  Base case: Show that P(1) is true  P(1) = 1  Inductive hypothesis: assume true for k  Thus, we assume that P(k) is true, or that P(k) =  k i=1 2i- 1= k 2  Note: we don’t yet know if this is true or not!  Inductive step: show true for k+1  We want to show that: P(k+1) =  k+1 i=1 2i-1= (k+1) 2 Induction example 6

Induction Example  Induction Hypothesis  P(k) =  k i=1 2i-1= k 2  Inductive Steps  P(k+1) =  k+1 i=1 2i-1 =  k i=1 2i-1 + (2 (k+1) -1) = k 2 + (2k +1) = (k+1) 2 7

What did we show  Base case: P(1)  If P(k) was true, then P(k+1) is true  i.e., P(k) → P(k+1)  We know it’s true for P(1)  Because of P(k) → P(k+1), if it’s true for P(1), then it’s true for P(2)  Because of P(k) → P(k+1), if it’s true for P(2), then it’s true for P(3)  Because of P(k) → P(k+1), if it’s true for P(3), then it’s true for P(4)  Because of P(k) → P(k+1), if it’s true for P(4), then it’s true for P(5)  And onwards to infinity  Thus, it is true for all possible values of n  In other words, we showed that:  [P(1)   k (P(k)  P(k+1))]   n P(n) 8

Second induction example  Show the sum of the first n positive even integers is n 2 + n  Rephrased:  n P(n) where P(n) =  n i=1 2 i = n 2 + n  The three parts:  Base case  Inductive hypothesis  Inductive step 9

Induction example  Show that n! 1  Base case: n = 2 2! < < 4  Inductive hypothesis: assume k! < k k  Inductive step: show that (k+1)! < (k+1) k+1  (k+1)!  = (k+1)  k!  < (k+1) k k  < (k+1) (k+1) k  = (k+1) k+1 10

Interesting Induction  Someone with zero hairs is bald.  Someone with one more hair than a bald person is bald. .. . turn the inductive crank…… ..  Therefore, someone with 1,000, 000 hairs is bald.  What’s wrong with this induction? 11

More Examples  Prove that if h> -1, then 1+nh  (1+h) n for all non-negative integer n.  Prove that n 2  1 mod 8 for all odd integer n. 12

Strong induction  Weak mathematical induction assumes P(k) is true, and uses that (and only that!) to show P(k+1) is true  Strong mathematical induction assumes P(1), P(2), …, P(k) are all true, and uses that to show that P(k+1) is true. [P(1)  P(2)  p(3)  …  P(k) ]  P(k+1) 13

Strong induction example 1  Show that any number > 1 can be written as the product of primes  Base case: P(2)  2 is the product of 2 (remember that 1 is not prime!)  Inductive hypothesis: P(1), P(2), P(3), …, P(k) are all true  Inductive step: Show that P(k+1) is true 14

Strong induction example 1  Inductive step: Show that P(k+1) is true  There are two cases:  k+1 is prime  It can then be written as the product of k+1  k+1 is composite  It can be written as the product of two composites, a and b, where 2 ≤ a ≤ b < k+1  By the inductive hypothesis, both P(a) and P(b) are true 15

Strong Induction Examples 2  Prove that every amount of 12 cents or more can be formed using just 4-cent and 5-sent stamps.  Basis Step  12 = 3 * 4 cent stamp  13 = 2 * * 5  14 = 1 * * 5  15 = 3 * 5  Inductive step: Suppose P(j) is true for 12  j  k (k  15). It is sufficient to show that P(k+1) is true. We know that P(k-3) is true since k  15. To form postage of k+1 cents, we just need to add 1 4-cent postage to the stamps we used to form k-3 cents. 16

Mathematical Induction Note : Mathematical induction can be used only to prove results obtained in some other way. It is not a tool for discovering formulae or theorems. P(n) : a propositional function (e.g. n ≦ 2 n ) A proof by mathematical induction (MI) that P ( n ) is true for every n  Z + consists of two steps : 1. Basis step : The proposition P(1) is shown to be true 2. Inductive step : the implication P(k) → P(k+1) is shown to be true for every k  Z + 17

Ch4 -18 Example 2. Use MI to prove that the sum of the first n odd positive integers is n 2. Note. Pf : Let P(n) denote the proposition that Basis step : P(1) is true, since 1=1 2 Inductive step : Suppose that P(k) is true for a positive integer k, i.e., …+(2k  1)=k 2 Note that …+(2k  1)+(2k+1) = k 2 +2k+1= (k+1) 2 ∴ P(k+1) is true By induction, P(n) is true for all n  Z + 18

Example 5. Use MI to prove the inequality n < 2 n for all n  Z + pf : Let P(n) be the proposition “ n < 2 n ”. Basis step : P(1) is true since 1 < 2 1. Inductive step : Assume that P(k) is true for a positive integer k, i.e., k < 2 k. Consider P(k+1) : k + 1 < 2 k + 1  2 k + 2 k =2 k + 1 ∴ P(k+1) is true. By MI, P(n) is true for all n  Z +. 19

Example 7. The harmonic numbers H k, k =1,2,3,…, are defined by. Use MI to show that Pf : Let P(n) be the proposition that “ ”. Basis step : P(0) is true, since. Inductive step : Assume that P(k) is true for some k, i.e., Consider P(k+1) : whenever n is a nonnegative integer. 20

∴ P(k+1) is true. By MI, P(n) is true for all n  Z +. >= 21

Strong Induction Basis step Inductive step : Assume all the statements P(1), P(2), …, P(k) are true. Show that P(k+1) is also true. 22

Example 2. Show that if n  Z and n >1, then n can be written as the product of primes. Pf : Let P(n) be the proposition that n can be written as the product of primes. Basis : P(2) is true, since 2 is a prime number Inductive : Assume P(2), P(3), …, P(k) are true. Consider P(k + 1) : Case 1 : k + 1 is prime  P(k+1) is true Case 2 : k + 1 is composite, i.e., k + 1 = ab where 2  a  b < k+1 By the induction hypothesis, both a and b can be written as the product of primes.  P(k+1) is true. By Strong MI, P(k) is true if k  Z and k >1. 23

Example 4. Prove that every amount of postage of 12 cents or more can be formed using just 4-cent and 5-cent stamps. Pf : Let P(n) be the statement that the postage of n cents can formed using just 4-cent and 5-cent stamps. Basis : P(12) is true, since 12 = 4  3; P(13) is true, since 13 = 4   1; P(14) is true, since 14 = 4   2; P(15) is true, since 15 = 5  3; Inductive : Assume P(12), P(13), …, P(k) are true. Consider P(k+1) : Suppose k  3 = 4  m + 5  n. Then k+1 = 4  (m  1) + 5  n.  P(k+1) is true. By Strong MI, P(n) is true if n  Z and n  12. (k  3  12) 24

Recursive Definitions. Def. The process of defining an object in terms of itself is called recursion. e.g. We specify the terms of a sequence using (1) an explicit formula: a n =2 n, n=0,1,2,… (2) a recursive form: a 0 =1, a n+1 =2a n, n=0,1,2,… Example 1. Suppose that f is defined recursively by f(0)=3, f(n+1)=2f(n)+3 Find f(1), f(2), f(3), f(4). 25

Example 2. Give an inductive (recursive) definition of the factorial function F(n) = n!. Sol : initial value : F(0) = 1 recursive form : F(n+1) = (n+1)! = n!  (n+1) = F(n)  (n+1) Def1, Example 5. The Fibonacci numbers f 0, f 1, f 2 …, are defined by : f 0 = 0, f 1 = 1, f n = f n  1 + f n  2, for n = 2,3,4,… what is f 4 ? Sol : f 4 = f 3 + f 2 = (f 2 + f 1 ) + (f 1 + f 0 ) = f = (f 1 + f 0 ) + 2 = 3 26

Example 6. Show that f n >  n  2, where Pf: ( By Strong MI ) Let P(n) be the statement f n >  n  2. Basis: f 3 = 2 >  so that P(3) and P(4) are true. Inductive: Assume that P (3), P (4), …, P(n) are true. We must show that P(n+1) is true. f n+1 = f n + f n  1 >  n  2 +  n  3 =  n  3 (  +1) ∵  +1=  2 ∴ f n+1 >  n  3   2 =  n  1 We get that P(n+1) is true. By Strong MI, P(n) is true for all n  3 27

Ch4-28 ※ Recursively defined sets. Example 7. Let S be defined recursively by 3  S x+y  S if x  S and y  S. Show that S is the of positive integers divisible by 3 (i.e., S = { 3, 6, 9, 12, 15, 18, … } Pf: Let A be the set of all positive integers divisible by 3. We need to prove that A=S. (i) A  S : (By MI) Let P(n) be the statement that 3n  S … (ii) S  A : (1) 3  A, (2) if x  A,y  A, then 3|x and 3|y.  3|(x+y)  x+y  A ∴ S  A S = A 28

Definition 2. The set of strings over an alphabet  is denoted by  *. The empty string is denoted by, , and wx  * whenever w  * and x . eg.  = { a, b, c }  * = {, a, b, c, aa, ab, ac, ba, bb, bc, … abcabccba, …} Example 9. Give a recursive definition of  l(w), the length of the string w  * Sol : initial value : l( )=0 recursive def : l(wx)=l(w)+1 if w  *, x . a b c 29

Ch4-30 Exercise 3, 7, 13, 48, 49 Exercise 39. When does a string belong to the set A of bit strings defined recursively by  A 0x1  A if x  A. Sol : A={, 01, 0011, , …} ∴ bit string  = 000…011…1  A n個n個 n個n個

Ch4-31 Ackermann’s function A(m, n) = 2n if m = 0 0 if m  1 and n = 0 2 if m  1 and n = 1 A(m  1, A(m, n  1)) if m  1 and n  2 Exercise 49 Show that A(m,2)=4 whenever m  1 Pf : A(m,2) = A(m  1, A(m,1)) = A(m  1,2) whenever m  1. A(m,2) = A(m  1,2) = A(m  2,2) = … = A(0,2) = 4. 31

Recursive algorithms. ※ Sometimes we can reduce the solution to a problem with a particular set of input to the solution of the same problem with smaller input values. eg. gcd( a,b ) = gcd( b mod a, a ) (when a < b ) Def 1. An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input. 32

Ch4-33 Example 2. Give a recursive algorithm for computing a n, where a  R \ {0}, n  N. Sol : recursive definition of a n : initial value : a 0 =1 recursive def : a n = a  a n  1. Algorithm 2. Procedure power( a : nonzero real number, n : nonnegative integer ) if n = 0 then power(a, n):=1 else power(a, n):= a * power(a, n  1). ∴ 33

Example 4. Find gcd(a,b) with 0  a<b Sol : Algorithm 4. procedure gcd(a,b : nonnegative integers with a<b) if a=0 then gcd(a,b) := b else gcd(a,b) := gcd(b mod a, a). Example 5. Search x in a 1, a 2,…,a n by Linear Search Sol : Alg. 5 procedure search (i, j, x: integers) if a i = x then location := i else if i = j then location := 0 else search(i+1, j, x) a i,a i+1,…a j x call search(1, n, x) 34

Ch4 -35 Example 6. Search x from a 1,a 2,…,a n by binary search (recursive version). Sol : Alg. 5 procedure binary_search (x, i, j: integers) m :=  (i+j) / 2  if x = a m then location := m else if (x < a m and i < m) then binary_search(x, i, m  1) else if (x > a m and j > m) then binary_search(x, m+1, j) else location := 0 call binary_search(x, 1, n) search x from a i, a i+1, …, a j a i, a i+1, …, a m  1 35

Example 1. Give the value of n !, n  Z + Sol : Note : n! = n  (n  1)! Alg. 1 (Recursive Procedure) procedure factorial (n: positive integer) if n = 1 then factorial (n) := 1 else factorial (n) := n  factorial (n  1) Alg. (Iterative Procedure) procedure iterative_factorial (n : positive integer) x := 1 for i := 1 to n x := i  x { x = n! } 36

※ iterative alg. recursive alg. ※ Find Fibonacci numbers (Note : f 0 =0, f 1 =1, f n =f n  1 +f n  2 for n  2 ) Alg. 7 (Recursive Fibonacci) procedure Fibonacci (n : nonnegative integer) if n = 0 then Fibonacci (0) := 0 else if n = 1 then Fibonacci (1) := 1 else Fibonacci (n) := Fibonacci (n  1)+Fibonacci (n  2) 37

Ch4 -38 Alg.8 (Iterative Fibonacci) procedure iterative_fibonacci (n: nonnegative integer) if n = 0 then y := 0 // y = f 0 else begin x := 0 y := 1 // y = f 1 for i := 1 to n  1 begin z := x + y x := y y := z end {y is f n } Exercise : 11, 35 i = 1i = 2i = 3 zf2f2 f3f3 f4f4 xf1f1 f2f2 f3f3 yf2f2 f3f3 f4f4 38