0% found this document useful (0 votes)
49 views35 pages

Computer - New - Automata Theory Lecture 6 Equivalence and Reduction of Finite State Machines

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views35 pages

Computer - New - Automata Theory Lecture 6 Equivalence and Reduction of Finite State Machines

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

EQUIVALENCE AND REDUCTION

OF FINITE STATE MACHINES


Equivalent Machines
• If you and I independently wrote computer programs to perform the
same function it’s almost certain that our programs would be
different.

• Nevertheless it’s quite common to come across two quite different


machines that behave identically.

• Identical behaviour lies behind the concept of equivalence. Two


finite-state machines are considered to be equivalent if they produce
the same output for each input.

• Two finite-state machines are equivalent if they have the same input
alphabet (and for machines that output strings, the same output
alphabet), and if for every input string, the two machines produce
the same output.
• The concept of equivalence raises two questions. Firstly, how can we
tell if two given finite-state machines are equivalent? Even though
their alphabets are finite, there are infinitely many possible input
strings because an input string can be arbitrarily long. We cannot
possibly test them all.

• The second question concerns efficiency. If you build a 100-state


machine that is equivalent to my 1000-state machine then yours is
clearly more efficient.

• If the logic of the machine had to be incorporated into mass-produced


microprocessors then your design will save the company money.

• So the second question is whether we can take any finite-state


machine and improve it by some routine process until we obtain the
most efficient machine possible that does the same job.
• Given any finite-state machine M we can carry out two processes.

• The first, called the Reduction Process, produces a reduced


machine that is equivalent to M.

• The second process, called the Standardisation Process, relabels


the states so as to put the machine into a standard form.
• The Reduction Process: Removing Inaccessible States

• The first stage in the Reduction Process is to remove any states


that can never be reached.

• While we would certainly never create such inaccessible states on


purpose, in the process of designing a complicated machine certain
states may be created which are later by-passed by some
improvement and we may not notice that they have become isolated.

• Most computer applications contain significant sections of “dead


code”.

• A state in an FSA is inaccessible if there is no input string for


which the machine will reach that state.
Consider the following FSA

• Starting with the initial state, A, we can reach the state B (and also the black hole,
Z, since the diagram has no arrow leading out of A with a “1” label).

• From B we can get to B and D.

• From D we can reach Z and A. So starting from A the only states we can ever reach
are A, B, D and Z. The others, C, E and F are inaccessible and so can be deleted.
• The systematic way of doing this is to prepare a list of accessible states. But first
it’s a good idea to express the FSA as a state table
• The State Table for the above FSA is:

Then introduce the inaccessible


state Z, which also serves as a
state with inputs

• We begin by writing down the initial state, in this case A. Even if it’s
not possible to ever return to that state, it’s accessible simply
because we start there.
• A: look out for the input state of state “A” , write them out
• A  B Z ……….(1)
Next state of the above is state B, hence write out its inputs B
BD, putting it in equation (1) we have
• A B Z B D ….(2)
• Remove one B as B.B=B
• A B Z D …….(3)
• The next state is Z ( note that you deal with the states as they
appear in the production)
• Z ZZ
• A B Z D Z Z , taking only one Z we have
• A B Z D ………(4)
• Next is state D which has ZA as the input, simplifying, we have
• A B Z D Z A = A B Z D…..(5)
• But now there is nothing further to be considered.

• So our list of accessible states is complete. All other states are


inaccessible. So C, E and F are inaccessible and may be removed.

• We can simply erase the corresponding rows from the table to give:
• Equivalent States
• Consider the diagram bellow and find its equivalent
• Solution:
(2) Introduce the accepting states with
(1) draw the state table asterisk
• We rule up a table with as many rows as in the original table, but with many columns.

• We copy the states, and the transition table into this larger table and then copy the
accepting state column into the next column, converting *’s to 1’s and blanks to 0’s.
• The next column gives the 0-equivalence partition, “1” for accepting states
and “0” for non-accepting states. Denoted by ≡0.

• Then fill the 0ther columns by looking for the combination of each input
state and assign them the values they now assume from the 0-equivalence
column

• Fill these new combination under the new possible input values.

• The 0-equivalence and these new input values column forms a pattern to
generate the first-equivalence

• These three column starting from the first set of input pattern forms the
first-equivalence rows in order of encounter.

• Label this column starting from 0 until the last pattern is exhausted
• Then we scan those columns, together with the ≡1 column itself,
to get the ≡2 column.

• We continue in this way until we get two successive ≡k columns


being identical.
• Since 5-equivalence is identical to 4-equivalence we’ve obtained
the final partition.

• States B and D are equivalent (at all levels) so having them both
involves unnecessary redundancy.

• We can identify them (roll them up together) and so save a


state. Also, states F and G can be identified.
•Thank God, class don
finish
• For where?

• We are just starting


• Generate the first equivalence by checking pattern in the rows from
shades columns
• The Reduction Process: Identifying States

• To identify two equivalent states s and t, we select one of them, say


s, to represent them both and redirect all references to t to a
reference to s.

• Example:
• Identifying states B and D and also F and G in the above example we
get the reduced machine.

• We change all references to D to a B and change all G’s in the table


to F.
• Now we omit all repeated rows:
• Standard Form
A binary FSA with transition function T(x,y) is in standard form if:

(1) the states are labelled 0, 1, 2, 3, ...;


(2) state 0 is the initial state;
(3) if an entry in the table is greater than the maximum of those above
and to the left of it, it must be exactly one more than this maximum.

• In a nutshell, standard form means that states are labelled 0, 1, 2, ...


in the order in which they are needed as you fill out the transition
table row by row.

• Whenever a state needs a new label it is always given the next


available number.
• Example: Put the following FSA in standard form:

• Solution
• Because F is the initial state we must label it 0. Since T(F, 0) = A,
state A must be labelled “1” (the next available number).

• But T(F, 1) = F which already has a code. So far in the relabeling


process we have:
• The * that went with A is now associated with its new name, 1.

• The next blank occurs in the shaded cell and that corresponds to
T(A, 0) = S.

• Looking down the last column we note that S has not yet been
assigned a code, so it gets the next available code of 2.

• Finally Z must be relabeled as 3.

• We have now put our machine in standard form:


• Reduction of Mealy and Moore Machines
• The only modification needed in order to apply the Reduction Process
to Mealy and Moore machines is in the setting up of 0-equivalence.

• For a Mealy machine, where the output depends on the combination


of the current state and the input character, two states are 0-
equivalent if, for each input character, the same output results from
each state.

• In other words two states are 0-equivalent if the entries in the P-


table are identical.

• For a Moore machine, where the appropriate output is printed as the


machine enters a state, two states are 0-equivalent if and only if
they produce the same output.
• Example: Solution: All states are accessible.
• Reduce the Mealy machine The state table is:
• Checking for equivalence:

• Identifying states A and D we get:


• Finally putting it in standard form we have
• Example:
• Reduce the Moore machine:


• Solution: All states are accessible.
Identifying state C with B and D with A: Putting it in standard form we get:
• Class done finish

• make una dey go

You might also like