Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.

Similar presentations


Presentation on theme: "Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5."— Presentation transcript:

1 Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5

2 2 Well-Ordering Property Every non-empty set of non-negative integers has a minimum (smallest) element The well-ordering property is the foundation of Mathematical induction

3 3 Recursion Recursion means defining an object in terms of itself part of itself versions of itself An object can be Sequence Function Set Algorithm

4 4 In Nature Fractals are self-similar structures, most of them defined recursively Romanesque Broccoli A fractal coastline in northern Portugal

5 5 Recursively Defined Sequence Def.: A sequence is defined recursively whenever some initial terms are specified and later terms are defined in terms of earlier terms. Arithmetic Series a 0 =1, r=3 a n =a n-1 +r, n>0 yields: 1, 4, 7, 10, 13, … Geometric Series a 0 =3, r=2 a n =a n-1 r, n>0 yields: 3, 6, 12, 24, 48, … a n = 2 n yields: 1, 2, 4, 8, 16, 32, … or a n+1 = 2a n where n > 0 and a 0 = 1

6 6 Recursively Defined Sequence In a recursively defined sequence: 1. Base or Initial Conditions The first term(s) of the sequence are defined 2. Recursion or Recursive Step The n th term is defined in terms of previous terms The formula to express the n th term is called a recurrence formula Arithmetic Series: Base: a 0 =1, r=3 Recursion: a n =a n-1 +r, n > 0 Geometric Series Base: a 0 =3, r=2 Recursion: a n =a n-1 r, n > 0 Recurrence Formula

7 7 Recursively Defined Sequence Be sure that the recursive definition of the sequence produces a well-defined sequence in which all the terms 0,1,2… are covered by the definition Example: Base: a 0 = 1 Recursion: a n = 3a n-2 - a n-1 What is a 1 ? Can’t tell so this is no good.

8 8 Fibonacci Sequence Fibonnaci Sequence Non-recursive (closed form) Definition Recursive Definition: Base Cases:f 0 =0, f 1 =1 Recurrence:f n = f n-1 + f n-2 for n > 1

9 9 Fibonacci Sequence Theorem: f n < 2 n. Proof: (By strong induction.) 1) Base cases: f 0 = 0 < 2 0 = 1 f 1 = 1 < 2 1 = 2 2) Inductive step: Inductive Hypothesis: Assume  j, 1 < j  k, f j < 2 j. i.e., f 2 < 2 2, f 3 < 2 3, …, f k < 2 k show that f k+1 < 2 k+1 f k + f k-1 < 2·2 k = 2 k + 2 k f k < 2 k from ind hyp and f k-1 ≤ f k < 2 k so f k+1 < 2 k+1

10 10 Fibonacci Sequence Theorem.  n ≥ 3, f n > α n−2, where α = (1+  5)/2. Proof. First note that: α 2 – α - 1 = (1 + 2  5 + 5)/4 - (1+  5)/2 – 1 = 6/4 + 2  5/4 – 1/2 -  5/2 – 1 =  5/2 -  5/2 + 3/2 – 1/2 – 1 = 0 (recall quadratic formula) Therefore, α 2 = α + 1 Take it away!

11 11 Recursively Defined Function A function f(n) with domain N or a subset of N is defined recursively, when f(n) is defined in terms of the previous functions of m < n Basis: f(0) = 1 Recursion: Define f(n) from f defined on smaller terms Example Let f : N -> N defined recursively as Basis: f(0) = 1 Recursion: f(n + 1) = (n + 1) · f(n). What are the values of the following? f(1)= 1 f(2)= 2 f(3)= 6 f(4)= 24 What does this function compute? n!

12 12 Recursively Defined Function Be sure that the recursive definition produces a well-defined function, i.e., every element in the domain has an image under f Example: Base: f(1) = 1 Recursion: f(n) = 1 + f(  n/2  ), n ≥ 1 Is this function correctly defined ? Ill-defined: f(1) is 1 but is not well-defined according to the recursion and f(0) is not defined. f(0) ? f(6) ? Consider a function f:N  {0,1,2}, Is this function well-defined ? 0 if 2 | n f (n)= 1 if 3 | n 2 otherwise.

13 13 Recursively Defined Set An infinite set S may be defined recursively, by giving: Basis Step: A finite set of base elements Recursive Step: a rule for forming new elements in the set from those already in the set Exclusion Rule: specifies that the set only contains those elements specified in the basis step or those generated by the recursive step Example: Let S be defined as follows Basis Step: 1  S Recursive Step: if n  S then 2n  S S = {2 k | k  N }

14 14 Recursively Defined Set Example: Basis Step: 0  S Recursive Step: if m  S then m + 1  S Exclusion Rule: No other numbers are in S. What is S? Example: Basis Step: 1  S Recursive Step: if m  S then -1m  S Exclusion Rule: No other numbers are in S What is S?

15 15 Set of Strings Def.:An alphabet  is a finite non-empty set of symbols (e.g.,  = {0, 1} ) Def.:A String over an alphabet  is a finite sequence of symbols from  (e.g., 11010 ) The set  * of strings over  can be defined as: Basis Step:  Σ * where is the empty string containing no symbols Recursive Step: if w  Σ * and x  Σ then wx  Σ * Is  * countable or uncountable ?

