Efficient evaluation of normal logic programs

An accident of implementation may be responsible for the fact that Logic Programming, Deductive Databases and Non-Monotonic Reasoning are different subfields. Logic Programming views logic as a programming language--usually through Prolog or an extension of Prolog. The Deductive Database community regards logic as a database language, often using a variant of magic sets as a basis for implementation. Finally the field of Non-Monotonic Reasoning studies non-classical logics of interest to Artificial Intelligence or other applications. However, there are currently few engines powerful enough to execute practical programs in Non-Monotonic Reasoning. Tabling methods have been formulated recently that have the potential to unify these subfields. This thesis explores how to efficiently implement one such method: SLG. Previous formulations of SLG do not make explicit the search strategy for an evaluation, or consider trade-offs between alternate search strategies. To bring out these features, an operational semantics for SLG, SLG$\sb{O}$, is defined which makes explicit algorithms for completion and other operations. This formalism allows proofs of correctness of algorithms upon which the SLG-WAM is based, as well as proofs of termination for programs of bounded-term size. The modelling of search strategy is powerful enough to derive preliminary results for the cut/O operator as extended to SLG, and for combining SLG and SLDNF using Existential Negation. Based on the SLG$\sb{O}$ search strategy, Part 2 describes the SLG-WAM, an engine which evaluates SLG for stationary stratified programs, and integrates SLG with full Prolog functionality, including the cut, findall, and meta-predicates. Data structures and instructions of the SLG-WAM are described in detail. The SLG-WAM is in fact the engine for the XSB system, and has been installed in hundreds of sites around the world. Part three analyzes the SLG-WAM and compares its performance with the WAM and with other deductive databases. When executing queries using SLD, the overhead of SLG to the WAM is about 10-15% on some standard benchmarks. At the same time, the SLG-WAM is an order of magnitude faster than current deductive databases for in-memory queries. These results are analyzed in detail, and areas for further optimization are identified.

[1]  Richard C. T. Lee,et al.  Symbolic logic and mechanical theorem proving , 1973, Computer science classics.

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

[3]  David Scott Warren,et al.  C-logic of complex objects , 1989, PODS '89.

[4]  David Scott Warren Programming the PTQ Grammar in XSB , 1993, Workshop on Programming with Logic Databases , ILPS.

[5]  David H. D. Warren,et al.  The SRI Model for Or-Parallel Execution of Prolog: Abstract Design and Implementation Issues , 1987, SLP.

[6]  T. Swift,et al.  Uni cation Factoring for E cient Execution of Logic Programs , 1995 .

[7]  Catriel Beeri,et al.  Optimizing existential datalog queries , 1988, PODS.

[8]  Mats Carlsson,et al.  Freeze, Indexing, and Other Implementation Issues in the WAM , 1987, ICLP.

[9]  Peter J. Stuckey,et al.  Well-founded ordered search , 1993 .

[10]  Shinichi Morishita,et al.  An alternating fixpoint tailored to magic programs , 1993, PODS '93.

[11]  David Scott Warren,et al.  An Abstract Machine for SLG Resolution: Definite Programs , 1994, ILPS.

[12]  Richard A. O'Keefe,et al.  The Craft of Prolog , 1990 .

[13]  Adrian Walker,et al.  Towards a Theory of Declarative Knowledge , 1988, Foundations of Deductive Databases and Logic Programming..

[14]  Andrew Taylor,et al.  LIPS on a MIPS: Results from a Prolog Compiler for a RISC , 1990, ICLP.

[15]  David B. Kemp,et al.  Completeness of a Top-Down Query Evaluation Procedure for Stratified Databases , 1988, ICLP/SLP.

[16]  Seif Haridi,et al.  Or-Parallel Prolog on Shared Memory Multiprocessors , 1989, J. Log. Program..

[17]  Hong Gao Declarative picture description and interpretation in logic , 1992 .

[18]  Allen Van Gelder Negation as Failure using Tight Derivations for General Logic Programs , 1989, J. Log. Program..

[19]  Teodor C. Przymusinski On the Declarative Semantics of Deductive Databases and Logic Programs , 1988, Foundations of Deductive Databases and Logic Programming..

[20]  R. Ramesh,et al.  A Portable Method of Integrating SLG Resolution into Prolog Systems , 1994, ILPS.

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

[22]  Evan Tick,et al.  Memory performance of Prolog architectures , 1987, The Kluwer international series in engineering and computer science.

[23]  I. V. Ramakrishnan,et al.  Multistage indexing algorithms for speeding prolog execution , 1994, Softw. Pract. Exp..

