Finite Automata
Finite Automata
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.
/1 'j Automaton °1
/2
°2
-----~
/p 01,02' ... , On Oq
71
72 li\ Theory of Computer Science
._---------------
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
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'
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.
c
D InI I [ I I I- -Ilt~~~t
S
1- ""dieg h,,,
i Finite
! control
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).
010
Fig. 3.5 A transition system,
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.
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.
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)
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.
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
~)~ 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
0 0 0
qo ~ qo • qo ~ qo • qo
\0
~\ ~
\
q3
\ q1 q3
\ q3
Fig. 3.9
\ q4
States reached while processing 0100.
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
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
EXAMPLE 3.6
Construct a deterministic automaton equivalent to
M ::: ({qo. qd· {O. l}. 8, qo, {qoD
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.
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.
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.
State/I a b
EXAMPLE 3.8
Construct a deterministic finite automaton equivalent to
State/I a b
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
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
---------------- --------------'---
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
~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.
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.
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.
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.
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 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.
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
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.
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
-~--
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.
a = 0 a =1
state output state output
-:;.Gi q: 0 q2 0
q2 q" 0 q3 1
q3 q" 0 q3 1
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.
a = 0 a =
state output state output
q2 Z, q3 Z,
q2 Z2 q3 Z-I
q2 Z, q3 Z2
Figure 3.11 gives the transition diagram of the required Moore machine.
Chapter 3: The Theory of Automata ~ 91
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.
StatelI. o
-'tqo
q1
®
q3
q4
qs
q6
q7
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.
State/I. 0
I---~o-_ _
7
A
[q2]
o
o !'\
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.
--- --------------
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
Q? = {q3}
As qo is 3-equivalent to q6,
As qj is 3-equivalent to qs,
As q2 is 3-equivalent to Q4,
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.
State/I. a b
b
Fig. 3.15 Minimum state automaton of Example 3,14,
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
Solution
The transition table of M is given by Table 3.25.
State a b
State a b
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)
~- -~-~-- ----------~~-
where F is the set of all subsets of {qo, qj' Q2' (/3} containing CJJ. <5 is defined
by Table 3.28.
State a b
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.
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
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
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.
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}
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~.
Slate a b
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.
State 0 2
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
State Input
a b
-}qo qo q3
q, q2 q5
q2 q3 q4
q3 qo q5
q4 qo q6
q5 q1 q4
@ q1 q3
o
o
~
I-----.~---_. .
tJ
0.1
Fig. 3.22 DFA of Exercise 3.16.