Non-termination Analysis of Logic Programs Using Types (original) (raw)

Termination analysis of logic programs extended abstract

2003

Verifying termination is often considered as one of the most important aspects of program verification. Logic languages, allowing us to program declaratively, increase the danger of non-termination. Therefore, termination analysis received considerable attention in logic programming (see e.g. [7, 8, 10, 16]). Unfortunately, the majority of existing termination analysers, such as Termi-Log [15], TerminWeb [7], and cTI [16] are restricted to pure logic programs and thus, leave many interesting real-world examples out of consideration. Therefore, in order to abridge the gap between programming practice and existing termination analysers real-world programming techniques should be considered. In this paper we present Hasta-La-Vista-a powerful tool for analysing termination of logic programs with integer computations. Hasta-La-Vista extends the constraints-based approach of Decorte et al. [9] by integrating the inference algorithm of [19]. Moreover, as explained in [19], in the integer case our approach is not limited to proving termination, but can also infer termination, i.e., find the set of queries terminating for a given program. System architecture. Conceptually, Hasta-La-Vista consists of three main parts: transformation, constraints generation and constraints solving. As a preliminary step, given a program and a set of atomic queries, type analysis of Janssens and Bruynooghe [14] computes the call set. We opted for a very simple type inference technique that provides us only with information whether some argument is integer or not. Based on the results of the type analysis the system decides whether termination of the given program can be dependent on the integer computation. In this case, the adorning transformation is applied [19]. The aim of the transformation is to discover bounded integer arguments and to make the bounds explicit. Intuitively, if a variable x is known to be bounded from above by n, then n x is always positive and thus, can be used as a basis for a definition of a levelmapping (a function from the set of atoms to the naturals). In order to prove termination we have to show that the level-mapping decreases while traversing a clause. This requirement can be translated into a set of constraints. Finally, this set of constraints is solved and depending on the solution termination is

Termination Analysis of Tabled Logic Programs Using Mode and Type Information

Lecture Notes in Computer Science, 1999

Tabled logic programming is receiving increasing attention in our community. It avoids many of the shortcomings of SLD(NF) execution and provides a more exible and often extremely e cient execution mechanism for logic programs. In particular, tabled execution of logic programs terminates more often than execution based on SLD-resolution. So, if a program can be proven to terminate under SLD-resolution, then the program will trivially also terminate under SLG-resolution, the resolution principle of tabulation. But, since there are SLG-terminating programs which are not SLDterminating, better proof techniques can be found. One of the few approaches studying termination of tabled logic programs was developed by Decorte et al. They present necessary and su cient conditions for two notions of termination under LG-resolution, i.e. SLG-resolution with left-to-right selection rule: quasi-termination and (the stronger notion of) LG-termination. Starting from these necessary and su cient conditions, we introduce su cient conditions for quasi-termination and LG-termination which reason fully at the clause level and are easy to automatize. To this end, we use mode and type information: we consider simply moded, well-moded/welltyped programs and queries. We point out how our termination conditions can be automatized, by extending the recently developed constraint-based automatic termination analysis for SLD-resolution by Decorte and De Schreye.

Applying static analysis techniques for inferring termination conditions of logic programs

2001

We present the implementation of cTI, a system for universal left-termination inference of logic programs, which heavily relies on static analysis techniques. Termination inference generalizes termination analysis/checking. Traditionally, a termination analyzer tries to prove that a given class of queries terminates. This class must be provided to the system, requiring user annotations. With termination inference such annotations are not necessary. Instead, all provably terminating classes to all related predicates are inferred at once. The architecture of cTI is described and some optimizations are discussed. Running times for classical examples from the termination literature in LP and for some middle-sized logic programs are given.

Termination Analysis of General Logic Programs for Moded Queries: A Dynamic Approach

2005

The termination problem of a logic program can be addressed in either a static or a dynamic way. A static approach performs termination analysis at compile time, while a dynamic approach characterizes and tests termination of a logic program by applying a loop checking technique. In this paper, we present a novel dynamic approach to termination analysis for general logic programs with moded queries. We address several interesting questions, including how to formulate an SLDNF-derivation for a moded query, how to characterize an infinite SLDNF-derivation with a moded query, and how to apply a loop checking mechanism to cut infinite SLDNF-derivations for the purpose of termination analysis. The proposed approach is very powerful and useful. It can be used (1) to test if a logic program terminates for a given concrete or moded query, (2) to test if a logic program terminates for all concrete or moded queries, and (3) to find all (most general) concrete/moded queries that are most likely terminating (or non-terminating).

Constraint-based termination analysis of logic programs

ACM Transactions on Programming Languages and Systems, 1999

Current norm-based automatic termination analysis techniques for logic programs can be split up into different components: inference of mode or type information, derivation of models, generation of well-founded orders, and verification of the termination conditions themselves. Although providing high-precision results, these techniques suffer from an efficiency point of view, as several of these analyses are often performed through abstract interpretation. We present a new termination analysis which integrates the various components and produces a set of constraints that, when solvable, identifies successful termination proofs. The proposed method is both efficient and precise. The use of constraint sets enables the propagation of information over all different phases while the need for multiple analyses is considerably reduced.

A general framework for automatic termination analysis of logic programs

Applicable Algebra in …, 2001

This paper describes a general framework for automatic termination analysis of logic programs, where we understand by "termination" the finiteness of the LD-tree constructed for the program and a given query. A general property of mappings from a certain subset of the branches of an infinite LD-tree into a finite set is proved. From this result several termination theorems are derived, by using different finite sets. The first two are formulated for the predicate dependency and atom dependency graphs. Then a general result for the case of the query-mapping pairs relevant to a program is proved (cf. ). The correctness of the TermiLog system described in follows from it. In this system it is not possible to prove termination for programs involving arithmetic predicates, since the usual order for the integers is not well-founded. A new method, which can be easily incorporated in TermiLog or similar systems, is presented, which makes it possible to prove termination for programs involving arithmetic predicates. It is based on combining a finite abstraction of the integers with the technique of the query-mapping pairs, and is essentially capable of dividing a termination proof into several cases, such that a simple termination function suffices for each case. Finally several possible extensions are outlined.

Hasta-La-Vista: Termination analyser for logic programs

Workshop on Logic Programming Environments

This volume contains papers presented at WLPE 2003, the 13th International Workshop on Logic Programming Environments. The aim of WLPE is to provide an informal meeting for researchers working on tools for development and analysis of logic programming. This year, the emphasis is on the presentation, pragmatics and experiences of such tools.

A practical analysis of non-termination in large logic programs

Theory and Practice of Logic Programming, 2013

A large body of work has been dedicated to termination analysis of logic programs but until recently little has been done to analyze non-termination. In our opinion, explaining nontermination is a much more important task because it can dramatically improve a user's ability to effectively debug large, complex logic programs without having to abide by punishing syntactic restrictions. Non-termination analysis examines program execution history when the program is suspected to not terminate and informs the programmer about the exact reasons for this behavior. In (Liang and Kifer 2013), we studied the problem of non-termination in tabled logic engines with subgoal abstraction, such as XSB, and proposed a suite of algorithms for non-Termination Analyzer, called Terminyzer. These algorithms analyze forest logging traces and output sequences of tabled subgoal calls that are the likely causes of non-terminating cycles. However, this feedback was hard to use in practice: the same subgoal could occur in multiple rule heads and in even more places in rule bodies, so Terminyzer left too much tedious work for the user to do manually.