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

Finite Automata and Their Decision Proble'ms#: Is To The Formalism of Nerve-Nets. However

This document discusses finite automata and their decision problems. It introduces finite automata as machines that can classify tapes based on a finite number of internal states. Various generalizations of finite automata are presented, including nondeterministic, two-way, and multi-tape automata. It is shown that some decision problems about automata, such as whether an automaton accepts any tapes, are solvable by algorithms, while others, such as problems involving two-way multi-tape automata, are unsolvable.

Uploaded by

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

Finite Automata and Their Decision Proble'ms#: Is To The Formalism of Nerve-Nets. However

This document discusses finite automata and their decision problems. It introduces finite automata as machines that can classify tapes based on a finite number of internal states. Various generalizations of finite automata are presented, including nondeterministic, two-way, and multi-tape automata. It is shown that some decision problems about automata, such as whether an automaton accepts any tapes, are solvable by algorithms, while others, such as problems involving two-way multi-tape automata, are unsolvable.

Uploaded by

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

Finite Automata and Their Decision Problems#

Abstract: Finite automata are considered in this paper a s instruments for classifying finite tapes. Each onetape automaton defines a set of tapes, a two-tape automaton defines a set of pairs of tapes, et cetera. The structure of the defined sets is studied. Various generalizations of the notion of an automaton are introduced and their relation to the classical automata is determined. Some decision problems concerning automata are shown to be solvable by effective algorithms; others turn out to be unsolvable by algorithms.

Introduction

Turing machines are widely considered to be the abstract prototype of digital computers; workers in the field, however, have felt more and more that the notion of a Turing machine is too general to serve as an accurate model of actual computers. It is well known that even for simple calculations it is impossible to give an a priori upper bound on the amountof tape a Turing machine will need for any given computation. Itis precisely this feature that renders Turings concept unrealistic. In the last few years the idea of a finite automaton has appeared in the literature.These are machineshaving only a finite number of internal states that can be used for memory and computation. The restriction of finiteness appears togive a better approximation to the idea of a physical machine. Of course, such machines cannot do as much as Turing machines, but the advantage of being able to compute an arbitrary general recursive function is questionable, since very few of these functions come up in practical applications. Many equivalent forms of the idea of finite automata have been published. One of the first of these was the definition of nerve-nets given by McCulloch and P i t h 3 The theory of nerve-nets has been developed by authors too numerous to mention. We have been particularly influenced, however,by the work of S. C . Kleene2who proved an important theorem characterizing the possible action of such devices (this is the notion of regular eventin Kleenes terminology). J. R. Myhill,in some unpublished work, has given a new treatment of Kleenes results and this has been the actual point of departure for the investigations presented in this report. We have not, however, adopted Myhills use of directed graphs as
*Now at the Department of Mathematics, Hebrew University in Jerusalem. +Now at the Department of Mathematics, University of Chicago. were associated $The bulk of this work wasdonewhiletheauthors with the IBM Research Center during the summer of 1957.

114

a method of viewing automata but have retained throughout a machine-like formalism that permits direct comparison with Turing machines. A neat form of the definition of automata has been used by Burks andWangl and by E. F. Moore,4 and our point of view is closer to theirs than it is to the formalism of nerve-nets. However, we have adopted an even simpler form of the definition by doing away with a complicated output function and having our machines simply give yes or no answers. This was also used by Myhill, but our generalizations to the nondeterministic, two-way, and many-tape machines seem to be new. In Sections 1-6 the definition of the one-tape, one-way automaton is given and its theory fully developed. These machines are considered as black boxes having only a finite number of internal states and reacting to their environment in a deterministic fashion. We center our discussions around theapplication of automata as devices for defining sets of tapes by giving yes or no answers to individual tapes fed into them. To each automatonthere corresponds theset of those tapes accepted by the automaton; such sets will be referred to as definable sets. The structure of these sets of tapes, the various operations which we can perform on these sets, and the relationships between automata and defined sets are the broad topics of this paper. After defining and explaining the basic notions we give, continuingwork by N e r ~ d e ,Myhill, ~ and Shepherdson,7 an intrinsicmathematicalcharacterization of definable sets. This characterization turnsoutto be a useful tool for bothproving that certain sets are definable by an automaton and for proving that certain other sets are not. In Section 4 we discuss decision problems concerning automata. Weconsider the three problems of deciding whether an automaton accepts any tapes, whether it ac-

IBM JOURNAL APRIL

1959

cepts an infinite number of different tapes, and whether two automata accept precisely the same tapes. All three problems are shown to be solvable by effective algorithms. In Chapter 1 1 we consider possible generalizations of the notion of an automaton. A nondeterministic automaton has, at each stage of its operation, several choices of possible actions. This versatility enables us to construct very powerful automata using only a small number of internal states. Nondeterministic automata, however, turn out to be equivalent to the usual automata. This fact is utilized for showing quickly that certain sets are definableby automata. Using nondeterministic automata, a previously given construction of the direct product of automata (Definition 7 ) , and the mathematical characterization of definable sets, we give short proofs for various well-known closure properties of the class of definable sets (e.g., the definable sets form a Boolean algebra). Furthermore we include, for the sake of completeness, a formulation of Kleenes theorem about regular events. In trying to define automata which are closer to the ideal of theTuring machine, while preserving the important feature of using only a preassigned amount of tape, another generalization suggests itself. We relax the condition that the automaton always move in one direction and allow the machine to travel back and forth. I n this way we arrive at the idea of a two-way automaton. In Section 7 we consider the problem of comparing oneway with two-way automata, a study that can be construed as an investigation into the nature of memory of finite automata. A one-way machine can be imagined as having simply a keyboardrepresenting the symbols of the alphabet and as having the sequence from the tape fed in by successively punching the keys. Thus no permanent record of the tape is required for the operation of the machine. A two-way automaton, &on the other hand, does need a permanent, actual tape on which it can run back and forth in trying to compute the answer. Surprisingly enough, it turns out that despite the ability of backwards reference, two-way automata are no more powerful than one-way automata. In terms of machine memory this means that all information relevant to a computation which an automaton can gather by backward reference can always be handled by a finite memory in a one-way machine. InChapter 111 we studymultitapemachines.These automatacan readsymbols on several different tapes, and we adopt the conventionthata machine will read for a while on one tape,then change control and read on another tape, and so on. Thus, with a two-tape machine, a set of pairs of tapes is defined, or we can say a binary relation between tapes is defined. Using again the powerful tool of nondeterministic automata, we establish a relationship between two-tape automata and one-tape automata. Namely, the domain and range of a relation defined by a two-tape automaton are sets of tapes definable by one-tapeautomata.From this follows thefact that, unlike the sets definable by one-tape automata, the

relations definable by two-tape automata do not form a Boolean algebra. The problems whether a two-tape automaton accepts any pair of tapes and whether it accepts an infinite number of pairs are shown to be solvable by effective algorithms. We conclude with a brief discussion of two-way, twotape automata. Here even theproblemwhether an automaton accepts any tapes at all is not solvable by an effective algorithm. Furthermore a reduction of two-way automata to one-way automata is not possible. All in all, there is a marked difference between the properties of one-tape automata and those of two-tape automata. The study of the latter is yet far from completion.
Chapter 1.
Q

One-tape, one-way automata

1. The intuitive model and

basic definitions

