Theorem: Let L be regular. Then ∃ a
regular expression such that L=L(r).
Perhaps you see that any regular expression can be
implemented as a NFA.
For most of us, its not obvious that any NFA can be converted to a
regular expression.
Proof Idea:
Remove states sucessively, generating equivalent
generalized transition graphs (GTG) until only two states are
left (initial state and one final state).
The transition between these states is a regular expression
that is equivalent to the original NFA.
Generalized Transition Graph (GTG)
A Generalized Transition Graph (GTG) is a transition
graph whose edges can be labeled with any regular expression.
Thus, it “generalizes” the standard transition graph.
Definition: A complete GTG is a complete graph, meaning that every
state has a transition to every other state.
Any GTG can be converted to a complete GTG by adding edges labeled
∅ as needed.
Proof (1)
L is regular ⇒∃ NFA M such
that L=L(M).
1. Assume M has one final state, and q0∉F.
2. Convert M to a complete GTG.
Let rij stand for the label of the edge from qi
to qj.
3. If the GTG has only two states, then it has this form:
qi
qj
rii
rjj
rji
rij
Add an arrow to the start state.
Then, the corresponding regular expression is:
r=(r∗iirijr∗jjrji)∗r∗iirijr∗jj
Proof (2)
(See homework question about why its fair to just assume that
there is a single final state, and that the start state is not final.)
If the GTG has three states, then it must have the following form:
qi
qj
qk
rkk
rjj
rii
rkj
rjk
rij
rji
rik
rki
Proof (3)
In this case, make the following replacements:
REPLACE WITH
riirii+rikr∗kkrki
rjjrjj+rjkr∗kkrkj
rijrij+rikr∗kkrkj
rjirji+rjkr∗kkrki
After these replacements, remove state qk and its edges.
Proof (4)
If the GTG has four or more states, pick any state qk that
is not the start or the final state.
It will be removed.
For all o≠k,p≠k, replace rop with
rop+rokr∗kkrkp.
When done, remove qk and all its edges.
Continue eliminating states until only two states are left.
Finish with step 3 of the “Proof (1)” slide.
Proof (5)
In each step, we can simplify regular expressions r and
s with any of these rules that apply: