## Proving Termination for Logic Programs by the Query-Mapping Pairs Approach (2004)

Venue: | PROGRAM DEVELOPMENT IN COMPUTATIONAL LOGIC |

Citations: | 10 - 0 self |

### BibTeX

@INPROCEEDINGS{Lindenstrauss04provingtermination,

author = {Naomi Lindenstrauss and Yehoshua Sagiv and Alexander Serebrenik},

title = {Proving Termination for Logic Programs by the Query-Mapping Pairs Approach},

booktitle = {PROGRAM DEVELOPMENT IN COMPUTATIONAL LOGIC},

year = {2004},

pages = {453--498},

publisher = {Springer LNCS}

}

### OpenURL

### Abstract

This paper describes a method for proving termination of queries to logic programs based on abstract interpretation. The method uses query-mapping pairs to abstract the relation between calls in the LD-tree associated with the program and query. Any well founded partial order for terms can be used to prove the termination. The ideas of the query-mapping pairs approach have been implemented in SICStus Prolog in a system called TermiLog, which is available on the web. Given a program and query pattern the system either answers that the query terminates or that there may be non-termination. The advantages of the method are its conceptual simplicity and the fact that it does not impose any restrictions on the programs.

### Citations

1857 |
Foundations of Logic Programming
- Lloyd
- 1987
(Show Context)
Citation Context ... are no variables in the query we just want to show that it is a logical consequence of the program). To do so we usually use SLD-resolution to compute answers to the query (for all these notions see =-=[1, 48]-=-).A crucial question in this case is whether the computation terminates. The way the computation proceeds depends on the choice of the atom in the goal on which resolution is performed at each step, ... |

617 |
The Art of Prolog
- Sterling, Shapiro
- 1986
(Show Context)
Citation Context ...at theremay be non-termination because the first append gets the binding append(f, b, f), and indeed a query like sublist([1], [2, 3]) does not terminate. If we switch the subgoals (as it is done in =-=[73]-=-) sublist(X,Y) :- append(X2,X3,Y), append(X1,X,X2). our system shows that the query sublist(b, b) terminates. This example shows how a user who writes a program according to the logic of a problem wit... |

558 | Principles of Artificial Intelligence - Nilsson - 1980 |

316 |
On a problem of formal logic
- Ramsey
- 1930
(Show Context)
Citation Context ...the set of all subsets of M of cardinality n. Theorem 3.2 (Ramsey). Let α be a mapping from N [n] to some finite set A. Then there is an infinite subset M of N such that α is constant on M [n] . (Cf. =-=[62, 39]-=-. For a short self contained proof of this version of the theorem see [10], p. 290.) Theorem 3.3 (Basic Theorem). Suppose the LD-tree for a program and query has an infinite branch. Suppose a substitu... |

287 | Abstract interpretation and application to logic programs
- Cousot, Cousot
- 1979
(Show Context)
Citation Context ...s paper we describe a method for proving termination of queries to logic programs based on abstract interpretation. The results of applying the ideas of abstract interpretation to logic programs (cf. =-=[24]-=-) seem to be especially elegant and useful, because we are dealing in this case with a very simple language which has only one basic construct—the clause. Termination of programs is known to be undeci... |

265 | Orderings for Term Rewriting Systems - Dershowitz - 1982 |

198 |
Geometric Nonlinear Functional Analysis
- Benyamini, Lindenstrauss
- 2000
(Show Context)
Citation Context ... mapping from N [n] to some finite set A. Then there is an infinite subset M of N such that α is constant on M [n] . (Cf. [62, 39]. For a short self contained proof of this version of the theorem see =-=[10]-=-, p. 290.) Theorem 3.3 (Basic Theorem). Suppose the LD-tree for a program and query has an infinite branch. Suppose a substitution-compatible partial mapping φ from terms to a strictly ordered well-fo... |

