Modular Implementation of Programming Languages and a Partial-Order Approach to Infinitary Rewriting

This dissertation is a collection of nine research papers pertaining to two independent areas of research. In the first part, entitled Modular Implementation of Programming Languages, we develop techniques for implementing programming languages in a modular fashion. Within this problem domain, we focus on operations on typed abstract syntax trees with the goal of developing a framework that facilitates the definition, manipulation and composition of such operations. The result of our work is a comprehensive combinator library that provides these facilities. What sets our approach apart is the use of recursion schemes derived from tree automata in order to implement operations on abstract syntax trees. In the first two papers we illustrate the power of this approach by showcasing tree homomorphisms – a very limited form of tree automata – as basic building blocks for simple tree transformations. Their simplicity allows us to combine them with monadic effects, manipulate and combine them in a flexible manner, and perform optimisations in the form of deforestation. In the third paper, we move to more powerful tree automata. Usually, these more powerful automata are cumbersome to define as they combine different computational aspects. We show, however, that these automata can be constructed from simpler ones, viz. tree homomorphisms and simple state machines. In the second paper, we focus on the important issue of representing variable names and variable binders using a carefully restricted form of higher-order abstract syntax. In the fourth paper, we presents a comprehensive and realistic application of our library: a prototype implementation of a novel enterprise resource planning system built around a family of domain-specific languages that make it possible to customise the system in a highly flexible manner. The system combines several highly integrated domain-specific languages, which are implemented using our library. The second part of this dissertation, entitled A Partial-Order Approach to Infinitary Rewriting, is concerned with infinitary rewriting, a field that studies transfinite rewrite sequences. We extend the established theory of infinitary rewriting in two directions: (1) a novel approach to convergence in infinitary rewriting that replaces convergence in a metric space with the limit inferior in a partially ordered set; (2) extending infinitary term rewriting to infinitary term graph rewriting. For the first item, we show correspondences between the established calculi based on metric convergence and the newly developed calculi based on partial orders. We also study both approaches on an abstract level and show the advantages of our partial order approach in terms of better confluence and normalisation properties of infinitary term rewriting as well as in terms of better completeness properties for infinitary term graph rewriting. For the second item, we explore several approaches to convergence on term graphs and analyse the resulting calculi. We distinguish two calculi among them – based on a metric space respectively a partially ordered set – by showing that they satisfy strong soundness and completeness properties w.r.t. infinitary term rewriting.

[1]  Z. M. Ariola,et al.  Skew and ω-Skew Confluence and Abstract Böhm Semantics , 2005 .

[2]  Erik Barendsen,et al.  Graph rewriting aspects of functional programming , 1999 .

[3]  Jacques Carette,et al.  Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages , 2007, Journal of Functional Programming.

[4]  Bruno C. d. S. Oliveira,et al.  Comparing libraries for generic programming in haskell , 2008, Haskell '08.

[5]  Felix Klaedtke,et al.  A trace-based model for multiparty contracts , 2012, J. Log. Algebraic Methods Program..

[6]  Andrew M. Pitts,et al.  Alpha-structural recursion and induction , 2005, JACM.

[7]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[8]  Frank Pfenning,et al.  Primitive recursion for higher-order abstract syntax , 1997, Theor. Comput. Sci..

[9]  Andres Löh,et al.  Generic storage in Haskell , 2010, WGP '10.

[10]  Mauro Javier Jaskelioff Lifting of operations in modular monadic semantics , 2009 .

[11]  Jakob Grue Simonsen,et al.  On Confluence of Infinitary Combinatory Reduction Systems , 2005, LPAR.

[12]  Zena M. Ariola,et al.  Equational Term Graph Rewriting , 1996, Fundam. Informaticae.

[13]  Stefan Kahrs,et al.  Infinitary rewriting: meta-theory and convergence , 2007, Acta Informatica.

[14]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1990, Theor. Comput. Sci..

[15]  Richard S. Bird,et al.  Generalised folds for nested datatypes , 1999, Formal Aspects of Computing.

