15
Computational Complexity of One-Tape Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative aspects oi' one-tape Turing machine computations are consid- ered. It is shown, for instance, thal there exists a sharp time bound which must be reaehed for he recognition of nonregular sets of sequences. It is shown th,'~t the computation time can be used to characterize the coInpiexity of recursive sets of sequences, ~tnd several results are ob- ained about this classification. These results tire then applied to the recognition speed of context-free languages and it is shown, among other things, timt it is reeursively undecidable how much time is required to recognize a nonregular context-free language on a one-tape Turing machine. Several unsolved problems :are discussed. KEY WORDS AND PHRASES: automata, Turing machines, complexity, context-free languages, nonregular sets, recognizers, one-tape machines CR CATEGORIES: 5.21, 5.22 Preliminaries All through this paper we are concerned with the quantitative aspects of one-tape, offline Turing machine computations. We assume that the Turing machine is used as a recognizer of sequences over some finite alphabet I. The set of all finite sequences over the alphabet [ is denoted by i* and the length of a sequence w = xlx2...xk, xiinI, 1 <i< k, is denoted by 1(w); in this case t(w) = k. The null sequence is designated by ^ and thus l ( ^ ) = 0. The tape of a Turing machine M is unbounded oil the right and the input string w = xlx~ ... xk (in I*) is written on the first k tape squares and the remaining tape is blank at the start of the computation. The first tape square contains be- sides xl a unique inarker (say, a prime on the symbol xl) which is preserved through the computation to prevent the machine h'om leaving the tape. Following Hennie [1] we use the word tape segment to denote a finite part of the tape and use the word tape to designate the infinite string of squares upon which some symbols may be written. Thus t = wwl shows that the tape t is obtained by concatenating the tape segment w with a to-the-right infinite tape wl. The blank tape (unbounded to the right) is denoted by wb. * Department of Computer Science. This research has been supported in part by National Science Foundation Grant GP-6426. Journal of the Associationfor Computing Machinery, Vol. 15, No. 2, April 1968,pp. 325--339.

Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

Computational Complexity of One-Tape

Turing Machine Computations

J. HARTMANIS

Cornell University,* Ithaca, New York

ABSTRACT. The quant i t a t ive aspects oi' one-tape Turing machine computations are consid- ered. I t is shown, for instance, thal there exists a sharp time bound which must be reaehed for the recognition of nonregular sets of sequences. It is shown th,'~t the computation time can be used to characterize the coInpiexity of recursive sets of sequences, ~tnd several results are ob- tained about this classification. These results tire then applied to the recognition speed of context-free languages and it is shown, among other things, timt it is reeursively undecidable how much time is required to recognize a nonregular context-free language on a one-tape Turing machine. Several unsolved problems :are discussed.

KEY WORDS AND PHRASES: automata, Turing machines, complexity, context-free languages, nonregular sets, recognizers, one-tape machines

CR CATEGORIES: 5.21, 5.22

P r e l i m i n a r i e s

All through this paper we are concerned with the quantitative aspects of one-tape, offline Turing machine computations. We assume that the Turing machine is used as a recognizer of sequences over some finite alphabet I.

The set of all finite sequences over the alphabet [ is denoted by i* and the length of a sequence

w = x l x 2 . . . x k , x i i n I , 1 < i < k,

is denoted by 1 (w); in this case

t(w) = k.

The null sequence is designated by ^ and thus l ( ^ ) = 0. The tape of a Turing machine M is unbounded oil the right and the input string

w = xlx~ . . . xk (in I * ) is written on the first k tape squares and the remaining tape is blank at the start of the computation. The first tape square contains be- sides xl a unique inarker (say, a prime on the symbol xl) which is preserved through the computation to prevent the machine h'om leaving the tape. Following Hennie [1] we use the word t a p e s e g m e n t to denote a finite part of the tape and use the word tape to designate the infinite string of squares upon which some symbols may be written. Thus t = w w l shows that the tape t is obtained by concatenating the tape segment w with a to-the-right infinite tape wl. The blank tape (unbounded to the right) is denoted by wb.

* Depar tment of Computer Science. This research has been supported in par t by National Science Foundation Grant GP-6426.

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968, pp. 325--339.

Page 2: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

326 J. H A R T ~ A N i s

The Turing machine M is always started with its reading head scanning the leftmost tape square (the first symbol of the input string). On each operation the machine M scans the tape square under the reading head; the tape symbol scanned and the present state of the machine uniquely determine:

(1) the symbol (from a finite alphabet) which is overprinted on the tape square under the head;

(2) the new state (from a finite set of states) which M enters; and (3) the motion of the reading head, which moves one tape square to the

right or left and does not move if and only if the machine has stopped by entering the rejecting or accepting state.

A set of finite sequences A over I, A ~ I*, is accepted or recognized by the Turing machine M if and only if M stops for all inputs w in I* and accepts the input if it is in A and rejects it if it is not in A by entering the accepting or rejecting state, respectively.

Next we define three quantitative measures of the complexity of one-tape, ofltine Turing machine computations.

1. The number of operations performed by a Turing machine in processing (rejecting or accepting) an input string is our measure of time. L e t T(n) be a computable function from nonnegative integers into nonnegative integers, T: 5 --~ 3. Then we say that a set A is T (n )-recognizable if and only if there exists a Turing machine M which accepts A and which processes every input of length n in T(n) or fewer operations.

2. The amount of tape used by the Turing machine is our measure of memory. Let L(n) be a computable function, L: 5 --~ 5. Then the set A is said to be L(n)- recognizable or recognized with L (n)-tape if and only if there exists a Turing machine M which accepts A ~md which processes every input of length n using no more than L (n) tape squares.

3. The last complexity measure is based on the number of times M crosses boundaries between tape squares. Let R(n) be a eompul~able function, R: 5 --~ 5. Then the set A is said to be R (n )-recognizable if and only if there exists a Turing machine M which accepts A and which processes every input of length n without crossing any boundary between adjacent tape squares more than R (n) times. (For related work, see [1-3].)

We say that the Turing machine M defines T(n) if and only if for any input of length n, the machine M uses no more than T (n) operations, and for some input of length n, uses exactly T (n) operations.

Similarly, the machine M defines L (n) or R (n) if and only if M never uses more than L (n) tape squares or R (n) crossings between tape squares for inputs of length n, and for some input length n uses exactly L (n) tape squares or makes exactly R (n) crossings of some boundary.

We now give a short description of crossing sequences which form the main analytic tool of this paper and which have been studied before [4], and recently in [1]. For a Turing machine M and tape t we associate with every boundary between adjacent tape squares of t an ordered sequence of states s(1), s(2), . . . , s(n); in which the ith state, s (i), is the state the machine is in on the i th crossing of this boundary during the computation performed by M when started on gape t; we

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 3: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape Turing Machine Computations 327

refer to this sequence as a crossing sequence. If t = w, w2 then the crossing sequence generated by M on the boundary between w~ and w2 is designated by C(wl ;w2).

I t is seen that the crossing sequence C (w, ; w2) completely describes the informa- tion which is carried across the boundary between Wl and w2 by M in its computation. Thus we can easily show the next result, which states that any tape segment be- tween identical crossing sequences can be removed without affecting the computa- tion on the remaining tape [1].

LEMMA l. If t = wx we wa w4 ws, and Jbr M, C (wl w2 ; wa w4 ws) = C (wl we w3 ; ~w4 w~ ) , then C (wl ; we w4 ws ) = C (w, ; we w3 w4 ws ) and C (wl w2 w4 ; ws ) = C (wl w.2 wa w4 ; ws).

Note tha t the machine M changes its st,~te before it moves and therefore we see tha t if M accepts (rejects) t = w~ w2 wa w4 w5 it will accept (reject) t = w~ we w4 w5.

Recognition of Nonregular Sets

I t is known [5] tha t if a set A is recognized by a one-tape, offline Turing machine which does not write on its tape, then A is a regular set and can be recognized by a finite automaton or, equivalently, by a Turing machine which scans the input seg- ment only once.

Recently Hennie [1] extended this result and showed that if M accepts A m~d for some constant k, R ( n ) _< k or T ( n ) < kn, then the set A is regular.

We now show that there exist sharp bounds on how fast R (n) and T (n) have to grow for the recognition of nonregular sets on one-tape Turing machines. The first two theorems were obtained by Trachtenbrot [4] and independently by the author.

THEOREM 1 . If A is R (n)-recognizable and

then A is a regular set. PROOF. We show tha t if

then R (n) is regular.

lira R ( n ) _ O, ~ log n

R (n) l i r a - - - = 0 ~ log n

_< k for some constant k, and therefore, by Hennie's result, the set A

Let M recognize A and let M define R ( n ) . (Thus R ( n ) is the longest crossing sequence generated by M for inputs of length n.) I f R (n) is not bounded then there exists an infinite sequence of integers 0 < nl < n2 < m < " '" such that R (nl) > R ( n ) , for n~ > n. Thus M generates a crossing sequence of length R(nl) , for the first time, for an input sequence of length n l .

We now show tha t on the input segments t~ of length n~, for which R (n0-1ong crossing sequences are generated, no crossing sequence can be generated more than twice. To see this, let

tl : ~Vl W2 W3 W4 , W2 , Y)3 ~ A ,

and assume tha t M on t = wl we w3 w4 wb generates

C (~)1 ; We ~J)3 ~)4 ~Ob) = C ( w l w2 ; q~)3 qJ)4 ~Ob) -~ C (•1 ~.02 w3 ; ~)4 U)b).

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 4: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

