Top Banner
Compiler Design Optimization of DFA- Based Pattern Matchers 06/17/22 1 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI
14

Minimization of dfa

Mar 03, 2017

Download

Education

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Minimization of dfa

Compiler Design

Optimization of DFA-Based Pattern Matchers

05/01/23 1ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI

Page 2: Minimization of dfa

Optimization of DFA-Based Pattern Matchers

• It refers to detecting those states of a DFA whose presence or absence in a DFA does not affect the language accepted by the automata.

• These states can be eliminated from the automata without affecting the language accepted by the automata.

• SUCH STATES ARE:-• Unreachable States:• Dead States:• Nondistinguishable States:

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 2

Page 3: Minimization of dfa

Contd…….

• Unreachable States: Unreachable states of a DFA are not reachable from the initial state of DFA on any possible input sequence.

• Dead States: A dead state is a nonfinal state of a DFA whose transitions on every input symbol terminates on itself. For example, q is a dead state if q is in Q F, and δ(q, a) = q for every a in Σ.

• Nondistinguishable States: Nondistinguishable states are those states of a DFA for which there exist no distinguishing strings; hence, they cannot be distinguished from one another.

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 3

Page 4: Minimization of dfa

Contd……..

• Optimization entails:

• Detection of unreachable states and eliminating them from DFA;

• Identification of nondistinguishable states, and merging them together; and

• Detecting dead states and eliminating them from the DFA.

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 4

Page 5: Minimization of dfa

Consider The Transition Diagram

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 5

Fig: Partitioning down to a single state.

Page 6: Minimization of dfa

Contd……

• Initially, we have two groups, as shown below:

Group I Group IISince

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 6

A, B, C, E, F D

Page 7: Minimization of dfa

Contd…..• Partitioning of Group I is not possible, because the

transitions from all the members of Group I go only to Group I. But since

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 7

state F is distinguishable from the rest of the members of Group I. Hence, we divide Group I into two groups: one containing A, B, C, E, and the other containing F, as shown below:

Page 8: Minimization of dfa

Contd……

Group I Group II Group IIISince

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 8

A, B, C, E F D

partitioning of Group I is not possible, because the transitions from all the members of Group I go only to Group I. But since

Page 9: Minimization of dfa

Contd…..

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 9

states A and E are distinguishable from states B and C. Hence, we further divide Group I into two groups: one containing A and E, and the other containing B and C, as shown below:

Page 10: Minimization of dfa

Contd……

Group I Group II Group III Group IV Since

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 10

A, E B, C F D

state A is distinguishable from state E. Hence, we divide Group I into two groups: one containing A and the other containing E, as shown below:

Page 11: Minimization of dfa

Contd……

Group I Group II Group III Group IV Group VSince

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 11

A E B, C D

partitioning of Group III is not possible, because the transitions from all the members of Group III on a go to group III only. Similarly,

F

Page 12: Minimization of dfa

Contd…..

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 12

partitioning of Group III is not possible, because the transitions from all the members of Group III on b also only go to Group III.

Hence, B and C are nondistinguishable states; therefore, we merge B and C to form a single state, B1, as shown in next Figure…

Page 13: Minimization of dfa

Contd……..

05/01/23 ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI 13

Fig. Merging nondistinguishable states B&C into a single state B1.

Page 14: Minimization of dfa

THANKS

05/01/23 14ANKUR SRIVASTAVA ASSISTANT PROFESSOR JETGI