Abstract Verification and Debugging of Constraint Logic Programs (original) (raw)

Program Debugging and Validation Using Semantic Approximations and Partial Specifications

Lecture Notes in Computer Science, 2002

The technique of Abstract Interpretation [11] has allowed the development of sophisticated program analyses which are provably correct and practical. The semantic approximations produced by such analyses have been traditionally applied to optimization during program compilation. However, recently, novel and promising applications of semantic approximations have been proposed in the more general context of program validation and debugging [3, 9, 7]. We study the case of (Constraint) Logic Programs (CLP), motivated by the comparatively large body of approximation domains, inference techniques, and tools for abstract interpretation-based semantic analysis which have been developed to a powerful and mature level for this programming paradigm (see, e.g., [23, 8, 18, 6, 12] and their references). These systems can approximate at compile-time a wide range of properties, from directional types to determinacy or termination, always safely, and with a significant degree of precisión. Thus, our approach is to take advantage of these advances in program analysis tools within the context of program validation and debugging, rather than using traditional proof-based methods (e.g., [1, 2, 13, 17, 28]), developing new tools and procedures, such as specific concrete [4, 15, 16] or abstract [9, 10] diagnosers and declarative debuggers, or limiting error detection to run-time checking [28]. In this talk we discuss these issues and present a framework for combined static/dynamic validation and debugging using semantic approximations [7, 26, 21] which is meant to be a part of an advanced program development environment comprising a variety of co-existing tools [14]. Program validation and detection of errors is first performed at compile-time by inferring properties of the program via abstract interpretation-based static analysis and comparing this information against (partial) speciñcations written in terms of assertions. Such assertions are linguistic constructions which allow expressing properties of programs. Classical examples of assertions are type declarations (e.g., in the context of (C)LP those used by [22, 27, 5]). However, herein we are interested in supporting a more general setting in which assertions can be of a much more general nature, stating additionally other properties, some of which cannot always be determined statically for all programs. These properties may include properties defined by means of user programs and extend beyond the predefined set which may be allow the integration of additional analyses in a simple way (for example, it has been adapted for use with the CHIP CLP(fd) system). More info: For more information, full versions of selected papers and technical reports, and/or to download Ciao and other related systems please access http://www.clip.dia.fi.upm.es/.

Abstract Interpretation Based Verification of Logic Programs

Electronic Notes in Theoretical Computer Science, 2001

This paper is an overview of our results on the application of abstract interpretation concepts to various problems related to the veriÿcation of logic programs. These include the systematic design of semantics modeling various proof methods and the characterization of assertions as abstract domains. We derive an assertion based veriÿcation method and we show two instances based on different assertion languages: a decidable assertion language and CLP used as an assertion language.

Static Analysis by Abstract Interpretation: A Mathematical Programming Approach

Electronic Notes in Theoretical Computer Science, 2010

Static analysis of a computer program by abstract interpretation helps prove behavioural properties of the program. Programs are defined by means of a forward collecting semantics function relating the values of the program variables during the execution of the program. The least fixed point of the semantics function is a program invariants providing useful information about the program's behaviour. Mathematical Programming is a formal language for describing and solving optimization problems expressed in very general terms. This paper establishes a link between the two disciplines by providing a mathematical program that models the problem of finding the least fixed point of a semantics function. Although we limit the discussion to integer affine arithmetic semantics in the interval domain, the flexibility and power of mathematical programming tools have the potential for enriching static analysis considerably.

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.

Refining Abstract Interpretation-based Approximations with Constraint Solvers

HAL (Le Centre pour la Communication Scientifique Directe), 2011

Programs with floating-point computations are tricky to develop because floating-point arithmetic differs from real arithmetic and has many counterintuitive properties. A classical approach to verify such programs consists in estimating the precision of floating-point computations with respect to the same sequence of operations in an idealized semantics of real numbers. Tools like Fluctuat-based on abstract interpretation-have been designed to address this problem. However, such tools compute an over-approximation of the domains of the variables, both in the semantics of the floating-point numbers and in the semantics of the real numbers. This over-approximation can be very coarse on some programs. In this paper, we show that constraint solvers over floating-point numbers and real numbers can significantly refine the approximations computed by Fluctuat. We managed to reduce drastically the domains of variables of C programs that are difficult to handle for abstract interpretation techniques implemented in Fluctuat.

Semantics-based generation of verification conditions by program specialization

2016

We present a method for automatically generating verification con-ditions for a class of imperative programs and safety properties. Our method is parametric with respect to the semantics of the impera-tive programming language, as it specializes, by using unfold/fold transformation rules, a Horn clause interpreter that encodes that se-mantics. We define a multi-step operational semantics for a fragment of the C language and compare the verification conditions obtained by using this semantics with those obtained by using a more tradi-tional small-step semantics. The flexibility of the approach is fur-ther demonstrated by showing that it is possible to easily take into account alternative operational semantics definitions for modeling new language features. Finally, we provide an experimental evalu-ation of the method by generating verification conditions using the multi-step and the small-step semantics for a few hundreds of pro-grams taken from various publicly available benchmarks,...

A Backward Analysis for Constraint Logic Programs

Theory and Practice of Logic Programming, 2002

One recurring problem in program development is that of understanding how to re-use code developed by a third party. In the context of (constraint) logic programming, part of this problem reduces to figuring out how to query a program. If the logic program does not come with any documentation, then the programmer is forced to either experiment with queries in an ad hoc fashion or trace the control-flow of the program (backward) to infer the modes in which a predicate must be called so as to avoid an instantiation error. This paper presents an abstract interpretation scheme that automates the latter technique. The analysis presented in this paper can infer moding properties which if satisfied by the initial query, come with the guarantee that the program and query can never generate any moding or instantiation errors. Other applications of the analysis are discussed. The paper explains how abstract domains with certain computational properties (they condense) can be used to trace control-flow backward (right-to-left) to infer useful properties of initial queries. A correctness argument is presented and an implementation is reported.

Semantics-based generation of verification conditions via program specialization

Science of Computer Programming, 2017

We present a method for automatically generating verification conditions for a class of imperative programs and safety properties. Our method is parametric with respect to the semantics of the imperative programming language, as it generates the verification conditions by specializing, using unfold/fold transformation rules, a Horn clause interpreter that encodes that semantics. We define a multi-step operational semantics for a fragment of the C language and compare the verification conditions obtained by using this semantics with those obtained by using a more traditional small-step semantics. The flexibility of the approach is further demonstrated by showing that it is possible to easily take into account alternative operational semantics definitions for modeling additional language features. We have proved that the verification condition generation takes a number of transformation steps that is linear with respect to the size of the imperative program to be verified. Also the size of the verification conditions is linear with respect to the size of the imperative program. Besides the theoretical computational complexity analysis, we also provide an experimental evaluation of the method by generating verification conditions using the multi-step and the small-step semantics for a few hundreds of programs taken from various publicly available benchmarks, and by checking the satisfiability of these verification conditions by using state-of-the-art Horn clause solvers. These experiments show that automated verification of programs from a formal definition of the operational semantics is indeed feasible in practice.