K: a Rewrite-based Framework for Modular Language Design, Semantics, Analysis and Implementation -Version 1-

K is an algebraic framework for defining programming languages. It consists of a technique and of a specialized and highly optimized notation. The K-technique, which can be best ex- plained in terms of rewriting modulo equations or in terms of rewriting logic, is based on a first-order representation of continuations with intensive use of matching modulo associativity, commutativity and identity. The K-notation consists of a series of high-level conventions that make the programming language definitions intuitive, easy to understand, to read and to teach, compact, modular and scalable. One important notational convention is based on context trans- formers, allowing one to automatically synthesize concrete rewrite rules from more abstract definitions once the concrete structure of the state is provided, by “completing” the contexts in which the rules should apply. The K framework is introduced by defining FUN, a concurrent higher-order programming language with parametric exceptions. A rewrite logic definition of a programming language can be executed on rewrite engines, thus providing an interpreter for the language for free, but also gives an initial model semantics, amenable to formal analysis such as model checking and inductive theorem proving. Rewrite logic definitions in K can lead to automatic, correct-by-construction generation of interpreters, compilers and analysis tools. Note to readers: The material presented in this report serves as a basis for programming language design and semantics classes and for several research projects. This report aims at giv- ing a global snapshot of this rapidly evolving domain. Consequently, this work will be published on a version by version basis, each including and improving the previous ones, probably over a period of several years. This version already contains the desired structure of the final version, but not all sections are filled in yet. In this first version I put more emphasis on introducing the K framework and on how to use it. Here I focus less on related work, inductive verification and implementation; these will be approached in next versions of this work. My plan is to eventually transform this material into a book, so your suggestions and criticisms are welcome. ∗Supported by joint NSF grants CCF-0234524, CCF-0448501, and CNS-0509321.

[1]  M. M. Algæ , 2022 .

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

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

[4]  Joseph A. Goguen,et al.  Initial Algebra Semantics and Continuous Algebras , 1977, J. ACM.

[5]  John C. Reynolds,et al.  The discoveries of continuations , 1993, LISP Symb. Comput..

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

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

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

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

[10]  José Meseguer,et al.  Mapping Modular SOS to Rewriting Logic , 2002, LOPSTR.

[11]  Paliath Narendran,et al.  NP-Completeness of the Set Unification and Matching Problems , 1986, CADE.

[12]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[13]  Christopher Strachey,et al.  Continuations: A Mathematical Semantics for Handling Full Jumps , 2000, High. Order Symb. Comput..

[14]  Michal Walicki,et al.  Algebraic approaches to nondeterminism—an overview , 1997, CSUR.

[15]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

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

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

[18]  Rodney Herzog All in One and One in All. , 2002 .

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

[20]  Paolo Atzeni,et al.  Cut and paste , 1997, PODS '97.

[21]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.