A Backward Analysis for Constraint Logic Programs (original) (raw)

Analysing Logic Programs by Reasoning Backwards

Program Development in Computational Logic, 2004

One recent advance in program development has been the application of abstract interpretation to verify the partial correctness of a (constraint) logic program. Traditionally forwards analysis has been applied that starts with an initial goal and traces the execution in the direction of the control-flow to approximate the program state at each program point. This is often enough to verify assertions that a property holds. The dual approach is to apply backwards analysis to propagate properties of the allowable states against the control-flow to infer queries for which the program will not violate any assertion. Backwards analysis also underpins other program development tasks such as verifying the termination of a logic program or proving that a logic program with a delay mechanism cannot reduce to a state that contains sub-goals which suspend indefinitely. This paper reviews various backwards analyses that have been proposed for logic programs, identifying common threads in these techniques. The analyses are explained through a series of worked examples. The paper concludes with some suggestions for research in backwards analysis for logic program development.

Global analysis of constraint logic programs

ACM Transactions on Programming Languages and Systems, 1996

This paper presents and illustrates a practical approach to the dataflow analysis of constraint logic programming languages using abstract interpretation. It is first argued that, from the framework point of view, it suffices to propose relatively simple extensions of traditional analysis methods which have already been proved useful and practical and for which efficient fixpoint algorithms exist. This is shown by proposing a simple extension of Bruynooghe's traditional framework which allows it to analyze constraint logic programs. Then, and using this generalized framework, two abstract domains and their required abstract functions are presented: the first abstract domain approximates definiteness information and the second one freeness. Finally, an approach for combining those domains is proposed. The two domains and their combination have been implemented and used in the analysis of CLP() and Prolog-III applications. Results from this implementation showing its performance and accuracy are also presented.

Denotational abstract interpretation of logic programs

ACM Transactions on Programming Languages and Systems, 1994

Logic-programming languages are based on a principle of separation of "logic" and "control." This means that they can be given simple model-theoretic semantics without regard to any particular execution mechanism (or proof procedure, viewing execution as theorem proving). Although the separation is desirable from a semantical point of view, it makes sound, efficient implementation of logic-programming languages difficult. The lack of "control information" in programs calls for complex data-flow analysis techniques to guide execution. Since data-flow analysis furthermore finds extensive use in error-finding and transformation tools, there is a need for a simple and powerful theory of data-flow analysis of logic programs. This paper offers such a theory, based on F. Nielson's extension of P. Cousot and R. Cousot's abstract interpretation. We present a denotational definition of the semantics of definite logic programs. This definition is of interest in its own right because of its compactness. Stepwise we develop the definition into a generic data-flow analysis that encompasses a large class of data-flow analyses based on the SLD execution model. We exemplify one instance of the definition by developing a provably correct groundless analysis to predict how variables may be bound to ground terms during execution. We also discuss implementation issues and related work.

Abstract interpretation for constraint handling rules

Proceedings of the 7th ACM SIGPLAN international conference on Principles and practice of declarative programming, 2005

Program analysis is essential for the optimized compilation of Constraint Handling Rules (CHRs) as well as the inference of behavioral properties such as confluence and termination. Up to now all program analyses for CHRs have been developed in an ad hoc fashion. In this work we bring the general program analysis methodology of abstract interpretation to CHRs: we formulate an abstract interpretation framework over the call-based operational semantics of CHRs. The abstract interpretation framework is non-obvious since it needs to handle the highly non-deterministic execution of CHRs. The use of the framework is illustrated with two instantiations: the CHR-specific late storage analysis and the more generally known groundness analysis. In addition, we discuss optimizations based on these analyses and present experimental results.

Path Dependent Analysis of Logic Programs

Higher-Order and Symbolic Computation (formerly LISP and Symbolic Computation), 2003

This paper presents an abstract semantics that uses information about execution paths to improve precision of data flow analyses of logic programs. The abstract semantics is illustrated by abstracting execution paths using call strings of fixed length and the last transfer of control. Abstract domains that have been developed for logic program analyses can be used with the new abstract semantics without modification.

Notes for a tutorial on abstract interpretation of logic programs

1989

The present notes are concerned with semantics-based dataflow analysis of definite clause logic programs. They have been produced for a tutorial given by the authors to the North American Conference on Logic Programming in Cleveland, Ohio, 16 October 1989. The notes are a condensed version of two forthcoming papers [33, 36]. Proofs omitted here appear in these papers. In Section 1 we give a brief introduction and historical background to the subject. In Section 2 we introduce some preliminary notation. In Section 3 we give a general theory for dataflow analysis which is basically that of abstract interpretation as introduced by P. and R. Cousot. We develop a simple abstract interpretation based on the well-known T P semantics of definite clause programs. In Section 4 we consider the abstract interpretation of definite clause logic programs and detail its uses. We discuss the limitations of dataflow analyses which are based on either the T P or SLD semantics of logic programs and develop a denotational semantics which may be used as a basis for most existing dataflow analyses. In Section 5 a non-trivial dataflow analysis for groundness propagation is developed from the denotational definitions given in Section 4. Clause the set of clauses, and Prog the set of (definite) programs.

An abstract interpretation scheme for identifying inherent parallelism in logic programs

New Generation Computing, 1990

We describe a new scheme for the abstract interpretation of logic programs. The scheme was developed to identify and integrate different forms of inherent parallelism in logic programs at compile time. The scheme has four components: generalization, abstract unification, summarization and concretization, algorithms for which are discussed. The abstract domain for interpretation consists of type expressions which are used as program modes. The generated mode information has been applied to identify different classes of procedures exhibiting different forms of inherent parallelism. The mode information has also been applied for detection of guards and producer-consumer relationship. The advantages and limitations of our resulting scheme are discussed. An Abstract Interpretation .Scheme for Identifying Inherent Parallelism in Logic Programs 275 suspended processes. We use mode information, expressed in terms of type expressions, to identify producer-consumer relationship and provide synchronization at compile time. We also use modes to identify guards. Development of transformation schemes: We use different source-tosource transformation scheme for simulation of OR-parallelism to stream parallelism and AND-parallelism under the framework of committedchoice AND-parallelism 1~ extended to generate multiple solutions. 2' 3~ This transformation integrates OR-parallelism, AND-parallelism, and stream parallelism. Logic Program Abstract Interpretation with abstract domain as polymorphic type expression Logic program with modes expressed as polymorphic type expressions Procedure Classification based on integration of type expression, modes, disjointness, and determinacy Logic program with procedure classification based upon inherent parallelism Transformation scheme to transform logic program to extended committed-choice AND-parallelism Transformed committed-choice logic program A.K. Bansal and L. S. Sterling

Design and implementation of a tracer driver: Easy and efficient dynamic analyses of constraint logic programs

Theory and Practice of Logic Programming, 2008

Tracers provide users with useful information about program executions. In this article, we propose a tracer driver. From a single tracer, it provides a powerful front-end enabling multiple dynamic analysis tools to be easily implemented, while limiting the overhead of the trace generation. The relevant execution events are specied by exible event patterns and a large variety of trace data can be given either systematically or on demand. The proposed tracer driver has been designed in the context of constraint logic programming; experiments have been made within GNU-Prolog. Execution views provided by existing tools have been easily emulated with a negligible overhead. Experimental measures show that the exibility and power of the described architecture lead to good performance.