0% found this document useful (0 votes)
4 views26 pages

Module 2

Module II covers Regular Expressions and Languages, detailing their definitions, applications, and methods for conversion between finite automata and regular expressions. It discusses the limitations of regular languages, the concept of non-regular languages, and the Pumping Lemma theorem. Additionally, it addresses closure properties of regular languages and the equivalence and minimization of finite automata.

Uploaded by

surabhik021
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)
4 views26 pages

Module 2

Module II covers Regular Expressions and Languages, detailing their definitions, applications, and methods for conversion between finite automata and regular expressions. It discusses the limitations of regular languages, the concept of non-regular languages, and the Pumping Lemma theorem. Additionally, it addresses closure properties of regular languages and the equivalence and minimization of finite automata.

Uploaded by

surabhik021
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/ 26

Theory of Computation Module II

MODULE 2
REGULAR EXPRESSIONS & LANGUAGES
 Introduction to Regular Expression
 Finite automata and regular expression
 Proving languages not to be regular
 Closure properties of regular Languages
 Equivalence and minimization of automata
 Applications of Regular Expressions

Regular Expression : A regular expression is recursively defined as


 Ø is a regular expression denoting an empty language
 Ʃ is a regular expression indicates the language consisting of an empty string
 a is a regular expression which indicates language containing only one a
 If R is a regular expression denoting langauge LR and S is a regular expression denoting language
Ls then
a) R+S is a regular expression corresponding to the language LR U LS
b) R.S is a regular expression corresponding to the language LR.LS
c) R* is a regular expression corresponding to the language LR.
 The expression denoted by applying any of the rules from 1 to 4 are regular expression

Some of the regular expressions:


1. Obtain a regular expression to accept a lanagauge consisiting of strings of a’s and b’s with alternate
a’s and b’s.
(ab)*+b(ab)*+(ba)*+a(ba)*

2. Obtain a regular expression to accept the lanaguage consisting of strings of 0’s and 1’s with atmost
one pair of consecutive 0’s
(1+01)*001*

3. Obtain a regular expression to accept lanagauge consisting of atleast one a and atleast one b where
Ʃ = {a,b,c}
[c*a(a+c)*b+c*b(b+c)*a](a+b+c)*
Explaination to the solution:
RE for the strings of a’s,b’s and c’s is

DR. Nagashree N Page 1


Theory of Computation Module II

(a+b+c)*
String should have atleast one a and atleast one b so
First a proceeding b or b processing a is written as
c*a(a+c)*b or c*b(b+c)*a
The RE (a+b+c)* can be proceeded by one of the two cases
That is, c*a(a+c)*b(a+b+c)* + c*b(b+c)*a(a+b+c)*
Therefore the final RE is
[c*a(a+c)*b + c*b(b+c)*a] (a+b+c)*

4. Obtain a regular expression to accept a language consisting of strings of a’s and b’s of even
length
(aa+ab+ba+bb)*

5. Obtain a regular expression to accept the language consisiting of strings of a’s and b’s of odd
length
(a+b) (aa+ab+ba+bb)*

6. Obtain a regular expression such that L( R) ={w belongs to 0,1} with atleast 3 consecutive 0’s

(0+1)*000(0+1)*

7. Obtain a regular expression to accept strings of a’s and b’s ending with b and has no substring
aa

(b+ab)(b+ab)*

8. Obtain a regular expression to accept the strings of 0’s and 1’s having no or two consecutive 0’s

(1+01)*(0+e)

9. Obtain a regular expression to accept the strings of a’s and b’s of length <=10

(e+a+b)

10. Obtain a regular expression to accept the strings of a’s and b’s starting with a and ending with
b
a(a+b)*b

11. Obtain a regular expression to accept the strings of a’s and b’s whose thenth symbol from
right end is a

DR. Nagashree N Page 2


Theory of Computation Module II

a(a+b)(a+b(a+b)(a+b)(a+b)(a+b)(a+b)(a+b)(a+b))

12. Obtain a regular expression to acccept the strings with two or more letters but beginning and
ending with same letter.

a(a+b)*a+b(a+b)*b

13. Obtain a regular expression to accept the strings of a’s and b’s whose whose length is either
even or multiples of 3 or both

[(a+b)(a+b)]* + [(a+b)(a+b)(a+b)]*

DR. Nagashree N Page 3


Theory of Computation Module II

Finite Automata and Regular Expression

I) To obtain finite automata from regular expression

DR. Nagashree N Page 4


Theory of Computation Module II

DR. Nagashree N Page 5


Theory of Computation Module II

II) To obtain regular expression from finite automata


There are two methods to obtain Regular Expression from Finite Automa
1) State Elimination Method
2) Kleen’s theorem
1. Converting FA to RE using state elimination method:
Theorem: Let M =(Q,Ʃ,δ,q0,F) be a FA recognising the language L. Then there exists
an equivalent regular expression R for the reguar language L such that L=L( R)

Example 1. Obtain a RE from the FA shown below

DR. Nagashree N Page 6


Theory of Computation Module II

DR. Nagashree N Page 7


Theory of Computation Module II

2. 4

3. Converting FA to RE using Kleen’s theorem

DR. Nagashree N Page 8


Theory of Computation Module II

DR. Nagashree N Page 9


Theory of Computation Module II

DR. Nagashree N Page 10


Theory of Computation Module II

DR. Nagashree N Page 11


Theory of Computation Module II

DR. Nagashree N Page 12


Theory of Computation Module II

DR. Nagashree N Page 13


Theory of Computation Module II

Regular Languages: A language is said to be a REGULAR LANGUAGE if and only if


some finite state machine recognizes it.
Limitations of Regular Language:
Every finite language is regular and any finite language can be expressed using
regular expression and any language which can be represented using regular
expression, we can have DFA.
But some of the infinite languages are not regular.
Non Regular Languages: The languages which are not accepted by the finite
automata are called non regular language. The pumping Lemma theorem is used to
prove that some languages are not regular.

Conceptual Finite automata: generates many strings by looping(or pumping). It


doesn’t have any storge to trace whether the generated string is in language.
Pumping Lemma refines the finite automata to show the generated strings are not
in language.

Pumping Lemma for Irregular Language


Theorem:

Proof:

DR. Nagashree N Page 14


Theory of Computation Module II

DR. Nagashree N Page 15


Theory of Computation Module II

Problems on Pumping Lemma:

DR. Nagashree N Page 16


Theory of Computation Module II

DR. Nagashree N Page 17


Theory of Computation Module II

DR. Nagashree N Page 18


Theory of Computation Module II

Closure properties of Regular Languages:

DR. Nagashree N Page 19


Theory of Computation Module II

Equivalence and minimization of finite automata


Any two automata is said to be equivalent if anf only ifit accepts the same set of
inputs.
Two automata are equivalent if they satifies the following conditions:

DR. Nagashree N Page 20


Theory of Computation Module II

DR. Nagashree N Page 21


Theory of Computation Module II

DR. Nagashree N Page 22


Theory of Computation Module II

DFA Minimization:

DR. Nagashree N Page 23


Theory of Computation Module II

2.

DR. Nagashree N Page 24


Theory of Computation Module II

DR. Nagashree N Page 25


Theory of Computation Module II

DR. Nagashree N Page 26

You might also like