You are on page 1of 13

# Minimization of Finite Automata

## Prof. (Dr.) K.R. Chowdhary

Email: kr.chowdhary@iitj.ac.in

## Former Professor & Head, Department of Computer Sc. & Engineering

MBM Engineering College, Jodhpur

## Monday 5th December, 2016

kr chowdhary TOC 1/ 13
Introduction

## Each DFA defines a unique Minimization of a DFA refers

language but reverse is not to detecting those states
true. whose absence does not affect
Larger number of states in FA the language acceptability of
require higher memory and DFA.
computing power. A reduced Automata
An NFA of n states result to consumes lesser memory, and
2n maximum number of states complexity of implementation
in an equivalent DFA, is reduced. This results to
therefore design of DFA is faster execution time, easier to
crucial. analyze.

kr chowdhary TOC 2/ 13
Some definitions

## Unreachable states: If there their behavior are

does not exist any q , such indistinguishable with respect
that (q0 , w ) = q , then q is to each other. For example,
unreachable/unaccessible p, q are indistinguishable if
state. (p, w ) = (q, w ) = r Q
Dead state: a, a , q is for all w .
dead state if (q, a) = q and k-equivalence: p, q are
q Q F. kequivalence if:
Reachability: FA M is (q, w ) F (p, w ) F ,
accessible if w , w , and for all w and |w | k;
(q0 , w ) (q, ) for all q Q. written as p k q.
is called reachability If they are equivalent for all k,
relation. then p k. The p q and
Indistinguishable states: Two p k q are equivalent
states are indistinguishable if relations.

kr chowdhary TOC 3/ 13
Minimization Example

q0
0
q2 q4
1 and the state which remains
0 q6
1
1 0 1 0
0
incoming transitions from the
q1
1
q3
1
q5
removed state.
0,1
Similarly, the states q0 , q4 are
Finite automata to be minimized
also indistinguishable states,
hence they can also be
q6 has no role, hence it can be
removed.
q1 , q5 are indistinguishable
states because their behavior 0

0
q2

## These are called equivalent

1
states, and can be merged. q5 q3

## states, one state is eliminated, Minimized FA

kr chowdhary TOC 4/ 13
Formalism for minimization

## 1 Identify and remove all 3 Identify and merge of dead

unreachable states: find all states.
reachable states R, the 4 A sequence w is accepted if
non-reachable states are (q, w ) F
Q R.
Indistinguishability is an
equivalence relation. Let p, q, r
R = {q0 }
Q. Let p q, if they are
while p, p R a, a , indistinguishable. So,
and (p, a)
/R
p p; reflexive
{
p q q p; symmetry
R = R (p, a)
p q, q r p r ;
} transitivity, ,
2 Identify and merge of indistinguishablity is an
indistinguishable states. equivalence relation.

kr chowdhary TOC 5/ 13
Formalism for minimization

## Let x, y , then x and y L into equivalence classes.

are said to be equivalent with For a DFA M; x, y are
respect to L (i.e. x L y ), if equivalent with respect to M,
for some z , xy L iff if x, y both drive M from a
yz L. state q0 to same state q ,
L relation is reflexive,
symmetric, and transitive, , (q0 , x) = q and
it is equivalence relation, (q0 , y ) = q ,
which divides the language set , x M y

kr chowdhary TOC 6/ 13
Minimization Example#1
0

0 q1 1
0, 1

q0
q3
1
1
Finite q2
Automata
0

0 0, 1
0, 1 1
[s0] [s1] [s2]

Minimized FA

## (1) There is no unreachable state

(2) Indistinguishable states
q1 , q2 are indistinguishable, and q0 , q3 are distinguishable
(3) Reduced automata: The set of distinguishable states are:
[s0 ] = {q0 }, [s1 ] = {q1 , q2 }, [s2 ] = {q3 }.
Start and final states are [s0 ], [s2 ].
kr chowdhary TOC 7/ 13
Minimization Algorithm

## The minimization algorithm is based on the following theorem:

Theorem
Let (p, a) = p and (q, a) = q , for a . If p , q are distinguishable
then so are p, q.

Proof.
If p , q are distinguishable by wa then p, q are distinguishable by string
w.

kr chowdhary TOC 8/ 13
Minimization Algorithm(Table Filling Algorithm)

## 1 Remove inaccessible/unreachable states:

delete Q QR , where QR is set of accessible states.
2 Marking distinguishable states:
- Mark p, q as distinguishable, where p F , q /F
- For all marked pairs p, q and a , if (p, a), (q, a) is already
marked distinguishable then mark p, q as distinguishable.
3 Construct reduced automata:
- Let the set of indistinguishable(equivalent) states be sets [pi ], [qj ], . . .
such that i, j [pi ] [qj ] = and [pi ] [qj ] = QR .
- For each (pi , a) = qj , add an edge from [pi ] to [qj ]
4 Mark the start and final states:
- if q0 [pi ] then mark [pi ] as start state,
- if qf F , then mark [qf ] as final state.

kr chowdhary TOC 9/ 13
Implementation of Table Filling Algorithm

Steps:
1 Let M = (Q, , , s, F ). Remove all the non-reachable states.
2 For p F and q Q F , put x in table at (p, q). This shows that
p, q are distinguishable.
3 If w , such that (p, w ) F and (q, w )
/ F , mark (p, q) as
distinguishable.
4 Recursion rule: if (p, w ) = r , (q, w ) = s, and (r , s) were earlier
proved distinguishable, then mark (p, q) also distinguishable in the
table.

## kr chowdhary TOC 10/ 13

Example: Table Filling algorithm to minimize a FA

0
1
0 1 0
q0 q1 q2 q3

1 1

0 0 1

1 1 0
q4 q5 q6
q7
1 0

## Consider that we want to minimize the FA shown above. The state

q3 is unreachable, so it can be dropped.
Next, we mark the distinguishable states at begin as final and
non-final states. and make their entries in table as
(q2 , q0 ), (q2 , q1 ), (q4 , q2 ), (q5 , q2 ), (q6 , q2 ), (q7 , q2 ) and indicate these
by mark x.

## kr chowdhary TOC 11/ 13

Example: Table Filling algorithm to minimize a FA ...

q1 x

q2 x x

q4 x x

q5 x x x x

q6 x x x x
x

q7 x x x x
q0 q1 q2 q4 q5 q6

## Next we consider the case (q0 , 1) = q5 , (q1 , 1) = q2 . Since (q5 , q2 )

are already marked distinguishable, therefore, (q0 , q1 ) are also
distinguishable.
Like this we have filled the table shown above. The unmarked are
indistinguishable states.

## kr chowdhary TOC 12/ 13

Example: Table Filling algorithm to minimize a FA...

1
0 1
{q0, q4} {q1, q7} {q2}

1
0 0

1 1
{q5} 0
{q6}

Only states pairs which are not marked distinguishable are {q0 , q4 }
and {q1 , q7 }. The automata shown in figure above is reduced
automata.