1. Gyanastra
  2. Theory of Computation
  3. Conversions between FA and RE
  4. State Elimination Method for Converting Finite Automata to Regular Expressions
Free lesson, no account needed 7 min read 11 practice questions after it
Asked in past papers12 times
  • GATE CSE202520242023202220142008200720061994
  • ISRO2023
  • UGC NET20132012

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:

  1. 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.
  2. 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.
  3. 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:

  1. Leave the initial state and the final state.
  2. Eliminate all remaining states one by one, in any order.
  3. 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.
  4. 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) =a+b+c= a + b + c (plus means union).
  • Path through an eliminated state with a self-loop: (incoming label)(self-loop label)∗(outgoing label)(\text{incoming label})(\text{self-loop label})^*(\text{outgoing label}).
    • Example: incoming AA, self-loop BB, outgoing CC gives AB∗CAB^*C.
  • Concatenation of labels along a path: written side by side, e.g. 11 followed by 00 gives 1010.

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: a+b+ca + b + c

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 ABAB. After eliminating the state, the same path must remain, so the regular expression is: ABAB

Example 3: States AA, BB, CC. Initial state has no incoming edge, final state has no outgoing edge. Eliminate BB:

  • There is an incoming edge to BB labeled AA.
  • BB takes any number of BB's (self-loop BB) and goes to CC on label CC.
  • After deleting BB, the path must still exist: AA then any number of BB's then CC, i.e. AB∗CAB^*C.

Example 4: State AA on 00 to state BB, and BB is the final state on 11.

  • Initial state has an incoming edge → create new initial state QxQ_x with epsilon transition to the old initial state.
  • Final state has an outgoing edge → create a new final state QFQ_F with an epsilon move, and make the old final state non-final.
  • Now eliminate AA:
    • Path from QsQ_s to BB: epsilon followed by 00 → label 00.
    • Path from BB to AA and back to BB: label 11 followed by 00 → label 1010 (self-loop on BB).
  • Now eliminate BB:
    • Path from QsQ_s to QFQ_F: starts with 00, then any number of 1010, then epsilon → 0(10)∗0(10)^*.
  • Final regular expression: 0(10)∗0(10)^*

Example 5: Initial state small aa; 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 BB from state 22 to state 66.
    • Eliminating another gives a path labeled CC.
    • Eliminating another gives a path labeled DD.
  • So from state number 22 to state number 66 there are three parallel paths labeled BB, CC, DD. Comma is union, so this is written as B+C+DB + C + D.
  • Eliminating the remaining state gives the regular expression: (B+C+D)(B + C + D) [unclear: exact concatenation with the remaining edge label]

Comparison

MethodLimitation / Advantage
Arden's lemmaWrites equations and substitutes; takes a lot of time; cannot be applied to epsilon-NFA
State eliminationCan 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
Pages 1–2 of 2