Towards a New Step of Logic Paradigm
Deductive and Object-Oriented Databases
Deductive and Object-Oriented Databases W. Kim, J.-M. Nicolas, and S. Nishio (Editors) It is desirable to answer queries posed to deductive databases by computing fixpoints because such computations are directly amenable to set-oriented fact processing. However, the classical fixpoint procedures based on bottom-up reasoning -the naive and semi-naive methods -are rather primitive and often inefficient. In this article, we rely on bottom-up meta-interpretation for formalizing a new fixpoint
... ure that performs a different kind of reasoning: We specify a top-down query answering method, which we call the Backward Fixpoint Procedure. Then, we reconsider query evaluation methods for recursive databases. First, we show that the methods based on rewriting on the one hand, and on resolution on the other hand, implement the Backward Fixpoint Procedure. Second, we interpret the rewriting of the Alexander and Magic Set methods as a specialization of the Backward Fixpoint Procedure. Finally, we argue that this rewriting is also needed for implementing efficiently the resolution-based methods. Thus, the methods based on rewriting and the methods based on resolution implement the same top-down evaluation of the original database rules by means of auxiliary rules processed bottom-up. The naive and semi-naive methods are based on rather primitive deduction techniques and are often inefficient. Indeed, both methods perform forward reasoning, i.e., they proceed bottom-up from the database rules and facts. Therefore, they do not use the constants occurring in the queries for restricting the search space. In contrast, such a restriction is a byproduct of backward -or top-down -reasoning. The rewriting of the Alexander [RLK 86] and Magic Set [BMSU 86, BR 87] methods aims at achieving the same restriction on the search space with bottom-up reasoning. 26 In this paper, we show that it is possible to keep the advantages of processing queries through fixpoint computations, without necessarily sticking to the basic principle of the naive and semi-naive methods. We specify a new fixpoint query answering procedure, the 'Backward Fixpoint Procedure', which is based on top-down -or backward -reasoning. In other words, we apply fixpoint theory to databases with another operator than the classical immediate consequence operator of van Emden and Kowalski. The Backward Fixpoint Procedure is a sound and complete query answering method for recursive databases. We rely on bottom-up meta-interpretation for formalizing the Backward Fixpoint Procedure, i.e., we specify a top-down evaluation of the database rules in a meta-language by means of rules intended for bottom-up processing. Meta-interpretation is a technique commonly used in Functional and Logic Programming. As we show below, bottom-up metainterpretation permits one to obtain a surprisingly simple specification for the Backward Fixpoint Procedure. Then, we reconsider evaluation methods for recursive databases from the viewpoint of fixpoint computation. Several methods have been proposed for evaluating queries on recursive databases. Those that ensure termination on all recursive databases defining finitely many facts -e.g., function-free databases -follow one or the other of two approaches. The methods of the first type rewrite the database rules and process the rewritten rules bottom- up. The Alexander [RLK 86] and Magic Set [BMSU 86, BR 87] methods are based on this principle. The second approach is an extension of SLD-Resolution [LLO 87] that consists of storing the encountered queries and the proven answers. The ET* and ET mt algorithms [DIE 87], OLDT-Resolution [TS 86], QSQ and SLDAL-Resolution [VIE 87], and the RQA/FQI procedure [NEJ 87], are methods of the second type. We investigate both types of methods. We show that the methods based on rewriting as well as the methods based on resolution implement the Backward Fixpoint Procedure. In other words, they express the same top-down reasoning principle in different formalisms. Similarities between rewriting-based and resolution-based methods were already observed by many authors. In particular, Beeri and Ramakrishnan showed in [BR 87] that the same strategies -called 'sideway information passing strategies' -can be applied to optimize both types of methods. Moreover, Ramakrishnan noticed in [RAM 88] that the same propagation of constants is possible with rewriting-based and resolution-based methods. This point was investigated more formally by Ullman in [ULL 89]. Commonalities in the inferences of both types of methods were often cited -e.g., in [DR 86, BEE 89, VIE 89]. Recently, Seki established a one-to-one mapping between the inferences performed by methods of both types [SEK 89 ]. These observations and results are precursors of the study we present here. Examining efficient implementations of the Backward Fixpoint Procedure, we investigate a technique called specialization. Specializing meta-interpreters is a classical way of obtaining efficient procedures from formal specifications. We show that the rewriting of the Alexander and Magic Set methods can be interpreted as a specialization of the Backward Fixpoint Procedure. We argue that this rewriting is also needed in efficient implementations of resolution-based methods. This motivates features of the implementation of SLDAL-Resolution which is reported in [LV 89]. Thus, efficient implementations of methods of both kinds have to rely on the same rewriting of the database rules and to process the rewritten rules bottom-up. Relying on the meta-interpreter for the Backward Fixpoint Procedure, we give in [BRY 89] simple soundness and completeness proofs for the Alexander and Magic Set methods, and for the ET* and ET interp algorithms, OLDT-Resolution, QSQ and SLDAL-Resolution, and the RQA/FQI procedure. Thus, bottom-up meta-interpretation appears to be a useful formalism for theoretical investigations of query answering procedures. Corollary 7.1: The algorithms ET* and ET interp , OLDT-Resolution, QSQ, SLDAL-Resolution, and the RQA/FQI procedure are sound and complete query answering methods for (possibly recursive) Horn databases. They are terminating query answering methods for databases defining finitely many facts -e.g., function-free databases. The fixpoint formalism is useful to understand the differences between some resolutionbased methods. In this formalism, the resolution-based methods are viewed as computing a fixpoint on answers and queries. In [DIE 87] an incomplete algorithm, called ET, is considered for defining the complete methods ET* and ET interp . The algorithm ET corresponds to the procedure QSQ as it is defined in [VIE 86] -QSQ is corrected in [NEJ 87] and [VIE 87]. The reason for incompleteness is that queries are generated only during the first round. During the subsequent rounds, the fixpoint is performed on answers only. Completeness requires treating answers and queries similarly, i.e., computing a fixpoint on both answers and queries.