Vojar Have you checked one? Note that 0 occurrences is an even number of occurrences as well. For every new subset you find, see where 0 or 1 takes you. It is useful because constructing an NFA to recognize a given language is sometimes much easier than constructing a DFA for that language. The DFA can be constructed using the powerset construction.
|Published (Last):||14 November 2004|
|PDF File Size:||18.28 Mb|
|ePub File Size:||14.23 Mb|
|Price:||Free* [*Free Regsitration Required]|
Minimum DFA[ edit ] For each regular language, there also exists a minimal automaton that accepts it, that is, a DFA with a minimum number of states and this DFA is unique except that states can be given different names. There are two classes of states that can be removed or merged from the original DFA without affecting the language it accepts to minimize it.
Unreachable states are the states that are not reachable from the initial state of the DFA, for any input string. Nondistinguishable states are those that cannot be distinguished from one another for any input string. DFA minimization is usually done in three steps, corresponding to the removal or merger of the relevant states.
Since the elimination of nondistinguishable states is computationally the most expensive one, it is usually done as the last step. These groups represent equivalence classes of the Myhill—Nerode equivalence relation , whereby every two states of the same partition are equivalent if they have the same behavior for all the input sequences.
That is, for every two states p1 and p2 that belong to the same equivalence class within the partition P, and every input word w, the transitions determined by w should always take states p1 and p2 to equal states, states that both accept, or states that both reject.
It should not be possible for w to take p1 to an accepting state and p2 to a rejecting state or vice versa. It gradually refines the partition into a larger number of smaller sets, at each step splitting sets of states into pairs of subsets that are necessarily inequivalent. The initial partition is a separation of the states into two subsets of states that clearly do not have the same behavior as each other: the accepting states and the rejecting states.
The algorithm then repeatedly chooses a set A from the current partition and an input symbol c, and splits each of the sets of the partition into two possibly empty subsets: the subset of states that lead to A on input symbol c, and the subset of states that do not lead to A. Since A is already known to have different behavior than the other sets of the partition, the subsets that lead to A also have different behavior than the subsets that do not lead to A. When no more splits of this type can be found, the algorithm terminates.
Given a fixed character c and an equivalence class Y that splits into equivalence classes B and C, only one of B or C is necessary to refine the whole partition. Then the states of D and E are split by their transitions into B. The purpose of the outermost if statement if Y is in W is to patch up W, the set of distinguishers. We see in the previous statement in the algorithm that Y has just been split.
If Y is in W, it has just become obsolete as a means to split classes in future iterations. So Y must be replaced by both splits because of the Observation above. If Y is not in W, however, only one of the two splits, not both, needs to be added to W because of the Lemma above. Choosing the smaller of the two splits guarantees that the new addition to W is no more than half the size of Y; this is the core of the Hopcroft algorithm: how it gets its speed, as explained in the next paragraph.
The worst case running time of this algorithm is O ns log n , where n is the number of states and s is the size of the alphabet. This bound follows from the fact that, for each of the ns transitions of the automaton, the sets drawn from Q that contain the target state of the transition have sizes that decrease relative to each other by a factor of two or more, so each transition participates in O log n of the splitting steps in the algorithm.
The partition refinement data structure allows each splitting step to be performed in time proportional to the number of transitions that participate in it. If S is a set of states in P, s is a state in S, and c is an input character, then the transition in the minimum DFA from the state for S, on input c, goes to the set containing the state that the input automaton would go to from state s on input c.
The algorithm terminates when this replacement does not change the current partition. Its worst-case time complexity is O n2s : each step of the algorithm may be performed in time O ns using a variant of radix sort to reorder the states so that states in the same set of the new partition are consecutive in the ordering, and there are at most n steps since each one but the last increases the number of sets in the partition.
Repeating this reversal operation a second time produces a minimal DFA for the original language. However, there are methods of NFA minimization that may be more efficient than brute force search.
NFA and DFA Equivalence Theorem Proof and Example
Nondeterministic finite automaton
Difference Between DFA NFA | NFA Vs DFA automata