Implementing Polymorphic Typing in a Logic Programming Language

Introducing types into a logic programming language leads to the need for typed unification within the computation model. In the presence of polymorphism and higher-order features, this aspect forces analysis of types at run-time. We propose extensions to the Warren Abstract Machine (WAM) that permit such analysis to be done with reasonable efficiency. Much information about the structures of types is present at compile-time, and we show that this information can be used to considerably reduce the work during execution. We illustrate our ideas in the context of a typed version of Prolog. We describe a modified representation for terms, new instructions and additional data areas that in conjunction with existing WAM structures suffice to implement this language. The nature of compiled code is illustrated through examples, and the kind of run-time overheads that are incurred for processing types is analyzed, especially in those cases where others have shown that type checking can be eliminated during execution. The ideas presented here are being used in an implementation of the higher-order language called @l Prolog.

[1]  Robert A. Kowalski,et al.  The Semantics of Predicate Logic as a Programming Language , 1976, JACM.

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

[3]  Gert Smolka TEL (Version 0.9) Report and User Manual , 1988 .

[4]  Saumya K. Debray Register Allocation in a Prolog Machine , 1986, SLP.

[5]  Michael J. C. Gordon,et al.  Edinburgh LCF: A mechanised logic of computation , 1979 .

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

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

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

[9]  Michael Hanus Horn Clause Programs with Polymorphic Types: Semantics and Resolution , 1991, Theor. Comput. Sci..

[10]  Gopalan Nadathur,et al.  Implementing Logic Programming Languages with Polymorphic Typing , 1991 .

[11]  Uday S. Reddy,et al.  Typed Prolog: A Semantic Reconstruction of the Mycroft-O'Keefe Type System , 1991, ISLP.

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

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

[14]  Gopalan Nadathur,et al.  Towards a WAM model for ?Prolog , 1989 .

[15]  Christoph Beierle,et al.  Extending the Warren Abstract Machine to Polymorphic Order-Sorted Resolution , 1991, ISLP.

[16]  Gopalan Nadathur,et al.  Implementation Considerations for Higher-Order Features in Logic Programming , 1993 .

[17]  Alan Mycroft,et al.  A Polymorphic Type System for Prolog , 1984, Logic Programming Workshop.

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

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

[20]  Michael Hanus Polymorphic High-Order Programming in Prolog , 1989, ICLP.

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

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