An automaton will be considered as a black box of which questions can be asked and from which a yes or no answer is obtained. The number of questions that can be asked will be infinite, and for simplicity a question is interpreted as any arbitrary finite sequence of symbols from a finite alphabet given in advance. An easy way to imagine the act of asking the question of the automaton is to think of the black box as having the separate symbols on a typewriter keyboard. Then the machine is turned on and the question is typed in; after an end of question button i s pressed, a light indicates a yes or no answer. Other good images of how the automaton could appear physically would use punched cards. Suppose that we punch just one symbol or code number for a symbol to a card; then a question is simply a stack of cards. The automaton is asked a question by having the stack read in a card at a time in the usual way. For the purposes of this paper, we shall not use either of the above images but rather think of the questions as given on one-dimensionaltapes. Themachine will be endowed with a reading head which can read one square of the tape (i.e., one symbol) at a time, and then it can advance the tape one unit and read, say, the next square to the right. We assume the machine stops when it runs out of tape. So much for the external character of an automaton. The internal workings of anautomaton will not be analyzed too deeply. We are not concerned with how the machine is built but with what it can do. The definition of the internal structure must be general enough to cover all conceivablemachines, but it need not involve itself with problems of circuitry. The simple method of obtaining generality withoutunnecessarydetail is to use the concept of internal states. No matter how many wires or tubes or relays the machine contains, its operation is determined by stablestates of themachine at discrete time intervals. Anactual existing machinemayhave billions of such internalstates, butthenumber is not important from the theoretical standpoint-only the fact that it is finite. As a further simplifying device, we need not consider all the intermediate states that the machine passes

7 15

IBM J O U R N A L

APRIL

1959

through but only those directly preceding the reading of a symbol. That is, the machine first reads a symbol or squareonthe tape, then it may pass through several states before it is ready to read the next symbol. To be able to mimic the action of the automaton, we need not remember all these intermediate states but only the last one it goes into before it reads the next square. I n fact, if we make a table-of all the transitions from a state and asymbol to a new state, then the whole action of the machine is essentially described. Finally, to get the answer from the machine, we need only distinguish between those states in which the yes light is on and those states in which the no light is on when the end of the question is reached. Again, for simplicity, it is assumed that all states are in one category or the other but not in both. Thus the whole machine is described when a class of designated states corresponding to the yes answers is given. It remains now to give a precise mathematical form to these ideas. First a finite alphabet Z is given and fixed for the rest of the discussion. The actual number of symbols in the alphabet is not important. It is only important that all the automata considered use the same alphabet so that different machines can be compared. For illustration we shall often think of Z as containing only the two symbols 0 and 1. By a tape we shallunderstandany finite sequence of symbols from 8. We also include the empty tape with no symbols to be denoted by A . The class of all tapes is denoted by T . If x and y are tapes in T , then xy denotes the tape obtained by splicing x and y together or by juxtaposing or concatenating the two sequences. In other words, if
x=
UU1

ning fromthe ( k + 1 ) s t symbol of x throughthe lt symbol.Clearly, the length of is 1-k. We will agree , tape of length 0 . As a useful that if k = l , then k x l = ~ the property of the notation, we have
x=Oxl; ,x),,

where k*n, or more generally


k X r n = k X ~ 1Xnu

where k L l f m l n . We shall refer to suchtapes as oxk as the initial section or initial portion of x of length k . The obvious notation x for xxx . . . x multiplied together n times will also be used with the convention that
xo=A.

Having explained all the notations for the tapes that will be fed into the machines, we turn now to the formal definition of an automaton. Definition 1. A (finite) automaton over the alphabet X is a system $I=(S,M,s,,F), where S is a finite nonempty set (the internal states o f s ) ,M is a function defined on the Cartesian product S X Z of all pairs of states and symbols with values in S (the table of transitions or moves o f X), so is an element o f S (the initial state o f ST), and F is a subset o f S (the designated final states o f 91). Let 81 be an automaton. First of all the function M can be extended from S x Z to SX T in a very natural way by a definition by recursionas follows:
M ( s , A ) =x, for s in S;
M ( s , x u ) = M ( M ( s , x ) , u ) ,for s in S, x in T , and u i n X.

. . . u,l

-1

and
)=TOTI..
T,l-l,

then
XY=U,,Ul..

. U l 1 - 1 T ~ T 1. . .
us

T%-l,

The meaning of M ( s , x ) is very simple: it is that state o f the machine obtained by beginning in state s and reading through the whole tape x symbol by symbol, changing states according to the given table of moves. It should be at once apparent from the definition of the extension of M just given that we have the following useful property:
M ( s , x y ) = M ( M ( s , x ) , y ) ,for all s in S and x,y in T.

where the two laws

and

TS

are in Z. We assume as obvious the

Ax=xAX,