[16]  Armin Kühnemann,et al.  Benefits of Tree Transducers for Optimizing Functional Programs , 1998, FSTTCS.

[17]  Simon L. Peyton Jones,et al.  Scrap your boilerplate with class: extensible generic functions , 2005, ICFP '05.

[18]  Patrick Bahr Abstract Models of Transfinite Reductions , 2010, RTA.

[19]  Mauro Jaskelioff,et al.  Modular Monad Transformers , 2009, ESOP.

[20]  Stephanie Weirich,et al.  Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism , 2003, ICFP '03.

[21]  Nachum Dershowitz,et al.  Rewrite, rewrite, rewrite, rewrite, rewrite... , 1989, POPL '89.

[22]  Vincent van Oostrom,et al.  Unique Normal Forms in Infinitary Weakly Orthogonal Rewriting , 2010, RTA.

[23]  B. Hamber Publications , 1998, Weed Technology.

[24]  Martin Odersky,et al.  A Statically Safe Alternative to Virtual Types , 1998, ECOOP.

[25]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[26]  J. R Kennaway On transfinite abstract reduction systems , 1992 .

[27]  Graham Hutton,et al.  Monadic parsing in Haskell , 1998, Journal of Functional Programming.

[28]  Ralf Hinze,et al.  Open data types and open functions , 2006, PPDP '06.

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

[30]  Matthias Felleisen,et al.  Synthesizing Object-Oriented and Functional Design to Promote Re-Use , 1998, ECOOP.

[31]  Patrick Bahr Partial Order Infinitary Term Rewriting and Böhm Trees , 2010, RTA.

[32]  Daniel M. Yellin,et al.  Composable attribute grammars: support for modularity in translator design and implementation , 1992, POPL '92.

[33]  Andrea Corradini,et al.  Term Graph Rewriting and Parallel Term Rewriting , 2011, TERMGRAPH.

[34]  Zena M. Ariola,et al.  Lambda Calculus with Explicit Recursion , 1997, Inf. Comput..

[35]  Ralf Hinze,et al.  "Scrap Your Boilerplate" Revolutions , 2006, MPC.

[36]  William M. Farmer,et al.  Redex Capturing in Term Graph Rewriting (Concise Version) , 1991, RTA.

[37]  Johan Jeuring,et al.  Generic conversions of abstract syntax representations , 2012, WGP '12.

[38]  Jean-Jacques Lévy,et al.  Minimal and optimal computations of recursive programs , 1977, JACM.

[39]  Giuseppe Longo,et al.  Set-theoretical models of λ-calculus: theories, expansions, isomorphisms , 1983, Ann. Pure Appl. Log..

[40]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[41]  Ken Friis Larsen,et al.  POETS: Process-oriented event-driven transaction systems , 2009, J. Log. Algebraic Methods Program..

[42]  J. Ketema,et al.  Bohm-Like Trees for Rewriting , 2006 .

[43]  Salvador Lucas Transfinite Rewriting Semantics for Term Rewriting Systems , 2001, RTA.

[44]  Fabio Gadducci,et al.  Rewriting on cyclic structures: Equivalence between the operational and the categorical description , 1999, RAIRO Theor. Informatics Appl..

[45]  Wouter Swierstra,et al.  Data types à la carte , 2008, Journal of Functional Programming.

[46]  Alfons Kemper,et al.  Databases and transaction processing: an application-oriented approach , 2002, SGMD.

[47]  Patrick Bahr Evaluation à la Carte Non-Strict Evaluation via Compositional Data Types , 2011 .

[48]  Detlef Plump,et al.  Term graph rewriting , 1999 .

[49]  Fritz Henglein,et al.  Domain-Specific Languages for Enterprise Systems , 2014, ISoLA.

[50]  Graham Hutton,et al.  Towards Modular Compilers for Effects , 2011, Trends in Functional Programming.

[51]  Tim Sheard,et al.  A hierarchy of mendler style recursion combinators: taming inductive datatypes with negative occurrences , 2011, ICFP '11.

