a generalization of context-free determinism

43
INFORMATION AND CONTROL 11, 196-238 (1967) A Generalization of Context-Free Determinism" " * THOMAS N. HIBBARD System Development Corporation, Santa Monica, California 90~OG Nondeterministic Turing machines, under the restriction that each square be written on only a fixed number of times, recognize all and only context free languages. The deterministic subclass gives rise to a hierarchical extension of the pushdown deterministic lan- guages. Unambiguity in terms of the machines is the same as gram- • matical unambiguity. 1. INTRODUCTION If context freedom is a significant linguistic property, then, since computing is prominent in communication processes, it is natural to ask whether there be computational processes (classes of automata) which are characteristic of context freedom. Unfortunately, in order to construct natural classes of such automata, it has been necessary to con- ceive of the automata as being "nondeterministic." The trouble with this term, first introduced simply as a notational device by Rabin and Scott (7), is that it expresses the fact that the responses of the automaton to given stimuli are not uniquely predetermined, which is to say that the automaton is not automatic. But once one overlooks this terminological inconsistency one finds a valid concept and some good theorems; for example: the (nondeter- ministic) pushdown automata recognize all and only context-free lan- guages [(2], p. 69]. Moreover, there seems to be an inherent need for nondeterminism. For, consider the lan~dage L1 = {a~b~cm:n, m > 0} U la~b%m:n, m > 0}. L1 is recognized by a nondeterministic automaton which first must * Research sponsored in part by the Air Force Cambridge Research Labora- tories, Office of Aerospace Research, USAF, under Contract F1962867C0008, and by the Air Force Office of Scientific Research, Office of Aerospace Research, USAF, under AFOSR Grant No. AF-AFOSR-1203-67. 196

Upload: thomas-n-hibbard

Post on 14-Sep-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

I N F O R M A T I O N AND CONTROL 11, 196-238 (1967)

A G e n e r a l i z a t i o n of Context -Free Determinism" " *

THOMAS N. HIBBARD

System Development Corporation, Santa Monica, California 90~OG

Nondeterministic Turing machines, under the restriction that each square be written on only a fixed number of times, recognize all and only context free languages. The deterministic subclass gives rise to a hierarchical extension of the pushdown deterministic lan- guages. Unambiguity in terms of the machines is the same as gram-

• matical unambiguity.

1. INTRODUCTION

If context freedom is a significant linguistic property, then, since computing is prominent in communication processes, it is natural to ask whether there be computational processes (classes of automata) which are characteristic of context freedom. Unfortunately, in order to construct natural classes of such automata, it has been necessary to con- ceive of the automata as being "nondeterministic." The trouble with this term, first introduced simply as a notational device by Rabin and Scott (7), is tha t it expresses the fact that the responses of the automaton to given stimuli are not uniquely predetermined, which is to say that the automaton is not automatic.

But once one overlooks this terminological inconsistency one finds a valid concept and some good theorems; for example: the (nondeter- ministic) pushdown automata recognize all and only context-free lan- guages [(2], p. 69].

Moreover, there seems to be an inherent need for nondeterminism. For, consider the lan~dage

L1 = {a~b~cm:n, m > 0} U la~b%m:n, m > 0}.

L1 is recognized by a nondeterministic automaton which first must

* Research sponsored in part by the Air Force Cambridge Research Labora- tories, Office of Aerospace Research, USAF, under Contract F1962867C0008, and by the Air Force Office of Scientific Research, Office of Aerospace Research, USAF, under AFOSR Grant No. AF-AFOSR-1203-67.

196

A G E N E R A L I Z A ~ O N OF CONTEXT-FREE DETERMINISM 197

choose, nondeterministically, which of the two defining properties it is going to look for. If this initial guess is correct the computation will be successful, but if the initial guess is wrong the computation will yield no information about the word. On the other hand, a deterministic (not necessarily pushdown) automaton capable of recognizing L1 would first have to look for one or the other of the two properties and, failing to verify that, still be able to verify the other. If such an automaton belonged to a class with any sort of reasonable closure properties then there would be another automaton in the class capable of checking both properties, one after the other, and thus recognizing the set {a~b~c~:n > 0}. But this set is not context-free.

So it seems that we cannot hope to automate the recognition of con- text-free languages without introducing machines which represent prop- erties more general than context freedom. There remains the question of how far we can in fact go with determinism. We ought to be able to go at least as far as

L2 = {da~b%~:n, m > 0} [J {eanbmc~:n, m > 0},

L3 = {a~b~cmd:n,m > 0} U {a~bmcme:n,m > 0},

for in each of these languages the d or e is a clue as to which property is relevant. While L2 is pushdown deterministic, L~ is not.

Therewith we can notice the existence of an intuitive predicate of context-free languages: inherent determinism. The next step ideally would be construct and begin to study a corresponding formal predicate, but this so far has proved to be too elusive. I t is toward this objective, though, that the line of investigation begun by Ginsburg and Greibach (3), and continued here, is directed.

Introduced here (Section 3) are the deterministic scan-limited automata, which are more powerful than the deterministic pushdown automata.

A (nondeterministic) scan-limited automaton is a (nondeterministic) Turing machine operating under the restriction, for some fixed integer d, that, after d passages over any particular square no new information can be written in that square. The square may be visited, and the information therein read, arbitrarily many more times, but the content of the square is frozen for the remainder of the computation.

Scan-limited automata recognize all and only context-free languages (Theorem 1, Section 3).

198 mBBA~D

Deterministic scan-limited automata recognize not only L3 but an infinite hierarchy of langaxages, in which hierarchy the pushdown deter- ministic languages appear at the first level. More precisely, call a language d-deterministic if it is recognized by a deterministic scan-limited automaton using at most d live passages of any square. Every pushdown deterministic language is 2-deterministic (Theorem 3, Section 3). L3 is 3-deterministic but not 2-deterministic. For each d > 2 there are (d q- 1)- deterministic languages which are not &deterministic (Theorem 4, Section 4).

There is one other consideration which, though more or less inde- pendent of the motivating considerations, is nevertheless important: ambiguity. In linguistics it is felt that the meaning of an expression is re- fleeted in the grammatical derivation which admits the expression into the language, and hence a grammar is called ambiguous if some expres- sion has two or more essentially distinct derivations. Analogously, an automaton is called ambiguous if some expression is accepted by two or more distinct computations. A language is then called (grammatically, eomputationally) unambiguous if it is expressible by an unambiguous (grammar, automaton). I t is known [(2), p. 69] that when the automata are pushdown automata these two notions of unambiguity are the same. Theorem 2 (Section 3) here extends this result to scan limited automata, with the important corollary that the deterministic languages are un- ambiguous.

The terminology is basically that of (2), with some differences set forth in Section 2. In Section 2 also are established two technical facts, needed later, about pushdown automata.

Some remarks about the further continuation of this line of investiga- tion constitute Section 5.

2. BASIC CONCEPTS AND NOTATION

The terminology and notation is basically drawn from Ginsburg (2), with the following exceptions.

The null word will here be denoted A, We define a phrase structure grammar, or simply grammar, as a triple

G = ' :~o, Po)where V e and Zo c V o are alphabets and Po is a finite set of ordered pairs a --~ ~, called the productions of G, where a and ¢1 are in V~*.

a ---*o ~ will mean that a --~ fl is a production of G. For two words 3' and ~ in V~* we write "F l---to ~ if v = "/la~/~, ~ = ~1¢~2,

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 199

such tha t a --~a 8. We write 1 ̀ F- ~ 8 if 1 ̀ = 8 or if there exists a sequence 1 ` 1 , ' " , % of words in V~*, with ~/ = 1̀ 1 and ~ -- % , such tha t 1̀ ~ I--so ~'~+1 for each i < n. In other words, [- a is the smallest reflexive and transit ive relation containing I--+a.

Any sequence 1`1, " ' " , ~ , n > 1, such that 1̀ ~ l-~a 1`~+~ for each i < n, is a G-computation, and a G-computation from 1`1 to .y~.

I f e is a G-computat ion from 1 ̀to 8 we write 1' ~-o ~ via e. A production a -+ ~ is applicable to a word 1 ̀if a is a subword of 1 .̀ We will be considering various classes of automata, M1 of whieh will

come under the following DEFINI'I?ION. An automaton A is a sextuple A = (VA, Nx, P x , K ~ ,

qa , FA) where ( VA, 2 ~ , PA) is a g rammar GA, Kx C Vx - ZA is the set of states of A, qA C KA is the start state of A, FA ~ K a is the se tof final states of A, and whenever a --~ ~ is in PA, a and ¢~ each contain exactly one s tate of A.

1 ̀ ]-->a 8 means 7 [-->oA 8; 1 ̀ ~-x 8 means 3' t--ox 8.

DEFINITION. If A is an au tomaton then the reflection of A is the au- tomaton A ~ = (VA, 2A, Px R, KA, qA, Fa) where

p ~ = {aR __4 iSR:a --~a ¢~}.

Note tha t 1`R t-~R 8 ~ if and only if 1 ̀ ~-A 8. A configuration of an au tomaton A, or A-configuration, is a word in

VA* containing exactly one s tate of A. An A-computation is a Ga-eomputat ion containing only A-configura-

tions. Note tha t V~, ZA, etc., will denote the respective terms of the sex-

tuple A even if A has not been set forth explicitly as a sextuple. Call a s tate p of an au tomaton A right-looking if there is no production

in A of the form ap~ -+ 1 ̀where a ~ /k ; call p left-lool~ing if there is no production in A of the fore ape ~ 1 ̀where ~ ¢ /k.

DEFINIWION. An automaton A is deterministic if for each A-configura- tion 1 ̀there is at most one production of A applicable to 1`.

Note tha t al though a word, apflq% where p and q are states, may have more than one applicable production, i t c~nnot be a eounterexample to determinism for it is not a configuration.

Let A be an automaton. A halting configuration of A, or A-halt, is an A-configuration 1`1p1`~ where p ~ F~ and such tha t no production of A is applicable to 1`1p1`2 •

200 HIBBKRD

If no production is applicable to ~1p~2 but p E K~ - FA, then 71P7~ is an A-hangup.

A halting A-computation is a computation ending in an A-halt. "y ~-~ halt means 7 t-A ~ for some A-halt ~.

The following definitions will be easily seen to be equivalent in all important respects to the usual ones, e.g., as given in (2).

DEFINITION. A (nondeterministic) sequential transducer is an automa- ton A such that every production of A has one of the two forms

pa .-~ aq, p ~ aq,

where p and q are states of A and a E Za. DEFI~ITmN. A pushdown automaton (pda) A is an automaton every

production of which has one of the forms

pa ----) aq, Xp ~ aq, p --~ aq,

where p, q, are in K a , a E ~ , X E V~ (a could be null). DEFINITmN. If A is a pushdown automaton then the language of A,

written L ( A ) , is

L ( A ) = {w E ~a*:q~w ~-,~ ap

for some a and some final state p of A}.

A complete A-computation on w (in Z~*) is any A-computation from qaw to ap where p is a final state of A. Note that if qa is a final state, then q~, or q~A, is a complete A-computation and/% E L ( A ) .

We will, on a couple of occasions, want pushdown automata to go the other way, from right to left; i.e., we will sometimes want to consider the reflection A R of a pda A.

DEFINITION. If A is a pushdown automaton then the reflected language of A, written L(Aa) , is the set

L(A R) -= {w E ~a*:wqa ~-aR pa

for some a and some final state p of A}.

We define the terms An-computation, Aa-comeiguration, complete An-computation, etc., in the obvious way analogous to their definition for pushdown automata.

I t is obvious that L ( A ~) = ( L ( A ) ) R. Note that the crucial property of pushdown automata is that they are

not allowed to back up without erasing, i.e., annihilating. The sense of

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 201

the present discussion will be approximately that this restriction can be loosened to the extent that the automaton is allowed to back up over a given letter some fixed number of times before being required to annihi- late it.

The central fact about pushdown automata is that they characterize context-free languages. Moreover, they characterize the class of un- ambiguous context-free languages [(2), pp. 31-33], according to the following definition.

DEFINITION. A pushdown automaton A is unambiguous if for each w E Z~* there is at most one complete A-computation beginning with q~w.

The analogous definition for reflected pushdown automata is obvious. We now state as propositions (for later reference) two well-known

facts. PI~OPOSITION 2.1. I f A is a pushdown automaton then there exists a

