Proceedings of the Twenty-Third AAAI Conference on Artificial Intelligence (2008) Abductive Logic Programming by Nonground Rewrite Systems Fangzhen Lin Jia-Huai You Department of Computer Science Hong Kong University of Science and Technology Clear Water Bay, Kowloon, Hong Kong Department of Computing Science University of Alberta Edmonton, Alberta, Canada is allowed if every variable other than X occurring in a Di occurs in a positive nonequality atom in the same Di ; similarly for queries, constraints, and sets of iff definitions. Allowedness reinforces a programming style in which every variable that may potentially become universally quantified must be “grounded” by a domain definition, so that floundering can be avoided by instantiating the variables in a negative subgoal before its proof is attempted. For small domains, such an approach is fine. But for large or infinite domains, it makes programming tedious and reasoning inefficient, as in such a procedure a mechanism of enumerating domain elements is tightly coupled with the process of proving negative subgoals. For example, if we have a fact member(X, [X|R]) in our program, the completed definition of member is not allowed: Abstract Logic programming with negation offers a compelling approach to abductive reasoning. This paper shows a simple view of abduction in this context for the completion semantics, under which the problem of abduction becomes one of solving quantified equations and disequations. By this way of treating abduction, the problems with nonground negative queries in the previous approaches no longer exist. We show the soundness and completeness results for our approach. Introduction Logic programming with negation has been considered an attractive approach to abduction (Kakas, Kowalski, & Toni 1995). The goal is to show that an observation, in terms of a query, can be explained by a reasoning process supported with hypotheses, called abducibles, while satisfying posted constraints. A number of approaches to abductive logic programming have been proposed. One approach is based on the (partial) stable model semantics (e.g., (Eshghi & Kowalski 1989; Kakas, Michael, & Mourlas 2000; Lin & You 2002)). These proof procedures are designed essentially for ground programs. Another family of procedures are proposed for nonground programs under the completion semantics (Console, Theseider, & Porasso 1991; Fung & Kowalski 1997; Endriss et al. 2004), where the use of the IFF definitions as rewrite rules has considerably simplified the proof process, and made abductive reasoning more intuitive and transparent. This is in contrast with the approach based on nested proof trees called the SLDNFA procedure (Denecker & De Schreye 1998). Iff definitions may contain existential variables. When negated, they become universally quantified. Since logic programming traditionally can only process queries with existential variables, processing queries with universal variables has been said to be unsafe. In the past, all proof procedures are designed to satisfy some safety conditions. A goal is said to flounder if all of its subgoals are nonground negative literals. To prevent a goal from floundering, the best-known syntactic condition is the so-called allowedness condition. An iff definition p(X) ↔ D1 ∨...∨Dm member(X, Y ) ↔ Y = [X|R] ∨ ... since variable R doesn’t appear in a positive nonequality atom. One can make the definition allowed by a recursive definition of list and restricting R to that domain. One would expect that, designed specifically for a class of well-behaved programs, namely allowed programs, a proof procedure would be simpler. It turns out all of the previous proof procedures are formulated in some complex ways. This paper shows that a much simpler view of abduction is possible, even for the class of all programs and goals. We show that the problem of abduction can be partitioned into two subproblems, the first of which is to transform a goal to a formula containing quantified equalities and disequalities, which can then be solved separately. Since variable quantification is represented explicitly according to the semantics, the problem in the past with nonground queries simply becomes a non-issue in our approach. This approach is sound where |= is interpreted in 2-valued logic. For completeness, |= has to be weakened to 3-valued logic. Definitions We consider a first-order language L. Variables begin with a capital letter, and predicate/function/constant symbols begin with a lower case letter. For any syntactic entity Φ, V (Φ) denotes the set of the variables appearing free in Φ. A conjunction A1 ∧ ... ∧ Ak may be written as [A1 , ..., Ak ]. We write ∀Φ to mean that all the variables appearing free in formula Φ are universally c 2008, Association for the Advancement of Artificial Copyright Intelligence (www.aaai.org). All rights reserved. 480 quantified, similarly for ∃Φ. We use the notation Θ to denote a vector of variable quantification, such as ∃X∀Y for instance. We assume the Clark’s equality theory (Clark 1978), written CET below, which essentially says that all syntactically distinct ground terms are not equal, and that functions are one-to-one: ∀X, Y f (X) 6= g(Y ) for any two distinct function symbols (including constants) f and g, and ∀X, Y f (X) = f (Y ) → X = Y . We also assume that the language includes all symbols in the given program. Thus if a and b occur in the program as two constants, then CET will include the axiom a 6= b. An abductive program is a triple hT, IC, Abi, where Given an abducible program hT, IC, Abi and a query G, the initial query is the goal formula ∀X.G ∧ ΦIC , where • ΦIC is the conjunction of the constraints in IC by converting a constraint of the form ⊥ ← A1 , ..., Ak , ¬B1 , ..., ¬Bm into the disjunction [¬A1 ∨...∨ ¬Ak ∨ B1 ∨ ... ∨ Bm ]. • X is the tuple of variables in IC. We assume here that G and IC do not have common variables - this can be achieved by variable renaming if necessary. Thus the initial query is logically equivalent to G∧∀XΦIC . We move all quantifiers to the outside during rewriting. In the following, we shall abuse the language and use IC to stand for its corresponding formula ΦIC as well. Thus we’ll write the initial query as ∀X.G ∧ IC. An answer to a query G is a pair (∆, σ), where ∆ is a finite set of ground abducible atoms, and σ is a substitution of ground terms for variables in V (G), such that T ∪ comp(∆) ∪ CET |= Gσ ∧ ∀XIC. (3) We may simply call σ an answer when there are no abducibles involved. The symbol |= refers to the 2-valued entailment relation if not said otherwise. Our objective in this paper is to propose a set of rules to rewrite an initial query into a formula of the form Θ(E ∨ Φ), and then extract answers from E when E contains only = and abducibles. 1. T is a finite set of iff definitions of the form p(X1 , ..., Xn ) ↔ D1 ∨ ... ∨ Dm (1) where p is an n-ary defined predicate symbol (denoted p/n), X1 , ..., Xn are distinct variables, and Di a conjunction of literals. The variables X1 , ..., Xn are implicitly universally quantified with the scope being the entire definition, and any other variable occurring in any Di is existentially quantified with the scope being Di . When m = 0, the right hand side of (1) is f alse. Iff definitions are the completed definitions of the predicates in a normal program P , denoted comp(P ), according to (Clark 1978). For convenience, and also for intuition, in exposition we may just give a normal program instead of its completion. A normal program is a finite set of normal rules of the form A ← B1 , ..., Bj , not C1 , ..., not Ck ., where j, k ≥ 0, A, Bi and Ci are (nonequality) atoms. The logical formula for the completion of p/n is m _ ∀X p(X) ↔ ∃Yi [(X = si ) ∧ Φi )] (2) Goal Rewriting under Completion Semantics A goal rewrite system is a transformation system that consists of iff definitions for unfolding, augmented by some simple rules for equivalence-preserving transformations. Simplification rules i=1 We use symbols T and F for boolean constants true and f alse, respectively. Let ΘΠ be a goal formula. Π can be rewritten according to the following rules (and their symmetric cases). SR1. F ∨ Φ → Φ SR2. F ∧ Φ → F SR3. T ∧ Φ → Φ SR4. T ∨ Φ → T SR5. (Φ1 ∨ Φ2 ) ∧ Φ3 → (Φ1 ∧ Φ3 ) ∨ (Φ2 ∧ Φ3 ) We assume that ¬T will be rewritten to F and ¬F to T , automatically. where X is an abbreviation of X1 , ..., Xn , and each disjunct corresponds to a Di in the form (1), where, for the corresponding normal rule with p/n in the head, X = si is the conjunction of equations representing unifiability, Yi denotes the variables other than X that appear in the disjunct, and Φi is the rule body with not replaced by ¬. The negation of an equation, ¬(s = t), is called a disequation and will be written as s 6= t. We use equation and equality interchangeably. We write ¬(t = s) by t 6= s. Rewrite rules for unification 2. IC is a consistent finite set of constraints of the form ⊥ ← A1 , ..., Ak , ¬B1 , ..., ¬Bm where Ai and Bi are atoms. All variables in a constraint are universally quantified. Let E be a conjunction of equalities. Let δ be the mgu of E when E is unifiable. We will write δ as a set of equations. We define δE = T if δ = ∅, and δE = δ otherwise. 3. Ab is a finite set of predicate symbols, called abducibles, which are different from = and any defined predicate symbol. A query, also called a goal, is a conjunction of literals. All variables appearing in a goal are free. During derivation, a derived goal may be a complex formula involving ∧, ∨ and ¬, and some variables may become universally quantified. Thus, a goal is generally called a goal formula, which formally is a formula of the form ΘΦ, where Φ is a quantifier-free formula with negation appearing only in front of an atom. Unification rules: (1) E → F if E is not unifiable (2) E → δE if E is unifiable (3) X = t ∧ Φ → X = t ∧ Φ{X/t}, where X does not occur in t and Φ{X/t} is the result of replacing X in Φ by t. (4) X 6= t ∨ Φ → X 6= t ∨ Φ{X/t} The unification rules should be applied whenever possible to propagate the unifier and to prevent non-unifiable patterns from being pursued. 481 Unfolding as the variables in Ri do not occur in t and si . It is easy to see that this formula entails the formula in (iii) above. We show that the other way around is also true under CET . To show this, we prove that under CET , for each i, Unfolding a positive literal is clear. Unfolding a negative literal raises the question of quantification for variables in Di ’s other than X1 , ..., Xn . Given a completed definition in the form (2), a negative literal ¬p(t) will be unfolded according to the following equivalences. Vm ¬p(t) ↔ i=1 ∀Yi [t 6= si ∨ ¬Φi ] (i) Vm ↔ i=1 ∀Yi [t 6= si ∨ [t = si ∧ ¬Φi ]] (ii) Vm ↔ i=1 ∀Yi0 [t6=si ] ∨ ∃Zi ∀Ri [(t=si ∧¬Φi ){Yi0 /Zi }] (iii) ∃Zi ∀Ri [(t = si ∧ ¬Φi ){Yi0 /Zi }] (4) ∀Yi0 [t 6= si ∨ ∀Ri [t = si ∧ ¬Φi ]]. To show this, suppose (5) entails ∀Ri [(t = si ∧ ¬Φi ){Yi0 /Zi }], t = si . (6) (7) From (6), we get (t = si ){Yi0 /Zi }, thus t = (si {Yi0 /Zi }) since Yi0 does not occur in t. So by (7) we have si = (si {Yi0 /Zi }), thus Zi = Yi0 by CET . From this and (6), we get ∀Ri [(t = si ∧ ¬Φi )]. Thus we have shown that where Yi0 = V (si ), which are renamed to Zi in the second disjunct (by substitution {Yi0 /Zi }) and become existentially quantified, and Ri = Yi \ Yi0 are the remaining variables. Here we have assumed that V (t) ∩ Yi = ∅ for each i. This can always be achieved by renaming variables in Yi when necessary. For instance, given CET |= (6) → [t 6= si ∨ ∀Ri [t = si ∧ ¬Φi ]]. So by ∀-introduction, we have CET |= (6) → (5), and by ∃-introduction, we have CET |= (4) → (5). 2 With this lemma, we can now define unfolding rules. p(V ) ↔ ∃X, Y, Z(V = s(X, Y ) ∧ ¬q(Y, f (Z))), for ¬p(f (X)), the formula (i) above is Unfolding Let Π = ΘΦ be a goal formula. 1. If p(t) occurs in Φ positively (i.e. not under ¬ operator), then rewrite Π into the following goal formula ∀X1 , X2 , X3 (f (X) 6= s(X1 , X2 ) ∨ q(X2 , f (X3 ))), and the formula (iii) is Θ∃Y1 · · · Ym Φ0 , ∀X1 , X2 (f (X) 6= s(X1 , X2 )) ∨ ∃Y1 , Y2 ∀X3 (f (X) = s(Y1 , Y2 ) ∧ q(Y2 , f (X3 ))). where Φ0 is the result of replacing this occurrence of p(t) by m _ (t = si ) ∧ Φi . The significance of the formula (iii) is the following. As mentioned earlier, the purpose of rewriting is to generate a goal formula of the form Θ(E ∨ Φ) such that E mentions only = and abducibles and then to extract answers from ΘE. In general, Θ(E ∨ Φ) 6≡ ΘE ∨ ΘΦ. However, in some situations, e.g., when E and Φ do not share universal variables, the two are logically equivalent. In this case, ΘE can be evaluated independently, so is ΘΦ. The formula (iii) says some universal variables resulted from an iff definition can be converted to existential ones, thus reducing the chances of shared universal variables. This will simplify the process of answer extraction (cf. the next section). We now prove that the equivalence (iii) indeed holds under the completion semantics. i=1 Here we assume that the following sets of variables V (Φ), Y1 , · · · , Ym are pair-wise disjoint. This can be achieved by renaming variables in Yi if necessary. 2. If ¬p(t) occurs in Φ, then rewrite Π into the following goal formula Θ∀Y10 ∃Z1 ∀R1 · · · ∀Ym0 ∃Zm ∀Rm Φ0 , where Φ0 is the result of replacing this occurrence of ¬p(t) by Lemma 1 (Correctness of unfolding) Given a program P , a predicate p, and a completed definition in the form (2), let p(t) be an atom such that V (t)∩Yi = ∅ for each i. Then, comp(P ) ∪ CET entails Wm (a) ∀ p(t) ↔ i=1 ∃Yi [(t = si ) ∧ Φi ] (b) ∀ ¬p(t) ↔ the formula in (iii) above. m ^ t 6= si ∨ (t = si ∧ Φi ){Yi0 /Zi }, i=1 where Φi , the complement of Φi , is ¬A1 ∨ · · · ∨ ¬Ak ∨ B1 ∨ · · · ∨ Bn when Φi is Proof. The correctness of part (a) is clear. Let’s prove part (b). It is clear that under comp(P ), ¬p(t) is equivalent to the formula (ii) above, which is equivalent to Vm 0 i=1 ∀Yi ∀Ri [t 6= si ∨ [t = si ∧ ¬Φi ]], A1 ∧ · · · ∧ Ak ∧ ¬B1 ∧ · · · ∧ ¬Bn . Again we assume that the following sets of variables V (Φ), Y10 , Z1 , R1 , · · · , Ym0 , Zm , Rm thus equivalent to Vm 0 i=1 ∀Yi [t 6= si ∨ ∀Ri [t = si ∧ ¬Φi ]] are pair-wise disjoint. Again this can be achieved by variable renaming if necessary. 482 formula. Let ∆ be a finite set of ground abducible atoms, and σ = {X/t | X ∈ V (G)} a substitution for variables in V (G). We say that (∆, σ) is extracted as an answer to G, based on E, if CET |= ΘE∆ σ. If a goal formula ΘE itself is also a pre-answer formula and no answer can be extracted from it, then the proof of the initial goal failed. It is convenient to make this explicit. As an example, suppose we have p(V ) ↔ V = s(X, Y ) ∧ ¬q(Y, f (Z)) q(Y, Z) ↔ Y = L ∧ Z = L ∧ r(L, K). For the goal ∃X(p(X) ∧ ¬q(X, Y )), • If we unfold p(X) in it, we get ∃X, X1 , X2 , X3 [X = s(X1 , X2 ) ∧ ¬q(X2 , f (X3 )) ∧¬q(X, Y )]. Rule of answer extraction failure: Let ΘE be a goal formula rewritten from some initial query such that ΘE is also a pre-answer formula. • If we unfold ¬q(X, Y ) in it, we get ΘE → F ∃X∀X1 ∃X2 ∀X3 [p(X) ∧ ((X 6= X1 ∨ Y 6= X1 ) ∨ (X = X2 ∧ Y = X2 ∧ ¬r(X2 , X3 )))]. if no answer can be extracted from ΘE We note that Proposition 1 can be extended with the addition of this new rule. We shall show that our rewrite system with answers extracted this way is sound and complete. Before we do this, we show some examples. Rewrite System and Answer Extraction In the following, given a goal formula Π, we write Π ⇒ Π0 if Π can be written into Π0 by one application of the rules introduced so far, and denote by ⇒∗ the transitive closure of ⇒. Examples Example 1 Let hT, ∅, ∅i be an abductive program, where T is {p(X) ↔ ¬r(X, Y ); r(X, Y ) ↔ X= a∧Y = b}. Clearly, T ∪ CET |= p(t), for any t in the language, which as we said in Section 2, includes at least a and b. We can show this using our rewrite system as follows: Proposition 1 If Π ⇒∗ Π0 , then comp(P ) ∪ CET |= ∀X(Π ↔ Π0 ) where X is the tuple of free variables in Π. p(V ) ⇒ ∃Y ¬r(V, Y ) ⇒ ∃Y (V 6= a ∨ Y 6= b) Proof. We only need to prove this for the single step case. The cases for simplification and unification rules are obvious. For the unfolding rules, they follow from Lemma 1 by noting that in first-order logic, if X and Y are different variables, X does not occur in ϕ, and Y does not occur in φ, then (Q1 Xϕ Q2 Y φ) ↔ Q1 XQ2 Y (ϕ φ), where Qi is either ∀ or ∃, and is either ∧ or ∨. 2 We get three pre-answer formulas from this: ∃Y (V 6= a), ∃Y (Y 6= b), and ∃Y (V 6= a ∨ Y 6= b). From the second one, we extract the answer (∅, {V /t}) for any t. On the other hand, we expect ¬p(V ) to be proved false. ¬p(V ) ⇒ ∀Y r(V, Y ) ⇒ ∀Y (V = a ∧ Y = b) ⇒ F This is because CET |= ¬∀Y (Y = b) as our language contains both a and b. This shows there is no t such that ¬p(t) follows from T ∪ CET . 2 This shows that our rewrite system is sound under the completion semantics and Clark’s equality theory. As we mentioned, given an initial query ∀X.G ∧ IC, our objective is to rewrite it into a formula of the form Θ(E ∨ Φ) such that E mentions only = and abducibles, and then extract answers from E. We now make this process precise. In the following, given Θ(E ∨ Φ), we call ΘE a preanswer formula if E is quantifier-free and mentions only = and abducibles. In addition, if E does not mention abducibles, then we call ΘE an answer formula. Note that an abducible in E may appear positively or negatively, and ΘE may contain universal or existential variables. Given ΘE, and a finite set D of ground atoms about abducible predicates in E, we abduce the pre-answer formula ΘE to the answer formula ΘED by the following transformation: for every abducible ab that appears in E and the subset of D about ab defined as Dab =W{ab(si ) ∈ D}, any occurrence of V ab(t) in E is replaced by i t = si , and ¬ab(t) by i t 6= si . The intuition here is that if D defines abducibles in E, then ΘE and ΘED are equivalent. In other words, ΘE and ΘED are equivalent under comp(D). This is a simple program. For more involved ones, there would be many variables and quantifiers, and it may become difficult to track whether they are universal ones or existential ones, and their nested order. To alleviate this, we propose an explicit representation of quantification for goal formulas using an annotated notation. Let Π = Q1 ξ1 ...Qk ξk Φ be a goal, where Φ is a formula with k variables ξ1 , ..., ξk , and each Qi is either ∀ or ∃. In the construction of a proof by rewriting, we will write Π as Φ0 , where Φ0 is obtained from Φ by replacing each variable ξi by XQi . For example, ∀X∃Y [f (X, X) = f (a, Y ) ∧ p(Y )] can be represented by f (X∀1 , X∀1 ) = f (a, X∃2 ) ∧ p(X∃2 ). In the following, we shall use these two notations, regular goal formulas and their annotated versions, interchangeably. In our definition of unfolding, we push all variables to the outside, and to do this, we have to rename variables to avoid name conflicts. We now use an example to show that this is necessary. Otherwise, one would have to design more involved distribution rules. Example 2 Consider the following program Answer Extraction Let hT, IC, Abi be an abductive program and G a goal. Assume that the initial query ∀X.G∧IC has been rewritten to Θ(E ∨ Φ), where ΘE is a pre-answer p(X) ← r(X), q(Y ). q(X) ← q(X). q(X) ← s(X, Y ). r(a). s(a, b). 483 For example, the answer X = s(s(s(0))) cannot be extracted from the second disjunct alone, as the answer formula ∀Y ∃Z[s(s(s(0) 6= 0, Y 6= 0, Y 6= s(s(Z))] is not entailed by CET . But this answer can be extracted from the first two disjuncts together, namely, and its completion p(X) ↔ r(X) ∧ ∃Y q(Y ), q(X) ↔ q(X) ∨ ∃Y s(X, Y ), r(X) ↔ X = a, s(X, Y ) ↔ X = a ∧ Y = b. It is easy to see that CET |= ∀Y ∃Z[s(s(s(0))) 6= 0, s(s(s(0))) 6= s(s(Y ))] ∨ [s(s(s(0))) 6= 0, Y 6= 0, Y 6= s(s(Z))] p(a) ⇒∗ a = a ∧ q(X∃1 ) ∨ (a = a ∧ X∃1 = a∧X∃2 = b) Since CET entails the answer formula ∃X1 , X2 (a = a ∧ X1 = a ∧ X2 = b), the query is answered positively. However, if we do not move the quantifiers to the outside, we would get: In this example, in order not to miss any answer, all answer formulas together must participate in answer extraction. Clearly, this is a much harder job than extracting answers from each disjunct independently. 2 p(a) ↔ r(a)∧∃Y q(Y ) ↔ a = a ∧ ∃Y (q(Y )∨∃Zs(Y, Z)) ↔ a = a ∧ ∃Y (q(Y ) ∨ ∃Z(Y = a ∧ Z = b)). We now show some examples that have abducibles. To extract answers from the above, we would need to have rules that can distribute quantifications to get, for example, the answer formula a = a ∧ ∃Y, Z(Y = a ∧ Z = b). 2 Example 4 Consider an abductive program and a goal. T = {q(X) ↔ ab(X); p(X, Y ) ↔ X = f (V ) ∧ Y = W } IC = {[¬ab(X) ∨ p(X, Y )]}, Ab = {ab}, and the goal is q(I). We mentioned earlier that for negative literals, the use of the formula in (iii), instead of the formula in (i) or (ii), can simplify the process of answer extraction. We now illustrate this by the following example. [q(I), [¬ab(X∀1 ) ∨ p(X∀1 , X∀2 )] ⇒ [ab(I), [¬ab(X∀1 ) ∨ p(X∀1 , X∀2 )] ⇒ [ab(I), [¬ab(X∀1 ) ∨ [X∀1 = f (X∃3 ), X∀2 = X∃4 ]]] This is a pre-answer formula. Since the conjunct X∀2 = X∃4 is entailed by CET independently, it can be dropped. Denote the resulting formula by E. Let ∆ = {ab(f (a))}. Then, Example 3 Consider T that consists of even(V ) ↔ [V = 0] ∨ [V = s(s(Y )), even(Y )] We expect query ¬even(X) to be proved with X bound to s(0), s3 (0), and so on. E∆ = [I = f (a), [X∀1 6= f (a) ∨ X∀1 = f (X∃3 )]] Clearly, (∆, {I/f (a)}) is an answer to the goal. ({ab(a)}, {I/a}) is not, since IC is not satisfied. ¬even(X) ⇒ X6=0∧[X6=s(s(Y∀1 ))∨(X=s(s(Y∃2)) ∧¬even(Y∃2))] ⇒ [X6=0,X6=s(s(Y∀1))]∨[X6=0,X=s(s(Y∃2)),¬even(Y∃2)] ⇒∗ [X 6= 0, X 6= s(s(Y∀1 ))]∨ [X 6= 0, X = s(s(Y∃2 )), Y∃2 6= 0, Y∃2 6= s(s(Z∀3 ))]∨ [X6=0, X=s(s(Y∃2)), Y∃26=0, Y∃2=s(s(Z∃3)),¬even(Z∃3)] Example 5 Consider the faulty-lamp example of (Fung & Kowalski 1997). For simplicity, let us consider only one way for the lamp to be faulty. Suppose the abductive program is hT, ∅, {power f ailure, empty}i, where T is In the last goal formula, an answer X = s(0) is extracted from the first disjunct. By definition, this can be expressed formally as f aulty lamp ↔ power f ailure(X) ∧ ¬backup(X) backup(X) ↔ battery(X, Y ) ∧ ¬empty(Y ) battery(X, Y ) ↔ X = b ∧ Y = c CET |= ∀Y [X 6= 0, X 6= s(s(Y ))]{X/s(0)} But 2 The abbreviations used below should be clear. f l ⇒ [pf (X∃1 ), ¬backup(X∃1 )] ⇒ [pf (X∃1 ), [¬batt(X∃1 , X∀2 ) ∨ emp(X∀2 )]] ⇒ [pf (X∃1 ), [X∃1 6= b ∨ X∀2 6= c ∨ emp(X∀2 )]] ⇒ [pf (X∃1), X∃1 6= b]∨[pf (X∃1), [X∀2 6=c∨emp(X∀2)]] Similarly, X = s(s(s(0))) is extracted from the second disjunct above. We mentioned that the language can have symbols not in the original program. Suppose now there is one more constant a in the language. Then we can extract additional answers, X = a and X = s(a), from the first disjunct above, and X = s(s(a)) and X = s(s(s(a))) from the second. Indeed, it is easy to see that T ∪ CET |= ¬even(t), for t = a, s(a), s(s(a)), etc. Thus the function “s” (successor) does not have its intended meaning when applied to terms formed by the new constant a. This can be fixed by adding even(a) (or even(s(a)) if one wants a to represent an odd number) to the program. Now suppose we use the formula in (i) to rewrite a negative literal in the goal formula, we will get The first disjunct gives answer ({pf (t)}, ∅), for any t 6= b; for the second, we have ∆ = {pf (t), emp(c)}, for any t in our language. 2 Soundness and Completeness Theorem 1 (Soundness) Let hT, IC, Abi be an abductive program and G a goal. (1) Suppose rewriting from ∀X.G ∧ IC generates Θ(E ∨ Φ) such that (∆, σ) is extracted as an answer to G, based on E. Then, T ∪ comp(∆) ∪ CET |= Gσ ∧ ∀XIC. ¬even(X) ↔ ∀Y [X 6= 0, X 6= s(s(Y ))] ∨ [X 6= 0, ¬even(Y )] ↔ ∀Y ∃Z[X6=0, X6=s(s(Y))]∨[X6=0, Y6=0, Y 6=s(s(Z))] ∨ [X 6= 0, Y 6= 0, ¬even(Z)] (2) If rewriting from ∀X.G ∧ IC generates F , then T ∪ CET ∪ ∀XIC |= ¬∃G. 484 Proof. (1) From Proposition 1, our assumption that X ∩ V (G) = ∅, and that comp(∆) |= E ↔ E∆ , we have T ∪ comp(∆) ∪ CET |= Gσ ∧ ∀XIC ↔ Θ(E∆ ∨ Φ)σ. Since CET |= ΘE∆ σ, and |= ΘE∆ σ → Θ(E∆ ∨ Φ)σ, we have T ∪ comp(∆) ∪ CET |= Gσ ∧ ∀XIC. P has a unique answer set that contains both p(a) and p(b), and in fact p(t), for any t in the language. As shown in Example 1, these are precisely what are proved from the goal p(V ) by our rewrite system. Note that Prolog would fail the goal p(V ), due to its naive implementation of finite failure. Further work is needed to address three issues arising from this work. The first concerns the possibility of reducing dependencies of disjuncts in a goal formula Θ(E ∨ Φ), so that ΘE and ΘΦ may be processed independently. We have shown that in unfolding negative literals, certain universal variables can indeed be converted to existential ones, thus reducing the chances of shared universal variables. The second issue is related to the computational properties of solving quantified equations and disequations and the design of an efficient reasoner for it. Finally, rewrite strategies will be an important issue to be addressed in future work. (2) From comp(P ) ∪ CET |= ∀X(G ∧ IC) ↔ F , we get comp(P ) ∪ CET ∪ ∀XIC |= ¬G by our assumption that X ∩ V (G) = ∅. ∀-introduction then leads to comp(P ) ∪ CET ∪ IC |= ∀¬G. 2 Theorem 2 (Completeness) Let hT, IC, Abi be an abductive program and G a goal. Suppose (∆, σ) is an answer to G under 3-valued logic: T ∪ comp(∆) ∪ CET |=3 Gσ ∧∀XIC. Then, there is a derivation from ∀X.G∧IC to a goal formula Θ(E ∨ Φ), where E is not further reducible by any defined predicates, such that an answer (∆0 , σ 0 ) can be extracted, based on E, where ∆0 is a subset of ∆ and σ 0 is more general than σ. Acknowledgements Fangzhen Lin’s work was supported in part by HK RGC CERG 616806 and by NSFC grant 60496322. We can prove the theorem under a fair selection rule, using the well-known result of (Kunen 1987). The difficulty for the 2-valued completion semantics is known to be caused by loops, e.g., with T = {p ↔ ¬p}, any goal would follow in 2-valued logic. But in 3-valued logic, T has a model where p is undefined, hence nontermination of repeated unfolding would not result in loss of completeness. References Chan, D. 1988. Constructive negation based on the completed database. In Proc. ICLP/SLP, 111–125. Clark, K. 1978. Negation as failure. Logics and Databases 293–322. Console, L.; Theseider, D.; and Porasso, P. 1991. On the relationship between abduction and deduction. J. Logic Programming 2(5):661–690. Denecker, M., and De Schreye, D. 1998. SLDNFA: an abductive procedure for normal abductive programs. J. Logic Prog. 34(2):111–167. Drabent, W. 1993. SLS-resolution without floundering. In Proc. LPNMR ’93, 82–98. Endriss, U.; Mancarella, P.; Sadri, F.; Terreni, G.; and Toni, F. 2004. The CIFF procedure for abductive logic programming with constraints. In JELIA’04. Eshghi, K., and Kowalski, R. 1989. Abduction compared with negation by failure. In Proc. 6th ICLP, 234–254. Fung, T., and Kowalski, R. 1997. The iff proof procedure for abductive logic programming. J. Logic Programming 33(2):151–164. Gelfond, M., and Lifschitz, V. 1988. The stable model semantics for logic programming. In Proc. ICLP/SLP. Kakas, A.; Kowalski, R.; and Toni, F. 1995. The role of abduction in logic programming. In Handbook of Logic in Artificial Intelligence and Logic Prog. Oxford University. Kakas, A.; Michael, A.; and Mourlas, C. 2000. ACLP: abductive constraint logic programming. J. Logic Programming 44:129–177. Kunen, K. 1987. Negation in logic programming. J. Logic Programming 4(3):289–308. Lin, F., and You, J. 2002. Abduction in logic programming: a new definition and an abductive procedure based on rewriting. Artificial Intelligence 140(1/2):175–205. Stuckey, P. 1995. Negation and constraint logic programming. Inf. Comput. 118(1):12–33. Related Work and Discussion Our approach can be viewed as a generalization of the iff procedure of (Fung & Kowalski 1997), which comes with a variety of additional inference rules that can be used to make answer extraction more constructive for the class of allowed programs and goals. An interesting fact is that our rewrite system without these extra rules does not lose the completeness even for arbitrary programs and goals. One can solve the floundering query problem by constructive negation (CN) (see, e.g., (Chan 1988; Drabent 1993; Stuckey 1995)). All of these approaches are based on the completion semantics, and have similar soundness and completeness results. Briefly, our approach is considerably simpler, as it builds reasoning directly on completed definitions on a flat structure, without relying on nested finite failure trees as needed in CN. In relating to the SLDNFA abductive procedure (Denecker & De Schreye 1998), we note that the completeness of their procedure depends on the condition that derivations terminate (due to finite failure), while ours does not, simply because there is no notion of finite failure in our approach. One advantage of the completion semantics is that iff definitions are first order formulas where theoremhood is semidecidable so that a complete procedure is possible. It is also known that if a program has no loops, the completion semantics coincides with the answer set semantics (Gelfond & Lifschitz 1988). All of the example nonground programs in this paper have no loops, so our rewrite system proves goals also for the answer set semantics. E.g., the theory T in Example 1 corresponds to the following program P : p(X) ← not r(X, Y ). r(a, b). 485