16 16 Recursive Definition on Strings Concatenation (combining two strings) Basis Step: if w  Σ * then w· = w, where is the empty string containing no symbols. Recursive Step: if w 1  Σ *, w 2  Σ * and x  Σ then w 1 ·(w 2 x)  Σ * (same as (w 1 · w 2 ) x  Σ * ) Example: Σ={a, b} Let w 1 =aba, w 2 =a and x=b then abaab  Σ *

17 17 Recursive Definition on Strings Length Basis Step: | | = 0 Recursive Step: if w  Σ * and x  Σ then |wx| = |w| + 1 Example: Σ = {a, b} |aba| = |(ab)a| = |ab| + 1 |ab| = |(a)b| = |a| + 1so |aba| = |a| + 2 |a| = |( ) a | = | | + 1so |aba| = | | + 3 | | = 0so |aba| = 3

18 18 Recursive Function on Strings The reversal of a string w, w R, consists of the string in reverse order. Give a recursive definition of the reversal of a string. Example: w = abacd, w R = dcaba Basis Step: if w = then w R = Recursive Step: if w = vx where x  Σ, v  Σ * then w R = xv R

19 19 Well-Formed Formulas p,q,r,… represent proposition variables; T, F and the set of logical operators { , , , ,  } Basis Step: T, F and p where p is a propositional variable is well defined (i.e., a wff) Recursive Step: If E and G are wff then (  E), (E  G), (E  G), (E  G), (E  G) are wff Examples: (  p), (p  q), ((  p)  q), ((  p)  q) are wff

20 20 Recursive Structures 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 by these steps: Basis Step: A single vertex r is a rooted tree. Recursive Step: Suppose that T 1, T 2, …, T n are disjoint rooted trees with roots r 1, r 2, …r n, respectively. Then the graph formed by starting with a root r, which is not in any of the rooted trees T 1, T 2, … T n, and adding an edge from r to each of the vertices r 1, r 2, … r n is also a rooted tree.

21 21 Recursive Structures The set of extended binary trees can be defined recursively by these steps: Basis Step: The empty set is an extended binary tree. Recursive Step: If T 1 and T 2 are disjoint extended binary trees, then there is an extended binary tree, denoted by T 1 · T 2, consisting of a root r together with edges connecting the root to each of the roots of the left subtree T 1 and the right subtree T 2 when these trees are nonempty.

22 22 Recursive Structures The set of full binary trees can be defined recursively by these steps: Basis Step: There is a full binary tree consisting only of a single vertex r. Recursive Step: If T 1 and T 2 are disjoint full binary trees, there is a full binary tree, denoted by T 1 · T 2, consisting of a root r together with edges connecting the root to each of the roots of the left subtree T 1 and the right subtree T 2.

23 23 Counting (now in chapter 5) The basic counting principles are the product rule and sum rule. Product Rule: Suppose that a procedure can be broken down into a sequence of two tasks. If there are n ways to do the first task and for each of these ways of doing the first task, there are m ways to do the second task, then there are n·m ways to do the procedure. Sum Rule: If a task can be done either in one of n ways or in one of m ways, where none of the set of n ways is the same as any of the set of m ways, then there are n + m ways to do the task.

24 24 Counting Product Rule: Examples. Bill and Ted move into a new house with 12 bedrooms. How many ways can we assign rooms to them? Stadium seats are labeled with a letter and a two-digit number (00 – 99). What’s the maximum number of seats in the stadium? How many license plates can we make using three letters followed by three digits?.

25 25 Counting Sum Rule: Examples. IHOP offers 16 breakfast items, 22 lunch items, and 31 dinner items (all unique). How many possible items do we have to choose from? How many 8-bit bit strings begin with 1 or end with 00? - begin with 1: 2 7 - end with 00: 2 6 - oops, some have been double counted; how many? 2 5 So, 128 + 64 – 32 = 160 ways (principle of inclusion-exclusion)

26 26 Counting How many 4-bit bit strings are there that do not have two consecutive 1s? How many ways can a playoff occur between two teams where the winner must win 3 out of 5 games.

27 27 Counting The Pigeonhole Principle: If k is a positive integer and k+1 or more objects are placed in k boxes, then there is at least one box containing two or more of the objects. (prove BWOC) Of 367 people, at least two have the same birth day. For every integer n there is a multiple of n that has only 0s and 1s in its decimal expansion.

28 28 Counting For every integer n there is a multiple of n that has only 0s and 1s in its decimal expansion. Let n be a positive integer. Consider the n+1 integers: 1, 11, 111, …, 11…1 where the last integer is the integer with n+1 1s. There are n possible remainders when an integer is divided by n. Since there are n+1 integers in the list, by the php there must be at least two with the same remainder when divided by n. The larger integer minus the smaller integer is a multiple of n (how do we know?), which has a decimal expansion consisting entirely of 0s and 1s.


Download ppt "Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5."

Similar presentations


Ads by Google