0 ratings0% found this document useful (0 votes) 173 views36 pagesModule 1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
The Theory of
Automata
In this chapter we begin with the study of automaton. We deal with transition
systems which are more general than finite automata. We define the
acceptability of strings by finite automata and prove that nondeterministc finite
automata have the same capability as the deterministic automata as far as
acceptability is concemed. Besides, we discuss the equivalence of Mealy and
Moore models, Finally, in the last section. we give an algorithm to construct a
minimum state automaton equivalent 10 4 given finite automaton,
3.1 DEFINITION OF AN AUTOMATON
We shall give the most general definition of an automaton and later modify
it to computer applications. An automaton is defined as a system where
energy, materials and information are transformed, transmitted and used for
performing some functions without direct participation of man. Examples are
‘automatic machine tools, automatic packing machines. and automatic photo
printing machines,
In computer science the term ‘automaton’ means ‘discrete automaton’ and
is defined in a more abstract way as shown in Fig. 3.1
4 Automaton |-——+ 0,
au teins Log
Fig. 3.1 Model of a discrete automaton,
7The characteristics of automaton are now described.
(i) Input. At each of the discrete instants of time 1). fy... fy the input
values 1h. Is, «++ yp each of which can take a finite number of fixed
values from the input alphabet £, are applied to the input side of the
model shown in Fig. 3.1
(ii) Ouput. 04, Os, .... Oy are the outputs of the model, each of which
can take a finite number of fixed values from an output 0.
(ii) States. At any instant of time the automaton can be in one of the
SALES iy Gy Me
Gy) State relation. The next state of an automaton at any instant of time
is determined by the present state and the present input,
(\) Output relation. The output is related to either state only or to both
the input and the state. It should be noted that at any instant of time
the automaton is in some state. On ‘reading’ an input symbol, the
automaton moves to a next state which is given by the state relation
Note: An automaton in which the output depends only on the input is called
{an automaton without a memory. An automaton in which the ousput depends
‘onthe states as well is called automaton with a finite memory. An automaton
in which the output depends only on the states of the machine is called a
Moore machine. An automaton in which the output depends on the state as
well as on the input at any instant of time is called a Mealy machine.
Consider the simple shift register shown in Fig, 3.2 as a finite-state machine
and study its operation.
Serial
input
>
pe Ps >
Fig. 3.2 A 4-bit serial shift register using D flip-fops.
Solution
‘The shift register (Fig. 3.2) can have 2* = 16 states (0000, 0001, .... LID).
and one serial input and one serial output. The input alphabet is Z = (0. 1).
and the output alphabet is O = (0. 1}. This 4-bit serial shift register can be
further represented as in Fig. 3.3.Chapter 3: The Theory of Automata Si 73
} ange
Fig. 3.3. A shift register as 2 finite-state machine
From the operation. it is clear that the output will depend upon both the input
and the state and so it is a Mealy machine.
Tn general. any sequential machine behaviour can be represented by an
automaton,
3.2 DESCRIPTION OF A FINITE AUTOMATON
Definition 3.1 Analytically. a finite automaton can be represented by a
Setuple (Q. E. 6. go. FY. where
() Q isa finite nonempty: set of states
Gi) E is a finite nonempty set of inputs called the inpur alphaber.
(iii) dis a function which maps Q into Q and is usually ealled the direct
transition fiction. This is the function which describes the change of
states during the transition. This mapping is usually represented by a
transition table or a transition diagram.
(iv) qo € Q is the initial state.
() F< Qis the set of final states. It is asstumed here that there may be
more than one final state
Note: The transition function which maps Q x E* into Q (ie. maps a state
and a string of input symbols including the empty string into a state) is ealled
the indirect sransition function. We shall use the same symbol 6 to represent
both types of transition functions and the difference can be easily identified
by the nature of mapping (symbol or a string). ie. by the argument. 6 is also
called the nest state function. The above model can be represented graphically by
Fig. 34.
iaeeeeeeeed/tiescea:
f ] TTT | |
c ] | input
| LL | tape
—— Reading head
Fig. 3.4 Block diagram of @ finite automaton74 Si Theory of Computer Science
Figure 3.4 is the block diagram for a finite automaton, The various
components are explained as follows:
(i) Input tape. The input tape is divided into squares. each square
containing a single symbol from the input alphabet E. The end squares
Of the tape contain the endmarker q at the left end and the end-
marker § at the right end. The absence of endmarkers indicates thai
the tape is of infinite length. The left-to-right sequence of symbols
between the two endmarkers is the input string to be processed.
(ii) Reading head. ‘The head examines only one square at a time and can
‘move one square either to the left or to the right. For further analysis
‘we restrict the movement of the R-head only to the right side
ii) Finite control. The input to the finite control will usually be the
symbol under the R-head, say a, and the present state of the machine,
say g, to give the following outputs: (a) A motion of R-head along
the tape to the next square (in some a null move, ie. the R-head
remaining to the same square is permitted); (b) the next state of the
finite state machine given by 5(q, a).
3.3. TRANSITION SYSTEMS
Actransition graph or a transition system is a finite directed labelled graph in
which each vertex (or node) represents a state and the directed edges indicate
the transition of a state and the edges are labelled with imput/output.
A typical transition system is shown in Fig. 3.5. In the figure, the initial
state is represented by a circle with an arrow pointing towards it, the final state
by two concentric circles, and the other states are represented by just a circle.
‘The edges are labelled by input/output (e.g. by 1/0 or 1/1). For example. ifthe
system is in the state gy and the input 1 is applied, the system moves to state
4) as there is a directed edge from gy to gy with label 1/0, It outputs 0.
oo 10 wn
Qn
%
00
Fig. 35 A transition system
‘We now give the (analytical) definition of a transition system,
Definition 3.2 A transition system is a S-tuple (Q, E, & Qp, F), where
(i) Q, ¥ and F are the finite nonempty set of states, the input alphabet,
and the set of final states, respectively, as in the case of finite automata;
(ii) Qy © Q and Qp is nonempty: and
ii) Sis a finite subset of Q x E° x Q.Chapter 3: The Theory of Automata 8. 75
In other words, if (gy, q3) is in 6. it means that the graph starts at the
vertex qy, goes slong a set of edges, and reaches the vertex qs. The
concatenation of the label of all the edges thus encountered is ws:
Definition 3.3 A transition system accepts a string w in E* if
(i) there exists @ path which originates from some initial state, goes
along the arrows, and terminates at some final state; and
Gi) the path value obtained by concatenation of all edge-labels of the path
is equal t0 w
Eee
Consider the transition system given in Fig. 3.6.
0
Fig. 3.6 Transition system for Example 3.2.
Determine the initial states. the final states. and the acceptability of 101011,
111010.
Solution
The initial states are qo and qy. There is only one final state, namely ¢
The path-value of goqegods is 1OI0LL, AS qs is the final state, 101011 is
accepted by the transition system, But, 111010 is not accepted by the transition
system as there is no path with path value 111010.
: Every finite automaton (Q, qo. F) can be viewed as a transition
system (Q, £, 6” Qp, F) if we take Qy = {go} and 8’ = [(g, w, dg, wg €
Q, w @ E*}, But a transition system need not be a finite automaton. For
example. a transition system may contain more than one initial state.
3.4 PROPERTIES OF TRANSITION FUNCTIONS
Property 1 6(q, A) = q is finite automaton, This means that the state of the
systemn can be changed only by an input symbol.76 Theory of Computer Science
Property 2 For all strings w and input symbols «
6iq, an) = 6, a), W)
6(q, wa) = 65g, w), a
This property gives the state after the automaton consumes or reads the
first symbol of @ siring aw and the state after the automaton consumes a prefix
of the string wa,
Sze
Prove that for any transition function & and for any two input strings x and y;
6g, wy) = 6(8(q. oY) GA)
Proof By the method of induction on |y’|, ie. length of »:
Basis: When |y|= Ly sae =
LHS. of B.)= 5g. x0)
= 5(6(q, 9, a) by Property 2
RHS. of 3.1)
Assume the result, ic. (3.1) for all strings x and strings y with [| = a. Let
y be a string of length m+ 1. Write y= yy@ where [yy| = 1
LHS. of (G1) = 6g, sya) = 8g. x, ey
68g, 8). a) by Property 2
45g, 0).
Sq, 2), 1), a) by induction hypothesis
RES. of G1) = 65q. 01 9)
= GHG, yy), aby Property 2
Hence, LHS. = RHS. This proves (3.1) for any string y of length m + 1.
By the principle of induction, (3.1) is true for all strings, 1
EXAMPLE 3.4
Prove that if 6(q, x) = 6(g, »), then 5¢g,
6(q, 32) for all strings < in E*
Solution
6a, (6G, ». by Example 3.3
851g, », ©
82
By Example 3.3.
iq, 5) = HBLG, J. 2
= 8g, x Ba)Chapter 3:
3.5 ACCEPTABILITY OF A STRING BY A FINITE
AUTOMATON
Definition 3.4 A string « is accepted by a finite automaton
M=(Q.E. 8 40 FY
if igo. x) = @ for some qe F.
This is basically the acceptability of a string by the final state
Note: A final state is also called an accepting state
EXAMPLE 3.
Consider the finite st
i¢ machine whose transition function is given by Table 3.1
in the form of a transition table. Here. Q = {go 41, 2 dsl. E = (0, 1)
F = (qo). Give the entire sequence of states for the input string 110001
TABLE 3.1. Transition Function Table for Example 3.5
State
5 5
7 & 3
4 ® a
@ % @
4 s &
Solution
L 4
&qy. HOLO1) = dq. 10101)
= 6(qo,0101)
4
= digs 101)
1
= 5iq3.01)
L
lq)
= 5g A)
=a
Hence.
La kg & ae
0 > > Io 2 > 49 > dy
The symbol 4 indicates that the current input symbol is being processed by the
machine78 ©. Theoryof Computer Science
3.6 NONDETERMINISTIC FINITE STATE MACHINES
We explain the concept of nondeterministic finite automaton using a transition
diagram (Fig. 3.7)
3.7. Transition system representing nondeterministic automaton.
Tf the automaton is in a state {qo} and the input symbol is 0, what will be
the next state? From the figure itis clear that the next state will be either (4o}
or {qu}. Thus some moves of the machine cannot be determined uniquely by
the input symbol and the present state, Such machines are called
nondeterministie automata. the formal definition of which is now given
Definition 3.5 A nondeterministic finite automaton (NDFA) is a S-tuple
(3.6 do, F), where
(] Qis a finite nonempty set of states:
(i) Z is a finite nonempty set of inputs
Gi) 3s the transition function mapping from Q x & into 2 which is the
power set of @, the set of all subsets of Q:
iv) go © Q is the initial stare: and
(8) FS Qs the set of final states.
We note that the difference between the deterministic and nondeterministie
automata is only in 6. For deterministic automaton (DEA), the outcome is a
state, ie, an element of Q; for nondeterministic automaton the outcome is a
subset of @.
‘Consider, for example, the nondeterministic automaton whose transition
diagram is described by Fig. 3.8.
‘The sequence Uf sates for die input suing 0100 is givew in Fig. 3.9. Hence,
qu 0100) = {90 4x da}
Since q, is an accepting state, the input string 0100 will be accepted by
the nondeterministic automaton.Chapter 3: The Theory of Automata S79
%—* % ——+ a) —2 9 — %
VN NY
\
:
Fig. 3.9 States reached while processing 0100.
Definition 3.6 A string w = Z* is accepted by NDFA M if (qo, ) contains
some final state
Note: As M is nondeterministic. 5(gq, ) may have more than one state. So
ww is accepted by M if a final state is one among the possible states that M can
reach on application of
We can visualize the working of an NDFA M as follows: Suppose M
reaches a state q and reads an input symbol a. Tf 6g, a) has » elements
the automaton splits inom identical copies of itself: each copy pursuing
fone choice determined by an element of 5g, a). This type of parallel
computation continues. When a copy encounters (g. a) for which 6(q, a) = 0,
this copy of the machine ‘dies’; however the computation is pursued by the
other copies. If any one of the copies of M reaches a final state after
processing the entire input string w. then we say that M accepts w. Another
‘way of looking at the computation by an NDFA M is to assign a tree structure
for computing 6(q, w). The root of the tree has the label g. For every input
symbol in ve. the tree branches itself. When a leaf of the tree has a final state
as rts label. then M accepts
Definition 3.7 The set accepted by an automaton M (deterministic or
nondeterministic) is the set of all input strings accepted by M. It is denoted by
TM).80_& Theory of Computer Science
3.7 THE EQUIVALENCE OF DFA AND NDFA
We naturally try to find the relation between DFA and NDFA. Intuitively we
now feel that
(i) A DPA can simulate the behaviour of NDFA by increasing the number
of states. (In other words, a DFA (Q, 3, & qo F) can be viewed as an
NDFA (Q, 3, 8", qo. F) by defining 5(q, a) = (51g, «)}.)
(i) Any NDFA is a more general machine without being more powerful
We now give a theorem on equivalence of DFA and NDFA.
‘Theorem 3.1 For every NDFA, there exists a DFA which simulates the
‘behaviour of NDFA. Alternatively, if J is the set accepted by NDFA, then there
exists a DFA which also accepts L.
Proof Let M=(Q. . & qo F) be an NDFA accepting L. We construct a DFA
Mas:
MOE 6 Ge PY
where
( @ = 22 (any state in Q" is denored by [a qo. ++ Gh Where gy 4
4g = Qy
Gi) a'y = Lgok: and
(iil) F* is the set of all subsets of Q containing an element of F,
Before defining 5% let us look at the construction of Q', gy and F’. M is
initially at go, But on application of an input symbol, say a, M can reach any
of the states 6(qu. a). To describe M, just after the application of the input
symbol a, we require all the possible states that Mf can reach after the
application of a. So, M”has to remember all these possible states at any instant
of time. Hence the states of MM’ are defined as subsets of Q. As M starts with
the initial state qo. 4% is defined as [qq]. A string w belongs to T(M) if a final
siate is one of the possible states that M reaches on processing w: So, a final
state in M’ (ie. an element of F’) is any subset of Q containing some final
state of M.
Now we can define 8%
Gv) Big. 4 «gh. a) = 6(q, a) U Bly aU... U BGs a)
Equivalently.
Sli. gm vom gi = Be ve Bl
if and only if
Slay... 6 Gib a) = [Py Ps Pit
Before proving L = T(M’), we prove an auxiliary result
8d = [d. «- + ah Gay
if and only if 8iqo, x) = {q). --» qi} for all x in E*
We prove hy induction on [x]. the “iP par,
Sai = Lae geo Gd Bs)
if ig. 3) = 4)Chapter 3: The Theory of Automata S81
When |x| = 0. S(qy A) = {ay}. and by definition of 6; d(qj, A) =
46 = [ao]. So. (3.5) is true for x with |x] = 0. Thus there is basis for induction
‘Assume that (3.5) is true for all strings y with |v] $m. Let x be a
string of length m + 1, We can write x as va, where |y| =m and ae E Let
(go. 9) = (Pie oe pi and Blqy. va) = (rr, vo Tu) As [yh Sm by
induction hypothesis we have
Sigh. YY = IPv Pil 3.6)
Also.
(ry Py ri) = lq, Ya) = HSlqa. 99. a) = Bp, ) a)
By definition of 6;
Pn pik a) = fr vd G7)
Hence,
SUgh. xa) = 818g. 9. @) = SUP. +s Pe @ by GH)
Fir. nd by G7
Thus we have proved (3.5) for x = va
By induction, (3.5) is true for all strings x. The other part t.e. the ‘only if
part), can be proved similarly. and so (3.4) is established.
Now. x € T(M) if and only if &(g, 2x) contains a state of F. By G4).
Bide x) Contains a state of F if and only if 54g’ x) is in F’, Hence. x € TM)
if and only if x = TUM’). This proves that DFA M' accepts LU
Note: In the constriction of a deterministic finite automaton M, equivalent to
2 given nondeterministie automaton , the only difficult par is the construction
of 6” for M;. By definition,
Fg --- who) = US. a)
So we have to apply 6 to (g,, a) for each f= 1. 2 .... k and take their
union to get 6g: ».- gah ad.
‘When 6 for M is given in terms of a state table. the construction is simpler.
5iqi, a) is given by the row corresponding to q and the column corresponding
to a. To construct 5'(q) «.. qh a). consider the states appearing in the rows
corresponding 10 gy...» gi. and the column corresponding to a. These states
constitute 3g, ... gal a
Note: We write 3” as 6 itself when there is no ambiguity. We also mark the
initial state with + and the final state with a circle in the state table.
Bae
Construct a determin:
M = (dy, ai)- (0. 1}. & an tao)
where 5 is defined by its state table (see Table 3.2),
tic automaton equivalent t0Computer Science
TABLE 3.2. Siate Table for Example 36
Solution
For the deterministic automaton My
(the states are subsets of (go. qh ie. O. fgoh (ao. gib [aik:
i) {gol is the initial state:
ii) [aol and [qo. qi] are the final states as these are the only states
containing gy: and
iv) Bis defined by the state table given by Table 3.3
TABLE 3.3. State Table of My for Example 36
Stator ° 1
6 0 9
la (asl fl
la fal las ai
te ad Ide gd Mad
“The states gy and q, appear in the rows corresponding t0 qo and q, and the
column corresponding to 0. So. S({qy. aib 9) = (ao. a1)
When Mf has m states, the corresponding finite automaton has 2" states
However, we need not construct 5 for all these 2" states, but only for those
states that are reachable from [go]. This is because our interest is only in
constructing M accepting T(M). So, we start the construction of 6 for (gol. We
continue by considering only the states appearing earlier under the input
columns and constructing 8 for such states. We halt when no more new states
appear under the input columns.
EXAMPLE 3.7
Find a deterministic acceptor equivalent to
M
{oe Gi aah: {ay bbs 8 dos Aa)
where 6 is as given by Table 3.4
TABLE 3.4. Stale Table for Example 37
Staten aChapter 3: The Theory of Automata _@ 83
Solution
‘The deterministic automaton M, equivalent to M is defined as follows:
M. = 2% {ab} & [aah
where
F = {la2h (o- 92h far. a2) [40 a1. G2)
We start the construction by considering [qo] first. We get [q:] and (qo. 4s]. Thon
we construct for [qs] and {go. 41}. (gr. 43] is @ new state appearing under the
inpat columns. After constructing 6 for [qy, qa}. we do not get any new states
and so we terminate the construction af 8. The state table is given by Table 3.5,
TABLE 3.5 State Table of M. for Example 37
‘State @ >
Tad (a. a) fea
(eal 9 fas. a
(a. a fan a)
(ad fay. ad
Bes)
Construct @ deterministic finite automaton equivalent to
M = (haw ay 93 a2h (0. 1D). & gos (gob)
where 8 is given by Table 3.6.
TABLE 3.6 State Table for Example 28
Sato a >
sae a % @
e @ a
a @ ®
@ a
Solution
Let Q = {go 91, 95 42)- Then the deterministic automaton IM, equivalent to
M is given by
M.= 22 {a bb. & taol FY
where F consists of:
Lash (ao. ash Uae Gah Cae ash ba 91. Goh ao 9 Gels Wie toe a2)
ane
Los i. aes 95)
and where d is defined by the state table given by Table 3.7.84 9 Theory of Computer Science
TABLE 3.7 State Table of M; for Example 3.8
‘Staiel
cs}
tas. ad
(a5. ay a3) las gy. 03}
9. 4 a) la. Gy.)
fas. a Ge {aoa Gaal
3.8 MEALY AND MOORE MODELS
3.8.1 FINITE AUTOMATA WITH OUTPUTS
The finite automata which we considered in the earlier seetions have binary
output. ie. either they accept the string or they do not accept the string. This
acceptability was decided on the basis of reachability of the final state by the
initial state, Now, we remove this restriction and consider the model where the
outputs can be chosen from some other alphabet. The value of the output
function Zit) in the most general case is a function of the present state g(#) and
the present input x11), i
Zany = Hain x0)
where A is called the output funetion. This generalized model is usually called
the Mealy machine. If the output funetion Zi#) depends only on the present state
and is independent of the current input, the output function may be written as
Zit) = Het)
This restricted model is called the Moore machine. I is more convenient to use
Moore machine in automata theory. We now give the most general definitions
‘of these machines,
Defi
jon 3.8 A Moore machine is a six-tuple (Q. 5, 4. & A, qo). where
(i) is a finite set of states:
fii) E is the input alphaber:
(iii) 4 is the output alphaher:
Liv) 8 is the transition function E x Q into Q:
(v) Ais the output function mapping Q into A; and
(si) go is the initia stare
Definition 3.9 A Mealy machine is a six-tuple (Q, EA. 6. A go), where
all the symbols except 4 have the same meaning as in the Moore machine, 2.
is the output funetion mapping © x Q into 3.
For example. Table 3.8 describes a Moore machine. The initial state qy is
marked with an arrow. The table defines 5 and 2.Chapter 3: The Theory of Automata @ 85
TABLE 3.8 A Moore Machine
Present stato Naw! state 6 Output
For the input string O111, the ransition of states is given by gq > qs >
9 > 4 > 42 The output string is 00010, For the input string A, the output
is Ago) = 0.
Transition Table 3.9 describes a Mealy machine
TABLE 3.9 A Mealy Machine
Present state
wate ipa
aa o
e o
% 1
on o
Note: For the input sting 0011. the transition of states is given by gh —¥ gs
ga ds and the ouput string is 0100. In the case of a Mealy machine.
‘we get an ourput only’ on the application of an input symbol. So for the input
string A the output is only A. It may be observed that in the case of a Moore
machine. we get Algj) for the input string A.
Remark A finite automaton can be converted into a Moore machine by
introducing A = (0. 1) and defining A(q) = 1 if g ¢ F and Ag) = 0 if
a2F.
For a Moore machine if the input string is of length n, the output string
is of length m + L. The first output is A(qo) for all output strings. In the case
of a Mealy machine if the input string is of length m, the output string is also
of the same length 12
3.8.2 PROCEDURE FOR TRANSFORMING A MEALY MACHINE
INTO A MOORE MACHINE
Ws develop procedures for transforming a Mealy machine into a Moore
‘machine and vice versa so that for a given input string the output strings are the
same (except for the first symbol) in both the machines.86_& Theory of Computer Science
EXAMPLE 3.
Consider the Mealy machine deseribed by the transition table given by
Table 3.10. Construct a Moore machine which is equivalent to the Mealy
machine.
TABLE 3.10 Mealy Machine of Example 3.9
Present state Next slate
wate
a % °
a °
a a ‘
aw eee o
Solution
At the first stage we develop the procedure so that both machines accept
exactly the same set of input sequences. We look into the next state column
for any state, say q,, and determine the number of different outputs associated
with. qin that column.
We split q, into several different states, the number of such states being
equal to the number of different outputs associated with q, For example. in this,
problem, qi is associated with one output I and q: is associated with two
different outputs 0 and 1. Similarly. 5 and qg are associated with the outputs
and 0. 1. respectively. So. we split g> into gay and gy.. Similarly, qs is split
into gan and gz). Now Table 3.10 can be reconstructed for the new states as
given by Table 3.11
TABLE 3.11 State Table for Example 39
Present state Next state
Input a
wae
94: % 0 a
a 1 tw
os a 1 we
a 1 a
ae 1 %
ae 1 %
The pair of states and outputs in the next state column can be rearranged as
given by Table 3.12.Chapter
: The Theory of Automata
TABLE 3.12, Revised State Table for Example 3.8
Prosent state Next state ouput
a %
1
ca 9 . °
m 3 % 4
% % @ °
a, % @ D
a a % 1
Table 3.12 gives the Moore machine, Here we observe that the initial state
4 is associated with output 1, This means that with input A we get an output
of 1, if the machine starts at state q,. Thus this Moore machine accepts a zero
length sequence (null sequence) which is not avcepted by the Mealy machine,
To overcome this situation, either we must neglect the response of a Moore
machine (0 input A, or we must add a new starting state qj, whose state
transitions are identical with those of q, but whose output is 0. So Table 3.12
is transformed 10 Table 3.13.
TABLE 3.13. Moore Machine of Example 3.9
Present state Next state Output
os
From the foregoing procedure it is clear that if we have an m-output, 1-
stare Mealy machine. the corresponding m-output Moore machine has no more
than nm + 1 states.
3.8.3 PROCEDURE FOR TRANSFORMING A MOORE MACHINE
INTO A MEALY MACHINE
We modify’ the acceptability of input string by a Moore machine by neglecting
the response of the Moore machine to input A. We thus define that Mealy
Machine M and Moore Machine M’ are equivalent if for all input strings w,
b7 hve) © Ziplos), where b is the output of the Moore machine for its initial
state, We give the following result: Let M; = (Q. , A. d A, qy) be a Moore
machine, Then the following procedure may be adopted t0 construct an
equivalent Mealy machine Ms.88_@ Theory of Computer Science
Construction
(i) We have to define the output function 2 for the Mealy machine as
a function of the present state and the input symbol, We define 2’ by
H(q, a) = MS{a, «)) for all states q and input symbols a
(ii) The transition function is the Same as that of the given Moore
‘machine.
EXAMPLE 3.10
Consteuet « Mealy Machine which is equivalent to the Moore machine given
by Table 3.14.
TABLE 3.14 Moore Machine of Example 3.10
Present state
a
%
%
Solution
We must follow the reverse provedure of converting a Mealy machine into a
‘Moore machine. In the case of the Moore machine, for every input symbol we
form the pait consisting of the next state and the corresponding output and
reconstruct the table for the Mealy Machine. For example. the states q3 and qy
in the next state column should be associated with outputs 0 and i, respectively
The transition table for the Mealy machine is given by Table 3.15.
TABLE 3.15 Mealy Machine of Example 3.10
Prasent state Next state
auto Sao att
0 a 1
1 % °
° a °
° & °
Note: We can reduce the number of states in any model by considering states
with identical transitions. If two states have identical wansitions (i.e. the rows,
corresponding t these two states are identical), then we can delete one of ther.
EXAMPLE 3.11
Consider the Moore machine described by the transition table given by
Table 3.16. Construct the corresponding Meuly machine.Chapter 3: The Theory of Automata 89
TABLE 3.16 Moore Machine of Example 3.11
Next state Cutpot
a ©
% 6
% pa
Solution
We construct the transition table as in Table 3.17 by associating the output
with the transitions,
In Table 3.17. the rows corresponding to > and qs are identical. So, we ean
deleie one of the two states. ie. gz or qs. We delete gs. Table 3.18 gives the
reconstructed table
TABLE 3.17 Transition Table for Example 3.11
Present stare Next state
TABLE 3.18 Mealy Machine of Example 3.11
Prasant st
Noxt state
In Table 3.18. we have deleted the qs-row and replaced qs by q2 in the other
Consider a Meaiy machine represented by Fig. 3.10, Construct a Moore
machine equivalent to this Mealy machine908 Theory of Computer Science
Start
Wy
Fig. 310 Mealy machine of Example 3.12
Solution
Let us convert the transition diagram into the transition Table 3.19. For the
given problem: q, is not associated with any output; q> is associated with Iwo
different outputs Z, and Zs: dy is associated with two different outputs Z, and
Zp, Thus we must split g> into qs) and qo» with outputs Z; aud Z,, respectively
and qs into qs, and gs> with outputs Z; and Z,, respectively. Table 3.19 may be
reconstructed as Table 3.20.
TABLE 3.19 Transition Table for Example 3.12
Present state Next state
%
a
TABLE 3.20 Transition Table of Moore Machine for Example 3.12
Present state Next state Output
Taso et
a a
a
om
ae
ae
Figure 3.11 gives the transition diagram of the required Moore machine.Chapter 3: The Theory of Automata © 91
Fig. 3.11 Moore machine of Example 3.12
3.9 MINIMIZATION OF FINITE AUTOMATA
In this section we construct an automaton with the minimum number of states
equivalent to a given automaton Mf.
As our interest lies only in strings accepted by M, what really matters is
whether a state is a final state or not, We define some relations in Q.
Definition 3.10 Two states q, and qy are equivalent (denoted by qy = 42) if
both 8{qy, x) and (qx) are final states. oF both of them are nonfinal states
for all xe E*
As it is difficult to construct &(q,, x) and &{qs, x) for all x € E* (there
are an infinite number of strings in E*). we give one more definition
Definition 3.11. Two states q, and q; are K-equivalent (k 2 0) if both
iq, x) and 4(q>. x) are final states or both nonfinal states for all strings x
of length kor less. In pecticular, any two final states are O-equivalent and any
two nonfinal states are also O-equivalent
We mention some of the properties of these relations.
Property 1 The relations we have defined, ic. equivalence and k-equivalenee,
ate equivalence relations. i.e. they are reflexive. symmetric and transitive.
Property 2 By Theorem 2.1. these induce partitions of Q. These partitions
can be denoted by and 7. respectively. The elements of 7; are k-equivalence
classes.
Property 3 If q, and g: are k-equivalent for all k2 0. then they are equivalent.
Property 4 If q; and qs are (k + L)-equivalent. then they are k-equivalent.
Property § x, = Myx for some n. (x, denotes the set of equivalence classes
under n-equivalence,)
The following result is the key to the construction of minimum state
automaton,
RESULT Two states g and gz are (k + L)-equivalent if (i) they are
A-equivalent; (ii) 6(q,, a) and 6(q3 a) are also k-equivalent for every a € E.92S Theory of Computer Science
Proof We prove the result by contradiction. Suppose q, and q> are not
(c+ Deequivatent. Then there exists a string w= aw, of length k + 1 such that
8(q), cov) is a final state and 5¢qz, aw,) is not a final state (or vice versa; the
proof is similar). So 6(8(q), a), w)) is a final state and 8(8(q>, a), wy) is not
4 final state, As w) is a string of length & S(q,, a) and S(qy, a) are not
equivalent. This is a contradiction, and hence the result is proved. 1
Using the previous result we can construct the (k + 1)-equivalence classes
once the K-equivalence classes are known.
3.9.1 CONSTRUCTION OF MINIMUM AUTOMATON
Step 1 (Construction of n). By definition of 0-equivalence, m = {Q?, O89}
where Qf is the set of all final states and Q? = Q- 0?
Step 2 (Construction of 7j.; from 7). Let Q be any subset in m. If q, and
gz are in Qf, they are (K+ 1)-equivalent provided 5(q,, a) and 6(q3, a) are
equivalent, Find out whether 5(q), a) and 5(q>, a) are in the same equivalence
class in m, for every a ¢ E. Hf so. gi and q: are (k + 1)-equivalent. In this way,
Q} is further divided into (k + 1)-equivalence classes. Repeat this for every Qi
in to get all the elements of Z,}
Step 3. Consiruc
Step 4 (Construction of minimum automaton). For the required minimum
state automaton, the states are the equivalence classes obtained in step 3. i.e. the
elements of #,. The state table is obtained by replacing a state q by the
corresponding equivalence class [q)
my form = 12... until m= Fy
Remark In the sbove construction, the crucial part is the construction of
equivalence classes: for, after getting the equivalence classes, the table for
‘minimum automaton is obtained by replacing states by the corresponding
equivalence classes. The number of equivalence classes is less than or equal to
10. Consider an equivalence class {] = (gy. az =.» dx} If gy is reached
while processing ws € TUM) with (aq, w;) = gi, then 5(g, w:) © F. So,
Sigg 3) F for i= 2. ....& Thus we see that 9}. 7 = 2, .... kis reached on
processing some w € T(M) iff qy is reached on processing w, Le. q, of [qi] can
play the role of q».. qs. The above argument explains why we replace a state
by the corresponding equivalence class.
Note: The construction of m, 7, m ete. is easy when the transition table
is given, m = (0°, 09}. where QP = F and Q? = Q ~ F. The subsets in
1% are obtained by further partitioning the subsets of a. If gi. gz © QP,
consider the states in each a-column, where a € E corresponding to q, and 4»
If they are in the same subset of m, qy and qy are I-equivalent. If the states
under some a-column are in different subsets of %, then g, and qy are not
L-equivalent. In general, ( + 1)-equivalent states are obtained by applying the
above method for q and qs in OF__Ghapter 3: The Theory of Automata _@ 93
Ez
Construct a minimum state automaton equivalent to the finite automaton
described by Fig. 3.12.
Fig. 3.12 Finite automaton of Example 3.13,
Solution
It will be easier if we construct the transition table as shown in Table 3.21
TABLE 3.21 Transition Table for Example 3.13
By applying step 1, we get
OP = F = {qh
So.
Ry = [142]. {do i 9% Ge Os Ie ah}942 Theory of Computer Science
The {q:) in m cannot be further panitioned. So, Q', = {q}. Consider qo and
4a; € 8. The entries under the O-cclumn corresponding 10 gp and qj; are 4)
and qg: they lie in O°. The entries under the 1-column are gs and qo. q> €
0? and qe € Q2. Therefore, qo and q, are not L-equivalent. Similarly. qo is
not I-equivalent to q:. gs and 4)
Now, consider qy and qs. The entries under the O-column are q; and 4
Both are in QS. The entries under the 1-column are qs, qs- So qs and qo are
L-equivalent. Similarly. gq is I-equivalent to gg. {qo gu do) is a subset in 7,
So, Os = ta da ah:
Repeat the construction by considering q, and any one of the states
45. gs. dr- Now, gy is not L-equivalent to qs or gs but I-equivalent to qr. Hence,
0% (4, qr}. The elements left over in Q! are qs and gs. By considering the
entries under the O-column and the I-column, we see that gs and ge ate
equivalent, So Qs = {gz 4s). Therefore.
= Uda}. (do de Gols (aie rhe (gs ash}
‘The’ (q3} is also in zt; as it cannot be further partitioned. Now. the entries
under the O-column corresponding 10 qo and g, are g; and qr, and these lie
in the same equivalence class in m, The entries under the L-column are qs,
qs So qy and qy are 2-eqnivalent, But qy and gy are not 2-equivatent. Hence.
{ao 40 go} is partitioned into (qo, 94} and (qg)- q, and qr are 2-equivalent
gz and gs ate also 2-equivalent. Thus. = {{qo}. {do dal. {gels (au ah
fas. qsh}- gy and gy are 3-equivalent. The q, and qr are J-equivalent, Also,
gz and qs are 3-equivalent. Therefore.
Y Udiv Gabe tgols Lane arb fare ash
AS Ms = my My gives us the equivalence classes. the minimum state automaton
m= Ly
= 410.1). 6 4%. FY
where
Q°= (ash [dos dah lash Lave ash fas 5)
qo (do ask F’= (aad
and 6 is defined by Table 3.22.
TABLE 3.22 Transition Table of Minimum State
Automaton for Example 3.13
‘Stators 1
(as. ad fa. od fe. ad
fa. a (eel taal
fal fas, aa tel
fas. a8) (al laa
teal ta (> a)— Chapter 3: The Theory of Automata _& 95
Note: The transition diagram for the minimum state automaton is described
by Fig. 2.13, The states qo and q, are identitied and treated as one state
(So also are qj, gy and qs, qx) But the transitions in both the diagrams (ie.
Figs. 3.12 and 3.13) are the same. If there is an arrow from q; to q; with label
@. then there is an arow from [qi] 1 {gd with the same label in the
diagram for minimum state automaton. Symbolically, if Bq. a) = gp then
Sg. a) = tg).
Fig. 3.13 Minimum state automaton of Example 3.13.
Construct the minimum stare automaton equivalent to the transition diagram
given by Fig. 3.14.
Fig. 3.14 Finite automaton of Example 3.14
Solution
We construct the transition table as given by Table 3.2:rv of Computer Science
TABLE 3.23 Transition Table for Example 3.14
Sia 2 °
ars a rs
a & a
By & a
® & %
% & &
& % a
a & a
a 4
Since there is only one final state qz, Q\' = {43}, Q? = Q - QP. Hence,
m= (ash. (qo 4 42 46 95 Ae Jr}}- AS {43} cannot be partitioned further,
Qi = {ga}. Now qo is L-equivalent to 9}, 45, qo But mot {0 qs, ga. gr. and so
2 = (do. Mi» 45. Go): 42 18 L-equivalent to qy Hence, Q’; = (42 44}. The only
element remaining in Q! is qj. Therefore, Q's = {q;}- Thus,
m= (lash {do ds 9 dol (a> debs tard}
QF = Lash
gp is 2equivalent to gq but not t0 q, oF ge. So.
23 = (a a6)
As qi is 2-equivalent tog,
OF = (av ash
As qz is 2-equivalent t0 du,
QP = lands QF = ta}
Thus,
= {Las}, (do. d}- {a as)+ {a daly (art)
QF = tas)
As qo is equivalent t0 ge,
(Go. Go)
As q: is 3-equivalent to qs,
{qu gst
AS qz is 3-equivalent to 44,
Qi = {qx 44). (an)
Therefore,
Aas}. {go debs (die as), (a> ashe tar}t
7M, My gives us the equivalence classes, the minimum state automaton
M’ =(Q, (ab). 8 gi. FY)Chapter 3: The Theory of Automata 8 97
Q'= (lash [ao teh Cav ash fas. ah Cal)
= [go oh F= Kas
and 5° is defined by Table 3.24,
TABLE 3.24 Transition Table of Minimum State
Automaton for Example 3.14
‘Stater= a
(oe. a Gan ad (eo. al
ta. ad toe ad te ad
tt teal eal
tal (a (ao. ae)
k [ao ae} (al
Note: ‘The transition diagram for M’ is given by Fig. 3.15,
oS
Cena lead tol
A NE
Fig, 3.18 Minimum state automaton of Example 3.14
3.10 SUPPLEMENTARY EXAMPLES
EZ
Construct a DFA equivalent to the NDFA M whose transition diagram is given
by Fig. 3.16.
Fig. 3.16 NOFA of Example 3.16.98 _G Theory of Computer Science
Solution
The transition table of Mf is given by Tuble 3.25.
TABLE 3.25 Transition Table for Example 3.18
g
= % a
* & ao
* a ~
®@ -
® = =
For the equivalent DFA:
i) The states are subsets of Q = ty. a1. a> 92 Gab
Gi) [go] is the initial stae.
Git) The subsets of Q containing qs or gs ste the final states
(iv) dis defined by Table 3.26. We start from [qo] and construct 6 only
for those states reachable trom {qa} (as in Example 3.8
TABLE 3.26 Transition Table of OFA for
Example 3.15
‘State @ >
(al lead (a. a)
(ae. aa) fe. ad) fae. ad
(oud
Construct a DEA equivalent to an NDFA whose transition table is defined by
Table 3.27.
TABLE 3.27 Transition Table of NOFA for
Example 3.16
‘State e °
% a Ge de
a 4 %
% % %
Solution
Let M be the DEA defined by
M = (hie 5), fa, B), & [gal F)where F is the set of all subsets of {qo 1. qs. qa} containing ¢y. 6 is defined
by Table 3.28,
TABLE 3.28 Transition Table of OFA for
Example 3.16
‘State
Ete sda
Construct a DFA accepting all strings w over {0, 1} such that the number of
I's in w is 3 mod 4
Solution
Let M be the required NDFA. As the condition on strings of TM) does not
at all involve 0, we ean assume that Mf does not change state on input O. If
appears in w (4k + 3) times. M can come back to the initial stae, after reading
41's and to a final state after reading 3 1's.
The required DFA is given by Fi
° ‘, ar
‘eT ayo
O_o»:
KS 7 ey
Fig. 3.17 DFA of Example 3.17.
Ura
Construct 2 DFA accepting all strings over (a, b) ending in ab.
Solution
We require two transitions for accepting the string ab. If the symbol b is
processed after aa or ba, then also we end in ad. So we can have states for100 _Theory of Computer Science
remembering aa, ab, ba, bb. The state corresponding to ab can be the final
state in our DFA. Keeping these in mind we construct the required DFA. Its
transition diagram is described by Fig. 3.18.
Fig. 318 DFA of Example 3.18.
EXAMPLE 3.19
Find T(M) for the DEA M described by Fig. 3.19
oe
A A
_
Solution
Tif) = {w © {a, b}* | ends in the substring ab}
Note: If we apply the minimization algorithm to the DEA in Example 3.18,
we get the DFA as in Example 3.19. (The student is advised 10 check.)
EZUaero
Construct a minimum state automaton equivalent to an automaton whose
transition table is defined by Table 3.29.Chapter 3: The Theory of Automata @ 101
TABLE 3.29. DFA of Example 3.20
sae
ppesss
BRReae "|
Solution
OP = lash. OP = (ar diy des a dab 80. % = Ads) (ay av 42 I Gab)
Q? vannot be panitioned further. So {qs} € 7)- Consider Q2. qy is equivalent
to gj. qy and gy But q is not equivalent to gs since S(gq, b) = gz and
8(q3. B) = Lash
Hence,
OF = (ah. OL = ta a a a). 0} = Las)
Therefore,
= (dss {do ga}. fast
qo is Qequivalent to g, but not 2equivalent to gy oF gs
Hence,
ap. 9) ©
qy and gz are not 2-equivalent.
‘Therefore.
Ry = thas}- Aashe (ao ashe (9i}> (agald
As qo is not 3-equivalent to 4, (go. qu} is further partitioned into {qx} and
a4)
So,
= (dol. (aib fash Lash (ass tas
Hence the minimum state automaton Mf is the same as the given M.
EXAMPLE 3.21
Construct a minimum state automaton equivalent to a DEA whose transition
table is defined by Table 3.30.102_&_Theory of Computer Science
Solution
OP = tgs. gabe OP = L4oe div do 5 dor 47}
Ty= (gs Gals {0 div
I» se Gos rh)
45 18 L-equivalent to qs. So, (qs. dah © 7
go is not Lequivalent to g.. 4 ds but gy is equivalent 10 go,
Hence {qu qs) € %- qi is L-equivalent to q; but not L-equivalent 10
G5 4 OF Gr So, {qe ao} My
gs is not Lequivalent to q, but 0
Hence,
$0. {ds ar} € Fi
™ = Udy dade dor do) (ae aah as eh)
gz is Qequivalent to qs. So. {qx qa} & Me
go is not 2-equivalent to qe So. do)+ {a6} © A>
gx is Qequivalent t0 qo. So. {qy. gz} ©
gs is Zequivalent t0 gr. So. (qs. gs) © 7
Hence,
= Ugx gabe Aol (doh tai a2) tas ahh
4g; 8 Bequivalent to 4: q, is equivalent to gs and qe is F-equivalent t0 ¢
Hence,
(dole tate debe tas as)- dss arhs dob
the minimum state automaton is
ts
As
M’ = (Q% (a. b}. &% Lagu (las auld)
where 8’ is defined by Table 3.31
TABLE 3.31 Transition Table of DFA for
Example 321
‘State a °
lad fas. aa) las. al
lan ad las. ad las. al
te, aa las a) {cal
(as. a1 Ia. aa fal
cy (ae fal
i
i
|
5
f
i
tChapter
The Theory of Automata 103
SELF-TEST
Study the automaton given in Fig. 3.20 and choose the correct answers
to Questions 1-8:
Fig. 3.20 Automaton for Questions 1-5
1 Misa
(a) nondeterministic automaton
(b) deterministic automaton accepting {0. 1}*
(6) deterministic automaton accepting all strings over (0. 1} having
3a O's and 3n V's. mn 2
(€) deterministic automaton
2. M accepts
(@) 01110 () 10001 () 01010 (@ it
3. TUM) is equal to
(ay (0" 1" | m,n 2 O}
(b) {0 P*]m. m2 1}
(6) foe] has L11 as a substring)
(2) fue }w has u's. 2
4. If gp is also made a final state, then Mf accepts
(2) 01110 and 01100
(b) 10001 and 10000
(e) 0110 but not 0111101
(a) 0". m2 1 but not Pn 2
S$. If gz is also made « final state, then TUM) is equal t0
(2) {0° 1 fm, 1 20} Y (OP I" | ma, 2 2 OF
() (OE fom BAPE OPM | mB HY
(c) few has 111 as a substting or LI as a substring}
(@) tor] the number of 1's in w is divisible by 2 or 3}
Study the automaton given in Fig. 321 and state whether the Statements
6-15 are true or false:
at os
Es a
bBo 6
Fig. 3.21 Automaton for Statements 6-15.104
52 _Theory of Computer Science
6
7.
8.
9.
10.
n
2
2B.
4.
48.
31
32
33
34
3S
36
BT
M is a nondeterministic automaton,
S(qy. 1) is defined.
0100111 is accepted by M.
010101010 is not accepted by M.
6(qy. 01001) = {ar}
(qo. 011000) = (qo. 94. a2}
6(q2, ¥) = gs for any string w € {0. 1}*.
6(q,. 11001) # 0
TOM) = (w|w = x00y, where x, y € (0. 1)*}.
A string having an even number of 0's is accepted by M.
EXERCISES
For the finite state machine M described hy Table 3.1. find the strings.
among the following strings which are accepted by M: (a) 101101,
(b) TIL, (©) 000000.
For the transition system M described by Fig. 3.8, obtain the sequence
of states for the input sequence 000101. Also. find an input sequence not
accepted by M.
Test whether 110011 and 110110 are accepted by the transition system
described by Fig. 36.
Let M = (Q, E. & qo F) be a finite automaton. Let R be a relation in
@ defined by q\Rqy if 61g}. a) = (gz, a) for all ae E Ts Ran
equivalence relation?
Construct @ nondeterministic finite automaton accepting {ab, ba}, and
use it to find a deterministic automaton accepting the same set.
Construct @ nondeterministic finite automaton accepting the set of all
strings over {a, 6} ending in aba, Use it to construct a DFA accepting the
same set of strings
The transition table of a nondeterministic finite automaton M is defined
by Table 3.32. Construct a deterministic finite automaton equivalent to M.
TABLE 3.32 Transition Table for Exercise 3.7
0
aa % 3
ooChapter
Theory of Automata 105
3.8 Construct a DFA equivalent to the NDFA described by Fig. 3.8.
39M = (1g. gy as), (0. 1}. & qu. (gah) is a nondeterministic finite
automaton, where 6 is given by
6. = {ay ash Sig. Y= fait
5q> O= (a. a2} 6a N= OH
6(gs, 0) = (42). Sx Y= {a ah
Construct an equivalent DFA.
3.10 Construct a transition system which can accept strings over the alphabet
4, b, ... containing either cat or rat
3.11 Construct a Mealy machine which is equivalent to the Moore machine
defined by Table 3.33,
TABLE 3.33. Moore Machine of Exercise 3.11
Next state Output
at
e 1
& °
a 1
% 1
3.12, Construct a Moore machine equivalent to the Mealy machine M defined
by Table 3.34,
TABLE 3.34 Mealy Machine of Exercise 3.12
Present state ext stare
aie “aie
“a a % 0
% % % 1
% a % 1
a % a 1
343 Construct a Mealy machine which can output EVEN. ODD according
as the total number of I's encountered is even or odd. The input
symbols are O and 1
3.14 Construct a minimum state automaton equivalent to a given automaton
M whose transition table is defined by Table 3.35.106 8 Theory of Computer S
TABLE 3.35 Finite Automaton of Exercise 3.14
State ‘Input
esasaes
lama >
3.15 Construct a minimum state automaton equivalent to the DFA described
by Fig. 3.18. Compare it with the DFA described by Fig. 3.19.
3.16 Construct a minimum state automaton equivalent to the DFA described
by Fig. 3.22.
on
Fig. 3.22 DFA of Exercise 3.16.