188 |
From Logic Programming to Prolog
- Apt
- 1997
(Show Context)
Citation Context ... are no variables in the query we just want to show that it is a logical consequence of the program). To do so we usually use SLD-resolution to compute answers to the query (for all these notions see =-=[1, 48]-=-).A crucial question in this case is whether the computation terminates. The way the computation proceeds depends on the choice of the atom in the goal on which resolution is performed at each step, ... |

176 | A.M.: The size-change principle for program termination
- Lee, Jones, et al.
- 2001
(Show Context)
Citation Context ...program is exponential in their arities, and there are cases in which the number of query-mapping pairs relevant to a program and query is large. The following result about complexity is relevant. In =-=[41]-=- size-change graphs are used to prove termination of functional programs. These graphs are the counterpart of our query-mapping pairs in the simpler context of functional programming, where all the pr... |

172 |
Acyclic programs
- Apt, Bezem
- 1990
(Show Context)
Citation Context ...ver, if the query pattern sublist(b, b) is given, our system will say that theremay be non-termination because the first append gets the binding append(f, b, f), and indeed a query like sublist([1], =-=[2, 3]-=-) does not terminate. If we switch the subgoals (as it is done in [73]) sublist(X,Y) :- append(X2,X3,Y), append(X1,X,X2). our system shows that the query sublist(b, b) terminates. This example shows h... |

151 |
The Craft of Prolog
- O’Keefe
- 1990
(Show Context)
Citation Context ...terested in finding a single answer only. The query we solved may be backtracked into and it is crucial that there will be termination also in that case (cf. the section on ’Backwards Correctness’ in =-=[56]-=-). Moreover, Prolog’s built-in predicates findall, setof, bagof depend on computing all answers to the query they include. One of the difficulties when dealing with the LD-tree for a query, given a lo... |

138 | Termination of logic programs: The never-ending story - Schreye, Decorte - 1994 |

126 | Reasoning about termination of pure prolog programs
- Apt, Pedreschi
- 1993
(Show Context)
Citation Context ... complete description of this collection may be found in [53]. Finally (Table 4), we have collected a number of programs from different sources, including Prolog textbooks [1, 73] and research papers =-=[2, 4, 77, 83, 82]-=-. Termination of most of the examples considered, with clearly indicated exceptions such as serialize, was established by using the term-size norm. Note also that there are cases in which we can estab... |

117 | The s-Semantics Approach: Theory and Applications
- Bossi, Gabbrielli, et al.
(Show Context)
Citation Context ... integer. The usual Herbrand base whose atoms are all ground is not useful in this case and we have to extend it. We define a semantics which is similar, although not identical, to the c-semantics of =-=[34, 15]-=-. As extended Herbrand base B we take all atoms that can be built from the constant, function, and predicate symbols of the program P and variables from an infinite set {X1, X2, . . .}. The 6 A comple... |

116 |
Declarative Modeling of the Operational Behavior of Logic Languages
- Falaschi, Levi, et al.
- 1989
(Show Context)
Citation Context ... integer. The usual Herbrand base whose atoms are all ground is not useful in this case and we have to extend it. We define a semantics which is similar, although not identical, to the c-semantics of =-=[34, 15]-=-. As extended Herbrand base B we take all atoms that can be built from the constant, function, and predicate symbols of the program P and variables from an infinite set {X1, X2, . . .}. The 6 A comple... |

99 | A semantic basis for termination analysis of logic programs
- Codish, Taboch
- 1999
(Show Context)
Citation Context ...gram, which is clearly equivalent to the original one, our system easily proves termination of perm(b, f). In [9] argument size relationships are inferred with CLP(R). In TerminWeb’s old version (cf. =-=[23]-=-) ideas similar to our query-mapping pairs method are augmented with the analysis of [9], so termination of the example can be proved. It also can be proved with cTI. cTI is a bottom-up constraint-bas... |

82 |
Andorra-I: A Parallel Prolog System that Transparently Exploits both And- and Or-Parallelism
- Costa, Warren, et al.
- 1991
(Show Context)
Citation Context ...on of benchmarks that were originally used for study of parallelism in logic programming [18, 36, 53, 19]. Benchmarks in this collection go back to Ramkumar and Kalé [61] (occur), Santos-Costa et al. =-=[67]-=- (zebra), Tick [75] (bid) and Warren (palin, qplan, warplan). A complete description of this collection may be found in [53]. Finally (Table 4), we have collected a number of programs from different s... |

