CSC445 Gharibyan Recursion
CSC445 Gharibyan Recursion
Hasmik Gharibyan
Specification of Languages
The specification of a language is an unambiguous description of the strings of the
language. Let’s discuss some ways we can specify a language.
In math we often use set notation, also known as implicit definition, to specify sets.
Example: the following implicit definition specifies the set of even length strings
over a given alphabet Σ:
L = { w | w∈Σ* and w has even length}
Infinite languages with simple syntax can be specified with the help of a recursive
definition.
Example 1: The language L of strings over {a,b} in which each string begins with aa
is defined recursively as follows:
1) Basis: aa∈L
2) Recursive step: If u∈L, then ua∈L and ub∈L
3) Closure: u∈L only if it can be obtained from the basis by finite number of
applications of the recursive step.
Example 2: The language L of strings over {a,b} in which each string contains an aa
is defined recursively as follows:
1) Basis: …………………………
2) Recursive step: …………………………………………………………….
3) Closure: . . . . . . . . . . . .
Example 3: The language L of strings over {a,b} in which each string has an even
length and contains an aa is defined recursively as follows:
1) Basis: …………………………
2) Recursive step: …………………………………………………………….
3) Closure: . . . . . . . . . . . .
Example 3a: Let L be as defined in example 3 but with odd length (i.e. odd length
strings containing aa). Then the definition will change as follows:
…………………………………………………………….
1
Dr. Hasmik Gharibyan
Example 4: The language L of strings over {a,b,c} in which each occurrence of b is
preceded by a and followed by c is defined recursively as follows:
1) Basis: …………………………
2) Recursive step: …………………………………………………………….
3) Closure: u∈L only if it can be obtained from the basis by finite number of
applications of the recursive step.
Example 5: The language L of palindromes over Σ (palindrome is a string that spells
the same way forward and backward), is defined recursively as follows:
1) Basis: λ∈L, a∈L for all a∈Σ.
2) Recursive step: If u∈L and a∈Σ, then aua∈L.
3) Closure: . . . . . . . . . . . .
Example 6: The language L = {aib2i | i>0} over {a,b} is defined as follows:
1) Basis: …………………………
2) Recursive step: …………………………………………………………….
3) Closure: . . . . . . . . . . . .
Example 7: The language L = {w | w∈Σ* and w has equal number of a’s and b’s }
where Σ={a,b} is defined as follows:
1) Basis: …………………………
2) Recursive step: …………………………………………………………….
3) Closure: u∈L only if it can be obtained from the basis by finite number of
applications of the recursive step.
//to be continued
Attention: Start this homework without delay. At this time you can
do all above-listed exercises except #4(a,b) and #13 which
you will be able to do after next lecture.
2