6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of.

Slides:



Advertisements
Similar presentations
Recursive Definitions and Structural Induction
Advertisements

Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
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.
Induction Sections 41. and 4.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Induction Sections 4.1 and 4.2 of Rosen Fall 2010
CSE115/ENGR160 Discrete Mathematics 03/22/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 03/31/11
CSS342: Induction1 Professor: Munehiro Fukuda. CSS342: Induction2 Today’s Topics Review of sequence and summations Mathematical induction Strong form.
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.
CSE115/ENGR160 Discrete Mathematics 03/29/11 Ming-Hsuan Yang UC Merced 1.
Mathematical Induction
Properties of the Integers: Mathematical Induction
Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.
Induction and recursion
ICS 253 Presents Mathematical Induction Sultan Almuhammadi muhamadi
Induction and recursion
Chapter 6 Mathematical Induction
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
Chapter 4: Induction and Recursion
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,
10/17/2015 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(1) Dr.Saad Alabbad Department of Computer Science
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
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.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
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.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Induction Practice CS1050. Prove that whenever n is a positive integer. Proof: Basis Case: Let n = 1, then.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
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.
CSE 311 Foundations of Computing I Lecture 15 Strong Induction and Recursive Definitions Spring
Mathematical Induction What it is? Why is it a legitimate proof method? How to use it?
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
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.
Chapter 4: Induction and Recursion
CSE15 Discrete Mathematics 03/22/17
Advanced Algorithms Analysis and Design
CS2210:0001Discrete Structures Induction and Recursion
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Induction and recursion
Induction and Recursion
Recursively Defined Functions
Mathematical Induction Recursion
Chapter 5 Induction and Recursion
Induction and recursion
Follow me for a walk through...
Applied Discrete Mathematics Week 9: Integer Properties
Follow me for a walk through...
Induction Chapter
Mathematical Induction
Mathematical Induction
Follow me for a walk through...
Recursion.
Presentation transcript:

6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of Computer Science Tel #

6/12/2016 Prepared by Dr.Saad Alabbad2 Mathematical Induction  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: Basis Step: prove that P(1) is true. Inductive Step: show that if P(k) is true then P(k+1) is true for all positive integers k (i.e P(k)  P(k+1) ) This can be expressed as [P(1)  k P(k)  P(k+1)]  n P(n)

6/12/2016 Prepared by Dr.Saad Alabbad3 Mathematical Induction  Example(1): Show that if n is a postive integer then 1+2+…+n=[n(n+1)]/2  Basis Step: P(1) is true since 1=[1(1+1)]/2=2/2=1  Inductive Step:  Assume that P(k) is true i.e 1+2+…+k=[k(k+1)]/2 (*)  We need to show that P(k+1) is true  By adding k+1 to (*) we obtain 1+2+…+k+(k+1)= [k(k+1)]/2+(k+1) = [k(k+1)+2(k+1)]/2 =(k+1)(k+2)/2 by taking k+1 as a common factor =P(k+1) So P(k+1) is true under the assumption that P(k) is true which completes the proof.

6/12/2016 Prepared by Dr.Saad Alabbad4 Mathematical Induction  Example(2): Show that n<2 n for all positive integers n  Basis Step: P(1) is true since 1<2 1  Inductive Step:  Assume that P(k) is true i.e k<2 k (*)  We need to show that P(k+1) is true i.e k+1<2 k+1  By adding 1 to (*) we obtain  K+1<2 k +1.  But since 1  2 k for all positive integers k. We have  K+1<2 k +1   2 k +2 k  =2.2 k  =2 k+1  K+1<2 k+1 So P(k+1) is true under the assumption that P(k) is true which completes the proof.

6/12/2016 Prepared by Dr.Saad Alabbad5 Mathematical Induction  Example(3): Show that the number of subsets of a finite set S is 2 n where n is the number of elements of the set S.  Basis Step: P(0) is true since the set with zero elements (empty set) has exactly one subset. Namely itself 2 0 =1  Inductive Step:  Assume that P(k) is true i.e every set with k elements has 2 k subsets  We need to show that P(k+1) is true i.e every set with k+1 elements has 2 k+1 subsets  Let T be a set with k+1 elements then we can write T=S  {a} where a is an element of T and S=T-{a}  For each subset X of S there are two subsets of T: subset that contains a i.e X  {a} and the subset that does not contain a i.e X (see next slide)  Since S has k elements, there are 2 k subsets of S and hence there are 2. 2 k = 2 k+1 subsets of T (see next slide)  So P(k+1) is true under the assumption that P(k) is true which completes the proof.

6/12/2016 Prepared by Dr.Saad Alabbad6 Mathematical Induction { } { } { } {1} { } {1} { } {2} {1} {1,2} { } {2} {1} {1,2} { } {3} {2} {2,3} {1} {1,3} {1,2} {1,2,3} { } {3} {2} {2,3} {1} {1,3} {1,2} {1,2,3} S={1,2} T={1,2,3} a=3 Every subset of T can be generated by adding or omitting element a from every subset of S Example(3): Illustration

6/12/2016 Prepared by Dr.Saad Alabbad7 Mathematical Induction  Example(4): Show that 2 n  n! for all positive integers n  4  Basis Step: P(4) is true since 2 4 =16  4!=24 (note: basis step is 4)  Inductive Step:  Assume that P(k) is true i.e 2 k  k! (*) for all k  4  We need to show that P(k+1) is true i.e 2 k+1  (k+1)!  Multiply (*) by 2, we obtain  2.2 k =2 k+1  2.K!   (k+1)k! Since 2<k+1 =(k+1)! So 2 k+1  (k+1)! So P(k+1) is true under the assumption that P(k) is true which completes the proof.

6/12/2016 Prepared by Dr.Saad Alabbad8 Strong Mathematical Induction  Principle of Strong 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: Basis Step: prove that P(1) is true. Inductive Step: show that if P(1)  P(2) ..  P(k) are true then P(k+1) is true for all positive integers k (i.e P(k)  P(k+1) ) This can be expressed as [P(1)  P(2)…  P(k)  P(k+1)]  n P(n)  Sometimes it is called second principle of induction  It is equivalent to the mathematical induction we have seen.However, in many cases it is much easier to prove using the strong induction.  Note that the difference lies in the inductive step. We assume that P(1),P(2) up to P(k) are true and we show that P(k+1) is true where in the normal induction we assume that only P(k) is true and show that P(k+1) is true.

6/12/2016 Prepared by Dr.Saad Alabbad9 Strong Mathematical Induction  Example: Show that if n is an integer greater than 1, then n can be written as the product of primes  Basis Step: P(2) is true since 2 can be written as the product of one prime (itself!)  Inductive Step:  Assume that P(2),…P(k) are true i.e P(j) is true for 2  j  k  We need to show that P(k+1) is true i.e k+1 can be written as product of primes  Now we have two cases:  K+1 is prime which means that P(k+1) is true.  K+1 is composite and can be written as the product of two positive integers 2  a  b  k+1  By the inductive step we see that both a and b can be written as the product of primes. Thus if K+1 is composite it can hbe written as the product of primes (primes in the factorization of a and b) So P(k+1) is true under the assumption that P(j) is true for 2  j  k which completes the proof. Note: this theorem is called the Fundamental Theorem of Arithmetic

6/12/2016 Prepared by Dr.Saad Alabbad10 Recursive Definitions: Recursively Defined Functions Recursion See: "Recursion" if you still don't get it,  Recursion: Defining something (process,function,set,concept,etc..) in terms of itself  Example(1): One’s ancestors : his father and his father’s ancestors  Example(2): Factorial of n is defined as n!=n*n-1*….*1 Can be defined recursively as: n!=n* (n-1)!

6/12/2016 Prepared by Dr.Saad Alabbad11 Recursive Definitions: Recursion See: "Recursion" if you still don't get it,  Recursion: Defining something (process,function,set,concept,etc..) in terms of itself  Example(1): One’s ancestors : his father and his father’s ancestors  Example(2): Factorial of n is defined as n!=n*n-1*….*1 Can be defined recursively as: n!=n* (n-1)!

6/12/2016 Prepared by Dr.Saad Alabbad12 Recursive Definitions: Recursively Defined Functions Recursive functions have two parts 1)Basis step: gives the value of the function at some initial value (usually zero). It is needed to terminate the recursive step. 2)Recursive Step: gives a rule of finding the value of the function from previous values  Example(1): Factorial of n is defined as n!=n*n-1*….*1 Can be defined recursively as: 0!=1 [basis step] n!=n* (n-1)! [recursive step]  Example(2): Let F(n)=0+1+2+…+n. Define F(n) recursively: F(0)=0 [basis step] F(n)=n+F(n-1) [recursive step] we can also write F(n+1)=(n+1)+F(n)  Question : Define F(n)=2 n recursively.

6/12/2016 Prepared by Dr.Saad Alabbad13 Recursive Definitions: Recursively Defined Functions  Example(3):Febonacci numbers f n are defined as: f 0 =0 [basis step] f 1 =1 f n = f n-1 + f n-2 [inductive step] Compute f 5. f 5 = f 4 +f 3 f 2 =1+0=1 f 3 =f 2 +f 1 =1+1=2 = f 3 +f 2 +f 2 +f 1 f 4 =f 3 +f 2 =2+1=3 f 5 =f 4 +f 3 =3+2=5 =f 2 +f 1 +f 1 +f 0 +f 1 +f 0 +1 =f 1 +f =5 More efficient way

6/12/2016 Prepared by Dr.Saad Alabbad14 Recursive Definitions: Recursively Defined Sets Recursive definition of sets have two parts 1)Basis step: initial collection of elements in the set. 2)Recursive Step: gives a rule for forming new elements in the set from those already in the set.  Example(1): Define the set S as follow 2  S [basis step] If x  S and y  S then x+y  S [ Recursive step] What is S ?? 2 in S 2+2=4 in S [Recursive step] 2+4=6 in S [Recursive step] Etc… Can you figure it out?

6/12/2016 Prepared by Dr.Saad Alabbad15 Recursive Definitions: Recursive Algorithm Recursive algorithms: solve a problem by reducing it to an instance of the same problem with smaller input. Factorial Algorithm int fac(int n) { if (n == 0) return 1; return n * fac(n-1); } Exponentiation Algorithm int power(int a, int n) { if (n == 0) return 1; return a * power (a,n-1); }

6/12/2016 Prepared by Dr.Saad Alabbad16 Recursive Definitions: Fibonacci Recursive Algorithm Fibonacci Algorithm int fib(int n) { if (n == 0) return 0; if (n == 1) return 1; return fib(n-1)+ fib(n-2); } f5f5 f4f4 f3f3 f3f3 f2f2 f2f2 f1f1 f0f0 f1f1 f1f1 f0f0 f2f2 f1f1 f1f1 f0f0

6/12/2016 Prepared by Dr.Saad Alabbad17 Recursive Definitions: Fibonacci Recursive Algorithm Fibonacci Algorithm int fib(int n) { if (n == 0) return 0; if (n == 1) return 1; return fib(n-1)+ fib(n-2); } f5f5 f4f4 f3f3 f3f3 f2f2 f2f2 f1f1 f0f0 f1f1 f1f1 f0f0 f2f2 f1f1 f1f1 f0f0