1 of 26

Session 8: �Equivalence of finite Automaton and regular expressions

By

Dr. Ashok Kumar

Amity School of Engineering & Technology

2 of 26

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

3 of 26

  • Thompson’s Construction Technique

RE to FA Conversion

a

Φ

λ

a

RE

NFA

Amity School of Engineering & Technology

4 of 26

  • Case 1 : Construction of L1 + L2     (Union)

  • Case 2 : Construction of L1L2     

                                    (Concatenation)

  • Case 3 : Construction of L1*       (Star closure)

RE to FA Conversion

Amity School of Engineering & Technology

5 of 26

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

6 of 26

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

7 of 26

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

8 of 26

RE to FA Conversion – More Example

1*0 + 0

(0+1)*

0*1*

(01)*(10)*+00*

Amity School of Engineering & Technology

9 of 26

Amity School of Engineering & Technology

10 of 26

Amity School of Engineering & Technology

11 of 26

Amity School of Engineering & Technology

12 of 26

Amity School of Engineering & Technology

13 of 26

Methods for Conversion

  • Conversion using Arden’s Theorem

  • Conversion using State Elimination Method

Amity School of Engineering & Technology

14 of 26

Arden’s Theorem:

  • Let P and Q be two regular expressions over ∑. If P does not contain λ, then the following equation in R,

R = Q + RP

has a unique solution given by

R = QP*

Amity School of Engineering & Technology

15 of 26

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-

    • Write a regular expression for each final state separately.
    • Add all the regular expressions to get the final regular expression.

Amity School of Engineering & Technology

16 of 26

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

17 of 26

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

18 of 26

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

19 of 26

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

20 of 26

Example 4

Amity School of Engineering & Technology

21 of 26

Example 5

Amity School of Engineering & Technology

22 of 26

Example 5…

Amity School of Engineering & Technology

23 of 26

Example 6

Amity School of Engineering & Technology

24 of 26

Example 7

Amity School of Engineering & Technology

25 of 26

Example 7…

Amity School of Engineering & Technology

26 of 26

SUMMARY

  • Regular Expressions represent the Regular Languages.
  • RE can be converted to Finite Automata using  Thomson’s Method
  • FA can be converted to RE using Arden’s Method

Amity School of Engineering & Technology