[24]  Roland N. Bol,et al.  Tabulated Resolution for the Well-Founded Semantics , 1993, J. Log. Program..

[25]  Weidong Chen,et al.  Towards Effective Evaluation of General Logic Programs , 1993 .

[26]  Roland N. Bol,et al.  The Underlying Search for Magic Templates and Tabulation , 1993, ICLP.

[27]  Micha Meier Recursion versus Iteration in Prolog , 1991, ICLP.

[28]  S. Sudarshan,et al.  Optimizing Bottom-Up Query Evaluation for Deductive Databases , 1992 .

[29]  Juliana Freire,et al.  The XSB Programmer’s Manual , 1800 .

[30]  C. R. Ramakrishnan,et al.  Extracting Determinacy in Logic Programs , 1993, ICLP.

[31]  Kenneth A. Ross,et al.  Modular acyclicity and tail recursion in logic programs , 1991, PODS.

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

[33]  Ling Liu,et al.  LogicBase: a deductive database system prototype , 1994, CIKM '94.

[34]  K. A. Ross Modular stratification and magic sets for DATALOG programs with negation , 1990, PODS 1990.

[35]  Lutz Plüer Termination proofs for logic programs based on predicate inequalities , 1990 .

[36]  Ewing L. Lusk,et al.  Experiments with OR-Parallel Logic Programs , 1987, ICLP.

[37]  Michael Kifer,et al.  Logical foundations of object-oriented and frame-based languages , 1995, JACM.

[38]  Michael Kifer,et al.  HILOG: A Foundation for Higher-Order Logic Programming , 1993, J. Log. Program..

[39]  Divesh Srivastava,et al.  The valid model semantics for logic programs , 1992, PODS '92.

[40]  Evan Tick,et al.  Parallel logic programming , 1991, Logic programming.

[41]  David Scott Warren,et al.  Analysis of Sequential SLG Evaluation , 1994 .

[42]  Andrew Taylor Removal of Dereferencing and Trailing in Prolog Compilation , 1989, ICLP.

[43]  Jeffrey D. Ullman,et al.  A Survey of Research in Deductive Database Systems , 1995 .

[44]  Laurent Vieille,et al.  Recursive Query Processing: The Power of Logic , 1989, Theor. Comput. Sci..

[45]  Yehoshua Sagiv,et al.  Is There Anything Better than Magic? , 1990, NACLP.

[46]  Peter Van Roy,et al.  1983-1993: The Wonder Years of Sequential Prolog Implementation , 1994, J. Log. Program..

[47]  Teodor C. Przymusinski The Well-Founded Semantics Coincides with the Three-Valued Stable Semantics , 1990, Fundam. Inform..

[48]  David Scott Warren,et al.  A Goal-Oriented Approach to Computing the Well-Founded Semantics , 1993, J. Log. Program..

[49]  Carlo Zaniolo,et al.  The LDL System Prototype , 1990, IEEE Trans. Knowl. Data Eng..

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

[51]  Khayri A. M. Ali,et al.  The Muse Or-Parallel Prolog Model and its Performance , 1990, NACLP.

[52]  Catriel Beeri,et al.  On the power of magic , 1987, J. Log. Program..

[53]  Hidenori Itoh,et al.  A Query Evaluation Method for Stratified Programs Under the Extended CWA , 1988, ICLP/SLP.

[54]  S. Sudarshan,et al.  Optimizations of Bottom-Up Evaluation with Non-Ground Terms , 1993, ILPS.

[55]  Suzanne Wagner Dietrich Extension tables for recursive query evaluation , 1987 .

[56]  Kenneth A. Ross,et al.  The well-founded semantics for general logic programs , 1991, JACM.

[57]  Timothy J. Hickey,et al.  Global Compilation of Prolog , 1989, J. Log. Program..

[58]  I. V. Ramakrishnan,et al.  Adaptive Pattern Matching , 1992, SIAM J. Comput..

[59]  V. S. Subrahmanian,et al.  Theory of Generalized Annotated Logic Programming and its Applications , 1992, J. Log. Program..

[60]  Allen Van Gelder,et al.  The Alternating Fixpoint of Logic Programs with Negation , 1993, J. Comput. Syst. Sci..

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

[62]  Kotagiri Ramamohanarao,et al.  Design overview of the Aditi deductive database system , 1991, [1991] Proceedings. Seventh International Conference on Data Engineering.

[63]  Konstantinos Sagonas,et al.  Xsb as an Eecient Deductive Database Engine , 1994 .