Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

Theory of Automata

Lecture # 5

Chapter # 4 Cont…
Definition
For regular expressions r1 and r2

Lr1  r2   Lr1   Lr2 


Lr1  r2   Lr1  Lr2 
Lr1 *  Lr1 *
Lr1   Lr1 

2
Example
Regular expression: a  b   a *
La  b   a *  La  b  La *
 La  b  La *
 La   Lb  La *
 a b a*
 a, b , a, aa, aaa,...
 a, aa, aaa,..., b, ba, baa,...
3
Example

Regular expression r  a  b * a  bb 
Lr   a, bb, aa, abb, ba, bbb,...

Regular expression r  aa * bb * b


2n 2m
Lr   {a b b : n, m  0}

4
Example
r  (0  1) * 00 (0  1) *
L(r ) = { all strings with at least
two consecutive 0 }

r  (1  01) *(0   )  1*(011*)*(0   )


L(r ) = { all strings without
two consecutive 0 }

5
Regular Languages
Definition: The language generated by any
regular expression is called a regular
language.
Note: If r1, r2 are regular expressions,
corresponding to the languages L1 and L2
then the languages generated by r1+ r2, r1r2
(or r2r1) and r1*( or r2*) are also regular
languages.

6
Languages
Generated by
Regular Expressions
 Regular
Languages

7
Note: All finite languages are regular whereas some
infinite languages are regular & some are non-regular.
In order to write RE for finite languages just include
+’s between the words of finite languages.
Consider the alphabet Σ={a,b}. The words of length 1
are two. Its RE will be a+b.
Similarly the words of length 2 will be aa,ab,ba,bb. Its
RE will be aa+ab+ba+bb or (a+b)(b+a).
Similary the languages of all words whose length is 3
will be aaa,aab,aba,abb,bbb,bba,bab,baa.
Thus we can conclude that all words of a’s and b’s of
any length can be defined by (a+b)*.
8
EVEN-EVEN Language
EVEN-EVEN = { aa bb aaaa aabb abab abba baab
baba bbaa bbbb aaaaaa …}
In this language we have following three types of
strings
type1 = aa
type2 = bb
type3 = (ab+ba)(aa+bb)*(ab+ba)

Thus the RE = (type1 +type2 +type3)*


= (aa + bb + (ab+ba)(aa+bb)*(ab+ba))*

9
Equivalent Regular Expressions

Definition:

Regular expressions r1 and r2

are equivalent if L(r1 )  L(r2 )

10
Check Equality
1. (a+)* = (a*)+ = a*
2. (a*+b)* = (a+b)*
3. (a+b)*ab(a+b)* = (a+b)*a(a+b)*b(a+b)*
4. (a+b)*= (a*+b*)*
5. (a+b)*= (a*b*+b*a*)*
6. (a+b)*= a(a+b)*+b(a+b)*+
7. (a+b)*= a(a+b)*ab(a+b)*+b*a*
8. (aa+ab*)* = (aa+ab)*
9. a*a* = (aa)*
10.(a+b)*= (a*b*)*
11
Check Equality
1. (a+)* = (a*)+ = a*
Yes
2. (a*+b)* = (a+b)* Yes
3. (a+b)*ab(a+b)* = (a+b)*a(a+b)*b(a+b)* Yes
4. (a+b)*= (a*+b*)* Yes
5. (a+b)*= (a*b*+b*a*)* Yes
6. (aa+ab*)* = (aa+ab)* No – what is missing
7. (a+b)*= a(a+b)*+b(a+b)*+ Yes
8. (a+b)*= a(a+b)*ab(a+b)*+b*a* No
9. a*a* = (aa)* No
10.(a+b)*= (a*b*)* Yes
12
Practice Questions

See examples at p-37, 38, 39, 40, 46, 47


Ch # 4 Exercise p-49.
Questions: 2, 3, 4, 5, 6, 7, 8, 9, 10

13

You might also like