Towards a Compact Knowledge Representation by AR Models Georg Gottlob
Reinhard Pichler
Institut fur Informationssysteme Technische Universitat Wien Paniglgasse 16 1040 Wien, AUSTRIA
Institut fur Computersprachen Technische Universitat Wien Resselgasse 3/1/3 1040 Wien, AUSTRIA
[email protected]
[email protected]
Abstract
An AR model (= atomic representation of a Herbrand structure ) is given through a set A = fA1 ; : : : ; A g of atoms over some Herbrand universe H with the following intended meaning: a ground atom over H evaluates to true, i it is an instance of some atom A 2 A. The applicability of AR models to automated model building has been demonstrated by recent publications in this eld (cf. [FL 96]). Moreover, AR models are also a useful formalism for knowledge representation in general. For the practical work with AR models, the complexity of algorithms for evaluating atoms and arbitrary clauses is decisive. Actually, both problems are shown to be coNP complete in [GP98]. The complexity considerations in [GP98] and the algorithms presented in [Pic 98] reveal, that the number of ground instances represented by an atom set A (or by a single atom) has only little in uence on the complexity of evaluating atoms and clauses, while the form of A is crucial. In particular, it is advantageous to have a small number of general atoms in A rather than a large number of speci c atoms. The purpose of this work is to investigate 2 desirable properties of AR models, namely "most-generality" and "minimality". Their positive eect on the complexity of evaluating atoms and clauses is clear from the above cited papers. What still has to be investigated is the cost of testing these properties and, hence, of compiling an arbitrary AR model into an equivalent one with these properties. The main result of this work is the 2 -completeness proof for testing whether a given AR model is most general. Furthermore, "most-generality" is contrasted with "minimality" and it is sketched that the latter one has a similar complexity. n
i
p
1 Introduction and Basic De nitions An AR model (= atomic representation of a Herbrand structure ) over some Herbrand universe H is given through a set A = fA1 ; : : : ; An g of atoms over H with the following intended meaning: a ground atom over H evaluates to true, i it is an instance of some atom Ai 2 A. The generalization to non-ground atoms and arbitrary clauses over H is obvious, e.g.: A non-ground atom evaluates to true, i all its ground instances evaluate to true. In [FL 96], an algorithm for automatically generating AR models of satis able clause sets of a certain syntax class (which comprises a generalization of DATALOG to an in nite Herbrand universe) is presented. In [GP98], some complexity results concerning AR models are proven. In particular, the evaluation of non-ground atoms or clauses in an AR model is shown to be coNP-complete. Note that the atoms Ai in an AR model A are, in general, non-ground. Hence, AR models provide a formalism for representing exponentially many ground atoms (in case of a nite Herbrand universe H ) or even an in nite set of ground atoms (if H is in nite). The semantics of an AR model A over H is solely determined by the clauses which evaluate to true in A. This truth evaluation in A only depends on the set of ground instances contained 1
in the atoms of A, no matter how these ground instances are represented. In general, there are many dierent ways for representing the same set of ground instances by an AR model. As far as the actual work with AR models is concerned, the concrete representation of a set of ground atoms by an AR model has an enormous in uence on complexity issues (e.g.: the space required for storing an AR model, the time required for evaluating atoms or clauses, etc.) An important property of AR models is that the number of ground atoms represented by an AR model has little or no in uence on complexity issues. In [Pic 98], algorithms for evaluating atoms and clauses are presented, whose main source of complexity is the number of atoms involved. In particular, the evaluation of ground atoms in an AR model A comes down to simple matching and is, therefore, of linear complexity no matter whether the atoms in A are ground or not. Moreover, as a heuristics, a match will in general be found more rapidly, if every single atom Ai in A contains more ground instances. Hence, when searching for a "compact" representation of ground atoms by an AR model, it turns out to be advantageous to have a small number of general atoms in A rather than a large number of speci c atoms. In particular, we are interested in AR models represented by atoms which are "as general as possible". The purpose of this paper is to formalize the concept of "most-generality" and investigate the complexity of testing this property (and, hence, of constructing an AR model with this property). The main result of this paper will be the p2 -completeness proof for testing whether a given AR model is most general. Furthermore, we shall contrast most-generality with the minimality of AR models. It will be brie y discussed how these two concepts relate to each other and that the complexity of testing minimality is quite similar to most-generality. But rst we recall the notion of H -subsumption from [FL 96], which allows a concise formulation of the de nitions and results in this paper: De nition 1.1 (H-subsumption) Let H be some Herbrand universe and let A be an atom set over H . Then we de ne: "A H-subsumes an atom B " over H (written as "A sH B "), i for every H -ground instance B of B there is an atom Ai 2 A, s.t. B is an instance of Ai . Likewise, "A H-subsumes an atom set B" over H (written as "A sH B"), i for every atom B 2 B, A sH B holds. We write "A =sH B", i for the two atom sets A and B, both directions of H-subsumption A sH B and B sH A hold. Note that H -subsumption is just another way of looking at atom evaluation, i.e: An atom B evaluates to true in an AR model A , every ground instance of B is an instance of some Ai 2 A , A sH B . Hence, in particular, "A =sH B" simply denotes the equivalence of the AR models A and B. For ordinary subsumption, we shall use the notation "s ", i.e.: An atom "Ai subsumes B " (written as "Ai s B "), i B is an instance of Ai .
2 Most General AR Models In this chapter, we make the notion of a "most general" AR model precise. The remainder of this chapter will then be devoted to a thorough complexity analysis of "most-generality". De nition 2.1 (most general AR models) An AR model A = fA1 ; : : : ; Ang is called most general, i the following conditions hold: 1. A is subsumption reduced, i.e.: for any two distinct atoms Ai 6= Aj in A, Ai 6s Aj . 2. No atom Ai 2 A is an instance of a more general one which is H -subsumed by A, i.e.: for any atom Ai 2 A, there exists no atom B , s.t. Ai is a proper instance of B and A sH B . 2
Starting from the above de nition of "most-generality", we formulate the following decision problem:
De nition 2.2 (The MOST-GENERAL-ATOM problem) The MOST-GENERALATOM problem over some Herbrand universe H is de ned as follows: instance: (B ; A1; : : : ; An ), s.t. B , A1 ; : : : ; An are atoms over H . question: Is the atom B most general in fB , A1 ; : : : ; Ang, i.e.: there exists no atom B over H , s.t. B = B for some non-empty substitution and fB , A1 ; : : : ; An g sH B? 0
0
0
In the following theorem we prove the p2 -hardness of the MOST-GENERAL-ATOM problem.
Theorem 2.3 (p2-hardness the MOST-GENERAL-ATOM problem) The MOST-p GENERAL-ATOM problem over the two-elementary Herbrand universe H = f0; 1g is 2 hard.
Proof: Remember from [Sto 77], that the 3QSAT2 problem is p2-hard, i.e.: instance: (X1 ; X2 ; E ), s.t. X1 and X2 are pairwise disjoint sets of propositional variables and E is a Boolean formula of the form E = (l11 ^l12 ^l13 )_: : :_(ln1 ^ln2 ^ln3 ) with propositional variables in X1 [ X2 . question: Is the quanti ed Boolean sentence (9X1 )(8X2 )E satis able? In order to prove the p2 -hardness of the MOST-GENERAL-ATOM problem we show that its complementary problem NOT-MOST-GENERAL-ATOM is p2 -hard. To this end, we provide the following problem transformation from 3QSAT2 to the NOT-MOSTGENERAL-ATOM problem over the two-elementary Herbrand universe H = f0; 1g: Let P = (X1 ; X2 ; E ) be an arbitrary instance of the 3QSAT2 problem, i.e.: X1 = fx1 ; : : : ; xk g and X2 = fy1 ; : : : ; ymg are sets of propositional variables and E = (l11 ^ l12 ^ l13 ) _ : : : _ (ln1 ^ ln2 ^ ln3 ) is a Boolean formula with propositional variables in X1 [ X2 . Furthermore, let Q denote a predicate symbol of arity k + m + 1. Then we transform P into the following instance G = (B ; A1 ; : : : ; An ) of the NOT-MOST-GENERAL-ATOM problem over H = f0; 1g: B = Q(0; 0; : : : ; 0; y1 ; : : : ; ym ) and Ai = Q(1; si1 ; : : : ; sik ; ti1 ; : : : ; tim ), where 8 < 1 if xj 2 fli1 ; li2 ; li3 g sij := : 0 if :xj 2 fli1 ; li2 ; li3 g xj otherwise and 8 < 1 if yj 2 fli1 ; li2 ; li3 g tij := : 0 if :yj 2 fli1 ; li2 ; li3 g y otherwise j
The idea of this transformation is the following: In a straightforward p2 algorithm for the 3QSAT2 problem, there are 2 sources of complexity: First, the subset of those propositional variables in X1 has to be determined, which have to be evaluated to T. Then the validity of the resulting Boolean formula in the variables from X2 has to be checked via a SAToracle. The idea of the above problem transformation is to simulate these 2 sources of complexity of the 3QSAT2 problem by the NOT-MOST-GENERAL-ATOM problem. Note that, in principle, there are 2 ways, how an atom A can be "generalized", namely either some (but not all) occurrences of a variable with at least 2 occurrences in A are replaced by 3
a new variable or some positions which have the same non-variable symbol are replaced by a new variable. Actually, we shall only make use of the latter criterion in our proof. The 2 sources of complexity will then be simulated by the above instance of the NOT-MOSTGENERAL-ATOM problem in the following way: First, the subset of positions in B with constant symbol 0 have to be determined, which may be replaced by a new variable z . For the resulting atom B , one has to check via an H-subsumption oracle that every H -ground instance of B is either an instance of B or of some Ai . Obviously the above transformation can be done in polynomial time. It therefore only remains to prove that the two problem instances P and G are equivalent, i.e.: (9x1 ) : : : (9xk )(8y1 ) : : : (8ym ) E with E = (l11 ^ l12 ^ l13 ) _ : : : _ (ln1 ^ ln2 ^ ln3 ) is satis able , There exists an atom B over H , s.t. B = B for some non-empty substitution and fB , A1 ; : : : ; An g sH B 0
0
0
0
0
")": Suppose that (9x1) : : : (9xk )(8y1) : : : (8ym) E is satis able, i.e.: there exists an interpretation I on the propositional variables fx1 ; : : : ; xk g s.t. for every extension J of I to the propositional variables fy1; : : : ; ym g, J (E ) = T. Let z be a rst-
order variable not occurring in B . Then we de ne the atom B over H as follows: B = Q(z; u1 ; : : : ; uk ; y1; : : : ; ym ), where if I (xj ) = T uj := 0z otherwise 0
0
Furthermore let denote the substitution = fz 0g. Then B = B clearly holds. Hence, in particular, B is a proper instance of B . It remains to prove that fB , A1 ; : : : ; An g sH B holds. All ground instances B of B , where the variable z is mapped to 0, are subsumed by B . So we only have to consider the remaining ground instances of B : Let C = B be an arbitrary ground instance of B , s.t. z = 1. Then, by the de nition of B , C is of the form C = Q(1; v1 ; : : : ; vk ; w1 ; : : : ; wm ), where if I (xj ) = T vj := 01 otherwise 0
0
0
0
0
0
0
0
0
We de ne an extension J of I to the propositional variables fy1 ; : : : ; ym g as follows: if wj = 1 J (yj ) = FT otherwise By assumption, J (E ) = T. Hence, there is a disjunct li1 ^ li2 ^ li3 which evaluates to T in J . We claim that then C is subsumed by Ai . Note that all variables in Ai occur only once and may therefore be instantiated independently. It therefore remains to prove the following properties of the components v ; w of C and si ; ti of Ai , respectively:
sij s vj tij s wj
for all j 2 f1; : : : ; kg and for all j 2 f1; : : : ; mg
To this end, we distinguish 3 cases each. First we consider occurrences of the propositional variable xj for an arbitrary j 2 f1; : : : ; kg: 1. If xj 2 fli1 ; li2 ; li3 g then, by the de nition of Ai , sij = 1. Furthermore, I (xj ) = J (xj ) = T, since li1 ^ li2 ^ li3 evaluates to T in J . But then, by the de nition of B , also vj = 1 holds. Thus sij s vj holds in this case. 2. If :xj 2 fli1 ; li2 ; li3 g, then sij = 0. Furthermore, I (xj ) = J (xj ) = F, since li1 ^ li2 ^ li3 evaluates to T in J . Hence, also vj = 0 holds and, therefore, sij s vj again holds. 0
4
3. Otherwise, i.e.: xj 62 fli1 ; li2 ; li3 g and :xj 62 fli1 ; li2 ; li3 g. Then sij = xj and sij s vj clearly holds. We distinguish the analogous cases for the occurrences of the propositional variable yj with j 2 f1; : : : ; mg: 1. If yj 2 fli1 ; li2 ; li3 g then by the de nition of Ai , tij = 1. Furthermore, J (yj ) = T, since li1 ^ li2 ^ li3 evaluates to T in J . But then, by the de nition of J , also wj = 1 holds. Thus tij s wj holds in this case. 2. If :yj 2 fli1 ; li2 ; li3 g, then tij = 0. Furthermore, J (yj ) = F, since li1 ^ li2 ^ li3 evaluates to T in J . Hence, also wj = 0 holds and, therefore, tij s wj again holds. 3. Otherwise, i.e.: yj 62 fli1 ; li2 ; li3 g and :yj 62 fli1 ; li2 ; li3 g. Then tij = yj and tij s wj clearly holds. "(": Now suppose that there exists an atom B over H , s.t. B = B for some non-empty substitution and fB , A1 ; : : : ; An g sH B . By the form of B and by the fact that B is a proper instance of B , B must be of the form B = Q(u0 ; u1 ; : : : ; uk ; z1 ; : : : ; zm ), where the following conditions hold: 1. z1 ; : : : ; zm are variables occurring exactly once in B 2. u0 ; : : : ; uk are either variables or the constant symbol 0. 3. At least one uj is a variable. We de ne the instance B = Q(v0 ; v1 ; : : : ; vk ; z1 ; : : : ; zm ) of B in such a way that all variables uj are instantiated to 1, i.e.: uj = 0 vj := 01 ifotherwise 0
0
0
0
0
0
0
00
0
Then fB; A1 ; : : : ; An g sH B , since B is an instance of B . Furthermore, by the form of B and by the de nition of B , there is at least one component vj of B , s.t. vj = 1. Hence, no instance of B is subsumed by B and, therefore, fA1 ; : : : ; Ang sH B also holds. From B , we de ne the following interpretation I on the propositional variables fx1 ; : : : ; xk g: if vj = 1 I (xj ) = FT otherwise It remains to prove that for every extension J of I to the propositional variables fy1; : : : ; ym g, J (E ) = T holds: Let J be an arbitrary extension of I to fy1 ; : : : ; ym g. Then consider the ground instance C = Q(v0 ; v1 ; : : : ; vk ; w1 ; : : : ; wm ) of B , where the wj 's are de ned as follows: if J (yj ) = T wj := 01 otherwise 00
00
0
0
00
00
00
00
00
00
By assumption, C is subsumed by some atom Ai . Hence, in all components sij or tij , respectively, where Ai has a constant symbol, this constant symbol coincides with C . Remember from the de nition of Ai , that Ai = Q(1; si1 ; : : : ; sik ; ti1 ; : : : ; tim ), where 8 < 1 if xj 2 fli1 ; li2 ; li3 g sij := : 0 if :xj 2 fli1 ; li2 ; li3 g xj otherwise 5
and
8 1 if y 2 fl ; l ; l g < j i1 i2 i3 tij := : 0 if :yj 2 fli1 ; li2 ; li3 g yj otherwise We have to show that all literals li evaluate to T in J . To this end, we distinguish the following 4 cases for li : 1. li is an unnegated propositional variable from fx1 ; : : : ; xk g, i.e.: li = xj for some j 2 f1; : : : ; kg. Then, by the de nition of Ai , sij = 1 holds. Hence, in particular, sij is a constant and, therefore, coincides with vj . Moreover, by the de nition of I , the equivalence vj = 1 , I (xj ) = T holds. Thus, J (li ) = J (xj ) = I (xj ) = T. 2. li is a negated propositional variable from fx1 ; : : : ; xk g, i.e.: li = :xj for some j 2 f1; : : : ; kg. Then, by the de nition of Ai , sij = 0 holds. Hence, in particular, sij is a constant and, therefore, coincides with vj . Moreover, by the de nition of I , the equivalence vj = 0 , I (xj ) = F holds. Thus, J (li ) = I (:xj ) = T. 3. li is an unnegated propositional variable from fy1 ; : : : ; ym g, i.e.: li = yj for some j 2 f1; : : : ; mg. Then, by the de nition of Ai , tij = 1 holds. Hence, in particular, tij is a constant and, therefore, coincides with wj . Moreover, by the de nition of C , the equivalence wj = 1 , J (yj ) = T holds. Thus, J (li ) = J (yj ) = T. 4. li is a negated propositional variable from fy1 ; : : : ; yk g, i.e.: li = :yj for some j 2 f1; : : : ; mg. Then, by the de nition of Ai , tij = 0 and, therefore, also wj = 0 holds, since tij and wj coincide on constants. Moreover, by the de nition of C , the equivalence wj = 0 , J (yj ) = F holds. Thus, J (li ) = J (:yj ) = T. But then J (li1 ^ li2 ^ li3 ) = T and hence, in particular, J (E ) = T holds. 3
The generalization of the p2 -hardness of the MOST-GENERAL-ATOM problem from the two-elementary Herbrand universe H = f0; 1g to an arbitrary Herbrand universe is obvious. In order to prove the p2 -membership of the MOST-GENERAL-ATOM problem, we have to make use of a result proven in [GP98], namely the coNP-completeness (and, in particular, of the coNP-membership) of the atom evaluation in an AR model:
Theorem 2.4 (p2-membership of the MOST-GENERAL-ATOM problem) The p
MOST-GENERAL-ATOM problem over an arbitrary Herbrand universe H is in 2 .
Proof: Let H be an arbitrary Herbrand universe. Furthermore, let an instance of the
MOST-GENERAL-ATOM problem H be given through the atoms (B ; A1 ; : : : ; An ). In order to prove that the complementary problem NOT-MOST-GENERAL-ATOM is in p2 , we consider the following nondeterministic procedure with oracle: 1. Guess an atom B whose size (= the number of positions) is restricted by the size of B. 2. Check by matching that the atom B is a proper instance of B . 3. Check by means of an oracle for atom evaluation in AR models that fB; A1 ; : : : ; An g sH B . For the correctness of the above algorithm, note that the restriction on the size of the guessed atom B in step 1 is correct, i.e.: If B is a proper instance of B , then the number of positions in B is not greater than the number of positions in B . Moreover, remember that atom evaluation in AR models is the same as H-subsumption of atoms. Hence, the atom evaluation oracle used in the third step is actually appropriate for testing H -subsumption. 0
0
0
0
0
0
6
As far as the complexity is concerned, note that the above algorithm clearly works in nondeterministically polynomial time. Furthermore, the atom evaluation in an AR model (or, equivalently, the H-subsumption problem for atoms) has been shown to be coNPcomplete in [GP98]. Hence, the oracle used in the above algorithm is in coNP and, therefore, the overall algorithm is in p2 . 3 p The main result of this work, namely the 2 -completeness of the MOST-GENERAL-ATOM problem, follows immediately from the above theorems:
Corollary 2.5 (p2-completeness of the MOST-GENERAL-ATOM problem) The p
MOST-GENERAL-ATOM problem over an arbitrary Herbrand universe H is 2 -complete.
Proof: By theorem 2.3, the MOST-GENERAL-ATOM problem is p2 -hard. The p2 membership is proven in theorem 2.4. 3
3 Minimal AR Models We shall now brie y investigate how the "most-generality" of AR models relates to minimality. It will turn out that neither property is a consequence of the other one. However, there is a close relationship between these two concepts which will be explained in this chapter. Furthermore, we shall sketch why they are quite similar as far as the complexity is concerned. We rst make precise what is meant by a minimal AR model:
De nition 3.1 (minimal AR models) An AR model A = fA1 ; : : : ; An g is called minimal, i there is no other AR model B = fB1 ; : : : ; Bm g s.t. m < n and A =sH B. The following example illustrates that a minimal AR model is not necesarily most general and vice versa:
Example 3.2 Let A = fP (0; x); P (x; 1)g be an AR model over the two-elementary Herbrand universe H = f0; 1g, i.e.: the set of ground atoms which evaluate to T in A is the three-elementary set fP (0; 0); P (0; 1); P (1; 1)g. Hence A is both minimal (since a threeelementary set cannot be represented by a single atom over H = f0; 1g) and most general (since the atoms of A are only proper instances of an atom with 2 distinct variables, which would also contain the ground instance P (1; 0)). The AR model B = fP (0; x); P (x; 1); P (x; x)g is equivalent to A and it is also most general. However, B is not minimal. The AR model C = fP (0; x); P (1; 1)g is also equivalent to A and it is minimal. However, C is not most general, since P (1; 1) is a proper instance of P (x; 1), which is H-subsumed by C .
Note that the above example also illustrates that neither minimal AR models nor most general ones are unique. Moreover, even these two properties put together do not uniquely determine an AR model, e.g.: A = fP (0; x); P (x; x)g is equivalent to A and it is also most general and minimal. Even though most-generality and minimality do not imply each other, there is a strong connection between these two properties. In particular, a minimal AR model can be easily transformed into a minimal and most general one by the following transformation rule: "If there exists an atom B over H and there exists an atom Ai 2 A s.t. A sH B and Ai is a proper instance of B , then Ai 2 A may be replaced by B and all atoms Aj 2 A, that are instances of B , may be deleted." Note that this rule is clearly correct, since neither are ground instances added nor deleted by this rule. The termination follows from the fact that the number of distinct variables in B is strictly greater than in Ai , whenever this rule is applied to Ai . Hence, the total number of rule applications is restricted by the total 0
7
number of positions in the atoms of A. When no more rule application is possible, then the resulting AR model is most general. Furthermore, since the number of atoms cannot be increased by this rule, the resulting AR model is still minimal. The following non-deterministic procedure with NP-oracle can be used to test whether a given atom set A = fA1 ; : : : ; An g is not minimal: 1. Guess an atom set B = fB1 ; : : : ; Bm g with m < n. 2. Check by means of an oracle for atom evaluation in AR models that A and B have the same set of ground instances, i.e.: 8j 2 f1; : : : ; mg, A sH Bj and 8i 2 f1; : : : ; ng, B sH Ai . The p2 -membership can be easily established by the above procedure. On the other hand, the hardness of testing minimality requires further investigation. At any rate, it is somehow to be expected that, analogously to most-generality, the test for minimality is also p2 -hard. We thus formulate the following conjecture: Conjecture 3.3 (p2 -completeness of the MINIMAL-AR-MODEL problem) Let the MINIMAL-AR-MODEL problem over some Herbrand universe H be de ned as follows: instance: atom set A = fA1 ; : : : ; Ang over H . question: For every atom set B = fB1 ; : : : ; Bm g with A =sH B, does m n hold? Then the MINIMAL-AR-MODEL problem is p2 -complete.
4 Conclusion and Future Work After recalling the de nition of AR models, related complexity results and the motivation for their usefulness, we have investigated the question as to what practically relevant AR models should look like. This question is further motivated by the fact that, in general, the same set of ground atoms can be represented by many dierent AR models with essentially dierent characteristics. For the practical work with AR models, the complexity of evaluating atoms and clauses is decisive. Most-generality and minimality seem to be desirable properties both as far as the space required for their representation and the time complexity of the actual work with AR models is concerned. From this point of view, the compilation of arbitrary AR models into most general and/or minimal ones is clearly advantageous. However, the problem of testing these properties (and, hence, of constructing AR models with these properties) has been shown to be computationally very expensive. This high complexity may even be prohibitive for the feasibility of the above mentioned compilation. Future research in this area should therefore pursue two goals: On the one hand, despite the p2 -completeness of most-generality and minimality, one should not give up the search for a reasonably ecient algorithm, which allows the knowledge compilation in many cases. On the other hand, one should search for other properties of AR models, which are cheaper to achieve and which still have a positive eect on the complexity of the actual work with such AR models.
References [FL 96] [GP98] [Pic 98] [Sto 77]
C.Fermuller, A.Leitsch: Hyperresolution and Automated Model Building, Journal of Logic and Computation, Vol 6 No 2, pp. 173-230 (1996). G.Gottlob, R.Pichler: Complexity Results on Atomic Representations of Herbrand Models, to appear (1998). R.Pichler: Algorithms on Atomic Representations of Herbrand Models, to be presented at JELIA'98. L.J. Stockmeyer: The Polynomial Time Hierarchy, in Journal of Theoretical Computer Science, Vol 3, pp.1-12 (1977).
8