Www.nskinfo.com && Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter:...

23
www.nskinfo.com && www.nsksofttch.com Department of nskinfo-i education CS2303-THEORY OF COMPUTATION •Chapter: Minimization of Automata 1

Transcript of Www.nskinfo.com && Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter:...

Page 1: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

www.nskinfo.com && www.nsksofttch.comDepartment of nskinfo-i education

CS2303-THEORY OF COMPUTATION

•Chapter:

Minimization of Automata

1

Page 2: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Minimized DFA

• Myhill-Nerode Theorem• DFA with minimum number of states that will

solve the problem• There may be states which are equivalent and

not necessary

Page 3: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Equivalent States

Two states p and q are said to be equivalent if and only if

for all input strings w *, both *(p, w) and *(q, w)

result in accepting states or both *(p, w) and *(q, w)

result in non accepting states.

Page 4: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Distinguishable States

Two states p and q are said to be distinguished when

there exist a string s * such that either *(p, w)

result in accepting state and *(q, w) results in a

non accepting state or vice versa.

Page 5: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

A D B

E F G H

C 0 1

0 1

0

1

0

0 1

1

0 1 1

0

0

1

Page 6: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

• By default final states of a DFA are distinguishable from non final states

• Hence in the given DFA, state C is distinguishable from other states

• To determine whether two states are equivalent we have to analyze the states reachable from the states for various strings from length 0 to some ‘n’

• Difficult hence we go for table filling algorithm

Page 7: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Table filling algorithm• Build a (n - 1) x (n - 1) table where n is the

number of states in the given DFA• Each column is named by the name of the

states starting with the first state till n-1 states• Each row is named with name of the states

starting from the second state• Duplicate cells are eliminated (i.e.) only one

cell is used to determine whether two states are equal

Page 8: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Table filling algorithm• Each cell in the table represents a pair of

states in the DFA. • Cells are marked with a “x” as soon as the two

states represented by it are decided to be distinguishable

• At the end of the process, the pairs of states corresponding to the cells of the table without the mark are concluded as equivalent states

Page 9: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Basis

If state p is an accepting and state q is a non

accepting then the pair of states {p, q} is

distinguishable.

Recursive part

Given two distinguished states r and s, if p and q are

states such that for some input symbol a, (p, a) = r

and (q, a) = s then one may conclude that the pair

of states {p, q} is also distinguishable.

Page 10: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

x x

x

x

x

x

x

B

C

D

E

F

G

H

A B C D E F G

Table after the base step in the table filling algorithm

Page 11: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Distinguishable states are analyzed, by analyzing the transition of the

states on the input symbol 0

*(A, 0) = B

*(B, 0) = G

*(D, 0) = C*

*(E, 0) = H

*(F, 0) = C*

*(G, 0) = G

*(H, 0) = G

Page 12: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

The two conditions to decide that the pair of states is

distinguishable are repeated below

(i) When one of the states moves to a non final

state on reading an input symbol and the other

one move to final state on the same symbol.

(ii) When the states in the pair moves to the states

already distinguished

Page 13: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

{A, D}, {A, F}, {B, D}, {B, F}, {D, E}, {D, G}, {D, H}, {E, F}, {F, G} and {F, H} are distinguishable as per the first condition

It may also be concluded from the above transitions, that the pair

states {D, F}, {B, G}, {B, H} and {G, H} cannot be distinguished by

strings that begin with 0, since both of the states in the pair move to

the same state on reading 0.

Page 14: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

x x

x x x

x x

x x x x

x x x

x x x

B

C

D

E

F

G

H

A B C D E F G Table after the using recursive step once in the table filling algorithm

Page 15: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

(A, 1) = F

(B, 1) = C*

(D, 1) = G

(E, 1) = F

(F, 1) = G

(G, 1) = E

(H, 1) = C*

As per the condition 1 of distinguishability, the pair of states {A, B},

{B, D}, {B, E}, {B, F}, {B, G}, {A, H}, {D, H}, {E, H}, {F, H}, {G,

H} are distinguished

Page 16: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Next distinguishability condition 2 is applied.

Using the known fact that the pair of states {E, F} and {E, G} are

distinguished, some more distinguishable pairs {A, G}, {E, G} are

obtained x

x x

x x x

x x x

x x x x

x x x x x x

x x x x x x

Page 17: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

{AE}

{BH}

{DF} G

C 1

0

0

1 0

0

1

1 0

1

Minimized DFA

Page 18: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Testing equivalence of two FA• To test whether the given two FAs M1 and M2

are equivalent it is imagined as if the two FAs are combined.

• The imaginary FA will contain m + n states in it where m is the number of states in M1 and n is the number of states in M2.

• The imaginary FA contains two initial states, initial state of M1 and M2 which is not allowed in real case.

Page 19: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Testing equivalence of two FA

• Table filling algorithm is used for the imaginary DFA. A table of size (m + n-1) x (m + n-1) is used and the two initial states are tested for equivalence.

• If they are equivalent then it may be concluded that both the DFAs represent same language.

Page 20: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

A B

0 1

1

0

DFA M1

E

C D

0 0

0 1

1

1

DFA M2

Page 21: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

x

x x

x x x

B C D E

A B C D

Page 22: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

Then transition from all the states on the symbol 0 is determined as below

(A,0) = A

(B,0) = A

(C,0) = D

(D,0) = D

(E,0) = C

No pair of states may be distinguished by looking at the

above transition since the entire set of states move to

non distinguished states on reading the symbol 0.

Page 23: Www.nskinfo.com &&  Department of nskinfo-i education CS2303-THEORY OF COMPUTATION Chapter: Minimization.

The transition of the states on the symbol 1 are analyzed as given below

(A,1) = B

(B,1) = B

(C,1) = E

(D,1) = E

(E,1) = E

transition on the symbol 1 also does not distinguish any state

Hence the pair of states {A, C}, {A, D}, {B, E}, {C, D} are equivalent.

The initial states A and C of the two given automata are

non distinguishable hence the automata M1 is

equivalent to M2