Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 11

DFA-NFA Equivalence

Recommended resources

Hello! Welcome back to your course on the Theory of Computation.

In our last lesson, you learned the "how": you mastered the subset construction algorithm to convert any NFA into an equivalent DFA. We saw this as a practical, algorithmic way to eliminate nondeterminism. Today, we move from the "how" to the "why." We will formalize this relationship and use it to achieve today's learning outcome: to prove that DFAs and NFAs are equivalent in their language-recognizing power.

This is a foundational result in computer science. It tells us that while NFAs offer greater design flexibility, they do not possess any more fundamental computational power than their deterministic counterparts. The set of languages they both recognize is the same, and we call this set the regular languages.

Proving this equivalence requires showing two things:

  1. Any language accepted by a DFA can also be accepted by an NFA.
  2. Any language accepted by an NFA can also be accepted by a DFA.

Let's tackle each direction of this proof.

1. From DFA to NFA: The Easy Direction

Let's start with the more straightforward part of the proof: showing that for any given DFA, there's an NFA that accepts the same language.

Intuitively, this makes sense because a DFA is essentially a very restricted type of NFA. It's an NFA that happens to have:

  • No -transitions.
  • Exactly one outgoing transition from every state for each symbol in the alphabet.

To formalize this, we just need to show how to represent a DFA's components in the NFA's format. The key difference lies in the transition function.

  • A DFA's transition function, , maps a state and a symbol to a single state: .
  • An NFA's transition function, , maps a state and a symbol to a set of states: .

The following video explains this relationship clearly.

Conversion of NFA to DFA

This brief segment from Neso Academy explains why every DFA can be considered an NFA by comparing their formal definitions, particularly their transition functions.

Watch from 00:19 to 02:57. Focus on how the DFA's transition function is a special case of the NFA's transition function.

To complete the formal conversion, we can construct an NFA from a DFA as follows:

  • For every state and symbol , if , we define .
  • For any state , .

Since the constructed NFA perfectly mimics the single path of the DFA for any input string, it accepts the exact same language. This completes the first part of our proof.


2. From NFA to DFA: The Subset Construction Revisited

Now for the more involved direction: proving that for any NFA, there's a DFA that accepts the same language. In the previous lesson, you learned the algorithm for this: the subset construction. Now, we will use it as the basis for our formal proof.

The core insight, as you know, is to create a DFA whose states correspond to sets of the NFA's states. This allows the DFA to deterministically track all parallel computations occurring in the NFA.

Let's watch a concise, high-level explanation of this idea, which will serve as a great warm-up for the formal proof.

2. Nondeterminism, Closure Properties, Conversion of Regular Expressions to FA

This lecture from MIT OpenCourseWare provides a crisp explanation of the subset construction. The lecturer explains how the DFA simulates the NFA by keeping track of the set of possible current states.

Watch from 27:01 to 34:48. Pay attention to the formal definition of the DFA's states (the power set), its transition function, and the brief discussion on the potential exponential growth in the number of states.

The Formal Construction and Proof of Correctness

The video laid out the construction. Now, let's dive into the formal proof that this construction is correct. This is where your appreciation for mathematical rigor will be valuable. We will prove that the language of the constructed DFA is identical to the language of the original NFA.

The following resource provides a concise but complete proof. We will walk through its logic step by step.

Equivalence of DFA and NFA

These lecture notes provide the formal definition of the subset construction and a clear, inductive proof of its correctness. We will focus on these sections to formally establish the equivalence.

First, read the 'Formal Construction' on page 16. This formally defines the 5-tuple of the equivalent DFA, which we'll call det(N). Then, carefully read the 'Correctness Proof' on pages 17-19. This is the heart of the lesson.

Let's break down the proof from the notes.

The proof uses induction on the length of the input string . This is a natural strategy because the machine's operation is defined step-by-step, symbol by symbol.

Let our NFA be and our constructed DFA be .

  • Let denote the state the DFA is in after reading string .
  • Let denote the set of states the NFA can be in after reading string . (The notes use for the NFA's extended transition to avoid confusion with the DFA's ).

The core claim we want to prove is:

This claim states that the single state our DFA reaches after reading is exactly the set of all possible states the NFA could have reached. If we prove this, the equivalence of the languages follows directly.

1. Base Case:

  • Here, .
  • For the DFA, by definition. By construction, (which is the -closure of the NFA's start state).
  • For the NFA, the set of states it can reach from on is, by definition, .
  • So, the statement holds for .

2. Inductive Step

  • Inductive Hypothesis (I.H.): Assume the claim holds for all strings of length . That is, .
  • Goal: We must show it holds for any string of length , where .
  • Let's analyze the DFA's state after reading :
  • Using our I.H., we can substitute for :
  • Now, we use the definition of our constructed transition function :
  • This final expression is precisely the definition of —the set of all states reachable from the start by reading and then .
  • Thus, . The claim holds for strings of length .

By induction, the claim is true for all strings .

Why does this prove language equivalence?
A string is accepted by the DFA if . By our construction, a state if and only if .
Since we just proved , the DFA accepts if and only if . This is the exact condition for the NFA to accept .

Therefore, .

Test your understanding!

In the subset construction, the states of the new DFA are subsets of the original NFA's states. If an NFA has states, the equivalent DFA could have up to states.

Why is this exponential relationship not a contradiction to the equivalence of their power? In other words, why does the number of states not affect what languages they can recognize, even if it explodes?

Show answer

The equivalence in "power" refers to the class of languages they can recognize, not their efficiency in terms of space (number of states) or time. The proof shows that for any NFA, no matter how many states it has, a DFA exists that recognizes the same language. The crucial point is that this DFA still has a finite number of states (since is finite if is finite). As long as the resulting machine is a valid finite automaton, the languages are both in the same class: the regular languages. The practical cost (an exponential number of states) is an efficiency trade-off, not a change in fundamental computability.


Conclusion: The Power of Equivalence

Today, you have formally proven one of the most important theorems in the first part of this course. By showing a constructive path from any DFA to an NFA and, more significantly, from any NFA back to a DFA, you have established that these two models of computation are equivalent in power.

Key Takeaways:

  • Equivalence is a Two-Way Street: To prove two models are equivalent, you must show that each can simulate the other.
  • DFA NFA: This direction is straightforward. A DFA is just a specialized NFA where each transition leads to a singleton set and there are no -moves.
  • NFA DFA: This direction is proven using the subset construction. The proof relies on induction on the input string's length to show that the DFA state after reading a string is identical to the set of possible states the NFA could be in.
  • The Class of Regular Languages: This equivalence establishes that the set of languages recognized by DFAs is the same as that recognized by NFAs. This robust and well-defined class of languages is known as the regular languages.

Preview of the Next Lesson:
We've proven DFAs and NFAs are equivalent in what they can do, but this says nothing about their practical differences. In the next lesson, we will compare the trade-offs between DFAs and NFAs. We'll discuss when to use one over the other, focusing on the trade-off between the number of states (space complexity) and the ease of design and combination.