0% found this document useful (0 votes)
18 views2 pages

CSC445 Gharibyan Recursion

The document discusses different ways to specify formal languages including set notation, explicit definition for finite languages, and recursive definition for infinite languages with simple syntax. Several examples are provided to illustrate recursive definitions of languages over different alphabets with properties like containing certain strings or having even/odd lengths.

Uploaded by

pophubcontent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

CSC445 Gharibyan Recursion

The document discusses different ways to specify formal languages including set notation, explicit definition for finite languages, and recursive definition for infinite languages with simple syntax. Several examples are provided to illustrate recursive definitions of languages over different alphabets with properties like containing certain strings or having even/odd lengths.

Uploaded by

pophubcontent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Dr.

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}

If the language is finite, it can be specified by explicit definition (by explicitly


listing all strings of the language).
Example: The language L over the alphabet {a,b} consisting of the strings of length
3 or less, and containing at most one a is specified explicitly:
L = { λ, a, b, ab, ba, bb, abb, bab, bba, bbb}

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

Homework1, Part 1 of 2 (submit Part1 only on Wednesday, 01/17/24)


Read Sections 2.1, 2.2 of chapter 2.
Exercises: 2, 4(a,b), 5 (a,b,c), 6, 7, 8, 11(a,b), 13 at the end of Chapter 2.

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

You might also like