0% found this document useful (0 votes)
35 views26 pages

Minimizing DFAs

This document discusses minimizing deterministic finite automata (DFAs) through identifying equivalent states. It defines equivalent states and n-equivalence of states. An example is provided to demonstrate the process of minimizing a DFA by determining the 0, 1, and 2-equivalence classes and merging equivalent states. The document outlines assigning students to construct an NFA for a language concatenation and minimize it, and to construct a minimal DFA for a language union.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views26 pages

Minimizing DFAs

This document discusses minimizing deterministic finite automata (DFAs) through identifying equivalent states. It defines equivalent states and n-equivalence of states. An example is provided to demonstrate the process of minimizing a DFA by determining the 0, 1, and 2-equivalence classes and merging equivalent states. The document outlines assigning students to construct an NFA for a language concatenation and minimize it, and to construct a minimal DFA for a language union.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Minimizing DFAs

Lecture 11
Exercise 7.40
Robb T. Koether
Hampden-Sydney College
Fri, Sep 21, 2012
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 1 / 26
Outline
1
Equivalent States
2
n-Equivalence
3
Minimization Examples
4
Assignment
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 2 / 26
Outline
1
Equivalent States
2
n-Equivalence
3
Minimization Examples
4
Assignment
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 3 / 26
Equivalent States
To minimize a DFA, we must identify states that are equivalent.
When two states are equivalent, one of them may be eliminated.
Denition (Equivalent states)
Two states in a DFA are equivalent if, for any input, the decision of
whether to accept or reject it will be the same regardless of which of
the two states we are currently in.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 4 / 26
Example
Example (Equivalent states)
Clearly, states 2 and 3 are equivalent and states 4 and 5 are
equivalent.
5 3
4 2
1
a
a
a
a
a
b
b
b b
b
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 5 / 26
Example
Example (Equivalent states)
Clearly, states 2 and 3 are equivalent and states 4 and 5 are
equivalent.
5 3
4 2
1
a
a
a
a
a
b
b
b b
b
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 6 / 26
Example
Example (Equivalent states)
Clearly, states 2 and 3 are equivalent and states 4 and 5 are
equivalent.
a, b
a
b
a b
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 7 / 26
Outline
1
Equivalent States
2
n-Equivalence
3
Minimization Examples
4
Assignment
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 8 / 26
Equivalence of States
Denition (0-equivalence of states)
Two states q and q

are 0-equivalent if
Both are accepting states, or
Both are rejecting states.
Denition (n-equivalence of states)
Let n be a positive integer. Two states q and q

are n-equivalent if the


states (q, a) and (q

, a) are (n 1)-equivalent for all a .


