Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP46– Programming Language Translators Dr. Manuel E. Bermudez

Similar presentations


Presentation on theme: "COP46– Programming Language Translators Dr. Manuel E. Bermudez"— Presentation transcript:

1 COP46– Programming Language Translators Dr. Manuel E. Bermudez
DFA-> Minimum DFA COP46– Programming Language Translators Dr. Manuel E. Bermudez

2 DFA-> Minimum DFA RGR RGL Minimum DFA RE NFA DFA Done Soon Now

3 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.

4 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.

5 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.

6 Example: Π0 = { {1, 2, 3, 4}, {5} } St. a b 1234 1234 1234 5
DFA-> Minimum DFA b a 1 2 3 5 4 Example: Π0 = { {1, 2, 3, 4}, {5} } St. a b 1 2 3 4 5 Split {4} from partition {1,2,3,4}: Π1 = { {1, 2, 3},{4}, {5} }

7 DFA-> Minimum DFA Π1 = { {1, 2, 3},{4}, {5} } St. a b 123 123 123 4
1 2 3 4 5 Split {2} from partition {1,2,3} Π2 = { {1, 3}, {2}, {4}, {5} }

8 DFA-> Minimum DFA Π2 = { {1, 3},{2},{4}, {5} } St. a b 2 13 2 4 2 5
2 13 2 4 2 5 5 13 4 2 a b 1 3 2 4 5 No more splitting ! Minimal DFA:

9 DFA-> Minimum DFA RGR RGL Minimum DFA RE NFA DFA Done !!

10 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.


Download ppt "COP46– Programming Language Translators Dr. Manuel E. Bermudez"

Similar presentations


Ads by Google