You are on page 1of 12

Annals of Mathematics and Artificial Intelligence, 1 (1990) 21-32

21

POLYNOMIAL-TIME INFERENCE OF ALL VALID IMPLICATIONS FOR H O R N AND RELATED FORMULAE


E. BOROS R UTCOR- Rutgers Center for Operations Research, Rutgers University, New Brunswick, NJ, USA Y. C R A M A Department of Quantitative Economics, University of Limburg, Maastricht, The Netherlands P.L. H A M M E R
RUTCOR- Rutgers Center for Operations Research, Rutgers University, New Brunswick, NJ, USA

To the memory of Robert G. Jeroslow

Abstract
This paper investigates the complexity of a general inference problem: given a propositional formula in conjunctive normal form, find all prime implications of the formula. Here, a prime implication means a minimal clause whose validity is implied by the validity of the formula. We show that, under some reasonable assumptions, this problem can be solved in time polynomially bounded in the size of the input and in the number of prime implications. In the case of Horn formulae, the result specializes to yield an algorithm whose complexity grows only linearly with the number of prime implications. The result also applies to a class of formulae generalizing both Horn and quadratic formulae. Keywords: Propositional logic, inference, resolution, Horn formulae, complexity.

I. Introduction

Logical inference is the central problem in many areas of artificial intelligence, e.g. automated theorem proving, logic programming, databases, etc. (see e.g. Chang and Lee [5], Kowalski [16], Gallaire and Minker [8]). This problem is usually formulated in a restricted form: given a knowledge-base, i.e. a list of valid facts and rules about atomic assertions, can one infer the validity of some statement involving the atoms. But, for most applications, it would be easy to argue the importance of a more general version of the inference problem, namely: infer all valid statements implied by the knowledge-base. Such valid implications can be added as new facts or rules to the knowledgebase, thus increasing the efficiency and the deductive power of the system in
9 J.C. Baltzer A.G. Scientific Publishing Company

22

E. Boros et al. / Polynomial-time inference

specific applications (see also Hooker [13] for an extensive discussion of the computational use of valid implications). Alternatively, valid implications can be used to determine effective question-asking strategies, in the interactive dialog between an expert system and its human user (see Hayes-Roth et al. [11], Wang and Van de Vate [26]). This paper examines the complexity of the general inference problem in the framework of propositional logic. In section 2, we give a precise formulation of our model, and we recall a classical algorithmic approach to the inference problem, based on the resolution principle. In section 3, we state and we discuss three conditions, under which the resolution procedure efficiently solves the inference problem. Here, "efficiently" means " i n time polynomially bounded in the size of the input and the number of prime implications". Our analysis is refined in section 4 to the case of Horn clause knowledge-bases. We show that, in this special, but important case, the resolution procedure can be implemented so that its running time grows only linearly with the number of prime implications. Finally, we introduce in section 5 a class of rules generalizing Horn clauses, but for which the results of section 3 can still be shown to hold.

2. Preliminaries

We restrict our attention in this work to formulae of the propositional calculus. We denote by (xl, x2,... } the infinite set of atomic propositions, or variables. These variables are said to be in positive form. Their negations are denoted Xl, x 2 , . . . . A truth assignment is an assignment of 0-1 values to x 1, x2,... (where 1 is interpreted as "true" and 0 as "false"). The value of a formula under any truth assignment is computed by the usual rules of the propositional calculus, viz. 0 = 1, 1 = 0 , 0 V 0 = 0 , etc. A clause is a disjunction of positive and negative variables, of the form: C(I, J)=x, V...VxirV~j,V...V2,,,

