0% found this document useful (0 votes)
19 views

Finite Automata

Uploaded by

soumyashaw58
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Finite Automata

Uploaded by

soumyashaw58
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

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 nondeterministic finite
automata have the same capability as the deterministic automata as far as
acceptability is concerned. 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 to a 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.

/1 'j Automaton °1
/2
°2
-----~

/p 01,02' ... , On Oq

Fig. 3.1 Model of a discrete automaton.

71
72 li\ Theory of Computer Science
._---------------

The characteristics of automaton are now desClibed.


(i) Input. At each of the discrete instants of time t b t2, ...• t m the input
. values Ii' 12. . . . . f p • 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.l.
iii) Output. a" 0:;., ..., Oq are the outputs of the model, each of which.
can take a finite number of fixed values from an output O.
(iii) States. At any instant of time the automaton can be in onenf the
states ql' q:;., ..., qJl'
(iv) State relation. The next state of an automaton at any instant of time
is determined by the present state and the present input.
(v) 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 output depends
on the 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.

EXAMPLE 3.1
Consider the simple shift register shown in Fig. 3.2 as a finite-state machine
and study its operation.

. I 11--,t1>II~
7:~~~ D 0 Q I. liD ,H,D
rU ~_ 0 --,Ol--s-eria-I
ootpol

I I I .
i

Fig. 3.2 A 4-bit serial shift register using D flip-flops.

Solution
The shift register (Fig. 3.2) can have 2+ = 16 states (0000. 0001, .... 1111).
and one serial input and one serial output. The input alphabet is ~ = {O, I}.
and the output alphabet is 0 = {O. I}. This 4-bit selial shift register can be
further represented as in Fig. 3.3.
Chapter 3: The Theory of Automata &;! 73

i
I1 q1' q2' '

~
1

I Q15' Q16'

