In this discussion we practiced all of the constructions from Kleene's
Theorem, starting with the regular expression
(b+a(a+ba^{*}b))^{*}a.
- Part I: Draw a λ-NFA whose language is the same
as the language of this regular expression. Do this twice -- first carry
out the construction exactly as presented, except that you may represent
ba^{*}b by the obvious simple three-state ordinary NFA instead of the
six-state λ-NFA that the construction would give. You should get four
λ-moves and seven states. Before proceeding to Part II, you can
make an optimization that will make Part II easier, eliminating one state and
one λ-move.
- State 1, the start state, has a λ-move to state 2.
- State 2 has an a-move to state 3, a b-move to state 5,
and a λ-move to state 5.
- State 3 has an a-move to state 5 and a b-move to state 4.
- State 4 has an a-loop and a b-move to state 5.
- State 5 has λ-moves to states 2 and 6
- State 6 has an a-move to state 7.
- State 7, the only final state, has no moves out of it.
The suggested optimization is to merge states 6 and 7 into a single
final state 6, with now an a-move from state 5 to state 6.
- Part II: Eliminate the λ-moves in this λ-NFA --
that is, make a new ordinary NFA, equivalent to the λ-NFA, with the
same six states, same start state, and a possibly different final state set.
We begin by finding the transitive closure of the λ-moves. We have
λ-moves from 1 to 2, 2 to 5, and 5 to 2. (We have eliminated the
former λ-move from 5 to 6.) The transitive
closure includes an additional λ-move from 1 to 5 -- all other two-step
paths are either covered by λ-moves or are from a vertex to itself.
Now we add the letter moves for each of the letter moves of the
λ-NFA:
- For (2,a,3) we add (1,a,3), (2,a,3), and (5,a,3).
- For (2,b,5) we add (1,b,2), (1,b,5), (2,b,2), (2,b,5), (5,b,2), and
(5,b,5).
- For (3,a,5) we add (3,a,2) and (3.a.5).
- For (3,b,4) we add only (3,b,4).
- For (4,a,4) we add only (4,a,4).
- For (4,b,5) we add (4,b,2) and (4,b,5).
- For (5,a,6) we add (1,a,6), (2,a,6), and (5,a,6).
Since there is no λ-path from start to final state, we do not need to
make the start state final. We have a total of eighteen letter moves.
- Part III: Using the Subset Construction, make a DFA equivalent
to your ordinary NFA (you will need only a small fraction of the 64
possible states).
- The (non-final)
start state is {1}, with a-move to {3,6} and b-move to {2,5}.
- {3,6} is a final state, with a-move to {2,5} and b-move to {4}.
- {2,5} is a non-final state, with a-move to {3,6} and b-move to itself.
- {4} is a non-final state, with a-move to itself and b-move to {2,5}.
- Part IV: Find the minimal DFA equivalent to your DFA.
For convenience I will rename the states 1, 36, 25, and 4.
Our initial partition has F = {36} and N = {1, 25, 4}. Looking at N, we
find that 1 and 25 each go to
F on a and to N on b, while 4 always goes to N. So we split N.
Now we have F = {36}, X = {1, 25}, and Y = {4}. We look at X and see that
both states go to F on a and to X on b. So this is our final partition.
The minimal DFA has three states:
- Nonfinal start state X with a-move to F and b-move to itself
- Final state F with a-move to X and b-move to Y
- Nonfinal state Y with a-move to itself and b-move to X
- Part V: Find a regular expression for the language of the minimal
DFA, using the construction from this week's lecture. How does this compare
to the regular expression you started with?
We take the three-state NFA and add a new start state S and a new final state
Z, with new λ-moves from S to X and from F to Z.
The easiest state to eliminate first is Y, leaving a move
(F,ba^{*}b,X) which merges with a parallel move to become
(F,a + ba^{*}b, X).
Now we may kill F, leading to two moves (X,a,Z) and (X,a(a+ba^{*}b),
X). The latter move merges with the parallel loop at X to make
(X,b + a(a+ba^{*}b), X).
Now killing the last move leaves us the regular expression
(b + a(a + ba^{*}b))^{*}a, which is exactly the regular
expression we started with. There are other valid regular expressions that
are obtained by eliminating the states in a different order.
Last modified 15 May 2006