<<

On correspondences between programming languages and semantic notations

Peter Mosses Swansea University, UK

BCS-FACS Annual Semantics Seminar 8th December 2014,

1 50th anniversary!

IFIP TC2 Working Conference, 1964 ‣ 50 invited participants ‣ seminal papers by Landin, Strachey, and many others ‣ proceedings published in 1966

2 Landin and Strachey (1960s)

Denotational semantics (1970s)

A current project

3 Peter J Landin (1930–2009)

Publications 1964–66 ‣ The mechanical evaluation of expressions ‣ A correspondence between ALGOL 60 and Church's lambda-notation ‣ A formal description of ALGOL 60 ‣ A generalization of jumps and labels ‣ The next 700 programming languages

[http://en.wikipedia.org/wiki/Peter_Landin]

4 1964

The mechanical evaluation of expressions By P. J. Landin

This paper is a contribution to the "theory" of the activity of using computers. It shows how some forms of expression used in current programming languages can be modelled in Church's X-notation, and then describes a way of "interpreting" such expressions. This suggests a method, of analyzing the things computer users write, that applies to many different problem orientations and to different phases of the activity of using a computer. Also a technique is introduced by which the various composite information structures involved can be formally characterized in their essentials, without commitment to specific written or other representations.

Introduction is written explicitly and prefixed to its operand(s), and The point of departure of this paper is the idea of a each operand (or operand-list) is enclosed in brackets, machine for evaluating schoolroom sums, such as e.g. Downloaded from 1. (3 + 4)(5 + 6)(7 + 8) /(a,+(x(2,6),3)). 19 12 12 5 2. if 2 < 3 then V2 else V 2 This notation is a sort of standard notation in which 3 If 17 cos n/l7 ~ "V^1 ~ 17 sin all the expressions in this paper could (with some loss l7 cos TT/17 + V(l + 17 sin of legibility) be rendered. The following remarks about applicative structure http://comjnl.oxfordjournals.org/ Any experienced computer user knows that his will be illustrated by examples in -which an expression is activity scarcely resembles giving a machine a numerical written in two ways: on the left in some notation whose expression and waiting for the answer. He is involved applicative structure is being discussed, and on the right with flow diagrams, with replacement and sequencing, in a form that displays the applicative structure more with programs, data and jobs, and with input and output. There are good reasons why current information- explicitly, e.g. processing systems are ill-adapted to doing sums. a/(2b + 3) /(fl, Nevertheless, the questions arise: Is there any way of extending the notion of "sums" so as to serve some of (a + 3)(6 - 4) + the needs of computer users without all the elaborations (c-5)(d-6) by guest on December 2, 2014 of using computers? Are there features of "sums" that In both these examples the right-hand version is in the correspond to such characteristically computerish con- "standard" notation. In most of the illustrations that cepts as flow diagrams, jobs, output, etc.? follow, the right-hand version will not adhere rigorously This paper is an introduction to a current attempt to to the standard notation. The particular point illus- provide affirmative answers to these questions. It trated by each example will be more clearly emphasized leaves many gaps, gets rather cursory towards the end if irrelevant features of the left-hand version are carried and, even so, does not take the development very far. over in non-standard form. Thus the applicative It is hoped that further piecemeal reports, putting right structure of subscripts is illustrated by these defects, will appear elsewhere. Oib,, a{j)b(J,k). Expressions Some familiar expressions have features that offer Applicative structure several alternative applicative structures, with no obvious criterion by which to choose between them. Many symbolic expressions can be characterized by For example their "operator/operand" structure. For instance al(2b + 3) f +(+(+(3, 4), 5), 6) 3+4+5+6 \ +(3, +(4, +(5, 6))) can be characterized as the expression whose operator [£'(3,4,5,6) is V and whose two operands are respectively 'a,' and the expression whose operator is '+' and whose two where 2' is taken to be a function that operates on a operands are respectively the expression whose operator list of numbers and produces their sum. Again is ' x ' and whose two operands are respectively '2' and '6,' and '3.' Operator/operand structure, or "applica- / t («. 2) tive" structure, as it will be called here, can be exhibited \ square (a) more clearly by using a notation in which each operator where t is taken to be exponentiation. 308

5 1964

The mechanical evaluation of expressions. The Computer Journal (1964) 6: 308-320. ‣ applicative expressions (AEs) - λ-abstraction, application ‣ structure definitions - algebraic data types ‣ an abstract machine - stack (S), environment (E), control (C), dump (D)

5 Mechanical evaluation By a X-expression we mean, provisionally, an expression of a segment of a vector by characterized by two parts: its bound variable part, »«. written between the 'A' and the '.'; and its X-body, written after the '.'. (A more precise characterization Themostdirect rendering of this as anAEis somethinglike appears below.) sum (v(r), s). Some of the right-hand versions appearing above However, this is not a semantically acceptable cor- contain a A-expression. Some of those below contain respondence since it wrongly implies dependence on several A-expressions, sometimes one inside another. only one element of v, namely vr. The same criterion This paper shows that many expressions can be con- prevents A from being considered as an operator, in sidered as constructed out of identifiers in three ways: our sense of that word; more precisely it rules that by forming A-expressions, by forming operator/operand 2 combinations, and by forming lists of expressions. Of X(x, x + 1) these three ways of constructing composite expressions, incorrectly exhibits the applicative structure of the first two are called "functional abstraction" and 'Ax.x2 + 1.' "functional application," respectively. We shall show We are interested in finding semantically acceptable below that the third way can be considered as a special correspondences that enable a large piece of mathe- case of functional application and so, in so far as our matical symbolism (with supporting narrative) to be Downloaded from discussion refers to functional application, it implicitly rendered by a single AE. refers also to this special case. We are, therefore, interested in a class of expressions Structure definitions about any one of which it is appropriate to ask the following questions: AEs are a particular sort of composite information

structure. Lists are another sort of composite informa- http://comjnl.oxfordjournals.org/ Ql. Is it an identifier? If so, what identifier? tion structure. Seyeral others will be used below, and Q2. Is it a A-expression? If so, what identifier or they will be explained in a fairly uniform way, each sort identifiers constitute its bound variable part and being characterized by a "structure definition." A in what arrangement? Also what is the expression structure definition specifies a class of composite informa- constituting its A-body? tion structures, or constructed objects (COs) as they will be called in future. It does this by indicating how many Q3. Is it an operator/operand combination? If so> components each member of the class has and what sort what is the expression constituting its operator? of object is appropriate in each position; or, if there Also what is the expression constituting its are several alternative formats, it gives this information operand? in the case of each alternative. A structure definition by guest on December 2, 2014 We call these expressions applicative expressions (AEs). also specifies the identifiers that will be used to designate Later the notion of the "value of" (or "meaning of," various operations on members of the class, namely or "unique thing denoted by") an AE will be given a some or all of the following: formal definition that is consistent with our correspond- (a) predicates for testing which of the various ence between AEs and less formal notations. We shall alternative formats (if there are find that, roughly speaking, an AE denotes something alternatives) is possessed by a given as long as we know the value of each identifier that CO; occurs free in it, and provided also that the expression (b) selectors for selecting the various components does not associate any argument with a function that of a given CO once its format is is not applicable to it. In particular, for a combination known; to denote something, its operator must denote a function (c) constructors for constructing a CO of given that is applicable to the value of its operand. On the format from given components. other hand, any A-expression denotes a function; roughly speaking, its domain (which might have few The questions Ql to Q3 above comprise the main part members, or even none) contains anything that makes of thApplicativee structure definitio expressionsn for AEs. What the (AEs)y do not sense when substituted for occurrences of its bound convey is the particular identifiers to be used to designate variable throughout its body. the predicates, selectors and constructors. Future Given a mathematical notation it is a trivial matter structure definitions in this paper will be laid out in to find a correspondence between it and AEs. It is less roughly the following way: trivial to discover one in which the intuitive meaning An AE is either of the notation corresponds to the value of AEs in the an identifier, sense just given. A correspondence that meets this condition might be called a "semantically acceptable" or a X-expression (Xexp) and has a bound variable (by) correspondence. For instance, someone might con- which is an identifier or ceivably denote the sum identifier-list, and a X-body (body) which is an AE, Mechanical evaluation vr+vr+ . . . +vr+s+s__1 310 or a combination and has an operator (rator) as an explicit definition with a A-expression for its right- which is an AE, hand side, e.g. and an operand (rand) / = which is an AE. f(y) = This is intended to indicate that 'identifier,' 'A- So an expression using an auxiliary function definition expressiori and 'combination1 (and also the abbreviations can be rendered by using two A-expressions, one for its written after them if any) designate the predicates, and operator and one for its operand, e.g. 'bv,' 'body,' 'rator,' 'rand' (mentioning here the 6 + f(A)}[Xy.y(y + 1)]. abbreviated forms) designate the selectors. We consider a predicate to be a function whose result for any suitable where f(y) = y(y + 1) argument is a "truth-value," i.e. either true or false. A group of auxiliary definitions may include both For instance, if A' is a A-expression, then the predicate numerical and functional definitions, e.g. Xexp applied to X yields true, whereas identifier yields false; i.e. the following equations hold: f(a +b,a-b) + {X(a,b,f).f(a + b,a-b) f(a -b,a+b) f(a -b,a + b)} Xexp X = true where a = 33 [33, 44, A(w, v). uv(u + v)].

identifier X = false. Downloaded from and b = 44 (It will be observed that, by considering predicates as functions, we are led into a slight conflict with the and /(M, V) = uv(u + v) normal use of the word "apply." For instance, in When a A-expression is written as a sub-expression of normal use it might be said that the predicate even a larger expression, the question may arise: how far to

"applies to" the number six, and "does not apply to" the right does its body extend? This question can http://comjnl.oxfordjournals.org/ the number seven. We must here avoid this turn of always be evaded by using enough brackets, e.g. phrase and say instead that even "holds for," or "yields true when applied to," six; and "does not hold for," or (X(u,v).(uv(u+v))). "yields false when applied to," seven.) However, to economize in brackets, we adopt the The constructors will not usually be named explicitly. convention that it extends as far as is compatible with Instead we shall use obviously suggestive identifiers the brackets, except that it is stopped by a comma. such as 'constructXexp.' E.g. the following equations Another way of saying this is that the "binding power" hold: of the '.' is less than that of"functional application", multiplication and all the written operators such as

identifier (constructXexp (J, X)) = false by guest on December 2, 2014 '+.' 7.' etc-> DUt exceeds that of the comma. For Xexp (constructXexp (J, X)) = true example: bv (constructXexp (J, X)) = J constructXexp (bv X, body X) = X Asia)) + g(f(b)) and many others. (More precisely, each of these where f(z) = z2 + 1 [Xz.z2 + 1, A z . z 2 - 1]. equations holds provided J and X are such as to make and g(z) = z2 — 1 both sides meaningful. Thus the first three hold provided J is an identifier or list of identifiers and X is An identifier may occur in the bound variable part of an AE. Again, the last holds provided I is a a A-expression (either constituting the entire bound A-expression.) variable, or as one item of it). Apart from this, every A structure definition can also be written more written occurrence of AE is in one of the following four formally, as a definition with a left-hand side and a sorts of context: right-hand side. The left-hand side consists of all the identifiers to which the structure definition gives mean- (a) It is the A-body of some A-expression. ing. The right-hand side is an AE containing references (b) It is the operator of some combination. to the component-classes involved (e.g. some class of (c) It is the operand of some combination. character-strings, in the case of AEs that are identifiers) (d) It is a "complete" AE occurring in a context of and also to one or more of a number of functions English narrative, or other non-AE. concerned with classes of COs. However, in this Each of the three formats of AE can appropriately paper we shall not formalize the notion of structure appear in any of the four sorts of contexts. We have definitions, and shall write any we need in the style already seen that A-expressions, like identifiers, can illustrated above. appropriately occur both as operators and as operands. Below we shall find combinations appearing as operators, Function definitions and A-expressions appearing as A-bodies. These last In ordinary use, definitions frequently give a functional, two possibilities are both associated with the possibility rather than numerical, meaning to the definiendum by that a function might produce a function as its result. using a dummy argument variable. This can be rendered Together with more obviously acceptable possibilities, 311 Mechanical evaluation of functions, etc. More precisely, an AE X has a value in bvX coincides with a constant of E). We denote this (or rather might have a value) relative to some back- derived environment by ground information that provides a value for each identifier that is free in X. This background information derive(assoc(bvX, x))E. will be called the environment relative to which evaluation We shall describe below a mechanical process for is conducted. It will be considered as a function that obtaining the value, if it exists, of any given AE relative associates with each of certain identifiers, either a to any given environment. This process can be imple- number, or a list, or a function, etc. Each identifier to mented with pencil and paper, or (as we shall briefly which an environment E gives a value is called a constant sketch)Applicative with a digital computer expressions. The rule (AEs)s Rl and R3 of E, and each object "named," or "designated," by a provide a criterion for deciding Whether or not the constant of E (possibly by several) is called a primitive ‣outcomAEs (X)e o generallyf this proces haves valuesis in fac (int thenvironmentse value as w Ee) under- of E. So E is a function whose domain and range stan- dindependently it. of any machine comprise respectively its constants and its primitives. The three rules can be formalized as a definition of If we let val, thus: val(E)(X) recursive valEX=identifierX'-> EX denote the value of X relative to E (or in E for short), \expX-+f the function that val designates can be specified by means where fx=val(derive(assoc(bvX,x))E) Downloaded from of three rules, Rl, R2 and R3. These correspond to the (bodyX) three questions, Ql, Q2 and Q3 that were introduced else -+ {valE(ratorX))[valE(randX)]. earlier to elucidate the structure of AEs. For example, suppose thrice is the function-producing Rl. If A' is an identifier, valEX is EX; function defined by http://comjnl.oxfordjournals.org/ (R2. appears below); thrice(f)(x) = f(f(f(x))). R3. If X is a combination, valEX can be found by first subjecting both its operator and operand to Then it follows from the above definition of val that the 7 valE, and then applying the result of the former values of the following fivee A E s , to the result of the latter. square 5 The rules Rl and R3 are enough to specify valEX thrice square 5 provided that A'contains ho A-expressions. For example, thrice square (thrice square 5) consider an environment in which the identifier k is thrice (thrice square) 5 associated with the number 7 and the identifier p with thrice thrice square 5 by guest on December 2, 2014 the truthvalue false, and other identifiers have their 2 23 6 2 227 expected meanings. Then Rl and R3 suffice to fix the are respectively 5, 5 , 5*, 5 ' and 5 . The reader value of, say, may be better equipped to check this assertion when he 19 12 has read the next Section, which describes an orderly if((2 < 3 ) yp)(sin, cos)(nlk). way of evaluating AEs. This example illustrates the need for evaluating the The set of objects that can be denoted by an AE operator of a combination as well as its operand. relative to an environment E, is the range of the function valE. It contains all the primitives of E, and everything R2. If A' is a A-expression, valEX is a function. Like produced by such an object, and every function that can any function it can be specified by specifying be denoted by a A-expression. what result it produces for an arbitrary argument, and we now do this as follows: valEX is that Mechanical evaluation function whose result for any given argument In order to mechanize the above rule, we represent can be found by evaluating bodyX in a new an environment by a list-structure made up of name- environment derived from £ in a way we shall value pairs. There is a function designated by location presently describe. For example, suppose E is such that if E* is this structure and Xis an identifier then the environment postulated above, and X is the A-expression 'Xr.k2 + r2.' Then its value in E locationE*X is that function whose result for any given argu- ment, say 13, can be found by evaluating denotes the selector that selects the value of X from E*. 'k2 + r2' in a new environment E', derived from So if E* represents the environment E then the following E. To be precise, E' agrees with E except that equation holds: it gives the value 13 to the identifier r. valEX = locationE*XE*. More generally, this derived environment consists of We shall not bother below to distinguish between E E, modified by pairing the identifier(s) in bvX with and £*. corresponding components of the given argument x Also we represent the value of a A-expression by a (and using the new value for preference if any variable bundle of information called a "closure," comprising 316 Mechanical evaluation

So if L is a list whose k items are au a2, • • •, ak, then item from a list which is not referred to elsewhere. So, we consider 'if to be an identifier designating a function- prefix(x)L producing function such that Mechanical evaluation denotes a list whose k + 1 items are x, au . . .,ak. The operand terms. By a circular definition we mean an ditional expressions, the existence' of /(0) does not function prefix is function-producing and so gives rise implicit definition havin//(trueg th) e= for 1stm involve the existence of/(—I). Notice also that Y to combinations whose operators are combinations. It //(false) = 2nd. may produce a function, and hence gives rise to com- can be denned in terms of constructlist as follows: Then (A) is equivalent to the following AE: binations whose operators are combinations, e.g. i.e. a definition of x in which x is referred to one or prefix{x) = \L.constructlist(x, L). {YXf. Xn.ifn = 0 then 1 else nfin - l)}6 more times in the definiensif (a < b)(a\. Fo r V). example, suppose (Al 'M') By a natural extension of the notation for function designates a list-structure, then is a meaningful combination. In fact its value is 720. This rendering is not, however, adequate. For it This device can also be used for a group of "jointly definitions this can also be written (a, M, (b, c)) would match Mechanical evaluationcircular" or "simultaneously recursive" definitions, e.g. prefix{x){L) = constructlist(x, L). denotes a list-structure whose second item is the list- fx = F[f, g, x] if, g) = YXtf, g)• (*x.F[f, g, x], So if L is a lisift awhos = 0e thek nitem 1 elss are e I/aau a2, • • •, ak, the(Bn) item from a list which is not referred to elsewhere. So, The following examples illustrate the applicative structure M. The equation wean consided gx =r 'if G[f, t og, b x]e an identifier designatin Xx.g G[f, a function g, x]). - by prefix(x)L structure we are now imposing on operand-lists of L = (a, L, (b, c)) producinSo the g fixed-point function suc ofh atha functiot n might be a list of length two or more, and of length zero: denotes a list whose k + 1 items are x, au . . .,ak. (BlThe) functions. This gives rise to the possibility that a is satisfied by the "infinite" list-structure containing //(true) = 1st

function prefix is function-producing and so gives rise dyadiDownloaded from c function might appear with what looks like one, f(a, b, c) /{prefix a(prefix b(prefix c niillist))) Buthret the eitems valu,e ooff whicthis hexpression the first i,s i.ea, .th toe thirbe dmor is e(b, explicit c) and, //(false) = 2nd. thtoe combinationsecond is thse whosinfinite eoperator list-structurs aree combinations whose first .ite mIt rather than two, arguments, e.g. when the above a + b -\-{prefix a(prefix b(nullist))) ofcan be denned in terms of constructlist as follows: jointly circular functions appear in an auxiliary

is a, and whose third item is (b, c) and whose second, Then (A) is equivalent to the following AE: Downloaded from constructnullistQ constructnullist(nullist). if (a = Q)(prefix l(prefix(l/a)( ))) (Bl') . . . and so prefix{x)on. = \L.constructlist(x, L). definition: if (a < b)(a\ V). (Al) Notice that while it is meaningful to ask whether a dependSo ths eo abovn the equatiovalue onf mathye bsub-expressioe considered na s 'I/a,'a circula andr figa) + gifb) {Xif, g) .figa) + gifb)} function is dyadic (i.e. has arguments restricted to lists definitioBy a naturan thalt extensioassociaten s ofthi ths e "infinite notation" folist-structurr functione where fx = Fif, g, x) [FA(/, g). (Ax .Ftf, g, x),

hence only exists if I/a exists. So (Bl) is not an http://comjnl.oxfordjournals.org/ This rendering is not, however, adequate. For it of length two), there is no significance to asking whether witdefinitionh the identifies this car n'Z,. als' o be written acceptable rendering of (B) if a is zero and division by wouland dmatc gx h= Gif g, x) Xx. G(f, g, *))]. a function is monadic since any function may be denoted Again prefix{x){L) = constructlist(x, L). zero is undefined. More generally, this method of Notice that the circularity is explicitly indicated in http://comjnl.oxfordjournals.org/ in combination with a single operand rather than a list if a = 0 then 1 else I/a (B) renderinTheg followinfin)conditiona = gif nexamplel =expression 0 thesn illustrat1 sels aes nfinAEe s th —doee 1)sapplicativ not meeet the right-hand version, whereas the left-hand version is of operand expressions. oui.er .criterion of semantic acceptability unless the domain bonly y recognizable as circular by virtue of our comments For the rare cases in which we wish to refer to a list structure we are now imposing on operand-lists of of lengteverhy twfunctioo /or= nmore An.iis ,artificiall fan n d= o f0 ylengtthe extenden h1 zeroelsed :nf(n to contai— 1) n any about it or by common sense. In the next Section (Blwe) with just one item, we use the function defined as argument that might conceivably arise on either shall extend our hitherto informal use of where so as to

may be considered as a circular definition of the factorial Downloaded from follows: Buprovidt thee avalu matce ohf fothir san expressiony use of ,A .i.e. to be more explicit, "branchfunctionf(a, " b,. oc)f a(I nconditiona this /{prefixbriel fexpression a(prefixdiscussio. b(prefixn Wthe eno cwimportan niillist))) presentt unitlist{x) = prefix x nullist. anothequestioa +r nmethob of whethed thart eacavoid -\-{prefixh circulas any a(prefix rsuc definitioh commitment b(nullist)))n characterize. s of ConsideconstructnullistQr instead th e constructnullist(nullist).following alternative The differencife (abetwee = Q)(prefixn structur el(prefix(l/a)( and written representatio))) (Bl'n ) We shall use the following abbreviation for 'prefix x a unique object will be skipped.) V: MakinNoticeg thauste whilof eA i,t anis ymeaningfu circular l definitioto ask nwhethe can r bae by guest on December 2, 2014 Our notation for AEs is deliberately loose. There rearranged so thai/(at =ther O)(Ax.le is jus, t one self-referentia(B2l) dependare mans yo nway thse invalu whice ohf wthee casub-expression write then sam 'I/a,'e AEan,d function is dyadic (i.e. has arguments restricted to lists by guest on December 2, 2014 x:L. hence only exists if I/a exists. So (Bl) is not an http://comjnl.oxfordjournals.org/ occurrenceof length two), an,d ther moreovee is nor significancso that thee tosingl askine occurrencg whethere acceptabldiffering ein renderinlayout, gus oef o(Bf )bracket if a is szer anod anusde divisioof infixen bdy So, e.g. wherconstitutea functioe 'x' nsi s i thsa monadien operanarbitrarilc dsinc ofye th anchosee ydefiniens function variabln, mae.gey. bane ddenote '3' dis as opposed to prefixed operators. However, they are an arbitrarily chosen operand. Unlike (Bl), (B2) has zero is undefined. More generally, this method of in combination with a single operand rather than a list renderinall writtegn conditionarepresentationl expressions of thes sameas AE AEs doe, ins thnoe tsens meeet x,y,z = x:(y,z) = -x:(y : unitlistz) = x :{y : (z : ())). a ovalufL operan =e (a,eve dL,n expressions i (b,f a c)) = 0; .forL =, Xx.l/a {XL'.(a, denote V, [b,s c))}L a function that the information elicited by the questions Ql, Q2 evefin)n =if ifa n= = 0 0 (albeithen 1t wit/ =h {Xfnul.l Adomain—thin . if n = 0 thes ni s1 in our criterion of semantic acceptability unless the domain We shall treat':' as more "binding" than ',', e.g. For the rare cases in which we wish to refer to a list oanf dever Q3y abovfunctioe arn ei sth artificialle same yin extendeeach cased t.o contaiThis ins thaney accordancwith juselset witeon nfinhe ou item-r vie,1 )w w eo f usthee "valuethe functio" oelsf aen nnfin expressiondefine - d1)}/ as,. essential information that characterizes the AE. We as introduced informally in a previous Section and argument that might conceivably arise on either 2nd(2nd(L, x:M, N)) = 1st M. followsNotic:e that, had we used 'V and '/' instead of 'L" "branchcall this "informatio of a conditionan the l"structure expression" . ofW thee no AEw .presen Ourt formalized in a subsequent one). So (B2) is precisely laxity with written representations is based on the The last example refers to a list whose items include equivalenand '/" tthe toy woul(Bunitlist{x)) din stil thl e hav= sensprefixe beee n thax bounnullist.t eithed anrd theso ywoul arde another method that avoids any such commitment. not have constituted self-referential occurrences. knowledgConsideer thainsteat andy th expressioe followinn gw alternative write coulde , at the a list. We admit this possibility and write, e.g. equivalenWe shalt olr usthee yth are efollowin both withoug abbreviatiot value.n for 'prefix x cost of legibility, have been writter ;n standard form, A circular definition of the form by guest on December 2, 2014 (a, b),(c,(),e), unitlistf. V:The arbitrarySyntactic V and '3sugar' in (B2 for) can AEsbe obviated.* with exclusively prefixei/(a =d operatorO)(Ax.l,s •<. J every bracket(B2 in) For the bv of a A-expressioxx:L. n= ca Fxn be a list of identifiers, place. In what follows, a list whose items include lists (i.e. a One of the syntactic liberties that we shall take is to anLists(sucd inh particulaas the lasr t atw liso tabove whos)e characterizelength is zeros an. objecSucth aas where 'x' is an arbitrarily chosen variable and '3' is ‣ So, e.g. use where instead of A. More precisely, we shall use an list which has items that are amenable to null, 1st, 2nd, A-expressiobeing invariann is tapplicabl when transformee to an dargumen by thet functiolist ofn th F,e an arbitrarily chosen operand. Unlike (Bl), (B2) has etc.) will be called a "list-structure." sami.ex,y,ze. alengths th=e x:(y,z)"fixed-point. Thi s =suggest -x:(y" of sF.: thaunitlistz) Itf alwle conditionaus =e ' xY' :{yto designatl: (expresz : ()))e-. aexpressio value even onf thife afor = m0; for, Xx.l/a denotes a function sionthes functiocan ben rendereof findingd i nth ae fixed-pointuniform wa oyf aa sgive followsn function: , even if a = 0 (albeiLt wherwith e nulX =l Mdomain—this is in We shall treat':' as more "binding" than ',', e.g. accordance with our view of the "value" of an expression, Conditional expressions ‣ Conditionalsuch a circula expressionsr definitio1 1n can be rearranged7 so that it is as a "syntactic variant" of formallif a < yb theno n2nd(2nd(L,longe a elsr ecircular b x:M, if: {a N))< 6)(A().a = 1st M., as introduced informally in a previous Section and We now show how AEs provide a match for con- if a = 0 then 1 else I/a if (a = 0)(A( ) . 1, A( ). \/a)(). formalized in a subsequen{XX.L}[M]t one). So (B2) is precisely The last example refers to a list whose items include ditional expressions, e.g. for x = YF. equivaleneven in caset tos tha(B)t gino rathethe sensr furthee thar ttha eithen thr e thefamiliay arre a list. We admit this possibility and write, e.g. equivalent or they are both without value. if a < b then a1 else b1. (A) ‣RecursivRecursiveThus the e definition definitions,above examples “paradoxical”s becom fixed-pointe operator (Y) use of where, e.g. Th2 e arbitrary V and '3' in (B22 ) can be obviated.* (a, b),(c,(),e), unitlistf. n +3n + 2 {Xn.n + 3n + 2}\n + 1] This expression somewhat resembles ThLe =us (a,e L,of (b,self-referential c)) L =, YXL.{a,or "circular, L, (b," c)) or what For the bv of a A-expression can be a list of identifiers, In what follows, a list whose items include lists (i.e. a where n = n -\- 1 th 7 1 havfin)e =com if en =to 0 thebe n calle1 d/ =i n FA/the. An.icomputef n = 0r theworldn 1 , and in particular a list whose length is zero. Such a / (a , b ) "recursivelist which" definitionelshase itemnfin s—s tha ca 1)tn aralse oamenabl be renderee to dels null, ien nfinoperator 1st, — 2nd, 1)/. A-expressioxy{x + y)n is applicable to {Xy an .{Xx. argumen xyix +t lis y)}t of the etc.) will be called a "list-structure." samwhere lengthe x =. aThi2 +s ay/ysuggest s that all conditiona [a2 + a-\/y]}l expres- where / is a computed index number, used to select an * The device given here was suggested by W. H. Burge. 2 2 2 2 Notice that, according to the above treatment of con- sionwhers caen y b=e renderea + bd in a unifor [a +m bwa]. y as follows: 313 Conditional expressions 314 if a < b then a1 else b1 if {a < 6)(A().a7, We now show how AEs provide a match for con- 8 if a = 0 then 1 else I/a if (a = 0)(A( ) . 1, A( ). \/a)(). ditional expressions, e.g. for if a < b then a1 else b1. (A) Recursive definitions This expression somewhat resembles The use of self-referential, or "circular," or what th 7 1 have come to be called in the computer world, / (a , b ) "recursive" definitions can also be rendered in operator/ where / is a computed index number, used to select an * The device given here was suggested by W. H. Burge. 313 1964–65

iiii~(i i~4,!i

proq

( /) 5. GOR~, Editor; H. w. H~.~I~H, /~sst. ~.oltor, t~{ossary & TermJn010gy E. LOHSE, Asst, Editor, Information Interchange S. GORN, Editor; R. W. BEMER, Asst. Editor, Glossary & Terminology R. V. SiVIITH~ Asst. Editor, Programming Languages E. LOHSE, Asst. Editor, Information Interchange R. V. SMITH, Asst. Editor. Programming Languages col: (or more accurately, to a class of ~exts that ~re, in a fairly A Correspondence Between 0or A Correspondence Between Introduction triviM sense, "mutually in~ercha~geable") that can be con- r sidered as the written representation of the abstract AC0. Anyone familiar with both (~hurch's X-calculi (see e.g. ALGOL 60 and Church's Lambda- ol Our syntactic expression is an expression denoting a fu~Le- ALGOL 60 and Church's Lambda- [7]) attd ALTO], 60 [61 will have noticed a superticial re- tion sprogram that passes from an ACO to the class of semblance t)etween the uay variables tie up with the X's Notation: Part II* texts representing it. Our semantic function, nprogra~., Notation: Part I* in a nest of X-expressions, and the way identifiers tie up passes from an ACO to an IAE that models it. In choosing wiltt the headings in a nesl, of procedures and blocks. Some BY P. d. LANDIN'I bo an IAE that models a particular AL(;OL 60 program there its- P. J. I,~XDtN} may also have observed that in, say ~p J Introduction are mm/y decisions to be made, some triviM and some more {\f.f(a) + f(b)} [Xx.:c2 + px + q] The first part of this paper" described an abstract lan- interesting in that they are analogous to important de- cisions made when implemeniing Ag(;or, 60. However, for the two X-expressions, i.e. the operator and the opcr~md, guage based on Church's X-calculi, and comprising ex- This paper describes how some of the semantics of ALGOL our present purpose the mMn virtues are conciseness and play roughly the roles of Mock-body and procedure- pressions called "imperative applicative expressions" 60 can be formalized by establishing a correspondence transparency of the semantic function, even at the costof declaration, respectively. The present paper explores this (IAEs). An informal aeeount was given of the way IAEs between expressions of ALGOL 60 and expressions in a these qualities in the resulting IAEs. modified form of Church's n-notation. First a model for com- resemblance ii~ some detail. ean be considered as a generMization and structural simplification of ALGOL 60. The present part presents a puter languages and computer behavior is described, based on The presenlal~ion falls into four sections. Tim first see- ABSTRACT ALGOI~ Lion, f(illowing this introduegi(in, gives some moi;ivation formal mapping of ALc~o~ 60 into IAEs. the notions of functional application and functional abstraction, The struetm'e definition that follows characterizes a for examining lhe e(n'respondenee. The second section de- but also having analogues for imperative language features. class of constructed objects, called ALGOL 60 COs (AC0s), scribes mt abstxaeL language based on Ctmreh's X-calculi. Formal Presentation of the Correspondence Then |his model is used as an "abstract object language" into that n'firror A~,GOL 60 programs. The relation between This abstrae( language is a development of the AE/SECI) The correspondence between AL~or, 60 arid IAEs is which ALGOL 60 is mapped. Many of ALGOL 60's features AI~GOL 60 texts arid ACOs is many-one; it would be one- system presented in [3] and sontc acquaintance with thai; presented here lm'gely in terms of AEs, or more precisely, emerge as particular arrangements of a small number of struc- one but for spaces, comments, parameter delimiters and paper (hereinMter referred to as [SiEE]) is assumed here. in AEs written with an informM syntax that was mostly tural rules, suggesting new classifications and generalizations. the optional omission in ALGOL 60 of 'real' in certain 0e- The third seclion describes inforlnally, mMnly by illus- described in [MEE]. So IAEs figure firstly as analyses of The correspondence is first described informally, mainly by currenees of 'real array'. (It is likely that some other lral;ions, a correspondence between expressions of ALCOL expressions of ALGOL 60 and secondly as description of the illustrations. The second part of the paper gives a formal languages make more use of such trivial equivalences,/In 60 and expressions of the abstract language. The last attalytieal process itself. This dual role of IAEs is in a sense description, i.e. an "abstract compiler" into the "abstract object framing the definition of ACOs, there is no attempt to see(ion formalizes tiffs eorrespondenee; i( first describes fortuitous. However, it has incidental advantages. It pro- language." lhis is itself presented in a "purely functional" filter out just nonsense as notation, that is one using only application and abstraction. a sort of "abstracl~ ALcol, 60" and then presents Lwo func- vides an example of the use of AEs as a descriptive tool. tiotts that map expressions of ~bstraet AL(alL 60 inlo, on It also saves us the burden of introducing yet another if a+b then ... l;he one hand, AL(~OL 60 texl;s, and on the other hand language in out' attempt at language explication. or expressions of the abstrac{; language. The presentation that follows somewhat resembles a real x; if x then ... syntax-oriented compiler in that, it is composed of two Motivation whereas the syntactic expressions of the ALC~OL 60 do ex- expressions, namely: first, a syntactic expression that de- clude the first, if not the second. (Four equivalent identi- Collten [S It seems possible that the correspondence might: form termines a parenthesization of each well-formed ALGOL 60 /ii tiers, 'arithexp', 'Boolexp', 'designexp' and 'exp', are used (Part J) Tlhe ('onstants and Primitives of the basis of a formal description of the semantics of AL(;OL text and a classification of the parenthesized segments; below solely for' improved readability. Their merit depends Introduction ALGOL 60 60/ As presented here it reduces the problem of specifying arid, second, a "semantic function" that associates an IAE on our undertaking not to interchange them misleadingly.) Motivatioi~ [[lustrat[otl~ of the (.~ortespon(lenee ALt,;OL 60 semani.ies t,o t.hal~ of specifying t)he semantics of with each parenthesized text, and hence (on the assump- [ ,O lit-tel" Ill Prospects Identifiers In general, ACOs are more tolerant thau Ar~ooI, 60 Short-term Aims Variables a sLrueturalty simpler language. The formal treaLment of tion of unique parenthesization) with each text. Ex pressions syntax. In some eases, such as the ones given above, the [mper~ttive Applieativ(! ]!]Xl)r(~ssions the latter problem is beyond the of this paper, and We elaborate the notion of a parenthesized text as fol- A Gener:dization of ,Imnps Blocks license is short-lived because it leads to undefined results, IIItrodlleillb~ (;Ollllii}~ilds into a I"Llne- Pseudo blocks hence likewise a formM t)roof l~hat~ the correspondence de- lows. We characterize a certain class of constructed ob- Declarations but others will actually be given a meaning by our semantic tii/tlal S(:}i() IIL(~ scribed here is eorrecl). [1~ is hoped that~ the informM at- jects (COs), called ALGOL 60 COs (ACOs), which can be Tim Sllaring Machine Statements function, e.g. ALGOl, 60 as Sugared IAE8 Labels and Jumps count of the semantics of the abstract "object language" considered as abstract ALaOL 60 programs arid parts of Informal Presentation of the Corre- Own Identifiers programs. Each ACO corresponds to an ALGOL 60 text .., real procedure a; a := [email protected]; S !~)()II(]ellCe (Part H) * Part I[ of this paper, which gives bite FormM Presenta- procedure f; value a;... Brief Ou'Hine * Ileeeived April, 1964; revised November, 1964. Parg I of this The DomMn of Reference of I"ormal Presentation of the Con'espoud~ tion of the Correspondence, will appear in the March, 1965 issue ence paper appeared in the the 8, 2 (1965), and AI,GOL 60 of the Communications of the ACM. Communications of ACM Abstract ALGOL 89--101. The complete list of References appears with Part I. Fo>lists Present address: Univac Division of Sperry Rand Corpora- ...L:ifp then s; L;... The Synthetic Syntax I"unction t Present address: Univac Division of Sperry Rand Corpora- Streams The Soma, lille IFtlltctioli lion, Systems Programming Research, New York, New York. Types (:(melllsion * This view is expanded in [10]. tion, Systems Programming Research, New York, New York. The structure definition of ACOs uses certain auxilial?

Volun, e 8 / Number 2 / February, 1965 Conmutnieations of the ACM 89 158 Communications of the ACM Volume 8 / Number 3 / ~larch, 1965

9 1964–65

A correspondence between ALGOL 60 and Church's lambda-notation. Comm. ACM (1965) 8: 89–101, 158–165. ‣ imperative applicative expressions (IAEs) - AEs + program-points (J), assigners (lhs ⇐ rhs) ‣ correspondence - ALGOL 60 abstract syntax (ACOs) - synthetic syntax functions : ACOs → Sets(Texts) - semantic functions : ACOs → IAEs

9 ALGOL 60

Landin was an adviser on the official language definition Downloaded from http://comjnl.oxfordjournals.org/ by guest on December 7, 2014

10 ALGOL 60

Landin was an adviser on the official language definition Downloaded from http://comjnl.oxfordjournals.org/ by guest on December 7, 2014

10 ALGOL 60

Expressions ‣ arithmetic, relational, logical, conditional ‣ function application, array and switch components Statements ‣ assignment, conditional, for-loop, compound ‣ procedure call, jump Declarations ‣ variable, function, procedure, array, switch ‣ block, recursion, name and value parameters

11 1964–66

P. J. Landin: A formal description of ALGOL 60. In Proc. IFIP 1964 TC2 Working Conference on Formal Language Description Languages, 1966. ‣ an introduction to the full description ‣ illustration of the correspondence ‣ discussion of foundations

12 1965

P. J. Landin: A generalization of jumps and labels. Univac Technical Report, August1965; Higher-Order & Symbolic Computation (1998) 11: 125–143. ‣ program-closures, J - for program-points ‣ an extended SECD-machine

13 1965–66

P. J. Landin: The next 700 programming languages. Presented at an ACM Programming Languages and Pragmatics Conference, California, 1965; Comm. ACM (1966) 9: 157–166. ‣ ISWIM (If you See What I Mean) - family of unimplemented(?) languages - extends IAEs with (let, where, rec, pp) definitions

14 Landin’s description of ALGOL 60

abstract syntax ACOs

sprogram nprogram

lambda- programprogramprogram notation programtextprogram textprogramtextprogramprogram texttextconcretetext IAEs textsyntaxtext Sets of texts

15 Abstract syntax (ACOs)

“presented informally as a rather long English sentence…” F a rator which is an o, r~.[ h, e function Q (el. (?m:~'y's Q [21) l;ur~s m~ object into a and art incr which is an arithexp, classes of COs, e.g, :~lal(~me'~d, forli,vteIement and arilhexp, and a rand which is an S, class whose sole :m(~mber is t~hat object. Similarly, we shall l>hat we sh~tll loosely call an:ciliary A COs. It also uses cer- and a terminal which is an arithexp, or ~n iteration and has or else is an S, let a quoted single char~cl:x:r, o.g. '::' desi~n,%e either the t:ai~, families of such classes each generated by a CO-class- a rhs which is an arithexp, and a 2op(o,S) is character, or: the string whose so/(' item is that character, producer; ('.g. for ally (',lasses t ariel S and a condition which is a Boolexp, either 2compound and has or the class whose solo member :is that string. If it is or else is an arithexp, a rator which is an o, 2o~(z,,5') and an uncondstatement is and a lstrand which is a 2op(o,S) important we shall dist.i~guish t:t~e l~st two by writing either composite and is a elosedprogram, is a ebtss o[' COs comprising all the £% and also some com- and a 2ndrand which is an S, u~=~ or unitlist ~=' or vnitstrino'= ' or jumping and has a body which is a designexp, or else is an S, posile objcc{s each incorporating t's and S's. Again, or a dummy, Q(u'=') or Q(unitlist'=' or Q('l~uitstring'=') and a typeprimary is or assigning and is an assignexp, either a which is labeled(S) where ree an assignexp has coast respectively. a/hs which is a variable, either arithmetical, Here are some definitions invok~d by the definition of comprises all S's and certain composite objects each in- or Boolean, attd a rhs which is the synthetic syntax function: corporating an id(mtifier and a labeled(S). either simple and is an exp, or string, The fol/owit~g structure definition defines ACOs in terms or else is an assignexp, or simple and is a variable, empty = Q(nullstring) of lists arid noneomposite objects. The noneomposite ob- or else is a fuactiondesig, or else is art exp, sp(s) = null (ts) ~ u(hs) and a labeled(S) is and an arithexp is an exp, jects are AL' l '>'I'#', spaces anywhere except in quoted strings. The other denotes the class of texts representing all non-null lists of a control which is a variable, 2op( ' + ' l '-', operation on text classes much used in the ALGOL 60 and a forlist which is a nonnull forlistelement-list, lop('+' l '--', arithexps, as opposed to just, one particular list. and a body which is a labeled statement, report is class union. It is indicated here as there by an 2op('X' [ '/' l '+ ', There follows the definition of sprogra'm: TM where a forlistelement is 2op("t" ', typeprimary)))})))))) infixed vertical stroke; we use 'u' on the few occasions either a progression and has where a lop(o,S) is where class unions other titan text classes are denoted. sprogram(S) = slabeled(sclosedprogram) (S) an initial which is an arithexp, either lcompound and has We shall generally let a quoted string, e.g. 'begin', where rec sclosedprogram (S) = Volume 8 / Number 3 / March, 1965 Communieations of the ACM 159 designate, ambiguously, either the character-string itself, twordbracket (bloekS --~ srepeat ( sc,sdec l ) (headS) ~ or the class whose sole member is that string. If it is SeC: important we shall distinguish the latter by writing sopenprogram (body,S) else --~ sopenprogramS) Q 'begin' where sopenprogram = srepeat(sc, slabeled(sslatemenl) )

Communications of the ACM 160 Volume I¢ / Number 3 / March, 1965 16 classes of COs, e.g, :~lal(~me'~d, forli,vteIement and arilhexp, and art incr which is an arithexp, l>hat we sh~tll loosely call an:ciliary A COs. It also uses cer- and a terminal which is an arithexp, Abstractor ~n iteration andsyntax has (ACOs) t:ai~, families of such classes each generated by a CO-class- a rhs which is an arithexp, producer; ('.g. for ally (',lasses t ariel S “presented informallyand a ascondition a rather which long isEnglish a Boolexp, sentence…” or else is an arithexp, F a rator which is an o, r~.[ h, e function Q (el. (?m:~'y's Q [21) l;ur~s m~ object into a and art incr which is an arithexp, classes of COs, e.g, :~lal(~me'~d, forli,vteIement and arilhexp, and a rand which is an S, class whose sole :m(~mber is t~hat object. Similarly, we shall l>hat we sh~tll loosely call an:ciliary A COs. It also uses cer- and a terminal which is an arithexp, 2o~(z,,5') or ~n iteration and has or else is an S, let a quoted single char~cl:x:r, o.g. '::' desi~n,%e either the t:ai~, families of such classes each generated by a CO-class- and an uncondstatementa rhs which is an arithexp, is and a 2op(o,S) is character, or: the string whose so/(' item is that character, producer; ('.g. for ally (',lasses t ariel S and a condition which is a Boolexp, either 2compound and has or the class whose solo member :is that string. If it is or else is an arithexp, a rator which is an o, 2o~(z,,5') and an uncondstatement is and a lstrand which is a 2op(o,S) important we shall dist.i~guish t:t~e l~st two by writing either composite and is a elosedprogram, and a 2ndrand which is an S, eitheris a ebtss o[' COs comprisingcomposite all the £% and also some com- and is a elosedprogram, u~=~ or unitlist ~=' or vnitstrino'= ' or jumping and has a body which is a designexp, or else is an S, posile objcc{s each incorporating t's and S's. Again, or a dummy, Q(u'=') or Q(unitlist'=' or Q('l~uitstring'=') and a typeprimary is is a ebtss o[' COs comprising all the £% and also some com- or assigning and is an assignexp, either a which is labeled(S) where ree an assignexp has coast respectively. a/hs which is a variable, either arithmetical, Here are some definitions invok~d by the definition of or comprisesjumping all S's and certain composite andobjects each in- has a body which is a designexp, or Boolean, attd a rhs which is the synthetic syntax function: corporating an id(mtifier and a labeled(S). either simple and is an exp, or string, The fol/owit~g structure definition defines ACOs in terms or else is an assignexp, or simple and is a variable, empty = Q(nullstring) posile objcc{s each incorporating t's and S's. Again, or else is a fuactiondesig, of lists arid noneomposite objects. The noneomposite ob- or else is art exp, sp(s) = null (ts) ~ u(hs) or a dummy, and a labeled(S) is and an arithexp is an exp, jects are AL' l '>'I'#', spaces anywhere except in quoted strings. The other denotes the class of texts representing all non-null lists of stants (e.g. '3.14', 'true', '~ abcd ") Ai,<;OL 60 operation a control which is a variable, 2op( ' + ' l '-', operation on text classes much used in the ALGOL 60 aand a forlistlabel which is a nonnull which forlistelement-list, is an identifier,lop('+' l '--', arithexps, as opposed to just, one particular list. and a body which is a labeled statement, report is class union. It is indicated here as there by an 2op('X' [ '/' l '+ ', There follows the definition of sprogra'm: TM where a forlistelement is 2op("t" ', typeprimary)))})))))) infixed vertical stroke; we use 'u' on the few occasions either a progression and has where a lop(o,S) is where class unions other titan text classes are denoted. sprogram(S) = slabeled(sclosedprogram) (S) an initial which is an arithexp, either lcompound and has symbols (e.g. '~', '+', 'T '), and certain Ai~aor, 60 sym- and a body which is a labeled(S),We shall generally let a quoted string, e.g. 'begin', where rec sclosedprogram (S) = Volume 8 / Number 3 / March, 1965 Communieations of the ACM 159 designate, ambiguously, either the character-string itself, twordbracket (bloekS --~ srepeat ( sc,sdec l ) (headS) ~ or the class whose sole member is that string. If it is SeC: or else is an S, important we shall distinguish the latter by writing sopenprogram (body,S) bols eotmerned with classes (e.g. 'real', 'label', 'string', else --~ sopenprogramS) Q 'begin' where sopenprogram = srepeat(sc, slabeled(sslatemenl) )

160 Communications of the ACM and a decl is either nonrec and is a nonrecdecl, Volume I¢ / Number 3 / March, 1965 'proeedure'--also one non-ALGO*, symbol, namely 16 or rec and is a recdecl, 'command'). where a nonrecdecl has if A is a class, then art Adist is a list each of whose items an ownness which is a truth-value, is an A. If k is an integer, a k-list is a list of length k; and and a body wlhieh is a to-A-list is an A-list of length It. either a typedecl and has A structure definition introduces iderttifiers that desig- a type which is a elassexp, and a nee which is a nonnull identifier-list, nate funei~ions for testing COs and for selecting com- or an arraydecl and has ponents from them. The following structure definition is a type which is a classexp, presented informally as a rather long English sentence. and a body which is a nonnull arraysegment-list, (There are certain points of rigour that are begged here, where an arraysegment has notably whether a one-component CO needs a selector or a nee which is a nonnull identifier-list, and a size which is a (2-arithexp-list)-list, nob. For example, below it will be observed that "looping and a recdecl is statements" do not, whereas "jumping uneondstate- either a switch&el and has ments" do. This is an issue whose resolution might emerge a nee which is an identifier, from more experience in using the descriptive technique.) and a niens which is a nonnull designexp-list, or a procdecl and has A program is a labeled elosedprogram, a type which is a elassexp, where ree and a nee which is an identifier, a elosedprogram is and formals which are a (possibly null) identifier-list, either a block and has and a valpart which is a (possibly null) identifier-list, a head which is a nonnull deel-list, and a specpart which is a (possibly null) spec-list, and a body which is an openprogram, where a spec has or else is art openprogram, a specifier which is a classexp, where an openprogram is a nonnull labeled(statement)-list, and a body which is a nonnull identifier-list, and a statement is and a body which is either code, either cond and is or else is a labeled statement, either 2armed and has where ree a condition which is a Boolexp, an exp is either cond and has and a lslarm which is a labeled uncondstatement, a condition which is a Boolexp, and a 2ndarm which is a labeled statement, and a lslarm which is a simpexp, or 1armed and has and a 2ndarm which is an exp, a comtition which is a Boolexp, where a simpexp is a and art arm which is 2op('~ ', either looping and is a labeled forstatement, 2op('D', or else i8 a labeled uncondstatement, 2op('V', or looping and is a forstatement, 2op('A ', or else is an uncondstatement, lop ( '-n ', and a forstatement has 2op('<' l '=<' l '=' l '=>' l '>'I'#', a control which is a variable, 2op( ' + ' l '-', and a forlist which is a nonnull forlistelement-list, lop('+' l '--', and a body which is a labeled statement, 2op('X' [ '/' l '+ ', where a forlistelement is 2op("t" ', typeprimary)))})))))) either a progression and has where a lop(o,S) is an initial which is an arithexp, either lcompound and has

Volume 8 / Number 3 / March, 1965 Communieations of the ACM 159 Landin’s description of ALGOL 60

abstract syntax ACOs

nprogram

lambda- notation IAEs

17 nprogram : ACOs ➞ IAEs

and nforstatementNS = consdef (eonsli sting ,f ~ and narilhexp = nexp eonsletexp(D, X) = counsf~redex(nee D, X, niens D) let Do, D, X = nlabeled(nstatementN '[') (bodyS) eons~redcx ('x '~ mirror ALGOL 60 in a correspondence that preserves and nBoolexp = nexp e.g. counsletexp ("let x = 2p - q", "x(x + 1)') = (Dog conslisting Z~ and ndesignexp = nexp ALGOL 60'S structure. We have given an informal account co~Ytbin(~ ('f', conslisting (eombine('g', 'x'), 'y')) "let x = 2p -- q parallel (), ! initialcon (typeS))) and nvariableNS = simpleS -~, nidentifierNS of the correspondence, and a formal account• + , . , x(~ + 1)" eombinelist ( ~for ', and nownarraydeclresetNS = i i,Ve stile{; wJlh two hst-proeesstng functmns, that are vlementS -~ The correspondence suggests new ways of classifying (nlhsN (controlS), serial(map nownarraysegmcntreset (bodyS) ) consreeexp(D,X) -- eons~redex(nee D, X, consYredex combine (nidentifierN (ralorS), some of ALGOL 60'S features, and also suggests certain needed later': combinelist ( 'concatenate*', -where nownarraysegmentr esct NS ' = (nee D, niens D)) consIisting (map narilhexpN (randS) ) ) generalizations and alterations that may be of interest to i tee map f L = null L --) ( ) e.g. consrecexp ("let x = x~+~ '', "x(x+l)")= map (nf orlistelementN) (forlistS) ) , serial (map nownarmyreset (neeS') ) clse --~ nfunctiondesigNS armngeaspseudoblock(D, X) ) ) language designers. In so far as the correspondence leads el se -~ f(hL) : mapf (tL) "let ree z = X2+~ where nownarrayresel J = and nlhsNS = simpleS A putativeresultNS -o resultvariantS where nforlistelementNS = iii e.g. map squ,are (1, 3, 7, 2, 3) = (1, 9, 49, 4, 9) x(x+l)" consassigner (ownvariant NJ , else --* nvariableS to better understanding of language structure the in- progressions -~ combines ( 'parearray*, and nfunctiondesigNS = formal account of it suffices. labels (N, X) = consf~redex(N, X, map jump N) :l:'i un ip r, = (map :ts, l,, map 2ha L) eombinelist ('step*', nbplist (sizeS'), combinelist (nidentifier (tarotS), The formal account somewhat resembles a two-pass e.g. labels ("L, M", "4,") = map (narithexp N) conslisting (ownvariantNJ, map (delay. nexp) (randS) ) "let L = JL compiler from ALGOL 60 to IAEs. The half-way house is a (initialS, inerS, terminalS)) initialcon (typeS)))) where nidentifier NJ = needsapplying NJ -~ doJ ree select(p)(L) = null L --~ 0 and M = JM kind of analysis-tree that we call "abstract ALGOL•" It iterations where nbplistNS' = ownidentifier NJ --~ ownvariant NJ p(hL) -~ hL:seleet(p) (tL) combinelist ('while*', else ~ J exemplifies a technique that might be of value to language else ~ select(p) (t~) conslisting (map nboundpairNS') arrangeaspseudoblock (D , X) = counreeexp(D , labels(nee D, X) ) (narithexp N (rhsS) , where nboundpairNS' = and inilialeon A = A = 'real' -~ '0.0' designers, since it isolates decisions about what informa- NeW come functions for processing IAEs and defini- nBoolexpN (conditionS))) conslisting(ownnessS -~ ('- ~ ', '+ ~ ') A = 'integer' -~ '0' tion must be conveyed from decisions about its written arrangeasbloek(D, D', D", X) = else --~ A = 'Boolean' --~ 'false' combine( 'unitlist*', narithexpNS) else --~ map narithexpNS') appearance. tions, These are built up from the eonsmmtors for IAEs, consl etexp (D , eonsreeexp (parallel ( D',D") , labels (unee D", X) ) ) and nuncondstatementNLS = and transfer S = simple S --~ S = 'real' --~ ']loat' e.g. (roughly) and nswitchdeelNS = The "compiler" was itself expressed in terms of AEs composites -~ nclosedprogramNLS consdef ( ) , S = 'integer' -~ 'unfloat' arrangeasblock("let a = ~kl", "letp(x)=¢2", else --~ (parallel(), S = 'command' --~ combine (i.e. IAEs that make no use of imperative concepts). So also use t>he selectors and constructor for definitions, consdef (neeS, "letL=¢4 and M=q%", "$a")= ('in', 'null') this paper includes a nontrivial application of a "purely parallel (), combine: ( 'arrangeasarray ~, namely nee, niens attd consdef. "let a = ~ S = 'label' -~ '[' functional" to language processing. (jumpingS --~ ndesignexpN (bodyS) conslisting (u (conslisting ('1 ', let ree p(z) = ¢2 else else --) combine('in', S) combiune2(F,X, Y) = eombine(combine(F,X),Y) length (niensS) ) ) ), Acknowledgments. This paper was written while I e.g. combine~("D .... sin","k~-/2") = "{Dsiun}[k~-/2]" and L = ¢4 serial ( (dummyS -.~ 'I' else and M = 4,5 conslisling (map ndesigncxpN (niensS) ) ) ) conscondexp' ('atom', worked for . It is based on some assigningS ~ combine~ ('K', conslisting (), and nproedeclNS = combined (F ,X , Y ,Z ) = combine (combine2 (F ,X , Y ) ,Z) let L = JL (t, combine('B', t))) lectures that George Coulouris invited me to contribute nassignexpNS) let Do", D '~, X" = i eombinelist (F,X) = combine (F,conslisting (X)) and M = JM else ~ nfunctiondesigNS), where t = transform(rand S) in Spring 1963 to a series on the "Logical Foundations of code (bodyS) ~ ncode (derive (classifiedvariab lesS) N) .... e.g. combmel*st( f ,( a+b , c+d )) = f(a+b,c+d)" (L)))) where needapplying N = needsapplying NO (bodyS) Programming" at the University of London Computer where tee nassignexpNS = putativeresultandneedsapplying N cons~redex (J,X,Z) = combine (consMxp (J ,X),Z) arrangeasblock p(D, D", X) = arrangeasbloek(D, parallel(), D",X) else --~ nlabeled (nstatement (derive (classi fiedvariab lesS) N ) Unit. W. H. Burge, C. Strachey and M. Woodger read combine2 ( 'assignandhold', and putativeresult N = putativeresult NU e.g. counsf~rede*(' u","u (a+u)","b+c") = "{Xu.u(a+u) }[b+c]" ('1') (bodyS) putativeresultandneedsapplying N parts of an earlier version and pointed out many errors (simpleS -.~ nexpNS i: i e "u(a+u) where u = b+c" There now follows the definition of the semantic function and monadicvariant J = (J = '+') --~ '+M' and obscurities• else --~ nassignexpN(rhsS)), Do", nprogram, with its auxiliaries nforlistelement, nexp, etc. (J = '- ') --~ '-- M' nlhsN (lhsS) ) consdef(neeS, conshexp (conslisting (formalsS) , e,g. consYredex("L","a:(b:L)") = "YXL.a:(b:L)" nprogramS = arrangeasblock'(unlabeled(ncIosedprogramNo'[')S) and nlabeled(ncategory) (S) = (types = 'command' -~ X In the definition of transfer just above, the complication i.e. (roughly) "L where ree L = a:(b:L)" where ree taggedS -+ let Do, D, X = nlabeled(ncategory) (bodyS) else -~ cons~redex (resultvariant (neeS), in the nonsimple case arises from an irregularity in ALGOL delay (X) = conshexp (conslisting (),X) nclosedprogramNLS = Do, parallel(consdef(labelS, delayX), D), labels else ~ ncategoryS X, 60, namely its treatment of parameterless type procedures e.g. delay("f(a) + f(b)") = "~().f(a) + f(b)" blocks -.~ let Do, D, D', Xo = nhead (N, derive (cIassifiedvariablesS) N) (headS) and nhead(N, N') (S) = initialcon (typeS))) occurring as procedure parameters. The predicate atom do (X) = combinelist (X, ()) let Do', D' = map parallel where X = consf~redex(d, is the union of real integer and Boolean. let Do", D", X" = nopenprogram(pnovN)L(bodyS) e.g. do("x',) = "x( )" (unzip (map nrecdeclN' (select rec S) ) ) arrangeasblocU (parallel (map nspecN (parallel(Do, Do"), The following alternative treatment of open programs conscondexp ( P,X) = do (combiunelist (combine ('if', P), map delay X) ) (parallel (Do': map nnonrecdeclN (select ownness S) ), (specpartS)), parallel(), with non-null tails avoids (a) inserting a jump after a Relaxed Deadline e.g. counscondexp("a=O","a","l/a") = parallel(map nnonrecdeclN (select( ~ .ownness) S) ). D 't ' arrangeasbloek(D,D', D ~, serial(Xo,X") ) ) dummy, assignment or procedure statement, or in a "ff(a=O)fX( ).a, x().l/a) ( )" D', X"), for else --~ unopenprogramNLS serial(map nownarraydeclresetN (select(arraydecluownness) S) ) ) Z) compound or conditional containing no labels. (b) in- delayed(F) = combiune( 'B', F) where nopenprogramNLS = ACM Special Interest Symposium on the where nnonrecdcclNS = typedeclS ~-~ ntypedeclNS where nvalue or = consdef(J, combine('separate', doJ)) serting a label when the following statement is already e.g. delayed("float") = "Bfloat" null (tS) --~ nlabeled (nstalementNL ) (hS) Reprogramming Problem arraydecl S -+ narraydeclNS and nspecNS = parallel (map nspec'N (bodyS) ) labeled. i.e. (roughly) "f where f(x) = float.x" else --~ let j, N', N" = takenewIabelN and nrecdeclNS = switchdecl S ~ nswitchdeclNS where nspeePNJ = 1-3 June at Nassau Inn, Princeton, New Jersey let Do, D, X = unlabeled(nstatementN~j)(hS) serial(X) = delay(serial ' (X,conslisting( ) ) ) procdecl S -÷ nprocdeclNS consdef(J, let Do, D, X = nlabeled(nstatementN'I')(hS) let D(, D', X' = nopenprogram(punovN~')L(tS) S,~onsored jointly by ACM and Applied where serial' (X,Z) = nullX ~ Z where ntypedecINS = let Do', D', X' = nopenprogram(pnovN)L(tS) combine ( (needsapplyingNJ --~ delayed Data Research, Inc. else --~ serial ~(tX,combiune (hX,Z) ) .... (parallel(Do, Do'), • parallel (map ntypedecl' (neeS)) null D ~ parallel(Do, Do'), D', serial X, X') parallel(D, eonsdef(j, delayX'), D'), else --, I) (transfer) e.g. serial("R", "S", "T") = "~( ).T(S(R( )))" where ntypedecl~J = tagged(2ndS) ~ let Do, D, X = nlabeled(nstatementN (label(2ndS) ) ) x) (specifierS) Summaries of papers, 1500 words long, i.e. "7'.S.R" eonsdef ( (ownnessS ~ ownvariantNJ (J)) (hS) will be accepted as late as April ls.t and nstatementNLS = else -~ d), where ree parallel(Do, Do'), parallel(D, D'), X full papers by May 1st. Summaries m Iel(D) = let J = map nee D condS --~ combine ('separate', else --~ let j,• N I , Nit takenewlabel N duplicate, and later the full papers in nexp = ncond(nsimp(nlypeprimary) ) and Z = map niens D letD~,D,X = let Do, D, X = nlabeled(nstatementN'j) (hS) duplicate, should be addressed to initialcon (typeS))) where ncond(ncategory)NS = I5. R. Wickenden, Chairman consdef (conslistingJ, counslistingZ) 2armedS ~ nlabeled(nuncondstatementNL) (lstarmS) and narraydeclNS = let Do, Do', X' = nopenprogTum(pnovN")L(tS) condS -~ conseondexp (n Boolexp N (conditionS), Reprogramming Conference parallel ("let u = a+b", larmedS --+ uunlabeIed(loopiung (armS) ~ nf orstatementN let J, Z = unzip(map narraysegmentN (bodyS) ) parallel(Do, Do'), parallel(D, consde$(j, delayX'), D'), X % Applied Data Research, Inc. (ncategoryN (lstarmS), "let v = c+d", else -+ nuneondstatementNL) where narraysegmenlNS' = 150 Route 206 Center Princeton, N. J. 08540 "let W = e+f") = (armS) neond(ncategory) N (2ndarmS))) Conclusion conslisting (ownnessS ~-~ map ownvariantN and nsimp (nprimary)NS = Summaries must be accompanied by Author's biography "let (u, v, w) = (a+b, c+d, eTf)" let Do', D', X' = (neeS') giving full professional background. 2armed ~ nlabeled(nstatementNL) (2ndarmS) 1compounds ~ combine (monadicvariant (raterS), An abstract language based on Churct!'s X-notation and ondexp'(P, F) = consXexp('x', conseondexp(do P, map do F)) else --~ nee S'), larmed ~ parallel(), parallel(), 'I' eons~redex ( ' A ', nsimp (nprimary) (randS) ) aa abstract machine that interprets it has been described. General conference information may be obtained by writing where do(f) = combine(f, ~x') (parallel(Do, Do'), 2compounds ~ combinelist (raterS, The language consists of expressions called "imperative to Mrs. L. Becker, Applied I)ata Research, Inc• eounscondexp' ("P tJ q", "f", "g.h") = constisting(map(K"separate A ") parallel(D, D'), map (nsimp (nprimary) ) expressions" (IAEs). Like Church's systems, No Registration Fee; Only Charges for Meals "~x.(P U q) (x) --~ f(x) (nee S')) conscondexp (n Boolexp (conditionS) , (X, X ') ) ) combine2 ( ' expandtoarray' , (lstrandS, 2ndrandS)) I few structural rules, but they are enough to else ~ (g.h) (x)" and ntypeprimaryNS = constS -+ S loopingS --~ serial (nforstatementNS, L) nbplistN (sizeSL simpleS .-~ nvariableNS (X) = combine ('J', X) else --~ nuuncondstatemenlNLS 'x')) Number 3 / March, 1965 Communications of the ACL'[ 165 else --~ nexpS Communications of the ACM 8 / Number 3 / March, 1965 163 164 Communications of the ACM Volume 8 / Number 3 / March, 1965

18 ro&i so ~hat if ..t is tt (:lass the(, i'nA is a filter that rejects non- fornling and string-forming functions as: decimal(re,n)= lOre + n; qttoge(s) = concatenate(u' r , ~, 'u' " ').) ior~S members of A. For example bz(Boolean) is the function rejectal~bullrutkvalue.s" defined above. So the transfer func- Group 2 consists of symbols and identifiers whose meaning ~s laid down in the ALGOL 60 report, and also a number of identifiers tions for Booleatls and strings are respectively in(Boolean) coined by us and explained above. We assunm that any collisions and in(string). andbetween nforstatementNS these coinages and = Ar~aor, 60 identifiers are avoided by consdef (eonsli sting ,f ~ The ftm(',tion defined by somelet deviceDo, D, such X as= thenlabeled(nstatementN use of a different typeface, '[') (bodyS) e.g. italic eons~redcx ('x '~ instead(Dog of roman. conslisting Z~ /loat,es.lt (f) (:~:) =/teat (f (:r ) ) parallel+, -, X,/, (), +, T, +~r, -~z, <, =<, =, ~, >, ~, -~, A, V, initialcon (typeS))) transforms any number producing function into a real- eombinelistabs, sign, sqrt, ( ~fsin,or ',cos, a,'etan, In, exp, e'ngier and nownarraydeclresetNS = produ(:ing function. (This definition exploils the fact that The infixed operators(nlhsN are (controlS),taken as (applying to 2-lists, either 2- serial(map nownarraysegmcntreset (bodyS) ) we consider any function as operating on a sz:ngle argument nulnbcr-lists or 2-Boolean-lists.combinelist (Numerical 'concatenate*', functions are applic- -where nownarraysegmentr esct NS ' = allbeit a list.) More generally, it' t is the transfer function able to both reals, and integers; if n andfloat(n) are both amenable to a fimetion then they yield the mapsame (nf result. orlistelementN) The coinages (fareorlistS) ) , serial (map nownarmyreset (neeS') ) for some class A, then the traHsfer function for A-pro- for, concatenate*,armngeaspseudoblock(D, step*, anitlist*, wh.ile*, expandtoarray, X) ) ) where nownarrayresel J = ducers is Bt, where B (Curry's combinator B [2]) is de- wherearrange~asarray, nforlistelementNS parearray, float, = .w~tJtoal~ [n> real, integer, consassigner (ownvariant NJ , fined by Boolean,progressions string, -~ atom Gro~tp 3 consists of names for very basic objects. combines ( 'parearray*, ho~£ Bq?: = t@c) null,eombinelist nullist, suffi.x, ('step*', {f, B, K, [, Y, separate, assignandhold nbplist (sizeS'), null is the predicate thatmap tests (narithexp whether a N) list has zero length. conslisting (ownvariantNJ, ~ 60 So for instance Bfloat is the function floatresult defined nullist is a list of length zero. (initialS, inerS, terminalS)) initialcon (typeS)))) above. The transfer functions for type-procedures are s'u~xiterations makes a list one longer, e.g. ya therefore Bfloal, Burtfloat and B(in(Boolean)). Since ar- s'aflix(x) (a,b,c) = (a,b,c,x} where nbplistNS' = if satisfiescombinelist the following: ('while*', 0i: rays are treated as functions these also serve as transfer conslisting (map nboundpairNS') if(true) = 1st (narithexp N (rhsS) , where nboundpairNS' = ftllletions for arrays. if(false) = 2nd nBoolexpN (conditionS))) o~} Imperatives arc treated as nullist-producing furmtions; B forms a functional product conslisting(ownnessS -~ ('- ~ ', '+ ~ ') else --~ combine( 'unitlist*', narithexpNS) so it would appear that the best we can do fern transfer B(t)(f) = hx.tff(z)) else --~ map narithexpNS') and nuncondstatementNLS = 2i'i~: function for lahels is B(bt(null)). Hence the transfer fune- It is used lit dclaying transfer functions for type t)roeedures and nswitchdeelNS = and formals called by name. ]t1~ (.ions for nontype procedures and for switches (which are composites -~ nclosedprogramNLS consdef ( ) , K elseproduces --~ (parallel(), "constant functions" ;|le! considered as arrays whose elements are program-closures) K (x) (:/) = x consdef (neeS, is B(B(in(null))). So for instanceparallel K3 is (), a function whose result is 3 for any argu- combine: ( 'arrangeasarray ~, M~, The effect of the at)eve provisions for checking argu- ment; it is (jumpingSused to tidy up--~ assignments. ndesignexpN (bodyS) conslisting (u (conslisting ('1 ', ments is tht~t a mismatched procedure, array, label or I is the identityelse function, defined by [ (x) = x length (niensS) ) ) ), switch is not itself immediately rejected. Instead it is modi- serial ( (dummyS -.~ 'I' it plays tim role of dummy statenlents. conslisling (map ndesigncxpN (niensS) ) ) ) fied so that any result it produces, whenever and if ever it Y is the "fixed-point finder."assigningS In so fat' ~as itcombine~ is reasonably ('K', repre- conslisting (), and nproedeclNS = is applied, is rejected. Hence our model is overtolerant in sentable it can be defined by nprogram : ACOs ➞ IAEs nassignexpNS) let Do", D '~, X" = pr~ that a mismatch will not lead to rejection if the procedure Y(F) = let z = separale(nullisl)else ~ nfunctiondesigNS),

and nforstatementNS = consdef (eonsli sting ,f ~ eonsletexp(D, X) = counsf~redex(neez' D,= X, niens D) F(z) and narilhexp = nexp code (bodyS) ~ ncode (derive (classifiedvariab lesS) N) let let Do, D, X = nlabeled(nstatementN '[') (bodyS) eons~redcx ('x '~ mirror ALGOL 60 in a correspondence that preserves and nBoolexp = nexp e.g. counsletexp ("let x = 2p - q", "x(x + 1)') = (Dog conslisting Z~ ALGOL 60'S structure. We have given an informal account co~Ytbin(~ ('f', conslisting (eombine('g', 'x'), 'y')) and ndesignexp = nexp at1*:- is never applied, or if it is exited unnaturally and thus ! "let x = 2p -- q parallel (), initialcon (typeS))) and nvariableNS = simpleS -~, nidentifierNS of the correspondence, and a formal account• + , . , x(~ + 1)" eombinelist ( ~for ', and nownarraydeclresetNS = i i,Ve stile{; wJlh two hst-proeesstng functmns, that are (L)))) vlementS -~ The correspondence suggests new ways of classifying (nlhsN (controlS), serial(map nownarraysegmcntreset (bodyS) ) needed later': consreeexp(D,X) -- eons~redex(nee D, X, consYredex combine (nidentifierN (ralorS), some of ALGOL 60'S features, and also suggests certain (nee D, niens D)) combinelist ( 'concatenate*', -where nownarraysegmentr esct NS ' = consIisting (map narilhexpN (randS) ) ) 2nd((z~z') ,z) map (nf orlistelementN) (forlistS) ) , serial (map nownarmyreset (neeS') ) generalizations and alterations that may be of interest to i tee map f L = null L --) ( ) e.g. consrecexp ("let x = x~+~ '', "x(x+l)")= clse --~ nfunctiondesigNS armngeaspseudoblock(D, X) ) ) where nownarrayresel J = language designers. In so far as the correspondence leads el se -~ f(hL) : mapf (tL) "let ree z = X2+~ and nlhsNS = simpleS A putativeresultNS -o resultvariantS (bodyS) where nforlistelementNS = iii e.g. map squ,are (1, 3, 7, 2, 3) = (1, 9, 49, 4, 9) x(x+l)" consassigner (ownvariant NJ , else --* nvariableS to better understanding of language structure the in- tea evades producing a result. Furthermore, a label denotes a progressions -~ combines ( 'parearray*, and nfunctiondesigNS = formal account of it suffices. labels (N, X) = consf~redex(N, X, map jump N) :l:'i un ip r, = (map :ts, l,, map 2ha L) eombinelist ('step*', nbplist (sizeS'), combinelist (nidentifier (tarotS), The formal account somewhat resembles a two-pass where e.g. teelabels ("L, M", "4,") = nassignexpNSmap (narithexp N) = conslisting (ownvariantNJ, map (delay. nexp) (randS) ) "let L = JL compiler from ALGOL 60 to IAEs. The half-way house is a This definition relies on the(initialS, inerS,fact terminalS)) that wheninitialcon (typeS)))) a wherefunction-trans- nidentifier NJ = needsapplying NJ -~ doJ ree select(p)(L) = null L --~ 0 and M = JM kind of analysis-tree that we call "abstract ALGOL•" It iterations where nbplistNS' = ownidentifier NJ --~ ownvariant NJ p(hL) -~ hL:seleet(p) (tL) combinelist ('while*', else ~ J exemplifies a technique that might be of value to language else ~ select(p) (t~) conslisting (map nboundpairNS') arrangeaspseudoblock (D , X) = counreeexp(D , labels(nee D, X) ) (narithexp N (rhsS) , where nboundpairNS' = and inilialeon A = A = 'real' -~ '0.0' designers, since it isolates decisions about what informa- else --~ nlabeled (nstatement (derive (classi fiedvariab lesS) N ) nBoolexpN (conditionS))) A = 'integer' -~ '0' tion must be conveyed from decisions about its written t,~i,: program-closure and so even when its result, namely NeW come functions for processing IAEs and defini- arrangeasbloek(D, D', D", X) = conslisting(ownnessS -~ ('- ~ ', '+ ~ ') else --~ A = 'Boolean' --~ 'false' combine( 'unitlist*', narithexpNS) else --~ map narithexpNS') appearance. tions, These are built up from the eonsmmtors for IAEs, consl etexp (D , eonsreeexp (parallel ( D',D") , labels (unee D", X) ) ) and nuncondstatementNLS = and transfer S = simple S --~ S = 'real' --~ ']loat' former is applied to the (arbitrarilyand nswitchdeelNS chosen) = argument nMlist, The "compiler" was itself expressed in terms of AEs combine2e.g. (roughly) ( 'assignandhold',composites -~ nclosedprogramNLS S = 'integer' -~ 'unfloat' consdef ( ) , arrangeasblock("let a = ~kl", "letp(x)=¢2", else --~ (parallel(), S = 'command' --~ combine (i.e. IAEs that make no use of imperative concepts). So also use t>he selectors and constructor for definitions, consdef (neeS, "letL=¢4 and M=q%", "$a")= ('in', 'null') this paper includes a nontrivial application of a "purely parallel (), combine: ( 'arrangeasarray ~, namely nee, niens attd consdef. "let a = ~ S = 'label' -~ '[' functional" programming language to language processing. (jumpingS --~ ndesignexpN (bodyS) conslisting (u (conslisting ('1 ', combiune2(F,X, Y) = eombine(combine(F,X),Y) let ree p(z) = ¢2 else else --) combine('in', S) ('1') length (niensS) ) ) ), Acknowledgments. This paper was written while I (bodyS) is produced, the context is never resumed and so e.g. combine~("D .... sin","k~-/2") = "{Dsiun}[k~-/2]" and L = ¢4 serial ( (dummyS -.~ 'I' else a,5: nullist, rejection does not occur unless, orconslisling until,(map ndesigncxpN (niensS) ) ) ) the argumcnt is and M = 4,5 conscondexp' ('atom', worked for Christopher Strachey. It is based on some assigningS ~ combine~ ('K', conslisting (), and nproedeclNS = combined (F ,X , Y ,Z ) = combine (combine2 (F ,X , Y ) ,Z) let L = JL (t, combine('B', t))) lectures that George Coulouris invited me to contribute nassignexpNS) let Do", D '~, X" = i eombinelist (F,X) = combine (F,conslisting (X)) and M = JM (simpleSelse ~ nfunctiondesigNS),-.~ nexpNS where t = transform(rand S) in Spring 1963 to a series on the "Logical Foundations of code (bodyS) ~ ncode (derive (classifiedvariab lesS) N) .... e.g. combmel*st( f ,( a+b , c+d )) = f(a+b,c+d)" (L)))) where needapplying N = needsapplying NO (bodyS) Programming" at the University of London Computer where tee nassignexpNS = putativeresultandneedsapplying N cons~redex (J,X,Z) = combine (consMxp (J ,X),Z) arrangeasblock p(D, D", X) = arrangeasbloek(D, parallel(), D",X) else --~ nlabeled (nstatement (derive (classi fiedvariab lesS) N ) Unit. W. H. Burge, C. Strachey and M. Woodger read combine2 ( 'assignandhold', and putativeresult N = putativeresult NU e.g. counsf~rede*(' u","uactually (a+u)","b+c") = "{Xu.u(a+u) }[b+c]" applied. ('1') (bodyS) putativeresultandneedsapplying N parts of an earlier version and pointed out many errors There now follows the definition of the semantic function (simpleS -.~ nexpNS n~: the cheek never occurs. Hence tile identity function serves i: i e "u(a+u) where u = b+c" Do", and monadicvariant J = (J = '+') --~ '+M' and obscurities• nprogram, with its auxiliaries nforlistelement, nexp, etc. else --~ nassignexpN(rhsS)), Do", (J = '- ') --~ '-- M' nlhsN (lhsS) ) consdef(neeS, e,g. consYredex("L","a:(b:L)") = "YXL.a:(b:L)" and nlabeled(ncategory) (S) = conshexp (conslisting (formalsS) , nprogramS = arrangeasblock'(unlabeled(ncIosedprogramNo'[')S) In the definition of transfer just above, the complication i.e. (roughly) "L where ree L = a:(b:L)" else taggedS--~ -+ let Do, D, XnassignexpN(rhsS)), = nlabeled(ncategory) (bodyS) (types = 'command' -~ X where ree else -~ cons~redex (resultvariant (neeS), in the nonsimple case arises from an irregularity in ALGOL separatedelay (X) = conshexp (conslisting (),X) avoidsnclosedprogramNLS unwanted = side-effects;Do, parallel(consdef(labelS, delayX), D), labels it is used when parameters else ~ ncategoryS X, 60, namely its treatment of parameterless type procedures e.g. delay("f(a) + f(b)") = "~().f(a) + f(b)" blocks -.~ let Do, D, D', Xo = nhead (N, derive (cIassifiedvariablesS) N) (headS) and nhead(N, N') (S) = initialcon (typeS))) occurring as procedure parameters. The predicate atom tli equally well as transfer function. do (X) = combinelist (X, ()) let Do', D' = map parallel where X = consf~redex(d, is the union of real integer and Boolean. e.g. do("x',) = "x( )" let Do", D", X" = nopenprogram(pnovN)L(bodyS) arrangeasblocU (parallel (map nspecN consdef(neeS, (unzip (map nrecdeclN' (select rec S) ) ) (parallel(Do, Do"), The following alternative treatment of open programs conscondexp ( P,X) = do (combiunelist (combine ('if', P), map delay X) ) (parallel (Do': map nnonrecdeclN (select ownness S) ), (specpartS)), parallel(), with non-null tails avoids (a) inserting a jump after a Relaxed Deadline e.g. counscondexp("a=O","a","l/a") = nlhsN parallel(map(lhsS) nnonrecdeclN (select( ~ .ownness) ) S) ). D 't ' are called by arrangeasbloek(D,D',value. D ~, serial(Xo,X") ) ) dummy, assignment or procedure statement, or in a "ff(a=O)fX( ).a, x().l/a) ( )" D', X"), for else --~ unopenprogramNLS serial(map nownarraydeclresetN (select(arraydecluownness) S) ) ) Z) compound or conditional containing no labels. (b) in- delayed(F) = combiune( 'B', F) where nopenprogramNLS = ACM Special Interest Symposium on the where nnonrecdcclNS = typedeclS ~-~ ntypedeclNS where nvalue or = consdef(J, combine('separate', doJ)) serting a label when the following statement is already e.g. delayed("float") = "Bfloat" null (tS) --~ nlabeled (nstalementNL ) (hS) Reprogramming Problem arraydecl S -+ narraydeclNS and nspecNS = parallel (map nspec'N (bodyS) ) labeled. i.e. (roughly) "f where f(x) = float.x" else --~ let j, N', N" = takenewIabelN and nrecdeclNS = switchdecl S ~ nswitchdeclNS where nspeePNJ = 1-3 June at Nassau Inn, Princeton, New Jersey let Do, D, X = unlabeled(nstatementN~j)(hS) ed: serial(X) = delay(serial ' (X,conslisting( ) ) ) procdecl S -÷ nprocdeclNS consdef(J, let Do, D, X = nlabeled(nstatementN'I')(hS) conshexp (conslisting (formalsS) , islet D(, definedD', X' = nopenprogram(punovN~')L(tS) by S,~onsored jointly by ACM and Applied assigmtndhold where where serial' (X,Z) = nullX ~ Z ntypedecINS = combine ( (needsapplyingNJ --~ delayed let Do', D', X' = nopenprogram(pnovN)L(tS) and .... (parallel(Do, Do'), Data Research, Inc. nlabeled(ncategory)• parallel (map ntypedecl'(S) (neeS)) = null D ~ parallel(Do, Do'), D', serial X, X') else --~ serial ~(tX,combiune (hX,Z) ) parallel(D, eonsdef(j, delayX'), D'), else --, I) (transfer) e.g. serial("R", "S", "T") = "~( ).T(S(R( )))" where ntypedecl~J = tagged(2ndS) ~ let Do, D, X = nlabeled(nstatementN (label(2ndS) ) ) x) (specifierS) Summaries of papers, 1500 words long, i.e. "7'.S.R" eonsdef ( (ownnessS ~ ownvariantNJ (J)) (hS) will be accepted as late as April ls.t and nstatementNLS = else -~ d), where ree parallel(Do, Do'), parallel(D, D'), X full papers by May 1st. Summaries m THE CONSTANTS AND PRIMITIVES OF ALGOL 60 • I Nit Iel(D) = let J = map nee D condS --~ combine ('separate', else --~ let j, N , takenewlabel N duplicate, and later the full papers in nexp = ncond(nsimp(nlypeprimary) ) and assignandhold(x)Z = map niens D letD~,D,X = (y) = let initialconx (typeS))) = real y -~ float x let Do, D, X = nlabeled(nstatementN'j) (hS) duplicate, should be addressed to where ncond(ncategory)NS = I5. R. Wickenden, Chairman consdef (conslistingJ, counslistingZ) 2armedS ~ nlabeled(nuncondstatementNL) (lstarmS) and narraydeclNS = let Do, Do', X' = nopenprogTum(pnovN")L(tS) = 'command' -~ X Reprogramming Conference (types condS -~ conseondexp (n Boolexp N (conditionS), parallel ("let u = a+b", larmedS --+ uunlabeIed(loopiung (armS) ~ nf orstatementN let J, Z = unzip(map narraysegmentN (bodyS) ) parallel(Do, Do'), parallel(D, consde$(j, delayX'), D'), X % Applied Data Research, Inc. (ncategoryN (lstarmS), "let v = c+d", letelse -+ nuneondstatementNL) where narraysegmenlNS' = 150 Route 206 Center taggedS -+ Do, D, X = nlabeled(ncategory) (bodyS)Princeton, N. J. 08540 "let W = e+f") = (armS) neond(ncategory) N (2ndarmS))) Conclusion conslisting (ownnessS ~-~ map ownvariantN and nsimp (nprimary)NS = Summaries must be accompanied by Author's biography "let (u, v, w) = (a+b, c+d, eTf)" let Do', D', X' = giving full professional background. (neeS') 1compounds ~ combine (monadicvariant (raterS), An abstract language based on Churct!'s X-notation and 2armed ~ nlabeled(nstatementNL) (2ndarmS) else --~ nee S'), integer y --~ unfloat a: ondexp'(P, F) = consXexp('x', conseondexp(do P, map do F)) larmed ~ parallel(), parallel(), 'I' eons~redex ( ' A ', nsimp (nprimary) (randS) ) aa abstract machine that interprets it has been described. General conference information may be obtained by writing where do(f) = combine(f, ~x') (parallel(Do, Do'), 2compounds ~ combinelist (raterS, The language consists of expressions called "imperative to Mrs. L. Becker, Applied I)ata Research, Inc• eounscondexp' ("P tJ q", "f", "g.h") = constisting(map(K"separate A ") parallel(D, D'), map (nsimp (nprimary) ) expressions" (IAEs). Like Church's systems, No Registration Fee; Only Charges for Meals -~ (nee S')) else cons~redex (resultvariant (neeS), The correspondence given in this paper associates with "~x.(P U q) (x) --~ f(x) (lstrandS, 2ndrandS)) I conscondexp (n Boolexp (conditionS) , (X, X ') ) ) combine2 ( ' expandtoarray' , few structural rules, but they are enough to else ~ (g.h) (x)" and ntypeprimaryNS = constS -+ S loopingS Do,--~ serial (nforstatementNS, L) parallel(consdef(labelS,nbplistN (sizeSL delayX), D), labels simpleS .-~ nvariableNS (X) = combine ('J', X) else --~ nuuncondstatemenlNLS 'x')) Number 3 / March, 1965 Communications of the ACL'[ 165 Booleanelse --~ nexpS y --~ in(Boolean)x Communications of the ACM 8 / Number 3 / March, 1965 163 164 Communications of the ACM Volume 8 / Number 3 / March, 1965 each ALGOL 60 text an IAE in which the identifiers occur- else ~ ncategoryS 2nd((y~x),x) X, ring free are drawn fi'om the following three groups. and nhead(N, N') (S) = initialcon (typeS))) In this subsection and the four preceding ones we have Group I consists of the arithmetical, Boolean and string con-- let Do', D' = map parallel where X = consf~redex(d, characterized the abstract objects comprising the "domain slants. An arithmetical constant is an unsigned number as defined (unzip (map nrecdeclN' (select rec18 S) ) ) arrangeasblocU (parallel (map nspecN in the AlmoL 60 report, and designates an integer or a (rationM) of(parallel reference" (Do': that map our nnonrecdeclNanalysis imputes (select to AL(~OL ownness 60. TheS) ), (specpartS)), real. However the integers also include '-~' and '+ co ', used in characterization has been partly formM and partly in- the initiM array bounds of own arrays. The Boolean constants are parallel(map nnonrecdeclN (select( ~ .ownness) S) ). D 't ' i; formal, taking for granted such things as numbers, propo- 'true' and 'false' and designate the truthvMues. The string D', X"), constants are certain character-strings whose first and last items sitionalserial(map relations, nownarraydeclresetN ere? Ia the next subsection (select(arraydecluownness) we turn to the S) ) ) Z) are ' ~ ' and ' " ' , respectively; such a constant designates the mainwhere (.epic nnonrecdcclNS of this paper, namely= typedeclS how ekLGOL ~-~ ntypedeclNS 60 texts can where nvalue or = consdef(J, combine('separate', doJ)) string obtained by removing its first and last items. (It would be be construed as IAEs referringarraydecl to these abstractS -+ narraydeclNS objects. possible to avoid an infinity of primitives by considering each and nspecNS = parallel (map nspec'N (bodyS) ) and nrecdeclNS = switchdecl S ~ nswitchdeclNS written tmmbcr and each charaeter-string as having internal r In [9], BShm is concerned with the formal treatment of this where nspeePNJ = applicative structure. These might conveniently use such nmnber- topic. procdecl S -÷ nprocdeclNS consdef(J, where ntypedecINS = combine ( (needsapplyingNJ --~ delayed Volume 8 / Number 2 / February, 1965 • parallel (map ntypedecl'Communications (neeS)) of the ACM 97 else --, I) (transfer) where ntypedecl~J = (specifierS) eonsdef ( (ownnessS ~ ownvariantNJ (J)) else -~ d), where ree combine ('separate', nexp = ncond(nsimp(nlypeprimary) ) initialcon (typeS))) where ncond(ncategory)NS = and narraydeclNS = condS -~ conseondexp (n Boolexp N (conditionS), let J, Z = unzip(map narraysegmentN (bodyS) ) (ncategoryN (lstarmS), where narraysegmenlNS' = neond(ncategory) N (2ndarmS))) conslisting (ownnessS ~-~ map ownvariantN and nsimp (nprimary)NS = (neeS') 1compounds ~ combine (monadicvariant (raterS), else --~ nee S'), eons~redex ( ' A ', nsimp (nprimary) (randS) ) 2compounds ~ combinelist (raterS, constisting(map(K"separate A ") map (nsimp (nprimary) ) (nee S')) combine2 ( ' expandtoarray' , (lstrandS, 2ndrandS)) I and ntypeprimaryNS = constS -+ S nbplistN (sizeSL simpleS .-~ nvariableNS 'x')) else --~ nexpS

164 Communications of the ACM Volume 8 / Number 3 / March, 1965 Landin’s description of ALGOL 60

Virtues ‣ a major example of a correspondence between a real programming language and a semantic notation - concisely documented Landin’s expert analysis - demonstrated the use of AEs (ISWIM) as a meta-language Drawbacks ‣ correspondence not tested/validated - no tool support (?) ‣ sharing of addresses not defined ‣ fixed-point operator Y defined in terms of assigners

19 Landin and Strachey (1960s)

Denotational semantics (1970s)

A current project

20 Christopher Strachey (1916–1975)

Towards a formal semantics. In Proc. IFIP 1964 Working Conf. on Formal Language Description Languages, 1966. ‣ cited by Landin as an alternative to IAEs - “to find, for each command, an AE denoting the SECD-transformation it effects” ‣ introduces L-values and R-values - an L-value “denotes an area of the store” ‣ refers to the fixed-point operator Y as “paradoxical” - cites Landin’s “computing procedure” for it

21 Assignments

‣ Without side-effects:

‣ With side-effects:

22 Strachey’s 1960s approach

Virtues ‣ used to give a correspondence between a developing major programming language (CPL) and a semantic notation ‣ applicative definition of addresses, stores, assigners - avoided the need for an abstract machine Drawbacks ‣ meta-language left informal ‣ fixed-point operator Y left “paradoxical”

23 Landin and Strachey (1960s)

Denotational semantics (1970s)

A current project

24 Autumn 1969

Dana Scott: Some reflections on Strachey and his work. Higher-Order and Symb. Comp. (2000) 13: 103–114 ‣ “The semester at […] was a very intense time, working with Strachey, meeting Peter Landin, David Park, John Reynolds, and many others. As I recounted in my Turing Lecture, I did not intend at all to construct models for the type-free λ-calculus…”

25 Scott–Strachey semantics

D. S. Scott, C. Strachey: Towards a mathematical semantics for computer languages. Technical Monograph PRG-6, Oxford Univ. Comp. Lab, 1971 ‣ least-fixed point operator Y no longer ‘paradoxical’ ‣ correspondence between program phrases and their denotations in Scott-domains (originally lattices, later cpos) ‣ separation between environments ρ∊Env and stores σ∊S

- C : Cmd → (Env → (S → S))

- E : Exp → (S → (T × S))

26 Scott–Strachey semantics

D. S. Scott, C. Strachey: Towards a mathematical semantics for computer languages. Technical Monograph PRG-6, Oxford Univ. Comp. Lab, 1971 ‣ Abbreviations:

- (f ◦ g)(σ) = f (σ′) when g(σ) = σ′ - (f ∗ g)(σ) = f (β)(σ′) when g(σ) = (β, σ′) monadic - (P β)(σ) = (β, σ) notation!

‣ C⟦γ0 ; γ1⟧ = λρ. C⟦γ1⟧(ρ) ◦ C⟦γ0⟧(ρ)

‣ C⟦ε → γ0 , γ1⟧ = λρ. Cond(C⟦γ0⟧(ρ), C⟦γ1⟧(ρ)) ∗ E⟦ε⟧

27 Scott–Strachey semantics

PDM: The mathematical semantics of ALGOL 60. Technical Monograph PRG-12, Oxford Univ. Comp. Lab, 1974 ‣ -style

- C : Sta → (Env → (C → C)) where C = (S → S)

- R : Exp → (Env → (X → (K → C))) where K = (V → C)

- γ1 || γ2 || θ = γ1{γ2{θ}}

‣ C⟦Sta ; StaL⟧ = λρ. λθ. C⟦Sta⟧ρ || C⟦StaL⟧ρ || θ

‣ C⟦if Exp then Sta1 else Sta2⟧ = λρ. λθ.

R⟦Exp⟧ρ “boolean” { λβ. β → C⟦Sta1⟧ρθ, C⟦Sta2⟧ρθ }

28 12

SEMANT I C F UNCT I ONS c o m p i l e r t : P r o g . 0 . 0 . l e t 1 = M a k e T y p ( " f n " , M a k e T y p ( " r e a l " , ? ) ) i n " l et 2 = M a k e T y p ( " f n " , M a k e T y p ( " i n t e g e r " , ? ) ) i n l e t l = 0 [ Ab s / 1 / i d " a b s " ] [ S i g n / 2 / i d " s i g n " ] [ S q r t / 1 / i d " s q r t " ] [ S i n / 1 / i d " s i n " ] [ Co s / 1 / i d " c o s " ] [A r c t a n / 1 / i d " a r c t a n " ] [ L n / 1 / i d " l n " ] [ E x p / 1 / i d " e x p " ] [ E n t i e r / 2 / i d " e n t i e r " ] i n

sw i t c h l a b e l o f t i n 13 d e f C [ [ t : S t a ] ] §= sw i t c h l a b e l o f t i n § c a s e " S t a " : P [[S t a ] ] l 0 c a s e " b e g i n De c L D e f L S t a L e n d " : $ l e t < * 1, *1> = ( I * de c [ [DecL] ] , T * de c [ [DecL] ]> i n l e t < * 2, *>2 = < I *d e f [ [De fL] ]> T *de f [ [DefL] ]> i n d e f lPe t [ [ t3 ]] = < =I * l ab[ [St aL] ] ,semantics T * l ab[ [StaL] ]> i n I n d li es tt i nc a t = *<2 I c*alta b[*[3)t ]] ,? ,T* lab[[t ]]> i n PDM: The Amathematicalr eAar e||a || semantics of ALGOL 60. Technical Monograph l . D* [[D PRG-12,e c L ] ] Oxford[ ? / ? Univ./ Comp.* 1c a t Lab, * 2 1974c a t * 3] || . C [ [ t ] ] [ ( f i x * . G [ [ t ] [ * / * / * ] ) / * / * ] || * 1. A r e a || ‣ Continuations-style 2 . l e t 1 = [ * 1/ * 1/ * 1] i n d e-f C C*: Sta[[t →: S (tEnva L ]→]l e (tC →= 1 Cs=))w S iwhereet tcAhr e aCl( a= b 1(eS) {→l o} f S )i nt i n § C * [[S t a L ] l ( f i x * . l e t 2= 1 [ * / * 2c a t * 3/ * 2c a t *3n] i - R : Exp → (Env → (X → (K → C))) whereH *K[[ D=e (fVL →]]2 C)c a t G * [[S t a L ] 2 2 1 ) c a s e " S t a ; S t a L " : C[ [S t a ] ] | | C * [[ S t a L ]] || γ || γ || θ = γ {γ {θ}} / *2 c a t *3 / *2 c a t * 3] || 1 $c a-s e " 1 S t a2 " : 1 2 C [[S t a ] ] ‣c a Cs e⟦"Stab e g; iStaLn S⟧t =a L λρ e. nλθd ". : CC⟦*Sta[ [S⟧tρaL ||] ] C ⟦StaL⟧ρ || θ

‣c a Cs e⟦"ifi fExp E xthenp t h e Stan 1S elset a 1 eStal s 2e⟧ =S tλρa 2. "λθ: . R [ [ E x p ]] " b o o l e a n " { . C [ [S t a1] ] , C [ S t a 2 ]] } R⟦Exp⟧ρ “boolean” { λβ. β → C⟦Sta1⟧ρθ, C⟦Sta2⟧ρθ }

28 c a s e " I d e :S t a " : l e t < , > = [ [ I de ]] i n H o p ( ) c a s e " g o t o E x p " : J [[Exp] | " l a b e l " || . J u m p ( ) c a s e " V a r : = A s s L " : l e t = M a i n ( T v a r [[V a r ] ] ) i n A [[ t]] <> || c a s e " f o r V a r : = F o r L do S t a " : l e t = T v a r [ [Var ] ] i n M a i n = " b o o l e a n " ? , F * [[F o r L ]] ( Ma i n ) ( V [[Var ] ] )(P[[Sta] ] ) || c a s e " I d e ( E x p L ) " : Co e r c e ( [ [ I d e ]])( M a k e T y p ( " r t " , ? ) ) " e v " || . A p p l y R t ( ) (U*[[E x pL ] ) { }

c a s e " " : $ VDM semantics

H. Bekić, D. Bjørner, W. Henhapl, C. B. Jones, P. Lucas: A formal definition of a PL/I subset. Tech. Rep. TR 25.139, IBM Lab. Vienna, Dec. 1974 ‣ Combinators: abbreviations with fixed behaviour (definitions dependent on the domains of denotations)

monadic notation!

29 VDM semantics

W. Henhapl, C. B. Jones: A formal definition of ALGOL 60. In “The Vienna Development Method: The Meta-Language”, LNCS 61: 305–336, 1978; and Chapter 6 of “Formal Specification & Software Development”, Prentice-Hall, 1982 ‣ M: Stmt → ENV => ‣ M: Expr → ENV => VAL ‣ M[mk-Compound()](env) = M[s1](env); M[s2](env)

‣ M[mk-If(e,th,el)](env) = def b: M[e](env); if b then M[th](env) else M[el](env)

30 156 VDM AND PROGRAMM I NG LANGUAGES 156 VDM AND PROGRAMM I NG LANGUAGES

66..33..33 SwSwi ticthc hD eDc el acrlaatriaotn ison s

SSwwi it ct hcdhedcelc l : : : :s - isd-:iIdd: I d s - e xsl-:eExx pl :r E+ x p r +

WWFF[ [mmk k- S-wSiwticthcdhedc el (c,le(x,le)x] l( )s e]n(vs)e n=v ) = ( e x e l em s e x l ) ( TP [ e x ] ( s e n v ) =LABEL ) ( e x e l em s e x l ) ( TP [ e x ] ( s e n v ) =LABEL ) t y p e : Sw i t c hd e c l STAT I CENV Boo l t y p e : Sw i t c hd e c l STAT I CENV Boo l

M [ m k - Sw i t c h d e c l ( , e x l ) ] ( e n v ) = M [ ml ke t- Sfw(ii ntdc,hcdaes c) l=( , e( ixf l )1 ]<(i endn

6 . 3 . 4 P r o c e du r e De c l a r a t i on s — a l r e a d y t r e a t e d i n s e c t . 6 . 2 . 2

6 . 4 STAT EMENTS

6 . 4S t mSt T AT EME:N:T Ss - l p : I d - s e t s - s p : Un l a b s t m t Un l a b s t m t = Comp s t m t | B l o c k | A s s i gn | Go t o

S t m t : :D umsm-yl p : I d -| sCeotn d s t ms t- s p| :FUonr l a b sI t mP rt o c s t m t Un l a b s t m t = Comp s t m t | B l o c k | A s s i g n | Go t o " S t a nd a r d " t ype s : Dummy | Co n d s t m t | Fo r I P r o c s t m t

WF : Un l a b s t m t VDM STAT I semanticsCENV Boo l A"LSGtOaLn d6a0r d " t ype s : ALGMOL: 60 Un l a b s t m t STMT ENV => 159 W. Henhapl, C. B. Jones: A formal definition of ALGOL 60. 163 In “The Vienna Development Method: The Meta-Language”, LNCS 61: 305–336, 1978; 6 . 4 . 6 Co n d i t i o n a l S t a t eme n t s 6 . 4and.W1FE Chapter:: CUoEmnx 6plp ofoar u b“Formaln sdt m SS tSpecificationtT aAtTe mISeCTnEA t&NTs SoftwareVI C EN V BDevelopment”, oo l Boo l Prentice-Hall, 1982 M: Stmt ENV => ‣CMToP:nd :s t mUEt n x lp: :a rbs s- tt→em sStt:T EAxpT r I SCTsEM-NTt hVE:SN tVm t (=T>sy-pe el :S t m| t LABEL ) Comp s t m t : : S t m t * ‣M:M: E xExprp r → E XENVPR E=>NV VAL=> VAL Th e e l s e s t a t eme n t i s a l wa y s p r e s e n t , i f n e c e s s a r y t h e t r a n s l a t o r i n s e r t s 6 . 4 . 1 Comp o u n d S t a t eme n t s a nu l lM[mk-Compound()](env) s t a t eme n t . = ‣M [ m k - C omp s t m t ( s t l ) ] ( s t e n v ) = M[s1](env); M[s2](env) 6 . 5 . 1 f oArr ii t=hl metot li ecn sCt ol ndsot aMn[ ts s- s p ( s t l [ i ] ) ] ( s t e n v ) WCF o[ mmkp- Csotnmd stt m t : (:e ,t Sh ,et ml )t] *( s e n v ) = T P [ e ] ( s e n v ) =BOOL M[mk-If(e,th,el)](env) = 6 . 4‣M. 2[ m k - CBolnodcs kt mst ( e ,—t h , ae ll )r ]e (as dt myt e ntvr) e a= t e d i n s e c t . 6 . 2 . 1 T y p edefc o n b:s t M[e](env);B o o l c o n s t A r i t hmc o n s t M [ ml ke t- C( o, emnpv ,sc atsm) t=( ss tmlt )e n]v( si nt e n v ) = Bo o d eifl fc o b nb sthent M[th](env): M [ Be ]o( eonlv , c a s ) ; else M[el](env) f o r i = l to l e n s t l do M [ s - s p ( s t l [ i ] ) ] ( s t e n v ) A r ii tf hbm ct hoe nn sM [ts - s p ( t hR) ]e(as tlmct oe nnv s) te l s e M [ sI-ns pt( ce lo) ]n(ss ttm t e n v )

30 6 . 4 .R7e aF ol rc oSnt ast etme n t s Re a l 6 . 4 . 2 B l o c k s — a l r e a d y t r e a t e d i n s e c t . 6 . 2 . 1 I n t c o n s t I n t Fo r s - c v : S i mp l e v a r s - c v t p : A r i t hm s - f l : F o r e l em+ s - b : B l o c k F o r e l em E x p r e l em | Wh i l e e l em | S t e p u n t i l e l em E x p r e l em Ex p r Comm e n t Th e a b s t r a c t s y n t a x c on t a i n s t h e s ema n t i c ob j e c t s Wh i l e e l em s - i n : E x p r s - wh : E x p r r a t h e r t h a n S t e p u n t i l etl heme i r s -ri en :pE rx per s e ns -tsat :tEix op rn s .s - u n : E x p r

Th e b o d y o f t h e a b s t r a c t f o r m o f a f o r s t a t eme n t i s a l wa y s a b l o c k ; i f no t TpPr e[sme nkt - Bi no ot hl ec ocnonsc tr e(tbe v )f o]r m( s ei tn vi s) g=e n eBrOa tOe dL b y t he t r a n s l a t o r . TP [ m k - R e a l c o n s t ( r v ) ] ( s e n v ) = REAL WF [ m k - F o r ( c v , c v t p , f l , b ) ] ( s e n v ) = TP i[sm- skc-a lIanr (tccv ,osne nsv )t ( i cvv )t p]=(TPs[ec vn] v( s)e n v )= I NT

W F [ m k - E x p r e l e m ( e ) ] ( s e n v ) = TP [e ] ( s e n v ) A r i t hm M [ m k - B o o l c o n s t (bv ) ] ( e x e n v ) = b v WF [ mk - Wh i l e e l em ( i n , wh ) ] ( s en v ) = M [ m k - R e a l c on s t ( r v ) ] ( e x e n v ) = r e p r e s e n t ( r v ) T P [ i n ] ( s e n v ) A r i t hm TP [ wh ] ( s e n v ) = BOOL M [ m k - I n t c o n s t ( i v ) ] ( e x e n v ) = t e s t ( i v ) WF [ m k - S t e p u n t i l e l em ( i n , s t , un ) ] ( s e n v ) = TP [ i n ] ( s e n v ) A r i t hm TP [ s t ] ( s e n v ) A r i t hm T P [ u n ] ( s e n v ) A r i t hm 6 . 5 . 2 V a r i a b l e Re f e r e n c e s M [ m k - F o r ( c v , c v t p , f l e l , b ) ] ( s t e n v ) = f o r i = l to l e n f l e l do M [ f l e l [ i ] , c v , c v t p , b ] ( s t e n v ) V a r r e f : Va r T y p e s f o r r ema i nd e r o f t h i s s ub - s e c t i on : Va r = S i mp l e v a r | Su b s c r v a r MS: i Fmopr ell eemv a rVa r T=y p eS i mB pl olc ke v a SrTbMTnEN V | =>S i mp l e v a r v S i mp l e v a r b n : s - nm : I d S i m p l e v a r v : s - nm : I d Su b s c r v a r = Su b s c r v a r b n | Su b s c r v a r v Su b s c r v a r b n : s - nm : I d s - s s c l : Sub s c r s Su b s c r v a r v : d - nm : I d s - s s c l : Sub s c r s Su b s c r s : E x p r +

Comme n t Th e d i s t i n c t i o n i s ma d e b e t we e n r e f e r e n c e s t o " byn ame " (bn) f o r ma l p a r ame t e r s a nd v a l u e s (v ). Th e l a t t e r c l a s s i n c l ud e s " b y v a l u e " f o r ma l p a r ame t e r s a nd no r ma l v a r i a b l e s .

W F [ m k - S i mp l e v a r b n ( i d ) ] ( senv ) = s e n v ( i d ) Type W F [ m k - S i mp l e v a r v ( i d ) ] ( s e n v ) = s e n v ( i d ) Type Further reading

PDM: VDM semantics of programming languages: combinators and monads. Formal Aspects of Computing (2011) 23: 221–238 C. B. Jones: Semantic descriptions library homepages.cs.ncl.ac.uk/cliff.jones/semantics-library/

‣ searchable on-line resources new! - descriptions of ALGOL 60 in various frameworks ‣ scanned manuscripts - VDM descriptions of programming languages - VDL description of PL/I - …

31 32 Landin and Strachey (1960s)

Denotational semantics (1970s)

A current project

33 Component-based semantics

open-ended collection fundamental programming constructs (funcons)

translation (correspondence) components-off-the-shelf

evolving languages

34 A60-4.cbs

Language "ALGOL 60"

Section 4 Statements

Syntax S: statement ::= ( variable ':=' )+ expression | 'go' 'to' designational-expression | empty | identifier | identifier '(' actual-parameter-list ')' | label ':' statement | 'begin' compound-tail | block-head ';' compound-tail | 'if' expression 'then' statement | 'if' expression 'then' statement 'else' statement | 'for' variable ':=' for-list 'do' statement Syntax compound-tail ::= statement ( ';' statement )* 'end' Syntax block-head ::= 'begin' declaration ( ';' declaration )* Syntax FL: for-list ::= for-list-element ( ',' for-list-element )* Syntax FLE:for-list-element ::= expression | expression 'step' expression 'until' expression Component-based| expression 'while' expression semantics

Semantics execute[[ _:(statement ( ';' statement )*) ]] : commands

Rule execute[[ S1 ';' S2 ...]] = sequential(execute[[S1]], execute[[S2 ...]])

Rule execute[[ 'if' E 'then' S1 'else' S2 ]] = if-true(evaluate[[E]], execute[[S1]], execute[[S2]])

Rule execute[[ I ':=' E ]] = assign(bound-value(I), transfer(type(bound-value(I)), evaluate[[E]])

35

Page 1 Reusable components

Fundamental constructs (funcons) ‣ correspond to programming constructs - directly (sequential, scope, …) - special case (if-true, apply, assign,…) - implicit (bound-value, …) ‣ and have (when validated and released) - fixed notation - fixed behaviour specified/proved once and for all! - fixed algebraic properties

36 PLANCOMPS project (2011-2015)

Foundations ‣ component-based semantics, bisimulation [Swansea] ‣ GLL parsing, disambiguation [RHUL] Case studies ‣ CAML LIGHT, C#, JAVA [Swansea] Tool support ‣ IDE, funcon interpreter/compiler [RHUL, Swansea] Digital library ‣ interface [City], historic documents [Newcastle]

37 Summary

ALGOL 60

PLANCOMPS

Henhapl & Jones funcons combinators Landin λ-notation + Y + J + ⇐ PDM λ-notation + Y abstract machines Scott-domains modular SOS foundations

38