Minimization of Finite Automata
Prof. (Dr.) K.R. Chowdhary
Email:
[email protected]Formerly at department of Computer Science and Engineering
MBM Engineering College, Jodhpur
Tuesday 25th August, 2015
kr chowdhary
TOC
1/ 12
Introduction to Minimization
Each DFA defines a unique language but reverse is not true.
Larger number of states in FA require higer memory and computing
power during implelemtation
An nfa of n states result to 2n states in the equivalent dfa, therefore
design of dfa is crucial.
Minimization of a dfa refers to detecting those states whose
presence or absence does not affect the language acceptability of fa.
A reduced automata consumes lesser memory, complexity of
implemenation is reduced, results to faster execution time, easier to
analyse.
kr chowdhary
TOC
2/ 12
Some definitions
Unreachable states: if (q0 , w ) = q is not true for any w , then q
is unreachable/unaccessible state.
Dead state: a, a , q is dead state if (q, a) = q and q Q F .
Reachability: FA M is accessible if w , w , and
(q0 , w ) (q, ) for all q Q. is called reachability relation.
Indistinguishable states: Two states are indistinguishable if their
behavior are indistinguishable with respect to each other. For
example, p, q are indistinguishable if (p, w ) = (q, w ) = r Q for
all w .
k-equivalence: p, q are kequivalence if:
(q, w ) F (p, w ) F ,
for all w and |w | k; written as p k q.
If they are equivalent for all k, then p k. The p q and p k q
are equivalent relations.
kr chowdhary
TOC
3/ 12
Minimization Example
one state is eliminated, and
the state which remains will
have in addition, all incoming
transitions from the removed
state.
0
0
q0
0
1
q2
q4
q6
0
q1
1
q3
q5
Similarly, the states q0 , q4 are
also indistinguishable states,
hence they can also be
merged. q3 is dead state.
0,1
Finite automata to be minimized
q6 has no role, hence it can be
removed.
q1 , q5 are indistinguishable
states because their behavior
is identical for any string
supplied at these states.
These are called equivalent
states, and can be merged. In
merging two equivalent states,
kr chowdhary
0
q0
q2
0
1
q5
q3
0,1
Minimized FA
TOC
4/ 12
Formalism for minimization
Identify and remove of
unreachable states
identify and merge of
indistinguishable states
identify and merge of dead
states.
First step: Find all reachable
states R, the non-reachable
states are Q R.
A sequence is accepted if
(q, w ) F
Indistinguishability is an
equivalence relation. Let
p, q, r Q. Let p q, if they
are indistinguishable.
p p; reflexive
p q q p; symmetry
p q, q r p r ;
transitivity, ,
indistinguishablity is an
equivalence relation.
R = {q0 }
whilep, p R a, a , and
(p, a)
/R
do
R = R (p, a)
endwhile
kr chowdhary
TOC
5/ 12
Formalism for minimization
Let x, y , then x and y
are said to be equivalent with
respect to L (i.e. x L y ), if
for some z , xy L iff
yz L.
L relation is reflexive,
symmetric, and transitive, ,
it is equivalence relation,
which divides the language set
kr chowdhary
L into equivalence classes.
For a DFA M; x, y are
equivalent with respect to M,
if x, y both derive M from a
state q0 to same state q ,
(q0 , x) = q and
(q0 , y ) = q ,
, x M y
TOC
6/ 12
minimization Example#1
0
0
q1
q0
0, 1
q3
1
1
Finite
Automata
q2
0
0, 1
0
0, 1
1
[s1]
[s0]
[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/ 12
minimization Algorithm(Table Filling Algorithm)
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 .
1
Remove inaccessible/unreachable states:
2
detele Q QR , where QR is set of accessible states.
Marking distinguishable states:
1
2
Marke 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.
construct reduced automata:
i) 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 ]
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
8/ 12
Table Filling Algorithm
Let M = (Q, , , s, F ). Remove first all the non-reachable states.
step 1. For p F and q Q F , put x in table at (p, q). This
shows that p, q are distinguishable.
/F
step 2. If w , and (p, w ) F (q, w )
mark (p, q) as distinguishable.
step 3. Recursion rule:
if (p, w ) = r , (q, w ) = s, and (r , s) were earlier proved
distinguishable, then (p, q) are also distinguishable.
kr chowdhary
TOC
9/ 12
Table Filling minimize- example
0
1
q0
q1
q3
q2
1
1
0
1
q4
0
0
q6
q5
1
q7
0
Consider that we have 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
10/ 12
Table Filling minimize- example
q1
q2
x
x
q4
q5
q6
q7
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. unmarked are
indistinguishable states.
kr chowdhary
TOC
11/ 12
Table Filling minimize- example
0
{q0, q4}
1
{q1, q7}
{q2}
1
0
0
1
{q5}
1
{q6}
Only states pairs which are not marked distinguishable are {q0 , q4 }
and {q1 , q7 } The automata shown in figure above is reduced
automata.
kr chowdhary
TOC
12/ 12