In this discussion we are going to practice our constructions
underlying Kleene's Theorem by taking a language given by a regular
expression and successively producing a λ-NFA, an ordinary NFA,
a DFA, a minimized DFA, and a new regular expression. The original
regular expression is ab^{*} + (ab)^{*}.

Question text is in black, solutions in blue.

- Give a λ-NFA for this language using the construction. You
should get eight states. Then indicate how three of the states can be combined
into one to leave an equivalent six-state λ-NFA.
We begin with b

^{*}, which gets a four state λ-NFA by the construction for Kleene star: state set {1,2,3,4}, λ-arrows from 1 to 2, 2 to 3, 3 to 2, and 3 to 4, and b-arrow from 2 to 3. Connecting this in series with the two-state λ-NFA for the language a, we get a five-state λ-NFA for ab^{*}, with a new state 0 and an a-arrow from 0 to 1.The language ab has a three-state λ-NFA -- its state set is {5,6,7} (start state 5, final state 7) and it has an a-arrow from 5 to 6 and a b-arrow from 6 to 7. To make the λ-NFA for (ab)

^{*}we add two new states and four λ-arrows. Combining the machines for ab^{*}and (ab)^{*}in parallel, the two new states of the second machine become 0 and 4 respectively. So we get a machine with state set {0,1,2,3,4,5,6,7}, start state 0, final state 4, and arrows (0,a,1), (1,λ,2), (2,b,3), (2,λ,3), (3,λ,2), (3,λ,4), (0,λ5), (5,a,6), (5,λ,7), (6,b,7), (7,λ,5), and (7,λ,4).The optimization is to combine states 1, 2, and 3 into a single state 1, with a b-loop on it. This gives six states {0,1,4,5,6,7}, with start state 0, final state 4, and arrows (0,a,1), (1,b,1), (1,λ,4), (0,λ,5), (5,a,6), (5,λ,7), (6,b,7), (7,λ,5), and (7,λ,4).

- Carry out the construction to get an equivalent ordinary NFA from
this λ-NFA. You should still have six states. Remember to get the
right final state set.
We first find the transitive closure of the λ-moves. The existing moves go from 0 to 5, 1 to 4, 5 to 7, 7 to 4, and 7 to 5. To get a transitively closed set we must add λ-moves from 0 to 7, 0 to 4, and 5 to 4.

The a-arrow from 0 to 1 gives us a-arrows from 0 to 1 and 1 to 4. The b-arrow from 1 to 1 gives us b-arrows from 1 to 1 and 1 to 4. The a-arrow from 5 to 6 gives us a-arrows from 0 to 6, 5 to 6, and 7 to 6. The b-arrow from 6 to 7 gives us b-arrows from 6 to 4, 6 to 5, and 6 to 7. This gives us ten letter-moves on our six states.

Since there is a λ-path in the λ-NFA from the start state to the final state, we must make the start state 0 final in the ordinary NFA. It thus has final state set {0,4}.

- Use the subset construction to get a DFA equivalent to this NFA. You
should have seven states.
We make the following states in succession:

- State {0}, a-arrow to {1,4,6}, b-arrow to ∅, final because 0 is.
- State {1,4,6}, a-arrow to ∅, b-arrow to {1,4,5,7}, final because 4 is.
- State &empty, a-arrow and b-arrow to itself, nonfinal.
- State {1,4,5,7}, a-arrow to {6}, b-arrow to {1,4}, final because of 4.
- State {6}, a-arrow to ∅, b-arrow to {4,5,7}, nonfinal.
- State {1,4}, a-arrow to ∅, b-arrow to itself, final because of 4.
- State {4,5,7}, a-arrow to {6}, b-arrow to ∅, final because of 4.

- Is your seven-state DFA minimal? Use the construction either to show
that it is or to get a smaller equivalent DFA.
We begin with a set F of final states {0, 146, 1457, 14, 457} and a set N of nonfinal states {E, 6}. Looking at N first, we see that E goes to N on both a and b while 6 goes to N on a and to F on b. So we split N into two classes E and 6. Looking at the five states of F we then find:

- 0 goes to F on a and to E on b
- 146 goes to E on a and to F on b
- 1457 goes to 6 on a and to F on b
- 14 goes to E on a and to F on b
- 457 goes to 6 on a and to E on b

There are four different behaviors, so we now know that each state is in a separate class except possibly for 146 and 14. But 146 goes to 1457 on b while 14 goes to itself. So once we know that 1457 and 14 are in different classes, it follows that 146 and 14 must be in separate classes as well.

We conclude that the seven-state DFA was already minimal.

- Get a regular expression from your minimal DFA by state elimination.
Remember that a "death state" can be eliminated immediately since it is not
involved in any path from the start state to a final state.
We can keep 0 as our start state because it has no moves into it. We need to add a new start state F and make λ-moves to F from each of the five final states. We then proceed to eliminate states in succession:

- Eliminate E following the hint, no new arrows are created.
- Eliminate 14, creating one arrow from 1457 to F labeled bb
^{*}, and this arrow combines with the λ-arrow from 1457 to F. - Eliminate 146, creating and arrow from 0 to F labeled a (which merges with the λ-arrow from 0 to F), and an arrow from 0 to 1457 labeled ab.
- Eliminate 1457, creating two new arrows. The first goes from 0 to F
and is labeled ab(λ+bb
^{*}), and it combines with the existing arrow to make an arrow from 0 to F labeled "λ+a+ab+abbb^{*}". The second arrow is from 0 to 6 and is labeled aba. - Eliminate 6, creating an arrow from 0 to 457 labeled abab and a loop on 457 labeled ab.
- Eliminate 457 to leave only a single arrow, labeled with the final regular
expression "λ+a+ab+abbb
^{*}+abab(ab)^{*}".

It is fairly easy to see that this regular expression is equivalent to the original one because we may rewrite ab

^{*}as a + ab + abbb^{*}and rewrite (ab)^{*}as λ + ab + abab(ab)^{*}.

Last modified 3 May 2007