An algebraic approach to syntax, semantics and compilation

In this thesis, we develop an algebraic strategy and tools for modelling and proving the correctness of the process of compiling one programming language into another. We deal with three topics: the syntax of programming languages; the semantics of programming languages; and the correctness of compiling one language into another. We begin by considering how we can formalise commonly used language practices so that we can algebraically specify the syntax of a language. Our rst step in this process is to apply a variation of the established technique of transforming the context-free grammar of a language into a closed term algebra. Next, we design equational de nitions of additional functions that act as a lter for the contextsensitive features of the language. To reduce the work involved in devising such speci cations, we provide parameterised descriptions of commonly occurring language features. We illustrate the practicality of these modular methods by considering the algebraic speci cation of a range of programming languages and constructions. Having established the viability of algebraic speci cations for de ning the syntax of programming languages, we then turn to their semantics. We develop an algebraic method for de ning operational semantics which is modular and computable. The key to this semantical description is the employment of a notion of time by means of a simple clock to enumerate the sequences of states produced by executing a program. We de ne the semantics of programs in terms of the behaviour of a sequence of atomical program constituents. The execution of each atomic program provides the next state in the execution sequence. We use functions that decompose the syntax one step at a time to determine which atomic program we should execute at each moment in time to simulate the behaviour of the entire program. We illustrate our technique with a large range of examples. Finally, we examine the problem of how we can describe the process of compilation, and what we have to do to prove its correctness. We show how we can structure compilation using hierarchies of algebras, and how we can use equational methods to determine correctness. The basis of our method of compiler correctness lies in establishing correctness over just one step of time. We illustrate our technique with a case study of translating a high-level while language into instructions for a low-level register machine.

[1]  D. J. B. Bosscher Term Rewriting Properties of SOS Axiomatisations , 1994, TACS.

[2]  Dana Scott,et al.  Mathematical concepts in programming language semantics , 1899 .

[3]  Emil L. Post Finite combinatory processes—formulation , 1936, Journal of Symbolic Logic.

[4]  Emma van der Meulen Deriving Incremental Implementations from Algebraic , 1991, AMAST.

[5]  Heinz Rutishauser,et al.  Automatische Rechenplanfertigung bei programmgesteuerten Rechenmaschinen , 1952 .

[6]  Joseph Sifakis,et al.  The Algebra of Timed Processes, ATP: Theory and Application , 1994, Inf. Comput..

[7]  James W. Thatcher,et al.  More on Advice on Structuring Compilers and Proving them Correct , 1981, Theor. Comput. Sci..

[8]  B. J. Mailloux,et al.  Report of Algorithmic Language ALGOL 68 , 1969 .

[9]  Friedrich L. Bauer,et al.  Report on the algorithmic language ALGOL 60 , 1960, Commun. ACM.

[10]  Andrew Richard Martin The specification and simulation of synchronous concurrent algorithms , 1989 .

[11]  Yuri Gurevich,et al.  Algebraic Operational Semantics and Modula-2 , 1987, CSL.

[12]  T. B. Dinesh Typechecking with Modular Error Handling , 1996 .

[13]  Christine Choppy,et al.  A Lisp Compiler for FP Language and Its Proof via Algebraic Semantics , 1985, TAPSOFT, Vol.1.

[14]  Jan A. Bergstra,et al.  Uniform Algebraic Specifications of Finite Sets with Equality , 1991, Int. J. Found. Comput. Sci..

[15]  John McCarthy,et al.  Towards a Mathematical Science of Computation , 1962, IFIP Congress.

[16]  Donald E. Knuth,et al.  Structured Programming with go to Statements , 1974, CSUR.

[17]  B.v. Karger Aspects of Proving Compiler Correctness , 1990 .

[18]  Hans Langmaack,et al.  The Formal Termination Problem for Programs with Finite ALGOL 68-Modes , 1979, Inf. Process. Lett..

[19]  Dino P. Oliva A Veri ed Compiler for Pure PreScheme: Final Report for Contract Number F19628-89-C-001 , .

[20]  Bruno Courcelle,et al.  Attribute Grammars and Recursive Program Schemes I , 1982, Theoretical Computer Science.

[21]  Rod M. Burstall,et al.  The algebraic theory of recursive program schemes , 1974, Category Theory Applied to Computation and Control.

[22]  Ernst-Rüdiger Olderog,et al.  Present-Day Hoare-Like Systems for Programming Languages with Procedures: Power, Limits and most Likely Expressions , 1980, ICALP.

[23]  John Hannan,et al.  Compiler verification in LF , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[24]  David Gries The Multiple Assignment Statement , 1978, Program Construction.

[25]  José Meseguer,et al.  Order-Sorted Algebra I: Equational Deduction for Multiple Inheritance, Overloading, Exceptions and Partial Operations , 1992, Theor. Comput. Sci..

[26]  René Moreau The Computer Comes of Age: The People, the Hardware, and the Software , 1984 .

[27]  Matthew Hennessy Timed Process Algebras: A Tutorial , 1992, NATO ASI PDC.

[28]  R. A. Brooker,et al.  An attempt to simplify coding for the Manchester electronic computer , 1955 .

[29]  Heinrich Hußmann,et al.  Specification and Prototyping of a Compiler for a Small Applicative Language , 1987, Algebraic Methods.

[30]  Susan Stepney,et al.  High integrity compilation - a case study , 1993 .

[31]  Edgar T. Irons,et al.  A syntax directed compiler for ALGOL 60 , 1961, CACM.

