Docsity

DFA Minimization Algorithm and Pigeonhole Principle, Slides of Theory of Automata

Partial preview of the text

Download DFA Minimization Algorithm and Pigeonhole Principle and more Slides Theory of Automata in PDF only on Docsity!

DFA minimization algorithm

Example

• Construct a DFA over alphabet {0, 1} that

accepts those strings that end in 111

• This is big, isn’t there a smaller DFA for this?

qε q 0 q 1 q 00 q 10 q 01 q 11 q 000 q 001 q 101 q 111

Even smaller DFA?

• Suppose we had a 3 state DFA M for L

• We do not know what this M looks like

… but let’s imagine what happens when:

• By the pigeonhole principle, on two of these

inputs M ends in the same state

M

inputs:

Pigeonhole principle

• Here, balls are inputs, bins are states:

Suppose you are tossing m balls into n bins,

and m > n. Then two balls end up in the

same bin.

If you have a DFA with n states and you run

it on m inputs, and m > n , then two inputs end

up in same state.

A smaller DFA

• Suppose M ends up in the same state after

reading inputs x = 1

i

and y = 1

j

, where 0 ≤ i < j ≤

• Then after reading the continuation z = 1

3 – j

– The state of yz should be accepting ( yz = 111)

– The state of xz should be rejecting ( xz = ε, 1 , or 11 )

… but they are both in the same state!

M

inputs:

i

j

No smaller DFA!

• Conclusion

• So, this DFA is minimal

– In fact, it is the unique minimal DFA for L

There is no DFA with 3 states for L

q 0 q 1 q 2 q 3

Examples of equivalent states

q

0

, q

1

equivalent

q 0 q 1 q 2 q 3

q 0 q 1 q 2 q 3

q0, q

1

equivalent

q

2

, q

3

also equivalent

Equivalent and distinguishable states

  • Two states q, q’ are equivalent if
    • Here, δ(q, w ) is the state that the machine is in if it starts at q and reads the string w
  • q, q’ are distinguishable if they are not equivalent:

^

For every string w , the states δ(q, w ) and δ(q’, w ) are either both accepting or both rejecting ^ ^ For some string w , one of the states δ(q, w ), δ(q’, w ) is accepting and the other is rejecting

DFA minimization algorithm

• Find all pairs of distinguishable states as

follows:

For any pair of states q, q’:

If q is accepting and q’ is rejecting

Mark (q, q’) as distinguishable

Repeat until nothing is marked:

For any pair of states (q, q’):

For every alphabet symbol a:

If (δ(q, a), δ(q’, a)) are marked as distinguishable

Mark (q, q’) as distinguishable

For any pair of states (q, q’):

If (q, q’) is not marked as distinguishable

Merge q and q’ into a single state

Example of DFA minimization

qε q 0 q 1 q 00 q 10 q 01 q 11

q 0 q 1 q 00 q 01 q 11 q 10 qε q 0 q 1 q 00 q 01 q 10

Example of DFA minimization

qε q 0 q 1 q 00 q 10 q 01 q 11

x

x

x

x

x

x

x x x x

q 0 q 1 q 00 q 01 q 11 q 10 qε q 0 q 1 q 00 q 01 q 10

 q

1

is distinguishable from q

ε

, q0, q

00

, q

On transition 1 , they go to distinguishable states

Example of DFA minimization

qε q 0 q 1 q 00 q 10 q 01 q 11

x

x

x

x

x

x

x

x

x

x

x

x

x x

q 0 q 1 q 00 q 01 q 11 q 10 qε q 0 q 1 q 00 q 01 q 10

 q

01

is distinguishable from q

ε

, q0, q

00

, q

On transition 1 , they go to distinguishable states

Example of DFA minimization

qε q 0 q 1 q 00 q 10 q 01 q 11

A x A x A x

x

A

x

A

x

x

B

x

x

x

A

x

x

x x

q 0 q 1 q 00 q 01 q 11 q 10 qε q 0 q 1 q 00 q 01 q 10 1 qΑ qΒ qC

minimized DFA:

A

B

C

Why does DFA minimization work?

• We need to convince ourselves of three

properties:

• Consistency

– The new DFA M’ is well-defined

• Correctness

– The new DFA M’ is equivalent to the original DFA

• Minimality

M M’