A self-applicable partial evaluator for the logic programming language Goedel

Partial evaluation is a program specialisation technique that has been shown to have great potential in logic programming, particularly for the specialisation of meta-interpreters by the so-called “Futamura Projections”. Meta-interpreters and other meta-programs are programs which use another program as data. In this thesis we describe a partial evaluator for meta-programs in the logic programming language Godel. Godel is a declarative, general-purpose language which provides a number of higher-level programming features, including extensive support for meta-programming with a ground representation. The ground representation is a standard tool in mathematical logic in which object level variables are represented by ground terms at the meta-level. The ground representation is receiving increasing recognition as being essential for declarative meta-programming, although the computational expense that it incurs has largely precluded its use in the past. This thesis extends the basic techniques of partial evaluation to the facilities of Godel. Particular attention is given to the specialisation of the inherent overheads of meta-programs which use a ground representation and the foundations of a methodology for Godel meta-programs are laid down. The soundness of the partial evaluation techniques is proved and these techniques are incorporated into a declarative partial evaluator. We describe the implementation and provide termination and correctness proofs for the partial evaluator SAGE, an automatic program specialiser based upon sound finite unfolding that is able to specialise any Godel meta-program (or indeed, any Godel program at all). A significant illustration of the success of our techniques for specialising meta-programs which use a ground representation is provided by the self-application of this partial evaluator. We use the partial evaluator to specialise itself with respect to a range of meta-programs. By virtue of its self-applicability SAGE has been used to produce a compiler-generator, which we believe shall prove to be an immensely powerful and useful tool for meta-programming.

[1]  Ehud Shapiro,et al.  Meta interpreters for real , 1988 .

[2]  John C. Shepherdson,et al.  Unfold/fold transformations of logic programs , 1992, Mathematical Structures in Computer Science.

[3]  Saumya K. Debray,et al.  Automatic Mode Inference for Logic Programs , 1988, J. Log. Program..

[4]  Heikki Mannila,et al.  Flow Analysis of Prolog Programs , 1987, SLP.

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

[6]  Mikhail A. Bulyonkov,et al.  Extracting polyvariant binding time analysis from polyvariant specializer , 1993, PEPM '93.

[7]  Mark Wallace,et al.  A Treatment of Negation during Partial Evaluation , 1989, META.

[8]  John W. Lloyd,et al.  Properties of a Pruning Operator , 1990, Journal of Logic and Computation.

[9]  John W. Lloyd,et al.  A Partial Evaluation Procedure for Logic Programs , 1990, NACLP.

[10]  Danny De Schreye,et al.  Sound and Complete Partial Deduction with Unfolding Based on Well-Founded Measures , 1992, Theor. Comput. Sci..

[11]  John P. Gallagher,et al.  Specialisation of a Unification Algorithm , 1991, LOPSTR.

[12]  Stephen Owen,et al.  Issues in the Partial Evaluation of Meta-Interpreters , 1989, META.

[13]  Mats Carlsson,et al.  SICStus Prolog User''s Manual , 1993 .

[14]  Hirohisa Seki,et al.  Unfold/Fold Transformations of Stratified Programs , 1991, Theor. Comput. Sci..

[15]  Tadashi Kanamori,et al.  Abstract Interpretation based on OLDT Resolution , 1993, J. Log. Program..

[16]  Hirohisa Seki,et al.  Unfold/Fold Transformation of Stratified Programs. , 1989 .

[17]  Danny De Schreye,et al.  Automatic Termination Analysis , 1992, LOPSTR.

[18]  Peter Sestoft,et al.  The structure of a self-applicable partial evaluator , 1985, Programs as Data Objects.

[19]  Chris Hankin,et al.  Abstract Interpretation of Declarative Languages , 1987 .

[20]  Rodney W. Topor,et al.  A Semantics for Typed Logic Programs , 1992, Types in Logic Programming.

[21]  John W. Lloyd,et al.  Analysis of Meta-Programs , 1989, META.