Fig. 3.3 .A shift register as a 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.
In 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
5-tuple (Q, E. 0. qo. F). where
(i) Q is a finite nonempty set of states.
(ii) I is a finite nonempty set of inputs called the input alphabet.
(iii) (5 is a function which maps Q x I into Q and is usually called the direct
transition function. 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 E Q is the initial state.
(v) F <;:;;; Q is the set of final states. It is assumed here that there may be
more than one final state.
Note: The transition function \vhich maps Q x I* into Q (i.e. maps a state
and a string of input symbols including the empty stling into a state) is called
the indirect transition function. We shall use the same symbol (5 to represent
both types of transition functions and the difference can be easily identified
by the nature of mapping (symbol or a string), i.e. by the argument. (5 is also
called the next state function. The above model can be represented graphically by
Fig. 3.4.

r-------------,t String being processerJ

c
D InI I [ I I I- -Ilt~~~t
S

1- ""dieg h,,,
i Finite
! control

Fig. 3.4 Block diagram of a finite automaton.


74 ~ 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 L. The end squares
of the tape contain the endmarker ¢ at the left end and the end-
marker $ at the right end. The absence of endmarkers i~clLcates11iat
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.
(iii) 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 q, to give the following outputs: (a) A motion of R-head along
the tape to the next square (in some a null move, i.e. the R-head
remaining to the same square is permitted); (b) the next state of the
finite state machine given by b(q, a).

3.3 TRANSITION SYSTEMS


A transition 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 inputJoutput.
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, if the
system is in the state qo and the input 1 is applied, the system moves to state
qJ as there is a directed edge from qo to qJ with label 1/0. It outputs O.

0/0 1/0 111

010
Fig. 3.5 A transition system,

We now give the (analytical) definition of a transition system.


Defmition 3.2 A transition system is a 5-tuple (Q, L, 0, Qo, F), where
(i) Q. Land 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) Qo ~ Q. and Qo is nonempty: and
(iii) 0 is a finite subset of Q x L* x Q.
Chapter 3: The Theory of Automata );1 75

In other words, if (qj, w. q'C) is in 8. it means that the graph starts at the
vertex (jj, goes along a set of edges, and reaches the vertex (j2' The
concatenation of the label of all the edges thus encountered is w.
DefInition 3.3 . A transition system accepts a string w in I* if
(i) there exists a path which originates from some initial state, goes
along the arrows, and terminates at some final state; and /
(ii) the path value obtained by concatenation of alJ edge-labels of the path
is equal to H'.

Example 3.2
Consider the transition system given in Fig. 3.6.

1/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 q!. There is only one final state, namely ({3'
The path-value of (joQOq:q3 is 101011. As (j3 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.
Note: Every finite automaton (Q, I, 8, qo, F) can be vie\ved as a transition
system (Q, I, 8/ Qo, F) if we take Qo = {Qo} and 8/ = {(q, w, 8(q, w»lq E
Q, W E I*}. 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 8{Q, A) = (j is a finite automaton. This means that the state of the
system can be changed only by an input symbol.
76 ~ Theory of Computer Science

Property 2 For all stlings wand input symbols a,


O(q, aw)= O(O(q, a), IV)

O(q, .va) = O(O(q, 'v), a)


This property gives the state after the automaton consumes or reads the
first symbol of a string aw and the state after the automaton consumes a
of the string .va.

EXAMPLE 3.3
Prove that for any transition function 0 and for any two input strings x and y,
O(q, xy) = o( O(q, x), y) (3.1)
Proof By the method of induction on I y I, i.e. length of y.
Basis: When I)' I = 1, y = a E 1:
L.R.S. of (3.1) = O(q, xa)
= O(O(q, x), a) by Property 2
= R.H.S. of (3.1)

Assume the result. l.e. (3,1) for all stlings x and strings)' with I Y I = n. Let
y be a stling of length n + 1. Write v = )'l a where i)'1 I = 11.

L.H.S. of (3.1) = O(q, ,'--:i'Ia) = 8(q, xIa), Xl = XYI


= O(O(q, Xl), a) by Property 2
= O(O(q, XYIl, a)
= O(O(O(q, x), Yj), a) by induction hypothesis
R.H.S. of (3.1) = O(O(q, x), Yla)
= O(O(&q, x), )'1), a) by Property 2
Hence, L.H.S. = R.H.S. This proves (3.1) for any string y of length 11 + 1.
By the principle of induction. (3.1) is true for all strings. I

EXAMPLE 3.4
Prove that if O(q, x) = O(q, y), then O(q, xz) = O(q, yz) for all strings ~: in 1:+.

Solution
O(q, xz) = O(O(q, x), z) by Example 3.3
= o( o(q, y), ;:) (3.2)
By Example 3.3.
O(q, yz) = O(O(q, y), z)

= O(q, xz) (3.3 )


Chapter 3: The Theory of Automata iii, 77

3.5 ACCEPTABILITY OF A STRING BY A FINITE


AUTOMATON
Definition 3.4 A stling x is accepted by a finite automaton
M = (Q, .L 8, C/o' F)
if D(qo, x) = q for some q E 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.5
Consider the finite state machine whose u'unsition function 0 is given by Table 3.1
in the form of a transition table. Here, Q = {CI(), qi. q2> q3}, L = {O, I},
F = {qo}. Give the entire sequence of states for the input string 110001.

TABLE 3.1 Transition Function Table for Example 3.5

Input
State
o
(--:\
-7 ~/
q,
q2
q3

Solution
l l
8{qo, 110101) = D(C/I.IOIOI)
I
..v
= 0(% 0101)
l
= D(q~, 101)
l
= 8(q3,Ol)
l
= D(q], 1)
= 8(qo, ..1\)

Hence.
J 1 a 1 a j
qo ~ qj ~ qo ~ q~ ~ q3 ~ qj ~ qo
The symbol l indicates that the current input symbol is being processed by the
machine.
78 ~ Theory of Computer Science

3.6 NONDETERMINISTIC FINITE STATE MACHINES


We explain the concept of nondeterministic finite automaton using a transition
diagram (Fig. 3.7).

~)~ O ----7 1

/
"'-. , /1
Fig. 3.7
"tr
Transition system representing nondeterministic automaton.

If the automaton is in a state {qa} and the input symbol is 0, what wii! be
the next state? From the figure it is clear that the next state will be either {qo}
or {qj}. Thus some moves of the machine cannot be determined uniquely by
the input symbol and the present state. Such machines are called
nondeterministic automata. the formal definition of which is now given.
Definition 3.5 A nondeterministic finite automaton (NDFA) is a 5-tuple
(Q, L. 0, qo, F), where
(i) Q is a finite nonempty set of states;
(ii) L is a finite nonempty set of inputs;
(iii) 0 is the transition function mapping from Q x L into 2Q which is the
power set of Q, the set of all subsets of Q;
(iv) qo E Q is the initial state; and
(v) F ~ Q is the set of final states.
We note that the difference between the deterministic and nondeterministic
automata is only in 0. For deterministic automaton (DFA), the outcome is a
state, i.e. an element of Q; for nondeterministic automaton the outcome is a
subset of Q.
Consider, for example, the nondeterministic automaton whose transition
diagram is described by Fig. 3.8.
The sequence of states for the input string 0100 is given in Fig. 3.9. Hence,
8(qo, 0100) = {qo, q3' q4}
Since q4 is an accepting state. the input string 0100 will be accepted by
the nondeterministic automaton.
Chapter 3: The Theory of Automata ,g 79

o o
o

Fig. 3.8 Transition system for a nondeterministic automaton.

0 0 0
qo ~ qo • qo ~ qo • qo

\0
~\ ~
\

q3
\ q1 q3
\ q3

Fig. 3.9
\ q4
States reached while processing 0100.

DefInition 3.6 A string W E L* is accepted by NDFA At if o(q(j, w) contains


some final state.
Note: As At is nondetenninistic, O(q(j, 'v) may have more than one state. So
w is accepted by At if a final state is one among the possible states that At can
reach on application of w.
We can visualize the working of an NDFA M as follows: Suppose At
reaches a state q and reads an input symbol a. If 8(q, a) has n elements,
the automaton splits into n identical copies of itself: each copy pursuing
one choice determined by an element of 8(q, a). This type of parallel
computation continues. When a copy encounters (q, a) for which 8(q, a) = 0,
this copy of the machine 'dies'; however the computation is pursued by the
other copies. If anyone of the copies of At reaches a final state after
processing the entire input string ',1', then we say that At accepts w. Another
way of looking at the computation by an NDFA At is to assign a tree structure
for computing 8(q. w). The root of the tree has the label q. For every input
symbol in ',1', the tree branches itself. When a leaf of the tree has a final state
as lts labeL then At accepts w.
Definition 3.7 The set accepted by an automaton At (deterministic or
nondetenninistic) is the set of all input strings accepted by At. It is denoted by
T(At).
80 9 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 DFA can simulate the behaviour of NDFA by increasing the number
of states. (In other words. a DFA (Q, L, 8, qQ, F) can be viewed as an
NDFA (Q, L, 8', qQ, F) by defining 8'(q, a) = {8(q, a)}.)
Oi) Any NDFA is a more general machine without being more powelfuL
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 L is the set accepted by NDFA, then there
exists a DFA which also accepts L.
Proof Let M = (Q, L, 8, qQ, F) be an NDFA accepting L. We construct a DFA
M' as:
M' = (Q', L, 8, (/o, F')
where
(i) Q' = 2Q (any state in Q' is denoted by [qio q2, .... q;], where qio q2,
.... qj E Q):
(ii) q' 0 = [clo]; and
(iii) r is the set of all subsets of Q containing an element of F.
Before defining 8'. let us look at the construction of Q', q'o and r. M is
initially at qo. But on application of an input symbol, say a, M can reach any
of the states 8(qo, a). To describe M, just after the application of the input
symbol a. we require all the possible states that M can reach after the
application of a. So, lvI' has to remember all these possible states at any instant
of time. Hence the states of M' are defined as subsets of Q. As M starts with
the initial state qo, q'o is defined as [qo]. A string w belongs to T(M) if a final
state is one of the possible states that M reaches on processing w. So, a final
state in M' (i.e. an element of F') is any subset of Q containing some final
state of M.
Now we can define 8':
(iv) 8'([qb q2. .... qi], a) = 8(q[, a) u 8(q2, a) u '" U 8(qi' a).
Equivalently.

if and only if
8({ql' ... , q;}, a) = {PI, P2 • ..., Pi}'
Before proving L = T(M'), we prove an auxiliary result
8'(q'o, x) = [qj, .. '. q;], (3.4)
if and only if 8(qo, x) = {qj, "" q;} for all x in P.
We prove by induction on Ix I. the 'if part. i.e.
8'(q'o. x) = [qJ' q2. , ... q;] (3.5)
if 8(qo. x) = {qJ ..... q;}.
Chapter 3: The Theory of Automata );;I, 81

When Ixl = O. o(qo, A) = {qoL and by definition of o~ [/(q6. A) =


qa = [qol So. (3.5) is true for x with Ix i ::: O. Thus there is basis for induction.
Assume that (3.5) is true for all strings y with Iy I S; m. Let x be a
string of length + 1. We can write x as va, where 'y' =
In and a E L. Let
111
o(qo, 1') = {p, ... , Pi} and o(qo. ya) = {rl' r2' .... rd· As Iyi S; In, by
Induction hypothesis we have
O'(qo· y) = [PI, .... p;] (3.6)
Also.
{rl' r~ .... r;} = O(qo, ya) = O(o(qo, Y). a) ::: O({PI, .... Pj}, a)

By definition of o~

(3.7)
Hence.
O'(q(;. yay = o/(o/(q'o. y), a) = O'([PI . ... , Pi], a) by (3.6)
::: [rl' .... rd by (3.7)
Thus we have proved (3.5) for x = .va.
By induction. (3.5) is true for all strings x. The other part (i.e. the 'only if'
part), can be proved similarly, and so (3.4) is established.
Now. x E T(M) if and only if O(q. x) contains a state of F. By (3.4).
8(qo, x) contains a state of F if and only if 8'(qo, x) is in F'. Hence. x E T(M)
if and only if x E T(Af'). This proves that DFA M' accepts L. I
Vote: In the construction of a deterministic finite automaton M 1 equivalent to
a given nondetelministic automaton M, the only difficult part is the construction
of 8/ for M j • By definition.
k
8'([q1 ... qd, a) = U 8(q;, a)
l=l

So we have to apply 8 to (q;. a) for each i = 1. 2..... k and take their


union to get o'([q] .. , qd. a).
When 8 for /1'1 is given in telms of a state table. the construction is simpler.
8(q;, a) is given by the row corresponding to q; and the column corresponding
to a. To construct 8'([ql ... qk]. a), consider the states appearing in the rows
corresponding to qj , ql;o and the column corresponding to a. These states
constitute 8'([q] qd. a).
Note: We write 8' as 8 itself when there is no ambiguity. We also mark the
initial state with ~ and the final state with a circle in the state table.

EXAMPLE 3.6
Construct a deterministic automaton equivalent to
M ::: ({qo. qd· {O. l}. 8, qo, {qoD

where 8 is defined by its state table (see Table 3.2).


82 g Theory of Computer Science

TABLE 3.2 State Table for Example 3,6

State/L o
~@ qo q,
_ _--'qC-'-' q--'i qo, ql

Solution
For the deterministic automaton MI.
(i) the states are subsets of {qo. Ql}, i.e. 0. [qo], [c/o' q;], [q;];
(ii) [qoJ is the initial state;
(iii) [qo] and [qo, q;] are the final states as these are the only states
containing qo; and
(iv) 8 is defined by the state table given by Table 3.3.

TABLE 3.3 State Table of M , for Example 3,6

State/'L o
o o o
[qo] [qo] [q,]
[q,] [q,] [qo, q,]
[qo, q,] [qo, q,] [qo, q,]

The states qo and ql appear in the rows corresponding to qo and qj and the
column corresponding to O. So. 8([qo. qt], 0) = [qo. qd·
When M has 11 states. the corresponding finite automaton has 2" states.
However. we need not construct 8 for all these 2" states, but only for those
states that are reachable from [Qo]. This is because our interest is only in
constructing M 1 accepting T(M). So, we start the construction of 8 for [qo]. 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 detefIIljnistic acceptor equivalent to
M = ({qo. qIo q:J. {a. hI. 8. qo. {q2})
where 8 is as given by Table 3.4.

TABLE 3.4 State Table for Example 3.7

State/'L a b

~qo qo. q, q2
q, qo q,
@ qo. q,
Chapter 3: The Theory of Automata ~ 83

Solution
The detenninisticautomaton M 1 equivalent to M is defined as follows:
M) = (2 Q, {a, b}, 8. [q01 F')
where
F = {[cd· [qo, Q2J, [Ql' q2], [qo· % q2]}
We start the construction by considering [Qo] first. We get [q2] and [qo. q:]. Then
we construct 8 for [q2] and [qo. q1]. [q), q2J is a new state appearing under the
input columns. After constructing 8 for [ql' q2], we do not get any new states
and so we terminate the construction of 8. The state table is given by Table 3.5.

TABLE 3.5 State Table of M , for Example 3.7

State/I a b

[001 [00. 01] [02]


[02] o [00, a,]
[00, 0'] [00. a,] [a" 02]
[a,. 02] [00] [00, 01]

EXAMPLE 3.8
Construct a deterministic finite automaton equivalent to

M = ({qCh qj, 12, q:}, {a, I}), 8. qo, {q3})

where /5 is given by Table 3.6.

TABLE 3.6 State Table for Example 3.8

State/I a b

---'>00 00. a' 00


a, 02 a,
02 03 03
.''.:.::.)
C0 02

Solution
Let Q == {qo, q1' q:, q:,}. Then the deterministic automaton M 1 equivalent to
M is given by
Q
M I = (2 • {a. b}. 8, [qo], F)
where F consists of:
[q3]. [qo· q3]. [q1- q3j· [q2' q3]. [qo. qj. Q3], [qo. q2' q3]. [Q]o Q2' Q3]
and
[Qo· Q!. q2. q3]
and where 15 is defined by the state table given by Table 3.7.
84 !;' Theory of computer Science

TABLE 3.7 State Table of M i for Example 3.8

State/I a b
-_ ..._ - - _ . _ - - - - - -
[qJ Clil [qol
[qo, Cli] [qo q,. q2l [qo. q,]
[qc. q1 q2] [qQ. q-,. Q2. q3] [qo. q,. q3]
[qo. qi. q3] [qo. q1 Cl2] [qo. Q,. q2]
[qc•. qi. q2. q3] [qc. q, Cl2 q3] [qo. qi. q2.{f31
---------------- --------------'---

3.8 MEALY AND MOORE MODELS


3.8.1 FINITE AUTOMATA WITH OUTPUTS

The finite automata \vhich we considered in the earlier sections have binary
output i.e. either they accept the string or they do not accept the string. This
acceptability \vas decided on the basis of reachahility of the final state by the
initial state. Now. we remove this restriction and consider the mode1 where the
outputs can be chosen from some other alphabet. The value of the output
function Z(t) in the most general case is a function of the present state q(t) and
the present input xU), i.e.
Z(n :::;

where Ie is called the output function. This generalized model is usua!Jy called
the !'v!ca!l' machine. If the output function Z(t) depends only on the present state
and is independent of the cunent input. the output function may be written as
Z(t) :::;

This restricted model is called the j'vJoore machine. It is more convenient to use
Moore machine in automata theory. We now give the most general definitIons
of these machines.
Definition 3.8 A Moore machine is a six-tuple (Q. L, ~. 8, I,. (]ol. where
(il Q is a finite set of states:
I is the input alphabet:
(i ii) ~ is the output alphabet:
8 is the transition function I x Q into Q:
I, is the output function mapping Q into ~; and
(]o is the initial state.
Definition 3.9 /'I. Ivlealy machine is a six-tuple (Q, I, ~, 8. )e, qo). "vhere
all the symbols except Ie have the same meaning as in the Moore machine. A.
is the output function mapping I x Q into ,1,
For example. Table 3.8 desclibes a Moore machme. The initial state iJo is
marked with an arrow. The table defines 8 ane! A...
Chapter 3: The Theory of Automata ,\;l 85

TABLE 3.8 A Moore Machine

Present state Next state () Output


a=O a=1

~qc o
q, 1
q2 o
q3 o

For the input string 0111. the transition of states is given by qo -7 Cf" -7
qo -7 qt -7 q2' TIle output string is 00010. For the input string A, the output
is A(qo) = O.
Transition Table .3.9 describes a Mealy machine.

TABLE 3.9 A Mealy Machine

Present state Next state

a ~ 0 a =
state output state output

q3 0 o
q" 1 o
q:; 1 1
q4 o

Note: For the input stling 0011. the transition of states is given by qi -7 q"
.~ q: -7 qj, -7 q~.
and the output string is 0100. In the case of a Mealy machine.
'Nt get an output 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 ),(qo) for the input string A.
Remark A finite automaton can be converted into a Moore machine by
introducing 2, = {O. I} and defining )~(q) = 1 if q E F and )~(q) = 0 if
q if. F.
For a Moore machine if the input string is of length 11, the output string
is of length 11 + 1. The first output is Ic(qo) for all output strings. In the case
of a 1'1ealy machine if the input string is of length n. the output string is also
of the same length II.

3.8.2 PROCEDURE FOR TRANSFORMING A MEALY MACHINE


INTO A MOORE MACHINE

VJ~ 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 &;l Theory of Computer Science

EXAMPLE 3.9
Consider the Mealv machine described 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 state

Input a =0 Input a =
state output state output

o o
1 o
1 1
1 o

Solution
At the first stage we develop the procedure so that both machines accept
exactly the same set of input sequences. Vve look into the next state column
for any state, say q/. and determine the number of different outputs associated
with q; in that column.
We split qi 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. ql is associated with one output 1 and q: is associated with two
different outputs 0 and 1. Similarly, q3 and '14 are associated with the outputs
o and O. 1. respectively. So. we split q: into q-:w and <721' Similarly, q4 is split
into q.11) and '141' Now Table 3.10 can be reconstructed for the new states as
given by Table 3.11.

TABLE 3.11 State Table for Example 3.9

Present state Next state

Input a =0 Input a =1
state output state output

-"q, qa 0 q20 0
Q20 q, q40 0
q21 q, Q40 0
qa q2 q, 1
q4G q4, qa 0
q41 q4, qa 0

The pair of states and outputs in the next state column can be rearranged as
given by Table 3.12.
Chapter 3: The Theory of Automata g 87

TABLE 3.12 Revised State Table for Example 3.9

Present state Next state Output


a =0 a =1
--+q., q3 G2C 1
q20 q" q40 0
q2', q, Q4C 1
q3 q21 q, 0
Q4CJ q41 q3 ~
q41 q4' q3 1

Table 3.12 gives the Moore machine. Here we observe that the initial state
ql is associated with output 1. This means that with input A we get an output
of 1, if the machine starts at state ql' Thus this Moore machine accepts a zero-
length sequence (null sequence) which is not accepted by the Mealy machine.
To overcome this situation, either we must neglect the response of a Moore
machine to input A. or we must add a new starting state qQ, whose state
transitions are identical with those of q\ but whose output is O. So Table 3.12
is transformed to Table 3.13.

TABLE 3.13 fv100re Machine of Example 3.9

Present state Next state Output


a =0 a =1
-'tqo q3 q2C o
q, q3 q2C 1
q2C q, Q40 o
q21 q, q4C
q3 q21 01 o
q4J q41 q3 o
q41 Q4' q2, 1

From the foregoing procedure it is clear that if we have an m-output, 11-


state Mealy machine. the corresponding m-output Moore machine has no more
than 11111 + 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 11;1' are equivalent if for all input strings lV,
b 7 ,t\,w) = Zw(w}. where b is the output of the Moore machine for its initial
state. We give the following result: Let AIL = (Q, L, ll, 8, A.. qo) be a Moore
machine. Then the following procedure may be adopted to construct an
equivalent Mealy machine Mo.
88 Theory of Computer Science

Construction
(i) We have to define the output function;: for the Mealy machine as
a function of the present state and the input symbol. We define;: by
X('1, a) = }eCoCq, a» for all states '1 and input symbols a.
(ii) The transition function IS the :..;ame as that of the gIven Moore
machine.

EXAMPLE 3.l0
Construct a 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 Next state Output


a =0 a =1
-;qo o
q, 1
q2 o
q3 o

Solution
We must follow the reverse procedure of converting a Mealy machine into a
Moore machine. In the case of the Moore machine, for every input symbol we
form the pair consisting of the next state and the corresponding output and
reconstruct the table for the Mealy Machine. For example, the states CJ3 and '11
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

Present state Next state

a =0 a =
state output state output
-;qc q3 0 q, 1
q q, 1 q2 0
q2 q2 0 q3 0
q3 q3 0 qo 0

Note: We can reduce the number of states in any model by considering states
with identical transitions. If two states have identical transitions (i.e. the rows
cOlTesponding to these two states are identical), then we can delete one of them.

EXAMPLE 3.11
Consider the Moore machine desclibed by the transition table given by
Table 3.16. Construct the corresponding Mealy rnachine.
Chapter 3: The Theory of Automata ~ 89
-~--

TABLE 3,16 Moore Machine of Examp!e 3.11

Present state Next state Output


a =0 a =1
o
o
1

Solution
We construct the transition table as in Table 3,17 by associating the output
\vith the transitions.
In Table 3.17. the rows cOlTesponding to '1: and '1." are identical. So. we can
delete one of the two states. i.e. if: or {h. We delete if.". Table 3,18 gives the
reconstructed table.

TABLE 3,17 Transition Table for Example 3.11

Present state Next state

a = 0 a =1
state output state output

-:;.Gi q: 0 q2 0
q2 q" 0 q3 1
q3 q" 0 q3 1

TABLE 3,18 Mealy rJlachine of Example 3.11

Present state Next state

a =0 a =

- - - , , - - - - - - - - - - - - _...-

In Table 3.18. we have deleted the '1.,,·1'ow and replaced '10, by '12 in the other
rows.
- ~-- - . ~ -~ -
EXAMPLE 3.12
Consider a Mealy machine represented by Fig. 3.10, Construct a Moore
machine equivalent to this Mealy machine.
90 ~ Theory of Computer Science

1/Z2
Fig. 3.10 Mealy machine of Example 3.12.

Solution
Let us convert the transition diagram into the transition Table 3.19. For the
given problem: qJ is not associated with any output; q2 is associated with two
different outputs Zj and 2 2 ; (]3 is associated with two different outputs 2 1 and
2 2, Thus we must split q2 into q21 and (]22 with outputs 2 1 and Z2, respectively
and q3 into (]31 and q32 with outputs 2 1 and 2 2, 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 = 0 a =
state output state output

q2 Z, q3 Z,
q2 Z2 q3 Z-I
q2 Z, q3 Z2

TABLE 3.20 Transition Table of Moore Machine for Example 3.12

Present state Next state Output


a =0 a =1
--,>q,
q21
q22
q31
q32

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 M.
As our interest lies only in strings accepted by i\!I, what really matters is
whether a state is a final state or not. We define some relations in Q.
DefInition 3.10 Two states ql and q: are equivalent (denoted by qj == q:) if
both o(qj. x) and O(q:. x) are final states. or both of them are nonfinal states
for all x E 2:*.
As it is difficult to construct O(qj, x) and O(q:, x) for all x E 2:* (there
are an infinite number of stlings in 2:*). we give one more definition.
Definition 3.11 Two states qj and q: are k-equivalem (k ;::: 0) if both
O(qj, x) and O(q:. ;r) are final states or both nonfinal states for all strings x
of length k or less. In particular, any two final states are O-equivalent and any
t\VO nonfinal states are also O-equivalent.

We mention some of the properties of these relations.


Property 1 The relations we have defined. i.e. equivalence and k-equivalence,
are 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 Jr and Jrl' respectively. The elements of Jrl are k-equivalence
classes.
Property 3 If qj and q: are k-equivalent for all k ;::: O. then they are equivalent.
Property 4 If ql and q: are (k + I)-equivalent. then they are k-equivalent.
Property 5 ir" = Jr,,+] for some 11. (Jr" denotes the set of equivalence classes
under l1-equivalence.)
The following result is the key to the construction of minimum state
automaton.
RESULT Two states qj and q: are (k + I)-equivalent if (i) they are
k-equivalent; (ii) O(q!. a) and O(q:, a) are also k-equivalent for every a E 2:.
92 ~ Theory of Computer Science

Proof We prove the result by contradiction. Suppose qj and q2 are not


(k + I)-equivalent. Then there exists a string W = aWl of length k + 1 such that
8(ql. aWj) is a final state and 8(q'b aWl) is not a final state (or vice versa; the
proof is similar). So 8(8(qb a}. wI) is a final state and 8(8(q:, a), WI) is not
a final state. As WI is a string of length k, 8(q), a) and 8(q:, a) are not
k-equivalent. This is a contradiction. and hence the result is proved. I
Using the previous result we can construct the (k + I)-equivalence classes
once the k-equivalence classes are known.

3.9.1 CONSTRUCTION OF MINIMUM AUTOMATON

Step 1 (Construction of no)· By definition of O-equivalence, no ={Q?, Qf }


where Q? is the set of all final states and Qf = Q - Q?
Step 2 (Construction of lrk+i from lr;:). Let Q/' be any subset in lrk' If q) and
q2 are in Q/'. they are (k + I)-equivalent provided 8(% a) and 8(q']) a) are
k-equivalent. Find out whether 8(qj, a) and 8(q2' a) are in the same equivalence
class in ~k for every a E L. If so. q) and q: are (k + I)-equivalent. In this way,
Q/' is further divided into (k + I)-equivalence classes. Repeat this for every Q/'
in lrk to get all the elements of lrk+)'
Step 3 Construct lr" for 11 = 1. 2, .... until lr" = lrn +!·

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 !rl!' The state table is obtained by replacing a state q by the
conesponding equivalence class [q].
Remark In the above 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 conesponding
equivalence classes. The number of equivalence classes is less than or equal to
I Q I· Consider an equivalence class [qd = {qj, q:, ..., qd· If qj is reached
while processing WIW: E T(M) with 8(qo, Wj) = qb then 8(Ql. w:) E F. So,
8(q;, w:) E F for i = 2...., k. Thus we see that qj. i = 2, .. " k is reached on
processing some IV E T(M) iff qj is reached on processing w, i.e. ql of [qd can
play the role of q: . ... , qk' The above argument explains why we replace a state
by the conesponding equivalence class.
Note: The construction of no, lrj, lr:, etc. is easy when the transition table
is given. Jl1J = {QF. Q:o}. where Q? = F and Q:o = Q - F. The subsets in
lrl are obtained by further partitioning the subsets of no· If qj, q: E Q?,
consider the states in each a-column. where a E l: conesponding to qj and q2'
If they are in the same subset of 71';), q) and q: are I-equivalent. If the states
under some a-column are in different subsets of 7i'Q. then ql and q: are not
I-equivalent. In generaL (k + 1)-equivalent states are obtained by applying the
above method for ql and q: in rj/'.
Chapter 3: The Theory of Automata ,!;l 93

EXAMPLE 3.13
Construct a minimum state automaton equivalent to the finite automaton
described by Fig. 3.12.

o 0

o
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

StatelI. o
-'tqo
q1
®
q3
q4
qs
q6
q7

By applying step 1, we get


Q? = F = {Q21,
So.
94 );2 Theory of Computer Science

The {cd in 7ru cannot be further partitioned. SO, Q\ = {q::}. Consider qo and
qj E Qt The entries under the O-column corresponding to qo and qj are q]
and qr,: they lie in Q!/ The entries under the I-column are qs and q::. q:: E
Qp and qs E Q::o. Therefore. qo and q\ are not i-equivalent. Similarly, qo is
not i-equivalent to q3' qs and q7'
Now, consider qo and q4' The entries under the O-column are qj and q7'
Both are in Q::o. The entries under the I-column are qs, qs· So q4 and qo are
I-equivalent. Similarly, qo is I-equivalent to q6' {qo. q4, q6} is a subset in n\.
SO, Q':: = {qo, q4' q(,}.
Repeat the construction by considering qj and anyone of the states
q3, qs· Q7' Now, qj is not I-equivalent to qj or qs but I-equivalent to q7' Hence,
o
Q'3 = {qj, q7}' The elements left over in Q:: are q3 and qs. By considering the
entries under the O-column and the I-column, we see that q3 and q) are
l-equivalent. So Q/4 = {qj, qs}' Therefore,
ITj = {{q:;}. {qo· q4' q6}. {qj. q7}, {q3. qs}}
The {q::} is also in n:: as it cannot be further partitioned. Now, the entries
under the O-column corresponding to qo and q4 are qj and q7' and these lie
in the same equivalence class in nj. The entries under the I-column are qs,
qs. So qo and q4 are 2-eqnivalent. But qo and q6 are not 2-equivalent. Hence.
{qo. Cf4, qd is partitioned into {qo, qd and {qd· qj and q7 are 2-equivalent.
q3 and qs are also 2-equivalent. Thus. n:: = {{q::L {qo, q4}, {Q6}, {Qj, Q7L
{qj, qs}}. qo and q4 are 3-equivalent. The qj and Q7 are 3-equivalent. Also.
q3 and qs are 3-equivalent. Therefore.
nj = {{qJ, {qo, q4}, {q6}, {qj, q7L {Q3, qs}}
As n: = nj. n2 gives us the equivalence classes, the minimum state automaton
is
M' = (Q" {O. I}. Fj8" qo,
where
Q' = {[q2J. [qo, q4J, [q6]. [qt- Q7], [Q3' Qs]}
qo = [qo, Q4]' F = [cd
and 8/ is defined by Table 3.22.

TABLE 3.22 Transition Table of Minimum State


Automaton for Example 3.13

State/I. 0

[qo, q4] [0', OJ] [03. q5]


[Q1, OJ] [q6] [q2]
[02] [00' 04] [q2]
(Q3· q5] [q2] [06]
[06] [q6] [qo, q4]
Chapter 3: The Theorv of Automata ~ 95
-----------------"----
Note: The transition diagram for the minimum state automaton is described
by Fig. 3.13. The states qo and q.', are identified and treated as one state.
(SO also are ql, q7 and q3' qs) But the transitions in both the diagrams (i.e.
Figs. 3.12 and 3.13) are the same. If there is an arrow from qi to (jj with label
a. then there is an arrow from [q;J to lq;] with the same label in the
diagram for minimum state automaton. Symbolically, if O(qi' a) = 'ii' then
8'([q;], a) = [q;J.
1

I---~o-_ _
7
A
[q2]

o
o !'\

Fig. 3.13 Minimum state automaton of Example 3,13,

EXAMPLE 3.14
Construct the minimum state automaton equivalent to the transition diagram
given by Fig. 3.14.

b a

-G- !'~\
I
I
b 0- '
I~
~
b
It\ '
I \

r
I
I \
'I :'
\;1 , I
\
I' b
~
I
\ ,
a

~ ~ \~
0- --\:~) ~--(i))b
b
Fig. 3.14 Finite automaton of Example 3,14,

Solution
We construct the transition table as given by Table ,3.23.
--- --------------

96 };l, Theory of Computer Science

TABLE 3.23 Transition Table for Example 3.14

State/I. a b

-7 qa q1 qa
q1 qa q2
q2 q3 q1
®
q4
q3
q3
qa
C15
q5 qe q4
qe q5 qe
q7 qe q3

Since there is only one final state q3' QIO= {q3}, Ql = Q - Qt Hence,
1ro = {{q3}, {qo, ql' q2' q4> % q6, q7}}' As {q3l cannot be partitioned further,
Q'I = {q3}' Now qo is I-equivalent to ql' q5, qIY but not to q2, q4, q7' and so
Q'). = {qo, ql> q5' q6}' q). is I-equivalent to Q4' Hence, Q'3 = {Q2> Q4}' The only
element remaining in Q).o is Q7' Therefore, Q4 = {Q7}' Thus,
= {{Q3},
Jrl {qo, qh qs, Q6}, {QJ., q4}, {Q7}}
Q1 = {Q3}
2

qo is 2-equivalent to q6 but not to ql or Qs. So,


Qi = {Qo, Q6}
As ql is 2-equivalent to qs,

As q). is 2-equivalent to q4,


Ql = {q)., q4},
Thus,
Jr2 = {{q3}' {qo, qd, {ql> qs}, {q)., q4}, {q7}}

Q? = {q3}
As qo is 3-equivalent to q6,

As qj is 3-equivalent to qs,

As q2 is 3-equivalent to Q4,

Ql = {q)., Q4}, Q{ = {Q7}


Therefore,

As Jr3 = Jr)., Jr2 gives us the equivalence classes. the minimum state automaton
is
M' = (Q',{a, b}, 8', q'o, F')
Chapter 3: The Theorv of Automata i;l 97

where
Q' = {[cI3], [qo, Q6], [ql' qs], [q:> q4], [q7]}
q'o = [qo, qd, r = [q3]
and 8' is defined by Table 3.24.

TABLE 3.24 Transition Table of Minimum State


Automaton for Example 3,14

State/I. a b

[qQ, q6] [q1' q5] [qQ, q6]


[q1' q5] [qQ, q6] [q2, q4]
[q2, q4] [q31 [q1, q5]
[q3] [q3] [qQ' q6]
[q7] [qQ, q6] [q3]

Note: The transition diagram for lVI' is given by Fig. 3.15.


b

b
Fig. 3.15 Minimum state automaton of Example 3,14,

3.10 SUPPLEMENTARY EXAMPLES

EXAMPLE' 3.15
Construct a DFA equivalent to the l\i'DFA M whose transition diagram is given
by Fig. 3.16.
a, b
a, 0 q1

b
I

~ j'
q2 a

Fig. 3.16 NDFA of Example 3,15


98 Q Theory of Computer Science

Solution
The transition table of M is given by Table 3.25.

TABLE 3.25 Transition Table for Example 3.15

State a b

For the equi valent DFA:


(i) The states are subsets of Q = {qo, CJl, CJ2, Q3, Q4}'
(ii) [qo] is the initial state.
(iii) The subsets of Q containing Q3 or Q4 are the final states.
(iv) 8 is defined by Table 3.26. We start from [qoJ and construct 8, only
for those states reachable from [qoJ (as in Example 3.8).

TABLE 3.26 Transition Table of DFA for


Example 3.15

State a b

[qQ] [qQ] [qQ, q2]


[qQ. qzl [qo. q4] [qQ- qzJ
[qQ. q4] [qo] [qQ. q2]

EXAMPLE 3.16
Construct a DFA equivalent to an NDFA whose transition table is defined by
Table 3.27.
TABLE 3.27 Transition Table of NDFA for
Example 3.16

State a b

Solution
Let i'v! be the DFA defined by
M = C{'!"·()I·'i2· Q3}, {a, b}, 0, [gal F)
~- -~-~-- ----------~~-

Chapter 3: The Theory of Automata ~ 99

where F is the set of all subsets of {qo, qj' Q2' (/3} containing CJJ. <5 is defined
by Table 3.28.

TABLE 3.28 Transition Table of DFA for


Example 3.16

State a b

[qo] [q1. q3] [Q2. q3]


[q,. q3] [q,] [q3]
[qd [QJ [Q3]
[q3] o o
[Q2. q3] [q3]
[q2] [q3]
o o

EXAMPLE 3.17
Construct a DFA accepting all strings Hover {O, I} such that the numher of
l' s in H' is 3 mod 4.

Solution
Let ;\J be the required NDFA. As the condition on strings of T(M) does not
at all involve 0. we can assume that ;\J does not change state on input O. If 1
appears in H' (4k + 3) times. M can come back to the initial state. after reading
4 l's and to a final state after reading 31's.
The required DFA is given by Fig. 3.17.

Fig. 3.17 DFA of Example 3.17.

EXAM PLE 3.18


Construct a DFA accepting all strings over {a. h} ending in abo

Solution
We require t\\/O transitions for accepting the string abo If the symbol b is
processed after an or ba. then also we end in abo So we can have states for
100 ~ 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.

a a

Fig. 3.18 DFA of Example 3.18.

EXAMPLE 3.19
Find TCM) for the DFA M described by Fig. 3.19.

b
Fig. 3.19 DFA of Example 3.19.

Solution
r(M) = {H' E {a, b} * 1 vI' ends in the substring ab}
Note: If we apply the minimization algorithm to the DFA in Example 3.18,
we get the DFA as in Example 3.19. (The student is advised to check.)

EXAMPLE 3.20
Construct a mimmum state automaton equivalent to an automaton whose
transition table is defined by Table 3.29.
Chapter 3: The Theory of Automata );J 101

TABLE 3.29 DFA of Example 3.20

State a b

-'>qo
q,
q2
q3
q4
®
Solution
Qp = {q)}. QJ = {qo, % q2' Q3, q-d. So, Jro = {{q)}. {qo, qi' q2' q3' q4}}
Q? cannot be partitioned further. So {q)} E Consider Qt qo is equivalent
JrI'
to Ql' q2 and q4' But qo is not equivalent to q3 since 6(qo, b) = q2 and
6(q3' b) = {qsJ·
Hence.
Q1l _
-
{ }
Cf).
Therefore,
JrI = {{q)}, {qo. qi. q2. q4}' {q3}}
qo is 2-equivalent to q4 but not 2-equivalent to qJ or Q2'
Hence.
{qo, q4} E Jro
ql and q2 are not 2-equivalent.
Therefore.
Jr2 = {{q)}. {q3}, {qo. q4}, {qd. {qJ}
As qo is not 3-equivalent to q4, {qo. q4} is further partitioned into {qr} and
{Cf4}'
So.
Tr 3 = {{qo}, {qd. {Cf2}, {q3}, {Cf4}, {qs}}
Hence the minimum state automaton M' is the same as the given M.

EXAMPLE 3.21
Construct a minimum state automaton equivalent to a DFA whose transition
table is defined by Table 3.30.

TABLE 3.30 DFA of Example 3.21

State a b

-'>qo
q,
q2
®
®
q5
qs
q7
102 ~ Theory or Computer Science

Solution
Q? = {q3' (r~}, Q~ = {qo. ql' q2' q), q6' q7}

1fo = {{Q3, q4}, {qo. qj, Q2, qs, q6' q7}}

q3 IS I-equivalent to q4' So, {q3' q4} E 1f1'

qo is not I-equivalent to ql, q2, Cis but q() is I-equivalent to Q6'


Hence {q(). qd E 1f1. ql is I-equivalent to q2 but not I-equivalent to
qs, q6 or q7' So, {Ql' C!2} E 1f1'

qs is not I-equivalent to q6 but to q7' So, {Cis, q7} E 1fJ

Hence,
Jrl = {{q3' CJ4}' {q(), qe,}, {ql' q2}, {q5' (j7}}
q3 is 2-equivalent to q4' So, {q3, q4} E Jr2'
qo is not 2-equivalent to Q6' So. {qo}· {CJ6} E Jr2'
qJ is 2-equivalent to q2' So. {qj, Q:J E Jr~.

qs is 2-equivalent to q7. So, {qs, q7} E Jr2'


Hence.

q3 is 3-equivalent to q4; qj is 3-equivalent to q2 and Cis is 3-equivalent to qi'


Hence.

As Jr3 = Jr2' the minimum state automaton is

where 8/ is defined by Table 3.31.

TABLE 3.31 Transition Table of OFA for


Example 3.21

Slate a b

[qo] [q1. q2] [q1' q2]


[q1 q2] [q3, q4] [Q3, q4]
[q3, q4] [qs, q7] [qs]
[qs. q7] [q3. q4] [qs]
[qs] [qs] [qs]
Chapter 3: The Theory of Automata g 103

SELF-TEST
Study the automaton given in Fig. 3.20 and choose the correct answers
to Questions 1-5:

-iGJpo
1,/-\
/ \
oc£5 1 .8Jo
Fig. 3.20 Automaton for Questions 1-5
1. M is a
(a) nondeterministic automaton
(b) deterministic automaton accepting {O. I} *'
(c) deterministic automaton accepting all strings over {O, I} having
3m O's and 3n ]'s, m. 11 2 1
(d) detelministic automaton
2. M accepts
(a) 01110 (b) 10001 (e) 01010 (d) 11111
3. T(M) is equal to
(a) {03111 1311 1m. 11 2 O}
(b) {O'm 1311 I m. n 2:: I}
(e) {1\ IH' has III as a substring}
(d) {H I H' has 31i l·s. 11 2 I}
4. If q2 is also made a final state. then At accepts
(a) 01110 and 01100
(b) 10001 and 10000
(c) 0110 but not 0111101
(d) 0 311 • 11 2:: 1 but not 1311 • 11 2:: 1
5. If q: is also made a final state, then T(M) is equal to
(a) {0 3111 13/1 I In, 11 2 O} u {0 2111 1" I m, 11 2 O}
(b) {03m 13n I m. Ii 2 I} u {O:'" I" I m. 11 2:: I}
(c) {H' I H' has III as a substring or 11 as a substring}
(d) {w I the number of l's in is divisible by 2 or 3}
]V

Study the automaton given in Fig. 3.21 and state whether the Statements
6-15 are true or false:
0.1 0,1

@1---O-'~0
Fig. 3.21 Automaton for Statements 6-15
104 ~ Theory of Computer Science

6. M is a nondeterministic automaton.
7. 8(ql' 1) is defined.
8. 0100111 is accepted by M.
9. 010101010 is not accepted by M.
10. 8(qo. 01001) = {qd·
11. 8(qo, 011000) = {qo, qj, q2}'
12. 8(q2' 11') = q2 for any string W E {O, 1}*.
13. 8(q!, 11001) :t 0.
14. T(M) = {w I w = xOOy, where x, y E {O, 1}*}.
15. A string having an even number of O's is accepted by M.

EXERCISES

3.1 For the finite state machine M des.cribed by Table 3.1, find the strings
among the following strings which are accepted by M: (a) 101101,
(b) 11111, (c) 000000.
3.2 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.
3.3 Test whether 110011 and 110110 are accepted by the transition system
described by Fig. 3.6.
3.4 Let M = (Q, L. 8, qo, F) be a finite automaton. Let R be a relation in
Q defined by q j Rq2 if 8(qj, a) = 8(% a) for all a E L. Is R an
equivalence relation'?
3.5 Construct a nondeterministic finite automaton accepting {ab, ba}, and
use it to find a deterministic automaton accepting the same set.
3.6 Construct a nondeterministic finite automaton accepting the set of all
strings over {G, b} ending in aba. Use it to construct a DFA accepting the
same set of strings.
3.7 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

State 0 2

---7qo q,q4 q4 q2q3


ql q4
q2 q2q3
®
q4
q4
Chapter 3: The Theory of Automata ~ 105

3.8 Construct a DFA equivalent to the NDFA described by Fig. 3.8.


3.9 M = ({qb q2' q3}, {O, I}, 8, ql' {q3}) is a nondeterministic finite
automaton. where 0 is given by
o(Qj. 0) = {q2' q3}, o(qj, 1) = {qd
O(q2> 0) = {qlo Q2}, O(Q2' 1) =0
O(q3' 0) = {Q2}, O(Q3' 1) = {Q1' CJ2}

Construct an equivalent DFA.


3.10 Construct a transition system which can accept strings over the alphabet
a, 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

Present state Next state Output


a =0 a =1
1
o

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 Next state

a =0 a =
state output state output

-'7q1 q, q2 0
q2 q4 q4 1
q3 q2 q3 1
q4 q3 0 q, 1

3.13 Construct a Mealy machine which can output EVEN, ODD according
as the total number of l' s encountered is even or odd. The input
symbols are 0 and 1.
3J 4 Construct a minimum state automaton equivalent to a given automaton
M \vhose transition table is defined by Table 3.35.
106 ~ Theory of Computer Science

TABLE 3.35 Finite Automaton of Exercise 3.14

State Input

a b
-}qo qo q3
q, q2 q5
q2 q3 q4
q3 qo q5
q4 qo q6
q5 q1 q4
@ q1 q3

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.

o
o

~
I-----.~---_. .
tJ
0.1
Fig. 3.22 DFA of Exercise 3.16.

You might also like