{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

recursive - CSCE 222 Discrete Structures for Computing...

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

View Full Document Right Arrow Icon
CSCE 222 Discrete Structures for Computing Recursion and Structural Induction Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1
Image of page 1

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

View Full Document Right Arrow Icon
Inductively Defined Sets 2
Image of page 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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 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
Image of page 5

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

View Full Document Right Arrow Icon
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
Image of page 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
Image of page 7

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

View Full Document Right Arrow Icon
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
Image of page 8
Example 4: Lists We can define the set L of finite lists of integers as follows.
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern