{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

recursive

# recursive - CSCE 222 Discrete Structures for Computing...

This preview shows pages 1–10. Sign up to view the full content.

CSCE 222 Discrete Structures for Computing Recursion and Structural Induction Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Inductively Defined Sets 2
Motivating Example Consider the set A = {3,5,7,. ..} There is a certain ambiguity about this “definition” of the set A. Likely, A is the set of odd integers >= 3. [However, A could be the set of odd primes. .. ] 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Motivating Example In Computer Science, we prefer to avoid such ambiguities. You will often encounter sets that are inductively defined . We can specify the set as follows: 3 A and if n is in A, then n+2 is in A . In this definition, there is (a) an initial element in A, namely 3. (b) you construct additional elements by adding 2 to an element in A, (c) nothing else belongs to A. We will call this an inductive definition of A. 4
Inductively Defined Sets An inductive definition of a set S has the following form: (a) Basis : Specify one or more “initial” elements of S. (b) Induction : Give one or more rules for constructing “new” elements of S from “old” elements of S. (c) Closure : The set S consists of exactly the elements that can be obtained by starting with the initial elements of S and applying the rules for constructing new elements of S. The closure condition is usually omitted , since it is always assumed in inductive definitions. 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example 1: Natural Numbers Let S be the set defined as follows: Basis: 0 S Induction: If n S, then n+1 S Then S is the set of natural numbers (with 0). Closure? Implied! 6
Example 2 Let S be the set defined as follows: Basis: 0 S Induction: If n S, then 2n+1 S. Can you describe the set S? S = {0,1,3,7,15,31,. .. } = { 2 n -1 | n a nonnegative integer } since 2 0 -1=0 and 2 n+1 -1 = 2(2 n -1)+1 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example 3: Well-Formed Formulas We can define the set of well-formed formulas consisting of variables, numerals, and operators from the set {+,-,*,/} as follows: Basis: x is a well-formed formula if x is a numeral or a variable. Induction: If F and G are well-formed formulas, then (F+G), (F-G), (F*G), and (F/G) are well-formed formulas. Examples: 42, x, (x+42), (x/y), (3/0), (x*(y+z)) 8
Example 4: Lists We can define the set L of finite lists of integers as follows.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 32

recursive - CSCE 222 Discrete Structures for Computing...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online