1 / 6

Section 11.3 Constructing Efficient Finite Automata

a. 1. L. b. a. L. S. 0. b. 2. Section 11.3 Constructing Efficient Finite Automata First we’ll see how to transform an NFA into a DFA. Then we’ll see how to transform a DFA into a minimum-state DFA. Transforming an NFA into a DFA

delisa
Download Presentation

Section 11.3 Constructing Efficient Finite Automata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. a 1 L b a L S 0 b 2 Section 11.3 Constructing Efficient Finite Automata First we’ll see how to transform an NFA into a DFA. Then we’ll see how to transform a DFA into a minimum-state DFA. Transforming an NFA into a DFA The l-closure of a state s, denoted l(s), is the set consisting of s together with all states that can be reached from s by traversing l-edges. The l-closure of a set S of states, denoted l(S), is the union of the l-closures of the states in S. Example. Given the following NFA as a graph and as a transition table. Some sample l-closures for the NFA are as follows: l(0) = {0, 1, 2} l(1) = {1, 2} l(2) = {2} l() =  l({1, 2}) = {1, 2} l({0, 1, 2}) = {0, 1, 2}.

  2. b a b 2 1 b S 0 L 3 a Algorithm: Transform an NFA into a DFA Construct a DFA table TD from an NFA table TN as follows: 1. The start state of the DFA is l(s), where s is the start state of the NFA. 2. If {s1, …, sn} is a DFA state and aA, then TD({s1, …, sn}, a) = l(TN(s1, a)  …  TN(sn, a)). 3. A DFA state is final if one of its elements is an NFA final state. Example. Given the following NFA. The algorithm constructs the following DFA transition table TD, where it is also written in simplified form after a renumbering of the states.

  3. 1 b a S 0 2 L a 3 a Quiz. Use the algorithm to transform the following NFA into a DFA. Solution: The algorithm constructs the following DFA transition table TD, where it is also written in simplified form after a renumbering of the states.

  4. Transforming an DFA into a minimum-state DFA Let S be the set of states that can be reached from the start state of a DFA over A. For states s, tS let s ~ t mean that for all strings w A* either T(s, w) and T(t, w) are both final or both nonfinal. Observe that ~ is an equivalence relation on S. So it partitions S into equivalence classes. Observe also that the number of equivalence classes is the minimum number of states needed by a DFA to recognize the language of the given DFA. Algorithm:Transform a DFA to a minimum-state DFA 1. Construct the following sequence of sets of possible equivalent pairs of distinct states: E0E1 … Ek = Ek+1, where E0 = {{s, t} | s and t are either both final or both nonfinal} and Ei+1 = {{s, t}  Ei | {T(s, a), T(t, a)} Ei or T(s, a) = T(t, a)} for every aA}. Ek represents the distinct pairs of equivalent states from which ~ can be generated. 2. The equivalence classes form the states of the minimum state DFA with transition table Tmin defined by Tmin([s], a) = [T(s, a)]. 3. The start state is the class containing the start state of the given DFA. 4. A final state is any class containing a final state of the given DFA.

  5. a 1 2 a b S 0 a, b 4 b 3 a, b a, b Min-state Table Renamed Table Min-state DFA graph a 1 a, b S 0 2 b a, b Example. Use the algorithm to transform the following DFA into a minimum-state DFA. Solution: The set of states is S = {0, 1, 2, 3, 4}. To find the equivalent states calculate: E0 = {{0, 4}, {1, 2}, {1, 3}, {2, 3}} E1 = {{1, 2}, {1, 3}, {2, 3}} E2 = {{1, 2}, {1, 3}, {2, 3}} = E1. So 1 ~ 2, 1 ~ 3, 2 ~ 3. This tells us that S is partitioned by {0}, {1, 2, 3}, {4}, which we name [0], [1], [4], respectively. So the minimum-state DFA has three states. Quiz: What regular expression equality arises from the two DFAs? Answer: a + aa + (aaa + aab + ab)(a + b)* = a(a + b)*.

  6. b a a 1 S 0 b Quiz. Is the following DFA a minimum-state DFA? a, b S 0 Quiz. Is the following DFA a minimum-state DFA? Answer. No. Use the minimum-state algorithm. E0 = {{0, 1}} E1 = {{0, 1}} = E0. So 0 ~ 1, which tells us that the partition is the whole set of states {0, 1} = [0]. Therefore, we obtain the following minimum-state DFA. Answer: No. E0 = {{0, 1}, {0, 5}, {1, 5}, {2, 3}, {2, 4}, {3, 4}} E1 = {{1, 5}, {2, 4}} E2 = {{1, 5}, {2, 4}} = E1. So 1 ~ 5 and 2 ~ 4. This gives us {0}, {1, 5}, {2, 4}, {3}, with names [0], [1], [2], [3], respectively with the following minimum-state DFA.

More Related