Introduction
Regular expressions and finite automata define the same class of languages. One direction builds an -NFA from an expression (Thompson's construction). The other eliminates states from a DFA (or NFA) until a single regular expression remains. Together with the subset construction, this closes the loop: RE -NFA NFA DFA.
The working tasks are building an NFA from an RE, an RE from a small DFA, and proving a language regular by exhibiting either description.
Prerequisites
- Regular Expressions: syntax and semantics of REs.
- NFA, Epsilon-NFA and Subset Construction: -closure and subset construction.
Core concepts
Theorem
For a language , the following are equivalent:
- for some regular expression .
- for some -NFA .
- for some NFA .
- for some DFA .
Thompson fragments
Thompson's construction builds an -NFA with exactly one start state and one accept state, and with no edges into the start or out of the accept, by composing fragments:
| Construct | Fragment idea |
|---|---|
| Symbol | start accept |
| start accept | |
| start and accept with no path between them | |
| new start -splits to the two starts; both accepts -merge to a new accept | |
| accept of -linked to start of | |
| new start to 's start and to new accept; 's accept back to 's start and to new accept |
The resulting NFA has states. Convert to a DFA by subset construction if needed.
State elimination (Arden / GNFA)
To get an RE from an automaton:
- Convert the DFA/NFA to a GNFA (generalized NFA) whose edge labels are regular expressions: add a new start with to the old start, and from every old accept to a new unique accept; replace missing edges by .
- While more than two states remain, pick a state (not the new start or accept) and eliminate it: for every pair of states with edges and loop , replace the label by .
- When only start and accept remain, the label on is the RE.
Arden's lemma is the algebraic twin: if and , then .
How it works
RE to DFA pipeline
RE-TO-DFA(r)
1 N <- THOMPSON(r) // epsilon-NFA
2 M <- SUBSET-CONSTRUCT(N) // DFA
3 optionally MINIMIZE(M)
4 return MDFA to RE pipeline
DFA-TO-RE(M)
1 G <- TO-GNFA(M)
2 while G has a state q other than start and accept
3 ELIMINATE(G, q)
4 return the single edge label from start to acceptDifferent elimination orders yield different but equivalent expressions.
Algorithms and pseudocode
Thompson for concatenation, union and star follows the fragment table. State count: every symbol, or fragment has 2 states, union and star add 2 new states each, and concatenation adds none, so the NFA has at most states, where counts symbols and operators. Textbooks differ on whether concatenation merges the two glued states, so a question asking for an exact Thompson state count must fix the convention.
State elimination makes polynomially many algebraic label updates, but explicitly expanded expressions can grow exponentially. Elimination is manageable by hand on small machines; expression size matters to the actual running time.
Mathematical explanation
Correctness sketch of Thompson
By induction on the expression: each fragment accepts exactly , and composing fragments preserves the inductive semantics of , concatenation and star because -edges only glue without reading input.
Correctness of elimination
When is removed, every path that looped on a total of times becomes a single RE edge . Summing with the old paths leaves the language of labels from start to accept unchanged.
Arden's lemma
Solving for languages with gives the unique solution . Proof: unfold , and the condition prevents infinite descent from hiding extra strings.
Worked examples
Example 1: Thompson for
Build fragments for , , union, star, then concatenate a, b, b. With the -glued concatenation of the fragment table the NFA has 14 states: 2 for each of the five symbol occurrences, 2 for the union and 2 for the star. The machine accepts strings ending with abb. Subset construction followed by minimization gives the 4-state DFA that tracks progress towards abb.

Example 2: state elimination on a 2-state DFA
DFA for "even number of 0s": states (start, accept) and ; alphabet ; , , , . means "even 0s so far", means "odd".
Eliminate : the path contributes , and the direct loop contributes . The new self-loop on is , and since is both start and accept the answer is .
One wrong edge changes the language. If and instead, eliminating gives , which is "empty, or ends in 1". The two machines agree on 1, 00 is in the first language only, and 01 is in the second only. Always check the edges out of the eliminated state before writing the loop label.

Example 3: RE for "contains 01"
. Thompson yields an -NFA; subset construction and minimization give a 3-state DFA: "no progress", "last symbol was 0" and the accepting sink "seen 01". Three states are necessary: prefixes , 0, and 01 are pairwise distinguishable. Continuation 1 distinguishes the first two; the empty continuation distinguishes 01 from either of them.
Example 4: from RE a(a+b)*b to an NFA then DFA
Thompson produces an epsilon-NFA with a chain: read a, then loop on a+b via star fragment, then read b. After subset construction and removing unreachable sets, the DFA tracks: have we read the leading a? are we in the middle? have we just closed with b? Membership: a string is accepted iff it starts with a, ends with b, and has length at least 2. Checks: ab yes; aab yes; aaabbb yes; a no; b no; ba no.
Example 5: proving two REs equivalent
To show : the second form asks for some 0 followed later by some 1. Take the last 0 before that 1; the symbol after it is a 1, so the factor 01 occurs. The converse is immediate. The automaton method gives the same answer: both expressions minimize to the same 3-state DFA of Example 3.
Example 6: state elimination on the divisible-by-3 DFA
Use the DFA of Deterministic Finite Automata (residues , start and accept ). Eliminate first: it is entered only from on 0, loops on 1, and leaves to on 0, so gains the loop . Now eliminate : it is entered from on 1, loops on , and returns to on 1, so gains the loop . Together with the 0-loop on :
11 (3), 110 (6) and 1001 (9) match; 10 (2) and 111 (7) do not. Eliminating in the order first gives a longer but equivalent expression.
Example 7: Arden's lemma on the even-number-of-0s DFA
Write one equation per state for the set of strings that lead to it ( for the start state):
The second equation has the form ; the right-sided Arden rule ( with gives ) yields . Substitute: , so , matching the elimination answer. Since is the only accepting state, this is the language.
Arden's condition matters. If , uniqueness is no longer guaranteed: the equation may have multiple solutions. For and , every is a solution; if , only is possible.
Regular grammars
A right-linear grammar has rules or with ; a left-linear one has or . Both generate exactly the regular languages. From a DFA: one variable per state, a rule for each edge , and for each accepting . For the reverse direction, first normalize to single-terminal rules , , with optional unit/epsilon rules. Then use one state per normalized variable plus a final state; general word-labelled edges for longer must instead be expanded into paths with intermediate states.
Mixing is not allowed. A grammar that uses right-linear and left-linear rules together can be non-regular: , is "linear" but generates .
IMPERATIVE RULE. When asked only for an NFA, stop after Thompson. When asked for a DFA, always finish subset construction (and minimize if the question says minimal).
Important properties and observations
- Every RE has an equivalent DFA; every DFA has an equivalent RE.
- Thompson NFAs are sparse and easy to draw by hand for exam REs.
- Elimination order changes the RE text, not the language.
- -edges in a GNFA act as absent paths.
- Converting RE minimal DFA is the standard way to prove two REs equivalent.
Common misconceptions.
- "State elimination needs a DFA." It works on NFAs too after converting labels to REs.
- "Thompson always gives a DFA." It gives an -NFA.
- "The RE from elimination is unique." Only unique up to language equality.
GATE examination perspective
- DRAW THOMPSON CLEANLY. One start, one accept per fragment; only for glue.
- ELIMINATE SYSTEMATICALLY. Update every pair when removing ; do not forget the loop .
- SIMPLIFY AFTERWARD. Apply , , distributivity.
- EQUIVALENCE QUESTIONS. Prefer RE minimal DFA for both sides, then compare.
- READ THE TABLE, NOT THE SHAPE. Two-state machines for "ends in 1" and "even number of 0s" look alike; one edge decides which language it is.
- ELIMINATION ORDER. Eliminate the state with the fewest in-out pairs first; the final expression differs by order, the language does not.
- ARDEN SIDES. For "strings leading to a state" equations the variable is on the left of the symbol (, solution ); for "strings accepted from a state" it is on the right (, solution ).
- LINEAR IS NOT REGULAR. Only purely right-linear or purely left-linear grammars are guaranteed regular.
Summary
Sources
- J. E. Hopcroft, R. Motwani, J. D. Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Pearson Addison-Wesley: Section 3.2 (finite automata and regular expressions, including 3.2.2 on eliminating states and 3.2.3 on converting regular expressions to automata).
- M. Sipser, Introduction to the Theory of Computation, 3rd ed., Cengage Learning: Section 1.3 (regular expressions, equivalence with finite automata).
- P. Linz, An Introduction to Formal Languages and Automata, 6th ed., Jones & Bartlett Learning: Sections 3.2 (regular expressions and regular languages) and 3.3 (regular grammars, right- and left-linear grammars).