In: B. Wolfinger (Ed): Innovationen bei Rechen- und Kommunikationssystemen (IFIP-Congress, Workshop FG2: Disjunctive Logic Programming and Disjunctive Databases), Springer, 1994, pp. 83–91.
A Disjunctive Semantics Based on Unfolding and Bottom-Up Evaluation Stefan Brass1 and J¨ urgen Dix2 1
Univ. of Hannover, Inst. f. Informatik, Lange Laube 22, D-30159 Hannover, FRG,
[email protected] 2 Univ. of Koblenz, Inst. f. Informatik, Rheinau 1, D-56075 Koblenz, FRG,
[email protected]
Abstract. We define a new semantics for disjunctive logic programs in an abstract way as the weakest semantics with certain properties, the most important being the unfolding-property (GPPE). Our semantics is similar to the strong well-founded semantics proposed by Ross, but seems to be more regularly behaved. It is an extension of both the well-founded semantics WFS and the generalized closed world semantics GCWA. We then present a bottom-up query-evaluation method for this semantics. An important feature of our approach is that we directly derive the algorithm from the given abstract properties of the logic programming semantics. The idea of the method is to compute derived rule instances with purely negative bodies (corresponding to Bry’s conditional facts and Chen/Warren’s residual program), and then to apply reduction steps in order to eliminate the conditions where possible.
1
Introduction
In this paper, we define a semantics for disjunctive logic programs based on abstract properties of such semantics, and show how to derive a bottom-up query evaluation algorithm from these properties. Abstract properties of logic programming semantics were extensively investigated in [Dix94c] for normal, and in [Dix92b, DM94] for disjunctive programs. They were already used for implementation purposes in [MD93], but here we show that a disjunctive extension of the well-founded semantics can be implemented by only using these properties. This means that our semantics is the weakest semantics with these properties (weakest in the sense of the information ordering: every atom which cannot be determined to be true or false by applying these properties is undefined in our semantics). For non-disjunctive programs, similar characterizations were obtained by Dix in [Dix94b]. There are quite a number of proposed semantics for disjunctive logic programs (see [Dix94c]). In this paper we define an interesting semantics by simply requiring some very natural properties. Our semantics (D-WFS) is a joint generalization of the well-founded semantics for non-disjunctive programs and the generalized closed world assumption (GCWA) for negation-free disjunctive programs. In addition, our semantics is quite similar to the strong well-founded 1
semantics proposed by Ross [Ros90], but it is more regularly behaved, as the following example shows: Example 1 (Strong WFS vs. GCWA and PERFECT). Consider the following positive logic program: p ∨ q ← r. p ∨ r. r ← p. The strong well-founded model as defined in [Ros90] contains ¬p! This is derivable neither in the GCWA nor the perfect model semantics (note that the given program is logically equivalent to {p ∨ q, r}). So this is a counterexample to [Ros90, Theorem 5.2]1 . Furthermore, if one adds the disjunction p ∨ q which is contained in the strong well-founded model, this changes the semantics and ¬p is no longer derivable. Finally, the example also shows that this semantics does not allow unfolding (see the GPPE-property defined below). 2 Our semantics solves these problems, but it is otherwise quite similar to the strong WFS: Example 2 (D-WFS is weaker than PERFECT). Consider the following stratified disjunctive logic program due to Ross: p ∨ q. r ← ¬p. r ← ¬q. Here the strong WFS as well as our semantics D-WFS leave r undefined, because p and q are undefined. In contrast, the perfect model semantics allows to conclude r, which is required for any semantics having a really exclusive or. 2 Of course, in order to really work with our semantics, the abstract definition is not very useful. Therefore, we develop a bottom-up query evaluation algorithm based only on the given semantical properties. Bottom-up query evaluation for disjunctive default theories was investigated in [BL92, BL93], this especially includes the perfect model semantics. In [KSS91], a bottom-up algorithm for computing the well-founded model of non-disjunctive programs was proposed — it can in fact be derived from our approach. There are also a number of top-down query evaluation algorithms for the well-founded semantics without disjunctions, e.g. [CW93b]. Compared to them, the main feature of our approach is its simplicity (which is quite usual for bottom-up methods). Finally, our method is also closely related to the work of Bry on a formalization of logic programming in constructive logic [Bry90]. He developed the notion of conditional facts, which we generalize to the disjunctive case in this paper. Our paper is structured as follows: In Section 2, we introduce the abstract properties of logic programming semantics that we need and use them to define 1
Ross told us that Dung independently noted the failure of this theorem.
2
the weakest semantics satisfying these conditions: D-WFS. Based on these properties we develop our query evaluation algorithm in Section 3, which computes D-WFS. Finally, we give a short summary and an outlook on future work and possible optimizations in Section 4.
2
Semantics of Logic Programs
In this paper, we consider allowed disjunctive DATALOG programs over some fixed function-free finite signature Σ (the program transformations may change the set of actually occuring symbols, but we wish to keep the syntactic base). Definition 1 (Logic Program Φ). A logic program Φ is a finite set of rules of the form A1 ∨ · · · ∨ Ak ← B1 ∧ · · · ∧ Bm ∧ ¬C1 ∧ · · · ∧ ¬Cn , where the Ai /Bi /Ci are Σ-atoms not containing function symbols, k ≥ 1, m ≥ 0, n ≥ 0, and every variable of the rule appears in one of the Bi . We identify such a rule with the triple consisting of the following sets of atoms A := {A1 , . . . , Ak }, B := {B1 , . . . , Bm }, C := {C1 , . . . , Cn }, and write it as A ← B ∧ ¬C. Definition 2 (Instantiation Φ∗ , Possibly True Facts P(Φ)). We write Φ∗ for the full instantiation of Φ (wrt Σ) and P(Φ) for the set of atoms occuring in rule heads in Φ∗ . A logic program or deductive database is used by posing queries. In fact, boolean queries are sufficient, since we usually require that θ is an answer to ψ iff “yes” is an answer to ψθ. We also need no conjunctive queries, since ψ1 ∧ ψ2 is answered with “yes” iff both subqueries are answered “yes”. However, we need disjunctive queries, since the result of ψ1 ∨ ψ2 cannot be derived from the results of the single queries. Definition 3 (Semantics |∼). A semantics |∼ is a relation between logic programs over Σ and pure disjunctions of ground literals over Σ satisfying the following requirements: 1. 2. 3. 4.
Φ |∼ ψ ⇐⇒ Φ∗ |∼ ψ (instantiation invariance). If Φ |∼ ψ and ψ ⊆ ψ 0 , then Φ |∼ ψ 0 (right weakening). If A ← true ∈ Φ for a ground disjunction A, then Φ |∼ A (necessarily true). If A 6∈ P(Φ) for some Σ-ground atom A, then Φ |∼ ¬A (necessarily false).
By the semantics of a logic program Φ, we mean S|∼ (Φ) := {ψ | Φ |∼ ψ}. Note that also semantics defined by declaring a certain set of models fit into this framework, we simply take the sceptical view (truth in all intended models). We base our discussion on abstract properties of logic programming semantics. All of them require that certain elementary transformations do not change the semantics of a given logic program, i.e. are |∼-equivalence transformations: 3
Definition 4 (|∼-Equivalence Transformation). We call a transformation Φ 7→ Φ0 a |∼-equivalence transformation iff Φ |∼ ψ ⇐⇒ Φ0 |∼ ψ for all ψ, i.e. S|∼ (Φ) = S|∼ (Φ0 ). An especially important such transformation is partial evaluation in the sense of the “unfolding” operation. It is the “Generalized Principle of Partial Evaluation (GPPE)” of [Dix94c]: Definition 5 (GPPE). A semantics |∼ satisfies GPPE iff the following transformation on instantiated logic programs is a |∼-equivalence transformation: Replace a rule A ← B ∧ ¬C where B contains an atom B by the rules A ∪ Ai − {B} ← B − {B} ∪ Bi ∧ ¬ C ∪ Ci (i = 1, . . . , n) where Ai ← Bi ∧ Ci (i = 1, . . . , n) are all rules with B ∈ Ai .
In the case of non-disjunctive programs this simply means that a positive body literal B is replaced by the bodies of all rules with head literal B. The well-founded and the stable model semantics allow this transfomation. WFS + , however, does not2 : we consider the program p ← ¬p, q ← p. GPPE allows to replace the second rule by q ← ¬p, and, whereas the first program derives p and therefore q under WFS+ , this is no longer true after the transformation. The next property we need is that tautological clauses like p ← p do not influence the semantics of a logic program. This and the following property together correspond to the “equivalence” principle of [Dix94b]: Definition 6 (Elimination of Tautologies). A semantics |∼ allows the elimination of tautologies iff the following transformation on instantiated logic programs is a |∼-equivalence transformation: Delete a rule A ← B ∧ ¬C with A ∩ B 6= ∅. The following property allows us to remove rules which are weakenings of other rules in a logic program. This and the reduction properties defined below are special cases of the D-reduction introduced in [MD93, DM94]. Definition 7 (Elimination of Non-Minimal Rules). A semantics |∼ allows to eliminate non-minimal rules iff the following transformation on instantiated logic programs is a |∼-equivalence transformation: Delete a rule A ← B ∧ ¬C such that there is another rule A0 ← B 0 ∧ ¬C 0 with A0 ⊆ A, B 0 ⊆ B, and C 0 ⊆ C. We already required that ¬A should be derivable if A appears in no rule head. But then it should be possible to evaluate the body literal ¬A to true, i.e. to delete ¬A from all rule bodies: 2
See [Sch92, Dix94a]: WFS+ was originally introduced from Schlipf under the name WFSC but shown to be equivalent to Dix’ version WFS+ .
4
Definition 8 (Positive Reduction). A semantics |∼ allows positive reduction iff the following is a |∼-equivalence transformation on instantiated logic programs: Replace a rule A ← B ∧ ¬C by A ← B ∧ ¬ C ∩ P(Φ) . Conversely, if the logic program contains A1 ∨ · · · ∨ Ak ← true, at least one of these atoms must be true, so a rule body containing ¬A1 ∧ · · · ∧ ¬Ak is surely false, so the entire rule is useless, and it should be possible to delete it: Definition 9 (Negative Reduction). A semantics |∼ allows negative reduction iff the following is a |∼-equivalence transformation on instantiated logic programs: Delete a rule A ← B ∧ ¬C if there is a rule A0 ← true with A0 ⊆ C. These notions of reduction have been introduced in [Dix92a] for normal programs and [DM92] for disjunctive programs. It turned out that an application of these principles may reduce a program drastically, because many literals are decided to be true or false. In addition, the program left is small since the underlying language is small. We call a semantics |∼1 weaker than a semantics |∼2 iff Φ |∼1 ψ =⇒ Φ |∼2 ψ for all Φ and ψ. We are now in a position to define our semantics D-WFS: Definition 10 (D-WFS). The semantics D-WFS of a program Φ is defined as the weakest semantics satisfying all our properties introduced in this section. Note that this definition is well-defined, i.e. there is a unique weakest semantics with these properties: Let ≡ be the reflexive, symmetric, and transitive closure of the union of transformations 7→ introduced above. Then we define for positive disjunctions A: Φ |∼0 A :⇐⇒ there is Φ0 ≡ Φ∗ and A0 ⊆ A with A0 ← true ∈ Φ0 . Correspondingly, we define for negative disjunctions A: Φ |∼0 A :⇐⇒ there is Φ0 ≡ Φ∗ and A ∈ A with A 6∈ P(Φ0 ). From this definition it is clear that |∼0 is invariant under the transformations and that any other semantics with these properties must at least derive the same disjunctions.
3 3.1
Bottom-Up Query Evaluation Computing Conditional Facts
Our approach is based on the notion of “conditional facts”. This idea was introduced in [Bry90] but is now extended to the disjunctive case. The idea is to delay the evaluation of negative body literals, so from the rule winning(X) ← move(X, Y ) ∧ ¬winning(Y ) 5
and the fact move(a, b) we derive the conditional fact winning(a) ← ¬winning(b). In [HY91] a somewhat related approach (again for normal programs) was defined: a semantics was reduced to programs containing only negative literals in their rule-bodies. Definition 11 (Conditional Fact). A conditional fact is a rule without positive body literals, i.e. of the form A1 ∨ · · · ∨ Ak ← ¬C1 ∧ · · · ∧ ¬Cm , where the Ai and the Ci are ground atoms (k ≥ 1, m ≥ 0). Logically, such a conditional fact is nothing else than the disjunctive fact [BL92]: A1 ∨ · · · ∨ A k ∨ C 1 ∨ · · · ∨ C m . Conditional facts can be matched with positive body literals as usual, we only have to append the conditions to the result. For instance, if we apply the rule goodstate(X) ← winning(X) ∧ ¬excluded(X) to the above conditional fact, we get goodstate(a) ← ¬excluded(a) ∧ ¬winning(b). In general, this corresponds to the hyperresolution rule, but the result is again partitioned into head and body: Definition 12 (Immediate Consequences of Conditional Facts). m m n [ [ Ci where there are Ai − {Bi } ← ¬ C0 ∪ TΦ (Γ ) := A0 ∪ i=1
i=1
a ground instance A0 ← B1 ∧ · · · ∧ Bm ∧ ¬C0 of a rule in Φ o
and cond. facts Ai ← ¬Ci ∈ Γ with Bi ∈ Ai (i = 1, . . . , m) . Since Φ is allowed, every variable occurs in a positive body literal, so the derived rules are really ground and furthermore contain only constants appearing somewhere in Φ. We compute the smallest fixpoint of TΦ as usual: We start with Γ0 := ∅ and then iterate Γi := TΦ (Γi−1 ) until nothing changes. This must happen because there are only finitely many predicates and constants to build ground atoms occuring in conditional facts, and there are only finitely many subsets of all these atoms (corresponding to head and body). The transformation from the original logic program to the set of all derived conditional facts does not change the semantics of the program: Theorem 13 (lfp(TΦ ) as Normalform). Let Γ := TΦω (∅), and |∼ be a semantics which satisfies GPPE, and allows the elimination of tautologies and non-minimal rules. Then Φ 7→ Γ is a |∼-equivalence transformation.3 3
In the meantime, we discovered that this theorem even holds without the elimination of non-minimal rules.
6
3.2
Computing the Residual Program
So we now have a logic program with rules of a very particular kind, namely containing no positive body literals. The next step of the proposed query evaluation algorithm is to simplify it by means of the reduction operations introduced in Definitions 7, 8, and 9. This leads to the following reduction operator on sets of conditional facts (a generalization of reductions studied in [Bry90]): Definition 14 (Reduction of Conditional Facts). R(Γ ) := {A ← ¬ C ∩ P(Γ ) | A ← ¬C ∈ Γ, there is no A0 ← true ∈ Γ with A0 ⊆ C and there is no A0 ← ¬C 0 ∈ Γ with4 A0 ⊆ A, C 0 ⊆ C} We again iterate this operator until nothing changes. Since the total number of atoms occuring in Γ is reduced in each step, this process must come to an end. We call the result the “residual program”, because it is similar to the residual program computed in [CW93a]. However, our version also contains the true facts, not only conditions for the undefined facts. The residual program therefore still contains all the information of the original program. Definition 15 (Residual Program). The residual program of an allowed DATALOG-program Φ is Φˆ := Rω TΦω (∅) . Theorem 16 (Φˆ as Normalform). Let |∼ be a semantics satisfying all properties defined in Section 2. ˆ the transformation Then for every logic program Φ and its residual program Φ, ˆ Φ 7→ Φ is a |∼-equivalence transformation. 3.3
Computing LP Semantics Based on the Residual Program
Theorem 17 (Computation of D-WFS). Φ |∼DWFS ψ :⇐⇒ there is A ⊆ ψ with A ← true ∈ Φˆ or ˆ there is ¬A ∈ ψ and A 6∈ P(Φ). The well-founded semantics and the GCWA also have the properties defined in Section 2 (when restricted to normal resp. positive logic programs). But then Theorem 16 is applicable (it also holds for such restricted semantics), and for residual programs the equivalence to D-WFS is trivial: Theorem 18 (D-WFS extends WFS). Let ψ be a ground literal (positive or negative) and Φ be a non-disjunctive logic program. Then Φ |∼DWFS ψ iff ψ is contained in the well-founded model of Φ. Theorem 19 (D-WFS extends GCWA). Let ψ be a positive ground disjunction or negative ground literal, and let Φ be a positive logic program. Then Φ |∼DWFS ψ ⇐⇒ GCWA(Φ) ` ψ. Theorem 20 (D-WFS is weaker than DSTABLE). If Φ |∼DWFS ψ, then ψ holds in all stable models of Φ (If Φ is stratified, these are the perfect models.). 4
We require that at least one of the following ⊆ is proper.
7
4
Conclusions
In this paper, we have shown how a bottom-up procedure for computing the well-founded model of disjunctive logic programs can be derived from abstract properties of this semantics. By doing this, we have discovered an intimate relation between three previously quite distinct approaches: – The abstract properties of logic programming semantics studied by Dix, in particular his characterization of the well-founded semantics. – The work of Bry on a formalization of logic programming in constructive logic — especially his conditional facts and the corresponding consequence and reduction operators. – The query evaluation algorithm of Kemp/Stuckey/Srivastava ([KSS91]) which only handels non-disjunctive programs. It turns out that the “p0 ”-facts of their approach correspond exactly to the heads of our conditional facts. Their algorithm can therefore be derived from our approach. Due to space limitations, we could not comment on more implementation-related topics in this paper, but the ideas of [BL92, Bra93] can be suitably generalized. There is also an important optimization, which we would like to mention. Currently, all negative body literals are delayed until the very end of the fixpoint computation. They are evaluated only in the second phase of our approach (the reduction). Obviously, it is better to iterate these two phases for every stronglyconnected component of the program. In the case of non-disjunctive stratified programs, this would allow to evaluate all negative body literals immediately, so our approach reduces to the standard one in this important special case. For future work, we are especially interested in a generalization of our approach to other logic programming semantics. And, of course, we are aiming at an actual implementation.
References [BL92]
Stefan Brass and Udo W. Lipeck. Generalized bottom-up query evaluation. In Alain Pirotte, Claude Delobel, and Georg Gottlob, editors, Advances in Database Technology — EDBT’92, 3rd Int. Conf., number 580 in LNCS, pages 88–103. Springer-Verlag, 1992. [BL93] Stefan Brass and Udo W. Lipeck. Bottom-up query evaluation with partially ordered defaults. In Proceedings of the 3rd International Conference on Deductive and Object-Oriented Databases (DOOD’93), number 760 in LNCS, pages 253–266. Springer, 1993. [Bra93] Stefan Brass. Efficient query evaluation in disjunctive deductive databases. Research report, Institut f¨ ur Informatik, Universit¨ at Hannover, 1993. [Bry90] Fran¸cois Bry. Negation in logic programming: A formalization in constructive logic. In Dimitris Karagiannis, editor, Information Systems and Artificial Intelligence: Integration Aspects, pages 30–46. Springer, 1990. [CW93a] Weidong Chen and David S. Warren. Computation of stable models and its integration with logical query processing. Technical report, Department of CS, SUNY at Stony Brook, 1993.
8
[CW93b] Weidong Chen and David S. Warren. A goal-oriented approach to computing the well-founded semantics. The Journal of Logic Programming, 17:279–300, 1993. [Dix92a] J¨ urgen Dix. A Framework for Representing and Characterizing Semantics of Logic Programs. In B. Nebel, C. Rich, and W. Swartout, editors, Principles of Knowledge Repr. and Reasoning: Proc. of the Third International Conference (KR ’92), pages 591–602. San Mateo, CA, Morgan Kaufmann, 1992. [Dix92b] J¨ urgen Dix. Classifying Semantics of Disjunctive Logic Programs. In K. Apt, editor, LOGIC PROGRAMMING: Proc. of the 1992 Joint International Conference and Symposium, pages 798–812. MIT Press, November 1992. [Dix94a] J¨ urgen Dix. A Classification-Theory of Semantics of Normal Logic Programs: I. Strong Properties. Fundamenta Informaticae, forthcoming, 1994. [Dix94b] J¨ urgen Dix. A Classification-Theory of Semantics of Normal Logic Programs: II. Weak Properties. Fundamenta Informaticae, forthcoming, 1994. [Dix94c] J¨ urgen Dix. Semantics of Logic Programs: Their Intuitions and Formal Properties. An Overview. In Andre Fuhrmann and Hans Rott, editors, Logic, Action and Information. Proceedings of the Konstanz Colloquium in Logic and Information (LogIn ’92). DeGruyter, 1994. [DM92] J¨ urgen Dix and Martin M¨ uller. Abstract Properties and Computational Complexity of Semantics for Disjunctive Logic Programs. In Proc. of the Workshop W1, Struct. Complexity and Rec-theor. Methods in LP, following the JICSLP ’92, pages 15–28. H. Blair, W. Marek, A. Nerode and J. Remmel, November 1992. [DM94] J¨ urgen Dix and Martin M¨ uller. An Axiomatic Framework for Representing and Characterizing Semantics of Disjunctive Logic Programs. In Pascal Van Hentenryck, editor, Proceedings of the 11th Int. Conf. on Logic Programming, S. Margherita Ligure. MIT, June 1994. [HY91] Yong Hu and Li Yan Yuan. Extended Well-Founded Model Semantics for General Logic Programs. In Koichi Furukawa, editor, Proceedings of the 8th Int. Conf. on Logic Programming, Paris, pages 412–425. MIT, June 1991. [KSS91] David B. Kemp, Peter J. Stuckey, and Divesh Srivastava. Magic sets and bottom-up evaluation of well-founded models. In Proc. of the 1991 Int. Symposium on Logic Programming, pages 337–351. MIT Press, 1991. [MD93] Martin M¨ uller and J¨ urgen Dix. Implementing semantics of disjunctive logic programs using fringes and abstract properties. In Lu´ıs Moniz Pereira and Anil Nerode, editors, Logic Programming and Non-monotonic Reasoning, Proc. of the 2nd Int. Workshop, pages 43–59. MIT Press, 1993. [Prz88] Teodor C. Przymusinski. On the declarative semantics of deductive databases and logic programs. In Jack Minker, editor, Foundations of Deductive Databases and Logic Programming, pages 193–216, Los-Altos (Calif.), 1988. Morgan Kaufmann. [Ros90] Kenneth A. Ross. The well founded semantics for disjunctive logic programs. In Won Kim, Jean-Marie Nicolas, and Shojiro Nishio, editors, Deductive and Object-Oriented Databases, Proc. of the First Int. Conf. (DOOD’89). NorthHolland Publ.Co., 1990. [Sch92] John S. Schlipf. Formalizing a Logic for Logic Programming. Annals of Mathematics and Artificial Intelligence, 5:279–302, 1992.
9
Appendix: Proofs Lemma 21. Let Φ be a positive instantiated logic program and Φ0 be the result of applying GPPE to Φ, i.e. for some rule A ← B in Φ and B ∈ B: Φ0 := Φ − A ← B ∪ A ∪ A0 − {B} ← B − {B} ∪ B 0 A0 ← B 0 ∈ Φ, B ∈ A0 . Then Φ and Φ0 have the same minimal models.
Proof. We first show that a minimal model of Φ resp. Φ0 also is a model of the other logic program: 1. Let I be a minimal model of Φ (in fact, in this direction, we do not need the minimality of I). If I would not be a model of Φ0 , it would have to violate one of the new rules, e.g. A ∪ A0 − {B} ← B − {B} ∪ B 0 .
Violating it means that I |= B − {B}, I |= B 0 , I 6|= A, I 6|= A0 − {B}. But since we know that I |= A0 ← B 0 (it is contained in Φ), we can conclude that I |= B. But now I |= A ← B (for the same reason) yields I |= A, which is a contradiction. 2. Let I be a minimal model of Φ0 . If I would not be a model of Φ, it would have to violate A ← B (the only element of Φ0 −Φ). So we would have I |= B, especially I |= B, and I 6|= A. Since I is a minimal model of Φ0 , I0 := I −{B} cannot be a model of Φ0 . So it must violate a rule A0 ← B 0 in Φ0 , and, by the construction B ∈ A0 and B 6∈ B 0 . It follows that I |= B 0 , and I 6|= A0 − {B}. But this means that I does not satisfy the rule A ∪ A0 − {B} ← B − {B} ∪ B 0 , which is contained in Φ0 , again a contradiction.
Now it immediately follows that a minimal model I of Φ (resp. Φ0 ) is not only a model of Φ0 (resp. Φ), but also a minimal model: Suppose it would not, i.e. there were a model I1 with I1 ≺ I. Then there were also a minimal model I0 with I0 I1 , i.e. I0 ≺ I. But this minimal model I0 of Φ0 (resp. Φ) is also a model of Φ (resp. Φ0 ), contradicting the assumed minimality of I. 2 Lemma 22. Let Φ be an instantiated logic program and Φ0 be the result of applying GPPE to Φ, i.e. for some rule A ← B ∧ ¬C in Φ and B ∈ B: Φ0 := Φ − A ← B ∧ ¬C ∪ A ∪ A0 − {B} ← B − {B} ∪ B 0 ∧ ¬ C ∪ C 0 A0 ← B 0 ∧ ¬C 0 ∈ Φ, B ∈ A0 . Let Γ := lfp(TΦ ) and Γ 0 := lfp(TΦ0 ). If |∼ allows the elimination of non-minimal rules, then Γ and Γ 0 are |∼-equivalent, i.e. S|∼ (Γ ) = S|∼ (Γ 0 ).
Proof. The immediate consequence operator TΦ for conditional facts is very similar to the hyperresolution operator. More specifically, it is identical in the case of 10
positive logic programs. Let us define Φ˜ for a logic program Φ to be the positive logic program arising from the translation of every rule A1 ∨ · · · ∨ Ak ← B1 ∧ · · · ∧ Bm ∧ ¬C1 ∧ · · · ∧ ¬Cn into
A1 ∨ · · · ∨ Ak ∨ C˜1 ∨ · · · ∨ C˜n ← B1 ∧ · · · ∧ Bm ,
where C˜i is an atom with a new predicate symbol. Now let Γ˜ := lfp(TΦ˜ ), i.e. the disjunctive facts derivable by hyperresolution. Then the translation back into conditional facts gives exactly Γ , since the new atoms did not occur in any rule body, so they did not participate in the resolution. But for hyperresolution we know a correctness and completeness result, namely that it only computes ˜ and that it computes at disjunctive facts which are logical consequences of Φ, least all minimal such disjunctive facts (minimal with respect to ⊆ if we view such facts as sets of atoms). But for the semantics |∼ only minimal conditional facts are relevant (minimal with respect to ⊆ for head and body). Since head and body literals are uniquely determined by the representation in Γ˜ , the two minimization criteria agree. So it suffices to show that Φ˜ and Φ˜0 imply the same disjunctive facts. But this follows from Lemma 21 (a disjunctive fact is implied iff it is true in all minimal models). 2 Lemma 23. Let Φ be an instantiated logic program containing a rule A ← B∧¬C with A ∩ B 6= ∅ (i.e. a tautology), and let Φ0 := Φ − {A ← B ∧ ¬C}. Let Γ := lfp(TΦ ) and Γ 0 := lfp(TΦ0 ). If |∼ allows the elimination of non-minimal rules, then Γ and Γ 0 are |∼-equivalent. Proof. An application of the tautological rule always yields a superdisjunction of the conditional fact inserted for B ∈ A ∩ B. But such non-minimal conditional facts are not relevant for the semantics. 2 A.2 Proof of Correctness of Fixpoint-Reduction (Theorems 13, 16) Theorem 13 (lfp(TΦ ) as Normalform). Let Γ := TΦω (∅), and |∼ be a semantics which satisfies GPPE, and allows the elimination of tautologies and non-minimal rules. Then Φ 7→ Γ is a |∼-equivalence transformation. Proof. By our definition of a semantics, Φ 7→ Φ∗ is a |∼-equivalence transformation, so it suffices to show Φ∗ 7→ Γ is one, too. The proof is by induction on the number n of distinct atoms which appear positively in rule bodies in Φ∗ . In the case n = 0 the result is trivial, because Φ∗ already is a set of conditional facts, so Γ = Φ∗ . Now assume that at least one atom A occurs positively in a rule body of Φ ∗ . Then we eliminate A from the rule bodies by 1. first deleting any rule instance A ← B ∧ ¬C containing A in A and B (this is a |∼-equivalence transformation, because such a rule is a tautology), 11
2. and then applying GPPE to every occurrence of A in a rule body (again this is a |∼-equivalence transformation). Since the rules about A did not contain A positively in the bodies, this operation eliminates all positive occurrences of A in the rule bodies. Let Φ0 be the result of this operation, and Γ 0 the set of conditional facts derivable from Φ0 . The construction guarantees that Φ 7→ Φ0 is a |∼-equivalence transformation. By the inductive hypothesis, we have that Φ0 7→ Γ 0 is one, too. Finally, by repeated application of Lemma 23 and Lemma 22, we can conclude that Γ 0 7→ Γ is a |∼-equivalence transformation, too. 2 Theorem 16 (Φˆ as Normalform). Let |∼ be a semantics satisfying all properties defined in Section 2. ˆ the transformation Then for every logic program Φ and its residual program Φ, Φ 7→ Φˆ is a |∼-equivalence transformation. Proof. This is an immediate consequence of Theorem 13 since the reduction operator R obviously uses only positive and negative reduction and the elimination of non-minimal rules. 2 A.3 Proof That Computed Semantics is D-WFS (Theorem 17) We first have to distinguish between the computed semantics and D-WFS. So let us temporaly call the computed semantics XWFS (until we have shown that the two are equivalent): Definition 24 (XWFS). For a logic program Φ with residual program Φˆ we define Φ |∼XWFS ψ :⇐⇒ there is A ⊆ ψ with A ← true ∈ Φˆ or ˆ there is ¬A ∈ ψ and A 6∈ P(Φ). Lemma 25. XWFS is a semantics according to our definition. Proof. We show that our requrements on a semantics are satisfied: 1. Because of the range-restriction, the variables are completely instantiated in the computation of conditional facts. So the same conditional facts are computed based on Φ and on Φ∗ . Therefore, the input to the second phase of the computation is the same, so the resulting residual program is also identical. 2. The possibility of right weakening is obvious from the definition of XWFS. 3. Let A ← true be in Φ. Then it is also contained in lfp(TΦ ) and the only reason why it might not be in the resulting residual program is that there is a disjunctive fact A0 ← true in the residual program with A0 ⊂ A. In both cases we get Φ |∼XWFS A. 4. Let A be a Σ-ground atom with A 6∈ P(Φ). The derived disjunctive facts can contain only head literals already present in Φ, so A 6∈ P lfp(TΦ ) . The reduction operations also introduce no new head literals, and we get A 6∈ ˆ But this means that Φ |∼XWFS ¬A. P(Φ). 2 12
Lemma 26. XWFS allows the elimination of non-minimal rules. Proof. So let Φ contain a rule A ← B ∧ ¬C and a rule A0 ← B 0 ∧ ¬C 0 with A0 ⊆ A, B 0 ⊆ B, C 0 ⊆ C (where at least one subset relation is proper). Let Φ0 := Φ − {A ← B ∧ ¬C}. One can show by induction on the number i of derivation steps that for every conditional fact A1 ← C1 ∈ TΦi (∅) there is a conditional fact A0 ← ¬C0 ∈ TΦi 0 (∅) with A0 ⊆ A1 and C0 ⊆ C1 . On the other hand, Φ0 ⊆ Φ, so TΦi 0 (∅) ⊆ TΦi (∅). This implies that the minimal conditional facts in TΦω0 (∅) and TΦω (∅) are the same, and non-minimal conditional facts will be deleted anyway by the reduction operator. 2 Lemma 27. XWFS satisfies GPPE. Proof. This is a direct corollary of Lemma 22 and Lemma 26: Let Φ0 be the result of applying GPPE to Φ, Γ := lfp(TΦ ) and Γ 0 := lfp(TΦ0 ). Since TΦ (Γ ) = Γ , the residual programs of Φ and Γ are identical, i.e. Φ 7→ Γ is a |∼XWFS -equivalence transformation. Anologeously, Γ 0 7→ Φ0 is a |∼XWFS -equivalence transformation. Lemma 22 is applicable because of Lemma 26, and allows to conclude that Γ 7→ Γ 0 is a |∼XWFS -equivalence transformation. 2 Lemma 28. XWFS allows the elimination of tautologies. Proof. This is a direct corollary of Lemma 23 and Lemma 26, since Φ and lfp(T Φ ) are |∼XWFS -equivalent by definition of XWFS. 2 Lemma 29. XWFS allows negative reduction. Proof. Let Φ be an instantiated logic program containing A0 ← true, and Φ0 := Φ − {A ← B ∧ ¬C} where A0 ⊆ C. All disjunctive facts derived directly or indirectly by using the rule A ← B ∧ ¬C contain ¬C in their condition. Formally, we can prove by induction on the number of derivation steps i that TΦi (∅) − TΦi 0 (∅) consists only of conditional facts A0 ← C0 with C ⊆ C0 . The disjunctive fact A0 ← true is of course contained in TΦω (∅). But then already the first reduction step eliminates the whole difference between the two sets of conditional facts. 2 Lemma 30. XWFS allows positive reduction. Proof. Let Φ be an instantiated logic program, A ← B ∧ ¬C be a rule in Φ, and Φ0 := Φ − {A ← B ∧ ¬C} ∪ A ← B ∧ ¬(C ∩ P(Φ)),
Let C 0 be the deleted negative body literals, i.e. C − P(Φ). Then it is possible to show that 0 i A ← ¬(C − C ) A ← ¬C ∈ T (∅) 0 0 0 0 Φ = A0 ← ¬(C0 − C 0 ) A0 ← ¬C0 ∈ TΦi 0 (∅) . 13
Furthermore, C 0 ∩ P TΦi (∅) = ∅ and C 0 ∩ P TΦi 0 (∅) = ∅ (since the derived conditional facts can contain only head literals already occurring in Φ). But this means that C 0 is removed from the conditional fact bodies already in the first reduction step. 2 Theorem 31 (D-WFS). XWFS is equal to D-WFS. Proof. In the preceding lemmas, we have proven that XWFS indeed has the properties characterizing D-WFS. We will now show that it is weaker than any other semantics |∼ with these properties, i.e. that Φ |∼XWFS ψ =⇒ Φ |∼ ψ. By Theorem 16, we have that Φ and its residual program Φˆ are |∼-equivalent. But by the conditions on a semantics, XWFS is the weakest possible semantics for residual programs, i.e. Φˆ |∼XWFS ψ =⇒ Φˆ |∼ ψ. Finally, by definition of XWFS, we have Φ and Φˆ are |∼XWFS -equivalent. In summary: Φ |∼XWFS ψ ⇐⇒ Φˆ |∼XWFS ψ =⇒ Φˆ |∼ ψ ⇐⇒ Φ |∼ ψ. Therefore, XWFS is the weakest semantics with these properties, i.e. it coincides with D-WFS. 2 Theorem 17 (Computation of D-WFS). Φ |∼DWFS ψ :⇐⇒ there is A ⊆ ψ with A ← true ∈ Φˆ or ˆ there is ¬A ∈ ψ and A 6∈ P(Φ). Proof. This is an immediate consequence of theorem 31.
2
A.4 Relation to WFS and GCWA Lemma 32. WFS satisfies all properties of section 2 (when restricted to nondisjunctive programs): GPPE, the elimination of tautologies and non-minimal rules, as well as positive and negative reduction. Proof. This is known from the literature.
2
Theorem 18 (D-WFS extends WFS). Let ψ be a ground literal (positive or negative) and Φ be a non-disjunctive logic program. Then Φ |∼DWFS ψ iff ψ is contained in the well-founded model of Φ. Proof. Lemma 32 shows that WFS has the properties sufficient to ensure that the transformation from Φ to the residual program Φˆ does not change the semantics. A slight problem here is that WFS is only defined on non-disjunctive programs, so Theorem 16 is not really applicable. But since the properties as applied in the proof of this theorem never introduce disjunctions, the proof works unchanged for semantics of non-disjunctive programs. ˆ = But now the special form of the residual program easily shows D-WFS(Φ) ˆ The direction ⊆ is obvious (the complement of P(Φ) ˆ is certainly an unwfs(Φ): founded set, and the facts are derived in a single step of the immediate conseˆ is also a fixpoint of W ˆ (no head literal can be quence operator). But D-WFS(Φ) Φ 14
contained in an unfounded set, and new positive facts could only be derived by assuming new negative facts). Therefore, D-WFS(Φ) is the least fixpoint of W Φˆ . ˆ = D-WFS(Φ) ˆ = D-WFS(Φ). So in summary we have: wfs(Φ) = wfs(Φ) 2 Theorem 19 (D-WFS extends GCWA). Let ψ be a positive ground disjunction or negative ground literal, and let Φ be a positive logic program. Then Φ |∼DWFS ψ ⇐⇒ GCWA(Φ) ` ψ. Proof. We noted already that for positive logic programs, TΦ is exactly the hyperresolution operator, so the derived disjunctive facts contain only logical consequences of Φ, and they contain all minimal implied disjunctive facts. The reduction operator removes all non-minimal such disjunctions, but nothing else. It also introduces no new disjunctive facts (in the case of positive programs). 1. The implied positive disjunctions are in both cases the disjunctions already implied by Φ. For D-WFS this was just explained. But for the GCWA this is also clear, since the added negative ground atoms hold in all minimal models, so they do not change the set of minimal models which are sufficient to determine the implied positive disjunctions. 2. The GCWA assumes those negative literals which are true in all minimal Herbrand models. So it suffices to show that these are exactly the negative literals assumed by the D-WFS. – If ¬A is true in all minimal Herbrand models, there cannot be a minimal disjunctive fact A ← true implied by Φ with A ∈ A: Since A is false in all minimal Herbrand models, A − {A} must be true in all minimal Herbrand models, but then it is true in all Herbrand models, and we get Φ ` A − {A} contradicting the minimality of A. – If A is not contained in a minimal disjunctive fact implied by Φ, then it is false in all minimal Herbrand models: Suppose it were true in a minimal Herbrand model I of Φ. Let I1 , . . . , In be those minimal Herbrand models in which A is false. Because of their minimality, I 6≺ Ii , so there are ground atoms A1 , . . . , An with I |= Ai and Ii 6|= Ai . Now we have Φ 6` A1 ∨ · · · ∨ An , but Φ ` A ∨ A1 ∨ · · · ∨ An . So a minimal implied subdisjunction must contain A. 2 Example 3. It is not true that D-WFS(Φ) ` Φ, i.e. there are models of D-WFS which are not models of Φ. We still claim that D-WFS is a “disjunctive model” of Φ, but it is not our intention to use D-WFS to determine a set of classical models. Consider for example the following Φ: p ← q. q ∨ r. Here, D-WFS(Φ) = {p ∨ r, q ∨ r} (assuming that the underlying signature contains no further predicates). Now I := {q, r} is a Herbrand model of D-WFS(Φ) with I 6|= Φ. 2 15
A.5 Relation to DSTABLE and PERFECT We once conjectures that D-WFS is weaker than PERFECT for all stratified (disjunctive) logic programs. This is true, but it is not easy to prove it directly, because GPPE may destroy the stratification: Example 4. Consider the following stratified logic program: p ← q. p ← ¬q. q ∨ r. It has two perfect (Herbrand) models, namely I1 := {p, q} and I2 {p, r}. But now consider what happens if we apply GPPE to the body literal q in the first rule: p ∨ r. p ← ¬q. q ∨ r. This logic program is not stratified, and it has no perfect model, which can be seen as follows: The base conditions for the priority relations between the three predicates yield p ≤ r and r ≤ p (from the first rule), p < q (from the second rule), and q ≤ r as well as r ≤ q (from the third rule). Now by the transitivity we can conclude that each of the three predicates has strictly higher priority than each other (or even itself). This follows by transitivity from a subchain of q ≤ r (rule 3), r ≤ p (rule 1), p < q (rule 2), q ≤ r (rule 3), r ≤ p (rule 1). So we get that I1