73 |
Termination Proofs for Logic Programs
- Plümer
(Show Context)
Citation Context ...which has, for every rule A : − B1, . . . , Bn in the program (remember that a rule is a clause with non-empty body) and every i, 1 ≤ i ≤ n, an arc from the predicate of A to the predicate of Bi (cf. =-=[58]-=-).We can consider the strongly connected components of this graph. We call a strongly connected component trivial if it consists of a single node that has no arc going from itself to itself. It is ea... |

67 |
Efficient tests for top-down termination of logical rules
- ULLMAN, GELDER
- 1988
(Show Context)
Citation Context ...ion also applies, as a special case, to constants (which are zeroarity function symbols). Linear norms generalize earlier norms used in automatic termination analysis. In particular, the list size of =-=[76]-=- and the term size of [78] are special cases of linear norms. Plümer used in his work on termination two restricted cases of linear norms. One corresponds to the case where all the ai are equal to 1 (... |

65 | Automatic termination analysis of logic programs - Lindenstrauss, Sagiv - 1997 |

51 | Strong termination of Logic Programs
- Bezem
- 1991
(Show Context)
Citation Context ...n which resolution is performed at each step, and on the choice of the clause with which it is resolved. Termination irrespective of which atom and clause are chosen is called strong termination (cf. =-=[12]-=-) and means that all SLD-trees constructed for the program and the query are finite. One can consider a weaker notion of termination, where one can choose any clause, but the choice of atom is determi... |

46 |
Characterizing termination of logic programs with level mapping
- Bezem
- 1992
(Show Context)
Citation Context ...respect to the left-to-right selection rule of Prolog. Early works on termination made no assumptions on the selection rule, that is, required termination with respect to all possible selection rules =-=[11, 2, 12]-=-. However, this notion of termination turned out to be very restrictive—the majority of real-world programs turn out to be non-terminating with respect to it. Thus, most of the authors studied termina... |

45 | Inferring Argument Size Relationships with CLP
- Benoy, King
- 1996
(Show Context)
Citation Context ...in the success set, the norms of the two arguments will be equal.) For the transformedprogram, which is clearly equivalent to the original one, our system easily proves termination of perm(b, f). In =-=[9]-=- argument size relationships are inferred with CLP(R). In TerminWeb’s old version (cf. [23]) ideas similar to our query-mapping pairs method are augmented with the analysis of [9], so termination of t... |

44 | Modular termination proofs for logic and pure prolog programs
- Apt, Pedreschi
- 1993
(Show Context)
Citation Context ...the results are reported here. First, classical benchmarks for termination of symbolic computations were studied. Tables 1 and 2 summarise the performance of the system on the programming examples of =-=[5, 30]-=-, and [58]. Next (Table 3), we applied our technique to study termination of benchmarks that were originally used for study of parallelism in logic programming [18, 36, 53, 19]. Benchmarks in this col... |

41 | A general framework for automatic termination analysis of logic programs
- Dershowitz, Lindenstrauss, et al.
(Show Context)
Citation Context ... a finite number of query-mapping pairs associated with it. The finiteness of the set of query-mapping pairs allows us to use the following version of Ramsey’s theorem to prove our basic theorem (cf. =-=[29]-=-). We will use the following notation: if M is a subset of the natural numbers N , we will denote by M [n] the set of all subsets of M of cardinality n. Theorem 3.2 (Ramsey). Let α be a mapping from N... |

41 |
Termination detection in logic programs using argument sizes
- Sohn, Gelder
- 1991
(Show Context)
Citation Context ...e coefficient appears at most once. So 2X + 5Y + 2 is in normalized form, while X + X + 3Y + 2Y + 1 + 1 is not. The idea of associating an integer variable with a logic variable goes back to [78]. In =-=[71]-=- what we call symbolic norm for the case of term-size is called structural term size. Some authors define the norm of a variable to be 0 and then use the norm only for terms that are rigid with respec... |

