Tree{Based Fixpoint Iteration for Disjunctive Logic Programs
Dietmar Seipel
University of Tubingen
Sand 13, D { 72076 Tubingen, Germany
[email protected]
Abstract
Non{Horn programs containing disjunctive rules allow for more advanced applications of
deductive databases. But the inference process dealing with rapidly increasing amounts of
disjunctive facts becomes much more intricate, because of the problems of nding resolvable
atoms in the facts and of subsumption elimination in sets of facts.
We present an ecient implementation of the xpoint computation for the disjunctive consequence operator TPS based on the {iteration technique and on a compact data structure of
so{called clause trees for disjunctive facts. These trees speed up the combinatorial search in
a TPS {hyperresolution step. Furthermore, the necessary operations of subsumption elimination
can be performed eciently based on them.
The presented techniques can be used for computing the extended generalized closed world
assumption of a disjunctive logic program and the generalized disjunctive well{founded semantics of a disjunctive normal logic program as well.
1 Introduction
Deductive databases use logic programming as a powerful, declarative language for specifying
queries to relational databases. There has been a lot of research on processing de nite horn clauses
with de nite facts, cf. [BaRa 86], [Ul 88,89], [CeGoTa 90], where the desired result is the least
xpoint of the de nite consequence operator TP , which equals the minimal Herbrand model MP ,
cf. [Llo 87]. The possibly recursive program is evaluated iteratively in a set{oriented fashion based
on the primitive operations of relational algebra, which can be executed eciently on databases.
A very frequently used logic program P is the one that speci es the transitive closure of a graph
given by an arc{relation. It consists of two de nite logic rules:
path(X; Y )
: ? arc(X; Z ); path(Z; Y ):
path(X; Y )
: ? arc(X; Y ):
But, when applied to a graph given by inde nite information for arc, e.g. the three disjunctive
facts
arc(a; b) _ arc(a; c); arc(b; d) and arc(c; d);
it is necessary to use the general disjunctive consequence operator TPS instead of the de nite one for
deriving all the de nite (e.g. path(a; d)) and disjunctive (e.g. path(a; b) _ path(a; c)) facts logically
implied by P .
1
More advanced applications require even the support of disjunctive rules in addition to disjunctive
facts: The deduction of independencies in probabilistic reasoning, cf. [Pea 88], and the overlapping
of rectangles in spatial databases, cf. [AbWiPa 93], are examples falling into this category. In
general, a disjunctive logic rule has a head given by a disjunction of positive atoms and a body
given by a conjunction of positive and negated atoms:
a1(X1) _ : : : _ ak (Xk ) : ? b1(Y1) ^ : : : ^ bm (Ym ) ^ :bm+1 (Ym+1 ) ^ : : : ^ :bm+n (Ym+n ):
where ai (Xi) and bi(Yi ) are positive atoms with argument vectors Xi and Yi , respectively. The rule
is a de nite horn clause, i k = 1 and n = 0.
Inde nite rules without negated body literals (i.e. k > 1, n = 0) specify the set of logically
implied disjunctive facts (i.e. positive ground clauses), the so{called minimal model state MS P ,
cf. [LoMiRa 92]. Ecient techniques for computing MS P iteratively as the least xpoint of
the consequence operator TPS are currently investigated. Inde nite rules with negation (i.e. k > 1,
n > 0) can be evaluated by repeated computation of minimal model states w.r.t. certain disjunctive
transformations of P and of closed world assumptions, cf. well{founded semantics [VaGeRoSchli 91],
generalized well{founded semantics [BaLoMi 89], generalized disjunctive well{founded semantics
[LoMiRa 92], stationary semantics [Prz 90] and stable model semantics [GeLi 88].
We will review some of the notations and theoretical foundations for disjunctive logic programming
of [LoMiRa 92]. Then, we will describe a bottom{up procedure that iteratively derives the disjunctive facts of MS P and organizes them in a tree structure that is used for a fast hyperresolution
of further disjunctive facts by TPS . For simplicity, we will use an example with de nite rules and
disjunctive facts. The presented ideas, however, are applicable to disjunctive rules as well.
2 Foundations of Disjunctive Logic Programs
Syntactically, a deductive database DDB = (DB; P ) is given by a set DB of facts, which
resemble a relational database, and a logic program P , which consists of a set of rules for deriving
new facts from DB .
(i)
Given some atoms pi(Xi), where 1 i m, m 2 IN+ , and some literals Lj (Yj ), where
1 j n, n 2 IN0 . A disjunctive fact is given by
p1 (X1) _ : : : _ pm (Xm):
A disjunctive normal rule r is given by
r : p| 1 (X1) _ : {z
: : _ pm (Xm}) : ? L| 1 (Y1 ) ^ :{z: : ^ Ln(Yn)} :
head
body
where the atoms p1 (X1); : : :; pm (Xm) form its head and the literals L1 (Y1); : : :; Ln(Yn) form
its body. r is disjunctive, i all its body literals Li are positive. r is normal, i m = 1. The
head atoms are called dependent on the body literals. A disjunctive logic program is called
recursive, i there is a rule such that a body literal transitively depends on a head atom.
The disjunctive normal logic program containing all the ground instances of rules in P is
denoted by ground(P ).
2
The semantics of a deductive database DDB = (DB; P ) is de ned according to the bottom{up
or naive evaluation algorithms, cf. [LoMiRa 92], as the least xpoint of a consequence operator TPS .
(ii) The disjunctive Herbrand base DHBP of a disjunctive logic program P is given by the
set of positive ground clauses
DHBP = f A1 _ : : : _ Ak j k 1; Ai 2 HBP ; 1 i k g:
A Herbrand state S of P is a subset S DHBP . The canonical form and the expansion of
S are given by
can(S ) = f C 2 S j there is no proper subclause C of C in S g;
exp(S ) = f C 2 DHBP j there is a subclause C of C in S g;
respectively, i.e. can(S ) S exp(S ): S is called expanded, i exp(S ) = S .
The set di erence with subsumption of two Herbrand sets S1 and S2 is given by
S1 ns S2 = f C 2 S1 j C is not subsumed by any clause in S2 g:
0
0
(iii) The disjunctive consequence operator TPS : 2DHBP ?! 2DHBP of a disjunctive logic
program P maps Herbrand states to Herbrand states:
TPS (D) = f C 2 DHBP j C :{ B1; : : :; Bn is in ground(P );
B1 _ C1; : : :; Bn _ Cn are in D; C is the smallest factor of C _ C1 _ : : : _ Cng:
A model state S of a disjunctive logic program P is an expanded Herbrand state of P such
that every minimal Herbrand model of S is a Herbrand model of P .
0
0
Example 2.1 ([LoMiRa 92]) Given the disjunctive logic program
P = f getto(X; Y ) _ getto(X; Z ) :{ path(X; Y; via(Z )); at(X );
at(X ) :{ getto(Y; X );
path(was; ny; via(phil)) _ at(ny) g:
For the state S1 = f path(was; ny; via(phil)) _ at(ny ) g we have
TPS (S1) = f path(was; ny; via(phil)) _ at(ny);
getto(was; ny) _ getto(was; phil) _ path(was; ny; via(phil)) _ at(ny) g
and for the state S2 = TPS (S1) we have
TPS (S2) = TPS (S1) [ f at(ny) _ getto(was; phil) _ path(was; ny; via(phil));
at(phil) _ at(ny) _ getto(was; ny) _ path(was; ny; via(phil)) g:
For every de nite logic program P the following sets are equal, cf. [Llo 87]: the logical consequences
f A 2 HBP j P j= A g of P , the minimal Herbrand model MP of P , the least xpoint lfp(TP ) of
the de nite consequence operator TP , and TP " ! .
In general a disjunctive logic program P does not have a unique minimal model, but a set MMP
of minimal models. The following theorem relates model states to the disjunctive consequence
operator and shows that { as for Herbrand models of de nite logic programs { every intersection
of model states again is a model state.
3
Theorem 2.2 (Model States) Given a disjunctive logic program P .
1. Characterization: An expanded Herbrand state D of P is a model state of P , i TPS (D) D.
2. Intersection Property: The intersection \i J MSi of every non{empty set fMSigi J of model
states of P is a model state of P too.
2
2
Thus, there is a unique minimal model state MS P of a disjunctive logic program P , namely the
intersection \i J MSi of the set fMSi gi J of all model states of P .
According to [LoMiRa 92], the following Herbrand states are equal:
2
1.
2.
3.
4.
5.
2
the logical (disjunctive) consequences f C 2 DHBP j P j= C g,
the minimal model state MS P of P ,
the expanded least xpoint exp(lfp(TPS )) of TPS ,
the expansion exp(TPS " ! ) of the ! {power TPS " ! of TPS , and
the set f C 2 DHBP j 8M 2 MMP : M j= C g of clauses implied by all minimal models of P .
For a de nite logic program P , the minimal Herbrand model MP is equal to the canonization
can(MS P ) of the minimal model state.
3 Optimization Techniques for the Fixpoint{Computation
A well{known paradigm of recursive query processing is {iteration or semi{naive iteration, cf.
[BaRa 86], [GuKiBa 87]. Up to now it has been used mainly for the xpoint computation of de nite
consequence operators. It can of course be used for the disjunctive consequence operator as well.
In [KoKiThoGu 93] it has been shown that {iteration combined with subsumption techniques is
sound and complete for all operators which are monotonous w.r.t. the subsumption ordering.
Fixpoint computation dealing with rapidly increasing amounts of disjunctive facts is rather intricate, because of the problems of nding resolvable atoms in the facts and of subsumption elimination
in fact sets. The disjunctive consequence operator TPS can be eciently implemented based on a
compact data structure of so{called clause trees for disjunctive facts. This will speed up the combinatorial search in a TPS {hyperresolution step. The necessary operations for subsumption elimination
during the {iteration process can be performed eciently based on the clause trees.
3.1
The Tree{Based Disjunctive Consequence Operator
The disjunctive consequence operator TPS applied to a Herbrand state S searches for all disjunctive
facts B1 _ C1; : : : ; Bn _ Cn in S that can be hyperresolved with a ground instance C :{ B1 ; : : :; Bn
of a rule r 2 P , deriving the smallest factor of C _ C1 _ : : : _ Cn .
0
0
Example 3.1 Given the disjunctive logic program P with the transitive closure rule
p(X; Y ) :{ p(X; Z ); p(Z; Y )
4
and the Herbrand state
S = f
p(a; b) _ p(f; g); p(a; b) _ p(f; h);
p(a; b) _ p(a; d) _ p(a; c) _ p(a; 1); : : : ; p(a; b) _ p(a; d) _ p(a; c) _ p(a; m);
p(b; c) _ p(g; 1); : : : ; p(b; c) _ p(g; n) g
From each of the facts p(a; b) _ p(a; d) _ p(a; c) _ p(a; i); 1 i m; and each of the facts
p(b; c) _ p(g; j); 1 j n; the TPS {operator derives n m new facts
p(a; d) _ p(a; c) _ p(a; i) _ p(g; j)
using the same ground instance of the transitive closure rule p(a; c) :{ p(a; b); p(b; c)
In the following disjunctive facts will be considered as sets of atoms.
Assume for each body atom Bi , 1 i n, facts Fij 2 S , 1 j ki , with common intersection Fi
such that Bi 2 Fi . We will try to store Fi just once with pointers to the ki di erence sets Fij n Fi .
Thus, once we have found that Bi 2 Fi , we knowQthat each Fij has the form Bi _ Cij , where
Cij = Fij n fBi g. Therefore the Fij can be used for ni=1 ki hyperresolutions producing facts that
all have the common subclause F10 _ : : : _ Fn0 , where Fi = Fi0 _ Bi . In the example above we had
B1 = p(a; b), B2 = p(b; c) and k1 = m, k2 = n.
As suggested, repeated application of the TPS {operator tends to rapidly increase the amount of
intersections between derived disjunctive facts.
The state overlap ratio oS (S ) is given by the ratio of the sums of the cardinalities of the clauses
in S and the total number of atoms in S :
P
oS (S ) := j SC2S jCCjj :
C 2S
When searching S for facts during resolution, each atom in S will be looked at oS (S ) times on
average. In the above example we had oS (S ) = ( 4 + 4 m + 2 n )=( 6 + n + m ), which converges
to 3 for large n = m.
The hasse diagram HS for the superset S 0 = f C1 \ : : : \ Ck j k 2 IN+ ; Ci 2 S; 1 i k g of
a nite Herbrand state S contains all the mentioned intersection information. But the cardinality
jS 0j can be of exponential size 2jSj. E.g. for the Herbrand state S = fC1; : : :; Cng containing the
clauses Ci = p1 _ : : : _ pi?1 _ pi+1 _ : : : _ pn the set S 0 contains all the subsets of fp1 ; : : :; png except
the full one. Thus, we are looking for a suitable small subset S 00 of S 0 (S S 00 S 0 ) that captures
a suitable subset of common intersections of clauses in S . For every resolution step the whole data
structure has to be searched for occurrences of Bi . This suggests to reduce the number of edges as
well as the number of nodes.
0
Example 3.2 Given the Herbrand state S = f o _ p _ t; o _ q _ t; p _ q g. The hasse diagram
HS for the superset S 0 = S [ fo _ t; p; q g containing all intersections is given by gure 1, as
well as two possible subtrees T1 and T2 , containing all the leaf nodes of HS .
0
0
A tree representation of Herbrand states will turn out to be a reasonable choice for supporting
deduction eciently.
De nition 3.3 Given a Herbrand state S . Let AS = [C2S C denote all the atoms occurring in the
clauses of S . A clause tree T = (V; E ) with a node labeling l : V ?! 2AS represents S , i
5
HS :
;
0
o
T1 :
? @
?? ? @@
R
_
?
@
?
@
?
?
@
R ?
R ? @@
??@
p
t
q
o_p_t o_q_t
o
p_q
;
T2 :
?
?? ?
_
@ @ @@
@R
? @R
o_p_t o_q_t
@
? @@R
? ??
?
? ? ?
p
t
;
p
p_q
o_p_t o_q_t
q
p_q
Figure 1: The Hasse{diagram HS and Steiner subtrees T1, T2
0
(i) each node 2 represents a clause
v
V
clause(v ) as follows: clause(v ) is the union of the sets
( ) which label the nodes v on the path from the root to v ,
(ii) the clauses clause(v) of the leaves v 2 V are in S , and every clause C 2 S is represented by
exactly one leaf of the clause tree.
l v
0
0
For tree construction of T = (V ; E ) we use as heuristic the minimizing of the sum of the arc lengths:
(T ) =
weight
X
e2E
()
length e
where length(e) = j clause(v2) n clause(v1) j, for (v1; v2) 2 E , i.e. we are looking for a minimal
Steiner tree T , cf. [Vo 90], of the hasse diagram HS . The price for this compact data structure
is of course a lack of symmetry in the treatment of intersections compared to HS . In example 3.2
clause tree T1 has the weight 6 and clause tree T2 has the weight 7. T1 is a minimal Steiner tree of
the hasse diagram HS .
0
0
0
Example 3.4 For the transitive closure example 3.1 the Steiner tree T { given in gure 2 {
representing the Herbrand state S is unique { which usually is not the case. The node identi ers
are omitted, only the labels are displayed.
;
HHH
HHHj
( )
( )
? QQQQs ??? @@@R
+
( )_
p a; b
(
p f; g
)
(
p f; h
p b; c
)
( 1)
p a; d
( )
? @
?? @@R
1)
( m)
p g;
p a; c
(
p a;
:::
:::
( n)
p g;
p a;
Figure 2: Tree representation by a minimal Steiner tree
6
Based on clause tree representations T of a Herbrand state S the TPS {operator is evaluated in
two steps. The rst one, tree search, determines nodes in the tree, such that there is a ground
instance of a rule from P whose body atoms are contained in the tree nodes. The second one, tree
resolution, resolves the clauses for the leaf nodes in the subtrees of the determined nodes w.r.t the
ground instance of the rule found in tree search.
tree search
search for all disjunctive facts B1 _ C1 ; : : : ; Bn _ Cn in the labeled tree T , such
that there is a ground instance C :{ B1 ; : : : ; Bn of a rule r 2 P as follows:
for each rule r given by p1 (X1) _ : : : _ pm (Xm ) :{ q1 (Y1 ) ^ : : : ^ qn(Yn ) successively look for nodes vi (1 i n) in the clause tree, such that some
Bi 2 clause(vi ) instantiates qi (Yi ), and no Bi 2 clause(vi ) does so for all
predecessors vi of vi in T ;
0
00
00
tree resolution
let vij (1 j ki) be
the leaves in the subtree Tv of T rooted at vi:
for each successful search, i.e. a combination v1j1 ; v2j2 ; : : : ; vnj of leaves in
Tv1 ; Tv2 ; : : : ; Tv , respectively, derive a new disjunctive fact C as the smallest factor of C _ C1 _ : : : _ Cn, where Ci = clause(vij ) n fBi g (note, that the
j
Bi choosen in tree search is contained in clause(vi ) clause(vi ));
i
n
n
0
Interleaved with the TPS {operator, the insertion of the portion of newly derived facts which are not
subsumed by already known facts in the old clause tree can be performed:
tree update
determine a new clause tree representation T with a labeling l for the updated
set S of disjunctive facts by re ning { cf. gure 3 { the clause tree T at node
vi , for some arbitrarily picked i 2 f1; : : : ; ng:
insert a node vi labeled by l(vi) n fBi g in the tree T (if not already present);
replace the edge (vi ; vi) in T between vi and its immediate predecessor vi by
two new edges (vi ; vi), (vi; vi);
Q
generate an (optimal) representing subtree Tv for the set of all ni=1 ki resolvents rooted at the node vi (correct, since clause(vi) is a subclause of each
resolvent !).
0
00
00
00
0
0
0
i
0
0
The { relatively large
Q { clause D = C _ clause(v1) n fB1g _ : : : _ clause(vn) n fBng is a common
subclause of all the ni=1 ki derived resolvents C . It yields exactly one node in the new subtree Tv .
Only the di erence clauses C n D have to be considered, when building Tv , which is a great gain
in eciency.
The tree overlap ratio oT (T ) of a clause tree T is given by the ratio of the weight of T and the
total number of atoms in S :
weight(T )
S
o (T ) :=
:
0
0
i
0
i
T
j
C 2S C j
When searching the clause tree T for facts C from S during resolution, each atom occuring in S
will be looked at oT (T ) times on average. Since
j
[
C 2S
C
j
(T )
weight
7
X
C 2S
j j
C ;
T:
A
A
A
A
A
A
A
v
i
00
r
0
r
i %B
vi %
r
B
A B vi0
A B
A B
A B
A B
A
B
B
v
T
A
A
A
A
A
A
A
A
A
A
Figure 3: Tree{re nement
it holds
1 oT (T ) oS (S ):
In the above example 3.4 we had oT (T ) = 1, i.e. the tree overlap ratio is minimal.
We were looking for fast algorithms constructing tree representations T with small oT (T ). Unfortunately, the minimal Steiner problem in graphs is NP {complete, cf. [Vo 90]. So, we have
implemented two heuristic methods:
(i)
(ii)
The rst one is based on constructing minimal spanning trees in the hasse diagram HS .
These trees can be transformed easily to Steiner trees. In graph theory, this is considered a
good heuristic for the general minimal Steiner tree problem.
But, a clause set S has much more structure that can be used for tree construction. The
second technique forgets about the hasse diagram and builts the tree T inductively by a
heuristic for the insertion of a clause C from S into an intermediate tree.
0
In our test runs, the achieved tree overlap ratios of the two methods were about equal. But the
second method worked much faster. It took only about 10% of the run time. Thus, for larger
Herbrand states containing more than 50 di erent atoms the rst method was too slow and could
no longer be used.
3.2
The Tree{Based
{Iteration Technique
Semi{naive or {iteration was originally de ned for de nite logic programs. For extending it to
the xpoint computation of a disjunctive logic program P , we need the {version of the disjunctive
consequence operator TPS .
8
De nition 3.5 Given a disjunctive logic program and two Herbrand states and of .
The disjunctive {consequence operator PS : 2DHBP 2DHBP ?! 2DHBP is de ned as
S
2 DHBP j :{ 1
( )
n is in
P( ) = f
[ some i _ i is in
1_ 1
n _ n are in
is the smallest factor of _ 1 _ _ n g
P
D
D
P
T
T
D;
D
C
C
B
0
B ; : : :; B
C ; : : :; B
ground P ;
C
C
D
C
0
D;
C
:::
B
C
C
D;
:
The algorithm {Iteration{1 of gure 4 formulates the disjunctive {iteration based on the {
version of TPS . When applied to the empty Herbrand state S = ;, it yields the least xpoint of TPS .
Algorithm {Iteration{1 (
f initialization g
P; S
)
S := S ;
f iteration g
while ( jS j > 0 )
S := can( prune(TPS (S; S )) ) ns S ;
S
:= can( S [ S );
end
Figure 4: Disjunctive {iteration
The basic operations of {Iteration{1 are the following. From a computational point of view, TPS
derives a multiset S of disjunctive facts, which has to be pruned by removing duplicates. The time
complexity of pruning is n log n, where n = jS j is the number of facts in S . {computation
w.r.t. subsumption is the computation of the set S1 ns S2 of all disjunctive facts in a Herbrand
state S1 which are not subsumed by a disjunctive fact in another Herbrand state S2 . It takes time
n1 n2 , where ni = jSi j. Canonization is the computation of all disjunctive facts in a Herbrand
state S which are not properly subsumed by other { i.e. shorter { disjunctive facts in the same
state. It takes time n2 , where n = jS j.
Based on these considerations, we derive a more ecient version of the disjunctive {iteration by
rearranging the basic operations.
0
0
0
00
00
Algorithm {Iteration{2 (
f initialization g
P; S
)
S := S ;
f iteration g
while ( jS j > 0 )
S1
:= TPS (S; S );
S2
:= prune(S1);
S3
:= S2 ns S ;
S := can(S3);
S
:= can(S [ S );
end
Figure 5: Improved disjunctive {iteration
9
Experiments with {Iteration{2, cf. tables 2 and 3 revealed, that the comparatively cheap
pruning operation reduces the multiset S1 of derived facts to about 30% of its size. Only to the
resulting facts {computation has to be applied yielding a further reduction to about 1 % of the
size of S1 in time O(jS2j jS j), where normally S is much smaller than S2. Finally, the most
expensive operation can is delayed as far as possible. It is applied to the smallest Herbrand state
S3 and reduces it to about 0.5% of the size of S1.
Based on a tree representation T of the intermediate Herbrand states S , it can be determined very
eciently if a Herbrand state S subsumes a given disjunctive fact, cf. the following Prolog{rules:
tree subsumes([RootjSubtrees],D Fact) :subsumes(Root,D Fact),
member(Subtree,Subtrees),
tree subsumes(Subtree,D Fact).
tree subsumes([Root],D Fact) :subset(Root,D Fact).
A clause tree is given by a clause Root denoting its root and a list Subtrees of zero or more subtrees
of Root. A clause C1 subsumes another clause C2 if C1 is a subclause of C2. Thus, tree subsumes
essentially searches for a complete path in the tree representation from the root to a leaf, such that
all labeling clauses of the nodes on the path are subclauses of the investigated clause. Then the
clause represented by the determined leaf is in S and subsumes the investigated disjunctive fact.
3.3 Experimental Results
We have compared Prolog{implementations of the basic version of algorithm {Iteration{2
and a tree{based version of algorithm {Iteration{2 using clause trees for resolution and subsumption. We achieved very encouraging results for the path example, even without incorporating
all possible optimization techniques. I.e. tree update was done by rooting a representing clause
tree for the derived new facts at the root of the old clause tree, instead of re ning the old tree or
merging the old and the derived clause tree, which might yield a tree with a smaller weight.
Example 3.6 Table 1 shows the ratio of the evaluation times for the xpoint computations with
the basic version (t1) and the tree{based version (t2 ) of {Iteration{2 for di erent initial Herbrand states S in the running transitive closure example. We have measured the state overlap
ratios oS (S ), the tree overlap ratios oT (T ) and the compacti cation ratios oS (S )=oT (T ) at the beginning (superscript i), at the end (superscript f ) and at the time where the compacti cation ratio
oS (S )=oT (T ) was maximal (superscript m).
o(Si)
1:54
1:73
1:88
2:00
o(Si) =o(Ti)
1:54
1:73
1:88
2:00
o(Sf )
18:26
22:23
25:64
28:68
o(Sf ) =o(Tf )
2:50
2:72
2:87
3:00
o(Sm)
23:53
34:55
44:52
54:50
o(Sm) =o(Tm)
2:66
2:98
3:23
3:41
t1 =t2
1:69
2:14
2:65
3:49
Table 1: Comparison of basic and tree{based {Iteration{2
For Herbrand states with many overlapping facts, i.e. large state overlap ratios oS (S ), the tree{based
version becomes more and more ecient and superior to the basic version of {Iteration{2.
10
For disjunctive rules with more than two body atoms we have achieved a speed{up for the tree{
based version of more than 10. When compared to the initial version {Iteration{1 { where the
canonization operation is performed before the {computation by ns { the speed{up is even much
higher.
We have also analysed the tree{based version of {Iteration{2 for the disjunctive transitive
closure example by measuring the following: the times for the basic operations of the iteration
steps, the numbers of tuples after the di erent operators, the state and tree overlap ratios, the
compacti cation ratios after the performed iteration steps.
Example 3.7 The tree{based version of {Iteration{2 for the disjunctive transitive closure ex-
ample for a Herbrand state with 11 facts yielded the results given by the tables 2, 3 and 4.
1
S 0:26
TP
prune 0:01
ns 0:05
can 0:27
can 0:55
step
2
3
4
2:69 28:71 11:22 42%
0:53 11:46 4:13 12:6%
1:21 19:68 11:33 32%
2:45 1:13 0:01 3:5%
5:17 4:19 0:02 9:9%
Table 2: Time for tree{based {Iteration{2
1
2
3
4
S 100 2:209 33:406 12:667 100%
TP
prune 50 891 8:612 5:235 31%
ns
44 208
151
0 0:9%
can 44 132
47
0 0:5%
can
0
3
30
0 14%
step
Table 3: Numbers of tuples after the di erent operators
step
S
T
oS =oT
o
o
0
1
2
3
4
1:75 8:36 28:92 31:08 31:08
1:00 3:64 10:12 10:77 10:77
1:75 2:30 2:86 2:89 2:89
Table 4: State and tree overlap ratios, compacti cation ratios
Most of the run time { 42% { is spent for the disjunctive TPS {operator. Pruning also takes a
considerable amount { 13% { of the run time, since it has to reduce a huge number (about 50:000)
of tuples to about 30%. {computation, although it has been speeded up by using trees, still is very
expensive and takes a further 32% of the run time. The canonization operations are much cheaper
than in the case where they are applied before the {computation.
11
4 Summary and Outlook
Disjunctive, normal logic programs P can be evaluated by repeated computation of minimal model
states w.r.t. certain disjunctive transformations of P to compute the generalized disjunctive well{
founded semantics.
Tree{based {iteration techniques can be used for computing the extended generalized closed world
assumption (EGCWA) of a disjunctive logic program as de ned in [LoMiRa 92]. The support for
negation sets for conjunctive facts can be eciently derived by an iteration from the minimal
model state MS P . Furthermore, the positive and the negative consequence operator TSD and FSD ,
respectively, used for de ning the generalized disjunctive well{founded semantics can be speeded
up by tree{based {iteration.
We have developed a tree{based evaluation of disjunctive normal logic programs under the generalized disjunctive well{founded semantics. It has been implemented as a meta{interpreter in
Prolog. The basic operators are the disjunctive consequence operator TPS , the {operator ns
with subsumption and the canonization operator can for Herbrand states. Tree{based versions of
these operators are used to built a {iteration technique for the computation of the least xpoint
of a disjunctive logic program. Based on this, the generalized disjunctive well{founded semantics
of disjunctive normal logic programs can be computed.
Tree{resolution has been analysed for the frequently occurring de nite transitive closure rules with
disjunctive facts. For general disjunctive logic programs involving disjunctive rules the method
is applicable as well, and yields even more ecient evaluation. The state overlap ratio gets even
higher, since the common subclause of the resolvents contains the whole disjunctive rule head.
Incorporating aspects of other data structures like Tries, cf. [AhHoUl 83], for a bit vector representation of Herbrand states, hash tables and inverted lists is currently investigated.
References
[AbWiPa 93] A. Abdelmoty, M. Williams, N. Paton: Deduction and Deductive Databases for Geographic
Data Handling, Proc. Intl. Symposium on Advances in Spatial Databases 1993 (SSD'93), pp. 443-464.
[AhHoUl 83] A. Aho, J. Hopcroft, J. Ullman: Data Structures and Algorithms, Addison{Wesley, 1983.
[BaLoMi 89] C. Baral, J. Lobo, J. Minker: Generalized Well{Founded Semantics for Logic Programs, Proc.
Intl. Conf. on Automated Deduction 1989, pp. 102-116.
[BaRa 86] F. Bancilhon, R. Ramakrishnan: An Amateur's Introduction to Recursive Query Processing
Strategies, Proc. ACM SIGMOD 1986, pp. 16-52.
[CeGoTa 90] S. Ceri, G. Gottlob, L. Tanca: Logic Programming and Databases, Springer, 1990.
[CheWa 92] W. Chen, D.S. Warren: A Goal{Oriented Approach to Computing Well{Founded Semantics,
Proc. Joint Intl. Conf. and Symp. on Logic Programming 1992, pp. 589-603.
[CheWa 93] W. Chen, D.S. Warren: Query Evaluation under the Well{Founded Semantics, Proc. ACM
PODS 1993.
[Da 92] S.K. Das: Deductive Databases and Logic Programming, Addison{Wesley, 1992.
[Fu 91] U. Fuhrbach: Computing Answers for Disjunctive Logic Programs, Proc. ILPS Workshop on Disjunctive Logic Programs 1991.
12
[GeLi 88] M. Gelfond, V. Lifschitz: The Stable Model Semantics for Logic Programming, Proc. Intl. Conf.
and Symp. on Logic Programming 1988, pp. 1070-1080.
[GuKiBa 87] U. Guntzer, W. Kieling, R. Bayer: On the Evaluation of Recursion in ( Deductive ) Database
Systems by Ecient Di erential Fixpoint Iteration, Proc. Intl. Conf. on Data Engineering 1987, pp.
120-129.
[KoKiThoGu 93] G. Kostler, W. Kieling, H. Thone, U. Guntzer: The Di erential Fixpoint Operator with
Subsumption, Proc. Intl. Conf. on Deductive and Object{Oriented Databases 1993.
[Llo 87] J.W. Lloyd: Foundations of Logic Programming, Springer, second edition, 1987.
[LoMiRa 92] J. Lobo, J. Minker, A. Rajasekar: Foundations of Disjunctive Logic Programming, MIT Press,
1992.
[Pea 88] J. Pearl: Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference, Morgan
Kaufman, 1988.
[Prz 90] T.C. Przymusinski: Stationary Semantics for Disjunctive Logic Programs and Deductive Databases,
Proc. North{American Conf. of Logic Programming, MIT Press, 1990, pp. 42-59.
[SeiAr 93] D. Seipel, H. Argenton: Evaluation Techniques for Disjunctive Logic Programs, Proc. Symposium
on Operations Research 1993.
[Ul 88,89] J.D. Ullman: Principles of Database and Knowledge-Base Systems, Volume I,II, Computer Science Press, 1988/89.
[VaGeRoSchli 91] A. Van Gelder, K.A. Ross, J.S. Schlipf: The Well{Founded Semantics for General Logic
Programs, JACM, vol. 38(3), 1991, pp. 620-650.
[Vo 90] S. Vo: Steiner{Probleme in Graphen, Anton Hain, 1990.
13