Session 8: �Equivalence of finite Automaton and regular expressions
By
Dr. Ashok Kumar
Amity School of Engineering & Technology
Equivalence of Regular Expression & FA
RE
NFA
DFA
Thompson’s Construction Technique
Set construction algorithm to convert NFA to DFA
Arden’s Theorem or
State Elimination Method
Amity School of Engineering & Technology
RE to FA Conversion
a
Φ
λ
a
RE
NFA
Amity School of Engineering & Technology
(Concatenation)
RE to FA Conversion
Amity School of Engineering & Technology
RE to FA Conversion - Example
RE 🡪 01
r1 = 0
r2 = 1
r3 = r1 . r2
q0
q1
0
q2
q3
1
q0
q1
0
q2
q3
1
ε
Amity School of Engineering & Technology
RE to FA Conversion - Example
RE 🡪 01*
r1 = 0
r2 = 1
r3 = r2*
r4 = r1 . r3
q0
q1
0
q2
q3
1
q5
q4
q2
q3
1
ε
ε
ε
ε
q0
q1
0
q5
q4
q2
q3
1
ε
ε
ε
ε
ε
Amity School of Engineering & Technology
RE to FA Conversion - Example
RE 🡪 0 + 1
r1 = 0
r2 = 1
r3 = r1 + r2
q0
q1
0
q2
q3
1
q0
q1
0
q2
q3
1
ε
q4
q5
ε
ε
ε
Amity School of Engineering & Technology
RE to FA Conversion – More Example
1*0 + 0
(0+1)*
0*1*
(01)*(10)*+00*
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Methods for Conversion
Amity School of Engineering & Technology
Arden’s Theorem:
R = Q + RP
has a unique solution given by
R = QP*
Amity School of Engineering & Technology
Construction of FA from RE- Arden’s Theorem
Conditions-
The transition diagram must not have any ∈ transitions.
There must be only a single initial state.
Step-01:
Form equation for each state considering the transitions which comes towards that state.
Add ‘∈’ in the equation of initial state.
Step-02:
Bring final state in the form R = Q + RP to get the required regular expression.
Arden’s Theorem can be used to find a regular expression for both DFA and NFA.
If there exists multiple final states, then-
Amity School of Engineering & Technology
Example : 1
q1
q2
q3
a
a
b
a
b
a
Initial Equations
q1 = q1a + q2b + λ
q2 = q1a + q2b +q3a
q3 = q2a
Substituting the value of q3 in q2
we get:
q2 = q1a + q2b + q2 a a
q2 = q1a + q2(b + aa )
By Arden’s Theorem
R = Q + RP has a solution R = QP*
Therefore
q2 = q1a(b + aa)*
Amity School of Engineering & Technology
Example : 1
q1
q2
q3
a
a
b
a
b
a
Substituting the value of q2 in q1
we get:
q1 = q1a + q1a(b+aa)* b + λ
q1 = q1 (a + a(b+aa)*b) + λ
By Arden’s Theorem
R = Q + RP has a solution R = QP*
Therefore
q1 = λ (a + a(b+aa)*b )*
q1 = (a + a(b+aa)*b )*
Substituting the values
q2 = (a+a(b+aa)*b)*a(b+aa)*
q3 = (a+a(b+aa)*b)*a(b+aa)*a
So the Resultant regular expression that describes the language accepted by the given FA is:
(a+a(b+aa)*b)* a (b+aa)* a
Amity School of Engineering & Technology
Example : 2
q1
q2
q4
q3
b
b
b
a
a
a
a,b
Initial Equations
q1 = q2b + q3a + λ
q2 = q1a
q3 = q1b
q4 = q2a + q3b + q4a + q4b
Since q1 is the only final state and it involves only q2 and q3 in its equation, the equation q4 is redundant for us.
So we will consider only q2 and q3 to solve q1.
q1 = q1ab + q1ba + λ
= q1(ab +ba) + λ
By Arden’s Theorem
q1 = λ (ab + ba)*
So the Resultant Regular Exp is:
(ab + ba)*
Amity School of Engineering & Technology
Example : 3 (Multiple Final States)
q1
q2
q3
0
0
1
1
0,1
Initial Equations
q1 = q10 + λ
q2 = q11 + q21
q3 = q20 + q3(0 + 1)
q1 = λ 0* = 0*
q2 = q1 1 + q2 1
q2 = 0* 1 + q2 1
q2 = (0*1)1*
As the Final States are only q1 and q2, we need not solve for q3
Therefore the Regular Expression will be:
q1 + q2 = 0* + 0*(11*)
= 0* (λ + 11*)
= 0*1* (by theorem)
Amity School of Engineering & Technology
Example 4
Amity School of Engineering & Technology
Example 5
Amity School of Engineering & Technology
Example 5…
Amity School of Engineering & Technology
Example 6
Amity School of Engineering & Technology
Example 7
Amity School of Engineering & Technology
Example 7…
Amity School of Engineering & Technology
SUMMARY
Amity School of Engineering & Technology