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

Module 2 Part 1

The document discusses regular expressions and how to convert them to finite automata. It defines regular expressions recursively and provides examples. It also explains the subset construction method to convert regular expressions to non-deterministic finite automata (NFAs) and then to deterministic finite automata (DFAs). The document further explains Arden's theorem which can be used to obtain a regular expression corresponding to a given finite automaton.

Uploaded by

suju ki vines
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Module 2 Part 1

The document discusses regular expressions and how to convert them to finite automata. It defines regular expressions recursively and provides examples. It also explains the subset construction method to convert regular expressions to non-deterministic finite automata (NFAs) and then to deterministic finite automata (DFAs). The document further explains Arden's theorem which can be used to obtain a regular expression corresponding to a given finite automaton.

Uploaded by

suju ki vines
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

BRAINWARE UNIVERSITY

[PCC-CSM404] [Formal Language and Automata Theory]

Regular Expressions

A Regular Expression can be recursively defined as follows −


• ε is a Regular Expression indicates the language containing an empty string. (L (ε) = {ε})
• φ is a Regular Expression denoting an empty language. (L (φ) = { })
• x is a Regular Expression where L = {x}
• If X is a Regular Expression denoting the language L(X) and Y is a Regular Expression
denoting the language L(Y), then
o X + Y is a Regular Expression corresponding to the language L(X) ∪
L(Y) where L(X+Y) = L(X) ∪ L(Y).
o X . Y is a Regular Expression corresponding to the language L(X) .
L(Y) where L(X.Y) = L(X) . L(Y)
o R* is a Regular Expression corresponding to the language L(R*)where L(R*) =
(L(R))*
• If we apply any of the rules several times from 1 to 5, they are Regular Expressions.
Some RE Examples

Regular Expressions Regular Set

(0 + 10*) L = { 0, 1, 10, 100, 1000, 10000, … }

(0*10*) L = {1, 01, 10, 010, 0010, …}

(0 + ε)(1 + ε) L = {ε, 0, 1, 01}

(a+b)* Set of strings of a’s and b’s of any length including the null string. So L
= { ε, a, b, aa , ab , bb , ba, aaa…….}

(a+b)*abb Set of strings of a’s and b’s ending with the string abb. So L = {abb,
aabb, babb, aaabb, ababb, …………..}

(11)* Set consisting of even number of 1’s including empty string, So L= {ε,
11, 1111, 111111, ……….}

(aa)*(bb)*b Set of strings consisting of even number of a’s followed by odd number

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

of b’s , so L = {b, aab, aabbb, aabbbbb, aaaab, aaaabbb, …………..}

(aa + ab + ba + bb)* String of a’s and b’s of even length can be obtained by concatenating
any combination of the strings aa, ab, ba and bb including null, so L =
{aa, ab, ba, bb, aaab, aaba, …………..}

Conversion of RE to FA
To convert the RE to FA, we are going to use a method called the subset method. This method is
used to obtain FA from the given regular expression. This method is given below:
Step 1: Design a transition diagram for given regular expression, using NFA with ε moves.
Step 2: Convert this NFA with ε to NFA without ε.
Step 3: Convert the obtained NFA to equivalent DFA.

Example 1:
Design a FA from given regular expression 10 + (0 + 11)0* 1.
Solution: First we will construct the transition diagram for a given regular expression.
Step 1:

Step 2:

Step 3:

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

Step 4:

Step 5:

Now we have got NFA without ε. Now we will convert it into required DFA for that, we will
first write a transition table for this NFA.
State 0 1

→q0 q3 {q1, q2}

q1 qf ϕ

q2 ϕ q3

q3 q3 qf

*qf ϕ ϕ
The equivalent DFA will be:
State 0 1

→[q0] [q3] [q1, q2]

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

[q1] [qf] ϕ

[q2] ϕ [q3]

[q3] [q3] [qf]

[q1, q2] [qf] [qf]

*[qf] ϕ ϕ
Example 2:
Design a NFA from given regular expression 1 (1* 01* 01*)*.
Solution: The NFA for the given regular expression is as follows:
Step 1:

Step 2:

Step 3:

Example 3:
Construct the FA for regular expression 0*1 + 10.
Solution:
We will first construct FA for R = 0*1 + 10 as follows:
Step 1:

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

Step 2:

Step 3:

Step 4:

Arden's Theorem

In order to find out a regular expression of a Finite Automaton, we use Arden’s Theorem along
with the properties of regular expressions.
Statement −
Let P and Q be two regular expressions.

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

If P does not contain null string, then R = Q + RP has a unique solution that is R = QP*
Proof −
R = Q + (Q + RP)P [After putting the value R = Q + RP]
= Q + QP + RPP
When we put the value of R recursively again and again, we get the following equation
R = Q + QP + QP2 + QP3…..
R = Q (ε + P + P2 + P3 + …. )
R = QP* [As P* represents (ε + P + P2 + P3 + ….) ]
Hence, proved.

Assumptions for Applying Arden’s Theorem


• The transition diagram must not have NULL transitions
• It must have only one initial state
Method
Step 1 − Create equations as the following form for all the states of the DFA having n states
with initial state q1.
q1 = q1R11 + q2R21 + … + qnRn1 + ε
q2 = q1R12 + q2R22 + … + qnRn2
…………………………
…………………………
…………………………
…………………………
qn = q1R1n + q2R2n + … + qnRnn
Rij represents the set of labels of edges from qi to qj, if no such edge exists, then Rij = ∅
Step 2 − Solve these equations to get the equation for the final state in terms of Rij
Problem
Construct a regular expression corresponding to the automata given below −

Solution −
Here the initial state and final state is q1.
The equations for the three states q1, q2, and q3 are as follows −
q1 = q1a + q3a + ε (ε move is because q1 is the initial state0
q2 = q1b + q2b + q3b
q3 = q2a
Now, we will solve these three equations −

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)


BRAINWARE UNIVERSITY
[PCC-CSM404] [Formal Language and Automata Theory]

q2 = q1b + q2b + q3b


= q1b + q2b + (q2a)b (Substituting value of q3)
= q1b + q2(b + ab)
= q1b (b + ab)* (Applying Arden’s Theorem)
q1 = q1a + q3a + ε
= q1a + q2aa + ε (Substituting value of q3)
= q1a + q1b(b + ab*)aa + ε (Substituting value of q2)
= q1(a + b(b + ab)*aa) + ε
= ε (a+ b(b + ab)*aa)*
= (a + b(b + ab)*aa)*
Hence, the regular expression is (a + b(b + ab)*aa)*.
Problem
Construct a regular expression corresponding to the automata given below −

Solution −
Here the initial state is q1 and the final state is q2
Now we write down the equations −
q1 = q10 + ε
q2 = q11 + q20
q3 = q21 + q30 + q31
Now, we will solve these three equations −
q1 = ε0* [As, εR = R]
So, q1 = 0*
q2 = 0*1 + q20
So, q2 = 0*1(0)* [By Arden’s theorem]
Hence, the regular expression is 0*10*.

2023-24 Even Prepared by: (Department of CSE, Brainware University, Barasat)

You might also like