and
X(YZ) = ( X Y 12,

for all x , y , z in T . In mathematical terminology, T together with the operation of juxtaposition forms the free semigroup (with unit) generated by Z. We shall often have occasion to cut tapes into pieces. For example, let
x=u,,u,

We may now easily define the set of those tapes which cause the automaton to give a yes answer. Definition 2. The set of tapes accepted or defined by the automaton X, in symbols T ( a ) , is the collection of all tapes x in T such that M(so,x) is in F. Definition 3 . The class of all definable sets of tapes, in symbols 3, is the collection o f all sets o f the form T ( % ) f o r some automaton The meaning of acceptance can be made clearer by a diagram. Let x=uo . . . Foreach k L n , let

a.

. . . ul-l; . ut-1,
h.l

Slc=M(So,oXJ

the US are in Z and n is referred to as the length of the tape X . We adopt the following notation
kxd=ugu&+1..

so that for k>O we have


Sk=M(Sh--l,uk-l).

116

where k G l S n . Inother words

is a section

of x run-

The condition that x bein T(91) is that sn be in F . Each sk is the state of the machine 81 after reaching the

1BM JOURNAL

APRIL

1959

kt11 symbol in the tape x . Thus if we write down the following diagram:
UI) 01

u2
SZ

...
sp

un-1

S O

S1

.. .s , -1

Sn,

we have a complete picture of the motion of the machine $1across the tape x. It is very important to notice in this picture that there is exactly one more internal state than there are symbols on the tape, a fact that will be used several times in Section 4.
2 . A mathematical characterization of definable sets

(iii) the explicit congruence relation E defined by the condition that for all x,y in T , x=y if and only if forall z,w in T , whenever zxw isin U , then zyw is in U , and conversely, is a congruence relation o f finite index. Proof: Assume (i)and in particularthat U = T ( ? I ) for a suitable automaton i ? l . Define a relation R by the condition that xRy if and only if M ( s , x ) = M ( s , y ) for all s in S. Clearly R is an equivalence relation, but it is also a congruence relation. For assume that xRy and z is any tape in T . Then
M ( s , x z )= M ( M ( s , x ) ,z) =M(M(s,y) ,z) =M(s,yz), for all s in S.

An automaton can be a very complicated object, and it is not clear exactly how complicated the sets definable by automata can become. In order to understand the nature of these definable sets, we will develop in this section a mathematicallysimple and completelyintrinsic characterization of these sets, which shows exactly the effect of consideringmachines with onlya finite number of internal states. This finiteness condition is certainly the main feature of our study. Actually two different characterizations will be given, but they share a common feature of involving equivalence relations over the set T of all tapes. The reader is assumed familiar with the notion of an equivalence relation and equivalence classes. Definition 4. A n equivalence relation R over the set T of tapes is right invariant if whenever xRy, then xzRyz f o r all z in T . Clearly there is an analogous definition of left-invarinnt equivalence relations. Definition 5. A n equivalence relation over the set T is a congruence relation if it is both right and left invariant. If R is a congruence relation then the formulas xRz and y R w always imply xyRzw. In consequence, if [x] is the equivalence class containing x, and [ y ] is the equivalence class containing y , then we can define unambiguously the product of the two equivalence classes by the equation
[~lbl=[xYl.

Thus R is right invariant. Likewise


M(s,zx) =M(M(s,z),x) = M ( M ( s , z ), Y ) =M(s,zy), for all s in S,

In mathematical terms, the set of equivalence classes is said to be the quotient semigroup of T under the congruence relation R and is called a homomorphic image of T . There are many distinct homomorphic images of T , but we shall be most interested in those that are finite. Somewhat more generally we shall make use of equivalence relations satisfying the following definition. Definition 6. A n equivalence relationover T i s of finite index if thereare only finitelymany equivalence classes under the relation. With these definitions, we may now state thefirst result on characterizing definable sets. This theorem is due to J . R. Myhill and is published with his kind permission. Theorem 1 . (Myhill) Let U be a set of tapes. The following three conditions are equivalent: (i) U is in T; (ii) U is the union of some o f the equivalence classes of o congruence relation over T of finite index;

and R is shown to be left invariant. That R is of finite index is a consequence of the fact that if x is a fixed tape and r is the number of internal states of 91, then the expression M ( s , x ) can assume at most r different values. Thus the number of equivalence classes is at most rr. Finally if x is in T ( g ) and xRy, then M ( s , , x ) = M ( s , , y ) so that y is in T ( a ) also. This remark shows that U = T ( $ [ ) is in fact the union of the equivalence class under R of those tapes in U . We have thus shown that (i) implies (ii). Assume next that statement (ii) holds, and let R now stand for any congruence relation satisfying the conditions mentioned in (ii). Consider the specific relation defined in (iii) in terms of U . Let x and y be any tapes such thatxRy. Suppose that zxw is in U . Now R is a congruence relation, so that zxwlzzyw. On the other hand U is a union of equivalence classes. Thus zyw must also be in U . Thisargument actually shows that if xRy, then x s y . In other words, = is a relation making fewer disis a congruence tinctions than the relation R . That relation is a trivial consequence of its definition, so if R is of finite index, then E must necessarily be of finite index too. Hence, (ii) implies (iii) . Finally,assume that(iii) holds. We must define an automaton 9[ such that U=T(iX). To this end, let S be the set of equivalence classes under the congruence relation =. Define the function M by the formula:
M([xl,u)=[xal,

where the square brackets indicate the formation of equivalence classes. Notice we need only the fact that = is rightinvariant to see that the definition of M is unambiguous. Further, let s o = [ A ] , and finally let F be the set of all [x] where x is in U . It should be obvious that U is indeed a union of equivalence classes under 3. A simple inductive argument shows that if M is extended in the way indicated in Section 1 to the set S X T , then M ( [ x ] , y ) = [ x y ] for all x,y in T . Thus we see at once that M ( s , , x ) = M ( [ A ] , x ) = [ x ]is in F if and only if x

117

IBM JOURNAL

* APRIL

1959

is in U ; in other words U = T ( $ [ ) ,as was to be shown. Hence, (iii) implies (i) , and the proof of Theorem 1 is complete. The main trouble with Theorem 1 is that the number of equivalence classes under the relation E can become verylargeas is indicatedin the proof that (i) implies (ii). To be more economical and to stay closer to the simpler automata defining the set U , one should use only right-invariant equivalence relations rather than demanding congruence relations. The following theorem is formulated in an exactly parallel fashion to Theorem 1 and is essentially a simplification of a theorem by A. Nerode,& who used a somewhat more involved notion of automaton than that adopted here. The principle is very useful and was employed by J. C. Shepherdson7 in a proof of the main theorem of Section 7, as is explained there. Theorem 2. (Nerode) Let U be a set o f tapes. The following three conditions are equivalent: ( i ) U is in T ; (ii) U is the union of some of the equivalence classes o f a right-invariantequivalencerelation overTof finite index; (iii) the explicit right-invariant equivalence relation E defined by the condition that f o r all x , y in T , xEy i f and only if f o r all z in T , whenever x z is in U , then y z is in U , and conversely, is an equivalence relation o f finite index. The proof need not be given in detail because it can be copied almost wordfor word fromthe proof of Theorem 1 . It should only be mentioned that the relation R in the proof that (i) implies (ii) has the simpler definition:
x R y i f and only i f M ( s , , x ) = M ( s , , y ) .

of tapes, but the discussion of this fact will be delayed to Section 6. Sometimes it is easier to use Theorems 1 and 2 and sometimes it is easier to give direct constructions of machines. In this section we shallindicatehow the Boolean operations canbedone in both ways. First, however, we prove two theorems that seem to be easier by the indirect method. Theorem 3. I f x is in T , then {x}, thesetconsisting only o f x, is in T . Proof: Clearly an automaton can be built which recognizes one and only one tape given in advance; however, Theorem 2 is easier to apply. The relation E deof U = (x} simply fined in Theorem 2 (iii)interms means that y E z if and only if whenever y and z are initial segments of the tapex, then y = z . Thus E has oneequivalence class for each initial segment of x and one extra equivalence class for all the rest of the tapes. Obviously E then is of finite index, which completes the proof. If x is any tape, then it can be turned end-for-end and written backwards. Let x+ stand for the result of writing x backwards so that if x=uou1.. . then x"= u ~ ~ - -~ 2 u . ., .~ uO.Clearly we have the rules:
u

=u,

for u in 2,

A*=&

x: :0 =x,
and
( x y ) :?xy::x::

This implies that the number of equivalence classes for R is at most the number of internal states of 91. This remark and an analysis of the full proof leads directly to the following corollary. Corollary 2.1. I f U is in 3, then the number of equivalence classes under the relation E is the least number o f internal states of any automaton defining U . Inother words, the relation E leads atoncetothe most economical automaton defining U . This remark is is also due to Nerode. As a simple application of Theorem 1, we shall show that the set U of all tapes of the form O"10" for n=0,1,2, . . . is not definable by any automaton. Suppose to the contrary that U is in 5.Consider the relation of Theorem 1 (iii) . This relation would have to be of finite index, so that for some integers n+m we would have Ofl-Om. It follows at once that 0"lOm~OnlO", and hence that On1Om is in U , which is impossible. Thus U cannot be in 3.

3. Closure properties of the class of definable sets


Using the theorems just given in the preceding section, we can derive very simply some facts about the class 7. It turns out that 7 can be actually characterized by its closure properties under some natural operations on sets

118

In case U is any set of tapes, U-"will denote the set of all x" where x is in U . The motion of an automaton, according to the definitions of Section 1, is always from left to right. Thus from the original definition, the following result is a little surprising. Theorem 4. I f U is in 3, then U* is in 3. Proof: The content of the theorem is that if a set of tapes is definable, then so is the set obtained by writing all the defined tapes backwards. The direct construction of a machine defining U" from a given machine defining U is rather lengthy, but Theorem 1 makes the result almost obvious. Let = be the relation defined in terms U from Theorem 1 (iii) and let =* be the analogous relation for U * . Assume that x - - " ~ .If zx*w is in U , then ( z x " w )d is in u*. But ( z x : k w ) "=w:>xz:>. Hence, w*yz* is in U-"also; however, w * y z * = ( z y * w ) * , and so z y * w is in U . This shows that x"=y:>. Since U':'k=U,this argument with U and U" interchanged is also valid, and we haveproved that x=*y if and only if x * " y * , for all x,y in T . Clearly then, if 3 is of finite index, then =* must be also of finite indexwith the same number of equivalence classes, which completes the proof. Theorem 5. The class 3 is a Boolean algebra o f sets. Proof: That the class 3 is closed under complements is the most obvious fact, even from the original definition. For if U = T ( g ) where 'ill=(S,M,s,, F ) , then T - U= T ( % ) , where 'B=(S,M,s,,S"F). One need only prove in addition that T is closed under intersections. Suppose

IBM JOURNAL

APRIL

1959

that U 1 and U 2 are in 7. By Theorem 2, let R 1 and R 2 be two right-invariant equivalence relations of finite index such that Ui is a union of equivalence classes under Ri for i=1,2. Consider the equivalencerelation R3= R,AR,, in other words xR,y if and only if xR,y and xR,y. R, is, of course, right invariant. Every equivalence class under R, is an intersection of equivalence classes under R 1 and R,. Hence,thenumber of equivalence classes for R , is at most the product of the numbers for R , and R2. We see, then, that R3 is of finite index. Now u,nU, is simply a union of intersections of the two kinds of equivalence classes, so that U l A U 2 is a union of equivalence classes under R,, which shows that U , A U , is in 3 by Theorem 2. The proof is complete. Corollary 5.1. The class 3 contains all finite sets 6f tapes. This is a direct consequence of Theorems 3 and 5. The proof of Theorem 5 may seem too abstract. To make it more direct, we show next how to form at once a machine defining the intersection. Definition 7. Let %=(S,M,so,F) and B=(T,N,t,,G) be two automata. The direct product 21 X % is that automaton (SX T , M X N , ( s o , t o ) , F X G ) where S X T and F X G are the Cartesian products o f sets, (so,to) is the ordered pair of so and to, and the function M X N on (SX T ) X Z is defined by the formula
( M X N )( ( s , t ) , a ) = ( M ( s , o ) , N ( t , o ) )

91. By way of contradiction, assume that r 4 n . It follows at once that there must exist integers k < l L n such that
M(s,,ox,) = M ( S o , o X J
Y

where oxk and ox1 are the initial segments of x of length k and 1. Consider the tape X ' = ~ X ~zx, which is shorter than x. We have
M(s,,x')
=M(SO,OXk

6,)
9 Z d

=M(M(so,ox,) ,&) =M(M(so,ox,) =M(so,oxz z x , ) =M(s,,x)

for all s in S, t in T , and u in X. Theorem 6. I f E and ? 3 are automata, then T(9IXB)=T(i!l)AT(B). Proof:An obvious inductiveargument shows that for all tapes x we have ( M x N( ) ( s , t ) ,x)= ( M ( s , x ), N ( t , x )) for all s in S and t in T . Now x is in T ( % X 8) if and only if ( M x N ) ((so,to),x) = ( M ( s o , x ) , N ( t o , x ) ) is in F X G . This in turn is equivalent to the conjunctions of conditions that M ( s o , x ) is in F and N(t,,x) is in G ; in other words, x is in T ( % ) n T ( B ) , as was to be shown.
0

because x=oxl ,x,. Hence x ' must be in T ( E) also, which contradictstheminimum conditions on x and proves that n<r. Corollary 7 . 1 . Given a finiteautomaton there is an effective procedure whereby in a finite number of steps it can be decided whether T ( % ) is empty. The corollary is an immediate consequence of the fact that Theorem 7 shows that only a finite number of tapes that need be tried, and any one tape can be effectively run through a machineoncethe table of moves has been given. It is also possible to give a simple necessary and sufficient condition of a similar nature for T ( % ) to be infinite. We precede that result by a lemma. Lemma 8. Let 2 be an agtornaton with r internal states. Let x be a tape in T ( % )o f length n. I f r L n , then there exist tapes y,z,w such that x=yzw, z+A, andall the tapesyzmw are in T(91) for m=0,1,2.. . . Proof: As inTheorem 7, theremust exist integers k S L n such that
M(s,,,x,)
=M(So,oXJ.

Let Y = ~ , X , ~z=,xZ, , w =z x , . Since k < 1, we see that z+A. ClearIy x=yzw, and Y Z = ~ X ~ hence , M ( s , , y ) =M(s,,yz). It follows thenatonce by induction that M(s,,y) = M(so,yzm).Whence, we derive

4 . The emptiness problem

Suppose someone gave you an automaton %= (S,M,so,F) without telling you what it was supposed to do. The gift might turn out to be an elaborate practicaljoke, and T ( 9 I ) could very well be empty. Now aperson would not want to spend the rest of his life feeding all the infinite number of possible tapes into the machine if all the answers are going to be the same. Thus one would like to know an upper bound on the number of tapes that need be tried to determine whether the machine is of any use. Such an upper bound is smupplied by the next theorem. Theorem 7. Let 9 1 be an automaton.Then T ( % ) is not empty if and only if 91 accepts some tape of length less than the number of internal states o f 91. Proof: We need only establish the implication from left to right. Assume that T ( % ) is not empty and indeed that x is a tape in T ( % )of minimal length. Let n be the length of x and let r be the number of internal states of

M ( s , , x ) =M(s,,yzw) =M(M(s,,yz),w) =M(M(s,,YZm),w) =M(S",yZmW).


Thus all the tapes yzmw are also in T ( X). Theorem 9. Let be an automaton with r internal states. Then T(21) is infinite if and only if it contains a tape of length n with r l n L 2 r . Proof: The implication from right to left is a direct consequence of Lemma 8. Assume that T ( % ) is infinite. The alphabet Z is finite, and so T ( X ) must contain tapes of length greater than any integer. Let x be a tape in T ( 9 [ ) of length n k r . Asintheothertwo proofs, there must exist integers k < l L n such that

M(so,ox,) = M ( S o , o X d .

Now take a new tape x which is of minimal length of any tape in T ( %) for which integers k<l exist satisfying the aboveequation. Assume further that I is the least such integer 4 n = t h e length of x. We no longer know

119

I B M J1OURNAL

APRIL

1959

ber of stepsit equivalent.

can be decided whether ?I and 8 are

Since there are at most r values for the functionM to assume, this proves that 1Lr. Further, if l-Li<jLn, then
M(s,,oxi) i M ( s o , o x j ) ,

since otherwise the tape x ' z 0 x i j x , would be a shorter tape than x satisfying the given conditions on x . Counting - the number of indices between I and n, we see that n--I+ 1 5 . Adding 1 toboth sides and applying the previous inequality, we find n 1 1 2 r , or better, n<2r. If r g n , then the proof would be complete; however, this maynotbe the case. Assume that n<r. Let Y = ~ X & , Z = ~ X , ,W = ~ X , . We have x+& and all tapes yznzw are in T ( %) . Let m be the least integer such that

All the results of this section are quite evident from 2.2. Only the literature, e.g., Burks-Wang,l Section Theorem 10 and its corollary are a little stronger than the corresponding results there because of a wider definition of equivalence of automata. These results are nonetheless included for completeness, since the general approach here is rather different.

Chapter 11. Reductions to one-way automata


0

5. Nondeterministic operation

r L k + m ( l - k ) +(n-1).

Clearly m+0,
2rLk+m(l-k) rdk+

since k + ( n - l ) <n<r.

If

+ (n-1), then ( m - l ) ( l - k ) + (n-1),

because 1- k + z < r . But this is impossible because m was chosen as the least such integer. Hence
k+rn(l-k)

+(n-I)

<2r

and the number on the left is the length of yz"w, which proves that there is some tape in T(s) of the indicated length. Corollary 9.1. Given a finite automaton there is an effective procedure whereby in a finite number of steps it can be decided whether T ( x ) is infinite.

x,

Corollary 9.2. Let 3 be a finite automaton with r ininternal states, and let the alphabet Z have q > 1 symbols. Then if T(?1) is finite, it can have at most

2
k<r

q"=4T--1 tapes. q-1

120

Notice also thatLemma 8 gives another proof that the set of tapes of the form Onlo" is not definable by any finite automaton. Finally we shall treat inthis section the question of decidingwhethertwo automata define the same set of tapes. Definition 8. Two automata 21 and 8 are equivalent if T(?U = U B I . Theorem 1 0 . Two automata X and 8 are not equivalent if and only if there is a tape x of length less than the product of the number of internal states of % by that of 9 3 which is accepted by one machine but notby the other. Proof: Let g ' be the machine having the same internal statesas and defining the complement of T ( X ) as in '3 . % and 8 are the proof of Theorem 5. Similarly for 2 , not equivalent if and only if one of the sets T ( % X W ) T ( % ' x ~ )is not empty. The theorem follows nowdirectly from Theorem 7, Theorem 6 and Definition 7. Corollary 10.1. Given two finite automata 8 and 8, there is an effective procedure whereby in a finite num-

The a'utomata used throughout Chapter I were strictly deterministic in their tape-reading action, which was uniquely determined by the table of moves, since there was one and only one way the machine would change its state in any particular situation. Requiring all machines to be of this form can lead to rather cumbersomedetails, in view of the large number of internal states needed even for some relatively elementary operations. In this section we introduce the notion of a nondeterministic automaton and show that any set of tapes defined by such a machine could also be defined by an ordinary automaton. The main advantage of these machines is the small states that they require in many number of internal cases and the ease in which specific machines can be described. Several examples of their use will be found in Section 6. Definition 9. A nondeterministic (finite) automaton over the alphabet Z is a system %=(S,M,So,F) where S is a finite set, M is a function of S X S with values in the . set of all subsets of S, and Soand F are subsets of S A nondeterministic automaton is not aprobabilistic machine but rather a machine with many choices in its moves. At each stage of its motion across a tape it will be at liberty to choose one of several new internal states. Of course, some sequence of choices will lead either to impossible situations from which no moves are possible or to final states not in the designated class F . We disregard all such failures, however, and agree to let the machine accept a tape if there is at least one winning combination of choices of states leading to a designated final state. The next definition makes this convention precise. Definition 10. Let 91 be a nondeterministic automaton. is the collection of The set T ( j J ) of tapesacceptedby all tapes x=u0u1 . . . for which there exists a sequence so,sl, . . . , s , ~of internal states of PI such that (i) so i.s in So; (ii) si is in M ( S ~ - ~ , U f~ or - i=1,2, ~ ) , . . ,n; (iii) s , is in F . It is readily seen that if 91 is a nondeterministic machine such that M(s,u) consists of exactly one internal state for each s in S and u in 8,then t[is really the same T ( 3 ) will containthe as anordinaryautomaton,and expected tapes. Thus ordinary automata are special cases of nondeterministic automata, and we shall freely identify the ordinary machines with their counterparts. One might imagine at first sight that these new ma-

IBM JOURNAL

APRIL

1959

"

~~.

ordinary automaton, defining exactly the same set of as tapes given nondeterministic machine. Definition 11. Let S = ( S , M , S o , F ) be nondetera ministic autumatun. %(!X) is the system (T,N,to,G) where T is the set of all subsets of S, N is a function 0 1 1 T X Z such that N(t+,) is the union of the sets M ( s , u ) f o r s in 1, tO=SO, and G is the set of all subsets of S containing at least one member of F . Clearly D( 3) is an ordinary automaton, but it is actually equivalent to !X. Theorem 11. If 3 is a nondeterministicautomaton, then T ( % )= T ( % ( X ) 1. Proof: Assume first that a tape x=u0u1 . . . u , - ~ is in T (91) and let so,sl, . . . ,s , be a sequence of internal states satisfying the conditions of Definition 10. We show by induction that for k l n , sk is in N ( For k = O ,N ( t o , o x k ) = N ( t , , A ) = t o = S , and we were given that so is in So.Assume the result for k - 1. By definition, ~ ( t o , o x k ) = N ( ~ ( t O , o x k - l ) , ~ kBut - l ) . we have assumed s k - l is in N ( t o , o x k - l ) so that from the definition of N we have M ( S ~ . - ~ , U ~N-(~ t , ,), C x , ) . However, sk is in M ( S ~ - ~ , U and ~-~ so ), the res'ult is established. In particular s , is in N ( t , , o x , ) = N ( t , , x ) , and since s , is in F, we have N ( t o , x ) in G, which proves that x is in T ( %( 91) ) . Hence, we have shown that

( S , M * , F , S o ) wherethefunction condition
.s'

M s is definedbythe

is in M" (s,u) if and only ifs is in M ( s ' , u ) .

Notice that we have at once the equation 91"" =%. The relation between the sets defined by an automaton and its dual is as follows.
Theorem 12. If 91 is a nondeterministicautomaton, then T ( X * )= T ( W *. Proof: In view of the equality %*:!==?I,we need only show T ( S * ) <T ( S ) " . Let x = u O u l . . . be a tape in T ( % * ) ; we must show that x* is in T(91). Let so&, . . . ,s , be the sequence of internalstates of %* such that so is in F, s , is in So and s , is in M*(sk-l,uk-l) for k= 1,2, . . . , n. Define a new sequence S ' ~ ~ , S '. ~. , ., s ' ,by theequation S ' ~ = S , + ~ for k L n . Obviously, d o is in S,, and , ' s is in F . Further,for k>O and k L n , S ' ~ - ~ = S , - ~ + ~ is in M * ( s ~ - ~ , u , or ~~ in) other , words, S,_,~"S'~ is in M ( S ' ~ ~ , , U , Now - ~ ) . defining a new sequence of symbols d o d l . . . a ' , , by the formula d k = unPk-1, we see that u'k"l=u,-k and u',,dl . . . u ' , - = x". Thus, x + is in T(91) as was to be proved. It should be noted thatTheorem12 together with Theorem 11 yields adirectconstruction and proof for Theorem 4 of Section 3 which was first proved by the indirect method of Theorem 1. In the next section we make heavy use of the direct constructions supplied by the nondeterministic machines to obtain results not easily apparent from the mathematical characterizations of Theorems 1 and 2.

T(91)C T(D(91) >.


that a tape x=u0u1 . . . u,-~ is in k L n , t k = N ( t o , , x k ) . We shall work backwards. First, we know that t , is in G. Let , be any internal state of 8 such that s,, is in t , then s and s , is in F. Since s , is in Assume next

T ( B ( S ) ) .Let for each

tn=N(t,,,(,X,)=N(t,-l,u,_,),

we have from the definition of N that s,, is in M(S,-~,U~for ~ ) some s,-~ in t , - l . But
tn"l=N(tO,"X,-l) =N(tn--2,un"2),

so that s,-~ is in M ( s , - ~ , u , - ~ )for some s , _ ~ in t , , - 2 . Continuing in this way we may obtain a sequence, S,,S,-~,S,-~, . . . , s o suchthat sk is in t,; sk is in M ( S ~ - ~ , U for ~ k>O; ~ ~ ) and , s , , is in F . Since tO=SO, we also have so in So, which proves that x is in T ( ? I ) . Thus, T ( %( 91) T ( g i ) , which completes the proof. This theorem has many interesting consequences. For example, it shows that any automaton with several initial states can be replaced by an equivalent automaton with but one initial state. It would seem that the notions of finalstateand initial state shouldbedual in some sense. But one must be careful, because, as the reader may easily show for himself, with the alphabet Z={O,1} the set of all tapes of the form 0" or 1% cannot be defined by anynondeterministic automaton with but one designated final state. The correct notion of duality between initial and final states is connected with the reversal of right and left, as indicated in the next definition and theorem.

)c

6. Furtherclosureproperties Simplifying a result due originally to Kleene, Myhill in unpublished work has shown that the class T can be characterized as the least class of sets of tapes containing the finite sets and closed under some simple operations on sets of tapes. We indicate here a different proof using the method developed in the preceding section. First of all, we need to define the operations on sets of tapes. Let U and V be two sets of tapes. By the complex product UV of U and V we understand the collection of alltapes of the form xy with x in U and y in V . Clearly the product of sets satisfies the associative law: (UV)

w=U ( V W ).

This leads to the introduction of finite exponents where we define U n = U U . . . U ( n times) with the convention than Uo= {A}. Finally, if U is aset of tapes we can form the closure of U , in symbols cl( U ) , which is the least set V containing U , having A as an element, and such that whenever x, y are in V then xy is in V . Another definition is given by the equation
cl(U)=U"yUlyU'~U~ . .. ,

where the infinite union extends all over finite exponents. We may prove at once about these operations that the class 7 is closed under them.

121

IBM JOURNAL

- APRIL 1959

Proof: Assume first that U , V are in 7. Let U = T ( % ) and V= T ( % ) where $1and B are ordinary automata with 9[= (S,M,s,,F) and %= ( T , N , t , , G ) . We need only find a nondeterministic machine 6 such that UV= T ( Q). We may assume that the sets S and T have no elements in common, and then equate Q=(SyT,P,{s,},G) where the function P is defined as follows: P(s,~)={M(s,u)),
P(S,U)

if s is in S - F ; if s is in F ;

=CM(s,@),N(To,u) 1,

p(t,u) =N(f,u),

if t is in T.

The straightforward proof that G has the desired property is left to the reader. Next, we must show why Hcl( U ) is in 3. Weconstruct a machine % such that cl( U ) =T ( %), where 9is allowed to be nondeterministic. Simply let %= (S,Q,s,,,F), where the function Q is defined as follows:

Q ( S , ~ ) = { M ( S , U ) } , if

is in 5 F ; if s is in F .

Q ( ~ , u={M(J,u) > ,M(so,o)},

The easy completion of the proof is left to the reader. Theorem 14. (Kleene-Myhill) . The class T is the least class o f sets o f tapes containing the finite sets and closed under the formation o f unions, complex products, and closures o f sets. The full proof of Theorem 14 will not be given. Instead we give a brief account of the method of proof needed. Let U be the least class closed under the operations mentioned in the theorem. That UC T is the content of Theorems 5, 5.1, and 13. To prove that T C U , consider each set in 3 to be of the form T ( % ) , where $1 is nondeterministic, and proceed by a kind of induction on 91. In more precise terms, define the weight of X, in symbols 1 9 x 1 , to be the sum of all the cardinal numbers of the sets M ( s , u ) for all s in S and u in 8 . Then by assuming that T ( B ) is in U for all % with /%\<1411, one can prove that T(91) is also in U . The details, however, are tiring. This discussion completes our survey of the closure properties of the class of definable sets begun in Section 3, and the authors are not awareof any other interesting operations on sets that can be effected by constructions of automata that we have not already indicated. The remainder of this paper will be therefore devoted to generalizations of the notion of an automaton.
7. Two-way automata Trying to further generalize the notion of an automaton, we consider afutomatawhich are not confined to a strict forward motion across their tapes. This leads to the following definition, which is a direct extension of Definition 1. Definition 13. Let L = { - l , O , + I}. A two-way (finite) automation over a finite alphabet Z is a system 91= (S,M,s,,F) where S is a finite non-empty set (the set of

122

(the initial state oj and F is a subset o f S (the set o f designated final states of %) . A two-way automaton a operatesasfollows: When given a tape, i.e., a finite linear sequence of squares each containing a single symbol of the alphabet Z, % is set in internal state so scanning the first (leftmost) square of the tape. At each stage of the machine's operation, if the internal state is s, the scanned symbol is U , and M ( s , u ) = ( P , s ' ) , where p is one of -1,O,l, then X will move one square to the left, stay where it is, or move one square to theright, according as p = - 1,0,1; furthermore, $[ will enter internal state s'. The operation described just now is called an atomicstep of 91. After completion of an atomicstep, $1is againina certain internal state scanning a certain symbol, and a new atomic step is performed, and so on. If, when operating in this way on a given tape, % will eventually get 08 the tape on the right side and at that time be in a state in F, then we shall say that the tape is accepted by 3. The formal definition is as follows: Definition 14. The set T ( % ) o f tapes accepted by the two-way automaton X is the set of all sequences u,, . . . un.-] o f symbols from the alphabet Z for which there exist an integer m>O, asequence o f integers po, . . . , pn,, and a sequence so, . . . , s , o f internal states of 2 such that (i) po=O and so is the initial state o f $1; (ii) OLpi<n for i=O, . . . , m - 1 ; (iii) pm=n and s , isin F; (iv) (~~-p~-~,s~)=M(s,~_,,u,,~_,) for i = l , . . . , m. Inthe above definition the sequence p,,, . . . , p m should be interpreted as the sequence of positions of the machine 91 onthetape;thus, p i - p i - l indicates the change in position of the machine from time i - 1 to time i. Condition(ii) , for example, meansthatthe machine does not run off the tapebefore thecomputationhas been completed. In analogy with Definition 3 we shall say that a set P of tapes is definable by a two-way automaton if there exists some two-way automaton such that T ( =P. To avoid confusion we shall, from now on, refer to the automata discussed in Sections 1-6 as one-wayautomata. Let us consider an example of a two-way machine illustrating the complicated fashion in which such a machine can operate on a given tape. Let %, ! & and 6, be three one-way automata over the same alphabet X. We combine these automata into a single two-way automaton having the following flow diagram. Given a tape t the automaton % (which we imagine as being a part of 9 ) starts reading it on the left end and proceeds from left to right until a designated final state of 91 is reached; when this happens B goes into the initial state of 8 and starts reading the tape from right to left until a designated final state of 8 is reached; when this happens % switches into the initial state of % and again starts moving from left to right, and so on; all this time automaton

a),

..

"

x)

IBM JOURNAL

APRIL

1959

Q is reading the tape symbols as they come in (i.e., in the sequence in which they are being scanned by 9) and t is accepted by 5Q only if 2 ever gets off the right-hand end of t and at that time (5 is in one of its final designated states. It seems to be quite difficult to determine the kind of set of tapes defined by 9 . It turns out, toour surprise, that the following theorem holds. Theorem 15. For every two-way automaton 91 there exists a one-way automaton 21 such that T(ijL)= T ( $ f ) . Furthermore, $fcan be obtained effectively from91. Outline of Proof:" By definition, a Z-motion of % on a tape t consists o f 9[ moving across a square x in a certain direction up to a square y , changing direction at y and moving backtowards x , changingagaindirection before passing x and moving up to y; a Z-motion thus contains exactly two changes of direction.While operating on a tape t a two-way automation will in general perform a complicated succession of forward and backward motions before accepting or rejecting t . Inparticular, ?[ will go through a great n'umber of Z-motions. In a given Z-motion in the diagram,
x 0
/

by the previous theorem this can be done effectively. Apply now to and the procedure given in Corollary 10.1.
Chapter 111. Multitape automata

8. Descriptionanddefinitions
We turn now to the study of multitape machines, fixing our attention, without any real loss of generality, on the two-tape case. We can picture the two-tape machine 91 ashavingtwoscanningheadsreading a pair ( t o , t , ) of tapes. We adopt the convention thatthemachine will read for a while on one tape, then change control and read for a while on the other tape, and so on until one of the tapes is exhausted. When this happens 91 stops and the pair ( t l , t 2 ) is accepted if and only if 3 is in a designated final state. Thus, with a two-tape automaton, a set of pairs of tapes is defined, or we can say a binary relation between tapes is defined. To make two-way automata more versatile we afford them with the ability to anticipate the end of the tape. This arrangement consists in augmenting the alphabet Z with an end-marker E and always feedinginto the automaton pairs of the form ( t " & , t l F ) ; here t , and t , do not contain E , the latter being merely a technical symbol. In order to indicate the change of control from one tape to the other we use the device of dividing the states of the machine into two classes: the first class contains those states in which the first tape is being read, while the second class has to do with the second tape. These remarks shouldserveas sufficient background for the following formal definition. Definition 15. A two-tape, one-way automaton over an alphabet C is asystem ~[=(S,M,s,,F,C,,C,) where (S,M,s,,F) is an ordinary automaton:except that M is a function from S X into S,and where the sets C,,C, form a partition o f S, i.e., C o r Cl=+ and

/
/

,,'

the internal state ' s in which 9 1 re-enters y is a function of the state s in which 3 originally entered y and the portion of the tape from x to y . If it were possible to compute this new state s ' , withoutactually having to move back, then we could substitute for '$1 a new automaton which, instead of turning back at y , would simply go directly fromstate s intostate s ' andthusthe Zmotion would be eliminated. It turns out that the computation of s ' from s is indeed possible because the set R(s,s') (L(s,s')) of tapes such that when 81 starts on the right-(left) hand end it will go thro'ugh a simple loop (i.e., move directly to some square,change direction there, and go straight back to where it started) and arrive back in state sf, is definable by a one-way automaton. Combining 9[ with these one-way automata it is possible to define a new derived automaton %' which on any given tape t performs fewer Z-motions than 91 does andsuchthat T ( ? [ ' )= T ( % ) , Wethen show that, by repeating this derivation operation a sufficient number of times, a one-way automaton is obtainedwhich defines the same set as '$1. This depends on the fact that there is a bound, common to all tapes t accepted by '$1, on the number of times '$1 goes through any square of t ; this bound being the number of internal states of X. Corollary 15.1. The equivalence problem for two-way automata is effectively solvable. Proof: Given two two-way automata 91 and & i to decide whether l"('$[) = T ( % ) construct one-way automata @ and % such that T(%) =T(?,o and T ( S )= T ( 8 );
*Theresult, with its originalproof, was presentedtotheSummer Inf SymbolicLogicin 1957 atCornellUniversity.Subsequently stitute o J. C. Shepherdson communicated to us a very elegant oroof which alsoappearsinthisJournal.' In view of this we confine ourselves here to sketching the main ideas of our proof.

(Xu{&})

c,nc,=s.
Thus a two-tape machine is just an ordinary automaton having an additional structure to determine which tape is to be read. To be able to define explicitly when a pair of tapes is accepted by anautomaton,the following notation involving the partition of the set of states is needed. Let 9[= (S,M,s,,F,C,,C,) be a two-tape automaton and let so,sl, . . . , s , be a sequence of states (where s,) is the initial state). Then there is a unique pair of associated sequences of integers k,, , . . , k,,;l,, . . . , I, such that: (i) ki is 0 or 1 according as si is in C, or C,; (ii) Zi is thenumber of indices j < i suchthat sj is in Cki. Definition 16. The set o f all pairs o f tapesaccepted byatwo-tape automaton a, in symbols T2(91), is the set o f all pairs ( t l , t 2 ) on the alphabet Z such that for
(t,">t2")=(u,,,,a,l. ~ ~ ( r n - l ) ~ ~ l C Ul( l n~ - 1l) l ) ~ ~

..

there is a (unique) sequence o f states so,sl, . . , sp and . , lp associated sequences o f integers kc,, . , k,; I,, such that

. .

..

123

IBM JOURNAL

APRIL

1959

(ii)

s i = M ( ~ - , l ~ - , 8 ~ - for ~ )i=l,

. . . ,p ;
1

(iii) ij k,-,=O then lp-,=m-l then I p - , = n - l ; (iv) s, is inF.

and ifk,-,=

the set of s for which there exists a tape t(sO,s),if SO is in C,. The set of designated final states of %

Inthe above definition we are, of course,assuming that if k,=O, then li<m and if kc= 1 , then li<n otherwise condition (ii) would be meaningless.
9. Relation to one-tape automata

124

Two-tape automata behave in a fashion almost identical with that of one-tape automata, the only difference being that they operate on two tapes. It is therefore natural to try to establish relationships between the sets of pairs of tapes definable by two-tapemachines andthe sets of tapes definable by one-tape automata. Theorem 16. Let %=(S,M,s,,F,C,,C1) be a two-tape automaton. The set of all tapes t, for which there exists some tape t2 such that (tl,t2) is in T3()11) (Le., the domain o f the relation defined by 91) is definable by a one-tape automaton. A n automaton defining this set can in fact be constructed effectively from8. Proof: The ideaunderlying the proof is that on the first component of any pair of tapes (%) operates like a nondeterministic one-tape machine. Once we are able to define the one-tape, nondeterministic automaton accepting precisely the tapes t, for which (tl,t2) is in T2(91) for some t, the proof is completed by Theorem 1 1 . To shorten the argument we shall consider a slightly simplified version of the notion of two-tape automata; namely, in Definitions 15 and 16 we disregard the end symbol E and the special role it plays (it is possible to extend the proof to cover the general case). A pair (tl,t2) is thus fed directly into 4 1 and is said to be accepted if and when 9l gets off one of the tapes in a designated final state of 81. Let s be in C , and s be in C,. A tape t on the alphabet Z is called a (s,f) transition tape if %, when started on t in s will go through states in C, until it gets off t in s. For every pair (sJ) for which there exists some transition tape let t(s,d) denote ashortest one.The length of t(ss) is clearly less thanthenumber of states in C , so that all shortest transition tapes, and hence all pairs of states possessing a transition tape, can be effectively found. A state s in C , will be called a finalizing state if there exists a tape t(s) such that 91, when started on t(s) in s, will go in states of C , to the end of t(s) and get off the tape in a designated final state of X. Define now a nondeterministic one-tape automaton 8 as follows. Let f be some new element not in S, the set of states of 8 is C , u { f } . The table N of moves of is defined by (i) N ( f + J > ={f>; (ii) N ( s , ~ ) = { M ( s , u ) } if, M ( s , u ) is in C,; (iii) N ( s , u )= { f } , if M ( s , u ) is a finalizing state in C , ; (iv) N ( s , u )=the set of all s where there exists a transition tape t ( M ( s , a ) ,f), otherwise.

(C0F)UCf). It is left for the reader to verify that the set of all tapes accepted by 8 is precisely the domain of the relation T 2 ( % ); we recallatthis pointthe simplified definition of acceptance used in the proof.Thiscompletes our proof. Corollary 16.1. There are effective procedures whereby, given a two-tape automaton %, it can be decided in a finite number of steps whether T 2 ( 9 [ ) is empty and whether T , ( s ) is infinite. Proof: Construct the one-tape automata 8 and 6 defining thedomainandrange of the relation T2(91). The set T 3 ( a ) is empty if and only if T ( 8 ) is empty. The set T2(91) is infinite if and only if at least one of T ( B ) and T ( % ) is infinite. Now applyCorollaries 7.1 and 9.1. Corollary 16.2. I f T 2 ( % ) containsonly pairs of the the f o r m( t , t ) (i.e., defines a diagonal relation) then set of all tapes t for which ( t , t ) is in T,(Yl) is definable by a one-tape automaton.
IO. Impossibility of Boolean operations

Whereas the class of sets definable by one-tape automata is closed underthe Boolean operations (Theorem 5 ) , when we come to sets of pairs definable by two-tape automata the situation is markedly different. Theorem 17. The class of all sets definable by twotape automata is ( i ) closed under complementation; ( i i ) is not closed under intersection and union.* Proof: (i) Let ~=(S,M,s,,F,C,,C,). The complement, with respect to the set of all pairs of tapes on Z, of T 2(3), is T 2( (S,M,so,S -F,Co,C1) ) . (ii) LetX = { 0, l} and use the notation 0 to denote the tape containing n zeroes. The sets U={(OnlOm, 0L10n),n,m,k=1,2, .. . } and V = { ( t , t ) , t runs through all tapes} are definable by two-tape automata. Now B A D = { (Onlo, OnlOn), n=1,2, . . . }. If this set were definable by atwo-tape automaton then, by Corollary 16.2, the set {OnlOn, n=1,2, . . . } would be definable by a one-tape automaton, which is impossible, That the class of definable sets is not closed with respect to unions now follows from the identity % X n % = T - [ ( T - ~ ) ~ ( T - 8 ) and ] (i).
0

I I . Unsolvability o f the intersection problem

We have shown that the emptiness problem for two-tape automata is effectively solvable. It will now turn out that a similar elementary problem is not solvable. As a preparation for this result concerning automata we must recall a theorem of E. Post.6 The correspondence problem is the following: Given two equally long ordered lists a1,a2, . . . , a, and b,,b,, , . . , b, of tapes on the alphabet X, to decide whether there exist asequence of indices i&, . . . , i , where
*J. C . Shepherdsoninformedus in aletterabouta different simple example for the fact that the class of definable relations is not closed underintersections.

IBM JOURNAL

APRIL

1959

I L i i L n , such that
ai, ai,

. . . ail,=bil

bi, . . . bi,.

E. Post proved that the correspondence problem (for an alphabet with more thanoneletter) is not effectively solvable. Theorem 18. The problem whether for two finite twotape automata % , and 212 we have T , ( ? l l ) A T , ( % z ) = +
(the empty set) is not effectively solvable. Proof: Corresponding to every sequence, al,a2, . . . , a,, of words on our alphabet Z construct a set P(a,,a,, . . . , a,,) of pairs of tapes as follows: We mayassume that 0,1 are in if i is an integer let i be the tape consisting of i symbols 1 followed by a single 0. Now ( t l , t 2 ) is in P(al,an, . . . , u , ~ if ) and only if for some k

x;

(i) tl=ail ai, - . . . a2.% (ii) t,=i,i, . . . i,,

where i j 4 n .

It is not hard to construct a two-tape automaton ?l(al,a,,. . . , an)=% such that T,(?l)=P(al,a,, . . . , aJ. Namely, to check whether a pair (t,,t,) satisfies conditions (i) and (ii) , a will start on t2 and count the number of symbols 1 until the first 0 is met, let this number be i,. The machine then switches to t , and checks whetherthis tape begins with ai,; if it does not, then ( t l , t 2 ) is not accepted. If tl does begin with ail, then after reading through ai, the machine switches back to t2, and the whole process is repeated. If at any time a symbol other than 0 or 1 is found on t,, or if t2 contains a run of more than n symbols 1 or more than one symbol 0, then the pair ( t l , t z ) is not accepted. These remarks sufficiently indicate the construction of 91 and we shall not go into further detail. Given two sequences of words SI=(a,,a,, . . . , a,) and S 2 = ( b l , b 2 , .. . , b,) then P(a,,a,, . . . , a , ) A P ( b , , b,, . . . , bn)=++ if and only if the Post correspondence problem of S1 and S, has asolution.Since the correspondence problem is not effectively solvable it follows that the problem whether

Tn(?l(a,, . . .

0,)

) A T Z ( % ( b l ,.

. . , bn) 1 4 9

sionmethod for decidingwhethertwotwo-tape,oneway machines % , and & both accept a common pair of tapes, that is, whether T2(911)r\T2(%2)++. From the construction of the two-tape machines it follows that if h is a new symbol not in the alphabet Z, then there is a one-onecorrespondence between all two-tape, one-way machines a over Z and certain two-tape one-way machines over Z y { h } such that a pair of tapes ( t l , t z ) is in T 2 ( a ) if and only if (ht,h, ht,h) is in T,(X). In words, we simply put a marker at the ends of the tapes, and all accepted tapes must be of this form. Let now and 2, be any two two-tape machines. The corresponding machines over Z y { h } are ? l , and % , . NOW because ?Yl and only accept tapes with markers atthe ends, they can be glued together into a twoway machine 8 such that T , ( B ) = T , ( ? ~ , ) n T , ( ~ , ) . The two-way motion of 8 is obvious: first run through the tapes in the style of ?Ix1 to see if the pair is accepted, and then, after hitting the markers at the right end, run backwards until the left markers are hit, at which time the motion is again reversed, and the machine is started over, running in the style of % , . Theoutline of the construction given above shows that every intersection problem about one-way machines 9,[1 and 91, is equivalent to the intersection problem about machines W, and W,, which in turn is equivalent to the emptiness problem for a two-way machine 8. Since there is an effective methodfor showing these equivalences, and since there is no effective solution of the intersection problem for one-way machines, we have proved the following. Theorem 19. There is no effective method of deciding of tapesdefinableby a two-tape,twowhethertheset way automuton is empty or not. An argument similar to the above one will show that the class of sets of pairs of tapes definable by two-way, two-tape automata is closed under Boolean operations. In view of Theorem 17, this implies that there are sets definable by two-way automata which are not definable by any one-way automaton; thus no analogue to Theorem 15 holds.

w,

is not effectively solvable.

12. Two-way, two-tape automata Turning now to two-way,two-tapeautomata we find that all hope of any constructive decision processes is lost. It is even impossible to decide,byaconstructive decision method applicable to all automata, whethera two-way, two-tape machine accepts any tapes. To prove this formally it is, of course, necessary to give the explicit definition of a two-way machine. We shall not give the details here, since they are long and not very much different from the formal definitions needed for two-way, one-tape automata. The main point is that, as with the two-way, one-tape automaton, the table of moves of a two-way, two-tape automaton sometimes requires the machine to back up from the scanned square. However, an outline of the proof should clarify the method. It was shown above that there is no constructive deci-

References 1. A. W. Burks and Hao Wang, The logic of automata, Journal of the Association for Computing Machinery, 4, 193-218 and 279-297 (1957). 2. S. C. Kleene, Representation of events in nerve nets and finite automata, Automata Studies, Princeton, pp. 3-4 1, (1956). 3. W. S. McCulloch and E. Pitts, A logical calculus of the ideas imminent in nervous activity, Bulletin of Mathematical Biophysics, 5, 115-133 (1943). 4. E. F. Moore, Gedanken-experiments on sequentialmachines, Automata Studies, Princeton, pp. 129-153 (1956). 5. A. Nerode, Linear automaton transformations, Proceedings of the American Mathematical Society, 9, 541544 (1958). 6. E. Post, A variant of a recursively unsolvable problem, Bulletin of the American Mathematical Society, 52, 264268 ( 1946). 7. J. C . Shepherdson, The reduction of two-way automata to one-way automata, IBM Journal, 3, 198-200 (1959).
Revised manuscript received August

8, 1958

125

IBM JOURNAL

APRIL

1959

You might also like