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

Slides:



Advertisements
Similar presentations
Recursive Definitions and Structural Induction
Advertisements

Recursively Defined Functions
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
10.1 CompSci 102© Michael Frank Today’s topics RecursionRecursion –Recursively defined functions –Recursively defined sets –Structural Induction Reading:
UCI ICS/Math 6A, Summer Recursion -1 after Strong Induction “Normal” Induction “Normal” Induction: If we prove.
Induction and recursion
UCI ICS/Math 6D5-Recursion -1 Strong Induction “Normal” Induction “Normal” Induction: If we prove that 1) P(n 0 ) 2) For any k≥n 0, if P(k) then P(k+1)
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
1 Section 4.1 Basics of Counting. 2 Basic Counting Principles: Sum Rule Suppose you have two tasks to perform: –The first task can be done in n 1 ways;
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CSE115/ENGR160 Discrete Mathematics 03/31/11
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Lecture Recursive Definitions. Fractals fractals are examples of images where the same elements is being recursively.
Chapter Mathematical Induction
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Properties of the Integers: Mathematical Induction
Induction and recursion
Induction and recursion
Applied Discrete Mathematics Week 9: Relations
CS100 : Discrete Structures
Recursive Definitions and Structural Induction
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Induction and recursion
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 4 Induction and Recursion 歐亞書局.
Chapter 4: Induction and Recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Induction and recursion
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Sequences and Summations
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
The Basics of Counting Section 6.1.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Chapter 5 With Question/Answer Animations. Section 5.1.
4.3 Recursive Definitions and Structural Induction Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object.
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.
1 Lecture 3.3: Recursion CS 250, Discrete Structures, Fall 2012 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Mathematical Preliminaries
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
1 Recursive Definitions and Structural Induction CS 202 Epp section ??? Aaron Bloomfield.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
CS 104: Discrete Mathematics
Chapter 5 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki, Copyright.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Chapter 4: Induction and Recursion
Induction and Recursion Chapter 5
Induction and Recursion
Recursively Defined Functions
Mathematical Induction Recursion
Discrete Structures for Computer Science
Discrete Structures for Computer Science
Induction and recursion
Chapter 4 Induction and Recursion
Representations of Integers
Induction and recursion
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
Presentation transcript:

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 Romanesque Broccoli A fractal coastline in northern Portugal

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 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 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 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 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 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 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 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 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 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., ) 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 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 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 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 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 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 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 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 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: end with 00: oops, some have been double counted; how many? 2 5 So, – 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.