Hello! Welcome back to your course on the Theory of Computation.
In our last lesson, we saw how to construct the unique minimal DFA for any regular language. We concluded by noting that this powerful tool gives us an elegant way to test if two different DFAs are equivalent: simply minimize both and check if the results are structurally identical. This is a perfect entry point into today's topic.
Today, we generalize this idea to explore several fundamental "decision problems" for regular languages. A decision problem is a question about a formal language that can be answered with a simple "yes" or "no". Our goal for this lesson is to:
Formulate and solve decision problems for regular languages, including membership, emptiness, finiteness, and equivalence.
We will define algorithms, or decision procedures, that can automatically answer these questions for any regular language presented as a DFA, NFA, or regular expression. You'll find that the concepts of simulation, graph traversal, and closure properties, which we've covered previously, are the key building blocks for these procedures.
1. What is a Decision Problem?
Before diving into specific problems, let's clarify what we mean by a decision procedure. In your work as an engineer, you design functions or APIs that take inputs and produce outputs. A decision procedure is an algorithm that takes a formal object (like a DFA) as input and returns a boolean true or false. Crucially, the algorithm must be guaranteed to terminate for any valid input.
Decision Problems for Regular Languages
This brief text introduces the concept of decision procedures and highlights the essential requirement of guaranteed termination.
Please read the short introductory section titled '1. Decision procedures'. It sets the stage for the algorithms we'll be discussing.
A key idea in computability theory is to frame these problems as languages. For example, the "acceptance problem" for DFAs can be thought of as the language , which contains all strings that encode a (DFA, input string) pair where the DFA accepts the string. An algorithm decides this language if it can determine membership in it for any given string.
2. The Membership Problem: Is ?
This is the most fundamental question: given a language and a string , is a member of ?
If L is represented by a DFA:
The algorithm is straightforward: simulate the DFA on the input string . If the DFA ends in an accepting state, the answer is "yes"; otherwise, it's "no". Since a DFA processes one character at a time and halts after reading the entire string, this procedure is guaranteed to terminate.
If L is represented by an NFA or a Regular Expression:
We can solve this by leveraging our previous work. The procedure is:
- Convert the regular expression or NFA into an equivalent DFA (using Thompson's construction and subset construction).
- Run the membership algorithm for DFAs on the resulting machine.
This process of reducing a problem about one representation (like an NFA) to a problem we already know how to solve for another (a DFA) is a powerful and recurring theme in computer science.
7. Decision Problems for Automata and Grammars
The following video from MIT OpenCourseWare provides a clear, high-level description of an algorithm (framed as a Turing Machine) that decides the membership problem for both DFAs and NFAs.
Watch the segments on the acceptance problem for DFAs (timestamp 07:29 - 16:44) and NFAs (16:44 - 24:07). Notice how the NFA problem is solved by converting it to a DFA and reusing the DFA decider, which is presented as a 'subroutine'.
3. The Emptiness Problem: Is ?
This problem asks whether a given regular language contains any strings at all.
If L is represented by a DFA:
A DFA's language is empty if and only if there is no path from the start state to any final state. This reduces the problem to a graph reachability analysis.
The algorithm is as follows:
- Treat the DFA as a directed graph where states are nodes and transitions are edges.
- Start at the initial state and perform a graph traversal (like Breadth-First Search or Depth-First Search) to find all reachable states.
- Check if the set of reachable states has any intersection with the set of final states.
- If the intersection is empty, the language is empty ("yes"). Otherwise, the language is not empty ("no").
This algorithm is guaranteed to terminate because the number of states is finite.
For a formal proof of decidability and a more detailed look at this algorithm, please review the following notes.
Read the sections 'Emptiness Problem for DFAs' and 'Proof that EDFA is Decidable'. Note how the proof formalizes the graph traversal idea.
4. The Finiteness Problem: Is finite?
This problem asks if a language contains a finite or infinite number of strings.
If L is represented by a DFA:
The key insight here connects to the Pumping Lemma. A regular language is infinite if and only if its minimal DFA contains a cycle that is:
- Reachable from the start state.
- Can reach a final state.
If such a cycle exists, we can traverse it repeatedly to "pump" the string and generate an infinite sequence of accepted strings of increasing length. If no such cycle exists, all paths from the start state to a final state are of limited length, and therefore the language is finite.
The algorithm to decide finiteness is:
- Remove all states from which a final state is not reachable.
- Remove all states that are not reachable from the start state.
- In the remaining graph, check for the presence of a cycle (e.g., using DFS and tracking visited nodes on the current recursion stack).
- If a cycle is found, the language is infinite ("no"). If no cycles are found, the language is finite ("yes").
Test your understanding!
Consider a DFA where the start state q0 can reach a cycle involving states q1 and q2. However, no final state is reachable from q1 or q2. Is the language accepted by this DFA finite or infinite?
Show answer
The language is finite. Even though there is a reachable cycle, no string generated by traversing that cycle can ever be accepted because no final state can be reached from it. The algorithm for finiteness would first remove states q1 and q2 (and any others in the cycle) because they cannot reach a final state. The cycle would thus be eliminated before the cycle-detection step.
5. The Equivalence Problem: Is ?
This problem asks if two regular languages are the same. As we discussed, you already know one way to solve this if you have two DFAs, and :
- Generate the unique minimal DFAs, and .
- Check if and are isomorphic (i.e., identical up to relabeling of states). If they are, the languages are equivalent.
There is another powerful method that relies on closure properties and the emptiness problem.
The Symmetric Difference Method:
Two sets are equal if and only if their symmetric difference is empty. The symmetric difference between and is the set of strings that are in one language but not the other:
We know regular languages are closed under complement, intersection, and union. This means we can construct a DFA, , that accepts .
The algorithm is:
- Given DFAs and , use the construction algorithms for complement, intersection, and union to build a new DFA, , for the symmetric difference language.
- Run the decision procedure for the emptiness problem on .
- If is empty, then ("yes"). Otherwise, they are not equivalent ("no").
This method beautifully combines several different tools we have developed.
7. Decision Problems for Automata and Grammars
The same MIT lecture from earlier also provides an excellent explanation of this symmetric difference method for testing equivalence.
Watch the section on the equivalence problem for DFAs (timestamp 30:41 - 37:40). The speaker explains the logic behind constructing the symmetric difference machine and then using the emptiness test.
Summary of Decidability
For regular languages, all the fundamental decision problems we've discussed are decidable. This is a powerful property that makes them well-behaved and useful in practice (e.g., in compilers, text editors, and network protocols).
The table below summarizes the decidability status of these problems for regular languages and other language classes we will study later. For now, focus on the "Regular" column, which confirms everything we learned today.

Conclusion
In this lesson, you learned how to formulate and solve the four major decision problems for regular languages. These are not just theoretical exercises; they represent the kinds of automated checks that give programming languages and other computer systems their reliability.
Key Takeaways:
- A decision problem is a yes/no question about a formal object, and a decision procedure is a terminating algorithm that answers it.
- Membership is solved by simulating the automaton or converting to a DFA first.
- Emptiness and Finiteness are solved by treating the DFA as a graph and checking for reachability and cycles.
- Equivalence can be solved either by comparing minimal DFAs or by constructing a DFA for the symmetric difference and testing for emptiness.
- All of these key problems are decidable for regular languages.
Preview of the Next Lesson:
We have now thoroughly explored the world of regular languages, their machine models, and their properties. We have also seen their limits via the Pumping Lemma. In the next module, we will move up the Chomsky Hierarchy to a more expressive class of languages: Context-Free Languages, which are generated by Context-Free Grammars (CFGs). We will start by defining CFGs and see how they can describe languages that finite automata cannot, such as the balanced parentheses you might encounter in programming language syntax. We will also revisit these decision problems and see that some of them become much harder—or even undecidable—for this new class of languages.