Chap03 PDF
Chap03 PDF
Recursive Definitions
3.1 Definition
A recursive definition is characteristically a three-step process:
1. First, we specify some basic objects in the set. The number of basic
objects specified must be finite.
3.2 Examples
Example: Consider the set P-EVEN, which is the set of positive even num-
bers.
We can define the set P-EVEN in several different ways:
• We can define P-EVEN to be the set of all positive integers that are
evenly divisible by 2.
3-1
CHAPTER 3. RECURSIVE DEFINITIONS 3-2
Rule 1 2 is in P-EVEN.
Rule 2 If x is in P-EVEN, then so is x + 2.
Rule 3 The only elements in the set P-EVEN are those that can be
produced from the two rules above.
Note that the first two definitions of P-EVEN are much easier to apply than
the last.
In particular, to show that 12 is in P-EVEN using the last definition, we would
have to do the following:
1. 2 is in P-EVEN by Rule 1.
2. 2 + 2 = 4 is in P-EVEN by Rule 2.
3. 4 + 2 = 6 is in P-EVEN by Rule 2.
4. 6 + 2 = 8 is in P-EVEN by Rule 2.
5. 8 + 2 = 10 is in P-EVEN by Rule 2.
6. 10 + 2 = 12 is in P-EVEN by Rule 2.
Rule 1 2 is in P-EVEN.
1. 2 is in P-EVEN by Rule 1.
2. 2 + 2 = 4 is in P-EVEN by Rule 2.
3. 4 + 4 = 8 is in P-EVEN by Rule 2.
4. 4 + 8 = 12 is in P-EVEN by Rule 2.
CHAPTER 3. RECURSIVE DEFINITIONS 3-3
Example: Let PALINDROME be the set of all strings over the alphabet Σ =
{a, b} that are the same spelled forward as backwards; i.e., PALINDROME
= {w : w = reverse(w)} = {Λ, a, b, aa, bb, aaa, aba, bab, bbb, aaaa, abba, . . .}.
A recursive definition for PALINDROME is as follows:
Σ = {0 1 2 3 4 5 6 7 8 9 + − ∗ / ( )}
Rule 4 AE consists of only those things can be created by the above three
rules.
For example,
(5 ∗ (8 + 2))
CHAPTER 3. RECURSIVE DEFINITIONS 3-4
and
5 − (8 + 1)/3
are in AE since they can be generated using the above definition.
However,
((6 + 7)/9
and
4(/9 ∗ 4)
are not since they cannot be generated using the above definition.
Now we can use our recursive definition of AE to show that
8 ∗ 6 − ((4/2) + (3 − 1) ∗ 7)/4
is in AE.
2. 8 ∗ 6 is in AE by Rule 3(iii).
4. (4/2) is in AE by Rule 2.
5. 3 − 1 is in AE by Rule 3(ii).
6. (3 − 1) is in AE by Rule 2.
7. (3 − 1) ∗ 7 is in AE by Rule 3(iii).
9. ((4/2) + (3 − 1) ∗ 7) is in AE by Rule 2.