[22]  Hassan Aït-Kaci,et al.  Warren's Abstract Machine: A Tutorial Reconstruction , 1991 .

[23]  Akikazu Takeuchi,et al.  Partial Evaluation of Prolog Programs and its Application to Meta Programming , 1986, IFIP Congress.

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

[25]  Maurice Bruynooghe,et al.  A Practical Framework for the Abstract Interpretation of Logic Programs , 1991, J. Log. Program..

[26]  John Wylie Lloyd,et al.  Foundations of Logic Programming , 1987, Symbolic Computation.

[27]  Danny De Schreye,et al.  Deriving Termination Proofs for Logic Programs, Using Abstract Procedures , 1991, ICLP.

[28]  Jeffrey D. Ullman,et al.  Efficient tests for top-down termination of logical rules , 1988, JACM.

[29]  Ulf Nilsson Towards a Methodology for the Design of Abstract Machines for Logic Programming Languages , 1993, J. Log. Program..

[30]  Manuel V. Hermenegildo,et al.  Combined Determination of Sharing and Freeness of Program Variables through Abstract Interpretation , 1991, ICLP.

[31]  Lutz Plümer,et al.  Termination Proofs for Logic Programs Based on Predicate Inequalities , 1990, ICLP.

[32]  Maurice Bruynooghe,et al.  Compiling Control , 1989, J. Log. Program..

[33]  Manuel V. Hermenegildo,et al.  Determination of Variable Dependence Information through Abstract Interpretation , 1989, NACLP.

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

[35]  John P. Gallagher,et al.  Transforming Logic Programs by Specialising Interpreters , 1986, ECAI.

[36]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[37]  John P. Gallagher,et al.  Using Safe Approximations of Fixed Points for Analysis of Logic Programs , 1989, META.

[38]  Jan Komorowski,et al.  Towards a Programming Methodology Founded on Partial Deduction , 1990, ECAI.

[39]  Henryk Jan Komorowski,et al.  A specification of an abstract Prolog machine and its application to partial evaluation , 1981 .

[40]  Christophe Lecoutre,et al.  Abstract Interpretation and Recursive Behaviour of Logic Programs , 1991, LOPSTR.

[41]  Saumya K. Debray,et al.  Abstract Interpretation of Logic Programs using Magic Transformations , 1994, J. Log. Program..

[42]  Robert A. Kowalski,et al.  Amalgamating language and metalanguage in logic programming , 1982 .

[43]  Tadashi Kanamori,et al.  Construction of Logic Programs Based on Generalized Unfold/Fold Rules , 1987, ICLP.

[44]  Donald A. Smith,et al.  Partial Evaluation of a CLP Language , 1990, NACLP.

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

[46]  Raf Venken A Prolog Meta-Interpreter for Partial Evaluation and its Application to Source to Source Transformation and Query-Optimisation , 1984, ECAI.

[47]  Peter Sestoft,et al.  An experiment in partial evaluation: the generation of a compiler generator , 1985, SIGP.

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

[49]  Chris Mellish,et al.  Abstract Interpretation of Prolog Programs , 1986, ICLP.

[50]  Maurice Bruynooghe,et al.  Generation and Compilation of Efficient Computation Rules , 1990, ICLP.

[51]  John P. Gallagher,et al.  Some low-level source transformations of logic programs , 1990 .

[52]  John W. Lloyd,et al.  The Gödel programming language , 1994 .

[53]  D. Andre de Waal,et al.  The Power of Partial Evaluation , 1993, LOPSTR.

[54]  Leon Sterling,et al.  Incremental Flavor-Mixing of Meta-Interpreters for Expert System Construction , 1986, SLP.

[55]  Dean Jacobs,et al.  Accurate and Efficient Approximation of Variable Aliasing in Logic Programs , 1989, NACLP.

[56]  Hirohisa Seki,et al.  Unfold/Fold Transformation of General Logic Programs for the Well-Founded Semantics , 1993, J. Log. Program..