Equivalence of NFA and DFA



Finite Automata are basic model in automata theory that are simple because of their finiteness. The finite automata may have in two forms the deterministic and non-deterministic.

Finite Automata are used to recognize patterns and define languages. A critical concept within this domain is the equivalence of two finite automata. It is proven that two types of finite automata perform the same function by accepting the same language.

In this chapter, we will prove their equivalence through an example and show the steps needed to check the equivalency of two automata by an illustrative example.

The Concept of Equivalence

Equivalence between two finite automata means that both automata accept the same language. In other words, for any given input string, both automata either accept or reject it consistently. But there are some conditions when we are going to check equivalence of two automata.

  • State Pair Comparison − For any pair of states, say (qi, qj) from two different automata, the transitions for an input A belonging to the input alphabet Σ must lead to states qA and qB, respectively. If one state in the pair is a final state and the other is not, the automata are not equivalent.
  • Initial and Final State Consistency − If the initial state of one automaton is also a final state, the initial state of the second automaton must also be a final state for them to be equivalent.

Steps to Determine Equivalence

Let us see the steps involved to check whether two finite automata are equivalent or not.

  • Identify State Pairs − Start by pairing the initial states of both automata.
  • Transition Analysis − For each pair, analyze and check the transitions for all inputs in the alphabet Σ.
  • State Comparison − Compare the resultant states from the transitions. Then ensure both resultant states are either final or non-final (intermediate).
  • Repeat for All Pairs − Continue the process for all possible pairs of states.

Checking Equivalence of Finite Automata

Consider two finite automata, A and B, with states and transitions as illustrated below. The inputs for both automata are c and d, respectively.ely.

Consider the first finite automata (A) −

Equivalence of Finite Automata

Consider the second finite automata (B)

Second Finite Automata

Now let us analyse the equivalence in steps −

  • The initial pair is (q1, q4 )
    • For input c, q1 → q1 and q4 → q4, both are final states
    • For input d, q1 → q2 and q4 → q5, both are intermediate states
  • Next pair is (q2, q5 )
    • For input c, q2 → q3 and q5 → q6, both are intermediate states
    • For input d, q2 → q1 and q5 → q4, both are final states
  • Next pair is (q3, q6 )
    • For input c, q3 → q2 and q6 → q7, both are intermediate states
    • For input d, q3 → q3 and q6 → q6, both are intermediate states
  • Next pair is (q2, q7 )
    • For input c, q2 → q3 and q7 → q6, both are intermediate states
    • For input d, q2 → q1 and q7 → q4, both are final states

From the above equivalence, we have compared between two machines A and B. Upon comparing all relevant pairs and their transitions, we find that for each pair, both resultant states are consistently either final or intermediate.

Therefore, based on the given conditions and steps, automata A and B are equivalent, as they meet all criteria for equivalence.

Examples: How to Convert NFA to DFA?

Example 1

Convert the following Non-Deterministic Finite Automata (NFA) to Deterministic Finite Automata (DFA).

Solution

The transition diagram is as follows −

NFA DFA

The transition table of NFA is as follows −

State a b
→q0 q0 q0,q1
q1 - *q2
*q2 - -

The DFA table cannot have multiple states. So, make q0q1 as a single state.

Let's convert the given NFA to DFA by considering two states as a single state.

The transition table of DFA is as follows −

State a b
→ q0 q0 [q0,q1]
[q0q1] [q0] [q0q1q2]
*[q0q1q2] [q0] [q0q1q2]

In the above transition table, q2 is the final state. Wherever, q2 is present that becomes the final state.

NFA DFAS

Example 2

Consider a Non-deterministic finite automata (NFA) and convert that NFA into equivalent Deterministic Finite Automata (DFA).

converting NFA to DFA1

Solution

Let's construct NFA transition table for the given diagram −

States\inputs a b
→q0 {q0,q1} q0
q1 q2 q1
q2 q3 q3
q3 - q2

DFA cannot have multiple states. So, consider {q0,q1} as a single state while constructing DFA.

Let's convert the above table into equivalent DFA

States\inputs a b
→ q1 [q0,q1] q0
[q0,q1] [q0q1q2] [q0q1]
*[q0q1q2] [q0q1q2q3] [q0q1q3]
*[q0q1q2q3] [q0q1q2q3] [q0q1q2q3]
*[q0q1q3] [q0q1q2] [q0q1q2]

In DFA the final states are q2 and q3, wherever q2 and q3 are present that state becomes a final state.

Now the transition diagram for DFA is as follows −

converting NFA to DFA2
  • After conversion the number of states in the final DFA may or may not be the same as in NFA.
  • The maximum number of states present in DFA may be 2pow (number of states in NFA)
  • The relationship between number of states in NFA and DFA is: 1 <= n <= 2m

    Where n = number of states in DFA

    m = number of states in NFA

  • The final DFA all states that contain the final states of NFA are treated as final states.

Conclusion

The equivalence of finite automata is checked through a systematic comparison of their states pair and their transitions. The resultant states for all input pairs are consistently final or intermediate for the checked pairs, if so it will be the case of equivalence. This process is crucial for validating that different automata can recognize the same language.

In this chapter, we explained the steps to check the equivalence between two machines in detail.

Advertisements