Conversion of an Epsilon NFA to a DFA



Read this chapter to learn the process of converting an epsilon NFA (Non-deterministic Finite Automata with epsilon moves) directly into a DFA (Deterministic Finite Automata). We will explain the process step-by-step along with an example to understand the concept better.

Epsilon NFA and DFA: The Basics

Before going into the details of the conversion process, let's briefly review the key differences between epsilon NFAs and DFAs −

  • Epsilon NFA − This allows transitions between states using epsilon moves, which are transitions without consuming any input symbol.
  • DFA − Every state must have exactly one transition defined for each input symbol in the alphabet. DFAs do not allow epsilon moves.

Direct Conversion: Epsilon NFA to DFA

To convert epsilon NFA to DFA, we need to follow two steps process:

  • Convert the epsilon NFA to an NFA (removing epsilon moves).
  • Convert the resulting NFA to a DFA.

However, there is another method to convert epsilon-NFA to DFA directly. We will see that method here.

Step-by-Step Conversion Process: Epsilon NFA to DFA

Let's break down the direct conversion process with a detailed example.

Example Epsilon NFA

Epsilon NFA

Step 1: Finding the Initial State of the DFA

Identify the initial state of the epsilon NFA − In our example, the initial state is q0.

Calculate the epsilon closure of the initial state − The epsilon closure of a state includes all states reachable from that state using only epsilon moves.

  • From q0, we can reach q1 with null (epsilon) move
  • Therefore, the epsilon closure of q0 is {q0, q1}.

The epsilon closure of the initial state becomes the initial state of the DFA.

DFA so far will look like this

Finding the Initial State of the DFA

Step 2: Determining Transitions for Each Input Symbol

For each state in the DFA (starting with the initial state), determine the transitions for each input symbol.

To find the transition for a specific input symbol (e.g., 'a') from a state in the DFA:

  • Consider each state within the DFA state: For example, our current DFA state is {q0, q1}.
  • Determine where you can reach from each of those states in the epsilon NFA using the input symbol:
  • From q0 in the epsilon NFA, using 'a', we can reach: q0, q1 (directly), and q2 (via q1 using epsilon).
  • From q1 in the epsilon NFA, using 'a', we can reach: q2.
  • Take the union of all the states reached: The union for is {Q0, Q1, Q2}.
  • This union becomes the target state in the DFA for the input symbol

After processing 'a' from the initial state, the DFA will look like this

Determining Transitions for Each Input Symbol

Repeat the process for the input symbol 'b' from the initial state {Q0, Q1}

  • From q0, using 'b', we can reach: q1 (using epsilon then 'b').
  • From q1, using 'b', we can reach: q1.
  • The union is {q1}.

After processing 'b' from the initial state, the DFA will look like this

initial state, the DFA

Step 3: Iterating for New States

We now have a new state in our DFA: {Q0, Q1, Q2}.

Repeat Step 2 for this new state and any subsequent new states generated, considering both input symbols 'a' and 'b'.

  • From {Q0, Q1, Q2}, using 'a', we will reach the same set of states {Q0, Q1, Q2}.
  • From {Q0, Q1, Q2}, using 'b', we can reach {Q1, Q2}.

After processing the new state, the DFA will look like this

Iterating for New States

Continue this process until no new states are generated in the DFA.

new states are generated in the DFA

Step 4: Identifying Final States in the DFA

Examine the final states of the epsilon NFA − In our example, the final state is q2.

In the DFA, any state that contains a final state from the epsilon NFA becomes a final state. In our DFA, the final states are: {q0, q1, q2} and {q1, q2}.

The conversion from epsilon NFA to DFA is now complete!

Identifying Final States in the DFA

Conclusion

In this chapter, we explained in detail how to convert an epsilon NFA to DFA. We know the NFA may have multiple states from one state with same input and may have null transitions. But in DFA, there will be no null transitions. We have seen this through an example and learnt how this can be formed in step by step manner.

Advertisements