# Search in the document preview

Discrete Mathematics CS 2610 October 21, 2008

Docsity.com

2

Recursively Defined Functions

We are familiar with the use of formulae to define functions. But it is also possible to define some functions using recursion.

Example:

f(n) = n2 for n ∈ **Z≥0
** or…

f(0) = 0
f(n+1) = f(n) + (2n + 1), for n ∈ **Z≥0**

Docsity.com

3

Recursively Defined Functions

Defining a function recursively requires a basis step
(or steps) and a recursive step, just like induction.
Example: f(n) = n!, for n ∈ **Z≥0**
Basis: f(0) = 1 Yup, that’s the def. of 0!
Rec. Step: f(n+1) = f(n) ⋅ (n+1), n ∈ **Z≥0**

Example: Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, …
Basis: f(0) = 0, f(1) = 1
Rec. Step: f(n+2) = f(n+1) + f(n), for n ∈ **Z≥0**

Docsity.com

4

Recursively Defined Sets

We can define sets in the same manner, by establishing a basis and recursive step. Example: S = { x | x is an odd, positive integer } Basis: 1 ∈ S Rec. Step: if x ∈ S, then x + 2 ∈ S

Docsity.com

5

Recursively Defined Languages

As many of you will learn in theory, a language in Computer Science refers to some set of strings generated from an alphabet using some set of syntax rules. Often times the alphabet is the set {0,1} Example: L = { x | x is a bitstring } Basis: 0 ∈ S, 1 ∈ S Rec. Step: if x ∈ S, then x0 ∈ S and x1 ∈ S (concatenation)

Docsity.com

6

Recursively Defined Structures

Structures such as Graphs, Trees, and Binary Trees can also be defined recursively. We will put off discussion of Structural Recursion and Structural Induction until the end of the course.

Docsity.com

7

Why Define Recursively?

Why bother to define sets, functions, or structures recursively, when there are many other ways to define them?

Recursive definitions can greatly simplify the
inductive proof process.
Example: Fibonacci proof
show f(1) + f(3) + … + f(2n-1) = f(2n) for **Z+**

Docsity.com