Presentation is loading. Please wait.

Presentation is loading. Please wait.

Inductive Proofs. Mathematical Induction A powerful, rigorous technique for proving that a predicate P(n) is true for every natural number n, no matter.

Similar presentations


Presentation on theme: "Inductive Proofs. Mathematical Induction A powerful, rigorous technique for proving that a predicate P(n) is true for every natural number n, no matter."— Presentation transcript:

1 Inductive Proofs

2 Mathematical Induction A powerful, rigorous technique for proving that a predicate P(n) is true for every natural number n, no matter how large. Essentially a “domino effect” principle. Based on a predicate-logic inference rule: P(0)  n  0 (P(n)  P(n+1))  n  0 P(n) “The First Principle of Mathematical Induction”

3 Outline of an Inductive Proof Want to prove  n P(n)… Base case (or basis step): Prove P(0). Inductive step: Prove  n P(n)  P(n+1). – E.g. use a direct proof: – Let n  N, assume P(n). (inductive hypothesis) – Under this assumption, prove P(n+1). Inductive inference rule then gives  n P(n).

4 Generalizing Induction Can also be used to prove  n  c P(n) for a given constant c  Z, where maybe c  0. – In this circumstance, the base case is to prove P(c) rather than P(0), and the inductive step is to prove  n  c (P(n)  P(n+1)).

5 Second Principle of Induction Characterized by another inference rule: P(0)  n  0: (  0  k  n P(k))  P(n+1)  n  0: P(n) Difference with 1st principle is that the inductive step uses the fact that P(k) is true for all smaller k<n+1, not just for k=n. P is true in all previous cases

6 Induction Example (1st princ.) Prove that the sum of the first n odd positive integers is n 2. That is, prove: Proof by induction. – Base case: Let n=1. The sum of the first 1 odd positive integer is 1 which equals 1 2. (Cont…) P(n)P(n)

7 Example cont. Inductive step: Prove  n  1: P(n)  P(n+1). – Let n  1, assume P(n), and prove P(n+1). By inductive hypothesis P(n)

8 Another Induction Example Prove that  n>0, n<2 n. Let P(n)=(n<2 n ) – Base case: P(1)=(1<2 1 )=(1<2)=T. – Inductive step: For n>0, prove P(n)  P(n+1). Assuming n<2 n, prove n+1 < 2 n+1. Note n + 1 < 2 n + 1 (by inductive hypothesis) < 2 n + 2 n (because 1<2=2  2   2  2 n-1 = 2 n ) = 2 n+1 So n + 1 < 2 n+1, and we’re done.

9 Example of Second Principle Show that every n>1 can be written as a product p 1 p 2 …p s of some series of s prime numbers. Let P(n)=“n has that property” Base case: n=2, let s=1, p 1 =2. Inductive step: Let n  2. Assume  2  k  n: P(k). Consider n+1. If prime, let s=1, p 1 =n+1. Else n+1=ab, where 1  a  n and 1  b  n. Then a=p 1 p 2 …p t and b=q 1 q 2 …q u. Then n+1= p 1 p 2 …p t q 1 q 2 …q u, a product of s=t+u primes.

10 Another 2nd Principle Example Prove that every amount of postage of 12 cents or more can be formed using just 4- cent and 5-cent stamps. Base case: 12=3  4), 13=2  4)+1(5), 14=1(4)+2(5), 15=3(5), so  12  n  15, P(n). Inductive step: Let n  15, assume  12  k  n P(k). Note 12  n  3  n, so P(n  3), so add a 4-cent stamp to get postage for n+1.

11 Recursion

12 Recursive Definitions In induction, we prove all members of an infinite set have some property P by proving the truth for larger members in terms of that of smaller members. In recursive definitions, we similarly define a function, a predicate or a set over an infinite number of elements by defining the function or predicate value or set-membership of larger elements in terms of that of smaller ones.

13 Recursion Recursion is a general term for the practice of defining an object in terms of itself (or of part of itself). An inductive proof establishes the truth of P(n+1) recursively in terms of P(n). There are also recursive algorithms, definitions, functions, sequences, and sets.

14 Recursively Defined Functions Simplest case: One way to define a function f:N  S (for any set S) or series a n =f(n) is to: – Define f(0). – For n>0, define f(n) in terms of f(0),…,f(n−1). E.g.: Define the series a n :≡ 2 n recursively: – Let a 0 :≡ 1. – For n>0, let a n :≡ 2a n-1.

15 Another Example Suppose we define f(n) for all n  N recursively by: – Let f(0)=3 – For all n  N, let f(n+1)=2f(n)+3 What are the values of the following? – f(1)= f(2)= f(3)= f(4)= 9 21 4593

16 Recursive definition of Factorial Give an inductive definition of the factorial function F(n) :≡ n! :≡ 2  3  …  n. – Base case: F(0) :≡ 1 – Recursive part: F(n) :≡ n  F(n-1). F(1)=1 F(2)=2 F(3)=6

17 The Fibonacci Series The Fibonacci series f n≥0 is a famous series defined by: f 0 :≡ 0, f 1 :≡ 1, f n≥2 :≡ f n−1 + f n−2 Leonardo Fibonacci 1170-1250 0 11 23 58 13

18 Recursive Algorithms Recursive definitions can be used to describe algorithms as well as functions and sets. Example: A procedure to compute a n. procedure power(a≠0: real, n  N) if n = 0 then return 1 else return a · power(a, n−1)

19 Recursive Factorial Algorithm Procedure factorial(n: nonnegative integer) if n = 0 then factorial(n) = 1 else factorial(n) = n · factorial(n - 1) Note recursive algorithms are often simpler to code than iterative ones… However, they can consume more stack space, if your compiler is not smart enough.

20 Recursive Euclid’s Algorithm procedure gcd(a,b  N) if a = 0 then gcd(a, b) = b else gcd(a, b) = gcd(b mod a, a)

21 Recursive Fibonacci Algorithm 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 - 1)

22 Tow of Hanoi 3 개의 기둥 중 제일 왼쪽 기둥에 크기가 큰 것이 제일 아래 에 있게 원판들이 쌓여있을 때 제일 오른쪽 기둥으로 원판 을 옮기는 데 소요되는 최소 이동 회수를 구하는 문제 – 추가조건 원판은 한 번에 하나씩만 옮길 수 있다. 원판은 기둥과 기둥으로만 옮길 수 있다. ( 즉, 바닥에 내려놓을 수 없다.) 크기가 큰 원판은 작은 원판 위에 올 수 없다.

23 Tow of Hanoi cont. 원판이 3 개인 하노이 탑의 풀이 원리

24 Tow of Hanoi cont. [ 예제 ] 하노이 탑 문제의 재귀 알고리즘을 구하시오. [ 풀이 ]

25 The Merge Sort Procedure mergesort(L = a 1,…, a n ) if n > 1 then m :=  n/2  {this is rough ½-way point} L 1 := a 1,…, a m L 2 := a m+1,…, a n L := merge(mergesort(L 1 ), mergesort(L 2 )) { L is now sorted into elements in nondreasing order }

26 Merge Routine procedure merge(L 1, L 2 : sorted lists) L = empty list while L 1 and L 2 are both nonempty Begin remove smaller of first element of L 1 and L 2 from the list it is in and put it at the right end of L If removal of this element makes one list empty then remove all elements from the other list and append them to L End (L is the merged sorted list in increasing order)


Download ppt "Inductive Proofs. Mathematical Induction A powerful, rigorous technique for proving that a predicate P(n) is true for every natural number n, no matter."

Similar presentations


Ads by Google