Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.

Slides:



Advertisements
Similar presentations
Chapter 1 Section 3 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Advertisements

Recursive Definitions and Structural Induction
Copyright © Cengage Learning. All rights reserved. 6 Equations and Formulas.
COUNTING AND PROBABILITY
Copyright © Cengage Learning. All rights reserved.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
Copyright © Cengage Learning. All rights reserved. 3 Differentiation Rules.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
ELEMENTARY NUMBER THEORY AND METHODS OF PROOF
Set Notation.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Induction and recursion
Copyright © Cengage Learning. All rights reserved.
Introduction to Proofs
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Lecture#16 Discrete Mathematics. Recursion Now, 1 is an odd positive integer by the definition base. With k = 1, = 3, so 3 is an odd positive integer.
Chapter 7 Logic, Sets, and Counting Section 2 Sets.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
Week 6 - Friday.  What did we talk about last time?  Solving recurrence relations.
Copyright © Cengage Learning. All rights reserved. 6 Inverse Functions.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Chapter 1 Section 3. Objectives 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Evaluate algebraic expressions, given values for the variables.
Copyright © Cengage Learning. All rights reserved. Fundamental Concepts of Algebra 1.1 Real Numbers.
Inductive Proofs and Inductive Definitions Jim Skon.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
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.
Slide Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
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.
Opener: Find three consecutive odd integers whose sum is -63 Integer #1 = n Integer #2 = n + 2 Integer #3 = n + 4 (n) + (n + 2) + (n + 4) = -63 3n + 6.
Chapter 1 Logic and Proof.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Copyright © Cengage Learning. All rights reserved.
Direct Proof and Counterexample V: Floor and Ceiling
Discrete Structures for Computer Science
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Chapter 7 Logic, Sets, and Counting
Chapter 1 Section 3.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Copyright © Cengage Learning. All rights reserved. General Recursive Definitions and Structural Induction SECTION 5.9

3 Recursively Defined Sets

4 To define a set of objects recursively, you identify a few core objects as belonging to the set and give rules showing how to build new set elements from old. More formally, a recursive definition for a set consists of the following three components: I. BASE: A statement that certain objects belong to the set. II. RECURSION: A collection of rules indicating how to form new set objects from those already known to be in the set.

5 Recursively Defined Sets III. RESTRICTION: A statement that no objects belong to the set other than those coming from I and II.

6 Example 1 – Recursive Definition of Boolean Expressions An expression composed of boolean variables letters from the alphabet such as p, q, and r, and the connectives ∧, ∨, and ~ is called boolean expression. To make precise which expressions are legal, the set of Boolean expressions over a general alphabet is defined recursively. I. BASE: Each symbol of the alphabet is a Boolean expression.

7 Example 1 – Recursive Definition of Boolean Expressions II. RECURSION: If P and Q are Boolean expressions, then so are (a) (P ∧ Q) and (b) (P ∨ Q) and (c) ~P. III. RESTRICTION: There are no Boolean expressions over the alphabet other than those obtained from I and II. Derive the fact that the following is a Boolean expression over the English alphabet {a, b, c,..., x, y, z}: (~(p ∧ q) ∨ (~r ∧ p)). cont’d

8 Example 1 – Solution (1) By I, p, q, and r are Boolean expressions. (2) By (1) and II(a) and (c), (p ∧ q) and ~ r are Boolean expressions. (3) By (2) and II(c) and (a), ~(p ∧ q) and (~ r ∧ p) are Boolean expressions. (4) By (3) and II(b), (~ (p ∧ q) ∨ (~ r ∧ p)) is a Boolean expression.

9 Recursively Defined Sets

