Implementation Considerations for Higher-Order Features in Logic Programming

This paper examines implementation problems that arise from providing for aspects of higher-order programming within and enhancing the metalanguage abilities of logic programming. One issue of concern is a representation for the simply-typed lambda terms that replace the usual first-order terms as data structures; this representation must support an efficient realization of $\lambda$-conversion operations on these terms. Another issue is the handling of higher-order unification that becomes an integral part of the computational model. An implementation must cater to the branching nature of this operation and also provide a means for temporarily suspending the solution of a unification problem. A final issue concerns the treatment of goals whose structure is not statically apparent. These problems are discussed in detail and solutions to them are described. A representation for lambda terms is presented that uses the de Bruijn ``nameless'''' notation and also permits reduction substitutions to be performed lazily. This notation obviates % the need for $\alpha$-conversion and also supports an efficient implementation of $\beta$-reduction. Branching in unification is implemented by using a depth-first search strategy with backtracking. A structure that is called a branch point record and is akin to the choice point record of the Warren Abstract Machine (WAM) is described for remembering alternatives in unification. An explicit representation for unification problems is presented that permits sharing and also supports the rapid reinstatement of earlier versions of the problem. The implementation of unification is tuned to yield an efficient solution to first-order like problems, in fact through the use of compiled code as in the WAM. A compilation method is also discussed for goals whose structure changes during execution. The various ideas presented here form part of an ongoing implementation of a higher-order logic programming language called $\lambda$Prolog.

[1]  Gopalan Nadathur,et al.  A representation of Lambda terms suitable for operations on their intensions , 1990, LISP and Functional Programming.

[2]  Amy P. Felty,et al.  Specifying and implementing theorem provers in a higher-order logic programming language , 1989 .

[3]  Gopalan Nadathur,et al.  Implementation Techniques for Scoping Constructs in Logic Programming , 1991, ICLP.

[4]  Dale Miller,et al.  A Logic Programming Language with Lambda-Abstraction, Function Variables, and Simple Unification , 1991, J. Log. Comput..

[5]  Gopalan Nadathur,et al.  Some Uses of Higher-Order Logic in Computational Linguistics , 1986, ACL.

[6]  Lawrence C. Paulson The representation of logics in higher-order logic , 1987 .

[7]  Alonzo Church,et al.  A formulation of the simple theory of types , 1940, Journal of Symbolic Logic.

[8]  Olivier Ridoux,et al.  Naïve Reverse Can be Linear , 1991, ICLP.

[9]  Frank Pfenning,et al.  A Semi-Functional Implementation of a Higher-Order Logic Programming Language , 1990 .

[10]  Gopalan Nadathur,et al.  A Notation for Lambda Terms I: a Generalization of Environments a Notation for Lambda Terms I: a Generalization of Environments , 1994 .

[11]  Amy P. Felty,et al.  Specifying Theorem Provers in a Higher-Order Logic Programming Language , 1988, CADE.

[12]  John Hannan,et al.  Investigating a proof-theoretic meta-language for functional programs , 1990 .

[13]  Pierre-Louis Curien,et al.  The Categorical Abstract Machine , 1987, Sci. Comput. Program..

[14]  Dale A. Miller,et al.  AN OVERVIEW OF PROLOG , 1988 .

[15]  John Field,et al.  On laziness and optimality in lambda interpreters: tools for specification and analysis , 1989, POPL '90.

[16]  Gopalan Nadathur,et al.  Uniform Proofs as a Foundation for Logic Programming , 1991, Ann. Pure Appl. Log..

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

[19]  Gopalan Nadathur,et al.  Implementing Polymorphic Typing in a Logic Programming Language , 1994, Comput. Lang..

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

[21]  de Ng Dick Bruijn Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem , 1972 .

[22]  William F. Clocksin,et al.  Programming in Prolog , 1987, Springer Berlin Heidelberg.

[23]  G. Nadathur,et al.  A Notation for Lambda Terms II: Refinements and Applications , 1994 .

[24]  Gopalan Nadathur,et al.  A Logic Programming Approach to Manipulating Formulas and Programs , 1987, SLP.

[25]  Frank Pfenning,et al.  Partial polymorphic type inference and higher-order unification , 1988, LISP and Functional Programming.

[26]  Krzysztof R. Apt,et al.  Contributions to the Theory of Logic Programming , 1982, JACM.

[27]  Gopalan Nadathur,et al.  The Type System of a Higher-Order Logic Programming Language , 1992, Types in Logic Programming.

[28]  Martín Abadi,et al.  Explicit substitutions , 1989, POPL '90.

[29]  Dale Miller,et al.  Uses of Higher-Order Unification for Implementing Program Transformers , 1988, ICLP/SLP.

[30]  Gérard P. Huet,et al.  A Unification Algorithm for Typed lambda-Calculus , 1975, Theor. Comput. Sci..

[31]  Frank Pfenning,et al.  An Empirical Study of the Runtime Behavior of Higher-Order Logic Programs , 1992 .

[32]  Gopalan Nadathur,et al.  Scoping Constructs in Logic Programming: Implementation Problems and their Solutions , 1995, J. Log. Program..

[33]  Gopalan Nadathur,et al.  Higher-order Horn clauses , 1990, JACM.