where I = { il,... , i r }, J = { ./'1. . . . . j, } are finite sets with I D J = O. By convention, the empty clause C ( ~ , ~ ) is identified with the constant O. A clause C(I, J) translates the implication: xj, A ... A x4--+ x,~ V ... V xi . Accordingly, xj,,. .., Xgs are called the antecedents of C( I, J), and x,,,. . ., xir are called its consequents. We say that a clause C(11, J1) absorbs a clause C(12, J2) if Il g I 2 and Jx c__Jz. A conjunctive normal form (CNF) is the conjunction of a finite number of clauses. The satisfiability problem for CNFs is the following: given a C N F q~, is there a truth assignment making qJ equal to 1?

E. Boros et al. / Polynomial-time inference

23

That satisfiability is a special type of inference problem can best be seen from its "complementary" version: given a C N F ~b, does q,(x 1, . . . . xn) = 1 imply 0 = 1? (Notice that, although apparently contrived, this version of satisfiability is actually the one handled by most algorithmic methods.) As discussed in the introduction, a natural (and, in a sense, most ambitious) generalization of satisfiability would be to infer all logical implications of a condition ~k(Xl,..., x n ) = 1. In order to make this idea m o r e precise, let us define an implication of the C N F qJ as a clause C(I, J) such that: I~(X 1
....

,X,) = 1 ~ C ( I ,

J)=l

(i.e. C(I, J) is satisfied by all truth assignments satisfying ~k). A convenient way of verifying that a clause C ( I , J ) is an implication of ff is provided by the following easy observation. As usual, assume I = { il . . . . , ir } and J = { J1,.-., J, }. Let 9 be the formula obtained from ff by deleting xil,... , xir from all clauses where they appear as consequents and deleting x j,, . . . . x j, from all clauses where they appear as antecedents. Then, C ( I , J ) is an implication of ~k if and only if is not satisfiable. A n implication C ( I , J ) is prime if it is not absorbed by any other implication. Thus, prime implications represent the strongest conclusions that can be drawn from a list of premises. The inference problem for C N F s can be stated as follows: given a C N F , list all its prime implications. A n algorithmic approach to the inference problem was published by Quine in [20,21] (although this result was already anticipated by Blake in [3] - see [4] - and by Samson and Mills in [23] - see [20]). Quine's approach is based on resolution of clauses, a concept later used by Robinson in the framework of first-order predicate logic [22] (see also Hooker [12] for some recent extensions). Consider two clauses C(I 1, Ja), C(I2, J2), and a variable xl, such that I 1 N J2 = { k }, I 2 n,/1 = ~ (i.e., xk appears positively in one of the clauses and negatively in the other, and no other variable has this property). Then, the resolvent of these two clauses is the clause C = C(I 1 tO I 2 \ { k } , J1 tO J 2 \ { k } ) . Reducing a list of clauses means deleting f r o m the list all clauses that are absorbed by another clause in the list. Observe that reduction is innocuous as far as the inference problem is concerned. Now, the resolution procedure takes as input an arbitrary C N F ~ = C 1 A . . . / x C,,, and performs on it the following operations.

Step 1. (Initialization). Reduce the list (C 1. . . . . Cm). Let S denote the reduced list.
G o to step 2. Step 2. (Termination). If all causes in S are marked, then o u t p u t S and stop. Else, let C be the next u n m a r k e d clause. Mark C, and go to step 3. Step 3. For every marked clause D in S, do the following: (a) (Resolution). If C and D have a resolvent, then generate it and go to (b). Else, repeat (a) with the next m a r k e d clause D.

24

E. Boros et al. / Polynomial-time inference

(b) (Reduction). Add the newly generated resolvent to S, reduce S and repeat (a) with the next marked clause D. When every marked clause has been processed, go to step 2. The list S returned in step 2 of this procedure is precisely the list of prime implications of q~ [20,21]. This follows directly from the fact that every prime implication of ~k can be obtained by a finite number of resolution steps. The latter statement is in turn easily seen to be equivalent to the completeness of resolution for the propositional calculus [22].

3. Efficiency of the resolution procedure


What is a reasonable measure of efficiency for an algorithm solving the inference problem? Since the number of prime implications of a CNF + can be exponentially larger than the number of variables and clauses in + (see section 4), the existence of a polynomial-time algorithm for this problem is definitely excluded. Rather, we should adopt here a criterion taking into account the number of objects to be outputted. Let us denote by n ( ~ ) (or, more briefly, n) the number of variables appearing in a CNF ~b, by m(ff) (or m) the number of clauses in ~k, and by p ( ~ ) (or p) the number of prime implications of ~b. Extending a definition of Valiant [25], we say that the inference problem restricted to a class F of CNFs is P-enumerable if tl'~ere exist an algorithm and a polynomial Pol(x, y, z), such that the algorithm outputs all prime implications of an arbitrary CNF ~ ~ F in time Pol(n (~), m (~b), p (+)). Observe that, if F is a class of CNFs for which the inference problem is P-enumerable, then the satisfiability problem restricted to F can be solved in polynomial time (since ~k is not satisfiable if and only if the empty clause is its unique prime implication). In order to state a partial converse of this observation, we first need some more definitions. Let ~ be the set of all clauses over x 1, ~1, x2, ~2,-.-- For a class ~ of clauses, ~___ ~, we denote by F ( ~ ) the set of all CNFs obtainable as conjunctions of clauses in ~ . We denote by S A T ( ~ ) (resp. I N F ( ~ ) ) the satisfiability problem (resp. inference problem) restricted to instances in F ( ~ ) . Consider now the following conditions on a class ~ _ ~. (I) S A T ( ~ ) is solvable in polynomial time, say in time t(n(+), m(~k)) for (II) ~ is closed under deletion of variables, i.e. C(I1, J 1 ) ~ if C(I1, J1) absorbs C(/2, J2) and C(/2, J2) ~ ~(To avoid trivialities, we shall assume in what follows that ~ is nonempty. In particular, condition (II) implies that ~ contains the empty clause.) We prove now:

E. Boros et al. / Polynomial-time inference

25

PROPOSITION 1 Let ~ satisfy conditions (I) and (II), ~ ~ F ( ~ ) , and C(I1, ,11) ~ ~ be a clause built on variables occurring in qJ. Then, one can test in time O(t(n, m)) whether C(I1, J1) is an implication of ~b. Moreover, when this is the case, one can find in time O(nt(n, m)) a prime implication C(I2, J2) of qJ absorbing C(I1, J1).

Proof
For the first statement, let 9 be the C N F obtained from q~ by deleting x, from all clauses where it appears as consequent, and deleting xj from all clauses where it appears as antecedent, for all i ~ I1, j ~ J r As discussed in section 2, C(11, J1) is an implication of q~ if and only if ~ is not satisfiable. By (I) and (II), this can be tested in time O(t(n, m)). If C(I1, J1) is an implication of q~, let i ~ 11, and test whether C ( I i \ ( i } , .11) is an implication of ~. If not, then i ~ I 2 (i.e., x, occurs in every implication absorbing C(I1, ,11)). If yes, then replace C(I1, J1) by C(I 1\ (i }, J1). Repeating this reasoning Ill U Jll times, we eventually obtain a prime implication C(I2, J2) which absorbs C(I1, J1). [] Proposition 1 suggests the introduction of a new operation on lists of clauses:

simplifying a list (C1,..., Cm) means replacing every clause C, (i = 1 , . . . , m) by a prime implication of C 1 A ... /X Cm which absorbs C,, and subsequently eliminating all duplications from the list. This operation will be used in the proof of our next result. But we first need to state one more condition on a class ~ of clauses: (III) ~ is closed under resolution, i.e. the resolvent of any two clauses of ~ is also in ~ . We shall discuss this assumption hereunder, For now, we can prove the central result of this paper: PROPOSITION 2 If ~ satisfies conditions (I), (II) and (III), then I N F ( ~ ) can be solved in time O((nm + np2)t(n, m)) for ~ ~ F ( ~ ) . In particular, I N F ( ~ ) is P-enumerable under those conditions.

Proof
Consider the resolution procedure described in section 2. Let us revise this procedure, and replace the instructions "reduce" in step 1 and step 3(b) by "simplify". It follows again from Quine's work [20,21] that this revised procedure correctly solves the inference problem. But the crucial observation is that the list S consists now only of prime implications, before each execution of step 2. This implies that step 2 is executed p times, steps 3(a), 3(b) are executed at most p2 times, and eliminating duplications in S can be done in time O(p2), thus leading to an overall time bound polynomial in p.

26

E. Boros et al. / Polynomial-time inference

We sketch now how the a n n o u n c e d time complexity can be achieved, through the use of an appropriate data structure. To understand this data structure, think of a complete ternary tree T of height n. Every clause C(I, J) on n variables is associated to the unique leaf of T defined by the sequence (o 0, 01,..., on), where v0 is the root of T, and oi is the left son (resp. middle son, right son) of o,_ 1 if i ~ I u J (resp. i ~ I, i ~ J). Through this correspondence, lists of clauses are associated to subsets of leaves. We maintain a representation of the list S as a subtree T(S) of T: namely, T(S) is the smallest subtree of T containing the root v0 and the subset of leaves associated to S. It is easy to see that this data structure can be set up in time O(nm) in step 1 of the revised resolution procedure. It supports the insertion of a new prime implication, or the verification that a prime implication is already present, in time O(n) (see Provan and Ball [19] for an earlier use of T(S)). It follows from this analysis, and from Proposition 1, that step 1 can be implemented in time O(nmt), step 2 in time O(p), step 3(a) in time O(np 2) and step 3(b) in time O(np2t) (by first determining a prime implication which absorbs the resolvent, and then inserting it in T(S)). []

Remark 1. Notice that the first statement of Proposition 2 remains true if we do not assume that t(n, m) is a polynomial. In particular, the time b o u n d holds when ~?= ~, with an appropriate definition of t(n, m). As promised earlier, we conclude this section with a brief discussion of condition (III). This condition m a y indeed appear quite restrictive, a n d the reader m a y feel more inclined to accept a seemingly m o r e inoffensive condition, like: (IV) 9t is closed under substitution of variables, i.e. C ( I u ( k } \ { i } , J ) ~ 9 ~ and C(I, JU ( k ) \ ( j ) ) ~ if i ~ I , j ~ J , k q ~ I U J and C(t, J) ~ . But we can prove in a sense m a d e precise by Proposition 3, that requiring condition (III) is not more d e m a n d i n g than requiring the apparently weaker condition (IV):
PROPOSITION 3

If ~? satisfies (I), (II), (IV), then 9t is contained in a Subclass of ~ satisfying (I)-(IV).

Proof
If P = NP, then the set g" of all clauses satisfies (I)-(IV), and we are done. So, assume that 9? satisfies (I), (II) and (IV) and that P ~ NP. Then, it follows from a result of Schaefer [24] that: (a) either ~ ___ where .~ is the set of all clauses involving at m o s t two variables, .~, (b) or ~__. 9~', where W is the set of all clauses involving at m o s t one positive variable, (c) or ~ c ) ~ " , where . ~ ' is the set of all clauses involving at most one negative variable.

E. Boros et al. / Polynomial-time inference

27

It is easy to see that ~, ~ and ~ " satisfy (II), (III), (IV). Moreover, S A T ( ~ ) and S A T ( . ~ ) were shown to be polynomially solvable by C o o k [6] and Jones and Laaser [15], respectively. So, .~, o~ and ~g~" satisfy (I). [] Formulae built on clauses from .~ are called quadratic; those built on clauses from ~ ' are Horn formulae. Efficient algorithms for enumerating all prime implications of a quadratic C N F have been k n o w n for some time (see e.g. Hansen [9], Hansen et al. [10]), but P-enumerability for H o r n formulae appears to be a new result. In the next section, we specialize our approach to the case of H o r n problems. In the last section, we shall introduce and briefly discuss a class of problems simultaneously generalizing quadratic and H o r n problems. This class still satisfies (I), (II) and (III), but not (IV).

4. Horn formulae

We define the class of Horn clauses as .,~'= { C(I, J ) 9 ~: [ I I ~< 1). H o r n clauses are extensively used in the artificial intelligence literature (Chang and Lee [5], Kowalski [16]). They translate elementary rules of the form:
X 1 AX 2A ... AX r~xr+ 1

(where, possibly, all antecedents x l , . . . , x r, or the consequent Xr+~, m a y be absent). A C N F ~ is a Horn formula if ~ 9 F(J{'). The satisfiability p r o b l e m for H o r n formulae, SAT()~'), can be solved in time O(l(q~)), where l ( ~ ) is the total n u m b e r of occurrrences of variables in ~ (so, in l(~), each x i or 2, is counted as m a n y times as it appears in qJ; l ( ~ ) ~< n(q~)m(qO) (Dowling and Gallier [7], Itai and Makowsky [14], Minoux [18]). The algorithms in [7,14,18] also deduce in time O(l(q~)) certain prime implications of length one of a H o r n formula + (i.e. variables whose value is fixed in every truth assignment satisfying +), b u t not all of these. Let us observe that, even for H o m formulae, the n u m b e r of prime implications can be exponentially large. Example. Fix a positive integer k, and define the H o r n formula ~k = q~0 A ~a A ... A ~1i where k,

9 , = (2, V Xk+,) ^ (X, V 2~+,) for i = 1,..., k, and


~ 0 = 21 V 2 2 V . . . V X2k.

Then, n(~kk) = 2 k and ( 8 1 , . . . , 3 k ) 9 (0, 1}k:


C 8 = x1+81 k V . . . V Xk+Sk k

m(~/k) = 2 k + 1. But P(~k) >I 2k since, for every

is a prime implication of ~b (notice that, by symmetry, this statement only has to k be checked for C o = 2] V ... v 2 k).

28

E. Boros et al. / Polynomial-time inference

Now, the class H of Horn clauses satisfies conditions (I), (II), (III) of section 2, and hence I N F ( ~ ) is P-enumerable. But, in this case, the resolution procedure can be further refined using the following observations. Let us say that a clause C is deduced by input resolution (see e.g. [5]) from a list (C1,..., Cm) of clauses if C is in the list, or if there exists a sequence C 1 , . . . , C m , Cm+ l , . . . , Cq of clauses such that: (1) Cq = C, and (2) for all k = m + 1,..., q, Ck is the resolvent of C, and Cj, where 1 ~< i ~< m and l <~j<<.k-1. The following result is found in Hooker [13]:
PROPOSITION 4

If ~k = C1/x .../X Cm is a H o r n formula, and C is a prime implication of ~k, then C can be deduced by input resolution from (C1,..., Cm).

Proof Say C = C(1, J). For i ~ 1 and j ~ 1, delete x i from all clauses of ~k where it appears as consequent, and xj from all clauses of qJ where it appears as antecedent, thus producing shorter clauses D1,..., Din. Since D 1 A ... A D,, is an unsatisfiable H o r n formula, the empty clause can be deduced by input resolution from (D1,..., Din) (see [5,15]). The same sequence of input resolution steps performed on Ca,..., C,, produces C. []
Accordingly, we define n o w an input resolution procedure, accepting as input any H o r n formula ~p = C1/x ... ACm: Step 1. (Initialization). Simplify the list (C1,...,Cm). Let S = S O denote the simplified list. Go to step 2. Step 2. (Termination). If all clauses in S are marked, then o u t p u t S and stop. Else, let C be the next u n m a r k e d clause in S. Mark C, and go to step 3. Step 3. For every marked clause D in So, do the following: (a) (Input resolution). If C and D have a resolvent, then generate it and go to (b). Else, repeat (a) with the next m a r k e d clause D in S 0. (b) (Simplification). A d d the newly generated resolvent to S, simplify S and repeat (a) with the next marked clause D in So. W h e n every marked clause in SO has been processed, go to step 2. PROPOSITION 5 The input resolution procedure correctly solves the inference p r o b l e m for H o r n formulae, in time O(nmlp).

Proof The correctness of the procedure follows immediately from Proposition 4. Its complexity can be determined as in Proposition 2, with t(n, m) = O(l). Thus,

E. Boros et al. / Polynomial-time inference

29

step 1 can be implemented in time O(nml). Steps 3(a) and 3(b) are iterated at most mp times (once for each pair of prime implications from SO and S). Each iteration of step 3(a) takes time O(n), and each iteration of step 3(b) takes time O(nl), by virtue of Proposition 1. So, the whole procedure runs in time O(nmlp). [] Notice that the time complexity of the input-resolution procedure is only linear in the number of prime implications. This is a significant improvement over the result stated in Proposition 2. In particular, since np is an obvious lower bound on the time needed to list all prime implications, this time complexity is within a factor ml of the best possible one. As mentioned in the introduction, such a procedure may be very useful in the design phase of a Horn-based expert system, by allowing to add many or all valid implications to the knowledge base prior to its use. Even step 1 alone (which runs in time O(nml)) may be useful in suppressing redundancies from the knowledge base, e.g. after the introduction of new rules.

5. Generalizations of Horn and quadratic formulae We introduce in this section some classes of clauses simultaneously generalizing Horn and quadratic clauses, and satisfying our conditions (I), (II), (III). In order to do so, we first select a weight a, for each variable x,, where 0 ~< a, ~< 1 ( i = 1, 2,...). For 1, J___ (1, 2,...}, we let

a(I,J)=

Eai+
i~l

E (l-aj).
j~J

Finally, we define the class ff(a 1, a 2 , . . . ) = ( C ( I , J): a(I, J) <~1}, and we let F(a 1, a2,...) be the class of all CNFs built on clauses from ff(a 1, a2,...). PROPOSITION 6 For a CNF qJ = C(I1, Ja) A ... A C( Im, J,,) o n ( x statements are equivalent: (a) there exist ( a l , . . . , a,) such that ~ ~ F(a I . . . . . or,); (b) the system of inequalities (1)-(2) has a solution: E a,+ E (1-aj)~<l
iel k jeJk

1. . . .

x,}, the following

(k-=l,...,m), ( i = 1 , . . . , n);

(1)
(2)

0 ~<ai~< 1

(c) the system (1)-(2) has a solution where a i ~ (0, 89 1} for i = 1 , . . . , n.

Proof The equivalence of (a) and (b) follows from the definitions, and (c) trivially implies (b). To prove that (b) implies (c), let ( a l , . . . , a,) be a solution of (1)-(2),

30 and define fl, = 0 i f 0 ~ < c t i <

E. Boros et al. / Polynomial-time inference

1;

fl,= 89 if a,= 89 fl,=lif 89 1. T h e n ( i l l , . . - , fin) is a solution of (1)-(2). [] This result allows to draw a n u m b e r of interesting conclusions, which we take up now in order. Remark 2. For an arbitrary C N F ~, one can decide in polynomial time whether there exists ( a l , . . . , an) such that ~ ~ F ( a l , . . . , an) , by solving the system (1)-(2). Remark 3. Statement (c) shows that we can restrict our attention to weights in (0, 1, 1}. Moreover, we can always replace a variable G- with weight 0 by a new negated variable ~,, where z~ has weight 1. This transformation leaves every formula essentially unchanged. Thus, we m a y assume that every variable has weight 89or 1 in our discussion of a class F ( a l , Ot2 . . . . ). Remark 4. fg(89 a. . . . ) is the set of quadratic clauses, i.e. clauses involving at most two variables. Remark 5. f~(1, 1 , . . . ) is the set ~ of H o r n clauses. Remark 6. The case where eti ~ (0, 1} for (i = 1, 2 . . . . ) is also worth mentioning. According to Remarks 3 and 5, ~ ~ F ( a l , . . . , an) for some a, ~ (0, 1} (i = 1 , . . . , n) if and only if ~ can be transformed into a H o r n formula by some elementary substitutions of the form x~ ~ ~,. Such formulae are called disguised Horn formulae (Lewis [17], Aspvall [1]). Notice that a C N F is disguised H o r n if and only if the system (1)-(2) has a 0 - 1 solution. The latter condition is in turn equivalent to the satisfiability of a quadratic C N F (expressing that no two terms in the left-hand side of (1) can be simultaneously equal to 1). We thus recover the recognition algorithm of Lewis [17] for disguised H o r n formulae. Remark 7. Assume now that a i ~ (1, 1} (i = 1, 2 . . . . ). For simplicity, we denote by X = (xl, x2,... } the set of variables with weight 1, and by Y = (Ya, Y2. . . . } the set of variables with weight 89 It is easy to see that clauses in , ~ ( a l , a 2 , . . . ) can be of two types: Type 1: clauses involving at most one positive variable from X, and no variable from Y (i.e., Horn clauses on X); Type 2: clauses involving no positive variable from X, and at most two (positive or negative) variables from Y. One possible interpretation for these clauses is to think of Yl, Y2. . . . as non-observable assertions, i.e. assertions whose truth-value cannot be obtained by direct experimentation, but can only be deduced from the values of x 1, x 2. . . . , using the rules in the knowledge-base. The clauses in ~ ( a l , t~2,... ) can then be translated as rules of the form:
X1 A X1 A X1 A ... ... ... A X r-'+ Xr+l; AXr"')yl; A x r

-">Yl VY2;

E. Boros et al. / Polynomial-time inference

31

where .vi denotes either y, or .~;, and the antecedents or the consequents of each rule may be missing. Such rules allow to extend the expressivity of H o r n knowledge-bases, without sacrifying the easiness of inference procedures in these systems. Indeed, we prove now our main result concerning the class ~ ( a l , a2,... ):
PROPOSITION 7

For every (ax, a 2 , . . . ) , ~ ( a l , a 2 , . . . ) satisfies conditions (I), (II) and (III). In particular, I N F ( ~ ( a l , a 2. . . . )) is P-enumerable.
Proof As follows from Remark 3, we m a y as well assume that a, ~ { 89 1} for all i = 1, 2 , . . . . Using Remark 7, it is then very easy to see that ~ ( a l , a 2 , . . . ) satisfies (II) and (III). As for (I), let ~k(Xl,..., xn) ~ F ( a l , or2 . . . . ). Let 9 be the conjunction of all clauses of type 1 occurring in ~k. Solve the satisfiability problem for 9 using one of the algorithms in [7,14,17]. If 9 is not satisfiable, then ~k is not satisfiable and we can stop. Else, the algorithm returns in time O(l(e~)) a subset A ___{ 1 , . . . , n} such that: (i) if ~ ( x l , . . . , xn) = 1, then x i = 1 for all i ~ A, and (ii) if x i = 1 for i ~ A, and x, = 0 for i ~ A, then ~ ( X l , . . . , xn) = 1. In view of (i), we m a y as well fix x, to the value 1 in every clause of ~k, for all i ~ A . We thus obtain a formula ~k' in the variables x i (i q~ A) such that ff is satisfiable if and only if ~k' is satisfiable, and ~' ~ F ( O t l , . . . , an). Rewrite ~k' as I~' = t~1 A 1~2 , where every clause of ~kl contains at least one variable from X, and the clauses of ~k2 involve no variable from X. Using (ii) and the description given in Remark 7, it is easy to see that ~kl is satisfied by any truth assignment such that x i = 0 for i ~ A. Solve the satisfiability problem for the quadratic formula ~2 in time O(l(~k2)) (see e.g. Aspvall et al. [2]). If ~k2 is not satisfiable, then ~ is not satisfiable. Else, any truth assignment satisfying ~k2, together with the assignment x i = O for i ~ A , satisfies ~. Thus, S A T ( ~ ( a l , a 2. . . . )) can be solved in time O(l(r and condition (I) is fulfilled. []

Acknowledgements
We thank A. Kolen and an a n o n y m o u s referee for helpful c o m m e n t s on the presentation of this paper. This work was partially supported by the N S F (grant ECS 85-03212) and the A F O S R (grants 85-0271 and 89-0066).

References
[1] B. AspvaU, Recognizing disguised NR(1)-instances of the satisfiability problem, J. Algorithms 1 (1980) 97-103.

32

E. Boros et al. / Polynomial-time inference

[2] B. Aspvall, M.F. Plass and R.E. Tarjan, A linear-time algorithm for testing the truth of certain quantified Boolean formulas, Information Processing Lett. 8 (1979) 121-123. [3] A. Blake, Canonical expressions in Boolean algebra, Ph.D. Disertation, University of Chicago, ILL (1937). [4] F.M. Brown, The origin of the method of iterated consensus, IEEE Trans. Computers C-17 (1968) 802. [5] C.L. Chang and R.C. Lee, Symbolic Logic and Mechanical Theorem Proving (Academic Press, New York, 1973). [6] S.A. Cook, The complexity of theorem-proving procedures, 3rd Annual ACM Syrup. on Theory of Computing (1971) pp. 151-158. [7] W.F. Dowling and J.H. Gallier, Linear-time algorithms for testing the satisfiability of propositional Horn formulae, J. Logic Programming 3 (1984) 267-284. [8] H. Gallaire and J. Minker, Logic and Databases (Plenum Press, New York, 1978). [9] P. Hansen, A cascade algorithm for the logical closure of a set of binary relations, Information Processing Lett. 5 (1976) 50-55. [10] P. Hansen, B. Jaumard and M. Minoux, A linear expected-time algorithm for deriving all logical conclusions implied by a set of Boolean inequalities, Math. Programming 34 (1986) 223-231. [11] F. Hayes-Roth, D.A. Waterman and D.B. Lenat, Building Expert Systems (Addison-Wesley, Reading, MA, 1983). [12] J.N. Hooker, Generalized resolution and cutting planes, Ann. Oper. Res. 12 (1988) 217-239. [13] J.N. Hooker, A quantitative approach to logical inference, Decision Support Systems 4 (1988) 45-69. [14] A. Itai and J.A. Makowsky, Unification as a complexity measure for logic programming, J. Logic Programming 4 (1987) 105-117. [15] N.D. Jones and W.T. Laaser, Complete problems for deterministic polynomial time, Theoretical Computer Sci. 3 (1976) 105-117. [16] R.A. Kowalski, Logic for Problem Solving (Elsevier, New York, 1979). [17] H.R. Lewis, Renaming a set of clauses as a Horn set, J. Assoc. Computing Machinery 25 (1978) 134-135. [18] M. Minoux, LTUR: A simplified linear-time unit resolution algorithm for Horn formulae and computer implementation, Information Processing Lett. 29 (1988) 1-12. [19] J.S. Provan and M.O. Ball, Efficient recognition of matroid and 2-monotonic systems, in: Applications of Discrete Mathematics, eds. R.D. Ringeisen and F.S. Roberts (SIAM, Philadelphia, 1988) pp. 122-134. [20] W.V. Quine, A way to simplify truth functions, Am. Math. Monthly 62 (1955) 627-631. [21] W.V. Quine, On cores and prime implicants of truth functions, Am. Math. Monthly 66 (1959) 755-760. [22] J.A. Robinson, A machine-oriented logic based on the resolution principle, J. Assoc. Computing Machinery 12 (1965) 23-41. [23] E.W. Samson and B.E. Mills, Circuit minimization: algebra and algorithms for new Boolean canonical expressions, Air Force Technical Report AFCRC 54-21 (1954). [24] T.J. Schaefer, The complexity of satisfiability problems, lOth Annual ACM Syrup. on Theory of Computing (1978) pp. 216-226. [25] L.G. Valiant, The complexity of enumeration and reliability problems, SIAM J. Computing 8 (1979) 410-421. [26] J. Wang and J. Vande Vate, Question-asking strategies for Horn clause systems, Ann. Math. Art. Intell. 1 (1990) 359-370.

You might also like