Landin-Seminar-2014
Total Page:16
File Type:pdf, Size:1020Kb
On correspondences between programming languages and semantic notations Peter Mosses Swansea University, UK BCS-FACS Annual Peter Landin Semantics Seminar 8th December 2014, London 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.