DFA to Regular Expression State Elimination Method

For Complete YouTube Video: Click Here

In this class, We discuss DFA to Regular Expression State Elimination Method.

The reader should have prior knowledge of regular expressions. Click Here.

We follow the steps for the state elimination method.

Step 1:

If there exists any incoming edge to the initial state, add a new initial state.

Example:

The below diagram has an incoming edge to the initial state.

DFA to Regular Expression State Elimination Method 1.1
E1

Add a new state qi and move to state q0 using epsilon moves. Make qi as the initial state.

The below diagram shows the final diagram after adding a new initial state.

DFA to Regular Expression State Elimination Method 1.2
E2

Step 2:

if there exists an outgoing edge to the final state, then create a new final state.

Example:

The below diagram has an outgoing edge to the final state.

DFA to Regular Expression State Elimination Method 2.1
E3

We add a new final state qf, and make q2 as the non-final state.

From state q2, we move to qf using epsilon moves.

The below diagram shows the final diagram after adding a new final state.

DFA to Regular Expression State Elimination Method 2.2
E4

Step 3:

if there exist multiple non-final states, make them non-final and create a new final state.

The below diagram has two final states q2 and q3.

DFA to Regular Expression State Elimination Method 3.1
E4

We change q2 and q3 as non-final states and add a new final state qf.

The states q2 and q3 are joined to qf using epsilon moves.

The below diagram shows the modifications.

DFA to Regular Expression State Elimination Method 3.2
E5

We understand a few examples.

Example 1:

DFA to Regular Expression State Elimination Method 4.1
E6

The regular expression for the DFA is a*.

Example 2:

DFA to Regular Expression State Elimination Method 4.2
E7

The regular expression for the DFA is (a + b)*

We take a or b. We stay on state q0, and we can repeat any number of times.

Example 3:

DFA to Regular Expression State Elimination Method 4.3
E8

The regular expression for the DFA is aa.

Example 4:

DFA to Regular Expression State Elimination Method 4.4
E9

The regular expression for the DFA is (a + b)

Example 5:

DFA to Regular Expression State Elimination Method 4.5
E10

The regular expression for the DFA is (ab)*. We form a cycle with ab.

Now we take an example and find the regular expression using the state elimination method.

The below diagram is our DFA.

DFA to Regular Expression State Elimination Method 5.1
Example

For the DFA, we need to add a new initial state and final state because the initial state has an incoming edge. And the final state has an outgoing edge.

The below diagram shows the final automata after adding the initial and final state.

DFA to Regular Expression State Elimination Method 5.2
After adding Initial and Final states

Now we need to eliminate the states between initial and final states.

We can follow any order. We can eliminate q0 first, then q1 or vice versa.

Any order of elimination will give the same output expression.

We eliminate q0 first.

The below diagram shows the Finite automata after eliminating q0.

DFA to Regular Expression State Elimination Method 6.1
After Eliminating q0

From state qi to state q1, we move using the expression b*a.

with input b, we move to state q0, and with a, we move to state q1.

Point to understand: we have input edge from state q1 to q0. after eliminating q0, we need to take care of that edge.

So on q1, we write a self-loop with the expression bb*a.

Now we have to eliminate state q1.

State q1 has two self-loops. So we use or condition.

If we eliminate state q1, we get the expression (a + bb*a)*

The final regular expression between state qi and qf is b*a(a + bb*a)*. Because q0 is having self loop.

DFA to Regular Expression State Elimination Method 6.2
Final DFA after eliminating q0 and q1