Professional Documents
Culture Documents
Regular languages are languages that can be generated from one-element languages by applying certain standard
operations a finite number of times. They are the languages that can be recognized by finite automata. These simple
operations include concatenation, union and kleen closure. By the use of these operations regular languages can be
represented by an explicit formula.
Regular expressions can be thought of as the algebraic description of a regular language. Regular
expression can be defined by the following rules:
4. If a string can be derived from the rules 1, 2 and 3 then it is also a regular expression.
Note that a* means zero or more occurrence of a in the string while a+ means that one or more
occurrence of a in the string. That means a* denotes language L = {є , a, aa, aaa, ….} and a+ represents
language L = {a, aa, aaa, ….}. And also note that there can be more than one regular expression for a
given set of strings.
Order for precedence for the operations is: kleen > concatenation > union. This rule allows us to lessen
the use of parentheses while writing the regular expression. For example a + b*c is the simplified form of
(a + ((b)*c)). Note that (a + b)* is not the same as a + b*, a + b* is (a + (b)*).
Question 1: Write a regular expression for a set of strings of 0s and 1s with even number of 0s.
View Answer
The set of strings would be 00, 001, 0011, 1001, 1010, …. The regular expression for the above set of strings can
be written as (((00)*1*) + (01*0))*.
2. r1r2 is a regular expression denoting the concatenation of L(r1) and L(r2). That is
L(r1r2) = L(r1) . L(r2)
These rules will be used to create regular expressions from a given languages.
For example consider the language L = {an bm : (n + m) is even}. For writing the regular expression we will
have to consider two cases
Case 1: n and m both are even
Case 2: n and m are both odd.
Let the regular expression for case 1 be r1, then
r1 = (aa)* (bb)* (as even numbers can be represented as 2n)
Let the regular expression for case 2 be r1, then
r2 = (aa)* a (bb)* b (as odd numbers can be represented as 2n + 1)
Let the regular expression for the language L be r, then
r = r1 + r1 (as it will be the union of both the cases described above)
r = ((aa)* (bb)*) + (aa)* a (bb)* b)) is the regular expression for the given language.
Question 2: Write a regular expression for the language containing odd number of 1s, ∑ = {0,1}.
View Answer
The language will contain at least one 1. It may contain any number of 0s anywhere in the string. So the language
we have to write a regular expression for is 1, 01, 01101, 0111, 111, . . . . This language can be represented by the
following regular expression
0*(10*10*)10*
http://www.sanfoundry.com/automata-theory-regular-expressions-languages/ 2/2