36 |
Deriving constraints among argument sizes in logic programs
- Gelder
- 1991
(Show Context)
Citation Context ...cial case, to constants (which are zeroarity function symbols). Linear norms generalize earlier norms used in automatic termination analysis. In particular, the list size of [76] and the term size of =-=[78]-=- are special cases of linear norms. Plümer used in his work on termination two restricted cases of linear norms. One corresponds to the case where all the ai are equal to 1 (in [58], it is called a “l... |

35 |
Automatic inference of norms: a missing link in automatic termination analysis
- Decorte, Schreye, et al.
- 1993
(Show Context)
Citation Context ...s the node in the LD-tree that caused this atom to be called as the result of resolution. Node 4 The reader may notice a similarity between this notion and the notion of a rigid norm (cf. for example =-=[25]-=-). The difference is that a norm is defined for all terms. Here the mapping is partial and a crucial part of the requirements for it to be substitutioncompatible is, that it be defined for T θ, for an... |

34 | Constraint-based termination analysis of logic programs
- DECORTE, SCHREYE, et al.
- 1999
(Show Context)
Citation Context ...ination it produces to the user the circular idempotent query-mapping pair that did not satisfy the termination test, thus showing him which predicate he should suspect. The constraint based approach =-=[27]-=- is implemented but not publicly available. It starts with a general level mapping and general linear norm and infers the coefficients. This is efficient when it can be done but may run into trouble w... |

33 | Termination Analysis for Mercury
- Speirs, Somogyi, et al.
- 1997
(Show Context)
Citation Context ...is strongly differs from logic programs, where the same predicate can be used in different modes. The compiler of the Mercury programming language contains a termination checker. This is described in =-=[72]-=- and its times are compared to TermiLog’s times for the benchmarks in our tables. The Mercury termination checker is usually faster than TermiLog, but one must remember that in Mercury the text of the... |

32 | Verification of logic programs with delay declarations
- Apt, Luitjes
- 1995
(Show Context)
Citation Context ...ver, if the query pattern sublist(b, b) is given, our system will say that theremay be non-termination because the first append gets the binding append(f, b, f), and indeed a query like sublist([1], =-=[2, 3]-=-) does not terminate. If we switch the subgoals (as it is done in [73]) sublist(X,Y) :- append(X2,X3,Y), append(X1,X,X2). our system shows that the query sublist(b, b) terminates. This example shows h... |

32 |
Inference of monotonicity constraints in Datalog programs
- Brodsky, Sagiv
- 1989
(Show Context)
Citation Context ...me ground, because the only instantiation pattern in which the first two arguments are ground is append(g, g, g). 4.7 The inference of constraints Inference of monotonicity constraints was treated in =-=[16]-=- and inference of inequality constraints was treated in [17]. Monotonicity constraints have the advantage that once an atom is given, there is only a finite number of possibilities for them, but they ... |

32 |
Deriving termination proofs for logic programs, using abstract procedures
- VERSCHAETSE, SCHREYE
- 1991
(Show Context)
Citation Context ... complete description of this collection may be found in [53]. Finally (Table 4), we have collected a number of programs from different sources, including Prolog textbooks [1, 73] and research papers =-=[2, 4, 77, 83, 82]-=-. Termination of most of the examples considered, with clearly indicated exceptions such as serialize, was established by using the term-size norm. Note also that there are cases in which we can estab... |

31 |
Compiled Execution of the Reduce-OR Process Model on Multiprocessors
- Ramkumar, Kalé
- 1989
(Show Context)
Citation Context ...d our technique to study termination of benchmarks that were originally used for study of parallelism in logic programming [18, 36, 53, 19]. Benchmarks in this collection go back to Ramkumar and Kalé =-=[61]-=- (occur), Santos-Costa et al. [67] (zebra), Tick [75] (bid) and Warren (palin, qplan, warplan). A complete description of this collection may be found in [53]. Finally (Table 4), we have collected a n... |

30 |
Automatically proving termination and innermost normalisation of term rewriting systems
- ARTS
- 1997
(Show Context)
Citation Context ...heorems 3.4 and 3.5 implies termination and can be verified automatically. While considering sufficient conditions for termination found in the literature one can distinguish between transformational =-=[63, 6, 40, 55]-=- and direct approaches [23, 27, 52]. A transformational approach first transforms the logic program into an “equivalent” term-rewrite system (or, in some cases, into an equivalent functional program).... |

28 |
Proving Termination Properties of Prolog Programs: A Semantic Approach
- Baudinet
- 1992
(Show Context)
Citation Context ...weakest notion of termination is existential termination, which means that there either is finite failure or at least one way to choose atoms and clauses, so that there is a succesful derivation (cf. =-=[80, 8, 49]-=-). All these kinds of termination are undecidable (this follows from the fact that the operation of a Turing machine can be described by a logic program, and the halting problem for Turing machines is... |

28 |
Automatic Compile-time Parallelization of Logic Programs for Restricted, Goal-level, Independent And-parallelism
- MUTHUKUMAR, BUENO, et al.
- 1999
(Show Context)
Citation Context ...m on the programming examples of [5, 30], and [58]. Next (Table 3), we applied our technique to study termination of benchmarks that were originally used for study of parallelism in logic programming =-=[18, 36, 53, 19]-=-. Benchmarks in this collection go back to Ramkumar and Kalé [61] (occur), Santos-Costa et al. [67] (zebra), Tick [75] (bid) and Warren (palin, qplan, warplan). A complete description of this collecti... |

27 |
Applying static analysis techniques for inferring termination conditions of logic programs
- Mesnard, Neumerkel
- 2001
(Show Context)
Citation Context ...ng pairs method are augmented with the analysis of [9], so termination of the example can be proved. It also can be proved with cTI. cTI is a bottom-up constraint-based inference tool for Prolog (cf. =-=[51, 50]-=-). This tool is goal independent — it infers sufficient universal left-termination conditions for all the predicates in the given program (the recent implementation of TerminWeb does so too — cf. [37]... |

26 |
Inference of inequality constraints in logic programs
- Brodsky, Sagiv
- 1991
(Show Context)
Citation Context ...he first two arguments are ground is append(g, g, g). 4.7 The inference of constraints Inference of monotonicity constraints was treated in [16] and inference of inequality constraints was treated in =-=[17]-=-. Monotonicity constraints have the advantage that once an atom is given, there is only a finite number of possibilities for them, but they are weak. Inequality constraints, say something like ‖arg1‖ ... |

26 | TermiLog: A system for checking termination of queries to logic programs
- Lindenstrauss, Sagiv, et al.
- 1997
(Show Context)
Citation Context ...t the relation between arguments of calls in the LD-tree associated with the program and query. The method has been implemented in SICStus Prolog ([68]) in a termination analyzer called TermiLog (cf. =-=[46]-=-), which is available on the web ([74]). Given a program and query pattern the analyzer either answers that the query terminates or that there may be non-termination. TermiLog was, as far as we know, ... |

25 | Inferring termination conditions for logic programs using backwards analysis
- GENAIM, CODISH
(Show Context)
Citation Context ... 50]). This tool is goal independent — it infers sufficient universal left-termination conditions for all the predicates in the given program (the recent implementation of TerminWeb does so too — cf. =-=[37]-=-). The new version of cTI, that uses the Parma Polyhedra Library (cf. [7]), is very efficient. However, it cannot prove termination for the program vangelder with query q(b, b) (see Table 4), which Te... |

24 |
Safety of recursive horn clauses with infinite relations
- Ramakrishnan, Bancilhon, et al.
- 1987
(Show Context)
Citation Context ...e algorithm of [66]. The original algorithm of [66] was based on an abstraction of a logic program as a datalog program with relations that could be infinite (this type of abstraction was proposed in =-=[60]-=-). The problem with this type of abstraction is that it loses too much valuable information about the original logic program and, in particular, one has to assume that every variable in the head of a ... |

24 |
Characterization of terminating logic programs
- Vasak, Potter
- 1986
(Show Context)
Citation Context ...weakest notion of termination is existential termination, which means that there either is finite failure or at least one way to choose atoms and clauses, so that there is a succesful derivation (cf. =-=[80, 8, 49]-=-). All these kinds of termination are undecidable (this follows from the fact that the operation of a Turing machine can be described by a logic program, and the halting problem for Turing machines is... |

23 |
A framework for analyzing the termination of definite logic programs with respect to call patterns
- SCHREYE, VERSCHAETSE, et al.
- 1992
(Show Context)
Citation Context ...econd notion of termination mentioned above, namely termination of computing all answers using the leftmost computation rule of Prolog. This notion of termination is also known as LD-termination (cf. =-=[32]-=-). Observe, that finding all answers in finite time is essential, even if one seems to be interested in finding a single answer only. The query we solved may be backtracked into and it is crucial that... |

18 |
A termination test for logic programs
- Sagiv
- 1991
(Show Context)
Citation Context ...ven a logic program, is that infinitely many different atoms may appear as subgoals. The basic idea is to abstract this possibly infinite structure to a finite one. The querymapping pairs method (cf. =-=[66, 44]-=-) uses a certain kind of graphs to abstract the relation between arguments of calls in the LD-tree associated with the program and query. The method has been implemented in SICStus Prolog ([68]) in a ... |

17 | On proving left termination of constraint logic programs
- MESNARD, RUGGIERI
(Show Context)
Citation Context ...ng three important lines: providing necessary and sufficient conditions of termination [27,14], providing sufficient (but not necessary) conditions for termination that can be verified automatically =-=[37, 41, 52]-=- and proving decidability or undecidability results for special classes of programs [13, 33, 64]. Our work is clearly situated in the second group: the condition presented in Theorems 3.4 and 3.5 impl... |

16 | 2000, ‘TALP: A Tool for the Termination Analysis of Logic Programs
- Ohlebusch, Claves, et al.
(Show Context)
Citation Context ...-argument comparisons instead of weighted sums. The following two termination analyzers fall in a slightly different category, as both of them impose requirements on the logic programs handled. TALP (=-=[55]-=-) is a publicly available tool that proves termination of logic programs by transforming them into term-rewriting systems. It requires the program and query to be well-moded. This requirement follows ... |

14 | cTI: a Constraint-Based Termination Inference Tool for ISO-Prolog. Theory and Practice of Logic Programming
- Mesnard, Bagnara
(Show Context)
Citation Context ...ng pairs method are augmented with the analysis of [9], so termination of the example can be proved. It also can be proved with cTI. cTI is a bottom-up constraint-based inference tool for Prolog (cf. =-=[51, 50]-=-). This tool is goal independent — it infers sufficient universal left-termination conditions for all the predicates in the given program (the recent implementation of TerminWeb does so too — cf. [37]... |

14 | Proving termination of input-consuming logic programs
- Smaus
- 1999
(Show Context)
Citation Context ...on rules. The most popular selection rule is left-to-right, as adopted by most of the Prolog implementations. Termination with respect to non-standard selection rules was considered, for instance, in =-=[3, 38, 57, 65, 69, 70]-=-. Roughly, the existing work on termination analysis proceeded along three important lines: providing necessary and sufficient conditions of termination [27,14], providing sufficient (but not necessa... |

14 |
Static termination analysis for definite Horn clause programs
- Verschaetse
- 1992
(Show Context)
Citation Context ...nite branch in the LD-tree corresponding to a program and query then there is an infinite sequence of nodes N1, N2, . . . such that for each i, Ni+1 is an offspring of Ni. Proof. Straightforward (cf. =-=[81]-=-). ⊓⊔ Suppose we have some way to associate basic query-mapping pairs with call branches between nodes that are direct offspring of each other. Suppose that this is done in such a way that if N2 is a ... |