Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson.

Similar presentations


Presentation on theme: "Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson."— Presentation transcript:

1 Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson

2 A recursive definition for a set consists of the following three components: I.BASE: A statement that certain objects belong to a set. II.RECURSION: A collection of rules indicating how to form new set objects from those already known to be in a set. III.RESTRICTION: A statement that no objects belong to the set other than those coming from I and II. 5.9 General Recursive Definitions and Structural Induction 2Erickson

3 Consider the set of Boolean expressions defined below. Give derivations showing that ((p  q)  ~((p  ~s)  r)) is a Boolean expression over the English alphabet {a, b, c, …, x, y, z}. I. BASE: Each symbol of the alphabet is a Boolean expression. 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 expression over the alphabet other than those obtained from Iand II. 5.9 General Recursive Definitions and Structural Induction 3Erickson

4 Let S be a finite set with at least one element. String over S A string over S is a finite sequence of elements from S. Characters The elements of S are called characters of the string. Length The length of a string is the number of characters it contains. Null String over S The null strong over S is defined to be the string with no characters. It is usually denoted by e and is said to have length 0. 5.9 General Recursive Definitions and Structural Induction 4Erickson

5 Structural Induction 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. 5.9 General Recursive Definitions and Structural Induction 5Erickson

6 Let S be a set that has been defined recursively, and consider a property that objects in S may or may not satisfy. To prove that every object in S satisfies the property: 1. Show that each object in the BASE for S satisfies the property; 2. Show that for each rule in the RECURSION, if the rule is applied to the objects in S that satisfy the property, then the objects defined by the rule also satisfy the property. Because no objects other than those obtained through the BASE and RECURSION conditions are contained in S, it must be the case that every object in S satisfies the property. 5.9 General Recursive Definitions and Structural Induction 6Erickson

7 Define a set S recursively as follows: I.BASE: 1  S, 2  S, 3  S, 4  S, 5  S, 6  S, 7  S, 8  S, 9  S, II.RECURSION: If s  S and t  S, a. s0  Sb. st  S III.RESTRICTION: Nothing is in S other than objects defined in I and II above. Use structural induction to prove that no string in S represents an integer with a leading zero. 5.9 General Recursive Definitions and Structural Induction 7Erickson

8 16.Give a recursive definition for the set of all strings of 0’s and 1’s for which all the 0’s precede all the 1’s. 17.Give a recursive definition for the set of all strings of a’s and b’s that contain an odd number of a’s. 5.9 General Recursive Definitions and Structural Induction 8Erickson


Download ppt "Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson."

Similar presentations


Ads by Google