Formalising and Verifying Reference Attribute Grammars in Coq

Reference attribute grammars are a powerful formalism for concisely specifying and implementing static analyses. While they have proven their merit in practical applications, no attempt has so far been made to rigorously verify correctness properties of the resulting systems. We present a general method for formalising reference attribute grammars in the theorem prover Coq. The formalisation is supported by tools for generating standard definitions from an abstract description and custom proof tactics to help automate verification. As a small but typical application, we show how closure analysis for the untyped lambda calculus can easily be implemented and proved correct with respect to an operational semantics. To evaluate the feasibility of our approach on larger systems, we implement name lookup for a naming core calculus of Java and give a formal correctness proof of the centrepiece of a rename refactoring for this language.

[1]  Tarmo Uustalu,et al.  Comonadic functional attribute evaluation , 2005, Trends in Functional Programming.

[2]  Atsushi Igarashi,et al.  On Inner Classes , 2000, ECOOP.

[3]  John Tang Boyland,et al.  Remote attribute grammars , 2005, JACM.

[4]  Xavier Leroy,et al.  Formal certification of a compiler back - end , 2005 .

[5]  Görel Hedin,et al.  Circular reference attributed grammars - their evaluation and applications , 2003, Sci. Comput. Program..

[6]  Martin Wirsing,et al.  Formal Syntax and Semantics of Java , 1999 .

[7]  Torbjörn Ekman,et al.  The jastadd extensible java compiler , 2007, OOPSLA.

[8]  Andrew M. Pitts,et al.  MJ: An imperative core calculus for Java and Java with effects , 2003 .

[9]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[10]  Venanzio Capretta,et al.  General recursion via coinductive types , 2005, Log. Methods Comput. Sci..

[11]  Görel Hedin,et al.  Circular reference attributed grammars - their evaluation and applications , 2007, Sci. Comput. Program..

[12]  Huiqing Li,et al.  Formalisation of Haskell refactorings , 2005, Trends in Functional Programming.

[13]  Tobias Nipkow,et al.  Machine-Checking the Java Specification: Proving Type-Safety , 1999, Formal Syntax and Semantics of Java.

[14]  Bernard Fotsing,et al.  Yet Another Implementation of Attribute Evaluation , 2007 .

[15]  Tom Ridge,et al.  Ott: effective tool support for the working semanticist , 2007, ICFP '07.

[16]  Matthias Felleisen,et al.  A Programmer's Reduction Semantics for Classes and Mixins , 1999, Formal Syntax and Semantics of Java.

[17]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[18]  Takuya Katayama,et al.  Verification of attribute grammar , 1981, POPL '81.

[19]  Benjamin C. Pierce,et al.  It Is Time to Mechanize Programming Language Metatheory , 2005, VSTTE.

[20]  Simon J. Thompson,et al.  Mechanical verification of refactorings , 2008, PEPM '08.

[21]  Torbjörn Ekman,et al.  Sound and extensible renaming for java , 2008, OOPSLA.

[22]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[23]  Görel Hedin,et al.  Reference Attributed Grammars , 2000, Informatica.

[24]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

[25]  Torbjörn Ekman,et al.  Modular Name Analysis for Java Using JastAdd , 2005, GTTSE.

[26]  Rodney Farrow Automatic generation of fixed-point-finding evaluators for circular, but well-defined, attribute grammars , 1986, SIGPLAN '86.

[27]  I. S. W. B. Prasetya,et al.  A survey on embedding programming logics in a theorem prover , 2002 .

[28]  Thomas Reps,et al.  The Synthesizer Generator: A System for Constructing Language-Based Editors , 1988 .

[29]  Thomas Johnsson,et al.  Attribute grammars as a functional programming paradigm , 1987, FPCA.

[30]  Sorin Lerner,et al.  Automated soundness proofs for dataflow analyses and transformations via local rules , 2005, POPL '05.

[31]  David F. Martin,et al.  An order-algebraic definition of knuthian semantics , 1979, Mathematical systems theory.

[32]  Peter Sestoft,et al.  Analysis and efficient implementation of functional programs , 1991 .

[33]  Eric Van Wyk,et al.  Proving correctness of compiler optimizations by temporal logic , 2002, POPL '02.

[34]  Anthony M. Sloane,et al.  Using Off-the-Shelf Formal Methods to Verify Attribute Grammar Properties , 2004, LDTA@ETAPS.

[35]  LeroyXavier Formal certification of a compiler back-end or , 2006 .

[36]  Xavier Leroy,et al.  Formal certification of a compiler back-end or: programming a compiler with a proof assistant , 2006, POPL '06.

[37]  David R. Hanson,et al.  A research C# compiler , 2004, Softw. Pract. Exp..

[38]  Arthur Charguéraud,et al.  Engineering formal metatheory , 2008, POPL '08.

[39]  Jens Palsberg,et al.  Closure analysis in constraint form , 1995, TOPL.

[40]  David Cachera,et al.  Extracting a Data Flow Analyser in Constructive Logic , 2004, ESOP.