0% found this document useful (0 votes)
8 views

TOC Unit2

The document discusses the theory of computation, focusing on regular expressions and languages, finite automata, and their applications. It covers operations on regular languages, identity rules, closure properties, and the pumping lemma, providing examples and solutions for various regular expressions. Additionally, it addresses the minimization of deterministic finite automata (DFA) and methods for constructing minimum state automata.

Uploaded by

keerthanamg19
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

TOC Unit2

The document discusses the theory of computation, focusing on regular expressions and languages, finite automata, and their applications. It covers operations on regular languages, identity rules, closure properties, and the pumping lemma, providing examples and solutions for various regular expressions. Additionally, it addresses the minimization of deterministic finite automata (DFA) and methods for constructing minimum state automata.

Uploaded by

keerthanamg19
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 87

THEORY OF COMPUTATION

Dr. K. Ananthajothi M.E.,Ph.D.,


UNIT II:
REGULAR EXPRESSIONS AND LANGUAGES
 Regular expressions, Identity rules,
 Finite automata and Regular expressions,

Applications of regular expressions,


 Closure properties of regular languages,

 Pumping lemma for regular languages,

Applications of the pumping lemma,


 Equivalence of two regular expressions,

Equivalence of two finite automata and


minimization of automata..
REGULAR EXPRESSION
 The language accepted by finite automata can be easily
described by simple expressions called Regular
Expressions. It is the most effective way to represent any
language.
 The languages accepted by some regular expression are
referred to as Regular languages.
 A regular expression can also be described as a sequence
of pattern that defines a string.
 Regular expressions are used to match character
combinations in strings. String searching algorithm used
this pattern to find the operations on a string.
 For instance:
 In a regular expression, x* means zero or more occurrence of x. It
can generate {ε, x, xx, xxx, xxxx, .....}
 In a regular expression, x+ means one or more occurrence of x. It
can generate {x, xx, xxx, xxxx, .....}
OPERATIONS ON REGULAR
LANGUAGE
 The various operations on regular language
are:
 Union: If L and M are two regular languages

then their union L U M is also a union.


L U M = {s | s is in L or s is in M}
 Intersection: If L and M are two regular
languages then their intersection is also an
intersection.
L ⋂ M = {st | s is in L and t is in M}
 Kleen closure: If L is a regular language then
its Kleen closure L1* will also be a regular
language.
 L* = Zero or more occurrence of language L.
Example 1:
Write the regular expression for the language accepting all combinations
of a's, over the set ∑ = {a}

Solution:

All combinations of a's means a may be zero, single, double and so on. If
a is appearing zero times, that means a null string.
That is we expect the set of {ε, a, aa, aaa, ....}. So we give a regular
expression for this as:
R = a*
That is Kleen closure of a.

Example 2:
Write the regular expression for the language accepting all combinations
of a's except the null string, over the set ∑ = {a}
Solution:
The regular expression has to be built for the language
L = {a, aa, aaa, ....}

This set indicates that there is no null string.


So we can denote regular expression as:
R = a+
Example 3:
Write the regular expression for the language accepting all the string
containing any number of a's and b's.
Solution:
The regular expression will be:
r.e. = (a + b)*
This will give the set as L = {ε, a, aa, b, bb, ab, ba, aba, bab, .....},
any combination of a and b.

The (a + b)* shows any combination with a and b even a null string.

Example 4:
Write the regular expression for the language accepting all the string
which are starting with 1 and ending with 0, over ∑ = {0, 1}.

Solution:
In a regular expression, the first symbol should be 1, and the last
symbol should be 0. The r.e. is as follows:
R = 1 (0+1)* 0
Example 5:
Write the regular expression for the language starting and ending with a
and having any having any combination of b's in between.

Solution:
The regular expression will be:
R = a b* a

Example 6:
Write the regular expression for the language starting with a but not
having consecutive b's.

Solution:

The regular expression has to be built for the language:


L = {a, aba, aab, aba, aaa, abab, .....}

The regular expression for the above language is:


R = {a + ab}*
Example 7:
Write the regular expression for the language accepting all the string in
which any number of a's is followed by any number of b's is followed by
any number of c's.
Solution:
As we know, any number of a's means a* any number of b's means b*,
any number of c's means c*. Since as given in problem statement, b's
appear after a's and c's appear after b's.
So the regular expression could be:
R = a* b* c*

Example 8:
Write the regular expression for the language over ∑ = {0} having
even length of the string.
Solution:
The regular expression has to be built for the language:

L = {ε, 00, 0000, 000000, ......}

The regular expression for the above language is:

R = (00)*
Example 9:
Write the regular expression for the language having a string which
should have atleast one 0 and alteast one 1.

Solution:

The regular expression will be:

R = [(0 + 1)* 0 (0 + 1)* 1 (0 + 1)*] + [(0 + 1)* 1 (0 + 1)* 0 (0 + 1)*]

Example 10:
Describe the language denoted by following regular expression
r.e. = (b* (aaa)* b*)*

Solution:
The language can be predicted from the regular expression by
finding the meaning of it. We will first split the regular expression
as:

r.e. = (any combination of b's) (aaa)* (any combination of b's)

L = {The language consists of the string in which a's appear triples,


there is no restriction on the number of b's}
REGULAR EXPRESSION TO ∈-NFA
 Union case
 a+b, a x b, a-b, or a/b

 Concatenation case
 ab
 Closure case
 a*
REGULAR EXPRESSION TO
NFA

Let r be a regular expression, then there exists a NFA


eith ε transitions that accepts L (r).
Example - 2
Example - 3
Unsolved Questions for Practice
Example - 4

Example - 5

Example - 6
IDENTITY RULES

 The two regular


expressions P and Q are
equivalent (denoted as
P=Q) if and only if P
represents the same
set of strings as Q
does. For showing this
equivalence of regular
expressions we need to
show some identities of
regular expressions.
 Let P, Q and R are some
regular expressions and
the identity rules are
given as
GENERATING REGULAR EXPRESSION
FROM FINITE AUTOMATA
Example - 1
Apply rule 1
Example - 2
Apply rule 12
Example - 3
Example -4 : Self Study /Assignment

Example -5 : Self Study /Assignment


CLOSURE PROPERTIES OF REGULAR LANGUAGES
Minimization of DFA
MINIMIZATION OF DFA
 The minimization of FSM means reducing the
number of states from the given FA. Thus we get
the FSM with redundant states after minimising
the FSM.
 While minimising the FSM we first find out which

two states are equivalent we can represent those


two states by one representative state.
 The two state q1 and q2 are equivalent, if both δ

(q1, x) and δ(q2, x) are final states or both of


them are non final states for all x ∈ ∑* (∑*
indicate any string of any length) we can
minimize the given FSM by finding equivalent
states.
METHOD FOR CONSTRUCTION OF MINIMUM STATE
AUTOMATA
Example - 1

Solution:

We first construct the transition table for the given DFA.

Then we will start constructing equivalence classes.


Example -2 :
MINIMIZATION OF DFA (ALTERNATE
METHOD)
Example -3 : Self Study /Assignment
PUMPING LEMMA FOR REGULAR SETS
PUMPING LEMMA FOR REGULAR SETS
 This is a basic and important theorem used
for checking whether given string is accepted
by regular expression or not.
 Theorem:

 Let L be the regular set. Then there is a

constant n such that if Z is any word in L and


|Z| ≥ n, we can write z= u v w such that |u
v| ≤ n, |v|≥1 for all i≥0, u vi w is in L. The
n should be greater than number of states.
Example -1:
Example -2:
Example -3:

You might also like