1 / 28

Discrete Mathematics CS 2610

Discrete Mathematics CS 2610. March 26, 2009. Skip: structural induction generalized induction Skip section 4.5. Well-Ordering Property. Every non-empty set of non-negative integers has a minimum (smallest) element

mac
Download Presentation

Discrete Mathematics CS 2610

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. In Nature Fractals are self-similar structures, most of them defined recursively A fractal coastline in northern Portugal Romanesque Broccoli

  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 a0=1, r=3 an=an-1+r, n>0 yields: 1, 4, 7, 10, 13, … Geometric Series a0=3, r=2 an=an-1r, n>0 yields: 3, 6, 12, 24, 48, … an = 2n yields: 1, 2, 4, 8, 16, 32, … or an+1 = 2an where n > 0 and a0 = 1

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

  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: a0 = 1 Recursion: an = 3an-2 - an-1 What is a1? Can’t tell so this is no good.

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

  9. Fibonacci Sequence Theorem: fn < 2n. Proof: (By strong induction.) • Base cases: f0= 0 < 20 = 1f1= 1 < 21 = 2 • Inductive step: Inductive Hypothesis: Assume j, 1 < j  k, fj < 2j. i.e., f2 < 22, f3 < 23, …, fk < 2k show that fk+1 < 2k+1 fk + fk-1 < 2·2k = 2k + 2k fk < 2k from ind hyp and fk-1 ≤ fk < 2k so fk+1 < 2k+1

  10. Fibonacci Sequence Theorem.n≥ 3, fn > α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. 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. 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. 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) ?

  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 = {2k | k  N }

  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. 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  Σ* andx  Σ then wx  Σ* Is *countable or uncountable ?

  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 w1 Σ*, w2 Σ* and x  Σ then w1·(w2 x)  Σ* (same as (w1 · w2) x  Σ*) Example: Σ={a, b} Let w1=aba, w2=a and x=b then abaab  Σ*

  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| + 1 so |aba| = |a| + 2 |a| = |()a| = || + 1 so |aba| = || + 3 || = 0 so |aba| = 3

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

  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. 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 T1, T2, …, Tn are disjoint rooted trees with roots r1, r2, …rn, respectively. Then the graph formed by starting with a root r, which is not in any of the rooted trees T1, T2, … Tn, and adding an edge from r to each of the vertices r1, r2, … rn is also a rooted tree.

  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 T1 and T2 are disjoint extended binary trees, then there is an extended binary tree, denoted by T1 · T2, 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 when these trees are nonempty.

  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 T1 and T2 are disjoint full binary trees, there is a full binary tree, denoted by T1 · T2, 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.

  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. 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. 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: 27 - end with 00: 26 - oops, some have been double counted; how many? 25 So, 128 + 64 – 32 = 160 ways (principle of inclusion-exclusion)

  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. 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. 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.

More Related