4.6.5 · D5Theory of Computation

Question bank — Regular expressions — equivalence with finite automata

1,756 words8 min readBack to topic

True or false — justify

Every line: decide true/false, then give the why.

True or false: A regex and the NFA built from it by Thompson's construction accept exactly the same set of strings.
True. Thompson's construction is proven correct by induction on the regex structure, so the gadget's language equals the sub-regex's language at every step, up to the whole pattern.
True or false: If a language is regular, there is exactly one regex that describes it.
False. Infinitely many equivalent regexes describe the same language (e.g. and ), just as and name the same number.
True or false: Every finite automaton can be converted to a regex, but some regexes are too complex to convert to a finite automaton.
False. The iff goes both ways with no exceptions; every regex has an equivalent NFA (Thompson) and every FA has an equivalent regex (state elimination).
True or false: Because NFAs allow -transitions and DFAs do not, NFAs recognize strictly more languages than DFAs.
False. Subset construction shows NFA ≡ DFA in power; -moves add convenience, not new languages.
True or false: The regex and the regex describe the same language.
False. is the empty language (accepts nothing, not even the empty string); is , the language containing exactly the empty string.
True or false: In Thompson's construction the final NFA always has exactly one accept state.
True. The whole point of the single-start/single-accept invariant is to make gluing trivial; every gadget preserves it, so the top-level machine has one accept state.
True or false: The self-loop term in the state-elimination rule can be dropped when the eliminated state has no self-loop.
True (in effect). With no self-loop, and , which is the identity for concatenation, so the term simply vanishes.
True or false: A language recognized by a finite automaton can always be described by a finite-length regex.
True. State elimination removes finitely many states, each producing a finite regex, so the surviving label is always finite text — even when the language it names is infinite.
True or false: If two GNFA state-elimination orders give textually different regexes, at least one order made a mistake.
False. Different orders legitimately yield different-but-equivalent regexes for the same language; correctness is judged by the language, not the text.
True or false: Since regexes and DFAs are equivalent, the pumping lemma can be used to prove a regex cannot describe a given language.
True. If no DFA accepts (shown via pumping), then by the equivalence no regex describes either — the lemma bites regexes indirectly.

Spot the error

Each item states a flawed claim or construction. Find the flaw.

"I'll merge the star gadget's new start with 's start to save a state."
The invariant "no edges into start, no edges out of accept" breaks; a leaked loop-back edge can accept a string that is not a clean repetition of . Always add fresh start/accept for star and union.
"For concatenation , I keep 's accept state accepting AND make 's accept accepting too."
Wrong — 's old accept must stop being accepting; otherwise the machine accepts strings that only match without the required part following.
"State elimination gives regex ; therefore the machine rejects the empty string, since needs at least one ."
The reasoning about is fine, but this is only a property of that language; don't confuse "this regex requires an " with a general rule — a different machine's regex might match via a at the outer level.
" means 'one or more copies of ', so the star gadget needs no skip-edge."
means zero or more; the skip-edge (new start new accept) is exactly what allows the zero-copy case, i.e. accepting .
"To convert an NFA with several accept states to a regex, I just eliminate states in any order and read off the label — no setup needed."
You must first normalize: add a fresh start with into the old start, and a fresh accept with from every old accept. Skipping this leaves multiple accepts and edges out of the start, and the ripping rule no longer applies cleanly.
", because zero copies of nothing is still nothing."
. "Zero or more copies" always includes the zero case, which is the empty string , regardless of what you're starring.
"Thompson gives an NFA; NFAs are weaker, so to be safe I should also add the pumping lemma to prove the regex is regular."
A regex defines a regular language by definition — no proof of regularity is needed. Thompson merely exhibits the machine; the pumping lemma is a tool for the opposite job (showing something is not regular).

Why questions

Why do we prove regex ↔ NFA rather than regex ↔ DFA directly?
NFAs with -moves glue together beautifully in Thompson's construction; since NFA ≡ DFA is already known, proving the easier NFA case gives the DFA case for free.
Why were regex operators chosen to be exactly union, concatenation, and star?
They mirror the three things -transitions let an NFA do — branch (union), sequence (concatenation), and loop back (star) — which is precisely why the equivalence comes out so clean.
Why does the ripping rule use the pattern rather than ?
A path through may spin on 's self-loop any number of times before leaving; captures "zero or more spins," which a bare would miss.
Why does the ripping rule keep the old with a "" (union) rather than overwriting it?
There may already be a direct route that bypasses entirely; the union preserves that alternative alongside the new route through .
Why must the normalized GNFA have no edge into the start and none out of the accept?
So that when only start and accept survive, there is a single clean edge between them whose label is unambiguously the whole language's regex — no stray loops or entries to account for.
Why does the star gadget loop 's accept back to 's start instead of to the new start?
Looping to 's own start re-enters exactly one fresh copy of ; routing to the new start would risk re-taking other branches and corrupt the "clean repetition of " meaning.
Why is the closure of regular languages under union, concatenation, and star essentially the same fact as Thompson's construction?
Each Thompson gadget is a constructive proof that regular languages are closed under that operation — building the combined machine is the closure argument.

Edge cases

What NFA does Thompson build for the regex , and what does it accept?
A start state and an accept state with no path between them; it accepts the empty language — no string at all, not even .
What regex does state elimination give for a machine whose start state is also its only accept state and has no transitions?
After normalization the only surviving label is (the edges into and out of the single old state chain through), so the regex is — accepting exactly the empty string.
What happens in Thompson's construction if the alphabet symbol appears but we build no gadget for it?
You cannot — every symbol used in the regex must contribute its base gadget ; omitting it means the pattern was never fully translated, so the induction is incomplete.
For , does the built NFA accept the empty string ?
Yes — the skip-edge from the new start directly to the new accept is the "zero copies" path, which accepts regardless of what is.
If a DFA accepts every string over , what regex does elimination produce, and is it unique?
A regex equivalent to (all strings); it is not textually unique — , , all name the same universal language.
What is the regex for a DFA with a start state that is not accepting and no accepting states reachable?
— with no accepting path surviving normalization, the label between new start and new accept is the empty language, correctly meaning "accepts nothing."
How does the empty string differ from a self-loop labeled during elimination?
A plain edge is just a free hop between distinct states; a self-loop labeled contributes to the rule, adding nothing — starring the empty string still gives only the empty string.
Recall One-line self-check before you move on

Can I explain, without notes, why different elimination orders are all correct? ::: They produce equivalent regexes (same language, different text); correctness is judged by the language recognized, exactly like .