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 ADFAA_{DFA}, ACFGA_{CFG}, EDFAE_{DFA}, and EQDFAEQ_{DFA} 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.

Key takeaways
  • A language is decidable if some Turing machine decides it: it halts on every input and correctly accepts or rejects.
  • ADFA={⟨B,w⟩:BA_{DFA} = \{\langle B, w\rangle : B is a DFA that accepts string w}w\} is decidable by direct simulation, step by step.
  • ACFGA_{CFG} is decidable by converting the grammar to Chomsky Normal Form and bounding derivation length by 2n−12n-1 for a string of length nn.
  • EDFAE_{DFA} (emptiness) is decidable via reachability search: a DFA accepts nothing iff no accepting state is reachable from the start state.
  • EQDFAEQ_{DFA} (equivalence) reduces to emptiness using the symmetric difference construction: L(A)=L(B)L(A) = L(B) iff L(A)△L(B)=∅L(A) \triangle L(B) = \emptyset.
  • These proofs establish the "decider-building" method later contrasted with the undecidability of ATMA_{TM}, where no such halting simulation exists.
The core insight

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 LL — a set of strings, typically encodings ⟨⋅⟩\langle \cdot \rangle of objects like automata, grammars, or pairs of them. The problem is decidable if there is a Turing machine MM such that for every input ww, MM halts, and MM accepts ww if w∈Lw \in L and rejects ww if w∉Lw \notin L. This is strictly stronger than recognizability (a Turing machine that accepts exactly LL but may loop forever on strings not in LL). 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 BB as a string ⟨B⟩\langle B \rangle 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 ⟨B,w⟩\langle B, w \rangle as input and simulate BB running on ww, because BB'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 ∣w∣|w| steps. The four central languages are:

ADFA={⟨B,w⟩:B is a DFA and B accepts w}A_{DFA} = \{\langle B, w \rangle : B \text{ is a DFA and } B \text{ accepts } w\}
ACFG={⟨G,w⟩:G is a CFG and G generates w}A_{CFG} = \{\langle G, w \rangle : G \text{ is a CFG and } G \text{ generates } w\}
EDFA={⟨A⟩:A is a DFA and L(A)=∅}E_{DFA} = \{\langle A \rangle : A \text{ is a DFA and } L(A) = \emptyset\}
EQDFA={⟨A,B⟩:A,B are DFAs and L(A)=L(B)}EQ_{DFA} = \{\langle A, B \rangle : A, B \text{ are DFAs and } L(A) = L(B)\}

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

ADFAA_{DFA}: decidability by direct simulation. A DFA processes one input symbol per transition and has no way to loop — it reads ww once, left to right, and after exactly ∣w∣|w| transitions it is in some single state. So a decider for ADFAA_{DFA} 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 ∣w∣|w| times; there is no recursion, no backtracking, and no possibility of nontermination, because δ\delta is a total function on Q×ΣQ \times \Sigma.

