DFA MINIMUM DFA Module 05 4 COP 4020










- Slides: 10
DFA-> MINIMUM DFA Module 05. 4 COP 4020 – Programming Language Concepts Dr. Manuel E. Bermudez
DFA-> MINIMUM DFA RGR RGL Minimum DFA Now RE NFA Done Soon DFA
DFA-> MINIMUM DFA Given a DFA M, there exists an equivalent minimal DFA M’: no other equivalent DFA exists with fewer states than M’. State Minimization: • Will build MDFA from DFA (not “surgery”). • Start with two states: final and non-final. • Split states only if necessary: minimum # of states.
DFA-> MINIMUM DFA Definition: A partition of a set S is a set of subsets of S so that every element of S appears in exactly one of the subsets. Example: S = {1, 2, 3, 4, 5} Π 1 = { {1, 2, 3, 4}, {5} } Π 2 = { {1, 2, 3, }, {4}, {5} } Π 3 = { {1, 3}, {2}, {4}, {5} } Π 2 is a refinement of Π 1 , and Π 3 is a refinement of Π 2.
DFA-> MINIMUM DFA Minimization Algorithm: 1. Remove all undefined transitions by introducting a TRAP state, from which no final state is reachable. 2. Partition all states into two groups (final states and non-final states). 3. Complete the “Next State” table for each group, by specifying transitions from group to group. 4. Form the next partition: split groups in which Next State table entries differ. 5. Repeat 3, 4 until no further splitting is possible. 6. Determine start and final states.
DFA-> MINIMUM DFA a Example: a Π 0 = { {1, 2, 3, 4}, {5} } St. a b 1 1234 2 1234 3 1234 4 1234 5 1234 1 b 2 4 a a b b 3 b a 5 b Split {4} from partition {1, 2, 3, 4}: Π 1 = { {1, 2, 3}, {4}, {5} }
DFA-> MINIMUM DFA a a Π 1 = { {1, 2, 3}, {4}, {5} } St. a 1 123 2 123 4 3 123 4 123 5 5 123 b 1 b 2 4 a a b b 3 b a 5 b Split {2} from partition {1, 2, 3} Π 2 = { {1, 3}, {2}, {4}, {5} }
DFA-> MINIMUM DFA a a 1 Π 2 = { {1, 3}, {2}, {4}, {5} } St. 21 a 13 23 13 22 4 24 25 b b 2 4 a a b 5 b b 13 No more splitting ! b 5 5 13 a b 3 b Minimal DFA: a a b a 2 a b 4
DFA-> MINIMUM DFA RGR RGL Minimum DFA RE NFA Done !! DFA
SUMMARY Summary of Regular Languages • Smallest class in the Chomsky hierarchy. • Appropriate for lexical analysis. • Four representations: RGR , RGL , RE and FSA. • All four are equivalent; algorithms to perform transformations among them. • Various advantages and disadvantages among these four, for language designer, implementer, and user. • FSA’s can be made deterministic, and minimal.