Implementing a Notion of Modules in the Logic Programming Language Prolog Implementing a Notion of Modules in the Logic Programming Language Prolog

Issues concerning the implementation of a notion of modules in the higher-order logic programming language Prolog are examined. A program in this language is a composite of type declarations and procedure deenitions. The module construct that is considered permits large collections of such declarations and deenitions to be decomposed into smaller units. Mechanisms are provided for controlling the interaction of these units and for restricting the visibility of names used within any unit. The typical interaction between modules has both a static and a dynamic nature. The parsing of expressions in a module might require declarations in a module that it interacts with, and this information must be available during compilation. Procedure deenitions within a module might utilize procedures presented in other modules and support must be provided for making the appropriate invocation during execution. Our concern here is largely with the dynamic aspects of module interaction. We describe a method for compiling each module into an independent fragment of code. Static interactions prevent the compilation of interacting modules from being completely decoupled. However, using the idea of an interface deenition presented here, a fair degree of independence can be achieved even at this level. The dynamic semantics of the module construct involve enhancing existing program contexts with the procedures deened in particular modules. A method is presented for achieving this eeect through a linking process applied to the compiled code generated for each module. A direct implementation of the dynamic semantics leads to considerable redundancy in search. We present a way in which this redundancy can be controlled, prove the correctness of our approach and describe run-time structures for incorporating this idea into the overall implementation.

[1]  Dale Miller,et al.  A Logical Analysis of Modules in Logic Programming , 1989, J. Log. Program..

[2]  Elsa L. Gunter Extensions to Logic Programming Motivated by the Construction of a Generic Theorem Prover , 1989, ELP.

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

[4]  Richard A. O'Keefe,et al.  Towards an Algebra for Constructing Logic Programs , 1985, International Conference on Spoken Language Processing.

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

[6]  Dale Miller,et al.  Lexical Scoping as Universal Quantification , 1989, ICLP.

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

[8]  Evelina Lamma,et al.  The Design of an Abstract Machine for Efficient Implementation of Contexts in Logic Programming , 1989, International Conference on Logic Programming.

[9]  Luís Monteiro,et al.  Contextual Logic Programming , 1989, ICLP.

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

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

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

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

[14]  Donald Sannella,et al.  A Calculus for the Construction of Modular Prolog Programs , 1987, J. Log. Program..

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