110 likes | 156 Views
DFA-> Minimum DFA. Module 05.4 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez. DFA-> Minimum DFA. Done. Soon. RG R RG L Minimum DFA RE NFA DFA. Now. Given a DFA M, there exists an equivalent minimal
E N D
DFA-> Minimum DFA Module 05.4COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez
DFA-> Minimum DFA Done Soon RGR RGL Minimum DFA RE NFA DFA Now
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: Remove all undefined transitions by introducting a TRAP state, from which no final state is reachable. Partition all states into two groups (final states and non-final states). Complete the “Next State” table for each group, by specifying transitions from group to group. Form the next partition: split groups in which Next State table entries differ. Repeat 3,4 until no further splitting is possible. Determine start and final states. DFA-> Minimum DFA
Example: Π0 = { {1, 2, 3, 4}, {5} } St. a b 1234 1234 1234 1234 1234 1234 1234 5 1234 1234 DFA-> Minimum DFA a b 2 4 a a 1 a b a b b 3 5 1 2 3 4 5 b Split {4} from partition {1,2,3,4}: Π1 = { {1, 2, 3},{4}, {5} }
Π1 = { {1, 2, 3},{4}, {5} } St. a b 123 123 123 4 123 123 123 5 123 123 DFA-> Minimum DFA a b 2 4 a a 1 a b a b b 3 5 1 2 3 4 5 b Split {2} from partition {1,2,3} Π2 = { {1, 3}, {2}, {4}, {5} }
Π2 = { {1, 3},{2},{4}, {5} } St. a b 2 13 2 13 2 4 2 5 2 13 DFA-> Minimum DFA a b 2 4 a a 1 a b a b b 3 5 b 1 3 2 4 5 b 13 No more splitting ! b a a a 5 2 a b Minimal DFA: b 4
DFA-> Minimum DFA Done !! RGR RGL Minimum DFA RE NFA DFA
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. summary