Lec 02- Recursive Definition.ppt
Lec 02- Recursive Definition.ppt
2
3
⚫ Recursive definition of languages
The following three steps are used in
recursive definition
1. Some basic words are specified in the
language.
2. Rules for constructing more words are
defined in the language.
3. No strings except those constructed in
above, are allowed to be in the
language.
Language of Integer
⚫Defining language of EVEN
Step 1:
2 is in EVEN.
Step 2:
If x is in EVEN then x+2 and x-2 are also
in EVEN.
Step 3:
No strings except those constructed in
above, are allowed to be in EVEN.
Example
6
⚫Defining the language factorial
Step 1:
As 0!=1, so 1 is in factorial.
Step 2:
n!=n*(n-1)! is in factorial.
Step 3:
No strings except those constructed in
above, are allowed to be in factorial.
Example
7
⚫Defining the language {anbn },
n=1,2,3,… , of strings defined over
Σ={a,b}
Step 1:
ab is in {anbn}
Step 2:
if x is in {anbn}, then axb is in {anbn}
Step 3:
No strings except those constructed in
above, are allowed to be in {anbn}
8
⚫Defining the language L, of strings
ending in a , defined over Σ={a,b}
Step 1:
a is in L
Step 2:
if x is in L then s(x) is also in L, where s
belongs to Σ*
Step 3:
No strings except those constructed in
above, are allowed to be in L
9
⚫Defining the language L, of strings
beginning and ending in same letters
, defined over Σ={a, b}
Step 1:
a and b are in L
Step 2:
(a)s(a) and (b)s(b) are also in L, where s
belongs to Σ*
Step 3:
No strings except those constructed in
above, are allowed to be in L
10
⚫Defining the language L, of strings
containing exactly aa, defined over
Σ={a, b}
Step 1:
aa is in L
Step 2:
s(aa)s is also in L, where s belongs to Σ*
Step 3:
No strings except those constructed in
above, are allowed to be in L
11
⚫ Example: The language EVEN-EVEN, of
strings with even number of a’s and even
number of b’s, defined over Σ={a,b},
⚫ can be written as
⚫ {Λ, aa, bb, aaaa, aabb, abab, abba, baab,
baba, bbaa, bbbb,…}
⚫ Example: The language INTEGER, of
strings defined over
Σ={-,0,1,2,3,4,5,6,7,8,9}, can be written
as
⚫ INTEGER = {…,-2,-1,0,1,2,…}
⚫ Even-Even langage
15