The Pebble Game and Logics of Programs

13
HARVEY FRIEDMAN’S RESEARCH ON THE FOUNDATIONS OF MATHEMATICS, L.A. Harrington et al. (editors) 0 Elsevier Science Publishers B.V. (North-Holland), 1985 317 THE PEBBLE GAME AND LOGICS OF PROGRAMS A.J. Kfoury Department of Computer Science Boston University Boston, Massachusetts, U .S .A. 02215 1. Introduction This paper is a computer scientist’s commentary on just, a small part of Friedman’s article entitled “Algorithmic procedures, grneralized Turing algorithms, and elementary recursion theory.” The pebblr game is a basic technique in theoretical computer science. , It has been particularly successful in studies that compare time and space requirements of computa- tions. Thus. by far the most numerous applications of thr pebble game have been in the area of time-space tradeoffs. In recent years, however, there have also been important applications in the areas of comparative schematology, logics of programs, code generation and optimization, among others. Harvey Frirdnian did not write an articlc on the pebble game as such, nor did he use the expression himself. He was nevertheless one of its originators in his article mentioned above. The two other people who independent,ly invented the pebble game, approximately a year later, are Michael Paterson and Carl Hewitt [1970]. (Friedman’s article appeared in the proceedings of the Logic Colloqiiium held at Manchester in August 1969; Paterson’s and Hewitt’s original report was dated November 1970.) Until a few years ago, computer scient,istsgeilerally acknowledged Paterson’s and Hewitt’s contribution but not Friedman’s. Thus. for rxample, in survey art,icles on the pebble game by a foremost, expert, credit is given to Paterson and Hewit,t while Friedman is not ment,ioned (Pippenger (1980,19821). M’ithout, dwelling too much on this history, there are at least two reasons for the fact that Friedman’s early contribution was ignored until recent years. First, Paterson and Hewitt talked to computer scientists and worked among them, while Friedman primarily addressed himself to an audience of logicians (and his article was thus published in the proceedings of a Logic Colloquium which are seldom looked at by computer scientists). Second, Friedman buried his version of what is now called pebbling (or the pebble game) in a long and highly technical investigation. In fact, Friedman stressed other ideas in the article, such as the concept of an “effective definitional scheme” which also proved to be important in logics of programs many years later (Tiuryn [1981a,1981b]). There was more than one (missed) opportunity in the 1970’s to give Friedman’s ar- ticle the full attention it deserved. Friedman’s ideas and results were reorganized, and compared with similar work by computer scientists, in a comprehensive study by Shep- herdson [1975], which unfortunately seemed to escape the attention of computer scientists

Transcript of The Pebble Game and Logics of Programs

HARVEY FRIEDMAN’S RESEARCH ON THE FOUNDATIONS OF MATHEMATICS, L.A. Harrington et al. (editors) 0 Elsevier Science Publishers B.V. (North-Holland), 1985 317

THE PEBBLE GAME AND LOGICS OF PROGRAMS A.J. Kfoury

Department of Computer Science Boston University

Boston, Massachusetts, U .S .A. 02215

1. Introduction

This paper is a computer scientist’s commentary on just, a small part of Friedman’s article entitled “Algorithmic procedures, grneralized Turing algorithms, and elementary recursion theory.”

The pebblr game is a basic technique in theoretical computer science. , It has been particularly successful in studies that compare time and space requirements of computa- tions. Thus. by far the most numerous applications of thr pebble game have been in the area of time-space tradeoffs. In recent years, however, there have also been important applications in the areas of comparative schematology, logics of programs, code generation and optimization, among others.

Harvey Frirdnian did not write an articlc on the pebble game as such, nor did he use the expression himself. He was nevertheless one of its originators in his article mentioned above.

The two other people who independent,ly invented the pebble game, approximately a year later, are Michael Paterson and Carl Hewitt [1970]. (Friedman’s article appeared in the proceedings of the Logic Colloqiiium held at Manchester in August 1969; Paterson’s and Hewitt’s original report was dated November 1970.) Until a few years ago, computer scient,ists geilerally acknowledged Paterson’s and Hewitt’s contribution but not Friedman’s. Thus. for rxample, in survey art,icles on the pebble game by a foremost, expert, credit is given to Paterson and Hewit,t while Friedman is not ment,ioned (Pippenger (1980,19821).

M’ithout, dwelling too much on this history, there are at least two reasons for the fact that Friedman’s early contribution was ignored until recent years. First, Paterson and Hewitt talked to computer scientists and worked among them, while Friedman primarily addressed himself to an audience of logicians (and his article was thus published in the proceedings of a Logic Colloquium which are seldom looked at by computer scientists). Second, Friedman buried his version of what is now called pebbling (or the pebble game) in a long and highly technical investigation. In fact, Friedman stressed other ideas in the article, such as the concept of an “effective definitional scheme” which also proved to be important in logics of programs many years later (Tiuryn [1981a,1981b]).

There was more than one (missed) opportunity in the 1970’s to give Friedman’s ar- ticle the full attention it deserved. Friedman’s ideas and results were reorganized, and compared with similar work by computer scientists, in a comprehensive study by Shep- herdson [1975], which unfortunately seemed to escape the attention of computer scientists

318 A.J. KFOURY

because it, appeared in the proceedings of anot hvr Logic Colloquium! Another paper with a definite logical flavor, by another logician (.4hra1nson [1978]). was also based on some of Friedman’s ideas, in particular what we now call the pebble game, and some of the work on program schemes at the time. Abramson developed techniques that were later used iii logics of programs, but he considered a problem ( “int.erpolation questions for program schemes”) which was then of limit,ed interest. As a result, Abranison’s paper seemed to find no audience among computer scientists at the time, even though it appeared in a computer science journal.

It is perhaps in the 1980’s that comput,er scientists have given Friedman his due. Ef- fective definitional schemes, which we now sometimes call “Friedman schemes”, are a very convenient tool in logics of programs (see for example the articles by Tiuryn [1981a,1981b], Meyer and Tiuryn [1982], Urzyczyn [1981a], Kfoury [1983], Crasemann and Langmaack [1983]). Once we started using “Friedman schemes”, we also disroveed in the same arti- cle that Friedman knew how to apply the pebble game to compare t,he expressive powers of programming formalisms, which we have siibsequently used in our logical analysis of programs (Kfoury and Vrzyczyn [1985]. Tiuryn [1981r], Urzyczyn [1981b]).

For the many coiincct ions between Friedman’s ideas, in particular effect,ive definitional schcines. and the c-arlier theory of program schemes in the 1970’s (extended by various logics of program5 in the 198O’s), the reader is referred to Shepherdson’s contribution t,o t,his voluiiic~. For a history of the pcbble game and it,s generalizations in relation to t,iiiie-spacr tradeoff results, the reader is referred to Pippenger [1980,1982].

2. Friedmen’s Original Formulatioii of the Pehhlr Game

Friedman’s original formulation was somewhat different from Pat,erson’s and Hewitt’s original formulation-and neither one was expressed in terms of pebbles and pebbling. (The words “pebbles” and “pebbling” were first, used by Hopcroft, Paul, and Valiant 119751.) Friedman’s formulation appeared more algebraic, while Paterson’s and Hewitt’s was in terms of graphs, which made the latter closer to the current formulation of the pebble game. Both were devised however to pr0X.e essentially t,he same result, namely, that progranis with unbounded memory are more powerful than programs with bounded

In what follows we identify definitions and resulk taken from Friedman’s article. We have reorganized the material and introduced a few simplifications here and there, which do not change the essence of Friedman’s analysis.

memory. I

2 .1 Definition (Friedman Definition 1.8). A vector of n 2 1 variables is denoted z = (XI,. . . , zn) A finite set of function symbols, each ofarity 2 0. is denoted 3 = {Fl,. . . , Fr}. (3 will later correspond to the similarity type of a structure without, for the sake of simplicity, underlying relations.) The pair (z, 3) is called a definitional type and denoted a . The a-terms are defined inductively by:

* Of course, Friedman’s contributions to theoretical computer science are not limited to things related to effective definitional schemes and the pebble game. There is in particular his remarkable work with Ker-I KO on the computational complexity of real functions. More recently, he was invited to be on the Advisory Board of Information and Control, a leading journal in theoretical computer science.

The Pebble Game and Logics of Programs 319

(1) each variable r t , 1 5 1 5 7 1 IS ,111 (1 t m i i .

(2) if t l , . . , t , are a-terms and F E 3 is of arity J 2 0. then F ( f l . . . , t l ) is an n-term.

The a-ternis are the terms built up from the variables r and the function symbols 3.

2 .2 Definition (Friedman, Definition 1.20 and 1.23). For every p > 0, the p - a-terms a r t dcsfined as a suhsr~t of the a-trrms according to t,he following. A p - a-sequence is a sqiience of finite length y > 0, drnoted C, , C,. . . . . C, such t,hat,

(1) each C, is a vector of Icngth p whose vntries are in {a - terms } u {*},

(2) every entry of (1, is *. (3) every C2+l differs from C, in exartly O:IC place - and, in this place, the ent,ry of C, and that of C,+l are not both a-t.ernis (i.e.. one of the two is a * 1, (4 ) if the place where C, , F ( / I . . . . . l k ) for some k 2 1. t,lien each 1, is an entry of C,.

differs from C, is assigned an u-term of the form

A 11 - o-trrm i5 i i n tr-trrrii which is an entry of some C, in some p - a-sequence.

Thus. a p -- ft-tcmii I is an tr-term that, can be built up from 5 and 7 such that, at any i n t r r m ~ d i a r ~ i)oiiit. at niost p subternis of / are “remembered”. The fact, that, the p - tr-trrnis f o r 2 1 tixed p are generally a proper subset of the a-terms is established by means of the p t )b i r gamc..

The only thing missing from Definition 2.2 to put it in the current nomenclature of the pebble game, is thc, association of terms with their representations as dag’s (directed acyclic graphs). With this association the preceding definition becomes the definition of finite dags whose “space requirement” (defined belowI is p . For example, if a = ( ( z ) , { F , G } ) where F is unary and G binary, then the a-terni

1 = G[G[r. F(.r)i . ( ; I F ( F ( z ) ) , F ( F ( F ( r ) ) ) ] ]

is reprrsented by the following labelled dag.

320 A.J. KFOURY

A node in a dag with in-degree = 0 (1 .c. . withont prrdecessor nodes) is called an input; a node with out-degree = 0 is called an output . Clearly, an arbitrary finite dag with exactly one output is the dag of an cu-term for home a. where node labels are omitted and the order of edges into a node is ignored.

2.3 Definit ion. The pebble game is a one-person game played on a finite dag D. At any point in the game some nodes of D will have pebbles on them (one pebble per node), while the remaining nodes will not. A configuration is a subset of the nodes comprising just those nodes that have pebbles on them. A move in the game consists in placing a pebble on a node, or removing a pebble from a node, according to the following rules:

(1) if all the immediate predecessors of a node have pebbles on them, then a pebble may be placed on that node,

(2) a pebble may be removed from any node.

A legal move is represenkd by an ordered pair of configurations, the second of which follows from the first according to (1) or (2) . Since an input has no immediate predeces- sors, a pebble may be placed on any input. ,4 rulculation is a sequence of configurations C , . C2 , . . . . C,, such that

(1) r , = 8.

(2) each pair (CZ,C,+,) is a legal movr

a calculation is complete when every output of D appears in some configuration Ci, i.e., has a pebble on it at some point. Intuitively, placing a pebble on a node corresponds to performing an operation and storing the result in a memory location, while removing a pebble from a node corresponds to freeing a memory location so that it can be re-used to store another value.*

There are two measures associated with a complete ralculation on a dag D: time (num- ber of moves) and space (maximum number of nodes in any ronfiguration, i.e., maximum number of pebbles on the dag at any point). We can talk accordingly about the time and space requirements of D. For the dag of the term t (see figure above), the time requirement is 7 (using 7 pebbles) and the space requirements 1 (making at least 10 moves).

* What we have given here is one version of the pebble game, which corresponds to Definition 2.2 above. There is another version which allows the removal and placement of a pebble in a single move. In particular, the latter allows the additional rule that if all the immediate predecessors of a node have pebbles on them, then one of these pebbles may be moved onto that node. This rule mimics more directly assignment instructions in high-level programming languages, which may store their result in one of the same memory locations that hold their arguments. (Think. for example, of the instruction X := X + Y.)

There are also several generalizations of the pebble game, in either one of the two versions above, which have been introduced for various applications in computer science. Such are, for example, the “black- and-white pebble game”, the “pebble game with aux- iliary pushdown stores”, the “edging game”. and the “parallel pebble game” (Pippenger [1981,1982], Kozen 119841, and Savage and Vitter 119841, respectively.)

The Pebble Game and Logics of Programs 32 1

Thca connection bet,we.cn Definition 2.2 and the pebble game is now plain. a-term f is a p - a-term iff the space requircnient of t,hc dag representing 1 is at most p . Put differently, a p - cy-t,erm is an a-term whose evaluat,ion requires at most p memory locations (Friedman, Lenmia 1.6.1) .

2.4 Lemma (Friedman, Lemma 1.3.1). Let 7 be any set of function symbols containing at least one symbol of arity 2 2. Then for every p there is an a-term 1 which is not a p - tr-term.

Proof. The idea here is to construct a family of terms { t n } such that, (1) the dag represent- ing 1 , is a full binary tree of arbitrary height n, and (2) there are no repeating subterms in t,', i.e. any t,wo nodes in the dag representing 1 , are labelled with distinct subterms. Since a full binary tree of height n 2 1 has space requirement n + 2 (easily proved by induction on n ) , the result fol1ows.t

With no loss of generality, let, a = ( ( r ) , { G } ) where G is a binary function symbol. First. define a-terms { u n } inductively, by setting u1 = I and zl,+l = G(u , ,u , ) . Sec- ond, tfefine the a-terms tl(ul,uz), t2(u1,u2,u3,u4),. . . , t n ( u l , . . . , u p ) , . . . inductively, by setting

t , (u1, uz) = G(Ul1 U'Z),

f n + l ( u 1 > . . . , u z z n ) = G ( t n ( u l , . . , % U P ) , t , (uzn+l , . . , , ~ Z Z " ) ) .

The dag represent,ing t , is obtained from a full binary tree by replacing the leaves with 21, j . . . , u p and therefore contains no repeating siibterm. I

Thc IcmIna fails for t,he case when all symliols in 3 are of arity 5 1. In this case, thc dag representing an a-term has a single node or is a linear chain, so that the space requirement is 1 or 2.

An effective definitional scheme (eda for short) of type a = (x, 3) is a recursively enumerable sequence of clauses, each of the form

C - - 1

where t is an a-term and C is a finite conjunction E,&Ez& . . . &Ek, where each E3 is u = v or u # u for some a-terms u , u . (Friedman, Definitions 1.10. 1.13) .

The interpretation of an eds (C , --+ t,li 6 w ) in a structure A , with universe A and similarity type 7, defines a partial function f : A" + A whose value at a E A" is

where i E w is the smallest index for which A I= C,[a], otherwise,

{ t $ ( 4 f(a) = undejz ned ,

where t! is the interpretation o f t , in A.

It turns out that eds's are another way of looking a t certain programming languages. For example, for every eds there is an equivalent flowchart scheme augmented with a

t The proof in Friedman's article has a bug: he ronstructs a family of terms {tn} which satisfies ( l ) , but not (2) . As a result, the dag representing t , is no longer a full binary tree when nodes labelled with identical subterms are merged. After this merging of nodes, the dag representing 1 , has space requirement 5 4 (independent of n ).

322 A.J. KFOURY

pusli-do\vn stack and counters and vicc.-vcrsa. (Two program schemes arc equivalent if they define the same partial function over rvery structure in wliich they are interpreted.) Further connect,ions between eds’s and programming languages are discussed in Shepherd- son’s article in this volume.

Flowchart schemes are an exaniple of a programming language which does not allow it,s individual members t o each access more than a bounded number of memory locations. “Flowchart scheme’’ (or. equivalent,ly. “while-program scheme”) is the name given by comput,er scientists to what Friedman calls a “formalized algorit,hmic procedure” ( / u p for short). Augmenting a flowchart schenie wih a push-down st,ack is one way of allowing it access to unbounded storage space. Count,ers, on t,he other hand. do not add to the storage space accessible by a flowchart scheme; counters can hold integers, but not elements from the universe of whatever structure the scheme is interpreted in.

The following t,heorem is one way of stating that programs that can access unbounded storage space are more powerful than those that cannot.

2.5 Theorem (Friedman, Theorem 1 .3 ) . There is a flowchart scheme, augmented with a pusli-ciou.11 st,ack and counters, which is not equivalent to any flowchart scheme augmented with counters only.

(In Friedman’s terminology, there is an eds which is not equivalent, to any fap with roiiutrm.)

Proof: Lrt (1 = ((z. y ) . { C } ) where G is a binary furirtion symbol. Denote by (t t(z)1i E w ) thc set of n-terms not roritaining y> recursively enunicratctl i n some fixed order. The drsircd eds S of typc n is

(y = t , ( z ) 4 zji E w).

A struct,ure A , over which S defines a partial function not programmable in the absence of unbounded storage space, is the following. The similarity type of A is { G } , and for every a , b , c , d E A:

G A ( a , a ) # a and

( a , b ) # ( c ; d ) implies G A ( a , b ) # GA(c ,d ) .

These two conditions guaranke the existence of an infinite chain a , , az, u3, . . . such that G A ( a z , a z ) = a Z i l and any 2” clements in this chain are the base of a full binary tree of height n. The argument, of Lemma 2.4 shows that to generate all the elements from any a E A , an unbounded number of Inerrlory locations is required. The partial function j : A x A - A defined by ,S when interpreted in A is:

if b is generated by a, = { t i d e j i n e d , otherwise.

No program scheme restricted to bounded storage space, in particular no flowchart scheme with counters, will compute when interpreted in A-because no such program scheme can check whether b is generated by a, for all a , b E A . I

The proof technique of Theorem 2.5 is general. It can be used again to compare any two programming formalisms, one that allows each of its programs unbounded storage space and one that does not-and as long as their type contains at least one function symbol of arity 2 2. Thus, Paterson and Hewitt (19701 used the technique to show that flowchart

The Pebble Game and Logics of Programs 323

schemes with recursive calls are more powwfiil than flowchart, schmics. (Recursiw calls can b r simulated by push-dowristacks. and vice-versa, they are therefore a way of accessing unbounded storagp space.)

In t,he case when all function symbols are of arit,y 5 1, the pebble game or any of its generalizations cannot be used to establish such results. Access t,o unbounded storage may or may not add to t,he power of programs in this case. Here arc some of the results when all function symbols arr of arit,y 5 1.

(1) Every flowchart scheme augment,ed with a push-down stack and coun- t,ers is equivalent t,o a flowchart scheme augmented with counters only (an imnicdiate ronsequence of Friednian. Theorem 1.6).

(2) There is a flowchart scheme augmented with a push-down stack which is not equivalent, to any flowchart scheme, provided there are at least two function symbols of arity = 1 (this follows from the main result, in Berman, Halpern. and Tiuryn [1982], or in Urzyczyn (19831, or in Stolboushkin and Taitsliri [1983]. and Section 2 in Kfoury and [Jrzyczyn [1985]).

Wr do not know whether (2 ) still holds when there is exactly one function symbol which is of arity = I : in fact if it does, it will sett,le a fiindamc,ntal open problem of complexity theory. nanicly, DSPACE (n) # U DTIME ( c “ ) ; and if (2) holds when there is exactly one function symbol of arity = 1 and one or more relation syinhols of positive arit,y, it will set,t,le another open problem of coiriplexit,y theory. DSPACE (log 11) # PTIME (Tiuryn and IJrzyczyn [1983].

3. Some Applications of the Pebble Game to Logics of Programs

A logic of programs is a formal language for reasoning about program properties. As such. it combines an “assertion formalism” and a “programming formalism” in a single language. There are many different logics of programs, depending on the possible choices for the assertion part, the programming part, and the way the two are combined.

For the sake of uniformity, our presentatlion is based on a specific logic of programs, first-order dynamic logic (Hare1 [1979]). The results below remain t,rue for other logics programs, such as algorithmic logic (Engeler [1975], Salwicki [1970]) and logic of effective definitions (Tiuryn [1981a,1981b]). Our present,ation is rather-cursory; all missing details can be found in the references, along with relevant discussions and generalizations.

Our version of first-order dynamic logic fixes the assertion part and the way it is combined with the programming part of the logic, but allows the latter to vary. If P is a programming language, i.e.. a class of program schenies satisfying some closure properties, let us denote by DL(P) the corresponding first-order dynamic logic.

3.1 The Syntax of Dynamic Logic. Let P be a specific, but otherwise arbitrary programming formalism. Briefly, DL( P ) is conventional first-order logic to which we add a construct (S)4 with the meaning that there is an execution of program S E P after which the assertion 4 holds. Hence, the symbols of DL(P) are the usual symbols of first-order logic (including function symbols, predicate symbols, and equality) in addition to the pair of symbols ( ) (pronounced “diamond”) and the symbols of the programming formalism

324 A.J. KFOURY

P. There is another pair ofsyiribols [ ] (pronoi~nrtd “box”) whirh are srrict,ly speaking not in the language), but which serve t,o ahbrcviate formulas. I ] is an abbreviation for i() 7

just as V is an abbreviation for 7 3 7 .

Terms and atomic formulas are formed exactly as in first-order logic. Formulas are also formed exactly as in first,-order logic except that ($) niay he used in place of 3, where S is any program in P . The formulas of DL(P) may thus he defined as follows:

(1) any atornir formula is a forniula:

(2) for any formulas r#I and $J, -4 and (4 V l i t ) are formulas;

(3) for any formula 4 and variable I, 3 x 4 is a formula;

(4 ) for any formula 4 and program S E P , (S)4 is a formula.

What we have called programs in this definition are strictly speaking program schemes, because they rontain uninterpreted function aiid predirate symbols.

3.2 Adjus tment , . One possible choice for P is the rlass of eds’s. But now, to properly definc t,he semantics of DL(P), wc h a w to spvcIfy for rvery eds the variable (or variables) from which output, values are ret,rievrd. To k w p notational details to a minimum, and with no loss of generality, t,he input variables x of ail ed.i of type (1 = (x, 7) will also be its out,put variables; that, is, clauses will henceforth br of thv form C(x) --+ x := I t (x) where t!(x) is a vrrtor of n a- te rm-or , niorc’ simply. wc’ shall Lvritr (.‘(x) - t t ( x ) with our new convent ion iniplicit in the not,ation.

The same adjustment is made for other classes of program schemes: their output variables will coincide with their input variables.

3.3 The Seman t i c s of D y n a m i c Logic. Let A be a structure (in the appropriate .irnilarity type), and u : V - A a valuation from the set V of all variables into the universe A of A. Let 4 be a formula of DL(P). The definition of the relation (A,u) 4 follows the inductive definition of DL(P). For cases ( l ) , ( Z ) , and (3) , in 3.1, the definition of I= is precisely the same as in first-order logic. For case (4) in 3.1:

if 4 E DL(P) and S E P , then (A ,u) I= (S)4 iff there is a finite computation of S over A which transforms u into u‘ and (+?,of) I= 4.

Note tha t , because P may allow non-deterministic computations, we say “there is a finite computation of S over A which transforms u into u’ ” rather than “the computation of S over A is finite and transforms u into u’”. From this case it follows that ( A , u ) I= [S]4 iff for every finite computation of S over A, if u is transformed into uf then (A ,u f ) I= 4.

As expected, the complexity and expressive power of DL( P) varies greatly depending on the choice of the underlying programming language. At one extreme, if P is the trivial language of loop-free programs (for example. the fragment of PASCAL which does not use the mechanisms while-do, r epea t -un t i l , and recursive calls), then DL(P) collapses into

The Pebble Game and Logics of Programs 325

coIivent,ional first-ordcr logic. This is I)erausr. in this case. every program in P can be uniformly representrdt by a quant ifirr-free first-order formula.

The simplest. non-trivial choice for P is the language of while-programs or flowchart srhemes. which allow unbounded iterations (loops). Such programs cannot be uniformly represent,ed by first-order formulas. We can get still more powerful programming for- malisms by adding to this P such features as: non-determinism, recursive calls (with and without paramekrs), counters, and others.

Somc%imrs t,he partial functions and relations computed by a programming formalism over a structure A are first-order definable in A , even in the presence of loops and other programming mechanisms. This can also happen over a class of structures. For example, over the standard model of arithmetic N, any programmable function (i.e., partial recursive function) is first-order definable in N. This is of course because first-order formulas over N can code and decode finite sequences of natural numbers. In this case too, whatever can be expressed by first-order dynamic logic is already expressed by conventional first-order logic.

There are sit,uations where the partial function romput,ed by a program over a struc- tiire A is first-order definable in A -not because first,-order formulas can code and decode fii l i ic wqiienccs of elernent,s. but because there is a uniform boiind on the lengths of the tcmiiinating computations of that program over A. In such a rase, we say that the program iui\$,i i id\ in A .

Thcs unwind property was first stated in Engrlcr 119751. and derives its name from a\prv-ts of flowchart schemes to which it was first applied. It has a very succinct formulation in tcriii\ of Frirdman‘b effective dcfinitional schcwles.

3.4 Defiiiition.Let A be a structure of similarity type 3. An eds (C, -+ tt,li E w ) of type (Y = (x, 7) unwinds in A if there is an integer n such that

A I= (C, v . . . v C,) t” v c, , t t W

in which case the partial function computed by the eds over A is first-order definable in A

(c,(x) A y = t t o ( x ) ) V . . . V (C,(x) A y = t t , ( x ) ) .

This definition directly applies to any program scheme that can be translated into an eds, in particular any flowchart scheme augmented with a push-down stack and counters. It is easily extended to more general program schemes, in particular to non-deterministic ones (Kfoury [ 19851).

by

If an eds unwinds in a structure A then it unwinds in every structure B elementary equivalent to A, because (using the notation of 3.4)

A )= C, i C, v . . . v C, iff B I= C, -+ C, v . . . V C,

for all i > n so that also B I= (C,v . . . VC,) - v C,.

eEu

t “Uniformly represented” in the sense that the same formula represent the functions or relations computed by that program over all structures.

326 A.J. KFOURY

Again, t,his fart can be extended t o riior(' gc,ric~al program srhemes, including non-deterrriiIiist,ic ones.

If every program scheme in a programming formalism P unwinds in a structure A , we say that A has t,he unwind property for P .

3.5 Lrriima. Lct P be a programming fornialism. If st,ructure A has the unwind property for P , then for every @J E DL(P) there is a first-order formula 41 such that Th ( A ) I= 6 i 4. Proof. This is by indurtion on the synt,ax of DL(P), using thc fart (implied by the unwind property) that every formula @ ) 0 , where 0 does not contain the symbols { ), is Th (A)- equivalent to a formula 0' not containing ( ). This fart is especially transparent when S is translated int~o an eds (C, + tt,li E w): the desired formula 0' is

3y{ [ ( C , A y = I t o ) V . . . V (C, A y = tin)] A q y ) } I

Consider now the structure M = (w, = , g , O ) where y : w x w + w is defined by

111 3.6. 3.7. and 3.8. wv asslime that all program schemes are in the similarit,y type of M, containing one 1)inai-y function symbol and one constant symbol.

3.6 Lrinliiti. wlieiiivs t o 1)onricIcd storage s p a n % . M has the unwind proprrty for P. Proof. This is an appliration of the pebble game. The idea is to show that with a finite supply of p memory locations. there is a bounded number (depending on p and n only) of elrnirnts that can be generated from any finite set of n natural numbers using the function y . From this, it follows that a program scheme must unwind in M if it has access to only p niemory lorations (think again in terms of eds's-it is easier). The details are in Kfoury [1983]. I

Let P h a programming formalism which restricts each of itls program

3.7 Lemma. Let P be the formalism of flowchart schemes each augmented with a push- down stack and counters. There is a formula 4 E DL(P) such that for no first-order forrriiila 41 is i t t,he case that Th ( M ) )= 6 H 4.

PTOO/. We can take P to be the class of eds's. Let a = ((z),{G}), where G is a binary function synibol, which will be interpreted as the function g of M . Let (t,(z)li E w ) be an r.e. sequence of all a-terms. It is easy to see that the set { t r ( O ) l i E w } exhausts the entire universe of M, so that the eds S = (z = t t ( 0 ) -+ z( i E w ) converges over M for every input value. This also means that over a non-standard model M' of Th (M), the eds S does not converge for every input value. Hence, M /= Vz((S)true ) but M' I# Vz((S) true). The desired formula 6 of DL(P) is Vz((S) true ). I

Theorem 3.8 was first established by Tiuryn [1981c] by a different method.* Tiuryn used a rather involved back-and-forth construction (a variant of Ehrenfeucht-Fraissegames) together with the pebble game.

* A third proof (in Russian) is in Erimbetov [1981].

The Pebble Game and Logics of Programs 321

3.8 Theorrm. Lct P I K t l i c forIrialiw1 of flowchart srhc i i i~ s each augnient,ed with a push- down st,ark and counters. and P’ that of fluwrhart srhe~ric~s augmcmted with counters. Then D L ( P ) is more expressive than DL(P’).

Proo/.By 3.7 there is a formula of D L ( P ) whirh can distinguish bet,ween two distinct models of TI1 ( M ) . By 3.5 and 3.6. no formula of DL(P’) can. I

Tlic preceding result is a general o~ ic , and can be proved again by the same technique for other programniing formalisms P and P‘ such t,hat: P 3 P’ and P allows access to u1ibou1iclecl htorage space but P’ does not, (Tiuryn [1981c]). The theorem holds as well in the non-deterministic rase. Our specific choire for P and P’ was in order to directly usc Frirdnian’s effective definitional schemes (identified with the formalism of flowchart schemrs each equipped with a push-down stack and counters), as well as to make explicit the sense in which Friedman’s earlier result (Theorem 2.5 above) is extended by Theorem 3.8. The first is implied by the second, but not the other way around.

The comments at, t,he end of Section 2 again apply here. When all function symbols are of arity 5 1, Theorem 3.8 cannot be proved by techniques based on the pebble game. If P is the formalism of flowchart, schemes each augment,rd with a push-down stack, and PI the formalism of flowchart schemes, then D L ( P ) is more expressive than DL(P’), provided t,herr are at, least two function symbols of arity = 1 (see the rc,ferences mentioned at the e11(1 of Section 2) . When there is exactly one furiction symlwl whirh is of arity = 1, we do i i o t know whrthcr the result holds.

4 . Arkiiowlrdjieriirrit s

Thanks are due t,o Steven Homer, Jerzy Tiuryn, P. Urzyczyn, and J .C . Shephcrdson for various corrections and comments on an earlier draft of the paper. I am especially grateful to Steve Homer who took charge of putting t,he paper in its final form. Tom Orowan was responsible for typesetting the paper in TEX.

328 A.J. KFOURY

5. Referenres

[l] Abramson, F.G. 119781, “In rrpolation theorems for program schemata,” Information and Con,trol, 36, No. 2 , 217-233.

[2] Berrnan. P., J .Y. Halpern, and J. Tiuryn [1982], “On t,hr power of non-determinismin dynamic logic,” Proceedings of the 9-th ICALP, Lecture Notes in Computer Science, 140, Springer-Verlag. 48-60.

[3] (kaserriann. C. and H. Langrriaack [1983]. “Charact,rrization of acceptable by Algol-like prograIiimiirig langiiagrs.” Proceedings of Pi’orkshop o n Logies of Programs, Carnegie- Mellon 1Jniii.. edited hy E. Clarkr and D. Kozen (Lecture Notes in Computer Science, 164, Springer-L’erlag).

141 Engeler, E. 119751, “Algorithmic logic,” in Malhematiral Center Tract No. 63, edited by de Bakker, Amsterdam.

(51 Erimbet,ov, M.M. [1981], “On the exprrssivr power of programming logics,” Proceedings of the Conference; Research in Theoretical Programming, Alma-Alta 1981, 49-68 (in Russian).

161 FrirdIrian. H. [1970], “Algorit,hmic procedures, generalized Turing algorithms, and el- enirritary rrrur.;iori throry.” Logir Colloquium ’69. c d . hy R.O. Gandy and C.M.E. Yatrs. North-Holland. 361-389.

171 Harcl, D. [1979]. First-Ordcr Dynamic Logir Leclure n’oles iu Compufer S e i e f m . 68. S p r i n g c ~ r - V t ~ l ~ p .

[8] Hopcroft, J . , W. Paul and L. VaIiant, [1975], “Oil t,inlr versus spare,” 16th IEEE Syinp. on Foundations of Computer Science, 57-64. Journal version of the same article appeared in J . of the A C M 24, (1977), 332-337.

[9] Kfoury, A.J. [1983], “Definability by programs in first- order structures,” Theoretical Computer Science, Fundamental Studies, 2 5 , 1-66.

[lo] Kfoury. A.J. (19851, “Definability by deterministic and non-deterministic programs (with new proofs of old and new results in first-order dynamic logic),” to appear in Information and Control.

1111 Kfoury, A.J. and P. Urzyczyn 119851, “Neressary and sufficient conditions for the uni- versality of programming formalisms,” to appear in Acta Informatica.

1121 Kozen, D. 119841, “Pebblings, edgings, and equational logic,” 16th A C M Symp. on Theory of Computing, 428-435.

1131 Meyer, A.R. and J. Tiuryn [1982], “A note on equivalences among logics of programs,” Logics of Programs Workshop IBM I’orktouin Heights, Proceedings edited by D. Kozen (Lecture Notes i n Computer Science 131, Springer-Verlag).

(141 Paterson, M. and C. Hewitt (19701, “Comparative schematology,” M I T A.I. Lab Tech- nical Memo No. 201, (also in Proceedings of Project MAC Conferenre on Concurrent Systems and Parallel Computation, 1970.)

1151 Pippenger, N. [1980], “Pebbling,” Fifth Symposium on Mathematical Foundations o/ Computer Science, IBM Japan.

The Pebble Game and Logics of Programs 329

1161 Pippmgrr, N . 119811, “Pc~l~l~l ing with an auxiliary piishdown,” .I . Conipuler and System S r i c n r e ~ 2 3. 15 1- 165.

1171 I‘ipprnger* N . [1982]. “Adranccs in Pebbling,” Proreedings of t h e 9-th ICALP, Lecture Notes in (.‘ompuler S r i e n r c . 140, Springer-Verlag.

1181 Salwicki. A . [1970]. “Forrnalizrd algorithmir languages.” Bull. Acad. Pol. Sci. Ser. S r ; . M n l h . A s t r . Phys. 1 8 (5).

1191 Savagr . .J.E. and J.C. Vitter 119841. “Parallclisni in spacr- time tradeoffs,” Proceedings of Inlernatioirul Workshop 0 1 1 l.L.sI; Algorithins and Archi tec ture , Arnalfi, Italy.

[20] Shepherdson, J .C . [1975], “Coinput,at,ion over abstract structures: serial and parallel procrdures and Friedman’s effective definitional schcnies.” in Logic Colloquium, ‘73, North-Holland, 445-513.

1211 Stolboushkin, A.P. an<. M.A. Tait,slin 119831, “Det,crniinistic dynamic logic is strictly weaker than dynamic logic,” Informofion and Conlrol, April 1983.

1221 Tiuryn, J. [1981a], “Logic of effectivc definitions,” Fundamenta Informaticae, Annales Sori?la/is Mafhenzaticae Polonae, IV.3, 629-659.

1231 Tiuryn, J. [1981b], “Survcy of the logic of effectivr definit,ions.” Logic of Programs Ilorkshop, ETH Zurich, proceedings edited by E. Engeler (Lect,ure Notes in Comput,er Sricncr. 125, Springer-Verlag).

1241 Tiiiryii. . I . [1981c], “Unbounded memory adds to the power of logics of programs,” Proreedinys of 22nd Annual Symposiu,m on Foiindations of Conipufer S’riencf. 335-339 (full paper to appear in Informatiovi and Coritro1 ) .

1251 Tiuryn, J. and P. TTrzyczyn 119831, “Some relationships between logics of programs and complexit,y theory,” Proceedings of 24th Arinual Symposium of Foundations of Computer Science.

[26] Urzyczyn, P. [1981a], “Algorithmic triviality of abstract structures,” Fundamenta In- formatieae, Annales Societatis Mathenzaticae Polonae. l L ’ . 4 , 819-849.

1271 Urzyczyn, P. [1981b], “The unwind property in certain algebras,” Information and Control. 60. No. 2, 91-109.

1281 Urzyczyn, P. [1983]. “Non-trivial definability by flowchart programs,” Information and L‘ontrol. 58, No. 1-3.