10 Certain configurations of parentheses in algebraic expressions are “legal” [such as(())() and()()()], whereas others are not [such as)())) and()))((( ]. Here is a recursive definition to generate the set P of legal configurations of parentheses. I. BASE: () is in P. II. RECURSION: a. If E is in P, so is (E). b. If E and F are in P, so is EF. Example 4 – Parenthesis Structures

11 III. RESTRICTION: No configurations of parentheses are in P other than those derived from I and II above. Derive the fact that (())() is in P. Solution: (1) By I, () is in P. (2) By (1) and II(a), (()) is in P. (3) By (2), (1), and II(b), (())() is in P. Example 4 – Parenthesis Structures cont’d

12 Proving Properties about Recursively Defined Sets

13 When a set has been defined recursively, a version of mathematical induction, called structural induction, can be used to prove that every object in the set satisfies a given property. Proving Properties about Recursively Defined Sets

14 Proving Properties about Recursively Defined Sets

15 Example 5 – A Property of the Set of Parenthesis Structures Consider the set P of all grammatical configurations of parentheses defined in Example 4. Prove that every configuration in P contains an equal number of left and right parentheses. Solution: Proof (by structural induction): Given any parenthesis configuration, let the property be the claim that it has an equal number of left and right parentheses. Show that each object in the BASE for P satisfies the property: The only object in the base for P is (), which has one left parenthesis and one right parenthesis, so it has an equal number of left and right parentheses.

16 Example 5 – Solution Show that for each rule in the RECURSION for P, if the rule is applied to an object in P that satisfies the property, then the object defined by the rule also satisfies the property: The recursion for P consists of two rules denoted II(a) and II(b). Suppose E is a parenthesis configuration that has an equal number of left and right parentheses. When rule II(a) is applied to E, the result is (E), so both the number of left parentheses and the number of right parentheses are increased by one. Since these numbers were equal to start with, they remain equal when each is increased by one. cont’d

17 Example 5 – Solution Suppose E and F are parenthesis configurations with equal numbers of left and right parentheses. Say E has m left and right parentheses, and F has n left and right parentheses. When rule II(b) is applied, the result is EF, which has an equal number, namely m + n, of left and right parentheses. Thus when each rule in the RECURSION is applied to a configuration of parentheses in P with an equal number of left and right parentheses, the result is a configuration with an equal number of left and right parentheses. Therefore, every structure in P has an equal number of left and right parentheses. cont’d

18 Recursive Functions

19 A function is said to be defined recursively or to be a recursive function if its rule of definition refers to itself. Because of this self-reference, it is sometimes difficult to tell whether a given recursive function is well defined. Recursive functions are of great importance in the theory of computation in computer science. Recursive Functions

20 The following function M : Z + → Z was defined by John McCarthy, a pioneer in the theory of computation and in the study of artificial intelligence: for all positive integers n. Find M(99). Example 6 – McCarthy’s 91 Function

21 Example 6 – Solution By repeated use of the definition of M,

22 Example 6 – Solution The remarkable thing about this function is that it takes the value 91 for all positive integers less than or equal to 101. Of course, for n > 101, M(n) is well defined because it equals n – 10. cont’d

23 The next example is a recursive “definition” that does not define a function. Recursive Functions

24 Consider the following attempt to define a recursive function G from Z + to Z. For all integers n  1, Is G well defined? Why? Example 8 – A Recursive “Function” That Is Not Well Defined

25 Suppose G is a function. Then by definition of G, Example 8 – Solution

26 However, Subtracting G(5) from both sides gives 0 = 3, which is false. Since the supposition that G is a function leads logically to a false statement, it follows that G is not a function. Example 8 – Solution cont’d

27 A slight modification of the formula of Example 8 produces a “function” whose status of definition is unknown. Consider the following formula: For all integers n  1, In the 1930s, a student, Luther Collatz, became interested in the behavior of a related function g, which is defined as follows: g(n) = n/2 if n is even, and g(n) = 3n + 1 if n is odd. Recursive Functions

28 Collatz conjectured that for any initial positive number n, computation of successive values of g(n), g 2 (n), g 3 (n),... would eventually produce the number 1. Determining whether this conjecture is true or false is called the 3n + 1 problem (or the 3x + 1 problem). If Collatz’s conjecture is true, the formula for T defines a function; if the conjecture is false, T is not well defined. Recursive Functions