## Quasi-Terminating Logic Programs for Ensuring the Termination of Partial Evaluation (2007)

### Cached

### Download Links

- [www.dsic.upv.es]
- [www.dsic.upv.es]
- [users.dsic.upv.es]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proc. of the ACM SIGPLAN 2007 Workshop on Partial Evaluation and Program Manipulation (PEPM’07 |

Citations: | 9 - 5 self |

### BibTeX

@INPROCEEDINGS{Vidal07quasi-terminatinglogic,

author = {Germán Vidal},

title = {Quasi-Terminating Logic Programs for Ensuring the Termination of Partial Evaluation},

booktitle = {In Proc. of the ACM SIGPLAN 2007 Workshop on Partial Evaluation and Program Manipulation (PEPM’07},

year = {2007},

pages = {51--60},

publisher = {ACM Press}

}

### OpenURL

### Abstract

Abstract. A logic program strongly quasi-terminates when only a finite number of distinct atoms (modulo variable renaming) are derivable from any given query and computation rule. This notion of quasi-termination, though stronger than related notions that only consider Prolog’s computation rule, is essential for ensuring the termination of partial evaluation, where liberal selection policies are often mandatory to achieve a good specialization. In this paper, we introduce sufficient conditions for the strong termination and quasi-termination of logic programs which are based on the construction of size-change graphs. The class of strongly quasi-terminating logic programs, however, is too restricted. Therefore, we also introduce an annotation procedure that annotates those predicate arguments which are responsible of the non-quasi-termination. As a consequence, the annotated program behaves like a quasi-terminating program if annotated arguments are generalized (i.e., replaced by a fresh variable) when they occur in a computation. We illustrate the usefulness of our approach by designing a simple partial evaluator in which global termination is always ensured offline (i.e., statically). A prototype implementation demonstrates its viability. 1

### Citations

1854 |
Foundations of Logic Programming
- Lloyd
- 1987
(Show Context)
Citation Context ...sses some related work and Sect. 7 concludes and presents some possibilities for future work. 2 Preliminaries We assume some familiarity with the standard definitions and notations for logic programs =-=[31]-=-. In this work, we consider a first-order language with a fixed vocabulary of predicate symbols, function symbols, and variables denoted by Π, Σ and V, respectively. We let T (Σ, V) denote the set of ... |

638 |
Partial evaluation and automatic program generation
- Jones, Gomard, et al.
- 1993
(Show Context)
Citation Context ...designing a simple partial evaluator in which global termination is always ensured offline (i.e., statically). A prototype implementation demonstrates its viability. 1 Introduction Partial evaluation =-=[19]-=- is a well-known technique for program specialization. Basically, given a program, pgm, and a partition of its input data into the so called static (i.e., known) and dynamic (i.e., unknown) data, a pa... |

453 | Termination of rewriting
- Dershowitz
- 1985
(Show Context)
Citation Context ...he computations. The notion of quasi-termination can be traced back to term rewriting, where a system is called quasi-terminating if all its derivations contain only a finite number of distinct terms =-=[12]-=-. In logic programming, quasi-termination has been studied, e.g., in [10, 28, 34, 37, 38], mainly in the context of tabled evaluation; in this context, a logic program quasi-terminates when only finit... |

316 |
On a Problem of Formal Logic
- Ramsey
(Show Context)
Citation Context ...f for every program loop there exists a measure which decreases as execution follows through that loop. The correctness of this approach (and thus the proof of Theorem 1) is based on Ramsey’s Theorem =-=[35]-=-. Proof. We prove the claim by contradiction. Assume that P is not terminating. Then, by [8, Lemma 3.5], 7 we have an infinite chain in the associated calls-to relation for 7 Although Lemma 3.5 in [8]... |

239 |
Partial evaluation in logic programming
- Lloyd, Shepherdson
- 1991
(Show Context)
Citation Context ...ecialized version of pgm for the static data s such that pgm(s, d) = pgms(d) for all values of the missing dynamic data d. In the partial evaluation of logic programs (also known as partial deduction =-=[32]-=-), both the static and the dynamic data are provided in the form of a query, which is usually less instantiated than ordinary run time queries. Roughly speaking, given a logic program P and a query Q,... |

175 | The size-change principle for program termination
- Lee, Jones, et al.
- 2001
(Show Context)
Citation Context ...n of SLD resolution where annotated arguments are generalized so that every computation is still strongly quasi-terminating. We formalize our quasi-termination analysis by means of size-change graphs =-=[22]-=-, which (together with monotonicity constraints [4]) are currently used by an increasing number of termination analyzers for different programming languages. Basically, one should first approximate th... |

145 | Tutorial on specialisation of logic programs
- Gallagher
- 1993
(Show Context)
Citation Context ...troduce a program annotation procedure that guarantees the quasi-termination of a program and, thus, the termination of a partial evaluator. Partial evaluators often follow a simple iterative process =-=[15]-=-. Essentially, in order to specialize a program P w.r.t. the set of atoms S, we construct a finite (generally incomplete) SLD tree for each atom S ∈ S and, then, we add to S all unselected atoms in th... |

114 |
Declarative modeling of the operational behavior of logic languages
- Falaschi, Levi, et al.
- 1989
(Show Context)
Citation Context ... , Bn, n � 0, are atoms (thus we only consider definite programs). A logic program is a finite sequence of clauses. Given a program P , the associated extended (non-ground) Herbrand Universe and Base =-=[13]-=- are denoted by U E P and BE P , respectively. Var(s) denotes the set of variables in the syntactic object s (i.e., s can be either a term, an atom, a query, or a clause). A syntactic object s is grou... |

99 | A semantic basis for termination analysis of logic programs
- Codish, Taboch
- 1999
(Show Context)
Citation Context ...rmination of logic programs is based on the computation of (an approximation of) the binary unfoldings of a program. This approach, however, has only been formalized 2sfor a leftmost computation rule =-=[8]-=- or for a local 1 computation rule [14]. Adapting it for considering strong termination implies redoing almost everything from scratch (and would likely produce a technique closely related to our deve... |

73 |
Termination Proofs for Logic Programs
- Plümer
(Show Context)
Citation Context ...rm rewriting, where a system is called quasi-terminating if all its derivations contain only a finite number of distinct terms [12]. In logic programming, quasi-termination has been studied, e.g., in =-=[10, 28, 34, 37, 38]-=-, mainly in the context of tabled evaluation; in this context, a logic program quasi-terminates when only finitely many different atoms—up to variable renaming—are derivable from any given query. In t... |

72 |
Recursive query processing: The power of logic
- Vieille
- 1989
(Show Context)
Citation Context ...n of computation rule R is used to select an atom within a query for its evaluation. Given a program P , a query Q = 〈A1, . . . , An〉, and a computation 1 Roughly speaking a computation rule is local =-=[39]-=- when it always select in a query one of the “most recently” introduced atoms in the derivation (e.g., the atoms that come from the body of the last clause used in the derivation). 3srule R, we say th... |

65 | Automatic termination analysis of logic programs
- Lindenstrauss, Sagiv
- 1997
(Show Context)
Citation Context ...≻ is a well-founded order on terms where both � and ≻ are closed under substitutions and compatible (i.e., � ◦ ≻ ⊆ ≻ or ≻ ◦ � ⊆ ≻ but � ⊆ ≻ is not necessary). In this work, we consider symbolic norms =-=[29]-=- as a basis for defining appropriate reduction pairs: Definition 5 (symbolic norm [29]). A symbolic norm is a function ||·|| : T (Σ, V) → T (IN ∪ {+}, V) such that ||t|| = � m + � n i=0 ki||ti|| if t ... |

53 | Logic program specialisation through partial deduction: Control issues. Theory and
- Leuschel, Bruynooghe
(Show Context)
Citation Context ... each atom in the leaves of the tree is an instance of a previously selected atom. The finiteness of this SLD tree can be ensured either online or offline. Online partial evaluation techniques (e.g., =-=[25, 27]-=-) use rather expensive tests—like the homeomorphic embedding [24]—for avoiding infinite derivations. In contrast, offline partial ⋆ This work has been partially supported by the EU (FEDER) and the Spa... |

51 | Strong termination of Logic Programs
- Bezem
- 1991
(Show Context)
Citation Context ...l possible computation rules. This is essential because liberal selection policies are often mandatory to achieve a good specialization (see, e.g., [1, 25]). Therefore, we consider strong termination =-=[2]-=-: a program P and query Q strongly terminate if they universally terminate (i.e., the computation of all solutions terminate) w.r.t. all computation rules. This is the strongest notion of termination ... |

42 |
Finiteness analysis
- Holst
- 1991
(Show Context)
Citation Context ...automatic BTA for ensuring the termination of offline partial evaluation yet. Recent progress include [9], which presents a fully automatic BTA but only provides partial termination guarantees. Holst =-=[18]-=- was the first to relate (within the functional programming paradigm) the termination of partial evaluation and the quasi-termination of the computations. The notion of quasi-termination can be traced... |

42 | Efficient specialisation in Prolog using the handwritten compiler generator LOGEN
- Leuschel, Jørgensen
- 1999
(Show Context)
Citation Context ...d by the EU (FEDER) and the Spanish MEC under grants TIN2004-00231 and TIN2005-09207-C03-02, and by the ICT for EU-India Cross-Cultural Dissemination Project ALA/95/23/2003/077-054.sevaluation (e.g., =-=[26]-=-) proceeds in two stages: first, the program is analyzed—using a so called binding-time analysis, BTA—so that an annotated program is returned; program annotations are used to point out which atoms ca... |

41 |
Proving Termination of Logic Programs by Exploiting Term Properties
- BOSSI, COCCO, et al.
- 1991
(Show Context)
Citation Context ...t recall the notion of instantiated enough w.r.t. a symbolic norm. 6 5 See [7] for a generalization of this condition where idempotence is not required. 6 A closely related notion is that of rigidity =-=[3]-=-, where a term t is rigid w.r.t. a norm ||·|| if, for any substitution σ, ||tσ|| = ||t||. 8sDefinition 10 (instantiated enough [29]). A term t is instantiated enough w.r.t. a symbolic norm ||·|| if ||... |

39 | Argument filtering transformation
- Kusakari, Nakamura, et al.
- 1999
(Show Context)
Citation Context ...t is reflexive and transitive. We say that an order ≻ is closed under substitutions (or stable) if s ≻ t implies sσ ≻ tσ for all s, t ∈ T (Σ, V) and every substitution σ. Definition 4 (reduction pair =-=[20]-=-). We say that (�, ≻) is a reduction pair on T (Σ, V) if � is a quasi-order and ≻ is a well-founded order on terms where both � and ≻ are closed under substitutions and compatible (i.e., � ◦ ≻ ⊆ ≻ or ... |

34 | Constraint-based termination analysis of logic programs
- DECORTE, SCHREYE, et al.
- 1999
(Show Context)
Citation Context ...his work has been extended in several ways. On the one hand, [37] present a sufficient condition which is amenable to automation and extend a constraint-based approach for Prolog termination analysis =-=[11]-=- to the case of Prolog with tabling. On the other hand, [38] considers that not all predicates are tabled (in contrast to [10]) and also introduces modular termination conditions. Unfortunately, all t... |

32 |
Inference of monotonicity constraints in Datalog programs
- Brodsky, Sagiv
- 1989
(Show Context)
Citation Context ...neralized so that every computation is still strongly quasi-terminating. We formalize our quasi-termination analysis by means of size-change graphs [22], which (together with monotonicity constraints =-=[4]-=-) are currently used by an increasing number of termination analyzers for different programming languages. Basically, one should first approximate the transition relation of the program by means of si... |

29 | Goal independency and call patterns in the analysis of logic programs
- Gabbrielli, Giacobazzi
- 1994
(Show Context)
Citation Context ...n the computation of (an approximation of) the binary unfoldings of a program. This approach, however, has only been formalized 2sfor a leftmost computation rule [8] or for a local 1 computation rule =-=[14]-=-. Adapting it for considering strong termination implies redoing almost everything from scratch (and would likely produce a technique closely related to our developments based on size-change graphs). ... |

28 | Homeomorphic embedding for online termination of symbolic methods. In: The essence of computation: complexity, analysis, transformation
- Leuschel
(Show Context)
Citation Context ...elected atom. The finiteness of this SLD tree can be ensured either online or offline. Online partial evaluation techniques (e.g., [25, 27]) use rather expensive tests—like the homeomorphic embedding =-=[24]-=-—for avoiding infinite derivations. In contrast, offline partial ⋆ This work has been partially supported by the EU (FEDER) and the Spanish MEC under grants TIN2004-00231 and TIN2005-09207-C03-02, and... |

26 | The size-change principle and dependency pairs for termination of term rewriting
- Thiemann, Giesl
(Show Context)
Citation Context ... to the size-change graphs), then no infinite computation is possible. Now, we adapt the definitions of size-change graph and maximal multigraph to logic programs; we mainly follow the definitions in =-=[36]-=- for rewrite systems, which in turn originates from the original definitions in [22] for first-order functional programs. In the following, a strict order ≻ is an irreflexive and transitive binary rel... |

21 | Testing for Termination with Monotonicity Constraints
- Lagoon, Stuckey
- 2005
(Show Context)
Citation Context ...X) ❀ last(X, WS) ❀ {WS/[R|RS]} . . . Therefore, some additional requirements are necessary to ensure termination. Let us first recall the notion of instantiated enough w.r.t. a symbolic norm. 6 5 See =-=[7]-=- for a generalization of this condition where idempotence is not required. 6 A closely related notion is that of rigidity [3], where a term t is rigid w.r.t. a norm ||·|| if, for any substitution σ, |... |

19 | Schreye. Termination Proofs for Logic Programs with Tabling
- Verbaeten, Sagonas, et al.
(Show Context)
Citation Context ...rm rewriting, where a system is called quasi-terminating if all its derivations contain only a finite number of distinct terms [12]. In logic programming, quasi-termination has been studied, e.g., in =-=[10, 28, 34, 37, 38]-=-, mainly in the context of tabled evaluation; in this context, a logic program quasi-terminates when only finitely many different atoms—up to variable renaming—are derivable from any given query. In t... |

18 | Termination analysis for tabled logic programming
- Decorte, Schreye, et al.
- 1998
(Show Context)
Citation Context ...rm rewriting, where a system is called quasi-terminating if all its derivations contain only a finite number of distinct terms [12]. In logic programming, quasi-termination has been studied, e.g., in =-=[10, 28, 34, 37, 38]-=-, mainly in the context of tabled evaluation; in this context, a logic program quasi-terminates when only finitely many different atoms—up to variable renaming—are derivable from any given query. In t... |

15 | Size-change analysis in polynomial time
- Ben-Amram, Lee
(Show Context)
Citation Context ...is a worst case exponential growth factor associated to the computation of multigraphs. Efficiency issues, however, are out of the scope of this paper (see, e.g., the polynomial-time approximation of =-=[21]-=- or the constraint-based approach of [6]). Clearly, if a program is size-change terminating, then it is terminating w.r.t. any ground query. Size-change termination, however, does not generally imply ... |

14 | Abstract domains based on regular types
- Gallagher, Henriksen
- 2004
(Show Context)
Citation Context ..., where “regular” binding-types are used. Regular binding-types improve on the classical static (totally known, i.e., ground) and dynamic (possibly unknown) binding-types by introducing regular types =-=[16]-=-. For instance, a bindingtype of the form list = []; [dynamic|list] describes the set of all lists whose elements are unknown. In the following, we use the binding-time analysis of [9] to determine wh... |

14 | Termination analysis and specialization-point insertion in offline partial evaluation
- Glenstrup, Jones
- 2005
(Show Context)
Citation Context ...nation w.r.t. Prolog’s leftmost computation rule is considered—and for partial evaluation—see, e.g., [18], where the relation between quasi-termination and partial evaluation is first established, or =-=[17]-=-, where the notion of bounded variation is introduced in order to ensure the termination of partial evaluation of first-order functional programs. As mentioned in the introduction, analyzing the stron... |

14 | Preserving termination of tabled logic programs while unfolding
- Leuschel, Martens, et al.
- 1997
(Show Context)
Citation Context |

12 | Controlling generalization and polyvariance in partial deduction of normal logic programs
- Leuschel, Martens, et al.
- 1998
(Show Context)
Citation Context ... each atom in the leaves of the tree is an instance of a previously selected atom. The finiteness of this SLD tree can be ensured either online or offline. Online partial evaluation techniques (e.g., =-=[25, 27]-=-) use rather expensive tests—like the homeomorphic embedding [24]—for avoiding infinite derivations. In contrast, offline partial ⋆ This work has been partially supported by the EU (FEDER) and the Spa... |

10 | Fully Automatic Binding Time Analysis for Prolog
- Craig, Gallagher, et al.
- 2005
(Show Context)
Citation Context ...tension of an SLD interpreter that simply obeys the annotations. Unfortunately, there is no fully automatic BTA for ensuring the termination of offline partial evaluation yet. Recent progress include =-=[9]-=-, which presents a fully automatic BTA but only provides partial termination guarantees. Holst [18] was the first to relate (within the functional programming paradigm) the termination of partial eval... |

10 | Proving Termination for Logic Programs by the Query-Mapping Pairs Approach
- Lindenstrauss, Sagiv, et al.
- 2004
(Show Context)
Citation Context ...ent condition for strong termination. On the other hand, size-change graphs (originally introduced in [22] in the context of functional programming) are closely related to the weighted rule graphs of =-=[30]-=-. However, the weighted rule graphs are built for a specific (leftmost) computation rule and, thus, strong termination cannot be analyzed. Furthermore, the weighted rule graphs are used as an intermed... |

7 | One loop at a time
- Codish, Genaim, et al.
- 2003
(Show Context)
Citation Context ...this information will be available for free from the output of a binding-time analysis (see Sect. 5). Observe that Theorem 1 allows us to use local conditions for proving termination (in the sense of =-=[5]-=-), i.e., rather than searching for a global measure that decreases over all of the loops in the program, termination is guaranteed if for every program loop there exists a measure which decreases as e... |

7 |
The DPPD (Dozens of Problems for Partial Deduction) Library of Benchmarks. Available at URL: www.ecs.soton.ac.uk/~mal/systems/dppd.html
- Leuschel
(Show Context)
Citation Context ...olog offline partial evaluator), can be found at http : //www.dsic.upv.es/users/elp/german/proff/ together with some selected examples from the DPPD (Dozens of Problems for Partial Deduction) library =-=[23]-=-. Our preliminary experimental results show that the approach presented so far is viable in practice, although much room for improvement still exists (which was expected given the simplicity of the co... |

6 | universal termination of logic programs
- Ruggieri
- 2001
(Show Context)
Citation Context ... query Q strongly terminate if they universally terminate (i.e., the computation of all solutions terminate) w.r.t. all computation rules. This is the strongest notion of termination and, as noted in =-=[33]-=-, strongly terminating programs and queries are generally trivial programs. Fortunately, the fact that the class of strongly terminating programs is so limited is not a problem in our context. On the ... |

5 |
Non-Leftmost Unfolding in Partial Deduction of Logic Programs with Impure Predicates
- Albert, Puebla, et al.
- 2006
(Show Context)
Citation Context ...consider the termination of SLD resolution w.r.t. all possible computation rules. This is essential because liberal selection policies are often mandatory to achieve a good specialization (see, e.g., =-=[1, 25]-=-). Therefore, we consider strong termination [2]: a program P and query Q strongly terminate if they universally terminate (i.e., the computation of all solutions terminate) w.r.t. all computation rul... |

5 | Size-change termination analysis in k-bits
- Codish, Lagoon, et al.
(Show Context)
Citation Context ... associated to the computation of multigraphs. Efficiency issues, however, are out of the scope of this paper (see, e.g., the polynomial-time approximation of [21] or the constraint-based approach of =-=[6]-=-). Clearly, if a program is size-change terminating, then it is terminating w.r.t. any ground query. Size-change termination, however, does not generally imply the termination of a program w.r.t. arbi... |

3 | Schreye. Termination of Simply-Moded Well-Typed Logic Programs under a Tabled Execution Mechanism. Applicable Algebra
- Verbaeten, De
- 2001
(Show Context)
Citation Context |