Theory of Computation · Conversions between FA and RE
State Elimination Method for Converting Finite Automata to Regular Expressions
Overview
The state elimination method converts any finite automaton (DFA, NFA, or epsilon-NFA) into an equivalent regular expression by repeatedly removing states and replacing the paths through them with equivalent labeled edges.
It is an alternative to Arden's lemma and is preferred for fast solving of competitive exam questions (GATE).
Key concepts
- State elimination method: a technique to convert any finite automaton (DFA, NFA, or epsilon-NFA) into an equivalent regular expression by repeatedly removing states and replacing the paths through them with equivalent labeled edges.
- Arden's lemma: an alternative method that writes equations and substitutes them; it takes a lot of time and cannot be applied to epsilon-NFA.
- State elimination vs. Arden's lemma: state elimination can be applied to any finite automata — epsilon-NFA, DFA, or anything.
- Grammar vs. finite automaton: a grammar is a generator of a language (it generates the entire language); a finite automaton is an acceptor (it decides whether a string belongs to the language).
How it works
Three rules must hold before elimination:
- Initial state must not have any incoming edge. If there is an incoming edge to the initial state, create a new initial state with an epsilon transition to the old initial state.
- Final state must not have any outgoing edge. If the final state has an outgoing edge, create a new final state with an epsilon move to it, and make the old final state non-final.
- There must be only one final state. If there are more than one final state, construct a new single final state with epsilon moves from all previous final states, and make all previous final states non-final.
Elimination procedure:
- Leave the initial state and the final state.
- Eliminate all remaining states one by one, in any order.
- When eliminating a state, all paths that existed before must remain intact: for every incoming edge to the eliminated state and every outgoing edge from it, write a combined path (incoming label)(self-loop label)*(outgoing label) between the surrounding states.
- After all intermediate states are removed, the label on the single edge from initial state to final state is the required regular expression.
Formulas
- Union of parallel edges:
a, b, c(comma) (plus means union). - Path through an eliminated state with a self-loop: .
- Example: incoming , self-loop , outgoing gives .
- Concatenation of labels along a path: written side by side, e.g. followed by gives .
Worked examples
Example 1: Initial state has no incoming edge, final state has no outgoing edge — diagram is already valid. Edges from initial to final are labeled a, b, c. Since comma is union, the regular expression is:
Example 2: Initial state has no incoming edge, final state has no outgoing edge. Eliminate the intermediate state. The path that went from the previous state through the eliminated state to the next state was labeled . After eliminating the state, the same path must remain, so the regular expression is:
Example 3: States , , . Initial state has no incoming edge, final state has no outgoing edge. Eliminate :
- There is an incoming edge to labeled .
- takes any number of 's (self-loop ) and goes to on label .
- After deleting , the path must still exist: then any number of 's then , i.e. .
Example 4: State on to state , and is the final state on .
- Initial state has an incoming edge → create new initial state with epsilon transition to the old initial state.
- Final state has an outgoing edge → create a new final state with an epsilon move, and make the old final state non-final.
- Now eliminate :
- Path from to : epsilon followed by → label .
- Path from to and back to : label followed by → label (self-loop on ).
- Now eliminate :
- Path from to : starts with , then any number of , then epsilon → .
- Final regular expression:
Example 5: Initial state small ; there are three final states.
- Initial state has no incoming edge — OK.
- Final states have no outgoing edges — OK.
- But there are three final states → create one new final state, make all three non-final, and give epsilon transitions from each of them to the new final state.
- Eliminate the intermediate states one by one:
- Eliminating one state gives a path labeled from state to state .
- Eliminating another gives a path labeled .
- Eliminating another gives a path labeled .
- So from state number to state number there are three parallel paths labeled , , . Comma is union, so this is written as .
- Eliminating the remaining state gives the regular expression: [unclear: exact concatenation with the remaining edge label]
Comparison
| Method | Limitation / Advantage |
|---|---|
| Arden's lemma | Writes equations and substitutes; takes a lot of time; cannot be applied to epsilon-NFA |
| State elimination | Can be applied to any finite automata (epsilon-NFA, DFA, anything); fast for competitive exams like GATE |
Revision summary
- Before elimination, enforce: no incoming edge to initial state, no outgoing edge from final state, exactly one final state — create new states with epsilon transitions wherever violated.
- Never eliminate the initial state or the final state; eliminate all other states in any order.
- When eliminating a state, preserve every path: combine each incoming edge, the self-loop (starred), and each outgoing edge.
- Comma between labels means union, written as in the regular expression.
- The final answer is the label on the single edge from the initial state to the final state.
- Arden's lemma cannot be applied to epsilon-NFA; state elimination can.
- A grammar generates a language; a finite automaton accepts (decides membership in) a language.
Previous-year exam insights
- When eliminating a state q, the new edge label from state p to state r is R(p,q) · R(q,q)* · R(q,r), and it must be UNIONED with any label already present on the p→r edge (parallel edges add, i.e. +).
Asked inGATE 2024GATE 2023GATE 2022ISRO 2023 - Elimination order is free but affects the size of the expression; eliminate states with the fewest incoming/outgoing edges first, and always keep the start and the (single) final state.
Asked inGATE 2024GATE 2022 - A state with no self-loop has R(q,q) = ∅, so the star factor is ε and the path label is just R(p,q)·R(q,r);
a state with no incoming or no outgoing edge can be deleted without adding any edge.
Asked inGATE 2023GATE 2007 - The final regular expression is the union of labels of all remaining edges from the start state to the final state; if the start state is also final, include ε (the empty string) in the union.
Asked inGATE 2024GATE 2014 - For an ε-NFA, treat ε as the identity: ε·R = R·ε = R and ε* = ε, so ε-edges can be collapsed before elimination;
alternatively compute the ε-closure of each state first.
Asked inGATE 2024 - Sanity-check the derived expression against the automaton: verify that the shortest accepted string and the number of strings of small length (≤ 4 or 5) match, since exam options often differ only in loop labels or in the order of concatenation.
Asked inGATE 2024GATE 2023GATE 2022