context-free grammar G such that for each w C ZA* the complete A-computa- tions on w are in one-to-one correspondence with the leftmost G-deriva- tions of w. Conversely, i f G is a context-free grammar then there exists a pushdown automaton A such that the above property holds.

Proposition 2.1 is clear from (5), or from Chapter 2, mainly the proof of Theorem 2.5.3, in (2).

Now if G is a context-free grammar then it is clear that there is a context-free grammar G R, namely the grammar with productions {X --~ aR:X --->~ a}, such that L( G ~) = ( L( G) ) R, and moreover such that for any w the leftmost G-derivations of w are in one-to-one cor- respondence with the leftmost G~-derivations of w R. We use this to get

P~OPOSITIO~" 2.2. I f A ~ is a reflected pushdown automaton then there exists a pushdown automaton B such that L( B) = L( A R) and such that for each w E Z,~* the complete AR-computations on w are in one-to-one cor- respondence with the complete B-computations on w.

Proof. By Proposition 2.1 we let G1 be a context-free grammar for L ( A ) , with the leftmost derivations in one4o-one correspondence with the complete computations of A. Then L(Gla), where GI R is as defined in the above remark, is, by Proposition 2.1, L ( B ) for some pushdown automaton B whose computations are in one-to-one correspondence with the leftmost derivations of G1 a. We have a one-to-one correspondence at each step, so the complete computations of B are in one-to-one corre- spondence with the complete AR-computations.

Notation. We will use the following notational coventions throughout what follows, except where otherwise specified.

2 0 2 HIBBARD

The letters p, q, r, s, t, will always be states of automata. The letters a, b, c, will always denote members of EA for some au-

tomaton A. The letters X, Y, Z, will always denote members of V~ for some

automaton A. The letters a, 8, % ~, will always denote, for some automaton A,

either words of Va* or A-configurations. The letters u, v, w, will always denote words of N~* for some au-

tomaton A. e, ~3, will denote computations. For example, if we say "Let, X p w be an A-configuration," it will be

understood without explicit mention that X C VA, p E K x , w C Nx*.

3. SCAN-LIMITED AUTOMATA

The notion which we are going to investigate, that of a nondeter- ministie Turing machine being allowed only a fixed number of writing operations per square, will at first be confined (Section 3.1) to linear bounded automata, and later generalized (Section 3.2) to Turing ma- chines. I t is plain that Turing machines and linear bounded automata are, in essence, examples of automata, as defined in Section 2, all pro- ductions being of the forms p X --~ qY, p X --~ Yq, Xp ~ qY, Xp --~ Yq (re- call the alphabetical conventions set forth in Section 2).

3.1 A RESTRICTED CLASS OF AUTOMATA

Besides linear boundedness, we will impose a few other, more technical restrictions initially.

DEFINITION. An automaton A is a Jd-automaton for the nonnegative integer d if the following conditions are satisfied.

(1) Every production of PA has one of the two forms p X --~ Yq, Xp --~ qY.

(2) There exists a function la from V~ to {0, . . . , d} such that 1A(a) = 0 for each a C ~A and such that if p X ---+ Yq or Xp --~ qY is in P~_ then either (i) lA(X) < la(Y) or (ii) l z ( X ) = d and X -- Y.

(3) Every state of A is either left-looking or right-looking. (4) For every p E FA and X C V~ there is some production p X ~ Yq

in P~ . Any Jd-automaton will be called a J-automaton. A starting A-configuration is one of the form qAw where w C Za*. A

complete A-computation on w is one which begins with a starting con- figuration qAw and ends with an A-hMt.

A GENERALIZATION OF CONTEXT-FREE DETER?¢IINISM 203

Notice that by property (4) every halt of a J-automaton is of the form vp, where p is right-looking.

DEFINITIOn. Let A be a J-automaton. The set of words accepted by A

is the set

L ( A ) = {w E 2A*:qAw }-'• halt}.

We will also have use for reflected J-automata: DEFI~'ITION. If A is a J-automaton then the reflected language of A is

L ( A ~) = {w E ZA*:wq~ t--x ~ halt}. Clearly L ( A R) = ( L ( A ) ) ~. The terms complete AR-computation, etc., are defined in the obvious

way. EXAMPLE. Let V~ = {a0, b0, al , a2, b~, c2}, 2A = {a0, b0},

= q l , q 2 , =

P a = { q~ao ---> c2ql , qlao --> alql , qlbo --~ b2q2 , b2q2 --~ q~b2 ,

a2q~ --~ q2a2 , alq~ --> qla2 , qla~ --~ a2ql , qlb2 --~ b2ql ,

c~q2 --> q~c2 , qFc2 -+ c2q~ , qFa2 --> a2qF , qrb.. ~ b2q~ ,

qFbo ~ b2q~ , q~ao ---> a~qa , q~a~ ---> a~qa}.

This defines a J~-automaton with la agreeing with the subscripts;

L ( A ) = {ao'~bo'hn > 0}.

a n Notice that the important A-hangups are c: ~ q~, c~a~'~a~mb~'~qt,

n~n+2 ~ m C a n~+l c2a~ o~ q~oo . The relevant A-halts are : ~ o~ qy. In this example A is deterministic, i.e., each A-configuration has at

most one applicable production (Section 2). We are going to prove that the sets accepted by J-automata are con-

text-free languages. DEFINITION. A J-automaton A is

w E ~A* there is at most one complete We will show that the unambiguous

context-free languages.

u n a m b i g u o u s if for every word A-computation on w. J-automata accept unambiguous

The next definition is intended to apply not only to some of the automata already defined but also to some objects to be defined later. All of these objects will be gathered under the term automaton sys tem.

At present we specify pushdown automata, J-automata, and their reflections as automaton systems.

204 I~IIB:~AI~D

DEFINITION. When A and B are automaton systems we say A reduces to B if L ( A ) = L(B) , andif for each w C Zx* there are at least as many distinct complete A-computations on w as there are distinct complete B-computations on w.

We are, of course, anticipating that the terms L ( A ) , Zx, etc., will be well-defined for each automaton system A to be introduced.

PROPOSITION 3.1. Every J2-automaton reduces to some pushdown au- tomatan, with determinism preserved.

Proof. Let A be a J~-automaton. Let W = {X E VA:IA(X) = 2}. Note that for ala2 E W*, alpa2 t-A ~lq~2 only if ~if~2 = aia~.

Call two nonnull words a and ~ in W* equivalent if the following four conditions hold for all states p and q of A.

(1) If p is right-looking and q is left-looking, then pa ~-x qa if and only if p~ }--x qfL

(2) If p is right-looking and q is right-looking, then pa b-A aq if and only if p~ I-x f~q.

( 3 ) If p is left-looking and q is left-looking, then ap ~ x qa if and only if f~p ~-x q~.

( 4 ) If p is left-looking and q is right-looking, then ap ~ x aq if and only if 5P ~.4 ~q.

This equivalence relation partitions W* - {A} into fmitely many equivalence classes.

Denote the equivalence class of any a by [a]. Note tha t if [all = [as] and [fill = LS~] then [alfll] = [a2f12]o TO verify

(2), for example, suppose P ~ l ~-x a~q , where q is right-looking. Then pal ~ alto for some right-looking r0 such that alr0fh I-~ al~lq, pc~2 t-x a2ro. Either r0f31 t-x ~lq, in which case r0& ~-x &q whence p a ~ t-- ~ a~3~q, or r0~ ~- a r1~1 for some left-looking rl such tha t a~r~ t-,t a~t31q. In the latter case, r0#~ }-~ rx~h ; also a~rl t--~ a~r~ for some right-looking r~ such tha t altO31 ~ x all,q, whence a~r~ ~-~ a~r~, which brings us back to the same situation tha t obtained with r0. Continuing this procedure, we must eventually encounter r~ such tha t p a ~ ~ x axr2~, p a ~ ~- ~r~f~ , and r ~ ~-x fllq, whence we get r~f~ t-x f~q and therefore p a ~ ~ x a~fl~q. The other conditions are handled in similar fashion.

Let us agree to the following simplification: ( , ) For every production p X ---) Yq or X p --~ qY of A either X = Y

or lx(Y) = Ix(X) q- 1. This involves no loss of generality since the only other possibility is

.~ GENERALIZATION OF CONTEXT-FREE DETERMINISM ~ 0 5

l~(X) = 0 and la(Y) = 2, in which case a production p X --* Yq, for example, can be eliminated by introducing a new variable I11 with l~(Y1) = 1, and new productions p X -~ Ylq, IvY1 --* Ys : rY --*A Ys}, and { Ylr ---> sY:Yr --->,~ sY}.

Let [A] = A . Let B be the following pushdown automaton:

V , = V~ U {[~]:~ E W*, ~ # A};

~B = ~ ;

Ks = [(p[a]):p E g ~ , a E W*};

Re = I(p)a ~ X(q):pa -+a Xq} U {X(p[a]) ---> (q[Ya]):Xp --+~ qY}

U { (pin]) --~(q[a]) :p right-looking, q left-looking, a ~ A , pa ~ A qa}

U { (p[a]) --+ [a](q) : p and q fight-looking, a ~ A, pa t-~ aq}

U {[f~](p[a]) --~ [~](q[a]):p left-looking, q right-looking, 3p ~-~ ~q}

U {[fl](p[a]) --+ (q[fla]):p and q left-looking, tip ~ q3};

q . = (q~);

F , = {(p):p E F~}.

Note that (p) = (p[A]) since [A] = A. Clearly the only A-configurations which matter are of the form

X1 . . . Xkp~w where 1A(X~) > 0 for each i, ~/E W*, and the only B-configurations which matter are of the form X1 . . . X~(p[a])w where for each i either X~ EVA with l~(X) = 1 or Xi = [~] for some/~ E W*. Hence let us let the term configuration be so restricted for the remainder of this proof.

Clearly B is deterministic if A is. To see that A reduces to B, it will only be necessary to divide A-com-

putations into segments which correspond to productions of B and, conversely, given a B-computation, to recover segments of a correspond- ing A-computation. To do this, we segment each word of each A-com- putation so that the segmenting corresponds to the way B thinks of the word. Let us make this precise. Let ~ be an A-configuration. A segmenting of ~ is

(.y~) . . . ( ~ k ) p ~ w

206 H I B B A R D

where

"h "'" "I~paw = "/;

a E W* (possibly null);

"Y~E { X E Va:l~(X) = 1} (J (W* -- {/k}) for each i < k.

Note that the parentheses have real notational force and that a seg- menting is a sequence of words rather than a sequence of letters.

Note tha t a starting configuration qaw has just one segmenting, but in general there are many segmentings of a given configuration.

There arises immediately the notion of a segmented computation: given an A-computation, we segment the first configuration, and then remove from the computation the details of the passages, e.g., from ~ p to qT~ where 3'~ E W*; the configurations which remain become, in a unique manner, given the segmenting of the initial configuration, a sequence of segmentings. More precisely, by induction:

1. The segmented computations of length I are just the segmentings of A-configurations.

2. The segmented computations of length 2 are the following, where /~ represents a sequence of the form (~/1) "." (Tk) :

