An Executable Rewriting Logic Semantics of K-Scheme

This paper presents an executable rewriting logic semantics of K- Scheme, a dialect of Scheme based (partially) on the informal defi- nition given in the R 5 RS report (Kelsey et al. 1998). The presented semantics follows the K language definitional style (Rosu 2005 and 2006) and is a pure rewriting logic specification (Meseguer 1992) containing 772 equations and 1 rewrite rule, so it can also be re- garded as an algebraic denotational specification with an initial model semantics. Rewriting logic specifications can be executed on common (context-insensitive) rewrite engines, provided that equa- tions are oriented into rewrite rules, typically from left-to-right. While in theory rewriting logic specifications can let certain behav- iors underspecified, thus allowing more models, in practice they need to completely specify all the desired behaviors if one wants to use their associated rewrite systems as "interpreters", or "imple- mentations". To become executable, K-Scheme overspecifies cer- tain features left undefined on purpose in R 5 RS. In spite of over- specifying for executability reasons, the rewriting logic semantics in this paper is the most complete formal definition of a language in the Scheme family that we are aware of, in the sense that it pro- vides definitions for more Scheme language features than any other similar attempts. The presented executable definition of K-Scheme can serve as a platform for experimentation with variants and ex- tensions of Scheme, for example concurrency. The Maude system is used in this paper, but other rewrite engines could have been used as well. Even though, on paper, K rewrite-based definitions tend to be as compact and high-level as reduction-based definitions with eval- uation contexts, their complete translation in Maude as executable specifications is rather verbose and low-level. An automated trans- lator from K to Maude is under development, which will reduce the size of definitions following the K style several times and will certainly increase their readability. The complete Maude specifi- cation is public, together with a web-based interface to "execute" K-Scheme programs without having to download Maude.

[1]  Grigore Rosu K: a Rewrite-based Framework for Modular Language Design, Semantics, Analysis and Implementation -Version 1- , 2005 .

[2]  Marcelo d'Amorim,et al.  An Equational Specification for the Scheme Language , 2005, J. Univers. Comput. Sci..

[3]  Paul Klint,et al.  Compiling language definitions: the ASF+SDF compiler , 2000, TOPL.

[4]  Claude Kirchner,et al.  Formal validation of pattern matching code , 2005, Trustworthy Software.

[5]  José Meseguer,et al.  A Rewriting Logic Approach to Operational Semantics (Extended Abstract) , 2007, Electron. Notes Theor. Comput. Sci..

[6]  Grigore Rosu,et al.  On Formal Analysis of OO Languages Using Rewriting Logic: Designing for Performance , 2007, FMOODS.

[7]  G. Rosu,et al.  Computationally Equivalent Elimination of Conditions-extended abstract-Traian , 2009 .

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

[9]  Grigore Rosu,et al.  KOOL: An Application of Rewriting Logic to Language Prototyping and Analysis , 2007, RTA.

[10]  Joseph A. Goguen,et al.  Software Engineering with Obj: Algebraic Specification In Action , 2010 .

[11]  Gérard Berry,et al.  The chemical abstract machine , 1989, POPL '90.

[12]  Gordon D. Plotkin,et al.  A structural approach to operational semantics , 2004, J. Log. Algebraic Methods Program..

[13]  MeseguerJosé Conditional rewriting logic as a unified model of concurrency , 1992 .

[14]  Robert Hieb,et al.  Revised 5 Report on the Algorithmic Language , 1999 .

[15]  José Meseguer,et al.  Rewriting logic: roadmap and bibliography , 2002, Theor. Comput. Sci..

[16]  José Meseguer,et al.  Rewriting Logic Semantics: From Language Specifications to Formal Analysis Tools , 2004, IJCAR.

[17]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[18]  Robert Bruce Findler,et al.  An operational semantics for R5RS Scheme , 2005 .

[19]  José Meseguer,et al.  The Rewriting Logic Semantics Project , 2006, SOS@ICALP.

[20]  Eelco Visser,et al.  Program Transformation with Stratego/XT: Rules, Strategies, Tools, and Systems in Stratego/XT 0.9 , 2003, Domain-Specific Program Generation.

[21]  Narciso Martí-Oliet,et al.  Maude: specification and programming in rewriting logic , 2002, Theor. Comput. Sci..

[22]  R. Kent Dybvig,et al.  The Scheme Programming Language , 1995 .

[23]  Peter D. Mosses,et al.  Modular structural operational semantics , 2004, J. Log. Algebraic Methods Program..

[24]  Claude Kirchner,et al.  An overview of ELAN , 1998, WRLA.

[25]  Kurt Nørmark Proceedings of the 2007 Workshop on Scheme and Functional Programming , 2007 .

[26]  José Meseguer,et al.  Formal Analysis of Java Programs in JavaFAN , 2004, CAV.

[27]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.