Ecient Specialisation in Prolog Using a Hand-Written Compiler Generator

The so called “cogen approach” to program specialisation, writing a compiler generator instead of a specialiser, has been used with considerable success in partial evaluation of both functional and imperative languages. This paper demonstrates that this approach is also applicable to partial evaluation of logic programming languages, also called partial deduction. Self-application has not been as much in focus in logic programming as for functional and imperative languages, and the attempts to self-apply partial deduction systems have, of yet, not been altogether that successful. So, especially for partial deduction, the cogen approach should prove to have a considerable importance when it comes to practical applications. This paper first develops a generic offline partial deduction technique for pure logic programs, notably supporting partially instantiated datastructures via binding types. From this a very efficient cogen is derived, which generates very efficient generating extensions (executing up to several orders of magnitude faster than current online systems) which in turn perform very good and non-trivial specialisation, even rivalling existing online systems. All this is supported by extensive benchmarks. Finally, it is shown how the cogen can be extended to directly support a large part of Prolog’s declarative and non-declarative features and how semi-online specialisation can be efficiently integrated.

[1]  Anders Bondorf,et al.  Logimix: A Self-Applicable Partial Evaluator for Prolog , 1992, LOPSTR.

[2]  Michael Leuschel,et al.  Ecological Partial Deduction: Preserving Characteristic Trees Without Constraints , 1995, LOPSTR.

[3]  Michael Leuschel,et al.  Redundant Argument Filtering of Logic Programs , 1996, LOPSTR.

[4]  Neil D. Jones,et al.  BTA Algorithms to Ensure Termination of Off-Line Partial Evaluation , 1996, Ershov Memorial Conference.

[5]  J. Lloyd Foundations of Logic Programming , 1984, Symbolic Computation.

[6]  John P. Gallagher,et al.  The Applicability of Logic Program Analysis and Transformation to Theorem Proving , 1994, CADE.

[7]  Corin A. Gurr,et al.  A self-applicable partial evaluator for the logic programming language Goedel , 1994 .

[8]  Marek J. Sergot,et al.  Data-driven Transformation of Meta-interpreters: A Sketch , 1991, PDK.

[9]  John Launchbury,et al.  Projection factorisations in partial evaluation , 1991 .

[10]  Jan Komorowski,et al.  An Introduction to Partial Deduction , 1992, META.

[11]  Zoltan Somogyi,et al.  The Execution Algorithm of Mercury, an Efficient Purely Declarative Logic Programming Language , 1996, J. Log. Program..

[12]  Saumya K. Debray,et al.  Global Flow Analysis as a Practical Compilation Tool , 1992, J. Log. Program..

[13]  M. Sørensen,et al.  Conjunctive Partial Deduction: Foundations, Control, Algorithms, and Experiments , 1999, J. Log. Program..

[14]  John W. Lloyd,et al.  Partial Evaluation in Logic Programming , 1991, J. Log. Program..

[15]  Olivier Danvy,et al.  Tutorial notes on partial evaluation , 1993, POPL '93.

[16]  Michael Leuschel,et al.  Sonic Partial Deduction , 1999, Ershov Memorial Conference.

[17]  Michael Leuschel,et al.  Partial Evaluation of the "Real Thing" , 1994, LOPSTR.

[18]  S. A. Romanenko,et al.  A compiler generator produced by a self-applicable specializer can have a surprisingly natural and u , 1988 .

[19]  Michael Leuschel,et al.  Advanced Techniques for Logic Program Specialisation , 1997, AI Commun..

[20]  Robert Glück,et al.  Introduction to Supercompilation , 1998, Partial Evaluation.

[21]  John P. Gallagher,et al.  Tutorial on specialisation of logic programs , 1993, PEPM '93.

[22]  Corin A. Gurr,et al.  Towards fast and declarative meta-programming , 1995 .

[23]  Steven David Prestwich,et al.  The PADDY Partial Deduction System , 1992 .

[24]  Patricia M. Hill,et al.  Supporting Transformations for the Partial Evaluation of Logic Programs , 1993, J. Log. Comput..

[25]  Franco Turini,et al.  Logic Program Synthesis and Transformation — Meta-Programming in Logic , 1994, Lecture Notes in Computer Science.