2.1. {~paw, tt(X)qw:pa --+A Xq}. 2.2. {tt( X)paw, ~qYaw:Xp "--+a qY}. 2~3. { t~paw, ~qonv :p right-looking, qleft-looking, a ~ A , pa ~ ~ qa}. 2.4. {~paw, tt(a)qw:p and q right-looking, a ~ A , pa t--a aq}. 2.5, {~(f3)paw, t~(fl)qaw:p left-looking, q right-looking, ~p t -a

~q}. 2.6. {~(~)paw, t~q[3aw:p and q left4ooking, ~p t-A q~}.

3. The segmented computations of length m + 1 are ~ , • • • , ¢m+1 where zl , - . . , zm and am, z~+l are segmented computations of length m and 2, respectively.

An arbitrary A-computation may not give rise to a segmented com- putation because the A-computation may terminate in the middle of one of the segments. However, a halting A-computation cannot so ter- minate , and the following assertion is plain:

Each :halting A-computation from ~ to ~, together with a segmenting z of % gives rise to a segmented computation from ~ to ~ where r is a segmenting of ~.

I f z is a segmenting of ~/write ~ = % (Clearly z can be a segmenting of only one configuration.)

A GENER~-LIZATION OF CONTEXT-FREE DETERMINISi'~ 207

By inspection of the definition of segmented computations, particularly those of length 2, it is easily verified that a segmented computation al , " " , am gives rise in a natural way to an A-computation (not necessarily unique) from 31 to ~m, which A-computation contains ~1, " '" , a~ as a subsequence. Moreover, distinct segmented computa- tions ~, al , . . . , am and ~, r~, - . . , r , (i.e., beginning with identical segmentings) give rise to distinct A-computations.

Call a segmented computation al , . . . , am complete if ~ = qAw for some w and ~m is an A-halt. From the facts just cited we assert

(1) For every complete A-computation beginning with qAw there is a complete segmented computation beginning with q.~w.

(2) For every complete segmented computation beginning with qAw there is a complete A-computation beginning with q~w; moreover, distinct complete segmented computations give rise to distinct com- plete A-computations.

To show that A reduces to B it will now suffice to establish for each w a one-to-one correspondence between complete segmented computa- tions beginning with q~w and complete B-computations beginning with (qA>w.

For ~, C W* let -~ = [~]. For X C V~ with 1.~(X) = 1 let )~ = X. If a = ( 'n) . . " (.~k)paw is a segmenting, denote by ~ or ( a ) - the B-con- figuration ~1 - ' " ~(p[a]>w.

Let us show for each segmenting z that there is a one-to-one cor- respondence between halting segmented computations beginning with

and halting B-computations beginning with ~. First, we claim tha t if ~ , • • • , ~ is a segmented computation then

~ , . . • , ~ is a B-computatiom This is trivial for n = 1, and to establish it in general we need only consider the case n = 2. The segmented com- putations of length 2 are given by sequences 2.1-2.6, above, and to each of these corresponds a production of B, which productions have been set forth in the order corresponding to sequences 2.1-2.6; inspection of the six possibilities establishes the claim.

Conversely, given the B-computat ion ~ , . - . , ~ and a segmenting ~ of ~ , we claim that there is a segmented computation ~ , . . . , ~, such tha t ~ -- ~ for each i; and, moreover, tha t once ~1 has been chosen the rest of the ¢~ are uniquely determined. Again the case n = 1 is trivial and it suffices to consider the case n = 2. Again it is a mat ter of com- paring the productions of B with the corresponding segmented com- putations of length 2 given in the same order in sequences 2.1-2.6, and

208 HIBBARD

we see that if the B-computation ~1, ~ is given together with the seg- menting zl of ~ , then z~ is uniquely determined such that ~ , ~2 is a segmented computation of length 2.

Thus the correspondence z~, • • •, ~ +~ ~ , . . - , ~. is one-to-one for each zl. Now if ~1 = (q.~)w then zl must be q~w, and ~ , . . . , ~ is com- plete if and only if ~ = ~(p> for some (right-looking) final state p of A, and the latter holds if and only if z~ is a segmenting of an A-halt. Thus we have a one-to-one correspondence between complete B-computa- tions on w and complete segmented computations beginning with q~w. With the relation established earlier between segmented computations and A-computations, this proves that A reduces t0 B.

Let us next add to the class of automaton systems the ordered pairs (A, B)'where A is a sequential transducer and B is a pushdown au- tomaton, reflected pushdown automaton, a J-automaton, or a reflected J-automaton. That is, B may be C or C ~ where C is a pushdown au- tomaton or a J-automaton. A complete (A, B)-computation is an ordered pair (C1, C2) where Cl is a complete A-computation from q.~w to a p for some a E ~B*, and e2 is a complete B-computation on a (i.e., to a: halt from either qBa or aqB, depending on whether B is reflected or not). (a~, ~2) is also called a complete (A, B)-computation on w. We define L(A, B) = {w C x~*: there exists a complete (A, B)-computation on 'w}.

This is enough terminology to render meaningful for (A, B) the term "reduces to" defined earlier.

I t is plain that if B reduces to C then (A, B) reduces to (A, C). The program now is to show that if B is a pushdown automaton and

A is a sequential transducer then (A, B ~) reduces to a pushdown au- tomaton, and then *h~t if A is a Jd+~-automaton, d > 2, then A reduces to (B, C R) where C is a J~-automaton. This, together with Propositions 3.1 and 2.2, will show that J-automata reduce to pushdown automata.

PROPOSlTIO~ 3.2. For each sequential transducer A and pushdown automaton B, ( A, B) reduces to C for some pushdown automaton C.

Proof. Let m be the length of a longest word a such that A has a production pa ---> aq or p --> aq. Let W = {w C ~ * : ] w ] =_6 m}. Note that/% ~ W.

Let C' be the following pushdown automaton:

Vc = ~ , U VB;

~c = ~A ;

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 209

Kc = K~ X W X K ~ ;

Pc = $1 U S~, where