[52]  M. Fokkinga A Gentle Introduction to Category Theory - the calculational approach , 1992 .

[53]  Jakob Grue Simonsen,et al.  Compositional specification of commercial contracts , 2006, International Journal on Software Tools for Technology Transfer.

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

[55]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[56]  Robert Atkey,et al.  Unembedding domain-specific languages , 2009, Haskell.

[57]  Ralf Hinze,et al.  Adjoint folds and unfolds - An extended study , 2013, Sci. Comput. Program..

[58]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[59]  james w.thatcher,et al.  tree automata: an informal survey , 1974 .

[60]  Kim B. Bruce Some challenging typing issues in object-oriented languages , 2003, WOOD.

[61]  Mark P. Jones,et al.  Instance chains: type class programming without overlapping instances , 2010, ICFP '10.

[62]  Patrick Bahr Infinitary Term Graph Rewriting is Simple, Sound and Complete , 2012, RTA.

[63]  Jon Louis Bentley,et al.  Programming pearls: little languages , 1986, CACM.

[64]  M. Slee,et al.  Thrift : Scalable Cross-Language Services Implementation , 2022 .

[65]  Johan Jeuring,et al.  Generic selections of subexpressions , 2010, WGP '10.

[66]  Christine Paulin-Mohring,et al.  Mathematics of Program Construction , 1998, Lecture Notes in Computer Science.

[67]  Maurice Nivat,et al.  The metric space of infinite trees. Algebraic and topological properties , 1980, Fundam. Informaticae.

[68]  Andrea Corradini,et al.  Cyclic) Term Graph Rewriting is adequate for Rational Parallel Term Rewriting , 1997 .

[69]  Joost Engelfriet,et al.  Macro Tree Transducers , 1985, J. Comput. Syst. Sci..

[70]  Patrick Bahr,et al.  Modes of Convergence for Term Graph Rewriting , 2012, Log. Methods Comput. Sci..

[71]  Jakob Grue Simonsen Weak Convergence and Uniform Normalization in Infinitary Rewriting , 2010, RTA.

[72]  Paul Hudak,et al.  Modular Denotational Semantics for Compiler Construction , 1996, ESOP.

[73]  Atsushi Ohori,et al.  A polymorphic record calculus and its compilation , 1995, TOPL.

[74]  Patrick Bahr,et al.  Compositional data types , 2011, WGP@ICFP.

[75]  Tim Sheard,et al.  Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space) , 1996, POPL '96.

[76]  Krzysztof R. Apt,et al.  Logics and Models of Concurrent Systems , 1989, NATO ASI Series.

[77]  Gordon V. Cormack,et al.  Modular Attribute Grammars , 1990, Comput. J..

[78]  Colin Runciman,et al.  Uniform boilerplate and list processing , 2007, Haskell '07.

[79]  Zoltán Fülöp,et al.  Syntax-Directed Semantics: Formal Models Based on Tree Transducers , 2011 .

[80]  Robert Atkey Syntax for Free: Representing Syntax with Binding Using Parametricity , 2009, TLCA.

[81]  Varmo Vene,et al.  CATEGORICAL PROGRAMMING WITH INDUCTIVE AND COINDUCTIVE TYPES , 2000 .

[82]  Ryan Stansifer,et al.  Type inference with subtypes , 1988, POPL '88.

[83]  Jacques Garrigue,et al.  Code reuse through polymorphic variants , 2000 .

[84]  Patrick Bahr A Functional Language for Specifying Business Reports , 2011 .

[85]  Grzegorz Rozenberg,et al.  Handbook of Graph Grammars and Computing by Graph Transformations, Volume 1: Foundations , 1997 .

[86]  Maarten M. Fokkinga,et al.  Law and order in algorithmics , 1992 .

[87]  Hartmut Ehrig,et al.  Graph-Grammars: An Algebraic Approach , 1973, SWAT.

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

