Introduction to Operational Semantics

This chapter presents the syntax of a programming language, IMP, a small language of while programs. IMP is called an "imperative" language because program execution involves carrying out a series of explicit commands to change state. Formally, IMP's behaviour is described by rules which specify how its expressions are evaluated and its commands are executed. The rules provide an operational semantics of IMP in that they are close to giving an implementation of the language, for example, in the programming language Prolog. It is also shown how they furnish a basis for simple proofs of equivalence between commands. 2.1 IMP-a simple imperative language Firstly, we list the syntactic sets associated with IMP: • numbers N, consisting of positive and negative integers with zero, • truth values T = {true, false}, • locations Loc, • arithmetic expressions Aexp, • boolean expressions Bexp, • commands Com. We assume the syntactic structure of numbers and locations is given. For instance, the set Loc might consist of non-empty strings of letters or such strings followed by digits, while N might be the set of signed decimal numerals for positive and negative whole numbers-indeed these are the representations we use when considering specific examples. (Locations are often called program variables but we reserve that term for another concept.) For the other syntactic sets we have to say how their elements are built-up. We'll use a variant of BNF (Backus-Naur form) as a way of writing down the rules of formation of the elements of these syntactic sets. The formation rules will express things like: If ao and al are arithmetic expressions then so is ao + al. It's clear that the symbols ao and al are being used to stand for any arithmetic expression. In our informal presentation of syntax we'll use such metavariables to range over the syntactic sets-the metavariables ao, al above are understood to range over the set of arithmetic expressions. In presenting the syntax of IMP we'll follow the convention that 12 Chapter 2 The metavariables we use to range over the syntactic categories can be primed or sub-scripted. We describe the formation rules for arithmetic expressions Aexp by: The symbol "::=" should be read as "can be" and the symbol "I" as "or". Thus an arithmetic expression a can be a number n or a location X or ao + al or ao-al or ao x a1, built from arithmetic …

[1]  Luca Cardelli The Amber Machine , 1985, Combinators and Functional Programming Languages.

[2]  Gérard Berry,et al.  The Esterel Synchronous Programming Language: Design, Semantics, Implementation , 1992, Sci. Comput. Program..

[3]  Timothy G. Griffin,et al.  A formulae-as-type notion of control , 1989, POPL '90.

[4]  Luca Cardelli,et al.  Compiling a functional language , 1984, LFP '84.

[5]  David Sands From SOS rules to proof principles: an operational metatheory for functional languages , 1997, POPL '97.

[6]  Peter Sewell,et al.  From Rewrite to Bisimulation Congruences , 1998, CONCUR.

[7]  John Hannan Making Abstract Machines Less Abstract , 1991, FPCA.

[8]  Marino Miculan The Expressive Power of Structural Operational Semantics with Explicit Assumptions , 1993, TYPES.

[9]  Rance Cleaveland,et al.  A Front-End Generator for Verification Tools , 1995, TACAS.

[10]  Richard Kennaway,et al.  Director strings as combinators , 1988, TOPL.

[11]  Matthias Felleisen,et al.  A Syntactic Theory of Sequential Control , 1987, Theor. Comput. Sci..

[12]  Richard Bornat,et al.  Proving Pointer Programs in Hoare Logic , 2000, MPC.

[13]  John Hannan Operational semantics-directed compilers and machine architectures , 1994, TOPL.

[14]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[15]  C. A. R. Hoare,et al.  Consistent and complementary formal theories of the semantics of programming languages , 1974, Acta Informatica.

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

[17]  Jens Palsberg,et al.  A Provably Correct Compiler Generator , 1992, ESOP.

[18]  G.D. Plotkin,et al.  LCF Considered as a Programming Language , 1977, Theor. Comput. Sci..

[19]  Peter H. Schmitt,et al.  A Formal Operational Semantics for Languages of Type Prolog III , 1990, CSL.

[20]  Peter W. O'Hearn,et al.  Semantic analysis of pointer aliasing, allocation and disposal in Hoare logic , 2000, PPDP '00.

[21]  P. J. Landin,et al.  Correspondence between ALGOL 60 and Church's Lambda-notation , 1965, Commun. ACM.

[22]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[23]  Pierre-Louis Curien,et al.  An Abstract Framework for Environment Machines , 1991, Theor. Comput. Sci..

[24]  Pierre-Louis Curien,et al.  The Categorical Abstract Machine , 1987, Sci. Comput. Program..

[25]  Gérard Berry,et al.  The ESTEREL Synchronous Programming Language and its Mathematical Semantics , 1984, Seminar on Concurrency.

[26]  David A. Schmidt,et al.  Denotationaisemantics: a methodology for language development , 1986 .

[27]  David Park,et al.  Concurrency and Automata on Infinite Sequences , 1981, Theoretical Computer Science.

[28]  David A. Schmidt,et al.  Structural operational semantics as a basis for static program analysis , 1996, CSUR.

[29]  Seif Haridi,et al.  Structural operational semantics for AKL , 1992, Future Gener. Comput. Syst..

[30]  Joseph M. Morris A General Axiom of Assignment , 1982 .

[31]  P. J. Landin The Mechanical Evaluation of Expressions , 1964, Comput. J..

[32]  Fabio Q. B. da Silva,et al.  Correctness proofs of compilers and debuggers : an approach based on structural operational semantics , 1992 .

[33]  Gordon D. Plotkin,et al.  Call-by-Name, Call-by-Value and the lambda-Calculus , 1975, Theor. Comput. Sci..

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

[35]  Mitchell Wand,et al.  Proving the correctness of storage representations , 1992, LFP '92.

[36]  D. A. Turner,et al.  A new implementation technique for applicative languages , 1979, Softw. Pract. Exp..

[37]  Dale Miller,et al.  From operational semantics to abstract machines: preliminary results , 1990, LISP and Functional Programming.

[38]  Bernard Robinet,et al.  Combinators and Functional Programming Languages , 1986 .