[32]  John W. Backus,et al.  The syntax and semantics of the proposed international algebraic language of the Zurich ACM-GAMM Conference , 1959, IFIP Congress.

[33]  Edward K. Blum Towards a theory of semantics and compilers for programming languages , 1969, STOC '69.

[34]  Martin Gogolla,et al.  Algebraic and operational semantics of exceptions and errors , 1983, Theoretical Computer Science.

[35]  Edmund M. Clarke,et al.  Programming Language Constructs for Which It Is Impossible To Obtain Good Hoare Axiom Systems , 1979, JACM.

[36]  Emil L. Post A variant of a recursively unsolvable problem , 1946 .

[37]  Peter J. Landin,et al.  PROGRAMS AND THEIR PROOFS: AN ALGEBRAIC APPROACH, , 1968 .

[38]  J. V. Tucker,et al.  Program correctness over abstract data types, with error-state semantics , 1988, CWI monographs.

[39]  Bruce D. Russell Implementation Correctness Involving a Language with goto Statements , 1977, SIAM J. Comput..

[40]  Teodor Rus,et al.  CONTEXT-FREE ALGEBRAS , 1976 .

[41]  Jan A. Bergstra,et al.  A simple programming language and its implementation , 1989 .

[42]  Robert W. Floyd The syntax of programming languages , 1964 .

[43]  Gregor von Bochmann,et al.  A Sampler of Formal Definitions , 1976, CSUR.

[44]  Maurice V. Wilkes,et al.  The use of a ‘floating address’ system for orders in an automatic digital computer , 1953, Mathematical Proceedings of the Cambridge Philosophical Society.

[45]  Roger Duke,et al.  Specifying the Static Semantics of Block Structural Languages , 1987, Aust. Comput. J..

[46]  Gordon Plotkin,et al.  An Operational Semantics for CSP. , 1982 .

[47]  Maurice V. Wilkes Programme Design for a High-Speed Automatic Calculating Machine , 1949 .

[48]  Maurice Nivat,et al.  Langages algébriques sur le magma libre et sémantique des schémas de programme , 1972, ICALP.

[49]  Jan A. Bergstra,et al.  Equational specifications, complete term rewriting systems, and computable and semicomputable algebras , 1995, JACM.

[50]  Edsger W. Dijkstra,et al.  Guarded commands, nondeterminacy and formal derivation of programs , 1975, Commun. ACM.

[51]  Donald E. Knuth,et al.  The Early Development of Programming Languages. , 1977 .

[52]  Egon Börger,et al.  The WAM - Definition and Compiler Correctness , 1995, Logic Programming: Formal Methods and Practical Applications.

[53]  Peter D. Mosses A Constructive Approach to Compiler Correctness , 1980, ICALP.

[54]  J. W. Backus,et al.  The FORTRAN automatic coding system , 1899, IRE-AIEE-ACM '57 (Western).

[55]  Frits W. Vaandrager,et al.  Turning SOS rules into equations , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[56]  Uwe Kastens The GAG-System - A Tool for Compiler Construction , 1983, Method and tools for compiler construction.

[57]  E. A. van deMeulen Algebraic specification of a compiler for a language with pointers , 1988 .

[58]  John C. Reynolds,et al.  Algebraic Methods in Semantics , 1985 .

[59]  Joseph A. Goguen,et al.  Abstract Errors for Abstract Data Types , 1977, Formal Description of Programming Concepts.

[60]  Wan Fokkink The Tyft/Tyxt Format Reduces to Tree Rules , 1994, TACS.

[61]  Heinrich Hußmann,et al.  The RAP System as a Tool for Testing COLD Specifications , 1987, Algebraic Methods.

[62]  J. C. Shepherdson,et al.  Algorithmic Procedures, Generalized Turing Algorithms, and Elementary Recursion Theory , 1985 .

[63]  F. Lockwood Morris,et al.  Advice on structuring compilers and proving them correct , 1973, POPL.

[64]  Faron Moller,et al.  A Temporal Calculus of Communicating Systems , 1990, CONCUR.

[65]  Rod M. Burstall,et al.  Proving Properties of Programs by Structural Induction , 1969, Comput. J..

[66]  Robert W. Floyd,et al.  On the nonexistence of a phrase structure grammar for ALGOL 60 , 1962, CACM.

[67]  James Allan Painter Semantic correctness of a compiler for an algol-like language , 1967 .

[68]  Martin Campbell-Kelly,et al.  The Development of Computer Programming in Britain (1945 to 1955) , 1982, Annals of the History of Computing.

[69]  Thomas B. Steel,et al.  Formal language description languages for computer programming : proceedings of the IFIP Working Conference on Formal Language Description Languages , 1966 .

[70]  J. W. de Bakker,et al.  Mathematical theory of program correctness , 1980, Prentice-Hall international series in computer science.

[71]  Christine Choppy,et al.  Abstract Data Types with Exception Handling: An Initial Approach Based on a Distinction Between Exceptions and Errors , 1986, Theor. Comput. Sci..

[72]  J. W. Backus The History of FORTRAN I, II and III , 1979, IEEE Ann. Hist. Comput..

[73]  Luca Aceto,et al.  GSOS and Finite Labelled Transition Systems , 1994, Theor. Comput. Sci..

[74]  Henry F. Ledgard,et al.  Production systems: or can we do better than BNF , 1974, CACM.

[75]  H.-R. Schuchmann 9. Jahrestagung der Gesellschaft für Informatik , 1979 .

[76]  A. Church An Unsolvable Problem of Elementary Number Theory , 1936 .