Theory of Automata: Recursive Definition of Languages
Theory of Automata: Recursive Definition of Languages
Chapter 3
Recursive definition of languages
Recursive definition of languages
The following three steps are used in recursive definition
Step 1: 1 is in INTEGER.
Step 2: If x is in INTEGER then x+1 and x-1 are also in
INTEGER.
Step 3: No strings except those constructed in above, are
allowed to be in INTEGER.
Example 2: Recursive definition of language 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.
Prove: 12 is in EVEN
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}
Example 5b:
◼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
Example 6:
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
Example 7:
Defining the language L, of strings containing aa or bb ,
defined over Σ={a, b}
Step 1: aa and bb are in L
Step 2: s(aa)s’ and s(bb)s’ are also in L, where s & s’
belongs to Σ*
Step 3: No strings except those constructed in above, are
allowed to be in L
Example 8
◼Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, -, *, /, (,
)}
Arithmetic Expression AE
◼ Obviously, the following expressions are not valid:
(3 + 5) + 6) 2(/8 + 9) (3 + (4-)8)
◼ The first contains unbalanced parentheses; the
second contains the forbidden substring (/; the third
contains the forbidden substring -).
◼ Are there more rules? The substrings // and */ are
also forbidden.
◼ Are there still more?
◼ The most natural way of defining a valid AE is by
using a recursive definition, rather than a long list
of forbidden substrings.
AE (Arithmetic Expressions) defined over S =
{0,1,2,3,4,5,6,7,8,9,+, –,*,/,(,)}