Academia.eduAcademia.edu

Computational Logic: Logic Programming and Beyond

2002, Lecture Notes in Computer Science

We present a new approach to termination analysis of logic programs. The essence of the approach is that we make use of general orderings (instead of level mappings), like it is done in transformational approaches to logic program termination analysis, but we apply these orderings directly to the logic program and not to the term-rewrite system obtained through some transformation. We de ne some variants of acceptability, based on general orderings, and show how they are equivalent to LD-termination. We develop a demand driven, constraint-based approach to verify these acceptability-variants. The advantage of the approach over standard acceptability is that in some cases, where complex level mappings are needed, fairly simple orderings may be easily generated. The advantage over transformational approaches is that it avoids the transformation step all together.

Acceptability with general orderings Danny De Schreye, Alexander Serebrenik Department of Computer Science, K.U. Leuven Celestijnenlaan 200A, B-3001, Heverlee, Belgium Email: fDanny.DeSchreye, [email protected] Abstract. We present a new approach to termination analysis of logic programs. The essence of the approach is that we make use of general orderings (instead of level mappings), like it is done in transformational approaches to logic program termination analysis, but we apply these orderings directly to the logic program and not to the term-rewrite system obtained through some transformation. We de ne some variants of acceptability, based on general orderings, and show how they are equivalent to LD-termination. We develop a demand driven, constraint-based approach to verify these acceptability-variants. The advantage of the approach over standard acceptability is that in some cases, where complex level mappings are needed, fairly simple orderings may be easily generated. The advantage over transformational approaches is that it avoids the transformation step all together. Keywords: termination analysis, acceptability, orderings. 1 Introduction It is not uncommon in research to have di erent research communities that tackle a same problem from a very di erent perspective or using totally di erent techniques. In some cases, such communities may co-exist for many years without much integration, cross-fertilisation or even decent comparison of the relative merits and drawbacks of competing approaches. In the context of termination analysis of logic programs, two such subcommunities are those who develop and apply \transformational" approaches and those working on \direct" ones. A transformational approach rst transforms the logic program into an \equivalent" term-rewrite system (or, in some cases, into an equivalent functional program). Here, equivalence means that, at the very least, the termination of the term-rewrite system should imply the termination of the logic program, for some prede ned collection of queries1. Direct approaches do not include such a transformation, but prove the termination directly on the basis of the logic program. Besides the transformation step itself, there is one other technical di erence between these approaches. Direct approaches usually prove termination on the 1 The approach of Arts [5] is exceptional in the sense that the termination of the logic program is concluded from a weaker property of single-redex normalisation of the term-rewrite system. basis of a well-founded ordering over the natural numbers. More speci cally, they use a level mapping, which maps atoms to natural numbers, and, they verify appropriate decreases of this level mapping on the atoms occurring in the clauses. On the other hand, transformational approaches make use of more general well-founded orderings over terms, such as reduction orderings, or more speci cally simpli cation orderings, or others (see [14]). At least for the direct approaches the systematic choice for level mappings and norms|functions which map each term (module variable renaming) to a corresponding natural number|instead of general orderings, seems arbitrary and ad hoc. More generally, the relative merits and drawbacks of these two lines of work are not well understood. This has been the main motivation for this paper. We present an initial study on the use of general well-founded orderings as a means of directly proving the termination of logic programs|without intermediate transformation. In particular, { we study whether the theoretical results on acceptability can be reformulated on the basis of general orderings, { we evaluate to what extent the use of the general orderings (instead of level mappings) either improves or deteriorates the direct approaches. To illustrate the latter point, consider the following program, that formulates some of the rules for computing the repeated derivative of a linear function in one variable u (see also [16]) : Example 1. d(der(u); 1): d(der(A); 0) number(A): d(der(X + Y ); DX + DY ) d(der(X ); DX ); d(der(Y ); DY ): d(der(X Y ); X DY + Y DX ) d(der(X ); DX ); d(der(Y ); DY ): d(der(der(X )); DDX ) d(der(X ); DX ); d(der(DX ); DDX ): We are interested in proving LD-termination, i.e., niteness of the SLD-tree constructed using the left-to-right selection rule of Prolog, of the program above together with the queries of the form d(t; v) , where t is a term, expressing a derivative of a linear function in one variable u, such as der(der(u u u + 3 u u + 3 u + 1)), and v is a fresh variable, that will be uni ed with the result of the computation. Doing this on the basis of a level-mapping is hard. For this example, a levelmapping that decreases between two sequential calls of d is a non-linear function. In particular, a level mapping , and a norm , such that: d(X; Y ) = X ; number(X ) = 0; der(X ) = 2kX k ; X + Y = max( X ; Y ) + 1; X Y = max( X ; Y ) + 1; u = 2; n = 2; if n is a number,would be needed. No automatic system for proving termination on the basis of level mappings is able to generate such mappings. Moreover, we believe, that it would be very dicult to extend existing systems to support generation of appropriate nonlinear mappings. 2         j  j j j k k k k k k k k kk k k k k 2 j k k k k j k k  k k Although we have not yet presented our general-well-founded ordering approach, it should be intuitively clear, that we can capture the decrease in ordering between the der( ) and by using an ordering on terms that gives the highest \priority" to the functor der. On the other hand, using level mappings and norms allows sometimes to explore more precise information on atoms and terms, that cannot be expressed by general orderings, such as arithmetical relations between terms. This information can sometimes be crucial in proving termination as the following program from [10, 13] demonstrates. Example 2. X conf(X ) DX delete2 (X; Z ); delete(U; Y ; Z ); conf(Y ): delete2 (X; Y ) delete(X; [X delete(X; [H j j delete(U; X; Z ); delete(V ; Z; Y ): ] ) ] [ j 1]) T ;T : T ; H T delete(X; T ; T 1): Note that by reasoning in terms of sizes of terms, we can infer that the size decreases by 2 after the call to delete2 predicate in the rst clause and then increases by 1 in the subsequent call to the delete predicate. In total, sizes allow us to conclude a decrease. Reasoning in terms of ordering relations only, however, does not allow to conclude the overall decrease from the facts that the third argument of delete predicate is smaller (with respect to some ) than the second one and that the rst argument of delete2 predicate is greater (with respect to ) than the second one. 2 As can be expected, theoretically both approaches are essentially equivalent. We will introduce a variant of the notion of acceptability, based on general orderings, which is again equivalent to termination in a similar way as in the level mapping based approach. On the more practical level, as illustrated in the two examples above, neither of the approaches is strictly better: the general orderings provide a larger set of orderings to select from (in particular, note that orderings based on level mappings and norms are general orderings), the level mapping approach provides arithmetic, on top of mere ordering. In the remainder of this paper, we will start o from a variant of the notion of acceptability with respect to a set, as introduced in [11], obtained by replacing level mappings by orderings. We show how this variant of acceptability remains equivalent to termination under the left-to-right selection rule, for certain goals. Then, we illustrate how this result can be used to prove termination with some examples. We also provide a variant of the acceptability condition, as introduced in [4], and discuss advantages and disadvantages of each approach. Next, we discuss automation of the approach. We elaborate on a demand-driven method to set-up and verify sucient preconditions for termination. In this method, the aim is to derive|in, as much as possible, a constructive way|a well-founded ordering over the set of all atoms and terms of the language underlying the program, that satis es the termination condition. > > 3 2 Preliminaries 2.1 Logic Programs We follow the standard notation for terms and atoms. A query is a nite sequence of atoms. Given an atom A, rel(A) denotes the predicate occurring in A. TermP and AtomP denote, respectively, sets of all terms and atoms that can be constructed from the language underlying P . The extended Herbrand Universe UPE (the extended Herbrand base BPE ) is a quotient set of TermP (AtomP ) modulo the variant relation. We refer to an SLD-tree constructed using the left-to-right selection rule of Prolog, as an LD-tree. We will say that a goal G LD-terminates for a program P , if the LD-tree for (P; G) is nite. The following de nition is borrowed from [2]. De nition 1. Let P be a program and p, q be predicates occurring in it. { We say that p refers to q in P if there is a clause in P that uses p in its head and q in its body. { We say that p depends on q in P and write p w q, if (p; q) is in the transitive, re exive closure of the relation refers to. { We say that p and q are mutually recursive and write p ' q, if p w q and q w p. 2.2 Quasi-orderings and orderings A quasi-ordering over a set S is a re exive and transitive relation  de ned on elements of S . We de ne the associated equivalence relation  as s  t if and only if s  t and t  s, and the associated ordering > as s > t if and only if s  t but not t  s. If neither s  t, nor t  s we write sk>t. Sometimes, in order to distinguish between di erent quasi-orderings and associated relations we also use , ,  and k . An ordered set S is said to be well-founded if there are no in nite descending sequences s1 > s2 > : : : of elements of S . If the set S is clear from the context we will say that the ordering, de ned on it, is well-founded. We'll also say that a quasi-ordering is well-founded if the ordering associated with it, is well-founded. De nition 2. Let  be a quasi-ordering on a set T . A quasi-ordering  de ned on a set S  T is called a proper extension of  if { t1  t2 implies t1  t2 for all t1; t2 2 T . { t1 > t2 implies t1  t2 for all t1; t2 2 T . The study of termination of term-rewriting systems caused intensive study of orderings on terms. A number of useful properties were established. De nition 3. Let > be an ordering on UPE [ BPE . 4 { { > is called monotonic if s1 > s2 implies f (t1 ; s1 ; t2 ) > f (t1 ; s2 ; t2 ) and p(t1 ; s1 ; t2 ) > p(t1 ; s2 ; t2 ) for any terms s1 and s2 , sequences of terms t1 and t2 , function symbol f and predicate p. > is said to have the subterm property if f (t1 ; s; t2 ) > s holds for any term f (t1 ; s; t2 ). We extend the de nition above to quasi-orderings. De nition 4. Let be a quasi-ordering on terms. { is called monotonic if s1 s2 implies f (t1 ; s1 ; t2 ) f (t1 ; s2 ; t2 ) and p(t1 ; s1 ; t2 ) p(t1 ; s2 ; t2 )   for any terms s1 and s2 , sequences of terms t1 and t2 , function symbol f and predicate p and the associated ordering is monotonic. { is said to have the subterm property if the associated ordering has the subterm property. The following are examples of orderings: > on the set of numbers, lexicographic ordering on the set of strings (this is the way the entries are ordered in dictionaries), multiset ordering and recursive path ordering [14]. The following are examples of quasi-orderings: on the set of numbers, on the power set of some set. For our purposes monotonicity and subterm properties are too restrictive. Thus, we assign to each predicate or functor a subset of argument positions, such that for the argument positions in this subset the speci ed properties hold. We will say that a predicate p (a functor f ) is monotone (has a subterm property) on a speci ed subset of argument positions. The formal study of these weaker notions may be found in [27]. Example 3. Let f be a functor of arity two, and a, b two terms, such that a > b. Let f be monotone in the rst argument position. Then, f (a; c) > f (b; c) holds for any term c, but there might be some term c, such that f (c; a) > f (c; b).           6 3 Order-acceptability with respect to a set In this section we present and discuss some of the theory we developed to extend acceptability to general orderings. In the literature, there are di erent variants of acceptability. The most well-known of these is the acceptability as introduced by Apt and Pedreschi [4]. This version is de ned and veri ed on the level of ground instances of clauses, but draws its practical power mostly from the fact that termination is proved for any bounded goal. Here, boundedness is a notion related to the selected level mapping and requires that the set G  is a grounding substitution for goal G is bounded in the natural numbers, where : BP denotes the level mapping. Another notion of acceptability is the \acceptability with respect to a set of goals", introduced in [11]. This notion allows to prove termination with respect fj j j g j j ! N 5 to any set of goals of interest. However, it relies on procedural concepts, such as calls and computed answer substitution. It was designed to be veri ed through global analysis, for instance through abstract interpretation. A variant of acceptability with respect to a set that avoids the drawbacks of using procedural notions and that can be veri ed on a local level was designed in [13]. This variant required that the goals of interest are rigid under the given level mapping. Here, rigidity means that G = G , for any substitution , where : BPE now denotes a generalised level mapping, de ned on the extended Herbrand base. Comparing the notions of boundedness and rigidity in the context of a level mapping based approach, it is clear that boundedness is more general than rigidity. If the level mapping of a goal is invariant under substitution, then the level mapping is bounded on the set of instances of the goal, but not conversely. Given the latter observation and given that acceptability of [4] is a more generally known and accepted notion, we started our work by generalising this variant. However, it turned out that generalising the concept of boundedness to general orderings proved to be very dicult. We postpone the discussion on this issue until after we formulated the results, but because of these complications, we only arrived at generalised acceptability conditions that are useful in the context of well-moded and simply moded programs and goals. Because of this, we then turned our attention to acceptability with respect to a set. Here, the generalisation of rigidity was less complicated, so that in the end we obtained the strongest results for this variant of acceptability. Therefore, we rst present order-acceptability with respect to a set of goals. We need the following notion. De nition 5. [12] Let P be a de nite program and S be a set of atomic queries. The call set, Call(P; S ), is the set of all atoms A, such that a variant of A is a selected atom in some derivation for P Q , for some Q S and under the left-to-right selection rule. To illustrate this de nition recall the following example [2, 13]. Example 4. permute([]; []): permute(L; [El T ]) delete(El; L; L1); permute(L1; T ): delete(X; [X T ]; T ): delete(X; [H T ]; [H T 1]) delete(X; T; T 1): Let S be permute(t1 ; t2 ) t1 is a nil-terminated list and t2 is a free variable . Then, Call(P; S ) = S delete(t1 ; t2 ; t3 ) t1 ; t3 are free variables and t2 is a nil-terminated list : Such information about S could for instance be expressed in terms of the rigid types of Janssens and Bruynooghe [21] and Call(P; S ) could be computed using the type inference of [21]. 2 j j  j j j j ! N [f g 2 j j j f [ f j j g j g 6 The following de nition generalises the notion of acceptability with respect to a set [12] in two ways: 1) it generalises it to general quasi-orderings, 2) it generalises it to mutual recursion, using the standard notion of mutual recursion [2]. De nition 6. Let S be a set of atomic queries and P a de nite program. P is order-acceptable with respect to S if there exists a well-founded quasi-ordering , such that { for any A 2 Call(P; S ) { for any clause A0 B1 ; : : : ; Bn in P , such that mgu(A; A0 ) =  exists, { for any atom Bi , such that rel(Bi ) ' rel(A) { for any computed answer substitution  for (B1 ; : : : ; Bi 1): A > Bi : The following establishes the connection between order-acceptability with respect to a set S and LD-termination for queries in S . Theorem 1. Let P be a program. P is order-acceptable with respect to a set of atomic queries S if and only if P is LD-terminating for all queries in S . Proof. For all proofs we refer to [27]. We postpone applying the Theorem 1 to Example 4 until a more syntactic way of verifying order-acceptability with respect to a set is developed. To do this, we extend the sucient condition of [13], that imposes the additional requirement of rigidity of the level mapping on the call set, to the case of general quasi-orderings. First we adapt the notion of rigidity to general orderings. De nition 7. (see also [8]) The term or atom A 2 UPE [ BPE is called rigid with respect to a quasi-ordering  if for any substitution , A  A. In this case  is said to be rigid on A. The notion of the rigidity on a term (an atom) is naturally extended to the notion of rigidity on a set of atoms (terms). In particular, we will be interested in quasi-orderings that are rigid on Call(P; S ) for some P and S . We also need interargument relations based on general orderings. De nition 8. Let P be a de nite program, p a predicate in P with arity n. An interargument relation is a relation Rp  fp(t1 ; : : : ; tn ) j ti 2 TermP g. Rp is a valid interargument relation for p if and only if for every p(t1 ; : : : ; tn ) 2 AtomP : if P j= p(t1 ; : : : ; tn ) then p(t1 ; : : : ; tn ) 2 Rp . Usually, the interargument relation will be de ned based on a quasi-ordering used for proving termination. However, in general, this need not be the case. Example 5. Consider the following program. p(0; []): p(f (X ); [X jT ]) p(X; T ): 7 The following interargument relations can be considered for p: p(t1; t2 ) t2 , valid if is a quasi-ordering imposed by a list-length norm, l . Recall, that for lists [t1 t2 ] l = 1 + t2 l , while the list-length of other terms is considered to be 0. On the other hand, p(t1; t2 ) t1 > t2 t1 t2 is valid, if is a quasi-ordering imposed by a term-size norm. Using general (non-norm based) quasi-orderings, p(t1; t2 ) t1 > t2 is valid, for example, for the recursive path ordering [14] with the following ordering on functors: f =1 :=2, where :=2 is a function symbol de ning lists, and 0 []. Alternatively, p(t1 ; t2 ) t2 > t1 is valid, for example, for the recursive path ordering with the following ordering on functors: :=2 f =1 and [] 0. 2 f t2 > t1 _ t1  g j  k  k k j k k k f j _  g  f j g   f j g   Using the notion of rigidity we state a sucient condition for order-acceptability with respect to a set. Theorem 2. (rigid order-acceptability with respect to S ) Let S be a set of atomic queries and P be a de nite program. Let  be a quasi-ordering on UPE and for each predicate p in P , let Rp be a valid interargument relation for p. If there exists a well-founded proper extension  of  to UPE [ BPE , which is rigid on Call(P; S ) such that { for any clause H B1 ; : : : ; Bn 2 P , and { for any atom Bi in its body, such that rel(Bi ) ' rel(H ), { for any substitution , such that the arguments of the atoms in (B1 ; : : : ; Bi 1 ) all satisfy their associated interargument relations Rrel(B1 ) ; : : : ; Rrel(B 1 ) i H  Bi  then P is order-acceptable with respect to S . The stated condition is sucient for order-acceptability, but is not necessary for it. Indeed, consider the following example: Example 6. p(X ) q (a; b): q (X; Y ); p(Y ): Query p(X ) terminates with respect to this program. Thus, Theorem 1 implies the program is order-acceptable with respect to p(X ) . However, the conditions of Theorem 2 do not hold. If is a quasi-ordering that satis es these conditions, then p(a) p(b) is implied by rigidity and p(a) > p(b) is implied by the decrease, contradicting the de nition of >. We continue the analysis of Example 4 and show how Theorem 2 is used. Example 7. Let be a well-founded quasi-ordering on UPE BPE , such that: { for all terms t1; t21 and t22 : permute(t1 ; t21 ) permute(t1; t22 ). f g    [  8 for all terms t11 ; t12 ; t2 ; t31 ; t32 : delete(t11 ; t2 ; t31 )  delete(t12 ; t2 ; t32 ). for all terms t11 ; t12 and t2 : [t11 jt2 ]  [t12 jt2 ]. That is, we impose that the quasi-ordering is invariant on predicate argument positions and functor argument positions that may occur with a free variable in Call(P; S ). Furthermore, we impose that  has the subterm and monotonicity properties at all remaining predicate or functor argument positions. First we investigate the rigidity of  on Call(P; S ), namely: G  G for any G 2 Call(P; S ) and any . Now any e ect that the application of  to G may have on G needs to be through the occurrence of some variable in G. However, because we imposed that  is invariant on all predicate and functor argument positions that may possibly contain a variable in some call, G  G. Associate with delete the interargument relation Rdelete = fdelete(t1 ; t2 ; t3 ) j t2  t3 g. First, we verify that this interargument relationship is valid. Note, that an interargument relationship is valid whenever it is a model for its predicate. Thus, to check whether Rdelete is valid, TP (Rdelete )  Rdelete is checked. For the non-recursive clause of delete the inclusion follows from the subset property of , while for the recursive one, from the monotonicity of it. Then, consider the recursive clauses of the program. { permute. If delete(El; L; L1) satis es Rdelete , then L  L1. By the monotonicity, permute(L; T )  permute(L1; T ). By the property stated above, permute(L; [EljT ])  permute(L; T ). Thus, the desired decrease permute(L; [EljT ])  permute(L1; T ) holds. { delete. By the properties of  stated above: delete(X; [H jT ]; [H jT 1])  delete(X; T; [H jT 1]) and delete(X; T; [H jT 1])  delete(X; T; T 1). Thus, delete(X; [H jT ]; [H jT 1])  delete(X; T; T 1). We have shown that all the conditions of Theorem 2 are satis ed, and thus, P is order-acceptable with respect to S . By Theorem 1, P terminates for all queries in S . Observe, that we do not need to construct the actual ordering, but only to prove that there is one, that meets all the requirements posed. In this speci c case, the requirement of subterm and monotonicity on the remaining argument positions is satis able. 2 { { 4 The results for acceptability with respect to a model In this section we brie y discuss some of the results we obtained in generalising the acceptability notion of [4, 17]. Since these results are weaker than those presented in the previous section, we do not elaborate on them in full detail. For a predicate p with arity n, a mode is an atom p(m1 ; : : : ; mn ), where mi 2 fin; outg for 1  i  n. Positions with in are called input positions, and positions with out are called output positions of p. We assume that a xed mode is associated with each predicate in a program. To simplify the notation, an atom written as p(s; t) means: s is the vector of terms lling the input positions, and 9 t is the vector of terms lling the output positions. Furthermore, by Var(s) we denote the set of variables occuring in vector of terms s [2]. Below, we assume that modes for the program and goal are given. For any atom A and a mode mA for A, we denote by Ainp the atom obtained from A by removing all output arguments. E.g., let A = p(f (2); 3; X ) and mA = p(in; in; out), then Ainp = p(f (2); 3). De nition 9. Let  be a quasi-ordering relation on BPE . We say that  is output-independent if for any two moded atoms A and B : Ainp = B inp implies A  B . The rst class of the programs we consider, are well-moded programs. De nition 10. [2] 1. A query p1 (s1; t1 ); : : : ; pn (sn ; tn ) is called well-moded if for i 2 [1; n] Var(si)  2. A clause p0 (t0 ; sn+1) i 2 [1; n + 1] [ Var(tj): i 1 j=1 p1 (s1; t1 ); : : : ; pn (sn ; tn ) is called well-moded if for Var(si)  [ Var(tj): i 1 j =0 3. A program is called well-moded if every clause of it is. For well-moded programs, order-acceptability in the style of [4] can now be de ned as follows. De nition 11. Let P be a well-moded program,  an output-independent wellfounded quasi-ordering and I a model for P . The program P is called orderacceptable with respect to  and I if for all A B1 ; : : : ; Bn in P and all substitutions , such that (A)inp and B1 ; : : : ; Bi 1  are ground and I j= B1  ^ : : : ^ Bi 1  holds: A > Bi . P is called order-acceptable if it is order-acceptable with respect to some output-independent well-founded quasi-ordering and some model. Note the similarity and the di erence with the notion of well-acceptability introduced by Etalle, Bossi and Cocco [17]|both notions relay on \ignoring" the output positions. However, the approach suggested in [17] measures atoms by level-mappings, while our approach is based on general orderings. In addition [17] requires a decrease only between atoms of mutually recursive predicates. Similarly, one might use the notion of order-acceptability that requires a decrease only between atoms of mutually recursive predicates. This de nition will be equivalent to the one we used, since for atoms of non-mutually recursive predicates the dependency relation, =, can always be used to de ne an ordering. Since every level mapping 10 naturally gives rise to the ordering on atoms, that is A1  A2 if j A1 j > j A2 j, we conclude that every well-acceptable program is order-acceptable. The following theorem states that order-acceptability of a well-moded program is sucient for termination of well-moded goals with respect to this program. Etalle, Bossi and Cocco [17] call such a program well-terminating. Theorem 3. Let P be a well-moded program, that is order-acceptable with respect to an output-independent well-founded quasi-ordering  and a model I . Let G be a well-moded goal, then G LD-terminates. Note that if the requirement of well-modedness of the program P is dropped then the theorem no longer holds. Example 8. p(a) q(X ): q(f (X )) q(X ): We assume the modes p(in) and q(in) to be given. This program is not wellmoded with respect to the given modes, because p(a) calls q=1 with a free vari- able, but it satis es the remaining conditions of order-acceptability with respect to the following quasi-ordering  on terms p(a) > q(t) and q(f (t)) > q(t) for any term t and t  s only if t and s are syntactically identical, and the following model I = fp(a); q(a); q(f (a)); q(f (f (a))); : : :g. However, note that the well-moded goal p(a) is non-terminating. 2 Unfortunately, well-modedness is not sucient to make the converse to hold. That is, there is a well-moded program P and a well-moded goal G, such that G is LD-terminating with respect to P , but P is not order-acceptable. Example 9. Consider the following program p(f (X )) p(g(X )): with the mode p(out). This program is well-moded, the well-moded goal p(X ) terminates with respect to this program, but it is not order-acceptable, since the required decrease p(f (X )) > p(g(X )) violates output-independence of . 2 Intuitively, the problem in the example occured, because some information has been passed via the output positions, i.e, P is not simply moded. De nition 12. [3] 1. A query p1 (s1; t1 ); : : : ; p (sn ; tn ) is called simply moded if t1 ; : : : ; tn is a linear family of variables and for i 2 [1; n] n [ n Var(si) \ ( Var(tj )) = ;: j =i 11 2. A clause p0 (s0 ; t0) p1 (s1 ; t1); : : : ; pn (sn ; tn ) is called simply moded if p1 (s1 ; t1 ); : : : ; pn(sn ; tn ) is simply moded and Var(s0) \ ( [n Var( j)) = ;: j =1 t 3. A program is called simply moded if every clause of it is. Indeed, if P is simply moded the second direction of the theorem holds as well. This was already observed in [17] in the context of well-acceptability and well-termination. The following is an immediate corollary to Theorem 5.1 in [17]. As that theorem states for well-moded simply moded programs, welltermination implies well-acceptability. Therefore, well-terminating programs are order-acceptable. Corollary 1. Let P be a well-moded simply moded program, LD-terminating for any well-moded goal. Then there exists a model I and an output-independent well-founded quasi-ordering , such that P is order-acceptable with respect to I and . To conclude, we brie y discuss why it is dicult to extend the notions of order-acceptability to the non well-moded case, using a notion of boundedness, as it was done for standard acceptability [4]. In acceptability based on level mappings, boundedness ensures that the level mapping of a (non-ground) goal can only increase up to some nite bound when the goal becomes more instantiated. Observe that every ground goal is trivially bounded. The most naive approach to generalisation of boundedness is replacing comparisons of level mappings with orderings, that is de ning an atom A to be bounded with respect to an ordering >, if there exists an atom C such that for all ground instances A of A, C > A. Unfortunately, this de nition is too week to impose termination. Example 10. q p(X ): p(f (X )) p(X ): p(a): Goal p(X ) is bounded with respect to the quasi-ordering such that q > : : : > p(f (f (a))) > p(f (a)) > p(a). Similarly, the decrease requirement between the head and the subgoals is satis ed, however the goal does not terminate. Intuitively, the problem in this example occured due to the fact that in nitely many di erent atoms are smaller than the boundary. One can try to x this problem by rede ning boundedness as: An atom A is bounded with respect to an ordering >, if there exists an atom C such that for all ground instances A of A: A < C , and fB 2 BPE j B < C g is nite. 12 Such a de nition imposes constraints which are very similar to the ones imposed by standard boundedness in the context of level mappings. However, one thing we loose is that it is no longer a generalisation of groundness. Consider an atom p(a) and assume that our language contains a functor f =1 and a constant b. Then one particular well-founded ordering is p(a) > : : : > p(f (f (b))) > p(f (b)) > p(b): So, p(a) is not bounded with respect to this ordering. Because of such complications, we felt that the rigidity-based results of the previous section are the preferred generalisations to general orderings. 5 A methodology for verifying order-acceptability In this section we present an approach leading towards automatic veri cation of the order-acceptability condition. The basic idea for the approach is inspired on the \constraint based" termination analysis proposed in [13]. We start o from the conditions imposed by order-acceptability, and systematically reduce these conditions to more explicit constraints on the objects of our search: the quasi-ordering  and the interargument relations, Rp , or model I . The approach presented below has been applied successfully to a number of examples that appear in the literature on termination, such as di erent versions of permute [6, 22, 13], dis-con [10], transitive closure [22], add-mult [25], combine, reverse, odd-even, at least double and normalisation [13], quicksort program [29, 2], derivative [16], distributive law [15], boolean ring [20], aiakl, bid [9], credit evaluation expert system [29], atten [5], vanilla meta-interpreter solve [29] together with wide class of interpreted programs. In the remainder of the paper, we explain the approach using some of these examples. We start by showing how the analysis of Example 4, presented before, can be performed systematically. We stress the main steps of a methodology. Example 11.  should be rigid on Call(P; S ). To enforce the rigidity,  should ignore all argument positions in atoms in Call(P; S ) that might be occupied by free variables, i.e., the second argument position of permute and the rst and the third argument positions of delete. Moreover, since the rst argument of permute and the second argument of delete are general nil-terminated lists, the rst argument of :=2 should be ignored as well. The decreases with respect to > imposed in the order-acceptability with respect to a set S are: delete(X; [H jT ]; [H jT 1]) > delete(X; T; T 1) delete(El; L; L1) satis es Rdelete implies permute(L; [EljT ]) > permute(L1 ; T ) 13 To express the rigidity constraints, we simplify each of these conditions by replacing the predicate argument positions that should be ignored by some arbitrary term|one of v1 ; v2 ; : : :. The following conditions are obtained: delete(v1 ; [H jT ]; v2) > delete(v3 ; T ; v4 ) delete(El; L; L1) satis es Rdelete implies permute(L; v1 ) > permute(L1 ; v2 ) (1) (2) Observe that this replacement only partially deals with the requirements that the rigidity conditions expressed above impose: rigidity on functor arguments (the rst argument of :=2 should be invariant with respect to the ordering) is not expressed. We keep track of such constraints implicitly, and only verify them at a later stage when additional constraints on the ordering are derived. For each of the conditions (1) and (2), we have two options on how to enforce it: Option 1): The decrease required in the condition can be achieved by imposing some property on , which is consistent with the constraints that were already imposed on  before. In our example, condition (1) is satis ed by imposing the subterm property for the second argument of :=2 and monotonicity on the second argument of delete. The second argument of :=2 does not belong to a set of functor argument positions that should be ignored. Then, [t1 jt2 ] > t2 holds for any terms t1 and t2 , and by the monotonicity of > in the second argument of delete (1) holds. In general we can select from a bunch of ordering properties, or even speci c orderings, that were proposed in the literature. Option 2): The required decrease is imposed as a constraint on the interargument relation(s) R of the preceding atoms. In the permute example, the decrease permute(L; t) > permute(L1 ; t) cannot directly be achieved by imposing some constraint on >. Thus, we impose that the underlying decrease L > L1  should hold for the intermediate body atoms (delete(El; L; L1)) that satisfy the interargument relation Rdelete . Thus, in the example, the constraint is that Rdelete should be such that for all delete(t1 ; t2 ; t3 ) that satisfy Rdelete : t2 > t3 . As we have observed, the interargument relation is valid if it forms a model for its predicate. Thus, one way to constructively verify that a valid interargument relation Rdelete exists, such that the property t2 > t3 holds for delete(t1 ; t2 ; t3 ) atoms is to simply impose that M = fdelete(t1 ; t2 ; t3 ) j t2 > t3 g itself is a model for the delete clauses in the program. So our new constraint on Rdelete is that it should include M . Practically we can enforce this by imposing that TP (M )  M should hold. As shown in [27], this reduces to the constraints \[t1jt2 ] > t2 " and \t2 > t3 implies [tjt2 ] > [tjt3 ]". These are again fed into our Option 1) step, imposing a monotonicity property on the second argument of :=2 for > . At this point the proof is complete. 2 Recall that we do not need to construct actually the ordering, but only to prove that there is one, that meets all the requirements posed. 14 6 Further examples Although the simplicity of the permute example makes it a good choice to clarify our approach it does not well motivate the need for general orderings instead of level mappings. Indeed, it is well-known that permute can be dealt with using standard acceptability or acceptability with respect to a set [10]. In this section we provide a number of additional examples. Most of them (distributive law, derivative and solve) illustrate the added power of moving to general orderings. After these we present an alternative version of permute in order to discuss an extension of our approach that deals with interargument relations for conjunctions of (body-) atoms. Before presenting the examples we recall once more the main steps of our approach. First, given a program and a set of goals, compute the set of calls Call( ). Janssens and Bruynooghe [21] show how this can be done through abstract interpretation. Second, enforce the rigidity of on Call( ), i.e., ignore all predicate or functor argument positions that might be occupied by free variables in Call( ). Given the set of calls, this step can be performed in a completely automatic way. Third, repeatedly construct decreases with respect to , such that the rigid order-acceptability condition will hold and check if those can be veri ed by some of the prede ned orderings. While performing this verication step the trade-o between eciency and power should be considered| using more complex orderings may allow correct reasoning on more examples but might be computationally expensive. First, we consider the distributive law program. This example originated from [15]. Example 12. dist( ) dist(   ) dist( + + ) dist( ) dist( ) dist(  ( + ) ) dist(  +  ) dist(( + )  ) dist(  +  ) P S P; S > P; S P; S > x; x : x x; x X Y; U X Y X Y x : V X; U ; Y; V Z ;T X Y X Z; T X Z Y : Z; T : Z; T : Similarly to the repeated derivation example in the introduction, no linear norm is sucient for proving termination. The simplest norm, we succeeded to nd, providing a termination proof is the following one: k  k = k k  k k, k + k = k k + k k +1, k k = 2 and the level mapping is jdist( )j = k k. This norm cannot be generated automatically by termination analysers we are aware of. In order to prove termination of a set of queries fdist( 1 2 ) j 1 is an expression in a variable and 2 is a free variableg we use the rigid-acceptability condition. First the quasi-ordering, , we are going to de ne should be rigid on a set of calls, i.e., it should ignore the second X X Y X t ;t Y x Y X X; Y t x 15 t Y X argument position of dist. Thus, in the decreases with respect to > to follow we replace the second argument of dist with anonymous terms v1 ; v2 ; : : :. dist((X + Y ); v1 ) > dist(X; v2 ) dist(X; U ) satis es Rdist implies dist((X + Y ); v1 ) > dist(Y ; v2 ) dist((X  (Y + Z )); v1 ) > dist((X  Y + X  Z ); v2 ) dist(((X + Y )  Z ); v1 ) > dist((X  Z + Y  Z ); v2 ) The rst two decreases are satis ed by any ordering having a subterm property for both arguments of +=2 and being monotonic with respect to the rst argument position of dist. However, in order to satisfy the later two we need to use the recursive path ordering (rpo) [14], with  preceding + with respect to an ordering on functors. If this ordering is used, the following holds for any t1 ; t2 and t3 : t2 + t3 > t2 t1  (t2 + t3 ) > t1  t2 t2 + t3 > t3 t1  (t2 + t3 ) > t1  t3 t1  (t2 + t3 ) > t1  t2 + t1  t3 (using the properties of rpo) This proves the third decrease with respect to >. The fourth one is proved analogously. 2 Now we can return to the motivating Example 1, on computing higher derivatives of polynomial functions in one variable. Example 13. d(der(u); 1): d(der(A); 0) number(A): d(der(X + Y ); DX + DY ) d(der(X ); DX ); d(der(Y ); DY ): d(der(X  Y ); X  DY + Y  DX ) d(der(X ); DX ); d(der(Y ); DY ): d(der(der(X )); DDX ) d(der(X ); DX ); d(der(DX ); DDX ): We are interested in proving termination of the queries that belong to the set S = fd(t1 ; t2 ) j t1 is a repeated derivative of a function in a variable u and t2 is a free variableg. So S consists of atoms of the form d(der(u); X ) or d(der(u  u + u); Y ) or d(der(der(u + u)); Z ), etc. Observe, that Call(P; S ) coincides with S. We start by analysing the requirements that imposes the rigidity of  on Call(P; S ). First, the second argument position of d should be ignored, since it 16 might be occupied by a free variable. Second, the rst argument position of d is occupied by a ground term. Thus, rigidity does not pose any restrictions on functors argument positions. Then, we construct the decreases with respect to > that follow from the rigid order-acceptability. The arguments that should be ignored are replaced by terms v1 ; v2 ; : : :. d(der(X + Y ); v1 ) > d(der(X ); v2 ) d(der(X ); DX ) satis es Rd implies d(der(X + Y ); v1 ) > d(der(Y ); v2 ) d(der(X  Y ); v1 ) > d(der(X ); v2 ) d(der(X ); DX ) satis es Rd implies d(der(X  Y ); v1 ) > d(der(Y ); v2 ) d(der(der(X )); v1 ) > d(der(X ); v2 ) d(der(X ); DX ) satis es Rd implies d(der(der(X )); v1 ) > d(der(DX ); v2 ) (3) (4) (5) (6) (7) (8) Conditions (3)-(7) impose monotonicity and subset properties to hold on the rst argument of d. In order to satisfy condition (8), it is sucient to prove that for any (t1 ; t2 ) 2 Rd holds that t1 > t2 . That is if M = fd(t1 ; t2 ) j t1 > t2 g then TP (M )  M . This may be reduced to the following conditions: der(t) > 1 (9) t1 2 Rnumber implies der(t1 ) > 0 (10) der(t1 ) > t2 & der(t3 ) > t4 implies der(t1 + t3 ) > t2 + t4 (11) der(t1 ) > t2 & der(t3 ) > t4 implies der(t1  t3 ) > t1  t4 + t2  t3 (12) der(t1 ) > t2 & der(t2 ) > t3 implies der(der(t1 )) > t3 (13) Condition (13) follows from monotonicity and transitivity of >. However, (10)(12) are not satis ed by general properties of > and we need to specify the ordering. The ordering that meets these conditions is the recursive path ordering [14] with der having the highest priority. 2 As a next example we demonstrate that the suggested technique is useful for proving termination of meta-interpreters as well. Example 14. solve(true): solve((A; B )) solve(A); solve(B ): solve(A) clause(A; B ); solve(B ): Even though the termination of an interpreted program might be easily proved with level-mappings, the termination proof of the meta-interpreter with respect to it cannot be immediately constructed based on the termination proof of the interpreted program. 17 Indeed, let P be the interpreted program: p([X; Y jT ]) p([Y jT ]); p(T ): Termination of the set of queries p(t) t is a list of a nite length can be easily proved, for example by a using level mapping p(X ) = X and the listlength norm . However, when this program is considered together with this meta-interpreter these level-mapping and norm cannot be extended in a way allowing to prove termination, even though there exist a linear level-mapping and a linear norm that provide a termination proof. In the case of this example, the following linear level mapping is sucient for proving termination: f j g j j k kl k  kl solve(A)j = kAk k(A; B )k = 1 + kAk + kB k kp(X )k = 1 + kX k k[H jT ]k = 1 + 3kT k j The constraint-based approach of [13] is able to derive this level mapping. However, it cannot reuse any information from a termination proof of the interpreted program to do so, and the constraints set up for such examples are fairly complex (n body atoms are interpreted as a ; =2-term of depth n and reasoning on them requires products of (at least) n parameters). Most other approaches based on level mappings work on basis of xed norms, like list-length and termsize, and therefore fail to prove termination of the example. Applying general orderings allows to de ne a new ordering for the metainterpreter together with the interpreted program based on the ordering obtained for the interpreted program itself. More formally, given a quasi-ordering , de ned for the interpreted program above, de ne a quasi-ordering on terms and atoms of the meta-interpreter, as follows (similarly to rpo [14]): { t s if one of the following holds:    t s t = (t1 ; t2 ); s = (s1 ; s2 ) and t1 s1 , t2 s2 t = solve(t1 ); s = solve(s1 ) and t1 s1 t s if one of the following holds: t>s t = f (: : :); s = (s1 ; s2 ), f di ers from ; =2; solve=1, t s1 and t s2 t = (t1 ; t2 ) and either t1 s or t2 s. t = solve(t1 ); s = solve(s1 ) and t1 s1 . t = solve(t1 ); s = clause(s1 ; s2 )    {                In our case is a list-length norm based ordering, and is de ned as speci ed. Then, p([X; Y T ]) (p([Y T ]); p(T )). This provides the -decrease for the second recursive clause of the meta-interpreter required in the rigid orderacceptability condition. Similarly, the decrease for the rst recursive clause is provided by the subterm property that is de ned to have, and thus, proving termination.   j  j   18 By reasoning in a similar way, termination can be proved for the metainterpreter and wide class of interpreted programs: from the small examples, such as append and delete and up to bigger ones, like aiakl, bid [9], credit evaluation expert system [29], or even the distributive law program, presented in Example 12. 2 The previous examples do not illustrate our approach in full generality. In general, we may have clauses of the type p(t1 ; : : : ; tn ) B1 ; B2 ; : : : ; Bi 1 ; q (s1 ; : : : ; sm ); Bi+1 ; : : : ; Bk : where multiple intermediate body-atoms, B1 ; B2 ; : : : ; Bi 1 precede the (mutually) recursive body-atom q(s1 ; : : : ; sm). In such cases the decrease with respect to > between p(t1 ; : : : ; tn ) and q(s1 ; : : : ; sm ) required by the (rigid) orderacceptability imposes a constraint on Rrel(B1 ) ; Rrel(B2 ) ; : : : and Rrel(B 1 ) . However, our previous technique of using TP (M )  M to translate the required decrease to Rrel(B1 ) ; Rrel(B2 ) ; : : : ; Rrel(B 1 ) is not easily generalised. This is because several of the atoms B1 ; B2 ; : : : ; Bi 1 together may be responsible for the decrease and the TP (M )  M technique is not readily generalised to deal with multiple predicates. One way to deal with this is based on early works on termination analysis ([31, 25]). Assume that the underlying decrease imposed by B1 ; B2 ; : : : ; Bi 1  satisfy Rrel(B1 ) ; Rrel(B2 ) ; : : : ; Rrel(B 1 ) implies p(t1 ; : : : ; tn ) > q (s1 ; : : : ; sm ) is of the form u > v, where u and v are subterms of p(t1 ; : : : ; tn ), respectively q (s1 ; : : : ; sm ). We then search for a sequence of terms u; u1 ; u2 ; : : : ; uj ; v , such that for each pair of terms, u and u1 , u1 and u2 , : : :, uj and v, there is a corresponding atom in the sequence B1 ; B2 ; : : : ; Bi 1 that contains both of them. Assume (without real loss of generality) that u and u1 occur in B1 , u1 and u2 occur in B2 , : : :, uj and v occur in Bi 1 . We then select one of these pairs of terms, say ui1 and ui2 in atom Bi3 , and impose the relations: ui1 < ui2 on Rrel(B ) , and 3 ui1  ui2 on Rrel(B ) for all other pairs of terms and corresponding atoms. 3 Now we can again use the TP (M )  M technique to translate such constraints into interargument relations. Note that this approach involves a search problem: if we fail to verify the proposed inequality constraints, we need to backtrack over the choice of: { the pair ui1 and ui2 in Bi3 with a strict inequality, or { the sequence of terms u; u1 ; u2 ; : : : ; uj ; v in B1 ; B2 ; : : : ; Bi 1 . A completely di erent method for dealing with multiple intermediate bodyatoms is based on the use of unfold/fold steps to group atoms. We illustrate this second method with an example. i i i i i 19 Example 15. The following is the version of the permute program that appeared in [22]. perm([]; []): ap1 ([]; L; L): perm(L; [H jT ]) ap1 ([H jL1]; L2; [H jL3]) ap2 (V; [H jU ]; L); ap1 (L1; L2; L3): ap1 (V; U; W ); ap2 ([]; L; L): perm(W; T ): ap2 ([H jL1]; L2; [H jL3]) ap2 (L1; L2; L3): This example is chosen to illustrate applications of Theorem 3 (the wellmoded case). We would like to prove termination of the goals perm(t1 ; t2 ), where t1 is a ground list and t2 a free variable. Assume the modes perm(in; out); ap1 (in; in; out); ap2 (out; out; in). The orderacceptability imposes, among the others, the following decrease with respect to >: I j= ap2 (V; [H jU ]; L) ^ ap1 (V; U; W ) implies perm(L) > perm(W ). Note that the underlying decrease L > W  cannot be achieved by reasoning on ap1 =3 or ap2 =3 alone. An alternative solution to the one described before is to use the unfold/fold technique to provide a de nition for the conjunction of the two intermediate body-atoms. To do this, we start of from a generalised clause, containing the conjunction of atoms both in its head and in its body. In our example we get ap2 (V; [H jU ]; L); ap1 (V; U; W ) ap2 (V; [H jU ]; L); ap1 (V; U; W ): Next, we unfold both body-atoms , using all applicable clauses, for one resolution step. This gives rise to a generalised program P , de ning the conjunction of intermediate body-atoms: 0 ap2 ([]; [H jT ]; [H jT ]); ap1 ([]; T; T ): ap2 ([H 1jT 1]; [H 2jT 2]; [H 1jT 3]); ap1 ([H 1jT 1]; T 2; [H 1jT 4]) ap2 (T 1; [H 2jT 2]; T 3); ap1 (T 1; T 2; T 4): Now, we need to verify that M = fap2 (a1 ; a2 ; a3 ); ap1 (b1 ; b2 ; b3) j a3 > b3g satis es TP (M )  M . Using the 2 clauses, this is reduced to \[t1 jt2 ] > t2 " and \t3 > t4 implies [t5 jt3 ] > [t5 jt4 ]", for any terms t1 ; t2 ; t3 ; t4 and t5 , imposing monotonicity and subterm properties on >. The proof is completed analogously to the permute example. 2 It should be noted that in general unfolding can transform a non-terminating program to a terminating one by replacing in nite branches of the LD-tree with failing ones [7]. Bossi and Cocco [7] also stated conditions on unfolding that impose termination to be preserved. 0 7 Conclusion We have presented a non-transformational approach to termination analysis of logic programs, based on general orderings. The problem of termination was 20 studied by a number of authors (see [10] for the survey). More recent work on this topic can be found among others in [12, 13, 17, 19, 23, 26, 28, 30, 32]. The transformational approach to termination has been studied among others in [1, 5, 18, 22, 24] Our approach gets its power from integrating the traditional notion of acceptability [4] with the wide class of orderings that have been studied in the context of the term-rewriting systems. In theory, such an integration is unnecessary: acceptability (based on level mappings only) is already equivalent to LD-termination. In practice, the required level mappings may sometimes be very complex (such as for Example 1 or Example 12 [15], boolean ring [20] or attening of a binary tree [5]), and automatic systems for proving termination are unable to generate them. In such cases, generating an appropriate ordering, replacing the level mapping, may often be much easier, especially since we can reuse the impressive machinery on orderings developed for term-rewrite systems. In some other cases, such as turn [8], simple level mappings do exist (in the case of turn: a norm counting the number of 0s before the rst occurrence of 1 in the list is sucient), but most systems based on level mappings will not even nd this level mapping, because they only consider mappings based on term-size or list-length norms. Meta-interpreters, as illustrated in Example 14, give the same complication. Again, our approach is able to deal with such cases. Sometimes level mappings and norms provide an advantage over general orderings. This is mostly the case if the termination proof can bene t from arguments based on arithmetical operations on the numerical values provided by the level mapping and norm, as illustrated in Example 2. Note however, that general orderings include orderings based on mappings and norms as a special case. We can allow the latter types of orderings as a special case, resorting to them when other orderings in our workbench fail to produce a proof. If we do resort to them, we may allow arithmetic operations on them. The main reason why we de ned interargument relations in a very general way is exactly to allow all the power of numerical orderings, and arithmetic, to be applicable in our context. Unlike transformational approaches, that establish the termination results for logic programs by the reasoning on termination of term-rewriting systems, we apply the orderings directly to the logic programs, thus, avoiding transformations. This could both be regarded as an advantage and as a drawback of our approach. It may be considered as a drawback, because reasoning on successful instances of intermediate body-atoms introduces an additional complication in our approach, for which there is no counterpart in transformational methods (except for the transformation step itself). On the other hand, we consider it as an advantage, because it is precisely this reasoning on intermediate body atoms that gives more insight in the property of logic program termination (as opposed to term-rewrite system termination). Another advantage over transformational approaches is that most of these are restricted to well-moded programs and goals, while our approach does not have this limitation. So, in a sense our approach provides the best of both worlds: a means to incorporate into `direct' approaches the generality of general orderings. 21 We consider as a future work a full implementation of the approach. Although we already tested very many examples manually, an implementation will allow us to conduct a much more extensive experimentation, comparing the technique also in terms of eciency with other systems. Since we apply a demand-driven approach, systematically reducing required conditions to more simple constraints on the ordering and the model, we expect that the method can lead to very ecient veri cation. 8 Acknowledgements We thank Robert Kowalski for continuously stimulating us to look outside of our ivory tower of research to search for challenges in cross-fertilisation of di erent streams of work. Alexander Serebrenik is supported by GOA: \LP + : a second generation logic programming language". We thank Maurice Bruynooghe for useful suggestions. References 1. G. Aguzzi and U. Modigliani. Proving Termination of Logic Program by Transforming them into Equivalent Term Rewriting Systems. In Proc. of 13th Conference on Foundations of Software Technologies and Theoretical Computer Science (FST& TCS), pages 114{124. Springer Verlag, 1993. LNCS 761. 2. K. R. Apt. From Logic Programming to Prolog. Prentice-Hall Int. Series in Computer Science. Prentice Hall, 1997. 3. K. R. Apt and S. Etalle. On the uni cation free Prolog programs. In A. M. Borzyszkowski and S. Sokolowski, editors, 18th Int. Symp. on Mathematical Foundations of Computer Science, pages 1{19. Springer Verlag, 1993. LNCS 711. 4. K. R. Apt and D. Pedreschi. Studies in Pure Prolog: Termination. In J. W. Lloyd, editor, Proc. Esprit Symp. on Comp. Logic, pages 150{176. Springer Verlag, 1990. 5. T. Arts. Automatically proving termination and innermost normalisation of term rewriting systems. PhD thesis, Universiteit Utrecht, 1997. 6. T. Arts and H. Zantema. Termination of logic programs using semantic uni cation. In M. Proietti, editor, 5th Int. Workshop on Logic Programming Synthesis and Transformation, pages 219{233. Springer Verlag, 1995. LNCS 1048. 7. A. Bossi and N. Cocco. Preserving universal temination through unfold/fold. In G. Levi and M. Rodrguez-Artalejo, editors, Algebraic and Logic Programming, pages 269{286. Springer Verlag, 1994. LNCS 850. 8. A. Bossi, N. Cocco, and M. Fabris. Norms on terms and their use in proving universal termination of a logic program. Theoretical Computer Science, 124(2):297{328, February 1994. 9. F. Bueno, M. J. Garca de la Banda, and M. V. Hermenegildo. E ectiveness of global analysis in strict independence-based automatic parallelization. In M. Bruynooghe, editor, Logic Programming, Proc. of the 1994 Int. Symp., pages 320{336. MIT Press, 1994. 10. D. De Schreye and S. Decorte. Termination of logic programs: The never-ending story. J. Logic Programming, 19/20:199{260, May/July 1994. 22 11. D. De Schreye, K. Verschaetse, and M. Bruynooghe. A framework for analyzing the termination of de nite logic programs with respect to call patterns. In I. Sta , editor, Proc. of the Int. Conf. on Fifth Generation Computer Systems., pages 481{ 488. IOS Press, 1992. 12. S. Decorte and D. De Schreye. Termination analysis: some practical properties of the norm and level mapping space. In J. Ja ar, editor, Proc. of the 1998 Joint Int. Conf. and Symp. on Logic Programming, pages 235{249. MIT Press, June 1998. 13. S. Decorte, D. De Schreye, and H. Vandecasteele. Constraint-based termination analysis of logic programs. ACM Transactions on Programming Languages and Systems (TOPLAS), 21(6):1137{1195, November 1999. 14. N. Dershowitz. Termination. In C. Kirchner, editor, First Int. Conf. on Rewriting Techniques and Applications, pages 180{224. Springer Verlag, 1985. LNCS 202. 15. N. Dershowitz and C. Hoot. Topics in termination. In C. Kirchner, editor, Rewriting Techniques and Applications, 5th Int. Conf., pages 198{212. Springer Verlag, 1993. LNCS 690. 16. N. Dershowitz and Z. Manna. Proving termination with multiset orderings. Communications of the ACM (CACM), 22(8):465{476, August 1979. 17. S. Etalle, A. Bossi, and N. Cocco. Termination of well-moded programs. J. Logic Programming, 38(2):243{257, February 1999. 18. H. Ganzinger and U. Waldmann. Termination proofs of well-moded logic programs via conditional rewrite systems. In M. Rusinowitch and J.-L. Remy, editors, Proc. of CTRS'92, pages 216{222. Springer Verlag, 1993. LNCS 656. 19. S. Hoarau. Inferer et compiler la terminaison des programmes logiques avec contraintes. PhD thesis, Universite de La Reunion, 1999. 20. J. Hsiang. Rewrite method for theorem proving in rst order theory with equality. Journal of Symbolic Computation, 8:133{151, 1987. 21. G. Janssens and M. Bruynooghe. Deriving descriptions of possible values of program variables by means of abstract interpretation. J. Logic Programming, 13(2&3):205{258, July 1992. 22. M. Krishna Rao, D. Kapur, and R. Shyamasundar. Transformational methodology for proving termination of logic programs. J. Logic Programming, 34:1{41, 1998. 23. N. Lindenstrauss and Y. Sagiv. Automatic termination analysis of logic programs. In L. Naish, editor, Proc. of the Fourteenth Int. Conf. on Logic Programming, pages 63{77. MIT Press, July 1997. 24. M. Marchiori. Logic programs as term rewriting systems. In Proc. of the Algebraic Logic Programming ALP'94, pages 223{241. Springer Verlag, 1994. LNCS; volume 850. 25. L. Plumer. Termination Proofs for Logic Programs. LNAI 446. Springer Verlag, 1990. 26. S. Ruggieri. Veri cation and validation of logic programs. PhD thesis, Universita di Pisa, 1999. 27. A. Serebrenik and D. De Schreye. Termination analysis of logic programs using acceptability with general term orders. Technical Report CW 291, Departement Computerwetenschappen, K.U.Leuven, Leuven, Belgium, 2000. Available at http://www.cs.kuleuven.ac.be/publicaties/rapporten/CW2000.html. 28. J.-G. Smaus. Modes and Types in Logic Programming. PhD thesis, University of Kent, 1999. 29. L. Sterling and E. Shapiro. The Art of Prolog. The MIT Press, 1994. 30. C. Taboch. A semantic basis for termination analysis of logic programs. Master's thesis, Ben-Gurion University of the Negev, 1998. 23 31. J. D. Ullman and A. van Gelder. Ecient tests for top-down termination of logical rules. Journal of the Association for Computing Machinery, 35(2):345{373, April 1988. 32. S. Verbaeten. Static veri cation of compositionality and termination for logic programming languages. PhD thesis, Department of Computer Science, K.U.Leuven, Leuven, Belgium, June 2000. v+265+xxvii. 24