Decidable Problems About Automata
Suppose someone hands you a description of a DFA with 10,000 states. They ask: does this machine accept any string at all? Or given two regular expressions scraped from two different codebases, are they secretly equivalent? These are not idle puzzles. They are exactly the questions a compiler's regex engine must answer. A network firewall rule optimizer or a static analysis tool must answer them too, and answer correctly, every time. The remarkable fact is that all of these questions are decidable: there exist Turing machines that always halt and always give the right yes/no answer. This article develops the classical toolkit for proving decidability of problems about finite automata and context-free grammars. The problems are simply stated — membership, emptiness, and equivalence. But the proofs are the real content. Each one builds a new Turing machine out of old decision procedures. They chain together simulation, enumeration, and closure properties of regular and context-free languages. This chaining technique is the single most important transferable skill in computability theory. Why does this matter beyond the classroom? Every time a browser parses HTML against a grammar, someone relies on these results. Every time a linter checks whether two regexes match the same set of strings, the same is true. Every time a model-checker verifies that a finite-state protocol never reaches a bad state, someone is silently relying on the decidability results proved here. These are the good cases — the well-behaved corner of computation where algorithms exist and terminate. That good behavior is precisely what makes this article's closing turn dramatic. The next natural question is simple to ask: "does this Turing machine accept this string?" It turns out to have no such algorithm at all. By the end, you will be able to state and prove decidability of , , , and from first principles. You will use only simulation and closure-property constructions. And you will see exactly where the same strategy breaks down when DFAs are replaced by general Turing machines.
- A language is decidable if some Turing machine decides it: it halts on every input and correctly accepts or rejects.
- is a DFA that accepts string is decidable by direct simulation, step by step.
- is decidable by converting the grammar to Chomsky Normal Form and bounding derivation length by for a string of length .
- (emptiness) is decidable via reachability search: a DFA accepts nothing iff no accepting state is reachable from the start state.
- (equivalence) reduces to emptiness using the symmetric difference construction: iff .
- These proofs establish the "decider-building" method later contrasted with the undecidability of , where no such halting simulation exists.
Every decidability proof in this article follows one pattern: replace a question about an infinite object (all strings, all computations) with a finite, computable check, using simulation, bounded search, or closure constructions to guarantee termination.
The idea
A decision problem is a language — a set of strings, typically encodings of objects like automata, grammars, or pairs of them. The problem is decidable if there is a Turing machine such that for every input , halts, and accepts if and rejects if . This is strictly stronger than recognizability (a Turing machine that accepts exactly but may loop forever on strings not in ). Decidability demands a decider: total correctness plus guaranteed termination on every input, without exception. The problems studied here all concern automata as data. We encode a DFA as a string listing its states, alphabet, transition function, start state, and accept states — a finite, parseable description, exactly the kind of encoding covered when discussing Encodings and Enumerators. A Turing machine can then take as input and simulate running on , because 's entire behavior is captured by a finite table. This is the same simulation idea that underlies the Universal Turing Machine, specialized here to the much tamer setting where the simulated machine is guaranteed to halt after exactly steps. The four central languages are:
Each is proved decidable by a different technique — direct simulation, bounded enumeration, graph reachability, and reduction via a closure-property construction — and together they form the essential proof vocabulary of Computability Theory.
How it works
: decidability by direct simulation. A DFA processes one input symbol per transition and has no way to loop — it reads once, left to right, and after exactly transitions it is in some single state. So a decider for just tracks that state. ``` Decider M_ADFA(⟨B, w⟩): // B = (Q, Σ, δ, q0, F) if ⟨B, w⟩ is not a syntactically valid DFA-string pair: reject current ← q0 for each symbol a in w (left to right): current ← δ(current, a) if current ∈ F: accept else: reject ``` The loop runs exactly times; there is no recursion, no backtracking, and no possibility of nontermination, because is a total function on .
: decidability by bounded enumeration. A CFG can have infinitely many derivations of a string, and can also loop forever (e.g. rules like ), so naive derivation search is not obviously a decider. The fix is to convert to Chomsky Normal Form (CNF), in which every rule has the form or (with a single rule allowed only if ). In CNF every non- rule application either keeps the string of variables the same length while adding one terminal, or replaces one variable with two — so any derivation of a string of length takes exactly steps. This bounds the search space to something finite and checkable. ``` Decider M_ACFG(⟨G, w⟩): if ⟨G, w⟩ is not a syntactically valid CFG-string pair: reject G' ← convert G to Chomsky Normal Form n ← length(w) if n = 0: if S ⇒ ε is a rule of G': accept else reject for each derivation D of length exactly 2n − 1 in G': if D derives w: accept reject ``` The number of candidate derivations of length is finite (bounded by choices of rule applications), so the `for` loop is a genuinely finite search, and the whole procedure halts.
: decidability by reachability. A DFA's language is empty exactly when no accepting state can ever be reached from the start state — a pure graph-reachability question on the transition diagram, solvable by breadth-first or depth-first marking. ``` Decider M_EDFA(⟨A⟩): // A = (Q, Σ, δ, q0, F) mark q0 repeat until no new state gets marked: for each marked state q, each symbol a: mark δ(q, a) if any state in F is marked: reject // language is nonempty else: accept // language is empty ``` The marking loop terminates because is finite: each pass either marks at least one new state or nothing changes, and once nothing changes the process is complete, after at most passes.
: decidability by reduction to . Rather than comparing and directly, build the DFA for their symmetric difference:
Regular languages are closed under complement, intersection, and union — each provable by an explicit product-automaton construction — so is an explicitly constructible DFA. Crucially, iff , which reduces equivalence checking to the emptiness decider already built. ``` Decider M_EQDFA(⟨A, B⟩): construct DFA C such that L(C) = L(A) △ L(B) // C's states are pairs (state of A, state of B) plus one extra // bit for "in a complemented copy"; accept iff exactly one // of A, B accepts along that path run M_EDFA(⟨C⟩) if M_EDFA accepts (L(C) is empty): accept // L(A) = L(B) else: reject // L(A) ≠ L(B) ```
Complexity & correctness
. Time: transition lookups for (each a table lookup assuming a fixed-size alphabet), so the simulation is linear in plus the cost of parsing , which is . Space: to store the current state, or if we count the input tape itself. Correctness is an invariant argument: after processing the first symbols of , `current` equals , the extended transition function's value — this holds by induction on (base case : `current = q0` by definition; inductive step: applying once extends the extended-transition-function computation by exactly one symbol). At , `current = \hat\delta(q_0, w)`, and by definition accepts iff this lies in — exactly the decider's accept condition.
. Converting to CNF takes polynomial time in (removing -rules, unit rules, and useless symbols, each a standard closure-preserving transformation). The dominant cost is enumerating derivations of length : with rules, there are at most candidate derivation sequences, so the algorithm as stated runs in time exponential in — it is a decider, not an efficient one. (In practice, one replaces the brute-force search with the CYK Algorithm, a dynamic-programming table of size over variables, achieving time — the same decidability result, dramatically faster.) Correctness rests on the CNF invariant: every application of a binary rule increases the number of variables in the sentential form by exactly one (replacing 1 variable with 2), and every terminal rule converts one variable to one terminal without changing the count. Starting from 1 variable () and ending at terminals with 0 variables forces exactly binary steps and terminal steps, i.e. steps total — so bounding derivation length to loses no derivations of , and the search is exhaustive within that bound.
. The marking loop is bounded-degree BFS/DFS over a graph with vertices and edges, so it runs in time and space (a boolean "marked" array) — linear in the size of the automaton. Correctness: by induction on the number of marking rounds, a state becomes marked iff there is a path of transitions from to , i.e. iff is reachable. iff some string drives to some accept state, which happens iff some accept state is reachable — exactly the marked-set test.
. The product construction for has at most states (times a constant factor for tracking symmetric difference via complement), so is polynomial in and , and the subsequent call to the decider is linear in — overall polynomial time. Correctness follows from set identities: iff their symmetric difference is empty, a basic fact of set theory, combined with the closure-property guarantee that as constructed truly recognizes (provable itself by an invariant on the product automaton's states tracking membership in and simultaneously). The unifying theme: every decider above is built by composing smaller deciders and constructions that are each individually guaranteed to terminate — simulation of a total function, bounded search over a provably finite space, or graph search over a finite vertex set. There is no step anywhere that risks an unbounded search, which is precisely the property that will fail when Turing machines replace DFAs.
Worked example
Trace on two small DFAs over .
- : accepts strings with an even number of 1s. States , start , accept .
.
- : accepts strings whose length is even. States , start , accept .
. These are not equivalent (e.g., "00" has zero 1s — even — length 2 — even, both accept; but "01" has one 1 — odd, rejects — length 2 — even, accepts). Let's see the decider catch this.
Step 1 — build with states , accepting iff exactly one of accepts (symmetric difference):
| State | accepts? | accepts? | accepts? |
|---|---|---|---|
| yes | yes | no | |
| yes | no | yes | |
| no | yes | yes | |
| no | no | no |
Start state of : .
Step 2 — transitions of (component-wise):
| From | on 0 | on 1 |
|---|---|---|
Step 3 — run on (reachability marking): Round 0: mark . Round 1: from reach [on 0] and [on 1]. Mark both. Marked set: . Round 2: from reach [old] and [new — mark it]. From reach [same, already about to be marked] and [old]. Marked set now: all four states. Round 3: no new states — stop.
Step 4 — check accept states. and are both marked (reachable) and both are accepting states of .
Result: rejects (nonempty language reachable) rejects , correctly reporting . Indeed the string "01" drives from , landing in an accepting state of — confirming the witness found earlier by hand.
Common pitfalls & traps
| Pitfall | Why it's wrong | Fix |
|---|---|---|
| Confusing "recognizer" with "decider" | A Turing machine that only accepts (loops on rejection) is not a decider — no halting guarantee | Require explicit reject branches / halting on every input, as in every pseudocode above |
| Skipping CNF conversion for | Without CNF, derivation length is unbounded (rules like or -chains can loop) | Always normalize to CNF first — this is what makes the bound valid |
| Testing string equality of DFA descriptions instead of language equality | Two DFAs can have different state counts / structure yet accept the same language | Use 's symmetric-difference-then-emptiness reduction, never syntactic comparison |
| Forgetting the empty string case in | The derivation-length formula assumes ; needs the special check | Branch explicitly on before the bounded search |
| Assuming this reachability/simulation trick generalizes to Turing machines | A Turing machine can loop forever instead of halting, so "just simulate it" is not a decider | This is exactly why is undecidable — simulation alone cannot bound runtime |
Pioneers & history
Origins · 1 minMichael O. Rabin and how this was discovered
Where this matters
Compiler front-ends rely on -style parsing every time a source file is checked against a language grammar — parser generators like Yacc and ANTLR are built on exactly the CNF/CYK-style machinery sketched here. Network intrusion detection systems and firewall rule compilers use -style equivalence checking to verify that an optimized rule set behaves identically to the original, unoptimized one, catching bugs before deployment. Static analyzers and linters that reason about regular expressions — flagging a regex that can never match anything — are directly running an emptiness check under the hood after converting the regex to an automaton. Hardware and protocol verification tools (model checkers) that certify a finite-state machine design never enters a forbidden configuration are running reachability analysis identical in spirit to the marking algorithm, just at industrial scale with millions of states. All of these applications depend on the same guarantee proved here: for finite automata and context-free grammars, the questions we actually want to ask are always answerable by an algorithm that halts — a guarantee that, as the next article on The Halting Problem and A_TM shows, spectacularly fails once the automaton is replaced by a general-purpose Turing machine.
Ask the tutor: If regular languages are closed under complement, union, and intersection, why isn't equivalence of two arbitrary context-free grammars decidable by the same symmetric-difference trick?
Is A_DFA decidable if the DFA has a huge number of states, say a million?
Yes — decidability is about the existence of an algorithm that always halts, not about efficiency for a fixed instance size. The simulation decider for runs in time proportional to regardless of how many states the DFA has (each transition lookup is given a reasonable table representation), so a million-state DFA is simulated exactly as reliably as a two-state one, just with a larger constant for parsing the description . Decidability results in this article are worst-case guarantees over all valid inputs, including arbitrarily large automata, which is exactly why they are useful as general theorems rather than one-off tricks.
Why does A_CFG need Chomsky Normal Form specifically, rather than any grammar?
An arbitrary CFG can contain rules like or long chains of unit productions that let a derivation "spin" through variables without ever producing a terminal, making naive derivation-length bounds meaningless — you could search forever without proving nonmembership. CNF eliminates unit rules, -rules (except possibly for the start symbol), and useless symbols, guaranteeing every non-empty derivation makes measurable progress toward terminals at each step. That guarantee — every step is "productive" — is what allows the clean bound and, in turn, a finite, exhaustively searchable derivation space.
Does the equivalence-checking technique for EQ_DFA extend to context-free grammars?
No, and this is a genuinely important boundary. Context-free languages are not closed under complement or intersection in general (only regular languages enjoy all three closure properties needed for the symmetric-difference trick), so the construction that builds a DFA for has no analog for arbitrary CFGs. In fact, equivalence of two context-free grammars is provably undecidable — a striking contrast that shows decidability results do not automatically transfer across a hierarchy of language classes, even when the individual membership problems () are decidable.
What exactly breaks when we replace the DFA in A_DFA with a general Turing machine?
The core issue is termination. A DFA reads its input exactly once, symbol by symbol, so simulating it for steps is guaranteed to finish. A Turing machine can move its head back and forth indefinitely and may never halt on a given input — so "simulate on for however long it takes" is not an algorithm, because "however long it takes" might be infinite. There is no known way to predict in advance, for an arbitrary Turing machine and input, whether the simulation will ever stop; this is precisely the content of the undecidability of , proved by a diagonalization argument rather than any simulation trick.
Are E_DFA and EQ_DFA solved efficiently in practice, or only "in principle"?
Both are solved efficiently in practice for realistic instance sizes. is linear-time graph reachability (), a completely standard, fast computation. 's bottleneck is the product construction, which can blow up to states — polynomial, not exponential, so it remains tractable for automata with thousands of states, which is why regex-equivalence tools and hardware model checkers use variants of this exact algorithm daily. The one place efficiency genuinely suffers in this article is the naive decider, whose brute-force derivation search is exponential; real parsers replace it with the polynomial-time CYK dynamic-programming algorithm instead.
Why does this article foreshadow the Halting Problem specifically, rather than some other undecidable problem?
Because — "does Turing machine accept input ?" — is the direct, structural analog of one level up the Chomsky hierarchy, and the proof technique used for (simulate and see what state you end in) is the first thing a student naturally tries for . Seeing exactly why that technique succeeds for DFAs (bounded, guaranteed-halting simulation) makes it much clearer why it fails for Turing machines (unbounded, not-guaranteed-halting simulation), turning the undecidability proof from a shock into an expected consequence of removing the halting guarantee.