[89]  Jeremy Gibbons Upwards and Downwards Accumulations on Trees , 1992, MPC.

[90]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA '89.

[91]  Apostolos Syropoulos,et al.  Steps in Scala: The expression problem , 2010 .

[92]  Marko C. J. D. van Eekelen,et al.  Functional Programming and Parallel Graph Rewriting , 1993 .

[93]  Peter D. Mosses,et al.  Constructive Action Semantics for Core ML , 2005, IEE Proc. Softw..

[94]  Apostolos Syropoulos,et al.  Steps in Scala: An Introduction to Object-Functional Programming , 2010 .

[95]  Thierry Coquand,et al.  Constructions: A Higher Order Proof System for Mechanizing Mathematics , 1985, European Conference on Computer Algebra.

[96]  Jan Willem Klop,et al.  Infinitary Lambda Calculi and Böhm Models , 1995, RTA.

[97]  Jan Willem Klop,et al.  On the adequacy of graph rewriting for simulating term rewriting , 1994, TOPL.

[98]  Joost Engelfriet,et al.  Three hierarchies of transducers , 1981, Mathematical systems theory.

[99]  Philip Wadler,et al.  Comprehending monads , 1990, Mathematical Structures in Computer Science.

[100]  Janis Voigtländer,et al.  Formal Efficiency Analysis for Tree Transducer Composition , 2007, Theory of Computing Systems.

[101]  Simon L. Peyton Jones,et al.  Complete and decidable type inference for GADTs , 2009, ICFP.

[102]  Stefan Blom,et al.  Skew confluence and the lambda calculus with letrec , 2002, Ann. Pure Appl. Log..

[103]  Richard Kennaway Infinitary rewriting and cyclic graphs , 1995, Electron. Notes Theor. Comput. Sci..

[104]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[105]  John Launchbury,et al.  Implicit parameters: dynamic scoping with static types , 2000, POPL '00.

[106]  Kaarel Kaljurand,et al.  Attempto Controlled English for Knowledge Representation , 2008, Reasoning Web.

[107]  G. Malcolm,et al.  Data Structures and Program Transformation , 1990, Sci. Comput. Program..

[108]  Eric Van Wyk,et al.  Flexible and Extensible Notations for Modeling Languages , 2007, FASE.

[109]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[110]  Torbjörn Ekman,et al.  The JastAdd system - modular extensible compiler construction , 2007, Sci. Comput. Program..

[111]  Jakob Grue Simonsen,et al.  Infinitary Combinatory Reduction Systems , 2005, Inf. Comput..

[112]  Jan Willem Klop,et al.  Infinitary Normalization , 2005, We Will Show Them!.

[113]  Jeremy Gibbons Polytypic Downwards Accumulations , 1998, MPC.

[114]  Kai Koskimies,et al.  Compiler construction using attribute grammars , 1982, SIGPLAN '82.

[115]  Patrick Bahr,et al.  Parametric Compositional Data Types , 2012, MSFP.

[116]  Terese Term rewriting systems , 2003, Cambridge tracts in theoretical computer science.

[117]  José Meseguer,et al.  Modular Rewriting Semantics in Practice , 2004, WRLA.

[118]  Gary T. Leavens,et al.  Typechecking and Modules for Multimethods , 1995, ACM Trans. Program. Lang. Syst..

[119]  Simon L. Peyton Jones,et al.  Type checking with open type functions , 2008, ICFP.

[120]  Jakob Grue Simonsen,et al.  Infinitary Combinatory Reduction Systems: Normalising Reduction Strategies , 2010, Log. Methods Comput. Sci..

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

[122]  Patricia Johann,et al.  Foundations for structured programming with GADTs , 2008, POPL '08.

[123]  Vincent van Oostrom,et al.  Meaningless Terms in Rewriting , 1996, J. Funct. Log. Program..

[124]  Andrew M. Pitts,et al.  FreshML: programming with binders made simple , 2003, ICFP '03.

[125]  Michael Barr,et al.  Terminal Coalgebras in Well-Founded Set Theory , 1993, Theor. Comput. Sci..