[26]  Robert Glück,et al.  Efficient Multi-level Generating Extensions for Program Specialization , 1995, PLILP.

[27]  Michael Leuschel,et al.  Partial Deduction of the Ground Representation and its Application to Integrity Checking , 1995, ILPS.

[28]  LeuschelMichael,et al.  Controlling generalization and polyvariance in partial deduction of normal logic programs , 1998 .

[29]  Danny De Schreye,et al.  Creating Specialised Integrity Checks Through Partial Evaluation of Meta-Interpreters , 1998, J. Log. Program..

[30]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[31]  Michael Leuschel,et al.  Conjunctive Partial Deduction in Practice , 1996, LOPSTR.

[32]  Danny De Schreye,et al.  A Conceptual Embedding of Folding into Partial Deduction: Towards a Maximal Integration , 1996, JICSLP.

[33]  Michael Leuschel,et al.  Efficiently Generating Efficient Generating Extensions in Prolog , 1996, Dagstuhl Seminar on Partial Evaluation.

[34]  Erik Sandewall,et al.  A Partial Evaluator, and its Use as a Programming Tool , 1976, Artif. Intell..

[35]  Carsten Kehler Holst Syntactic currying: yet another approach to partial evaluation , 1989 .

[36]  Danny De Schreye,et al.  Two semantics for definite meta-programs, using the non-ground representation , 1995 .

[37]  Harvey Abramson,et al.  Meta-programming in logic programming , 1989 .

[38]  Bart Demoen,et al.  Analysing Logic Programs Using 'Prop'-ositional Logic Programs and a Magic Wand , 1993, ILPS.

[39]  Leon Sterling,et al.  The Art of Prolog , 1987, IEEE Expert.

[40]  Michael Leuschel,et al.  Global Control for Partial Deduction through Characteristic Atoms and Global Trees , 1996, Dagstuhl Seminar on Partial Evaluation.

[41]  Valentin F. Turchin,et al.  The concept of a supercompiler , 1986, TOPL.

[42]  Wim Vanhoof,et al.  To Parse or Not To Parse , 1997, LOPSTR.

[43]  Gustaf Neumann,et al.  A Simple Transformation from Prolog-written Metalevel Interpreters into Compilers and its Implementation , 1990, RCLP.

[44]  Neil D. Jones,et al.  Mix: A self-applicable partial evaluator for experiments in compiler generation , 1989, LISP Symb. Comput..

[45]  Alberto Pettorossi,et al.  Transformation of Logic Programs: Foundations and Techniques , 1994, J. Log. Program..

[46]  Danny De Schreye,et al.  Towards creating specialised integrity checks through partial evaluation of meta-interpreters , 1995, PEPM '95.

[47]  Danny De Schreye,et al.  Automatic Finite Unfolding Using Well-Founded Measures , 1996, J. Log. Program..

[48]  Danny De Schreye,et al.  Logic Program Specialisation: How To Be More Specific , 1996, PLILP.

[49]  Maurice Bruynooghe,et al.  A Polyvariant Binding-Time Analysis for Off-line Partial Deduction , 1998, ESOP.

[50]  John P. Gallagher,et al.  Regular Approximation of Computation Paths in Logic and Functional Languages , 1996, Dagstuhl Seminar on Partial Evaluation.

[51]  Randy Goebel,et al.  Gracefully adding negation and disjunction to Prolog , 1986, ICLP.

[52]  John P. Gallagher,et al.  Ensuring Global Termination of Partial Deduction while Allowing Flexible Polyvariance , 1995, ICLP.

[53]  Robert Glück,et al.  Controlling conjunctive partial deduction of definite logic programs , 1996 .

[54]  Thom W. Frühwirth,et al.  Polymorphically Typed Logic Programs , 1991, ICLP.

[55]  Lars Birkedal,et al.  Hand-Writing Program Generator Generators , 1994, PLILP.

[56]  Roland N. Bol,et al.  Loop checking in partial deduction , 1993, J. Log. Program..

[57]  Robert Glück,et al.  An Algorithm of Generalization in Positive Supercompilation , 1995, ILPS.