ACFGA_{CFG}: decidability by bounded enumeration. A CFG can have infinitely many derivations of a string, and can also loop forever (e.g. rules like S→SSS \to SS), so naive derivation search is not obviously a decider. The fix is to convert GG to Chomsky Normal Form (CNF), in which every rule has the form A→BCA \to BC or A→aA \to a (with a single rule S→εS \to \varepsilon allowed only if ε∈L(G)\varepsilon \in L(G)). In CNF every non-ε\varepsilon 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 n≥1n \ge 1 takes exactly 2n−12n - 1 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 2n−12n-1 is finite (bounded by ∣G′∣2n−1|G'|^{2n-1} choices of rule applications), so the `for` loop is a genuinely finite search, and the whole procedure halts.

EDFAE_{DFA}: 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 QQ 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 ∣Q∣|Q| passes.

EQDFAEQ_{DFA}: decidability by reduction to EDFAE_{DFA}. Rather than comparing AA and BB directly, build the DFA for their symmetric difference:

L(C)=L(A)△L(B)=(L(A)∖L(B))∪(L(B)∖L(A)).L(C) = L(A) \triangle L(B) = (L(A) \setminus L(B)) \cup (L(B) \setminus L(A)).

Regular languages are closed under complement, intersection, and union — each provable by an explicit product-automaton construction — so CC is an explicitly constructible DFA. Crucially, L(A)=L(B)L(A) = L(B) iff L(C)=∅L(C) = \emptyset, 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) ```

Figure
The reduction pipeline: EQ_DFA is decided by building on E_DFA, which is decided by reachability
Input: ⟨A, B⟩ two DFAs Build C : L(C)=L(A)△L(B) product + complement construction Call E_DFA(⟨C⟩) reachability check Mark states from q0 BFS/DFS over δ, finite Q halts after ≤ |Q| rounds Accepting state reachable? yes → reject (L(A)≠L(B)) no → accept (L(A)=L(B)) Every stage is a total, halting procedure — the composition halts too.

Complexity & correctness

ADFAA_{DFA}. Time: O(n)O(n) transition lookups for ∣w∣=n|w| = n (each a O(1)O(1) table lookup assuming a fixed-size alphabet), so the simulation is linear in ∣w∣|w| plus the cost of parsing ⟨B⟩\langle B \rangle, which is O(∣B∣)O(|B|). Space: O(log⁡∣Q∣)O(\log |Q|) to store the current state, or O(∣B∣+∣w∣)O(|B| + |w|) if we count the input tape itself. Correctness is an invariant argument: after processing the first ii symbols of ww, `current` equals δ^(q0,w1⋯wi)\hat\delta(q_0, w_1\cdots w_i), the extended transition function's value — this holds by induction on ii (base case i=0i=0: `current = q0` by definition; inductive step: applying δ\delta once extends the extended-transition-function computation by exactly one symbol). At i=∣w∣i = |w|, `current = \hat\delta(q_0, w)`, and by definition BB accepts ww iff this lies in FF — exactly the decider's accept condition.

ACFGA_{CFG}. Converting to CNF takes polynomial time in ∣G∣|G| (removing ε\varepsilon-rules, unit rules, and useless symbols, each a standard closure-preserving transformation). The dominant cost is enumerating derivations of length 2n−12n - 1: with ∣G′∣|G'| rules, there are at most ∣G′∣2n−1|G'|^{2n-1} candidate derivation sequences, so the algorithm as stated runs in time exponential in nn — 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 O(n2)O(n^2) over O(∣G′∣)O(|G'|) variables, achieving O(n3∣G′∣)O(n^3 |G'|) time — the same decidability result, dramatically faster.) Correctness rests on the CNF invariant: every application of a binary rule A→BCA \to BC increases the number of variables in the sentential form by exactly one (replacing 1 variable with 2), and every terminal rule A→aA \to a converts one variable to one terminal without changing the count. Starting from 1 variable (SS) and ending at nn terminals with 0 variables forces exactly n−1n - 1 binary steps and nn terminal steps, i.e. 2n−12n - 1 steps total — so bounding derivation length to 2n−12n-1 loses no derivations of ww, and the search is exhaustive within that bound.

EDFAE_{DFA}. The marking loop is bounded-degree BFS/DFS over a graph with ∣Q∣|Q| vertices and ∣Q∣⋅∣Σ∣|Q| \cdot |\Sigma| edges, so it runs in O(∣Q∣⋅∣Σ∣)O(|Q| \cdot |\Sigma|) time and O(∣Q∣)O(|Q|) space (a boolean "marked" array) — linear in the size of the automaton. Correctness: by induction on the number of marking rounds, a state qq becomes marked iff there is a path of transitions from q0q_0 to qq, i.e. iff qq is reachable. L(A)≠∅L(A) \ne \emptyset iff some string drives q0q_0 to some accept state, which happens iff some accept state is reachable — exactly the marked-set test.

EQDFAEQ_{DFA}. The product construction for CC has at most ∣QA∣⋅∣QB∣|Q_A| \cdot |Q_B| states (times a constant factor for tracking symmetric difference via complement), so CC is polynomial in ∣A∣|A| and ∣B∣|B|, and the subsequent call to the EDFAE_{DFA} decider is linear in ∣C∣|C| — overall polynomial time. Correctness follows from set identities: L(A)=L(B)L(A) = L(B) iff their symmetric difference is empty, a basic fact of set theory, combined with the closure-property guarantee that CC as constructed truly recognizes L(A)△L(B)L(A) \triangle L(B) (provable itself by an invariant on the product automaton's states tracking membership in AA and BB 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 EQDFAEQ_{DFA} on two small DFAs over Σ={0,1}\Sigma = \{0,1\}.

  • AA: accepts strings with an even number of 1s. States {a0,a1}\{a_0, a_1\}, start a0a_0, accept {a0}\{a_0\}.

δA(a0,0)=a0, δA(a0,1)=a1, δA(a1,0)=a1, δA(a1,1)=a0\delta_A(a_0,0)=a_0,\ \delta_A(a_0,1)=a_1,\ \delta_A(a_1,0)=a_1,\ \delta_A(a_1,1)=a_0.

  • BB: accepts strings whose length is even. States {b0,b1}\{b_0,b_1\}, start b0b_0, accept {b0}\{b_0\}.

δB(b0,0)=b1, δB(b0,1)=b1, δB(b1,0)=b0, δB(b1,1)=b0\delta_B(b_0,0)=b_1,\ \delta_B(b_0,1)=b_1,\ \delta_B(b_1,0)=b_0,\ \delta_B(b_1,1)=b_0. These are not equivalent (e.g., "00" has zero 1s — even — length 2 — even, both accept; but "01" has one 1 — odd, AA rejects — length 2 — even, BB accepts). Let's see the decider catch this.

Step 1 — build CC with states (ai,bj)(a_i, b_j), accepting iff exactly one of A,BA, B accepts (symmetric difference):

State (ai,bj)(a_i,b_j)AA accepts?BB accepts?CC accepts?
(a0,b0)(a_0,b_0)yesyesno
(a0,b1)(a_0,b_1)yesnoyes
(a1,b0)(a_1,b_0)noyesyes
(a1,b1)(a_1,b_1)nonono

Start state of CC: (a0,b0)(a_0, b_0).

Step 2 — transitions of CC (component-wise):

Fromon 0on 1
(a0,b0)(a_0,b_0)(a0,b1)(a_0,b_1)(a1,b1)(a_1,b_1)
(a0,b1)(a_0,b_1)(a0,b0)(a_0,b_0)(a1,b0)(a_1,b_0)
(a1,b0)(a_1,b_0)(a1,b1)(a_1,b_1)(a0,b1)(a_0,b_1)
(a1,b1)(a_1,b_1)(a1,b0)(a_1,b_0)(a0,b0)(a_0,b_0)

Step 3 — run EDFAE_{DFA} on CC (reachability marking): Round 0: mark {(a0,b0)}\{(a_0,b_0)\}. Round 1: from (a0,b0)(a_0,b_0) reach (a0,b1)(a_0,b_1) [on 0] and (a1,b1)(a_1,b_1) [on 1]. Mark both. Marked set: {(a0,b0),(a0,b1),(a1,b1)}\{(a_0,b_0), (a_0,b_1), (a_1,b_1)\}. Round 2: from (a0,b1)(a_0,b_1) reach (a0,b0)(a_0,b_0) [old] and (a1,b0)(a_1,b_0) [new — mark it]. From (a1,b1)(a_1,b_1) reach (a1,b0)(a_1,b_0) [same, already about to be marked] and (a0,b0)(a_0,b_0) [old]. Marked set now: all four states. Round 3: no new states — stop.

Step 4 — check accept states. (a0,b1)(a_0,b_1) and (a1,b0)(a_1,b_0) are both marked (reachable) and both are accepting states of CC.

Result: MEDFAM_{EDFA} rejects ⟨C⟩\langle C \rangle (nonempty language reachable) ⇒\Rightarrow MEQDFAM_{EQDFA} rejects ⟨A,B⟩\langle A, B \rangle, correctly reporting L(A)≠L(B)L(A) \ne L(B). Indeed the string "01" drives CC from (a0,b0)→(a0,b1)→(a1,b0)(a_0,b_0) \to (a_0,b_1) \to (a_1,b_0), landing in an accepting state of CC — confirming the witness found earlier by hand.

Common pitfalls & traps

PitfallWhy it's wrongFix
Confusing "recognizer" with "decider"A Turing machine that only accepts (loops on rejection) is not a decider — no halting guaranteeRequire explicit reject branches / halting on every input, as in every pseudocode above
Skipping CNF conversion for ACFGA_{CFG}Without CNF, derivation length is unbounded (rules like A→AA \to A or ε\varepsilon-chains can loop)Always normalize to CNF first — this is what makes the 2n−12n-1 bound valid
Testing string equality of DFA descriptions instead of language equalityTwo DFAs can have different state counts / structure yet accept the same languageUse EQDFAEQ_{DFA}'s symmetric-difference-then-emptiness reduction, never syntactic comparison
Forgetting the empty string case in ACFGA_{CFG}The 2n−12n-1 derivation-length formula assumes n≥1n \ge 1; n=0n=0 needs the special S→εS \to \varepsilon checkBranch explicitly on ∣w∣=0|w| = 0 before the bounded search
Assuming this reachability/simulation trick generalizes to Turing machinesA Turing machine can loop forever instead of halting, so "just simulate it" is not a deciderThis is exactly why ATMA_{TM} is undecidable — simulation alone cannot bound runtime

Pioneers & history

Origins · 1 minMichael O. Rabin and how this was discovered
MO
Michael O. Rabin
1931– · Israeli-American computer scientist, co-inventor of the nondeterministic finite automaton model and pioneer of automata-theoretic decidability results

DS
Dana Scott
1932– · American logician and computer scientist, co-developer with Rabin of the finite automata framework (1959) underlying modern decidability proofs for regular languages

History
1936
— Turing and Church independently formalize computability, giving the first precise definition of "decidable."
1943
— McCulloch and Pitts introduce finite-state models of neural computation, forerunners of the DFA.
1956
— Kleene's theorem connects regular expressions to finite automata, cementing closure properties used in EQDFAEQ_{DFA}.
1959
— Rabin and Scott formalize nondeterministic finite automata and prove the subset construction, receiving the 1976 Turing Award.
1965–1970
s — Chomsky Normal Form and the CYK algorithm turn brute-force ACFGA_{CFG} search into a practical polynomial-time procedure.

Where this matters

Compiler front-ends rely on ACFGA_{CFG}-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 EQDFAEQ_{DFA}-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 EDFAE_{DFA} 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 EDFAE_{DFA} 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 ADFAA_{DFA} runs in time proportional to ∣w∣|w| regardless of how many states the DFA has (each transition lookup is O(1)O(1) 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 ⟨B⟩\langle B \rangle. 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 A→AA \to A 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, ε\varepsilon-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 2n−12n-1 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 L(A)△L(B)L(A) \triangle L(B) 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 (ACFGA_{CFG}) 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 ∣w∣|w| 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 MM on ww 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 ATMA_{TM}, 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. EDFAE_{DFA} is linear-time graph reachability (O(∣Q∣∣Σ∣)O(|Q||\Sigma|)), a completely standard, fast computation. EQDFAEQ_{DFA}'s bottleneck is the product construction, which can blow up to ∣QA∣×∣QB∣|Q_A| \times |Q_B| 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 ACFGA_{CFG} 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 ATMA_{TM} — "does Turing machine MM accept input ww?" — is the direct, structural analog of ADFAA_{DFA} one level up the Chomsky hierarchy, and the proof technique used for ADFAA_{DFA} (simulate and see what state you end in) is the first thing a student naturally tries for ATMA_{TM}. 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.

Before this

Where this leads