Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Induction Proof

2 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. Examples:  N is well ordered (under the  relation).  Any coutably infinite set can be well ordered. The least element in a subset is determined by a bijection (list) which exists from N to the countably infinite set.  Z can be well ordered but it is not well ordered under the  relation. Z has no smallest element.  The set of finite strings over an alphabet using lexicographic ordering is well ordered.

3 Mathematical Induction Let P(x) be a predicate over a well ordered set S. In the case that S = N, the natural numbers, the principle has the following form. P(0) P(n)  P(n +1)  x P(x) The hypotheses are H 1 : P(0) (Basis Step) H 2 : P(n)  P(n +1) for n arbitrary. (Induction Step)

4 How It Works  First, prove that the predicate is true for the smallest element of the set S (0 if S = N).  Then, show if it is true for an element (n if S=N) implies it is true for the “next” element in the set (n + 1 if S=N). Meaning  Knowing it is true for the first element means it must be true for the element following the first or the second element  Knowing it is true for the second element implies it is true for the third and so forth.  Therefore, induction is equivalent to modus ponens applied an countable number of times!!

5 Outline of Induction Proof  State what P(n) is.  Basis: Prove that P(0) is true.  Induction hypothesis: Assume that P(n) is true, for an arbitrary n.  Induction step: Prove that P(n+1) is true, using P(n). (Usually, direct proof)

6 Example Prove:  n i = n(n +1)/2 i=0 In logical notation we wish to show  n [  n i = n(n +1)/2 ] i=0 Hence, P(n) is [  n i] = n(n +1)/2 i=0 Basis: Prove H1: P(0): 0=0(0 +1)/2 Induction Hypotheses: Assume P(n) is true for n arbitrary. Now use this and anything else you know to establish that P(n+1) must be true.

7 Example Induction step: Write down the assertion P (n+1) P(n + 1) is the assertion  n+1 i = (n+1)((n +1)+1)/2 i=0  n+1 i =  n i +n+1 i=0 = n(n +1)/2 + n+1 (from induction hypothesis ) = (n(n +1) + 2(n+1) )/ 2 = (n+1)(n+2)/ 2 = (n+1)((n +1)+1)/2 Q.E.D.

8 More General Rule  Suppose we wish to prove for some specific integer k  x [x  k  P(x)]  Now we merely change the basis step to P(k) and continue.

9 Example Prove 3n + 5 is in O(n 2 ). Definition: f(n) is in O(g(n)) if there are constants c>0 and k such that f(n)  c  g(n) for n  k. Proof: We must find C and k such that 3n + 5  Cn 2 for n  k (or n > k-1). If we try C = 1, then the assertion is not true until k = 5. Hence we prove by induction that 3n + 5  n 2 for all n  5. The assertion becomes  n[n  5  3n + 5  n 2 ] and the predicate P(n) is 3n + 5  n 2.

10 Example Basis step: P(5): 3  5 + 5 = 20  (5) 2. Induction hypothesis: Assume P(n): 3n  5  n 2 is true for arbitrary n. Induction step: Prove P(n+1): 3(n  1)  5  (n  1) 2 From 3n  5  n 2, we have (3n  5)  3  n 2 +3. Now we must show that n 2 + 3  (n + 1) 2 = n 2 + 2n + 1 which is true iff 3  2n + 1 which is true iff n  1. But we have already restricted n  5 so n  1 must hold. That is,  n[n  5  3n  5  n 2 ], i.e. 3n + 5 is in O(n 2 ). Q.E.D.

11 Double Qualifier  In doubly quantified assertions of the form  m  n[P(m,n)]  we often assume m (or n ) is arbitrary to eliminate a quantifier and prove the remaining result using induction.

12 Strong Induction H1: P(0) H2: P(0)  P(1) ...  P(n)  P(n +1)  xP(x) The two rules are equivalent but sometimes the second is easier to apply.

13 Example For any integer n>1, n can be written as a product of primes. Proof: Let P(n) be the predicate n can be written as a product of primes. Basis: P(2): 2 can be written as a product of 2, which is a prime. Induction hypothesis: For any integer k  n, k can be written as a product of primes.

14 Example Induction step: Prove n+1 can be written as a product of primes.  If n+1 is a prime, then it can be written as a product of itself only (by def. of primes).  If n+1 is not a prime, then there exist integers p and q such that p  q=n+1 (by def. of primes) and p and q are less than n+1. Since p and q are less than n+1, p and q can be written as products of primes (by induction hypothesis). Thus, n+1 can be written as a product of primes that make p and q. Q.E.D.

