HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Brzozowski's algorithm for Kleene star NFA

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
starnfabrzozowskialgorithmforkleene

Problem

I have some troubles in understanding of the Brzozowski's algorithm for NFA to minimized DFA transformation. Or maybe I'm doing a mistake in the NFA to DFA transformation steps.

The Algorithm, as described in Wikipedia, is as follows:

  • Reverse the NFA.



  • Transform to DFA.



  • Reverse DFA.



  • Transform to DFA again.



Let's assume we have the following language: A* (zero or more repetitions of A).

For this language we may have the following NFA (over-complicated for a purpose):

-
I'm reversing it.

-
Turning reversed NFA to DFA using the Powerset approach.

  • The init state 3 Epsilon-closure is {1, 2, 3}.



  • Closure {1, 2, 3} transits by A to {1, 2}.



  • Closure {1, 2} transits by A to {1, 2}.



So, we have two new states for these two new closures and transitions between them as follows:

All states are final as their closures contain state 1. {1, 2, 3} state is a Start state is it contains state 3. This is clearly a DFA that reads the reversed language which is equal in this case to original one A*. There are redundant states, but I assume it does not contradict the Algorithm requirements.

-
Reverse it again.

-
Turning to DFA again.

  • The init state 3 Epsilon-closure is {1, 2, 3}.



  • Closure {1, 2, 3} transits by A to {1, 2}.



  • Closure {1, 2} transits by A to {1, 2}.



New closure-states and the topology of the final Automata are the same as on step 2.

But this DFA is not minimal. Can you explain me, please, where did I make a mistake?

Thanks in advance!

Ilya.

Solution

I realized this question is a duplicate.

Basically, as @Pseudonym mentioned above, when reverting DFA you should avoid introducing new starting state of the NFA even if there were multiple finish states in DFA. Instead just merge epsilon closures of each reversed NFA start state into a single closure and treat it as a start closure during the Powerset construction.

For those of you who faced this suboptimal issue after reading of the Wikipedia Article's Note:

or add an extra state with ε-transitions to all the initial states, and make only this new state initial.

Please be aware, that this note is simply wrong.

Context

StackExchange Computer Science Q#159607, answer score: 4

Revisions (0)

No revisions yet.