Académique Documents
Professionnel Documents
Culture Documents
Chapter Summary
Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms
Mathematical Induction
From (1), we can reach the first rung. Then by applying (2), we can reach the second rung. Applying (2) again, the third rung. And so on. We can apply (2) any number of times to reach any particular rung, no matter how high up.
To complete the inductive step, assuming the inductive hypothesis that P(k) holds for an arbitrary integer k, show that must P(k + 1) be true.
Hence, P(k) P(k + 1) is true for all positive integers k. We can reach every rung on the ladder.
where the domain is the set of positive integers. In a proof by mathematical induction, we dont assume that P(k) is true for all positive integers! We show that if we assume that P(k) is true, then P(k + 1) must also be true. Proofs by mathematical induction do not always start at the integer 1. In such a case, the basis step begins at a starting point b where b is an integer.
Consider an infinite sequence of dominoes, labeled 1,2,3, , where each domino is standing. Let P(n) be the proposition that the nth domino is knocked over.
We know that the first domino is knocked down, i.e., P(1) is true .
We also know that if whenever the kth domino is knocked over, it knocks over the (k + 1)st domino, i.e, P(k) P(k + 1) is true for all positive integers k.
Hence, all dominos are knocked over. P(n) is true for all positive integers n.
FIGURE 3 (4.1)
To prove that P(n) is true for all integers nb (*), where P(n) is a propositional function, follow the steps:
Inductive Step: Show that the conditional statement P(k) P(k+1) is true for all integers k b. This can be done by showing that under the inductive hypothesis that P(k) is true, P(k+1) must also be true.
(*) quite often b=1, but b can be any integer number. 9
Conclusion By induction we have shown that P(k) holds for all k b (b is what was used for the base case).
10
Mathematical Induction
Prove a base case (n=1) Prove Use induction to prove that the sum of the first n odd integers isP(k) n2. P(k+1) Whats the hypothesis? 1 Hypothesis: P(n) sum of first n odd integers = n2. 2 - Base case (n=1): the sum of the first 1 odd integer is 12. Since 1 = 12 3 - Assume P(k): the sum of the first k odd ints is k2. 1 + 3 + + (2k - 1) = k2 Inductive hypothesis
4 Inductive Step: show that (k) P(k) P(k+1), assuming P(k). By inductive How? hypothesis P(k+1)= 1 + 3 + + (2k-1) + (2k+1) k2 + (2k + 1) = = (k+1)2
p(k)
QED
Mathematical Induction
Prove a base case (n=?) Prove P(k)P(k+1)
Use induction to prove that the 1 + 2 + 22 + + 2n = 2n+1 - 1 for all non-negative integers n. P(n) = 1 + 2 + 22 + + 2n = 2 n+1 1
for all non-negative integers n. 2 - Base case?
1 Hypothesis?
n = 0 10 = 21-1.
12
Mathematical Induction
4 Inductive Step: show that (k) P(k) P(k+1), assuming P(k). How?
P(k+1)= 1 + 2 + 22 + + 2k+ 2k+1 = (2k+1 1) + 2k+1 By inductive hypothesis p(k) = 2 2k+1 - 1
Mathematical Induction
Prove that 11! + 22! + + nn! = (n+1)! - 1, positive integers
1 Hypothesis P(n) = 11! + 22! + + nn! = (n+1)! - 1, positive integers 2 - Base case (n=1): 11! = (1+1)! - 1? 11! = 1 and 2! - 1 = 1
Inductive hypothesis
= (k+2)! - 1
Mathematical Induction
Prove that a set with n elements has 2n subsets.
2n subsets
Inductive hypothesis
2- Base case (n=0): S=, P(S) = {} and |P(S)| = 1 = 20 3- Inductive Hypothesis - P(k): given |S| = k, |P(S)| = 2k
4- Inductive Step: (k) P(k) P(k+1), assuming P(k). i.e, Prove that if |T| = k+1, then |P(T)| = 2k+1, given that P(k)=2k
BASIS STEP: P(1) is true since 1(1 + 1)/2 = 1. INDUCTIVE STEP: Assume true for P(k).
Proving Inequalities
Example: Use mathematical induction to prove that n < 2n for all positive integers n. Solution: Let P(n) be the proposition that n < 2n. BASIS STEP: P(1) is true since 1 < 21 = 2. INDUCTIVE STEP: Assume P(k) holds, i.e., k < 2k, for an arbitrary positive integer k. Must show that P(k + 1) holds. Since by the inductive hypothesis, k < 2k, it follows that: k + 1 < 2(k + 1) 2k * 21 = 2 2k = 2k+1 Therefore n < 2n holds for all positive integers n.
18
19
Strong Induction
Strong Induction: To prove that P(n) is true for all positive integers n, where P(n) is a propositional function, complete two steps:
Basis Step: Verify that the proposition P(1) is true. Inductive Step: Show the conditional statement [P(1) P(2) P(k)] P(k + 1) holds for all positive integers k.
Strong Induction is sometimes called the second principle of mathematical induction or complete induction.
20
21
22
23
25
Well-Ordering Property
Well-ordering property: Every nonempty set of nonnegative integers has a least element. The well-ordering property is one of the axioms of the positive integers The well-ordering property can be used directly in proofs The well-ordering property can be generalized.
Definition: A set is well ordered if every subset has a least element.
N is well ordered under . The set of finite strings over an alphabet using lexicographic ordering is well ordered.
26
Definitions
The principle of mathematical induction: the statement n P(n), is true if P(1) is true and k (P(k) P(k + 1)) is true. Basis step: the proof of P(1) in a proof by mathematical induction of n P(n). Inductive step: the proof of P(k) P(k + 1) for all positive integers k in a proof by mathematical induction of n P(n). Strong induction: the statement n P(n) is true if P(1) is true and k [(P(1) P(2) P(k)) P(k + 1) ]. Well-ordering property: every nonempty set of nonnegative integers has a least element.
27
28
A function f(n) is the same as a sequence a0, a1, , where ai, where f(i) = ai. This was done using recurrence relations in Section 2.4.
29
30
31
32
Sometimes the recursive definition has an exclusion rule, which specifies that the set contains nothing other than those elements specified in the basis step and generated by applications of the rules in the recursive step. We will always assume that the exclusion rule holds, even if it is not explicitly mentioned. We will later develop a form of induction, called structural induction, to prove results about recursively defined sets. 33
Recursive Definitions
Recursion is a principle closely related to mathematical induction. In a recursive definition, an object is defined in terms of itself. We can recursively define sequences, functions and sets.
a0 = 1 an+1 = 2an for n = 0, 1, 2, Obviously, induction and recursion are similar principles.
an initial set of elements, rules for the construction of additional elements from elements in the set.
Example: Let S be recursively defined by: 3S (x + y) S if (x S) and (y S) S is the set of positive integers divisible by 3.
Since x and y are both in A, it follows that 3 | x and 3 | y. From Theorem I, Section 2.3, it follows that 3 | (x + y).
Conclusion of Part II: S A. Overall conclusion: A = S.
The well-formed formulae of variables, numerals and operators from {+, -, *, /, ^} are defined by:
x is a well-formed formula if x is a numeral or variable. (f + g), (f g), (f * g), (f / g), (f ^ g) are well-formed formulae if f and g are.
Recursive Algorithms
An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input. Example I: Recursive Euclidean Algorithm 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)
Recursive Algorithms
Example II: Recursive Fibonacci Algorithm procedure fibo(n: nonnegative integer) if n = 0 then fibo(0) := 0 else if n = 1 then fibo(1) := 1 else fibo(n) := fibo(n 1) + fibo(n 2)
Recursive Algorithms
Recursive Fibonacci Evaluation:
f(4)
f(3) f(2) f(1) f(1) f(0) f(1) f(0) f(2)
Recursive Algorithms
procedure iterative_fibo(n: nonnegative integer) if n = 0 then y := 0 else begin x := 0 y := 1 for i := 1 to n-1 begin z := x + y x:=y y := z end end {y is the n-th Fibonacci number}
Recursive Algorithms
For every recursive algorithm, there is an equivalent iterative algorithm. Recursive algorithms are often shorter, more elegant, and easier to understand than their iterative counterparts. However, iterative algorithms are usually more efficient in their use of space and time.
The set of full binary trees can be defined recursively by these steps. BASIS STEP: There is a full binary tree consisting of only a single vertex r. RECURSIVE STEP: If T1 and T2 are disjoint full binary trees, there is a full binary tree, denoted by T1T2, consisting of a root r together with edges connecting the root to each of the roots of the left subtree T1 and the right subtree T2.
51
52
S A:
We used mathematical induction to prove a result about a recursively defined set. Next we study a more direct form induction for proving results about recursively defined sets.
53
Structural Induction
Definition: To prove a property of the elements of a recursively defined set, we use structural induction. BASIS STEP: Show that the result holds for all elements specified in the basis step of the recursive definition. RECURSIVE STEP: Show that if the statement is true for each of the elements used to construct new elements in the recursive step of the definition, the result holds for these new elements. The validity of structural induction can be shown to follow from the principle of mathematical induction. 54
55
RECURSIVE STEP: If T1 and T2 are full binary trees, then the full binary tree = T1T2 has the number of vertices n(T) = 1 + n(T1) + n(T2).
56
57
Generalized Induction
Generalized induction is used to prove results about sets other than the integers that have the well-ordering property. For example, consider an ordering on N N, ordered pairs of nonnegative integers. Specify that (x1, y1) is less than or equal to (x2, y2) if either x1 < x2, or x1 = x2 and y1 <y2 . This is called the lexicographic ordering. Strings are also commonly ordered by a lexicographic ordering. The next example uses generalized induction to prove a result about ordered pairs from N N.
58
Generalized Induction
Example: Suppose that am,n is defined for (m,n)N N by a0,0 = 0 and Show that am,n = m + n(n + 1)/2 is defined for all (m,n)N N. Solution: Use generalized induction.
BASIS STEP: a0,0 = 0 = 0 + (01)/2 INDUCTIVE STEP: Assume that am,n = m+ n(n + 1)/2 whenever(m,n) is less than (m,n) in the lexicographic ordering of N N .
If n = 0, by the inductive hypothesis we can conclude am,n = am1,n + 1 = m 1+ n(n + 1)/2 + 1 = m + n(n + 1)/2 . If n > 0, by the inductive hypothesis we can conclude am,n = am1,n + 1 = m + n(n 1)/2 +n = m + n(n + 1)/2 .
59
Recursive Algorithms
Section 5.4
60
Recursive Algorithms
Definition: An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input. For the algorithm to terminate, the instance of the problem must eventually be reduced to some initial case for which the solution is known.
61
62
63
64
= a ak = ak+1 .
2
65
Merge Sort
Merge Sort works by iteratively splitting a list (with an even number of elements) into two sublists of equal length until each sublist has one element. Each sublist is represented by a balanced binary tree. At each step a pair of sublists is successively merged into a list with the elements in increasing order. The process ends when all the sublists have been merged. The succession of merged lists is represented by a binary tree.
66
Merge Sort
Example: Use merge sort to put the list 8, 2, 4, 6, 9, 7,10, 1, 5, 3 into increasing order.
67
Merge Sort
Solution:
68
continued 69
Complexity of Merge: Two sorted lists with m elements and n elements can be merged into a sorted list using no more than m + n 1 comparisons. 70
71
Definitions
Recursive definition of a function: a definition of a function that specifies an initial set of values and a rule for obtaining values of this function at integers from its values at smaller integers. Recursive definition of a set: a definition of a set that specifies an initial set of elements and a rule for obtaining other elements from those in the set. Structural induction: a technique for proving results about recursively defined sets. Recursive algorithm: an algorithm that proceeds by reducing a problem to the same problem with smaller input. Merge sort: a sorting algorithm that sorts a list by splitting it in two, sorting each of the two resulting lists, and merging the results into a sorted list. Iteration: a procedure based on the repeated use of operations in a loop. 72