328 z. HARTMANIs

Then by the previous l emma we know tha t when M is s tar ted on t' = w~ w3 w4 wb or t" = wl w~ w4 wb, it generates a crossing sequence of length R(n~) oa wx wa w,~ wb or wx w2 w~ w~. Bu t since the segments are shorter than t~ we have a contradiction with the fact tha t a crossing sequence of length R(nd is reached for the first time for an input segment of length n~,

Thus on the input segments h , t2, • • • of length nl < n2 < • • • , respectively, no crossing sequence is generated more than twice. We now use this fact to compute how fast R (nl) has to grow.

If M has Q states (Q ~ 2) length at most r is givea by

i~0

then the number of different c, rossing sequences of

Qi _ Q~+i _ 1 < Q~+~ Q - 1

Now if on a segment of length n~ no crossing sequence can be generated more than twice, then we mus t have 2Q R(~':)+~ > n~,

Taking logari thms to base Q on both sides of the inequali ty we get tha t R (n~) + 1 -t- log2 > log n,~, whence R(n~) > log ni - 2.

Bu t then

Thus

implies t h a t R (n)

COROLLARY 1. R (n) then

R (n ) lira l ~ r i ~ 0.

lira R ( n ) _ 0 , ~ log n

k and therefore A is regular.

I f a Turing machine M recognizes a nonregular set A and defines

R (n ) sup i~:i~- > o.

Pl~ooF. Follows directly f rom the theorem. Next we show tha t there are nonregular sets which are recognizable with R (n) =

2 [log2 n]. (The symbol [x] denotes the smallest integer k such tha t t~: > x. )

LEMMA 2. There exists a one-tape Turing machine M which started on t = l'~w~ computes with R(n ) = 2[log2 n], the binary representation of n (i.e., M stops after writing the binary expansion of n on its tape).

PROOF. The machine M sweeps from left to right over the segment of ones and marks off the first, third, fifth, etc., unmarked squares, then returns arid repeats this process until all squares of this segment are marked off. I t is seen t imt in the binary expansion

k n = ~ ai2 i,

i=0

the coe/ficient a . is 1 if the r ightmost umnarked square is marked off on the ith sweep; a~_~ is 0 otherwise. Thus to compute ak ak_~ • • • a0 the machine just records the a~ according to the above procedure. Since this process is completed in [logs n]

JournM of the Association for Comput ing Machinery, Vol. 15, No. 2, April 1968

Page 5: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape Turing Machine Computations 329

sweeps, we see that there exists an M which computes the desired binary expansion with R (n) = 2[log2 n].

Froln tile above proof it follows (as was ah'eady shown in [1]) tha t n = 2 k if and only if the process is finished in k sweeps and the rightmost one is marked off on the last sweep. Thus the nonregular set [1 ~k I k = 1, 2, -.-} is R(n ) = 2 [log n]- recognizable.

Next we show that there ~lso exists a sharp time bound which must be reached or exceeded for nonregular computations. This result and the following corollary were first obtained by Traehtenbrot [4] and independently by the author.

THEORm.t 2. I f A is T (n)-recognizable and

~lim T (n ) _ 0, , ~ n log n

then A is regular. Pt~OOF. Observe tha t the computation time is given by the sum over the length

of all crossing sequences generated in the computation. Furthermore, the proof of Theorem 1 showed that if A is not regular then there are infinitely many input segments h , t2, t3, . . . of length n~ < n2 < n3 < . . - , respectively, on which no crossing sequence is generated more than twice. I t was furthermore shown in this proof that , even if M generates the shortest possible crossing sequences on the seg- ments tl , the longest crossing sequence R (n~) must be such tha t R (ni) >_ logQ n~ -

2 .

Thus, for all i, the computat ion time T (n~) on t~ must be such that

r

T(ni) >_ 2 ~ j Q i , r = [logQ nd - 3, i = 0

since there are QJ different crossing sequences of length j and no crossing sequence can be used more than twice. Note tha t M does not have to generate all crossing sequences of length less than lOgQ n~ -- 2, but then short sequences have to be re- placed by longer ones and the inequality is strengthened. Returning to the inequal- ity we see that

r

T(ni) > 2 ~ j Q J >_ 2rQ ~ >_ 2(logQ nl - 3)niQ -3, i=O

and therefore

Thus

lira _ T ( n ) # 0. , ~ n log n

lim T(n) - 0 ,~,~ n log n

implies tha t A is regular.

COROLLARY 2. I f M recognizes a nonregular set and defines T (n), then

T (n ) sup~ ~-~g n > O.

PROOF. Follows from the theorem.

Journal of the Association for Compu t ing Machinery, Vol. 15, No. 2, April 1968

Page 6: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

330 J. HARTMANIS

Since the set A = { 1 ~ ] k = 1, 2, • - • } can be recognized in [log n] sweeps each of length n, we see that A is T (n) = 2n [log n]-recognizable. Thus there exist non- regular sets which are T (n) = 2n [log n]-recognizable.

The previous results can be extended to obtain a relation between the amount of time and memory used in computations with unbounded crossing sequence length.

THEOREM 3. Let M stop for all inputs and define L (n ) , R(n) and T(n) . Then

n lim - 0 ..... L (n )

implies that there exists C > 0 and N such that

P R O O F .

identical

R (n) > C log L (n),

T (n ) >_ CL(n) log L(n) , for n >_ N.

First we show that for an input tape t = wwb, M cannot generate two crossing sequences on the initially blank tape ~zb. If C(wb~; bkwb) =

C (wbrbk; wb), then by Lemma 1 we can remove the segment b k and the computation will not be changed, except tha t it will have/c fewer crossing sequences. On the other hand, the removal of b k from wb leaves wb unchanged and therefore t = wwb is un- changed. Thus M will generate exactly the same number of crossing sequences as before and (since M stops) we conclude that k = 0.

Since

n lim,~_~ L ( n ) - O,

there exists an integer N1 such that for n > N1, L (n) > 2n. Thus for every n, n > N , , there exists an input of length n for which L(n) - n >_ ½L(n), and we see that for this input M uses ½L (n) tape squares of wb. This implies that M must generate at least ½L (n) different crossing sequences since no crossing sequence can be repeated oil wb. There are

Qi _< Qr+l i~0

different crossing sequences of length r or less (Q > 2). Thus to generate ½L(n) different crossing sequences we must have QR(~)+i > ½L (n), and therefore

R(n) >_ logQL(n) - 1 - logQ2.

This implies tha t there exist positive constants C1 and N2 such that

R(n) >_ CllogQL(n), for n >_ N2.

The computation t ime T(n) , n >_ N1, is not less than the sum of the length of the ½L (n) different crossing sequences generated by M. Thus

T ( n ) > ~ - i _ ~Q, r = [logQL(n)l - 3,

and therefore

T(n) > (logQL(n) -- 3)L(n)Q -~.

Journal of the Association for Computing Machinery, Vol. 15, No, 2, April 1968

Page 7: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape Turing Machine Computations 331

'This implies that there exist positive constants C2 and N3 such that

T (n ) > C.,L(n) logQL(n), for n > N;~.

• To obtain the desired inequalities we let

C = min(C1,C2) and N = m a x ( N 2 , N a ) .

TUEOtmX[ 4. Let M stop for all inputs, define R (n), L (n), T (n), and let R (n) be unbounded. Then there exist two positive constants C~ and C2 such that for infinitely ~tany values n~

R(n~) >_ C1 logQ L(ni),

7'(n~) >_ C2L(ni) logQL(ni).

PROOF. Since R(n) is,unbounded, there are infinitely many values L(n~) < L(n~) < L(n3) < . . . such that R(n) < R(nl) if L(n) < L(ni). By arguments similar to the ones used in the proofs of Theorems 1 and 2, we can show that no crossing sequence can be generated more than twice during the computation when R(n~) is reached for the first time (i.e., on the shortest L(n)). Again by counting the number of crossing sequences we conclude that for some C~ > 0 and N1 > 0 we have

R(n~) > CllogQL(nl), for ni ~ N1.

Similarly, we can now compute the number of operations performed in these computations and show that for some C2 > 0 and N2 > 0 we have

T(ni) > C:L(n~)log¢L(nl), for nl >_ N2.

By picking the n~ >_ max (N1, N~) we have the desired infinite set of integers for which the inequalities hold.

The previous results showed that there exists a sharp break in the computation time when we go from regular to nonregular computations. Next we turn to the classification of the complexity of nonregular sets by their computation time on one-tape Tufing machines. For related results for multitape Turing machines, see [2 and 6].

Hierarchies of Time-Limited Computations

In this section we investigate the classification of nonregular sets by the time re- quired for their recognition.

For a computable function 7' (n) (R (n)) , we refer to the set of T (n)-recognizable (R(n)-recognizable) sets of sequences as a complexity class and designate it by CT (CR). The next result shows that there are infnitely many complexity classes.

LEMMA 3. If T (n) is computable, then there exists a recursive set of sequences A not in C T .

PROOF. By a simple diagonal process [2]. Next we show that every computation carl be speeded up by a linear factor, if

we permit a trivial condensing of the input string. That is, we permit to write several input symbols per tape square.

THEOREM 5. If A is T (n )-recognizable, then A is [½ T (n )]-recognizable.

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 8: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

332 J. IIARTMANIS i~

PltOOF. Let the input string be condensed to two input symbols per tape square and let A be recognized by M in time T(n) . Then, by techniques similar to those used in the proof of Theorem 2 in [2], we can show that there exists a machine M' which recognizes A and performs one operation for every two operations of M. Thus M' recognizes A in time T'(n) = [½T(n)].

The next result shows that for slowly growing time functions a slight (nonlinear) increase in the computation time is sufficient to recognize more complicated sets. To prove this result we define sweep functions, which are very easy to compute. They are used to count the number of sweeps over the input segment perforlned by a machine M and to terminate this computation if the number of sweeps grows too large. The sweep functions play a role similar to the real-time functions used in the study of the computation time of multitape machines [2] and the realizable func- tions used in the study of memory limited computations [3].

Definition. Let F be a monotonic, increasing function from integers into integers, F: 5 ~ 5 , s u c h t h a t for someQ > 0 and for large n, 3n < F(n) < Q'~.Then F is a sweep function if and only if there exists a computable, monotonic, increasing function g, g: 5 + 5, such that the set

A = {lg(k)0~I~(k)t-g(k) I h = 1, 2, . . .1

can be recognized by a Turing machine M which makes no more than F-~(n) sweeps over the input segment of length n.

(Note that F (n) cannot grow more rapidly than the exponential function, since otherwise

F-l(n) sup - 0, ~ log n

and by Corollary 1 only regular sets can be aecepted in F -1 (n) sweeps. The lower limit for F (n) is used explicitly in the proof of Theorem 6; see also the discussion after Corollary 3.)

The sweep functions form an interesting and rich class of functions (which should be investigated further). For the present application it is sufficient to note that this (',lass contains many of the commonly used functions. For e×mnple, the follow- ing are sweep functions:

F(/c) = k p/q, p > q; F(/c) = 2~; F@) = 2 (p/q)k, p/q < 1;

F(/c) = /c[log2k] ~, p = 1,2, . . . ; F(k) = /c [log log k] ;

etc. To gain a better understanding of sweep functions consider F (k) = 2 k. Choose g(/c) = k. Then, using Lemma 2, we see that the set {l~0~-k I k = 1, 2, . . .} is recognizable in k sweeps with /c _< log2 n = F-~(n). Thus F(k) = 2 k is a sweep function.

To see the use of the auxiliary function g(lc) consider F(k) = /c ~/q. (See [1] for the use of related techniques. ) Let g (/c) = 2 qk. Then to recognize the set

{ 12~kO 2"k-~k [ ]c = 1, 2, ...1,

we construct a machine M which checks (by the process described in the proof of Lemma 2) whether the length of the input sequence and the length of the segment

Jo-rna l of tile Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 9: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape Turing Machine Computations 333

of ones are powers of two, and checks whether tile number of sweeps to verify this for the two segments is ill tile ratio p/q. This can be done ia hp sweeps over the input sequence. Since n = 2 vk, we see that F -~ (n) = 2 ~'~ > kp (for large n), and therefore, F (k) = ],c ~/'~ is a sweep function.

By similar techniques we can show that many other functions are sweep functions. I t is the author 's conviction tha t sweep functions should be investigated in more detail attd their properties compared to those of real-time func.tions and construct- able functions. So far this has not been done systematically.

We now utilize sweep functions to generalize Hennie's results [1, Th. 4 and Cot'. 4] and show that sweep functions can be used to define sets of sequences with sharp requirements for their recognition time.

THEOREM 6. I f F is a sweep J~mction, then there exists a set oj' sequences which is R (n) = F -1 (n) and T (n) ~ nF -1 (n) recognizable and is not Ri (n) or Ti (n) recog- nizable ~f

lira R l ( n ) 0 or lira T l ( n ) - O . ..... F - l ( n ) , ~ nF -1 (n)

PROOf. We show tha t the set

A = { w ~ w w i l w i ~ (0 + 1)*, l ( w l ) = g ( k ) , w = a ~lg(k)~-2g(k)}

satisfies the theorem. For the sake of brevity let g(k ) = ]c. Since F ( h ) is a sweep function we can in k = l(w~) sweeps check whether the length conditions are satisfied for the three segments, and at the same t ime check whether the first and *third segments are identical, hi this colnputation n = F (k), and therefore, F -~ (n) = k. Thus A is R (n) = F-~(n)-recognizable. Furthermore, since every sweep is no longer than n we see tha t A is recognizable with no more than T (n) = 2nF -~ (n) operations. Thus (by Theorem 5), A is T ( n ) = n F - l (n )-recognizable.

Next we show that if

T , ( n ) lim - 0, , , ~ n F- l ( n)

then A is not TI (n)-recognizable. To see this, note tha t for a fixed lc there are 2 k F(k)--2k different wi such that wia wi is in A and l (w~) = k. Let

F(k)--2k Ak = Iwia w~ l l(w~ ) = k} ~ A.

Then all the crossing sequences generated by M in the middle segments, w = a r(k)-~k, of sequences in Ak must be different. Since, if

C(wiaP;aqwi) = C ( w y ; a * w i ) , p ~ r or w~ ~ wi ,

then M will accept (by [1, Th. 1]) the sequence w~aPa"wi not in A. Thus ia the recog- nition of the strings in Ak, M must use 2k[F (//c) -- 21c] different crossing sequences on the middle segments w. Since F (/c) >_ 3k there is a C > 0 such tha t

2k[F(k) - 2k] >_ C2kF(h).

There are ~ Q~ _< Q"+~ different crossing sequences of length r or less for a m a -

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 10: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

334 J. HARTMAXIS

chine with Q states, Q > 2. hi order to have C.2~F (k) different crossing sequences we must have

r + 1 > log [C.2kF(Ic)]

and therefore for some C~ > 0,

r + 1 > CJ~: + logF(k) .

Since n = F(k) and k = F - ' ( n ) we conclude that (for large n)

r > C1.F-l(n)

and therefore,

R ( n ) o

Thus A is not R1 (n )-recognizable if

Rl(n) lim,~ F_l(n) - O.

Next we compute a lower bound for the computation time. If all crossing sequences of length r or less are used in the computation, then the average computation time for strings in Ak is given by

iQ~/2 k > log [C2kF (k)]. C2kF (k)/2 k 0

> C~F(k).l~,

for C3 > 0. Again, since n = F (k) and k = F -1 (n), we have that for some sequence in Ak the computation time must exceed C3nF -1 (n). T h u s

Ti(n) ~im ~F_~(n) - 0

implies tha t A is not T1 (n)-recognizable. COROLLARY 3. Let F be a sweep function. Then there exists a set A such that A is

in C~r-X(~) and A in CT implies that

T (n ) - - > 0 ; sup

n ~ nF -1 (n)

and A is in Cp-~ and A in Ca implies that

R (n ) SUPn. > o.

PROOF. An immediate consequence of the theorem. The above results establish for a wide class of functions (the set of sweep func-

tions) sets of sequences with well-defined computation times. Unfortunately, the reasoning holds only for slowly growing time functions, namely, for T(n) _< n 2. I t is easily seen that this limitation, as in many other similar arguments, exists because we constructed sets in which two segments of length n or less had to be

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 11: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape T u~'ing Machine Computations 335

checked for identity. This can be done within, n e operations, and thus these results cannot be extended past n ~ by these te('lmiques.

To obtain related results for more complex computations, that is, for larger time functions, we are forced to use diagonal arguments. Unfortunately, the diagonal arguments for one-tape machines are quite cumbersome and the results obtained in this paper for large time functions are imlch weaker than the previous result. On the other hand, the author conjectures that for arbitrarily large time functions T(n) the condition

7'2(n) lim T(n) - 0

implies that C7,~ ~ Cr •

The next result, obtained in collaboration with John E. ttopcroft, gives the best result obtained until now.

THEOREM 7. Let T (n ) , T ( n ) > n'-', be defined by a Turing machine and be computed on L (n ) = [log 7' (n ) ]-tape. Then there exists a set which is T (n ) [log T (n)]- acceptable and not T1 (n )-acceptable for 7'1 (n ) such that

TI(n) lint,,~ T(n) - 0.

PROOF. We give a short outline of the proof by constructing a Turing machine M which recognizes in time T(n)[log T(n)] a set A which is not Tl(n)-recogniza- ble for any T~ (n) with

Tl(n) lim,~_.~ T ( n ) - O.

Let M be a Turing machine which carries out two different computational processes (oil different tracks of the tape).

(a) First computation: M attempts to interpret some initial part of the input tape w wb as a description of a Turing machine, Mi , and then proceeds to simulate what this machine Mi would have done when presented with the input tape w wb. If M completes the simulation and M~ accepts w, then M rejects it and vice versa. If w does not describe a Turing machine and the simulation cannot be carried out, then the computation is stopped and w is rejected. I t can be shown that for every w (whose prefix describes a machine M~) there is a constant hi, such that every operation of M~ can be simulated inn k~ operations by M.

(b) Second computation: In this computation M counts the number of opera- tions which M has performed for the first computation and stops and rejects the input if the first computation exceeds T (n) operations for an input w of length n. Since T ( n ) is defined by a Turing machine, M can count up to T(n) in T(n ) opera- tions. (For the sake of simplicity we assume that T ( n ) is defined by a machine which stops for every input of length n in T (n) operations.)

The two computations are independent and to carry them out simultaneously M alternates the operations: After performing one operation in the first computa- tion (simulation), M marks the tape square the head is on ~nd "remembers" the state of this computation and then returns to perform one operation of the second computation (counting); again after performing this operation M marks the tape

Journal of the Association for Computing Machinery, Vo]. 15, No. 2, April 1968

Page 12: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

336

square the head is on and "remembers" the state of this computation; in order ton keep the two "current head positions" lined up M now proceeds to move the whole lower tape pattern (counting) so that the two head positio~,s line up. After this the cycle is repeated and the machine alternates between the computations. Since T (~) is defined by a Turing machine and is computed on L(n) = [log T(n)]-tape, we see that one cycle in this computation can be performed in 3[log T(n) l or fewer operations. Thus 7'(n) cycles (or T(n ) operations) in the simulation of M~ can be performed by M using no more than 3T(n)[ log T(n)] operations. This implies (Theorem 5) that the set, A accepted by M is T (n) [log T (n)]-recognizable.

We now show that if a Turing machine Mj operates in time T~(n) and

T ~ ( n ) _ O, lira 7' (n)

then Mj cannot accept the set A accepted by the previously described machine M. To see this recall that, for some los, in kj operations M can simulate an operation oi' Mj when the description of Ms is the prefix of an input wj presented to M. BeeatLse of the limit condition there is an N such that for n > N, kjT~(n) < T ( n ) , a~(:t therefore for some sufficiently long input w (whose prefix describes Mj) the re:e- chine M has enough time to simulate what Mi would have done with the input vJ and do the opposite. Thus the set accepted by Mi differs from the set accepted by M. This completes the proof, since we have shown that in time T (n) [log T (n)]~ we can accept a set not acceptable in time T, (n).

From the previous proof it is seen that the factor [log 7' (n)] entered the result of the previous theorem because of the necessity of performing two indcpende~. computations: the simulation of M~ and the counting. The simulation was used to get a set which differs from all sets of sequences in Cr, and the counting operation was used to terminate those simulations which required more than T (n) [log T (n)} operations. It seems very likely that with deeper insight into the nature of one-tape computations, we should be able to eliminate the big sweeps between the two i ~ dependent computations and decrease the time lost in shuttling back and ford'a

between1 the two processes. In this connection it is interesting to recall that a corresponding result for multi °

tape machines was first derived in [2] and that this result contained a "square." Only after the simulation of multitape machines on two-tape machines was unde> stood better [6] was the result improved, but even in this case it does not seem that the best possible result has been obtained.

J. H A R T M A N i s

Recognition of Context-Free Languages

In this section we study the recognition speed of context-free languages on one-tape

Turing machines.

LEMMA 4. There are nonregular context-free languages which are recognizable i~ time T (n ) = n [log n] and with R (n ) = [log n].

PROOF. The context-free language A = { lk0 k I k = 0, 1, 2, • • -} is recognizable with R (n) = [log n] and T (n) = n [log n]. To see this we just recall that with no more than [log n] sweeps a Turing machine can compute tile binary expansion oi' the length of the segment of ones and the segment of zeros and see if they arc

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 13: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape 7bring Machine Computations 337

identical (using I,emma 2). Thus the nonregular set A is R(n) = ilogn]- anci (n) = n [log n]-reeogtfizable. For W .... xlx.a . . . :c~ let ~,1 ,rr = :~'k ' " xexl.

L~M~,I* ,5. The context:/:tee language A = {IV ,~ IV'ciW in (0 + 1)*} "is T ( n ) = n-recognizable and not T1 (n)-recognizable for an}/ T1 (n ) st~ch that

ia f T~(r~) _ O. r ~ m n 2

PROOF. By a simple counting argument Oll crossing seque~lces (see [1]). By using sweep functions and constructions similar to those used hi [7, proof of

'Th. 3], we era1 show that there exist infinitely many different computational com- plexity classes of context-free languages between the time functions 7' (fa) = n [log n]

2 and .7' (n) = n . The most interesting problem which is still open is to determine a least upper

time bound in which every context-free language can be recognized on a one-tape Turing machine. We know that this time })otmd has to be at least T ( n ) = 'n =. I t is the author's conjecture that there are context-free languages which cammt be recognized on a one-tape machine in time 7' (n) = n ~.

The next result established an upper bound for the recognition of context-free languages. I t is not known whether it is a good bound, and it is the author's con- jecture that it can be improved considerably.

COROLLARY 4 (Younger). Every context-free language is T (n ) = nS-recognizable. PROOF. In [8] it is shown that every context-free language is T (n ) = na-reeog -

nizable on a multitape Turing machine. A straightforward implementation of this algorithm on a one-tape Turing machine shows that every context-free language is

T(n) = nS-reeognizable.

Next we show that it is recursively undecidable how much time is required for the recognition of nonregular context-free languages.

THEOREM 8. There is no algorithm to decide whether a nonregular context@'ee language generated by grammar G can be recognized in time 7' (n ) = n [log n].

PROOF. Let A and B be lc-tuples of nonnull binary strings,

A = ( w l , w 2 , "'" , w k ) ,

B = (v~, v2, . . . , v D , v~, w~ C (0 + 1)* - h.

Let A' and B' be the same lc-tuples over a primed alphabet and indexed from/~ + 1 to 2k:

A t I I ! = ( W k + x , W k + ~ , '" • , W 2 ~ )

B ! ._~ t t ! ! t _ _ ( v k + l , v k + 2 , " '" , v ~ k ) , v ~ , wl C (0' --k 1')* A, for all i ,

! ! ! !

ifw~ = a , a 2 . . . ar, aj C {0---}- 1},thenwk+~ = a~a2 . . . a ~ . L e t i b e t h e binary representation of the i th integer. Consider the deterministic, context-free languages

L(A) = {i~ ~ 4 ~ " " % ip ~ % %, . . . ar~aq lp = 1 , 2 , . . . }

L ( B ) = {i~ ~ i2 a . . . ~ ip a # b ~ , . . , b~2b h [ p = 1 , 2 , . . . } .

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968

Page 14: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

338 J. HARTMANiS

Then L ( A ) N L ( B ) ~ ~ if and only if there exists a sequence of indices i t , i2, • .. , ik such that

~' r r = b~'b ~ . . b~' a , i l a i 2 " ' " aik i t i2 " ~Iz"

But the probleln whether such a sequence of indices exists for a pair of binary k-tuples A, B is an unsolvable problem [9, 10]. Thus it is recursively undecidable whether L (A) n L (B) = 4~.

Recall that L ( A ) and L ( B ) are deterministic context-free languages and there- fore L ( A ) and L i B ) are context-free languages [10]. Thus

L ( A ) [J L ( B ) = L ( A ) f-1 L ( B )

is a context-free language. Consider now the context-free language

L = {a'~bnln = 1,2, . . . } ( L ( A A ' ) [J L ( B B ' ) ) ,

where A A ' is the 2 k-tuple ! ! !

Then L ( A A ' ) N L ( B B !) = 4~ implies that L ( A A ' ) U L ( B B ~ is the set of all sequences over 0, 1, 0 ~, 1 !, ~, and L is recognizable in (Lemma 4) T ( n ) = n [log n]. If L ( A A !) f'l L ( B B ' ) ~ ~, then there is a sequence of indices i~, i~, . . - , i, such

that

and

If we designate

T T T T T T a ~ a~. 2 . . . a ~ , = b ~ b ~ . . . b ~

I T I T I T I T I T I T aq+k ai~+k . ' . ai~+k = bi~+k biu+k " '" bi,.+k.

~ il /~ i2 ~ . . . ~ ir b y E 1 ,

~ i l + k g i 2 + k ~ . . . ~ i r + k byEs. ,

a~ . . . a~ah b y A 1 ,

aiT+k • • • a ~ 2 + k a i ~ + ~ by A2,

then the set L contains sequences of the form

E i ~ E i ~ . . . Eim ~ # A i m " " A h A i ~ ,

with ij in { 1, 2} ; and no sequence in

( E i + E ~ ) * ~ $ (A1-4- A:)*,

which is not of this form. But then using Lernma 5 we conclude that L requires T (n) = n 2 for its recognition. Thus L is T (n) = n [log n]-recognizable if and only if L ( A A ' ) n L (BB ~) = q~, and therefore we cannot decide whether L can be recog-

nized in T ( n ) = n [log n].

REFERENCES

1. HENNIE, F. C. 553-578.

One-tape, off-line Turing machine computations. Inf. Contr. 8 (1965),

Journal of the Association for Comput ing Machinery, Vol, 15, No. 2, April 1968

Page 15: Turing Machine Computationscse.iitkgp.ac.in/~goutam/toc/readingMaterial/... · Turing Machine Computations J. HARTMANIS Cornell University,* Ithaca, New York ABSTRACT. The quantitative

One-Tape Tw'ing Machine Computations 339

2. ]~[AIVI'MANIS, J., AND S'['EAtINS, l{, E. 011 tile eomt)tltali(mal complexity of algorithms. Trans. Amer. Math. Soc. 117 (N[ay 1965), 285-30(i.

3. S'rShniS, II. 1i;., t[ARTMANIS, J., AND LEWIS, P .M. Hierarchies of memory limited compu- tations, i E E E Confereace Ilecord on Switching Circ/lit Theory and Logical Design, IEEE Pub. 16C13, 1965, pp. 179-190.

4. TI.IACIt'rENBI¢OT, B . A . Turing computations with logarithnlie delay. (In I(ussian.) Alge- bra i Logica 3 (1964), 33 48. English translalion in U. of California Computing Center, Teeh. llep. No. 5, Berkeley, Calif., 1966.

5. IIAI~IN, M. 0., AND S(:(/'rT, I). Finite automata and their decision problems. In Moore, E. F. led . ) , Seqvential Machines: Selected Papers. Addison-Wesley, llea(ting, Mass., 1964, pp. 63-91.

6. HENNIE, F. C., AND STEARNS, l{. E. Two-tape simulation of multi lape Turing machines. J. ACM 13, 4 (Oct. 1966), 533-546.

7. LEWIS, P. M., STEARNS, [{, E., AND IIAt~TMANIS, J. Memory bolmds for recognition of con{ext-free and context-serYsitive languages. I E E E Conference llecord on Switching Circuit Theory and Logical l)esign, I E E E Pub. 16C13, 1965, pit. 191 202.

8. YO[:NGER, 1). It. Context-free language processing in time n 3. Proc. 1966 Seventh Auroral Symposium on Switching and Automata Theory. IEEE, New York, 1966, pp. 7-20.

9. POST, E. A variant of a recursively unsolvable problem. Bull. Amer. Math. Soc. 52 (1946), 262-268.

10. GINS~tURG, S. The Mathematical Theory of Context-Free Languages. McGraw-t[ill , New Y o r k , 1966.

RECEIVED FEBRUARY, 1967; REVISED MAY, 1967

Journal of the Association for Computing Machinery, Vol. 15, No. 2, April 1968