Abstract. This paper describes a deduction method that works both top-down and bottom-up. The method can be viewed as an extension of a well-known ...
Generalized Earley Deduction and its Correctness Michelle Kim IBM Research Division T.J. Watson Research Center Yorktown Heights, NY 10598
Clemens Beckstein CS Department #8 (IMMD VIII) University of Erlangen-Nuremberg 8520 Erlangen, W. Germany
Abstract This paper describes a deduction method that works both top-down and bottom-up. The method can be viewed as an extension of a well-known approach|Earley deduction|to handle negation-as-failure. We show that with respect to the strati ed model theory of [1] the method is sound, that it is strongly complete (terminating) for function-free programs with negation, and complete for programs without negation if function symbols are allowed. The method uses the call graph of a program to represent static dependencies, and a Truth Maintenance System to store dynamic dependencies between partial lemmas generated by the deduction method. We argue by means of examples that these dependencies allow the method to avoid some redundant deductions, and that they are useful in forward reasoning in the presence of negation-as-failure.
1 Introduction Whether a logic program should be processed bottom-up or top-down has been much discussed in the literature. The two approaches have been compared and contrasted mainly on strong (i.e. terminating) completeness over programs without function symbols, weak (non-terminating) completeness, coverage and eciency. The top-down approach is goal directed, often a good feature for eciency. However, it has been shown that strict top-down approaches cannot be strongly complete over programs without function symbols [4]. Vieille has described top-down approaches in which lemmas are used to obtain termination over programs without function symbols, and there is a completeness proof for one of his methods (see [13]). The bottom-up approach is complete and terminating over programs without function symbols, but used naively computes the entire deductive closure of a program in order to answer any question, so it is not usually ecient. Various methods based on `magic sets' (cf. [12]) have been proposed to guide bottom-up deduction, but appear to sometimes need very large numbers of auxiliary `magic rules' (see [2]). Pereira and Warren proposed a mixed bottom-up and top-down deduction method (in [11]), which is based on an algorithm by Earley which parses context-free grammars [7] and techniques developed in the context of chart-parsing [9]. Earley deduction, while combining the bottom-up and top-down approaches, has not (to our knowledge) been extended to cover negation-as-failure. In this paper we take the basic Earley deduction framework, extend it to handle negation-as-failure, and provide (strong) completeness and soundness proofs for the method. The method uses the call graph of a DATALOG program to constrain deduction in the presence of negation, and the ATMS [6] to maintain important data about the ongoing deduction process. It has been implemented as a meta-interpreter in PROLOG.
2 The Nature of Earley Deduction Earley deduction works by utilizing two kinds of deduction steps: Instantiation and Reduction. We can think of instantiations as backward chaining steps (top-down) and reductions as forward chaining 1
(bottom-up) steps. Backward chaining steps identify rules relevant to a given query and forward chaining steps compute the consequences of those rules. In Earley deduction backward and forward chaining are interleaved and partly grounded rules, as well as fragments of partly grounded rules (the lemmas), are maintained. An Earley prover operates on two sets of de nite clauses: the given program (input clauses) and a so-called state. The state is a collection of derived clauses (conditional lemmas). It is initialized with a query and describes the progress made by the prover in its attempt to derive answers to this query. At any moment a selection function distinguishes a certain literal of every non-unit clause in the state upon which either an instantiation or a reduction is performed. In order to perform an instantiation , a clause in the current state is chosen whose selected body literal L uni es with the head of a non-unit clause H B in the program. In this situation a new clause C 0 with C 0 = (H B) is added to the state where = mgu(L; H ) (the most general uni er of L and H ). A reduction step involves a non-unit clause C of the state and a unit clause F from either the program or the state. If C 0 is the clause C with its selected body literal L removed, then the new clause added to the state is C 0 where = mgu(L; F ). In both cases a check whether the new clause is subsumed by an older clause in the state is made before the clause is added. As can be seen from these de nitions, Earley deduction computes only part of the xpoint of a logic program. It combines the goal-directedness of backward operating proof procedures like SLD resolution with the robustness of forward operating procedures. Earley deduction can be realized in many dierent ways: the method itself does not de ne a strategy that determines when to perform an instantiation and when to do a reduction if there is a choice. In order to simplify proofs about Earley deduction we reformulate Earley deduction as a meta-program E for a meta-interpreter that operates bottom-up1 : fact (Q) lemma (Q B ) ^ fact (B ) (E1) query (B ) lemma (Q B ) ^ B 6= (C1 ^ C2 ) (E2) query (B1 ) lemma (Q B1 ^ B2 ) (E3) lemma (Q B ) query (Q) ^ rule (Q B ) (E4) lemma (Q B2 ) lemma (Q B1 ^ B2 ) ^ fact (B1 ) (E5) The variables in this meta-program range over atoms or conjunctions of atoms in the language of the object-program. fact (Q) is considered true if either Q is a fact of the program or fact (Q) was deduced earlier by rule (E1). rule (Q B ) is true if (Q B ) is a rule of the object-program. Rules (E1) and (E5) realize reduction steps whereas rule (E4) is responsible for instantiations. Rules (E3) and (E5) make up a left-to-right selection strategy. The following is a suitable bottom-up operating meta-interpreter (called demo and written in VM-PROLOG). We will need it later for termination considerations: demo(Q,P,Ans)