[126]  Jeremy Gibbons Generic downwards accumulations , 2000, Sci. Comput. Program..

[127]  Bruno C. d. S. Oliveira,et al.  "Scrap Your Boilerplate" Reloaded , 2006, FLOPS.

[128]  Bart Jacobs,et al.  Categorical Views on Computations on Trees (Extended Abstract) , 2007, ICALP.

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

[130]  Peter Henderson,et al.  A lazy evaluator , 1976, POPL.

[131]  Graham Hutton,et al.  Bananas in space: extending fold and unfold to exponential types , 1995, FPCA '95.

[132]  Jan Willem Klop,et al.  Infinitary Lambda Calculus , 1997, Theoretical Computer Science.

[133]  Matthew Flatt,et al.  Jiazzi: new-age components for old-fasioned Java , 2001, OOPSLA '01.

[134]  Daan Leijen,et al.  Parsec: direct style monadic parser combinators for the real world , 2001 .

[135]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[136]  Graham Hutton,et al.  Higher-order functions for parsing , 1992, Journal of Functional Programming.

[137]  Matthias Felleisen,et al.  Units: cool modules for HOT languages , 1998, PLDI.

[138]  James Cheney Scrap your nameplate: (functional pearl) , 2005, ICFP '05.

[139]  Jan Willem Klop,et al.  Transfinite Reductions in Orthogonal Term Rewriting Systems , 1995, Inf. Comput..

[140]  Alessandro Berarducci,et al.  Innite -calculus and non-sensible models , 1994 .

[141]  Patrick Bahr Modular Tree Automata , 2012, MPC.

[142]  Simon Peyton Jones,et al.  Playing by the rules: rewriting as a practical optimisation technique in GHC , 2001 .

[143]  Jakob Grue Simonsen,et al.  On confluence and residuals in Cauchy convergent transfinite rewriting , 2004, Inf. Process. Lett..

[144]  Jukka Paakki,et al.  Attribute grammar paradigms—a high-level methodology in language implementation , 1995, CSUR.

[145]  William M. Farmer,et al.  Redex Capturing in Term Graph Rewriting , 1990, Int. J. Found. Comput. Sci..

[146]  Jacques Garrigue,et al.  Programming with Polymorphic Variants , 2010 .

[147]  Pieter Hendrik Rodenburg,et al.  Termination and confluence in infinitary term rewriting , 1998, Journal of Symbolic Logic.

[148]  Johan Jeuring,et al.  Generic programming with fixed points for mutually recursive datatypes , 2009, ICFP.

[149]  Gary T. Leavens,et al.  MultiJava: modular open classes and symmetric multiple dispatch for Java , 2000, OOPSLA '00.

[150]  Jan Willem Klop,et al.  Term Graph Rewriting , 1995, HOA.

[151]  João Saraiva,et al.  Designing and Implementing Combinator Languages , 1998, Advanced Functional Programming.

[152]  Adam Chlipala Parametric higher-order abstract syntax for mechanized semantics , 2008, ICFP.

[153]  Enno Ohlebusch,et al.  Term Rewriting Systems , 2002 .

[154]  J. Grosch,et al.  A Tool Box for Compiler Construction , 1990, CC.

[155]  Hubert Comon,et al.  Tree automata techniques and applications , 1997 .

[156]  Michael Kifer,et al.  Databases and Transaction Processing: An Application-Oriented Approach , 2001 .

[157]  Frank Pfenning,et al.  Higher-order abstract syntax , 1988, PLDI '88.

[158]  Jesse B. Wright,et al.  Automata in General Algebras , 1967, Inf. Control..

[159]  Gordon D. Plotkin,et al.  Concrete Domains , 1993, Theor. Comput. Sci..

[160]  Robert Giegerich,et al.  Attribute coupled grammars , 1984, SIGPLAN '84.

[161]  Stefan Blom An Approximation Based Approach to Infinitary Lambda Calculi , 2004, RTA.