$1 = {(p, a~, r) -+ a(q, ~, r):pa "--->B aq}

[J IX(p, ~, r) ---* a(q, ~, r ) :Xp -+8 aq}

U {(p, ~, r) .--*c~(q,~,r):p---+Baq};

S~ = {(p, A , r)a --> a(q, fl, s):ra ---*~ b~s, pb ---*B aq}

U { (p, A , r) ~ a(q, ~, s):r -%~ b~s, pb ---~ aq} ;

qc = (q~, A, q~);

Fc = F , X {A} X F ~ .

C's job is to run A and feed the output into B as it is generated. The productions in the subset $1 of Pc are simulations of B. The productions in $2 are simultaneous simulations of moves of A and moves of B (to avoid ambiguities that might arise in C were C allowed to generate output from A without immediate use of it by B).

To be more precise, it is plain that for all % fl C VB*, all p, r E Ks , all q C K~, and all a C W, there is a one-to-one correspondence between B-computations from "ypa to fir and C-computations utilizing only $! from 7(P, a, q) to f~(r, A, q).

From this it is easy to show by induction on the length of w that there is a one-to-one correspondence between ordered pairs (C1, C2) and C-computations Ca, where Ct is an A-computation from qAw to f~q, as is a B-computation from qBf~ to ~p, and C3 is a C-computation from (q., A, qA)w to 7(p, A, q).

The desired result follows at once by taking p C F , and q E F~. PROPOSITION 3.3. Let A be a J~-automaton, d > 1. Then A reduces to

some ( B, C ~) where B is a sequential transducer and C is a Jd-automaton. Proof. Let

ZB = Z ~ ,

v~ = ~ U { x : x c v~ , z~(x) > o}

U {(p, q):p, q C KA, q right-looking}

U { p ' : p C K~},

KB = K~ U { O ] ,

210 HIBBARD

P n = {pa --~ X ( q , r ) r : a E Y,a , p a - - ~ X q , r right-looking}

U {p--~ p'0: p E FA},

q8 = qa, F , = {0}.

Let us note that for al , • • • , an C Y.x , qo, • • • , q~ E K ~ with qo = qA ,

pl, " " , p , C K ~ , a n d X 1 , . . . , X ~ C VA, (1) q~-la~ - % X , p ~ for each i, 1 =< i =< n, and q~ C Fx, if and

only if q,a l . . . . a~ ~ - , X~(p~ , ql) " " X ~ ( p ~ , q~)q~'O.

Note that this includes the case n = 0. The following notation will be convenient: Let e0 be a B-computation

from q,~al . . . a , to X I ( p l , ql) "'" X~(p~q~)q, 'O. Suppose no, . " , a,~

are words such that for each i , 0 < i <= n, there is an A-computation ei from a~_lX~p~ to a~+lq~+l. Then the sequence e0, .... , e~ will be called a B A - s e r i e s on aoqa~ • • • a , . Note that for i > 0, C~ may be trivial, i.e., possibly a i - l X i p l = a iq i .

Note that in case n = 0, the BA-series consists just of the A-computa- tion e0 = q~, q~'0. This occurs only if q~ C Fa , i.e., only i f /~ E L ( A ) .

I t is plain that there exists for each configuration aoqw, q right-looking, a one-to-one correspondence between, on the one hand, A-computations from aoqw to words of the form 7P, and, on the other hand, BA-series on aoqw. In particular, we have for each w E 2~A* a one-to-one correspond- ence between complete A-computations on w and BA-series on qAw.

The transducer B produces the firsg terms e0 of BA-series (together with some irrelevant computations). We will now set forth a reflected Jd-automaton C R which produces the rest of the BA-series. Let

v~ = {x ~ v~:z~(x) > o} U {$,]}

U { (p, q) :p, q E Ka , q right-looking}

U {<p, q) :p E Kx, q E K~ U {H}} U { p ' : p C g a } ,

Zc = V~ - - Z a ,

K~ = K~ U {H}, 8

Pc ~ = ~ Si where the Si are defined thus: i = 1

& --= {p'q~ --+ p]:p ~ K~};

S= = {(p, q)r --+ p(q, r}:p, q, r ~ K a , r left-looking};

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 211

Sa = {q(q,r} ~ $r:q E K # , r E K , U {H}, q right-lo0king};

St = {a--+ f~:a --% f~ and a contains no m e m b e r of Z~}

U [$P ---+ P$:P E KA, p left-10oking }

U {p$ -+ $p:p E K a , p r ight- looking};

& = {r] -+ $ / / : r C F~};

$6 = {$H---+ H$} U {XH--+ H$:I,~(X) < d q - l }

O {XH--, HX:l~(X) d + 1}

U {XH---+ H $ : X = ] or X = (p, q) or X = p'}.

& = {(p, q)g---+p(q,H}:p, q E KA};

Ss : {q(q, H} -+ SH:q E K a , q r ight-looking};

Fc = {H}; qc = an.

C ~ is a reflected J d - a u t o m a t o n : We can choose lc (X) = l~(X) - 1 for each X E V a - Z a , Ic((p, q)) = d - 2, lc(p') = d -- 2, lc((p,q)) = d - 1, lc(]) = d - 1, lc($) = d. E v e r y produc t ion is of the required fo rm as can be seen direct ly or, in the case of 84, f rom the fact t h a t A is a J - a u t o m a t o n . E v e r y s t a te of C ~ is ei ther lef t- looking or r ight-looking, again ei ther b y inspect ion or because the corresponding s ta te of A is. T h e product ions of the last given subset of & are no t funct ional bu t only prov ide fo rmal compl iance wi th the specif icat ions of J - a u t o m a t a .

W e now define A-series. These are sequences e l , • • • , e , of the t ype occurr ing in BA-ser ies e0 , . . . , e , . M o r e generally, we wi l l call e l , • . . , e , an A-series if there exist words a0, . . • , a , in (Va - z a ) * , le t ters X i , . - . , X , in Va - - ~ a , and s ta te pairs ( p l , ql) , • • " , ( p , , q~), each q~ r ight- looking, such t h a t for each i, 1 < i < n, e~ is an A-com- pu t a t i on f rom a~xX,T~ to a~q~. ~kTote t h a t e~ m a y be trivial , e , , • • • , e~ is an A-series on oeoXl(pl, q,) . . . X~(p~, q~). I f qn E F , then the A-series is a halting A-series. A-series are not defined for n = 0.

VVTe w a n t to show for each f~ = a0Xi(p~, ql) . . X ~ ( p , , q~) t h a t there is a one- to-one correspondence be tween hal t ing A-series on f~ and com- plete 6m-c0mputa t ions on flq~'qc. W e will show b y induct ion t h a t a one- to-one correspondence exists for each fixed n. Fo r n = 1 we are considering ha l t ing A-compu ta t i ons e f rom ceoX~pl to a, ql. B y inspect ion of C ~ these are in one-to-one correspondence wi th CR-computa t ions

212 HIBBARD

aoXl(pl , ql)q~'qc, aoXl(p~, qi)ql], a~X~(pi, ql)$H, oLoX~(pl, ql)H$, aoX~p~(ql, H)$, . . . , a~q~(q~, H)$, a~$H$, . . . , Ha~$$. We here adopt the convention that a, . . . , /~ may denote a trivial computation with

~ ~°

Suppose we have the correspondence for the integer n. Plainly an A-computation Cl from aoX~p~ to a~ql, together with a halting A-series C~, . . - , C.+~ on a~X~(p2, q2) " " X,+l(p,+~, q,+~), uniquely specifies a halting A-series on a0Xl(p~, q~) . . . X,+~(p,+~ , q~+~), and conversely. The halting series on alXs(p~, q2) " " X.+i(p.+l, q~+l) are by inductive hypothesis in one-to-one correspondence with halting Ca-computations ~l beginning with aiX~(p3, q2) " " X,+I(p,+I, q,+l)q',+iqc, and the A-computations from aoX~pl to alql are, for each left-looking state r of C a, in one-to-one correspondence with C~-computations ~)3 = aoXi(pi , ql)r, aoXipl(qi, r), . . . , alql(ql, r}, alSr. Hence it will suffice to show that these ordered pairs ( ~ , :O3) are in one-to-one correspond- ence with halting Ca-computations ID beginning with aoXl(p~, ql) "'" X~+l(pn+i, q,+l)q',+lq~. The only Ca-halts are of the form H~. So, given

as just described, ~D must provide a computation from X~(p3, q3) • • • X,+z(p,+l , q~+l)q,+lqv to r7 for some 7 and some left-looking state r of C a (which is either H or a left-looking state of A). From a0Xl(pl, ql)r')', the only possible continuation is of the form aoX~p~(ql, r}% . . . , a~q~(ql, r)~,, alSr% . . . , H~, thus providing a Ca-computation :93 from aoXlpi to a~q~ (for some al). There is an obvious one-to-one correspondence between Ca-computations from alXlSrS, to H~ and Ca-computations from aiXlr7 to H~', where ~' is the same as except for the omission of the initial $, for the only effect of $ is to add some applications of productions p$ --~ Sp and $p --~ p$. Thus we can assert that ~) not only provides a computation from X3(p3, q3) " " X,+l(p,,+i, q ~+1) q'~+lq~ to r-~ but also from a~r7 to H~'. Putting these together gives a computation ~)l from a~X~(p3, q3) " " X,+I(P,+I, q~+i)q',~+lqc to H~'.

Conversely, given the computation ~O3 from aoXlp, to a,q,, and the X computation ~O, from aiX3(p3, q3) . " ,+,(p,+l, q.+i)q.+lqe to halt,

we obtain from ~Oi a computation from X3(p3 , q3), • • • , X~+i(p,+i , q~+l) " !

q,,+,qc to r'r for some left-looking state r, and a computation from air3' to halt. This provides, with ~ , , a computation aoXi(pi , qi) ' ' ' X~+i(p~+,, q,,+i)q',~+,qc, " " , aoX, (p i , q,)r3,, aoX~p,(q,, r)% • aiqi(ql, r>'r, alSr'r, . . . , H~ (with the convention adopted above if pl = q~ and a0X1 = al), where the final segment of the computation,

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 213

that from al$r~" to halt, is obtained in the obvious way from the given computation from airy to halt. Moreover, this construction is just the reverse of the one given in the previous paragraph.

Therefore the one-to-one correspondence exists as claimed. We have already seen that for each w the complete BA-series on w

are in one-to-one correspondence with the complete A-computations on w. A BA-series on w consists of a complete B-computation and, if n > 0, an A-series, so, from what we have iust seen, the complete BA-series on w are in one-to-one correspondence with the ordered pairs ( e~, e2), where C1 is a complete B-computation from qBw to XI(pl , ql) . . . X~(p~ , q~)qn'O and C~ is a complete Ca-computation on X~(pl, ql) "" X~(p~, q~)q~'. This includes the case n = 0, according to the remark made earlier. These ordered pairs (e~, C2) are exactly the complete (B, Ca)-computa- tions on w. Therefore A reduces to (B, Ca).

PROPOSITION 3.4. Every J-automaton reduces to a pushdown automaton. Proof. We have already seen (Proposition 3.1) that every J~-au-

tomaton, and therefore every J0- or J1-automaton, reduces to a push- down automaton.

Let d _-> 2 be an integer such that every Jd-automaton reduces to a pushdown automaton. Then dearly every J~a-automaton reduces to a reflected pushdown automaton. By Proposition 3.3, every J~+l- automaton A reduces to (B, Ca) where B is a sequential transducer and C R is a reflected J~-automaton. C a reduces to some re- flected pushdown automaton D ~, and D ~ reduces (Proposition 2.2) to some pushdown automaton E. Hence (B, Ca) reduces to (B, Da), and (B, D ~) reduces to (B, E). Finally, by Proposition 3.2, (B, E) reduces to some pushdown automaton F, whence A reduces to F.

We remark that the effect of this construction is to simulate a J~-au- tomaton with a sequence of d sequential transducers, since a pushdown automaton can be simulated by two transducers.

3.2 SCAN-LIMITED AUTOMATA

The restrictions imposed on the J-automata are likely to be incon- venient in practice. Moreover, the inability of J-automata to make positive recognition of the right-hand end of the tape prevents a lan- guage such as

{a"b%~m:n, m > 0} (J {a~b2~m-~:n, m > 0}

from being deterministic in terms of J-automata. The modus operandi

2 1 4 : H i B B A R D ' : . . . .

of Turing machines, whereby a new "blank" Square pops up auto- matically whenever the reading head gets t o the far right, makes the end of the tape recognizable. '

Therefore, we now pass to true Turing machines having only the limited scan restriction. Formally:

DEFINITION. A d-limited automaton A is a 7-tuple (V~, ~ , P x , K~, qA, F~ , 0~) where (Vx, ~a , PA, K x , F~ ,qx) is an automaton, 0~ E V a -- ~x, and the following holds: There exists a function l~ from V~ to {0, . . . , d} such that lx(a) = lx(Oz) = 0 for each a E Zx , and each of the productions of Px has one of the five forms:

pX ~ qY; pX --~ Yq; Xp ---+ Yq; Xp ---+ qY; p -~ q,

where either (i) la(X) < 1A(Y) or (ii) X = Y and la(X) = d. An A-configuration is a configuration of the automaton (V~,

Z~, P~, , K~ , qA, F~). The states, productions, final states, start state, of A are respectively those of (V~, ~x, P x , KA, qx, Fx). a --+~ means a --+ ~ is in P x .

We write -~ I--~A 6 for two A-configurations ~, and 6 under either of two l

conditions: (1) ~/ is not of the form ~,p, ~, = ~'1a~'2, and 6 = ~'1~'2 where a --~A/~; (2) "y = V'p and 6 = "/pOx.

An A-computation (from -~1 to ~'~) is a sequence ,y~, - . . , ~,~ of A-configurations such tha t ~/~ [--+~ ~,~+~ for each i < n. If n = 1 the computation is called trivial.

We write ~ t-x 6 if there is an A-computation from ~, to 6. An A-halt is an A-configuration ~, = "~p~/~ where p ~ Fx and for

no 6 does ~, [--~ & A complete A-computat ion (on w) is an A-computation from qaw,

w ~ ~**, to ~, where ~/is ~n A-halt. A scan-limited automaton is any d-limited automaton for some d.

DEFImTION. If A is a scan-limited automaton then the set of words accepted by A is the set

L(A) = {w ~ Za*:there exists a complete A-computation on w}.

DEFINITION. A scan-limited automaton A is unambiguous if for each w ~ Za* there is at most one complete A-computation on w.

DEFINITION. A scan-limited automaton A is deterministic if for each A-configuration ~ there is at most one 6 such that ~, 1-+~ 6.

Clearly every deterministic scan-limited automaton is unambiguous. No~ice tha t whereas the J -automata are linear bounded automata, the

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 215

scan limited automata are Turing machines: Any amount of tape may be acquired for the computation through the appending of 0~.

We now specify the scan limited automata to be automaton systems; we have defined enough terms to render meaningful the expression " A

reduces to B" when A or B is a scan-limited automaton. EXAMeLE. The set {ao~bo'~:n > 0} is accepted by the following 2-limited

automaton A.

Va = {a0, bo , al , oe , b2 , 0o , 02},

Z~ = {a0 , b0},

K~ = {q~, p, q},

P.~ = { qAao - ~ alq~ , q~bo ---+ pb2 , b2p ~ pb2 , asp ~ p o e , alp ~ oeq,

qoe ~ oeq, qb2 ~ b2q, qbo ---+ pb2 , qOo ~ r02 , b2r ~ rb2 , oer ~ ra2 ,

alr ~ soe}.

Fa = {r}, 0~ = 00.

We now want to show that every scan-limited automaton reduces to one having properties ( 1 ) and (3) of J-automata, (referring to the definition given above) and having the following property (5) which corresponds to (4):

(5) A has exactly one final state H, H is right-looking, there are no productions of the form H --+ p, p --~ H, or H X --~ q Y , and any configura- tion H X is an A-halt if and only if X = 0~.

To reduce a given d-limited automaton A to one having property (5), let B be the following (d 4- 1)-limited automaton (we could preserve d but it is not worth the trouble).

V, = V.~ U {{$X):X E V~} U {x}, where x i s anew symbol,

Z~ = ZA ,

K , = K~ U {($p}:p E K~} U { p ~ : p E FA} U {H},

P , = P~ U {($z)r --~ ($p)u:z, r, o, # E K~U V , , zr --~a p•}

U { X p ~ x p ~ : p E F x and there exists no production X p ---~a

or p---+q in Pa}

U {($p} --~ p R : p E F.~, there exists no production p --+ q in Px}

216 ~BBAm~

[J {pRX -"* Hx:p E F.~ and there exists no production

pX---ra in P~}

U {HX ----> x H : X ~ O,t},

q~ = ($q.4}, FB = {H}.

B has property (5). Call 3" a proper B-configuration if 3" = ($z}3" where z C K~ U V~ and

~3" is an A-configuration. I t is easily seen that if 3' is proper and 3" [-- B ~, then, unless ~ contains H or some p~, 6 is also proper.

Plainly, a B-computation containing only proper configurations is homomorphic to an A-computation under the homomorphism which drops $. Conversely, any A-computation is the homomorphic image of such a B-computation, and these two sets of computations correspond in a one-to-one manner under the homomorphism.

A_a A-computation from q~w to ~3", z E Ka O Va, corresponds there- fore to a B-computation from ($q.4}w to ($~}3" and conversely. Now if X p Y is an A-halt, then X p Y ~B xpRY t--B xHx, and if p X is an A-halt, then ($p}X ~-B pRX ~-B Hx. Conversely, the only proper configurations from which H can arise are ($~}3" where ¢3" is an A-halt. Moreover, if ~3" is an A-halt then there is one and only one B-computation from ($~)3' to halt. This establishes a one-to-one correspondence between A-computa- tions fom q.4w to halt and B-computations from ($q~}w to halt; i.e., A reduces to B.

Now let us reduce a d-limited automaton A with property (5) to one with both (5) and property ( 1 ) of J-antomata. We will in general obtain a d'-limited automaton where d' > d. We have to eliminate productions p X ---> qY, Xp ~ Yq, p ---> q.

A production p X --+ qY, X ~ Y, can be simulated by two productions p X ~ Zr, Zr ~ qY, where Z is a newly introduced letter, r is a new state, and la is adjusted so as to accommodate l~(X) < l~(Z) < l~(Y). The latter adjustment is always possible because the reflexive and transitive closure of the relation R, defined by X R Y when a "-+a/~ with X in a and Y in/~, is a partial ordering relation, and the adjunction of X R Z R Y ex- tends R to a new partial ordering according to which the new la can be constructed. Similar comment applies to productions Xp --~ Yq. In case of a production p X ----> qX, we introduce a new state r and replace the production with the two productions p X ---> Xr, Xr --~ qX. Similar com- ment applies to Xp ~ Xq. Multiplicities of computations are preserved

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 217

because the new pairs of productions can only be used consecutively, and any such new pair uniquely specifies the old production which it i s replacing.

Proper ty(5) is preserved by this transformation. : : One more reduction is necessary for property (1), the elimination of

p --* q. We first replace p -+ q by the productions {pX --~ Yr: qX ---~.~ Yr} 0 {Xp ~ rY :Xq ---+ rY}. Then anything that the old automaton could do from state q the new automaton can do from state p, and anything the new automaton can do from state p the old automaton could do either directly from state p or by first passing to state q. Clearly the halts of the new automaton are lust those of the old, because the old automaton has proper ty(5) and none of the changes could have involved the final state H. The complete computations of the old automaton may fail to be in one-to-one correspondence with those of the new, but only because the old automaton may have a nontrivial computation from p to p (a "loop"). But for each w there are at least as many complete computa- tions on w in the old automaton as there are in the new one. Property (5) and also the absence of productions p X ---+ qY, Xp ~ Yq, are pre- served in the reduction.

Now property (3), namely that each state be either left-looking or right-looking, is easily obtained from an automaton having properties (1) and (5). Given A with Fa = {H} we let

VB = Ira; ~B = 2;A;

K B = {p~:p C K.~ , p # H} U {PR:P E K a , p ~ H} U {H};

PB = {paX ---> YqR:pX "---~A Yq, p, q # H};

U {pRX ~ Yq~.:pX---~A Yq, P, q # H};

i.J {XpL ~ qRY:Xp -*a qY, p, q # H};

U {XpL --~ qLY:Xp ---~a qY, p, q ~ H};

t.J {pax --~ Y H : p X --->~ YH};

0 {XpL --~ H Y : X p -->~ HY};

U {HX ~ Y H : H X -+a YH};

q, -- (q~)R, F , = {H}.

B has properties (1) and (5) if A does, and B also has property (3) [H is right-looking by (5)].

218 mBBARD

Obviously B can do anything A can do. The only thing B can do, which .4 can't do, is get stuck with the wrong choice between pr or PR, but this leads to no surplus complete computation. So .4 reduces to B.

PROI'OSITrO~ 3.5. Each scan-limited automaton reduces to ( B, C) where B is a sequential transducer and C is a J-automaton.

Proof. Let A be a scan-limited automaton. By the preceding discussion we can assume that A has properties (1), (3), (5). Let B be a sequential transducer such that for each w E Z~*, {a:qBw ~B ap for somep C F.} = {w0ff:n > 0}, and such tha t for each w and each n there is exactly one complete B-computation from qBw to wO.~p.

Let H be the unique final state of A. Properties (1), (3), (5), are easily seen to imply that (V~, Z~, P a , K ~ , qA, {H}) = A' is a J-au- tomaton. Let

V~ =V~ U {$},

Zz = Z~ ,

Ke = KA U {pc, He},

Pc = PA U {HOA --+ SHe, He0~ --+ SPe},

qe = q~, Fe = {He}.

C is a J-automaton. Rather than make a special case where A is 0-limited, let us note the

obvious fact that a 0-limited automaton can be reduced to a i-limited automaton, and the latter, by the above discussion, reduces to some d-limited automaton, d _>- 1, with properties (1), (3), (5). Hence we can assume without harm tha t A is not 0-limited.

Then all relevant `4-halts are of the form ~,H0~, where 0x is not in % because 1A(0x) = 0 and hence there are no productions p0a --+ 0Aq.

I t is immediate tha t there is a one-to-one correspondence between A-computations from qAw to "~HO~ and ordered pairs (n, C) where C is a C-computation from qAwOff to 7HOA • ~,H0~ can only be continued via the production H0~ --~ SHe. ~H is a hangup, and ~/H0~ ", n > 1, is forced to ~,$$po0] -2, another hangup. Conversely, state Hc cannot be reached except by means of ~,HOA [--~e 7SHe. Thus there is a one-to-one correspondence between C-computations from q~wO~ ~ to ~HOA and com- plete C-computations on w0ff. I t follows that there is a one-to-one cor- respondence between complete ,4-computations on w and ordered pairs (n, ¢) where C is a complete C-computation on q~wOx ~. Clearly the latter

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 219

correspond one-to-one with pairs (C1, C) where el is a complete B-com- putation from q~w to w0ffp. Thus A reduces tO (B, C),

We have seen that any J-automaton C reduces to a pushdown au- tomaton D, and that (A, D) reduces to a pushdown automaton when A is a sequential transducer. Hence we have immediately )

PROPOSITION 3.6. Every scan-limited automaton reduces to a pushdown automaton.

Now let us close the circle by reducing pushdown automata to 2-limited automata. The next proposition will simplify the notation.

PROPOSITION 3.7. Every pushdown automaton A reduces to a pushdown automaton B which is deterministic i f A is and has the following properties:

(1) each production of B is of one of the forms pa ~ Xq) pa ---+ q, Xp --> Yq, X p ---* q;

(2) every final state o r b is right-looking; (3) for all a E SB and all p C FB , there exists a production pq --~ a.

Proof. We first consider the case where A is not deterministic. In (2), the proofs of Theorem 2.5.3 and the associated lemmas can

easily be modified so as to show that for every pushdown automaton A there is a context-free grammar G such that L ( A ) = JL(G)and such that for each w E ~x* there is a one-to-one correspondence between complete A-computations on w and leftmost G-derivations of w.

In (5) it is shown that any context-free grammar G is equivalent to grammar H such that all the productions of H have the form X -+. as, with the single possible exception of ~ -*/% where ~ is the start letter of H. Here equivalent means that L ( H ) = L(G) and that for each w the two sets of leftmost derivations of w are in one-to-one correspondence.

We can assume without loss of generality that the Start letter z of H is not in the second string of any production of H, and also tha t /~ has ~ most the one derivation ~, /k.

Let m -- max { I a I : X "---~H as for some X, a}. We are now going to define a pushdown automaton B : B will simulate

H directly, but will appear more complicated than it is because of the need to keep a special mark ~t the front of the tape; the initial letter will always be of the form (a].

~ = :~( = ~ ) .

KB = /(X):X C V . -- ~ } U {0, f, g}.

PB = I(X)a --~ [a~]0:X --~, as, X # zl

220 HIBBARD

u ((u)u -+ (aR]O:a ‘a aa}

U ( [aX]O --) [a](X):all ar, X)

U ((ax]0 -4 (cz](X):all or, X]

u fbw --) o:, (Al0 -+ f) u (fu + g:a E X4).

qe = (4.

Fe = (fl U & where & = {(c)j if u +d /j and

& is empty otherwise.

B-computations proceed by segments of the forms (U)UW, (crRX]O~, (~“l@h rGow YbREr10 w, y[oLR](Y}w; etc. Corresponding to these we have segments of leftmost H-derivations: u, aXa!; uXrR, vuY( a~)~; etc., where v is the part of the input already read by the automaton. Thus there is for each w a one-to-one correspondence between B-computations from (u)w to r(X) and H-derivations from u to wXyR. Pushing the same thing a little further, there is a one-to-one correspondence for each w between leftmost H-derivations from u to w and B-computations from (u)w to (r\]O. Th e a 1 tt er continue uniquely to f. No A-computation ending in fv is complete unless v = A. Therefore we have a one-to-one corre- spondence for each w between leftmost H-derivations of w and complete B-computations on w.

Due to the properties of H already cited, B is the required pushdown automaton.

There still remains the case where A is deterministic. First, we can do away with the productions of the form p -+ 9, for,

given any state p there is at most one state Q for which p l- d p while A has some production qcz + CY or Xq -+ LY, lest A be nondeterministic. Given such p and q, we introduce the new production pa + Q! if qa -+A ct,

or Xp + (Y if Xq + (11, and delete the productions by which p I- 1 q. If p f-d q where q is a final state, we make p a final state. So we may as well assume that A has no productions of the form p --+ q.

Since A is deterministic, every state of A is either left- or right-looking. According to (S), Lemma 2.1, we can assume that A is loop-free; i.e.,

for every word w E 2** there exists a right-looking state p and a word rE zA* such that qAw l-a ‘yp. It follows that we may assume for each X E VA and each state p of A that there is a unique word yxp E VA* and a unique state qxP such that Xp I-A yxPqxP and either yxp = A or

A G E N E R A L I Z A T I O N O F C O N T E X T - F R E E D E T E R M I N I S M 221

qxr is right-looking. The uniqueness of 7xp and qx~ follows, of course, from the determinism of A.

L e t N = max ({lal:pa---*~aq, p,q E KA ,a E ~ } U {l~/xp]:p E K.4 , X ¢ V A ) .

Let B be the pushdown automaton defined as follows:

VB = ~.~ U {('v):~' EVa* , "Y # A, ]~] _-< 2N},

Z B = ~ a ,

K . -- {(,yp):~ C V.~*, I~'l -<- N, p E K.4},

P . = { (ap)a --->. (a~)(q): pa -->A #q, a~ ~ A }

O { ( p ) a-+. (q):pa -~A q}

U {(~X)(p) --+ (f~)('Yx~qx~):p left-looking, fl # A}

U { (X}(p} -~ (~/x~qxp) :p left-looking},

q. = ~q~),

F. = {(~/p):p E Fa}.

B is a deterministic pushdown automaton with properties (1)-(3) , Proposition 3.7.

The complete computations of B are in one-to-one correspondence with those of A. For, the complete A-computations are specified by sequences ex, • .- , ek of A-computations, where each e~ is either a~, a~+l

t where ~i I---~a ~+1, or a~, ~.Jl , ' " , ~i.~'~, ~+1 where ~ = ~/Xpv, ~+~ = "y~lxpqx~v. I t is easily verified by induction tha t these sequences ax, - ' . , ek with their a t tendant ~ , . . . , ~+x correspond to B-compu- tations ~/x, " '" , ~/~+~ where q~ = ~. for each i, q being defined as the image of "~ under the homomorphism (&} --- a, (a-~) = aT, g = a (each a E Za). Although tha t homomorphism is not one-to-one, its action on complete B-computations is one-to-one, for ~ then must be some start- ing B-configuration (q~}w.

This proves the proposition. PROPOSITION 3.8. I f A is a pushdown automaton then A reduces to a

2-limited automaton B which is deterministic i f A is. Proof. By Proposition 3.7 we can assume that A has the properties

given for B in the statement of Proposition 3.7. Let us also assume tha t X and Y in productions pa ~ Yq, Xp ~ Yq, X p --~ q, are not in Z~, a condition which is obtained in an obvious way.

2 2 2 HIBBARD

Let B be the following 2-limited automaton, where for brevi ty we let W = (V~ - Z~) U I$}:

VB = Y~ U {0, $, 0.}(0, $, 0B ~ V~);

ZB = ZA ;

KB = {<Xp>:X E W, p C K~}

U {<Xp~>:z E w, p c K~} U K~ ;

P~ = {(Xp} -~ <Yq}:Xp ----~A Yq}

U { (Xp} ~ q: X p --*A q}

U {(Xp~)a ~ X(Yq):pa ---~.~ Yq, X E W}

U {(Xpa}a ---+ O(Xq}:pa --~A q, X E W}

U {Op--* pO:p E K~}

U {Xp ~ O(Xp>:X c w, p c K~}

U {(Xp} ~ (Xpa}:X E W, p E KA}

U {<Xp~>O --+ O{Xpr~}:X E W, p C Ka};

q , = ($q~) ;

F. = {<XpR}:p E F.~, X E W}.

B is seen to be 2-1iraited when we take 1B(OB) = l . (a) = 0 for each a E Z~, 1.($) = lB(X) = 1 for each X i n V~ - Z~ , 1B(0) = 2.

Call a B-configuration ~ basic if ~/ = "yo(Xp>O'w with 0"w ~ A , or if = ~0<Xp}0., where if X ~ $ then "Y0 = 0~$~0 ' where ~0 t does not con-

ruin $, and if X = $ then ~0 = 0 ~. To simplify the next definition, let us say of two B-configurations ~,

and 8 tha t ~, t - . 6 by the production a --* ~ if either ~ = ~'ia~2,8 = ~lfl~'~ and 8 is not of the form 8~p, or if ~ /= ~ a , 8 = " / ~ 0 . . (0 . plays no signifi- cant role here; it would be convenient to drop it except tha t then we would have to define a whole new class of au tomata . )

I f 7 is a basic B-configuration write ~, ]--)* 8 if one of the following holds:

(1) 7 t--. 8 by some production (Xp} --~ (Yq>. (2) There exist 80, • • • , 8~ (m _-> 0) such tha t 7 ~- ~ 80 by some pro-

duction (Xp} ---+ (XpR), 8~ ~ B ~i+1 by (Xp~)O ~ O(XpR} for each i < m, and 8~ ~- . 8 by either (XpR}a ----> X(Yq) or by {Xpa)a ~ O(Xq):

A GENERALIZATION OF C O N T E X T - F R E E DETERMINISI~ 223

(3) There exist ~0, "-" , ~ (m _-__ 0) such that ~ ~- ~ ~0 by (Xp) ~ q, ~i t -z ~i+l by 0q --~ q0 for each i < m, and ~ t-B ~ by Yq --~ 0(Yq}.

Note that if ~, is basic and ~ [--~* ~ then ~ is basic. Also, the starting configurations <$q~}w of B are basic except when w = A.

We regard the pairs ~/ ]--~* 8 as pseudoproductions. Each pseudopro- duction corresponds to a production of A, possibly preceded by reading a string of O's as in (2), or followed by reading a string of O's and picking up the last non-0 letter as in (3), or not accompanied by any other operation as in (1).

If ~ is any basic B-config~aration, let ff be the image of ~, under the homomorphisms defined by 0 = ~ = 0s = A, (Xp} = Xp if X ~ $, <Sp> = p.

I t is plain that if ~ I--~* 8 then ~7 I-+x ~. Moreover, it is straightforward to verify by case analysis tha t if ~0 is an A-configuration and ff I - ~ ~o, then there exists a unique ~ such tha t $ = ~o and ~, ]-~B* 6.

Call a b~sic configuration final if it has the form ~o<Xp}0~0, with p E FA. Call a sequence ~ , • • • , ~/~, m > 1, of basic B-configurations such that ~1 = ($q~}w, ~,~ is final, and -~ l--+* ~-1 for each i < m, a pseudocomputation (on w), and for the case m = 1 call ($q~}0, a pseudo- computation (on w).

By Proposition 3.7, complete A-computations end in halts ~,p, and for p C Fx any ~,p is a halt. By this and by what was iust previously noted there must be for each w E ~ * a one-to-one correspondence between complete A-computations on w and pseudocomputations on w.

The pseudocomputations on w are, in turn, in one-to-one corre- spondence with B-computations from q~w to ~, where -~ is a final con- figuration (not necessarily a halt) . This is because B-computations end- ing in final configurations consist (except in the special case ($q~), <$q~>0,) of segments of exactly the type set forth in (1)- (3) above, and, conversely, given a pseudoeomputation there is exactly one way to fill in the gaps, namely according to (1)- (3) , to construct a B-computation.

Finally, every final configuration yields a B-halt in a unique way, namely by application of the production (Xp> --~ (Xpa), followed by re- peated application of <Xpa}0 --+ O(Xpa} until a halt of the form "~(Xpa}O, is obtained. There is nothing else to be done with a final configuration, for A is assumed to have been reduced by Proposition 3.7, whence all final states are right-looking. Conversely, no halt arises in a computation before a final configuration arises.

Thus for each w the complete B-computations on w are in one-to-one

224 HIBBARD

correspondence with the B-computations from q~w to a final configura- tion, and these by the earlier discussion are in one-to-one correspondence with the complete A-computations on w. Therefore A reduces to B.

Our objective has been the following three theorems. THEOREM 1. The family of context-free languages is just the family of

sets accepted by scan limited automata. Proof. Propositions 3.6 and 3.8. T~F,0Rv,~ 2. The family of unambiguous context-free languages is just

the family of sets accepted by unambiguous scan-limited automata. Proof. Propositions 3.6 and 3.8. Remark. In fact we have taken a little extra trouble (in Proposition

3.7) to show that the degree of ambiguity of a language is the same eom- putationally as grammatically. Tha t is, if L can be defined by a (au- tomaton, grammar) having at most n distinct (complete computations, leftmost derivations) for any word, and if n is the smallest possible such number, then L has (computational, grammatical) degree of am- biguity n.

TEEORE~ 3. The language accepted by a deterministic pushdown au- tomaton is 2-deterministic.

Proof. Proposition 3.7. I t seems a safe conjecture tha t Theorem 3 can be strengthened to assert

t h a t pushdown determinism and 2-determinism are the same. We leave this open.

4. THE DETERMINISTIC HIERARCHY

We are going to prove that for every d there are languages tha t are (d -t- 1 )-deterministic without being d-deterministic. This will show tha t the scan-limited automata give us quite a large extension of the push- down deterministic languages, since all of the lat ter are, as we have seen, 2-deterministic.

The main idea of the section can be seen in the language L consisting of all words

a~lbmlc ~I da~2b'~c ~ dx,

where x is either a or b and the following property holds:

x = a implies In1 = ml implies n~ = ms and nl ~ m~ implies ms -- p2];

x = b implies [ml = pl implies n~ = me and ml ~ pl implies m2 = p~].

A GENERALIZ&TION OF CONTEXT-FREE DETER,~_~cIINISM 225

L is certainly deterministic, for it is simple to construct a 4-limited automaton which obeys the flow chart of Fig. 1.

o/

~qt

Reiec I I ccep FIo. 1. Flow c h a r t for the au toma ton ' s recogni t ion of L.

However, L is not 3-deterministic. For no scan-limited automaton can compare, say, nl with ml without losing the ability to compare ml with pl , which means that the automaton must examine the x before begin- ning work on the segment preceding the first d. Similarly, the work on the first segment must be completed before beginning work on the middle segment. This calls for three passages across one of the words a ~2 or b ~2, requiring that segment of tape to contain letters X such that l~(X) >= 3, before comparison begins, and the comparison requires another increase in the value of 1,. Thus 4-determinism is the best we can do.

Using the same principle we can ge~ a language which is 5-deter- ministic without being 4-deterministic: Each word of the language is divided into four segments, and the defining property of the language is such that a deterministic automaton must examine the fourth segment before the first, the first before the third, and the third segment before the second. Indeed, the same principle works for arbitrary d.

226 I-IIBBAI~D

We have only to make the preceding argument precise. I t will now be convenient to think of an A-computation as a n × m

matrix where n is the length of a computation and m + I is the maximal configuration length occurring in the computation. (m is the maximal number of letters in a configuration.) The state and the letter it is "look- ing a t " will together comprise one entry in the matrix. The entries in the matrix will be members of {A} U Va U Va X {p 6 KA:p left-looking} U {p 6 Ka:p right-looking} X Va •

To simplify the discussion we will assume tha t A has no productions of the form p --~ q. The acquisition of this property was discussed in Section 3.2; it is easily seen in tha t discussion that d-determinism is preserved by the transformation.

A matrix M with n rows is intended to be interpreted as a computa- tion ~1, " '" , "/n as follows: If M(i, j ) C V~ then ~ = 8~M(i, j) 82 where l 81 ] = j - 1. I f M ( i , j ) = (p, X) then~, = SlpXS~and I Sl I = J - 1. If M(i, j) = (X, p) then -/, = 81Xp~2 and I 81 ] = j -- 1. If M(i, j) = A then 1 "/~l < J. ~ is the configuration at time i of M. If M has n rows the ~n is the last configuration of M. M is complete if the associated 71, • • • , ~/~ is a complete A-computation.

Such a matrix will be called a computation matrix. Note that if row i is ~I(Xp)Y~2 and Xp "--*a Zq and q is right-looking then row i + 1, if there is one, must be ~IZ(qY)~2.

A (n X m)-computat ion matrix has length n and width m. Let W = {X 6 Va:la(X) = d}. Note that , if ~1~2 6 W and

alpa2 ~-a ~1q~2, then ala2 = ~1~2. If ~ C W* and p 6 K~ call p~ (re- spectively ap) final if pa (respectively ~p) ~-a ~1q~2 where ~1~2 = c~ and ~lq#~ is a halt, such that if ~1 = /~ then q is right-looking, and if #2 = A then q is left-looking.

For two words a and fl in W* call a andfl equivalent if either ~ = # = A or the following four conditions hold for all states p and q of A :

(1) if q is right-looking then pa t - - a aq if and only if pfl ~- A ~q, and c~p F-~ aq if and only if ~p t -a ~q;

(2) if q is left-looking then pa ~ a qa if and only if p# F-a q3, and ap [-a qa if and only if ~p 1-a q~;

(3) pa is final if and only if pfl is final; (4) ap is final if and only if/~p is final.

This is an equivalence relation. I t partitions W* into finitely many equivalence classes, for the equivalence of two words depends only on the finite amount of information asked for in ( 1 ) - (4 ) above.

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 227

We want also to extend this equivalence relation to configurations ~1p~/2 where ~17~ C W*. We say that ~/lp~2 is equivalent to 81p82 if 71 is equivalent to 31 and ~/~ is equivalent to ~2 • There continue to be finitely many equivalence classes under the extended relation.

L e t M be n (n X m)-computat ionmatr ix . For 1 -<_ j _-< k ~ m define the (j, tc)-segment of M at time i to be the word or configuration corre- sponding in the obvious way with M(i, j) , . . . , M(i , k). The (j, k)- segment at t ime 1 is thefirst (j, k)-segment, the (j, k)-segment at time n is the last (j, k)-segment. By the (j, end)-segment we mean the (j, re)- segment. The (j, j ) -segment will also be referred to as the j-square.

If ~, is a word or configuration we define the content of ~, to be ~, if x has no state and to be ~'1"/2 if -y = ~/lp~'2 •

We now want to define the (j, lc)-history and the (j, k)-boundary history of M. The former is a description of the computational work which takes place inside the (j, k)-segments, and the latter is the list of states in which the machine enters and exits the (j, k)-segments. Together they are what is seen by an observer who watches the computat ionbut cannot see anything outside the (j, k)-segment. The border history will be defined only when the state is initially outside the segment; the history will always be defined. Formally:

Suppose the (j, l~)-segment at t ime 1 has no state. Let i~ be the first integer such tha t the (j, k)-segment at t ime il has a state. Given i2~_~, n > 0, let i2~ be the first integer greater than i2~_~, if any, such that the (j, k)-segment at t ime i2~ has no state. Given i2~, n > 0, let i2~+x be the first integer greater than i2., if any, such that the (j, k)-segment at t ime i2~+1 has a state. For each i , let p~ be the state of the configuration a t t ime in of M. The resulting sequence (p l , " '" , pl) is the (j, I~)-border history of M.

The history, unlike the border history, is defined whether or not the first (j,/~)-segment has a state. To define formally the (j, k)-history, let "Yi" denote for each i the (j, k)-segment at t ime i. Let Q, . . . , i~ be as defined in the previous paragraph. If ~ ' has a state let ~ = ~,(. If ~ , has no state and the ( 1 , j - 1)-segment at time i has state p, let ~ -- pT(. If ~ ' has no state and the (k ~ 1, end)-segment at t ime i has state p, let ~ = ~ ' p . The history of the (j , /c)-segment of M is the sequence ~%, ~ + ~ , • • • , ~ : , ~ , , ~,+~, • • • , ~ , • •. , ~ , where if 1 is odd, so that the computation finishes with the state in the (j, k)-segment, then i~ is the number of rows in M (and the history finishes with ~ , ~%+~, • -. , ~(~), and if l is even then h = I.

228 H1BBARD

Thus a history is essentially a sequence of computations, the con- catenation of which is not necessarily a computation but has "jumps" like 7~2, ~3 , which will be, for example, configurations of the form p~l, q~l where p is left-looking and q is right-looking.

PROPOSITION 4.1.1 Let M1 and Ms be computation matrices and suppose that the (jl , end)-border history of M1 is the same as the (3"2, end)-border history of M s . Then there exists a computation matrix M8 with the same (1, j l -- 1)-history as M1 and with (jl , end)-history equal to the (js , end)- history of M s .

Proof. Typical is the case where the first configuration of M1 is p~las where al is the first (1, 3"1 - 1)-segment of M1. If the (3"1, end)-border history of M1 is empty then so is the ( j s , end)-border history of Ms, and we can get the required Ma by appending the unique (is, end)-segment of Ms at the right of each word of the (1, 3"1 - 1)-history of M1 • If the ( j l , end)-history of M1 is not empty then pal ~-~ alq where q is right- looking and is the first state of the (3"1, end)-border history of M1 • Let the first configuration of Ms be ~17s where 7s is the first (is, end)-seg- ment of Ms. Since q is also the first state of the (is, end)-border history of Ms, 71 t--a 71'q for some 7' • qTs I-a rTs' where r is left4ooking and is the next state in the (is, end ) -border history of Ms, hence also in the ( j l , end)-border history of M1. So we have pa17s ~-A fllqTs ~-x ~lr'ys' t-a . . . , and it is obvious that we can continue thus to build the re- quired computation matrix M3.

Let (M)~ denote the matrix consisting of the first i rows of M. Call the (j, k)-segment dead at time i if the content of the (j, /~)-

segment at time i is in W*. Let M~ and Ms be computation matrices. We define M1 to be

( j l , kl:j2, ks )--similar to Ms if the following holds for two integers il and/2 :

The ( j l , kl)-segment of M1 is dead at time i l . The (js, ks ) -segment of Ms is dead at time/2. The (3"1,/~l)-border history of (M1) i~ is the same as the (j2, ks)-border history of (Ms)~. The ( i t , kl)-segment of M1 at time il is equivalent to the (is, ks)-segment of M2 at time is.

The next assertion is that if M1 is ( j l , k l: js , ks)-similar to Ms then the (is, ks) part of Ms can replace in M1 the ( j l , kl) part of M1.

PnOPOSITION 4.2. I f M1 is (jl , kl:js , k~)-similar to Ms then there exists a computation matrix M3 such that the ( j l , jl ~- ks -- js)-segment of M8 at time I is the same as the (j~ , ks)-segment of Ms at time 1, the ( 1,jl -- 1)- and

Essentially, this same lemma was stated and proved informally in (6).

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 229

( j l "~ k2 - j2 -~- 1, end)-histories of M8 are the same respectively as the (1, j l - 1)- and (k~ -~- 1, end)-histories of M~, and such that the last ( j l , j l ~- k2 - j2)-segment of M3 has the same content as the last (j2 , k2)-

segment of M2 . Proof. Let i~ and i2 be as in the preceding definition. Clearly the

( j l , end)-border history of (M1)~1 agrees with the ( js , end)-border history of (Ms)~ • We apply Proposition 4.1 to obtain MR" with the same (1, j l -- 1)-history as (M1)q and with ( j l , end)-histolT equal to the (j2, end)-history of (M2)¢= • By the equivalence of the last ( i i , ix)- segment of (M,)il and the last (i2, js)-segment of (M~.)~2, Ma" can be continued to a matrix Ma' with the same (1, j l -- 1)-history as M1 and with (jl + k2 - js + 1, end)-history the same as the (k2 + 1, end)- history of Ms (with the obvious interpretation if ks happens to be the width of Ms). So the (jl + k2 - js + 1, end)-history of M j is the same as the (k~. + 1, end)-history of M.o. Therefore, for some ia the (jl + k2 -- j~. + 1, end)-border history of (Ma')¢a is the same as the (k2 + 1, end)-border history of (Ms)~= (because the (k + 1, end)-border history of a matrix depends uniquely on the (j, k)-border history of that matrix). Then the (jl + k2 - j2 + 1, end)-border history of (Ma'),a is the same as the (kl + 1, end)-border history of (M1)~1. Applying Prop- osition 4:1, we obtain the matrix Ma ° with the same (1, j l + k2 -- 3"2)- history as (Ma')ia and the same (jl + ks - j2 + 1, end)-history as (M1)~ . The last (j~, jl + ks -- j2)-segment of M ° is equivalent to the last (j~, k~)-segment of (M~) ~ . Therefore the continuation of (I]I1) i~ to M~ provides a continuation of M~ ° to the required matrix M3.

The principal tool which we will use is the finding of numbers jl < j2 < k2 < k~ such that a computation matrLx is (j~, k l : j s , k~) equivalent to itself, and the constructing thereby of a new computation by Proposition 4.2. To find such numbers we will need the following combinatorial lemma, s

LEMMA. Let s = x~ , • • • , x~ be a sequence of n distinct numbers. Then there exists a monotonic subsequence t = x~ , . . . , x~, of s of length k >= ½(1 + log.~(n + 1)) having one of the following two properties:

(1 ) For all g and j such that i~ < g < i~ <= i~ , x~ < x 9 ; (2) For all g and j such that i~ <= ii < g <= i~ , x~ < x~ .

The lemma is related to the well-known combinatorial fact tha t every se- quence of n dis t inct numbers has a monotonic subsequence of length a t least the square root of n. In fact, the lemma could probably be obtained more elegantly as a consequence of tha t theorem.

230 HIBBARD

Remark. Case (1) is where the subsequenee is increasing and Case (2) is where it is decreasing. In either case if the sequence is read in its de- creasing direction it never jumps over members of s which are as large as the most recent t e rm of the subsequence. The kind of sequence asked for can be illustrated as follows, where the vertical placement of the dots depicts the relative sizes of the terms of the sequence. The circled dots depict a subsequence with the desired property, the dots enclosed in squares depict a subsequence which lacks the desired proper ty:

® ®

E3

• •

Proof. We define a nested sequence t o , . . . , t~ of segments of s as follows. ( B y a segment, we mean a subsequence x i , xi+l, xi+2, . . . . )

to---- S.

Given t i , let xhi be the maximal member of t i , let t~ -- uo~xh~uli. I t may be tha t both sequences u0~ and ull are null. I f so we set i = p and we are finished with the definition. Otherwise we define t ~ to be the longer of u0~, u~ (u01 if they have the same length). I f t~ has length Z~ > 1 then ti+~ has length at least - 1). Therefore t~ has length at least n / 2 ~ -- ( 1 -- 1/2i). t~ has only one number; hence

1=>2- ~ -- 1 -

or

2 ~+1 _-> n -b 1.

The sequence xh0, • • • , x% is decreasing, though not necessarily a sub- sequence o f s . Bu t for any i and all g > i, xh~ is in t~+l, which contains only numbers smaller than xhl . Therefore, if there is a monotonic subse -~

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 231

quence of the required length in the sequence of indices h0, .-o , hp, then the lemma will be proved.

Now if hi < h~+l then hl < hg for all g > i, and if h~ > h~+l then hl > h~ for all g > i, because xhl lies either immediately to the left or immediately to the right of t i , from which are chosen all later x ~ . One of the following assertions must hold:

(1) There are at least p/2 values of i f r o m 0 to p - 1 such that h~ < h~+~ ;

(2) There are at least p /2 values of i from 0 to p -- 1 such that h~ > h~+l.

In Case (1) we get an increasing subsequence of h0, . - . , h~:of length k >= p /2 + 1, since the last of the values of i mentioned ir~ (1) also allows the term h~+l to be appended. In Case (2) we get a decreasing subse- quence of length k = p/2 + 1./¢ has the required size.

For a computation matrix M w e define E ~ ( j ) to be the integer, if one exists, such that the content of the j-square at time E ~ ( j ) -- 1 is not in W and the content of the j-square at time E~f(j) is in W; and if no such integer exists we define E ~ ( j ) = 0 when the initial content of the j-square is in W, and otherwise E ~ ( j ) is one greater than the length of M.

PROPOSlTIO~r 4.3. There is a number N, depending only on .4, such that i f M is a (n X m)-eomputation matrix, the first (ml , m2)-segment of M contains no state and no member of W, and the last ( ml , m~ )-segment of M is dead, then there exist jt and j2 , with ml <= jl <= m~ and ml < j2 <_ m2 , such that one of the following assertions holds for some kl , k~ :

(1) £ < j2 <= k2 <= lc~ and M is ( £ , k~:j~, k2)-similar to M; (2) kl <= k2 <= j~ < jl and M is (kl , j~:k2, j2)-similar to M. More-

over, in case (1) either k~ = mOr EM(k~ + 1) > EM(j~) for i = 1, 2; and in case (2) either k~ = 1 or E M ( k ~ - 1) > EM(j~) for i = 1, 2.

Proof. The relation " M is (j~, k~:j2, k2)-similar to M " can be viewed as an equivalence relation on the pairs (j, k ) ; i.e., if M is (j~, kl :j2, k2) and (j~, k2:j~, k~)-similar to M, then M is (3"1, kl:j~, k~)-similar to M, etc. Now let us consider the restriction of this equivalence relation to pairs (j, k) with the:following properties for some i :

( i ) t h e (j,/~)-segment of M is dead at t i m e / . (ii) t he (j, k)-border history of (M)~ has length at most 4 d. The

pairs satisfying (i) and (ii) are partitioned into finitely many equiva- lence classes by the equivalence relation, for the equivalence class of any (j, k) depends only on the :(j, k)-border history, of which there are

232 I-IIBBARD

finitely many satisfying (ii), and the equivalence class of the (j, k)- segment at the time that it is first dead. Let No be the number of such equivalence classes.

The content of each j-square, mi ~ j --< ms, being initially not in W and finally in W, E~(j) > 0 for a l l j between mi and m~. All these E~(j) are distinct. If ms - ml = Z, then according to the 1emma the sequence r a i , . . - ,m2 has a subsequence t = j i , . . . , j~ where u ½(1 + logs (Z -t- 1)) , such that one of the following holds:

(iii) ifj~ ___ y < fi+l then E ( y ) < E(j~+I); (iv) if j , < y _<_ j~+l then E(y) < E(j,).

Suppose (iv) holds. For each x, 1 -<_ x =< u, let k, be, if possible, the first integer greater than j , such that E(k, + 1) > E(j,), and if no such integer exists let k, be the width of M.

Note that k~+~ ->_ k~ for all x. We claim that each of the pairs { (j~, k~) : 1 _-< x =< u} satisfies (i) and

(ii) with respect to i = E(j~). I t is obvious that each (j~, k~)-segment is dead at time E(j~), from the definition of E(j~) and from the fact E(i) < E(j~) forj~ < i _-< k~. At most, 2 d terms of the (j~, k~)-border history of (M)E(i~) can arise from entries and exits at the left of the seg- ment, because E(j~) represents the last live passage of square j~, there are at most d such, and each entry-exit pair requires one live passage of square j~. At the right-hand end of the segment, each exit-entry pair, if k~ < n, calls for one passage of square k~ + 1, but E(k~ -}- 1) _--> E(j~), so that each such passage of square k~ -{- 1 is a live passage. So the (j~, k:~)-border history of (M)E(i~) acquires at most 2 d terms from entries and exits at the right-hand end of the segment. Thus the border history is no longer than 4 d, and (ii) is satisfied.

Now suppose u > No. Then for some two numbers x and y, 1 < x < y ~ u, M is (j~, k~:j~, k~) equivalent to M. But from the lower bound already stated for u, it is clear that we can have u > No if only we take ms -- ml large enough. Thus from (iv) we get conclusion (1).

Conclusion (2) follows from (iii) in similar fashion, provided m2 - ml is large enough.

Now let us define the languages L(d) for each d. These will be like the languages discussed informally at the beginning of the section, but :: will have s o m e additional technical properties to facilitate the proof.

We first define inductively for each d two sets, H~ and F~, of d-tuples of number triples, a s follows:

F1 = { ( n , m , p ) : 0 < n -- m, 0 < p}; Hi = {(n,m,p):O < m = p,O < n}.

A GENERALIZATION OF CONTEXT-FREE DETERMINISM ~33

Given Fd and Hd, let (no, mo, p0), t l , • • • , t~ be a sequence of d + 1 triples.

(1) (no, m0, po), t l , . - . , td is in Fd+l if and only if one of the following holds:

( l a ) 0 < n 0 = m 0 , 0 < p 0 , ~ n d t l , . . . , t ~ i s i n F a . ( l b ) 0 < n 0 < m 0 , 0 < p 0 , a n d t l , . . - , tdis i n H d .

(2) (no, m0, p0), t~, . - . , t~ is in Hg+~ if and only if one of the following holds:

(2a) 0 < n 0 , 0 < po = m o , a n d t ~ , . . . , t d i s i n F ~ ; (2b) 0 < n 0 , 0 < p0 < m 0 , a n d t l , . . . , t d i s i n H a .

To see whether t~, • • • , td is in F~ we begin by looking at the first two numbers in t~ . If they are equal we look at the first two in t2, if the first is less than the second, we look at the second two numbers in t~, and if the second is less than the first then we expel the sequence from Fa immedi- ately. Whichever pair we find ourselves examining in t~, i < d, if the two are equal we look at the first two numbers in t~+~, if the two are unequal in the correct sense we look at the second two numbers in t~+~, and if the two are unequal in the wrong sense we reject the sequence. Whichever pair we thus find ourselves examining in t~, we admit the sequence to F~ just in case the two are equal.

The language L(d) will be an expression of the set Fd in the following way. Each triple t~ = (n~, mi , p~} is represented for odd i by a word a"~b~c ~ and for even i by a word c~bm~a "~ ; these words are separated by 0's and concatenated in the order

Tha t is, let

2, 4, 6, . . . , 5, 3, 1.

W2i+l = a~ibm~cWO, 0 < i < d/2,

W ~ = c~'%'~a~O, 0 ~ i <= d/2.

Then, letting e be the greatest even number ~ d, and f the greatest odd number <d , let

W ~ W 2 W 4 " ' " W e W f " ' " W 3 W l

be the word which represents t l , • • • , td. L ( d ) is then the set of all words w which thus represent some

t l , ' " , t d E F d . For example, L3 is the set of all words cP2bm~an~Oa~3bmcP~Oa~'b'~LcPlO

having one of the properties

234 HIBBARD

nl = ml , n2 = m2, n3 = m3 ;

n l = m ~ , n2 ~ m 2 ~ m3 = P3 ;

n l ~ m l , p2 ~ m 2 , n3 - m 3 ;

n~ < m~, p2 < m2, m3 = p3.

Given a candidate w for membership in L(d) , the symbol w~ will with- out explicit mention refer to the form w = w2w~ . . . w~wf • ". w3wi , as above.

I t is not hard to see tha t L ( d ) is (d - t - 1)-deterministic. The following informal algorithm can, in a straightforward way, be converted into a scan limited automaton:

Beginning at the left, pass (d - 1)0's and thence continue r ight to the first b: M a r k al ternate a 's and b's un t i l it is determined whether the number of a 's is or is not the same as the number of b's. Move left past (d - 1)0 's and compare the number of a 's with the number of b's or the number of b's with the number o f c's, depending on how the first com- parison Came out. Move to the right past (d -- 2)0 's and compare either the a 's with the b's (if the second comparison showed equali ty) or the b's with the c's (if the second comparison showed the proper inequali ty) . Move le f t past (d - 3)0's and make another comparison, and so on, until the comparison is being made in w~ . , I f t ha t last comparison results in an equality, accept the word; otherwise reject it.

We will now show tha t L ( d ) is not d-deterministic. I f i is odd and wl = a"~b'~c~O, or if i is even and wl = cP~b~an~O, let

t (w~) = (n~ , m i , p~). Let us say tha t wl switches left in w if t ( w l ) = (n, n, p) for some n, p,

and tha t w~ switches right in w i f t (w~) = (n , n + i, p ) with i > 0. Con- tinuing inductively, let us say for ~1 < i =< d, with t ( w i ) = (n , m, p ) , tha t w~ switches left in w if either:w~_l switches left in w and n = m or w~-i switches right in w and m = p, and tha t w~ switches right in w if either w~_~ switches left in w and n < m or w~_~ switches right in w and p < m.

Notice tha t w is in L ( d ) just in ease w~ switches left in w. Now let us suppose, of our deterministic d-limited au tomaton A, tha t

L ( A ) = L ( d ) . Let M be the matr ix Of a Complete A-computat ion on w where w~ = a~b%'O for each i , n being the same for each i .

Let f~ and g~ be the bounds of w~, let j i and k~ be the bounds of the string of b's in w~.

We Wan~ first to show that , if we choose n large enough, then Propo-

A GENERALIZATION OF CONTEXT-FREE DETERMINISM 235

sition 4.3 will be applicable to some subsegment of each (j~, k~)-segment. Let No be the number of border histories of length at most 2 d. If there are more than No numbers j, j~ =< j N ]¢~, such that the last j-square of M is not dead, then, since each corresponding (j, end ) -segment has a border history of length at most 2 d, two of them, say j' and j" , have identical border histories. Now by applying Proposition 4.1 we can delete the (j' + 1, j " )-segment, tha t is, construct a computation M' with (1, j ' ) -history the same as M and with (j ' ~- 1, end)-history the same as the (j" -b 1, end)-history of M. M' will be a complete computa- tion because every entry into the (j', j " - 1)-segment must be accom- panied by an exit from that segment in order to obtain the identical border histories, hence the machine cannot halt inside the segment.

! .

But M is a computation on a word with fewer b's than either a's or c's in the i th segment, and no such word is in L(d).

Therefore, there are at most No numbers j , j~ < j < k~, such that the last (j, j)-segment of M is not dead. So if n > N(No ~- 1), where N is the number defined in Proposition 4.3, each (j~, k~)-segment contains a subsegment ( j( , k() of length at least N such that the last (j{, k{)-seg- ment of M is dead. Applying Proposition 4.3 to each ( S , k / ) -segment we obtain j~l, j~2, hi1, k~ satisfying either (1) or (2) of Proposition 4.3. In fact, for odd i (2) holds, for suppose (1) held for some odd i: Then we could not have g~ < k~l, because Proposition 4.2 would give us another complete computation on a word w' with w( = a'bn-%~0 for some posi- tive x, but no such word is in L(d). We could not have k~l < gil < k~2, for then application of Proposition 4.2 would delete a 0 and thus provide a complete computation on a word containing at most d - 1 O's, whereas L(d) has no such words. Therefore /~ < k~ < g~. This means that ap- plication of Proposition 4.2 gives a complete computation on

! t ! ! t ! ! g w -- w2w4 " ' 'Wd "''W~W~ where w, = w, for t ~ i and w~ = a~b~-%~-~O, where x > 0 becausejll < ji~. Then i > 1 since w ! C L(d).

t

But w~_~ switches left in w ~. This means that a~b ~-~ is the relevant sub- word of w~, but that again excludes w' from L(d).

Therefore (2) holds for each odd i. Moreover, by considerations similar to the preceding, that is by applying Proposition 4.2 to obtain an initial word with fewer occurrences of b than a in w(, or too few occurrences of 0, we can also establish that f~. < /~ < j~ and f l =< /~2 < k~.

The situation with even i is symmetric to the preceding, and the s~me argument shows that (1) holds, tha t k~ < kll < gl, and thatj~ < k~2 =< g~.

To summarize:

236 HIBBARD

For odd i we have fi <= k~l <= k~2 <-_ if2 "< j~l , j~ <-_ j~2 < j~l <-_ ki , f~ _-< k~l< j~ ,f~ ~ k~ =< k~, and M is (kil , j~l:k~2, j~2)-similar to M.

For even i we have (symmetrically) j;~ < if2 < k~: =< k~l =< g~:, j~ =< jll < j~2 < ki , k~ </c~1< g~ ,j~ < k~2 -< g~, a n d M is (j~l, k~1:j~2, k~2)- similar to M.

For S <= J <= k(, E( j ) > O, for square j contains b initially and a member of W finally. For simplicity, denote EM(j) by E(j) . Let us show that E(j~I), . . . , E( jdl) is an increasing sequence. Suppose; to the con- trary, that i < d and E(j(~_~)~) <= E(j,1).

Take first the case where i is odd. Then gi+l < f~, i.e., the ( i q- 1)th segment is entirely to the left of the i th segment. Now from the (k~l, jil:k~:, j~2) similarity of M to M, we clearly have that the (j~ + 1, end ) -border history of (M)~(~,) is the same as the (ji2 + 1, end)-border history of (M)E(j~) • This is because for any j, ~ the (j, ~)- border history uniquely specifies the (/~ -t- 1, end)-border history. By Proposition 4.1, letting 7 be the (j~ ~ 1, end)-segment of (M)~(j~2) at time 1, there exists a computation matrix M~ with (j~ W 1, end)-segment

at time 1, such that the ( 1, j~)-history of M~ is the same as the ( 1, j~1)- history of ( M ) , ( ~ ) , and such that the (j~l -t- 1, end)-history of M~ is the same a s t h e ( j~ ~- 1, end)-history of ( M ) . ( ~ ) . Now M~ is a computa-

! P f t i o n o n a w o r d w ' = w~ . . - w ~ . . . w ~ ' w h e r e w ~ = w ~ f o r h ~ l a n d w( = a'~b~+~c~O where z is positive, w' ~ L( d) and A is deterministic, so MI = (M')~ for some z and some complete computation matrix M'. Because E(j~I) ~ E(j(~+I)~)andE(j(~+m) > E(k) for j ( ~ m > k => k(~+~)~, the (k(~+m , j(~+l)l)-segment of M is dead at time E(j~.~). Therefore ( M ) .(j.~ ~) is ( k ( ~ m , J(~+m:/c(~+m, j(~+l):)-similar to itself. Therefore Mi , and therefore M', is (/c(~+m, j(~+m:]c(~_~)~, j(~+m)-similar to itself. But then by applying Proposition 4.3 to M' we can obtain a complete compu-

Y f! Y . . , W l t t ! t t a t i o n o n w = w= . . . w ~ • wherewj = w J i f j ~ i q - l a n d W~+l = c~bn-~a~-~O where y > 0. Here we use clauses (iii) and (iv) of the definition of equivalence in order to make sure that the new compu- tation is indeed complete. Now w~" switches right in w" since w~" has more b's than a's and all earlier w7 switch left. But w~+l has fewer b's than c's, and this would disqualify the word from membership in L(d).

This is a contradiction, so it must be that E(j~) < E(j(~+m) for odd i. The case of even i is essentially the same; indeed, this is the reason for

requiring the w~ for even i to be in the form c~'b'~a'~O instead of the form a'bmc~O.

Therefore, for all i we have E(ji~) < E(j(~I)~ ) From this we easily conclude that if d is even and k~ ~ j -< g~, or if

A G E N E R A L I Z A T I O N OF C O N T E X T - F R E E D E T E R N I I N I S M 237

d is odd andfd < j < je (i.e., j is in the a ne segment), then the content x of the j-square at time E(jdl) issuch that lx(x) > d.

Now we use the last part of the conclusion of Proposition 4.3. If d is even, whence (2) holds with respect to jel , je2, kd~, kdl, we cannot have ka~ be the width of the matrix for we have already established led1 < gd • Hence E(ke~ 4- 1) > E(jd~). I t follows that if x is the content of square kdl + 1 at time E(jdl) and y is the content of square kea + 1 at time E(kdl + 1), then l~(y) > 1.~(x). lx(x) >= d, hence lx(y) >=_ d 4- 1.

The situation for odd d is exactly similar. Hence A is not d-deterministic. We have thus proved the following. THEOREM 4. For every d > 2 there are languages which are d-deter-

ministic and not ( d - 1)-deterministic; i.e., the deterministic hierarchy does not terminate.

5. LINES OF FURTHER INVESTIGATION

The language L = {wwR:w C 2*} has the intuitive property of in- herent determinism discussed in Section 1, for we can think of jumping from one end of the word to the other without processing the information in between. But this language is not obtainable with a deterministic scan limited automaton. However, if we think of a machine's tape as forming a loop, and construct the corresponding abstract computer, L becomes deterministic. I t only remains to work out the details of the proof, which can be built upon some of the proofs in Section 3.

But consider the language

L' = (J (L~c)~d(L~c) ~ U ( [.] (L2c)~d(L2c)~), ~>0 n>0

where L~ and L2 are distinct deterministic languages over {a, b} *. L' is not necessarily deterministic in the sense of scan limited automata for essentially the same reason that {a~b~:n > 0} [J {a%2~:n > 0} is not. In case L1 and L2 are regular, e.g., LI = {a}, L2 = {b}, then L' is deter- ministic. In general, though, the determination of whether L1 or L~ is present precludes the comparison of the exponents, and vice versa. Yet it seems that L ~ ought to be deterministic.

I t is possible, of course, to construct arrays of scan limited automata, hedge them around with various artificial restrictions, and thus obtain languages such as L' deterministically. The problem, though, is to get them with some natural class of computers.

RECEIVED: January 6, 1967

238 HIBBARD

I~:EFERENCES

1. CHOMSKY, N. Context free grammars and pushdown storage. Quarterly Prog- ress Report No. 65, Research Laboratory of Electronics, MIT, 1962.

2. GINSBURS, S. "The Mathematical Theory of Context Free Languages." Mc- Graw-Hill, New York, 1966.

3. GINSBU~G, S. ~NI) G~EIB~C~, S. A. Deterministic context free languages. SDC Document No. TNI-738/014/00, 1965. (To appear in Information and Control, 1967.)

~. GINS~URG, S..~ND Ros~, G. Operations which preserve definability in lan- guages. J. Assoc. Computing Machinery 10 (1965), 175-195.

5. GREIBAC~, S. A. Inverses of phrase structure generators. Report No. NSF-11, Mathematical Linguistics and Automatic Translation, to the National Science Foundation, the Computation Laboratory, Harvard University, 1963.

6. H~NN~, F. C. One-tape, off-line Turing machine computations. Infor. Control 8 (1965), 553-578.

7. RABIN, M. O. AND SCOTS, D. Finite automata and their decision problems. IBM J. Res. Develop. 8 (1959), 114-125.