Denition (Equivalence of states)
Two states are equivalent if they are n-equivalent for all n 0.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 9 / 26
Determining Equivalent States
To determine which states are equivalent,
Add a dead state, if necessary, to make the DFA fully dened.
Determine the 0-equivalence classes: F, Q F.
From the 0-equivalence classes, determine the 1-equivalence
classes.
From the 1-equivalence classes, determine the 2-equivalence
classes.
And so on, until, for some n, the n-equivalence classes and the
(n 1)-equivalence classes are the same.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 10 / 26
Determining Equivalent States
At that point, the equivalence classes are the n-equivalence
classes.
Redraw the DFA, lumping all states of an equivalence class
together as a single state.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 11 / 26
Outline
1
Equivalent States
2
n-Equivalence
3
Minimization Examples
4
Assignment
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 12 / 26
Example
Example (Minimizing a DFA)
Minimize the following DFA:
a, b
a
b
a
a
a a
a
a a
a
b
b
b
b b
b
b b
10
6 5
9 8
4 3
7
2
1
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 13 / 26
Example
Example (Minimizing a DFA)
The 0-equivalence classes are
F = {10}
and
Q F = {1, 2, 3, 4, 5, 6, 7, 8, 9}.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 14 / 26
Example
Example (Minimizing a DFA)
Summarize the transitions in the following tables.
1 2 3 4 5 6 7 8 9
a 2 6 8 5 10 10 2 5 4
b 7 3 9 3 7 3 9 7 10
10
a 10
b 10
Identify each entry with one of the 0-equivalence classes
1 2 3 4 5 6 7 8 9
a A A A A B B A A A
b A A A A A A A A B
10
a B
b B
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 15 / 26
Example
Example (Minimizing a DFA)
There are three patterns within {1, 2, 3, 4, 5, 6, 7, 8, 9}: AA, BA,
and AB.
These patterns subdivide the 0-equivalence classes into the
1-equivalence classes:
{1, 2, 3, 4, 7, 8}, {5, 6}, {9}, {10}.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 16 / 26
Example
Example (Minimizing a DFA)
Show the transitions for the 1-equivalence classes.
1 2 3 4 7 8
a 2 6 8 5 2 5
b 7 3 9 3 9 7
5 6
a 10 10
b 7 3
9
a 4
b 10
10
a 10
b 10
Identify each entry with a 1-equivalence class.
1 2 3 4 7 8
a A B A B A B
b A A C A C A
5 6
a D D
b A A
9
a A
b D
10
a D
b D
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 17 / 26
Example
Example (Minimizing a DFA)
There are 3 different patterns within {1, 2, 3, 4, 7, 8}: AA, BA, and
AC.
These patterns subdivide the 1-equivalence classes into the
2-equivalence classes:
{1}, {2, 4, 8}, {3, 7}, {5, 6}, {9}, {10}.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 18 / 26
Example
Example (Minimizing a DFA)
Show the transitions for the 2-equivalence classes.
1
a 2
b 7
2 4 8
a 6 5 5
b 3 3 7
3 7
a 8 2
b 9 9
5 6
a 10 10
b 7 3
9
a 4
b 10
10
a 10
b 10
1
a B
b C
2 4 8
a D D D
b C C C
3 7
a B B
b E E
5 6
a F F
b C C
9
a B
b F
10
a F
b F
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 19 / 26
Example
Example (Minimizing a DFA)
Identify each entry with a 2-equivalence classes.
The patterns are the same within each class.
There is no further subdividing.
Therefore, these are the nal equivalence classes:
{1}, {2, 4, 8}, {3, 7}, {5, 6}, {9}, {10}.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 20 / 26
Example
Example (Minimizing a DFA)
The equivalent states:
a, b
a
b
a
a
a a
a
a a
a
b
b
b
b b
b
b b
10
6 5
9 8
4 3
7
2
1
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 21 / 26
Example
Example (Minimizing a DFA)
The simplied diagram:
a, b
a
b
a
a
a
a
b
b
b
b
10
6
9 7
2
1
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 22 / 26
Example
Example (Minimizing a DFA)
The nal diagram:
a, b
a
b
a a a b
b
b
10
6
7
2
1
b
a
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 23 / 26
Example
Example (Minimizing a DFA)
Minimize the following NFA.
a
a, b
b
a
a
a
a
a
b
b
b
b
b
7
6 5 4
3 2 1
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 24 / 26
Outline
1
Equivalent States
2
n-Equivalence
3
Minimization Examples
4
Assignment
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 25 / 26
Assignment
Assignment
Read the algorithm described in Exercise 7.40, page 299. Study it
until you understand how it is equivalent to the algorithm
presented in class.
Construct an NFA for the concatenation L
1
L
2
of the following
languages over the alphabet {a, b} and then minimize it.
L
1
= {w | the length of w is at most 1}
L
2
= {w | every odd position of w is b}.
Construct a minimal DFA for (L
1
L
2
)

where
L
1
= {w | w starts with a and has an even number of symbols}
L
2
= {w | w starts with b and has an odd number of symbols}.
Robb T. Koether (Hampden-Sydney College) Minimizing DFAs Fri, Sep 21, 2012 26 / 26

You might also like