15 Recursive or Inductive Definitions  Basis step For sets  State the basic building blocks (BBB's) of the set. For functions  State the values of the function on the BBB’s.  Inductive or recursive step: For sets  Show how to build new things from old with some construction rules. For functions  Show how to compute the value of a function on the new things that can be built knowing the value on the old things.

16 Recursive or Inductive Definitions  Extremal clause: For sets  If you can't build it with a finite number of applications of steps 1. and 2. then it isn't in the set. For functions  A function defined on a recursively defined set does not require an extremal clause. Often omitted.  To prove something is in the set you must show how to construct it with a finite number of applications of the basis and inductive steps.  To prove something is not in the set is often more difficult.

17 Example A recursive definition of N:  Basis: 0 is in N (0 is the BBB).  Induction: if n is in N then so is n + 1 (how to build new objects from old: “add one to an old object to get a new one”).  Extremal clause: If you can't construct it with a finite numberof applications of the basis and induction, it is not in N.

18 Example Given the recursive definition of N, we can give recursive definitions of functions on N:  f(0) =1 The initial condition or the value of the function on the BBB’s.  f(n+1)=(n+1)  f(n) The recurrence equation, how to define f on the new objects based on its value on old objects.  f is the factorial function: f(n) = n!  Note how it follows the recursive definition of N.  Proof of assertions about inductively defined objects usually involves a proof by induction.

19 Proof guideline  Prove the assertion is true for the BBBs in the basis step.  Prove that if the assertion is true for the old objects it must be true for the new objects you can build from the old objects.  Conclude the assertion must be true for all objects.

20 Example We define a n inductively where n is in N. Basis: a 0 = 1 Induction: a (n+1) = a n  a Theorem:  m  n [a m a n  a m  n ] Proof: Since the powers of a have been defined inductively, we must use a proof by induction somewhere. Get rid of the first quantifier on m by Universal Instantiation: Assume m is arbitrary. Now prove, by induction, the remaining quantified assertion  n [a m a n  a m  n ]

21 Example Basis step: Show it holds for n=0. The left side becomes a m a 0  a m (1)  a m. The right side becomes a m+0  a m. Hence, the two sides are equal to the same value. Induction hypothesis: Assume the assertion is true for n: a m a n  a m  n. Induction step: Now show it is true for n+1 (a m a n+1  a m  n+1 ). a m a n+1 =  a m (a n a) (by inductive step in the definition of a n ) a m a n+1 = (a m a n )a (by associativity of multiplication) a m a n+1 = a m  n a (by the induction hypothesis) a m a n+1 = a m  n+1 (by inductive step in the definition of a n )

22 Rooted Trees The set of rooted trees, where a rooted tree consists of a set of vertices containing a distinguished vertex called the root, and edges connecting these vertices, can be defined recursively as follows: Basis step: A single vertex r is a rooted tree. Recursive step: If T 1, T 2, …, T n are rooted trees with roots r 1, r 2, …, r n, espectively, the graph form by starting with a root r, which is not in any of T 1, T 2, …, T n, and adding an edge from r to r 1, r 2, …, r n is also a rooted tree.

23 Extended Binary Trees The set of extended binary trees can be defined recursively as follows: Basis step: The empty set is an extended binary tree. Recursive step: If T 1 and T 2 are extended binary trees, there is an extended binary tree, denoted by T 1  T 2, consisting of a root r together with edges connecting the root to the root of the left subtree T 1 and the right subtree T 2, when these trees are not empty.

24 Full Binary Trees The set of full binary trees can be defined recursively as follows: Basis step: A single vertex r is a full binary tree. Recursive step: If T 1 and T 2 are full binary trees, there is an full binary tree, denoted by T 1  T 2, consisting of a root r together with edges connecting the root to the root of the left subtree T 1 and the right subtree T 2.

25 Height of Trees The height of a full binary tree T, denoted by h(T), can be defined as follows: Basis step: The height of a full binary tree T consisting of a single vertex r is h(T)=0. Recursive step: If T 1 and T 2 are full binary trees, the height of a full binary tree T = T 1  T 2 is h(T)=1+max(h(T 1 ), h(T 2 )). 0 0 1 2

26 Number of Nodes in a Full Binary Tree Theorem: If T is a full binary tree, the number of nodes in T, denoted by n(T), is not more than 2 h(T)+1 -1. Proof: Basis step: For a full binary tree T of height 0, T is consisted of one vertex. Then, n(T)=1, and 2 h(T)+1 -1 =2 0+1 -1=1. Thus, n(T)  2 h(T)+1 -1. Induction hypothesis: Assume n(T)  2 h(T)+1 -1 for any full binary tree T of the height less than k. Induction step: If T 1 and T 2 are full binary trees of the height less than k, the number of nodes in a full binary tree T = T 1  T 2 is 1+n(T 1 )+n(T 2 ).

27 Number of Nodes in a Full Binary Tree n(T) = 1+n(T 1 )+n(T 2 )(from the construction of T)  1 + (2 h(T 1 )+1 -1) + (2 h(T 2 )+1 -1) (from induction hypothesis) 1 + (2 h(T 1 )+1 -1) + (2 h(T 2 )+1 -1) = 2 h(T 1 )+1 + 2 h(T 2 )+1 -1  2  max(2 h(T 1 )+1, 2 h(T 2 )+1 ) -1 2  max(2 h(T 1 )+1, 2 h(T 2 )+1 ) -1= 2  (2 max(h(T 1 )+1, h(T 2 ))+1 ) -1 = 2  2 h(T) -1 = 2 h(T)+1 -1 That is, n(T)  2 h(T)+1 -1. Q.E.D.

28


Download ppt "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."

Similar presentations


Ads by Google