June 1996 CSTR-96-003 University of Bristol Department of Computer Science Static Analysis of Logic Programs Using CLP as a Meta-language Huseyin Saglam John Gallagher ACRC-96 : CS-003Also issued as Static Analysis of Logic Programs Using CLP as a Meta-language H. Sa > = glam and J.P. Gallagher Department of Computer Science , University of Bristol Merchant Venturers Building , Woodland Road , Bristol BS8 1UB , U.K. e-mail : fsaglam , johng@cs.bris.ac.uk fax : +44-117-954 5208 phone : +44-117-954 5132 Abstract The tools for analysing logic programs presented here support a systematic method for constructing static analyses . The basic approach and some implementation experiments were described in previous papers -LSB- GBS95 -RSB- , -LSB- Gal95 -RSB- , -LSB- BB94 -RSB- , -LSB- BBD94 -RSB- . Briefly , the method includes the following steps . First the functions and constants of the language of the program to be analysed are given an interpretation into a domain of values representing properties -LRB- a pre-interpretation of the language -RRB- ; second , abstract compilation with respect to the pre-interpretation transforms the program into a \ domain program '' ; third , -LRB- an approximation to -RRB- the standard model of the domain program is computed . In addition to these steps , various program transformations may be used to simulate goal-directed analysis and improve precision . The methods described in -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- are extended by introducing constraint logic programs as the meta-language for describing pre-interpretations , rather than simple Datalog programs as before . Pre-interpretations with respect to arithmetic domains thus become possible . This implies that the domain program can be a constraint logic program of arbitrary complexity , and so the main practical concern is to compute reasonably precise approximate models of constraint logic programs . The flexibility of the approach is illustrated , showing how well-known approximations such as convex polyhedra can be combined with other constraints . A prototype implementation , with simplified handling of some operations on convex polyhedra , and some examples are included . 1 Introduction The declarative semantics of -LRB- constraint -RRB- logic programs is a basis for approximation that is both conceptually simple and practical . Briefly , let P be a logic program and denote the set of atomic logical consequences of P by C -LSB- -LSB- P -RSB- -RSB- . Then a program P is said to be an -LRB- over - -RRB- approximation of P if C -LSB- -LSB- P -RSB- -RSB- ? C -LSB- -LSB- P -RSB- -RSB- . Non-membership of C -LSB- -LSB- P -RSB- -RSB- thus provides a sufficient condition for non-membership of C -LSB- -LSB- P -RSB- -RSB- . The usefulness of an approximation depends completely on how much easier it is to determine membership of C -LSB- -LSB- P -RSB- -RSB- than that of C -LSB- -LSB- P -RSB- -RSB- . Typically membership of C -LSB- -LSB- P -RSB- -RSB- is decidable while membership of C -LSB- -LSB- P -RSB- -RSB- is not . In some experiments the reduced complexity , rather than decidability , of checking membership of C -LSB- -LSB- P -RSB- -RSB- and C -LSB- -LSB- P -RSB- -RSB- is the main justification for approximation . In -LSB- BB94 -RSB- , -LSB- BBD94 -RSB- , -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- an approach to analysis of logic programs was presented , based on declarative semantics . Throughout , we emphasise the practicality of the approach as well as its directness . The method explained in -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- consisted of the following steps . ffl Define a pre-interpretation of the language of the program over a non-standard domain . In -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- the pre-interpretation was captured by defining two predicates domain/1 and denotes/2 which enumerated the domain and the pre-interpretation mappings for each function symbol . ffl Perform \ abstract compilation '' of the program with respect to the given pre-interpretation , yielding a program in which the predicates denotes/2 and domain/1 are incorporated into the original program . The resulting program is a \ domain program '' ; that is , it contains functions and constants representing the domain of interpretation . ffl Compute -LRB- an approximation of -RRB- the standard concrete semantics of the domain program -LRB- e.g. find a superset of the least fixed point of the TP operator -RRB- . The techniques explored in this work include approximation of arithmetic constraints by linear inequalities -LRB- convex polyhedra -RRB- , regular approximations , and approximations based on most specific generalisations . ffl Interpret the concrete semantics of the domain program as abstract semantics for the original program . This approach is attractive ; an analysis amounts to an interpretation of each language symbol in an abstract domain . Only concrete semantics is handled explicitly ; what could be simpler ? Yet for infinite pre-interpretations it is not clear how effective this technique might be , though a few pointers were given in -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- . 1.1 Analysis Using Infinite Pre-Interpretations The goal of the present research is to extend the practical techniques of -LSB- GBS95 -RSB- and -LSB- Gal95 -RSB- , to allow a pre-interpretation to be defined by an arbitrary constraint logic program , and to obtain reasonably precise approximations of the corresponding domain program . Simply stated , if we can get precise approximations of more concrete programs , we can construct more abstract analyses . A further contribution is to clarify aspects of the relation between pre-interpretations and properties of terms . Let us consider the problem of computing term-size relations between arguments of predicates . This is useful in termination and complexity analyses . As an example , a simple pre-interpretation for lists maps each list to a natural number -LRB- its length -RRB- . This example is considered in more detail later . Finite pre-interpretations can be given an extensional definition , by listing the facts defining the pre-interpretation . The concrete meaning of the \ domain program '' is then computed in a finite number of iterations of the fixpoint operator . More generally , these predicates could be defined intensionally by clauses , rather than extensionally by facts . For large domains of interpretation the enumeration of the pre-interpretation may be very unwieldy and some intensional representation could be more appropriate . More importantly , there is the question of infinite pre-interpretations and infinite program meanings . 1.2 Bottom-Up Abstract Interpretation of Logic Programs Bottom-up semantics defines the meaning of a logic program , without reference to an initial goal , as the closure of an \ immediate consequences '' operator that computes instances of clause heads from solutions to the bodies . There are several variations of this method -LSB- MS88 -RSB- , -LSB- CDY94 -RSB- , -LSB- BGLM94 -RSB- , -LSB- AG94 -RSB- . Constraint logic programs can be given bottom-up semantics in a similar way , but the interpretation of the constraint predicates and functions is fixed . Bottom-up semantics provide the main engine of our approach , but the use of tools to simulate top-down semantics in a bottom-up framework is an important point that will also be discussed -LSB- DR94 -RSB- , -LSB- CDY94 -RSB- . Well-known \ magic-set '' transformations are examples of a more general class of query-answer transformations . Bottom-up semantics can be defined to give either declarative semantics or procedural semantics . Declarative semantics captures the set of atomic logical consequences of a program . Procedural semantics captures in general a subset of the atomic logical consequences -LRB- assuming the procedural semantics is sound -RRB- . Note that two programs could be logically equivalent , yet have different computed answers . In the following , only declarative semantics is considered . The theoretical basis of this approach to static analysis of definite programs was set out in -LSB- BBD94 -RSB- , -LSB- BB94 -RSB- and -LSB- GBS95 -RSB- . The main advantage of bottom-up declarative semantics as a basis for static analysis is the lack of operational components , especially unification , that have to be given abstract counterparts . As shown in the works cited , the main requirement is a declarative interpretation of the language of the program , which usually corresponds directly to defining the properties of interest . In this paper we concentrate on the approximation of constraints , since most of the other techniques have been covered elsewhere . The combination of constraint approximations with standard Datalog model computations and regular approximations has not previously been explored . It adds considerable expressiveness and flexibility to the basic analysis method based on pre-interpretations . 1.3 Declarative Bottom-Up Core Semantics : Preliminaries Let P be a definite program and L its underlying language . A pre-interpretation of L consists of 1 . a non-empty domain of interpretation D ; 2 . an assignment of an n-ary function Dn ! D to each n-ary function symbol in L -LRB- n > = 0 -RRB- . Let J be a pre-interpretation for L with domain D. Let V be a mapping assigning each variable in L to an element of D . A term assignment TVJ -LRB- t -RRB- is defined for each term t as follows : 1 . TVJ -LRB- x -RRB- = V -LRB- x -RRB- for each variable x. 2 . TVJ -LRB- f -LRB- t1 ; : : : ; tn -RRB- -RRB- = f -LRB- TVJ -LRB- t1 -RRB- ; : : : ; TVJ -LRB- tn -RRB- -RRB- , -LRB- n > = 0 -RRB- for each non-variable term f -LRB- t1 ; : : : ; tn -RRB- , where f is the function assigned by J to f . Definition 1.1 Domain atom Let J be a pre-interpretation of a language L , with domain D , and let p be an n-ary function symbol from L . Then a domain atom for J is any atom p -LRB- d1 ; : : : ; dn -RRB- where di 2 D , 1 < = i < = n. Let p -LRB- t1 ; : : : ; tn -RRB- be an atom . Then a domain instance of p -LRB- t1 ; : : : ; tn -RRB- with respect to J and V is a domain atom p -LRB- TVJ -LRB- t1 -RRB- ; : : : ; TVJ -LRB- tn -RRB- -RRB- . The set of all domain instances of A with respect to J and some V is denoted by -LSB- A -RSB- J . The definition of domain instance extends naturally to formulas . In particular , let C be a clause . Denote by -LSB- C -RSB- J the set of all domain instances of the clause with respect to J . The core bottom-up declarative semantics is parameterised by a pre-interpretation of the language of the program . Definition 1.2 Core bottom-up semantics function T JP Let P be a definite program , and J a pre-interpretation of the language of P , with domain D. Let AtomD be the set of domain atoms with respect to J . T JP : 2AtomD ! 2AtomD T JP -LRB- I -RRB- = ae A A B1 ; : : : ; Bn 2 -LSB- A B1 ; : : : ; Bn -RSB- J fB1 ; : : : ; Bng ? I oe MJ -LSB- -LSB- P -RSB- -RSB- = lfp -LRB- T JP -RRB- MJ -LSB- -LSB- P -RSB- -RSB- is the minimal model of P with pre-interpretation J . The usual declarative semantics is given by taking J to be the Herbrand pre-interpretation , which we call H . In this case MH -LSB- -LSB- P -RSB- -RSB- is the minimal Herbrand model of P . For the purposes of this paper , an extended version of H is taken , which will be called the concrete semantics , which permits properties of non-ground terms , including variables , to be handled . Let L be the language of program P . Let HV be an extended Herbrand pre-interpretation defined as follows : 1 . The domain of interpretation is the set of terms constructible from L together with an additional infinite set of special constants . 2 . The interpretation of function symbols is that each n-ary function symbol f -LRB- n > = 0 -RRB- is mapped to the function which when applied to ht1 ; : : : ; tni yields f -LRB- t1 ; : : : ; tn -RRB- . Assume that ? is some one-to-one mapping from the variables in L to the special constants in the domain . Given an atom A , let ? A be the atom obtained by replacing each variable x in A by ? -LRB- x -RRB- . MHV -LSB- -LSB- P -RSB- -RSB- , the minimal model with this pre-interpretation , is a set of terms that represents the set of atomic logical consequences of P . This is made precise by the following proposition -LSB- GBS95 -RSB- . Proposition 1.3 Let P be a program and MHV -LSB- -LSB- P -RSB- -RSB- be its concrete semantics . Then for all atoms A , P j = 8A iff ? A 2 MHV -LSB- -LSB- P -RSB- -RSB- . In what follows , the conversion between an atom A and its corresponding domain atom ? A is sometimes implicit . 1.4 Systematic Construction of a Pre-Interpretation Although any pre-interpretation can be used to construct a domain model , it is often appropriate to start from those properties of terms which the analysis is intended to capture . In this section we outline the steps and main requirements to be satisfied when constructing a pre-interpretation 1 . 1Discussions with M. Denecker and D. Boulanger were helpful in clarifying the material in this section . M. Denecker identified this formulation of the consistency condition Definition 1.4 and its role in Proposition 1.5 The domain of the concrete pre-interpretation HV is denoted DHV . Let D be a set -LRB- the abstract domain of interpretation -RRB- , representing properties of elements of DHV . Assume that a function P : DHV ! D assigns properties to elements of DHV . For example , define a domain fg ; ngg where g stands for the set of ground terms and ng the set of non-ground terms . Then , for this domain , P -LRB- t -RRB- = g if t is a ground term and ng otherwise . A pre-interpretation I can be defined from P , if P is onto -LRB- surjective -RRB- and satisfies the following condition . Definition 1.4 consistency of property function The property mapping P : DHV ! D is consistent if for each n-ary function symbol f , and for all terms t1 ; : : : ; tn ; s1 ; : : : ; sn : P -LRB- t1 -RRB- = P -LRB- s1 -RRB- : : : P -LRB- tn -RRB- = P -LRB- sn -RRB- -RRB- P -LRB- f -LRB- t1 ; : : ; tn -RRB- -RRB- = P -LRB- f -LRB- s1 ; : : ; sn -RRB- -RRB- Proposition 1.5 Let P : DHV ! D be onto and consistent , and let I be the function that , for each n-ary function symbol f : DnHV ! DHV , maps f to the function f : Dn ! D defined as f -LRB- P -LRB- t1 -RRB- ; : : : ; P -LRB- tn -RRB- -RRB- = P -LRB- t1 ; : : : ; tn -RRB- for all t1 ; : : : ; tn 2 DHV . Then I is a pre-interpretation for the function symbols in DHV . Proof . Outline . It is just necessary to verify that f is a well-defined total function in Dn ! D . 2 Example 1 Using the domain fg ; i ; vg discussed in -LSB- BB94 -RSB- , -LSB- BBD94 -RSB- and -LSB- GBS95 -RSB- , define P -LRB- t -RRB- to be g if t is ground , v if t is a variable , and i otherwise . Then the pre-interpretation I maps the function symbols -LSB- -RSB- , and cons = 2 to the functions -LSB- -RSB- and cons where -LSB- -RSB- = g ; cons -LRB- g ; g -RRB- = g cons -LRB- g ; i -RRB- = i cons -LRB- g ; v -RRB- = i cons -LRB- i ; g -RRB- = i cons -LRB- i ; i -RRB- = i cons -LRB- i ; v -RRB- = i cons -LRB- v ; g -RRB- = i cons -LRB- v ; i -RRB- = i cons -LRB- v ; v -RRB- = i Note that the element v is not in the range of either -LSB- -RSB- or cons , and is a so-called \ non-term '' element -LSB- BBD94 -RSB- . Non-term elements are useful for capturing properties of variable arguments . 2 Abstract Compilation of a Pre-Interpretation The idea of abstract compilation was introduced first by Debray and Warren -LSB- DW88 -RSB- . Operations on the abstract domain are coded as logic program clauses and introduced directly into a program , which is then executed according to standard concrete semantics . The reason for this technique is to avoid some of the overhead of interpreting the abstract operations . A pre-interpretation I can be defined by two predicates , domain = 1 and denotes = 2 . They are given suitable definitions as follows . ffl domain -LRB- d -RRB- is true iff d is in the domain of interpretation . ffl denotes -LRB- f -LRB- d1 ; : : : ; dn -RRB- ; d -RRB- is true if the pre-interpretation of the n-ary function f maps hd1 ; : : : ; dni to d These two predicates are incorporated directly in the program to be analysed . The details were explained in -LSB- GBS95 -RSB- and an example can be found below . If P is the original program , the transformed program is called ? P . When specific definitions of domain = 1 and denotes = 2 defining a pre-interpretation J are added to ? P , the result is a domain program for J , called ? P J . Clearly ? P J has a different language than P , since the definitions of domain = 1 and denotes = 2 contain elements of the domain of interpretation . It can easily be shown that the minimal Herbrand model of ? P J -LRB- restricted to the original program predicates -RRB- is isomorphic to MJ -LSB- -LSB- P -RSB- -RSB- . Example 2 Let P be the append program . Let the abstract domain be fg ; ngg where P -LRB- t -RRB- = g if t is ground and ng otherwise . This satisfies the consistency condition Definition 1.4 . Define a preinterpretation of constants and function symbols consistent with this . The resulting domain program , including definitions of domain = 1 and denotes = 2 is as follows . domain -LRB- g -RRB- . domain -LRB- ng -RRB- . denotes -LRB- -LSB- -RSB- , g -RRB- . denotes -LRB- -LSB- g | g -RSB- , g -RRB- . denotes -LRB- -LSB- ng | g -RSB- , ng -RRB- . denotes -LRB- -LSB- g | ng -RSB- , ng -RRB- . denotes -LRB- -LSB- ng | ng -RSB- , ng -RRB- . append -LRB- U1 , Ys , Ys -RRB- : - denotes -LRB- -LSB- -RSB- , U1 -RRB- , domain -LRB- Ys -RRB- . append -LRB- U1 , Ys , U2 -RRB- : - append -LRB- Xs , Ys , Zs -RRB- , denotes -LRB- -LSB- X | Xs -RSB- , U1 -RRB- , denotes -LRB- -LSB- X | Zs -RSB- , U2 -RRB- , domain -LRB- X -RRB- . The minimal Herbrand model of this program , restricted to append = 3 is fappend -LRB- g ; g ; g -RRB- ; append -LRB- g ; ng ; ng -RRB- ; append -LRB- ng ; ng ; ng -RRB- ; append -LRB- ng ; g ; ng -RRB- g : A constraint-based formulation of this example is shown later . 3 Infinite Pre-Interpretations The method outlined above is straightforward to implement when the domain of pre-interpretation is finite . In such cases , the least fixed point of T JP is computed by iteration in the usual way . Powerful domain-independent optimisations are available to compute the fixed point efficiently -LRB- semi-naive evaluation , decomposition into strongly-connected components -RRB- -LSB- GdW94 -RSB- , -LSB- Gal95 -RSB- , -LSB- GBS95 -RSB- . For infinite pre-interpretations , the fixpoint iterative computation may not terminate . In -LSB- GBS95 -RSB- we discussed this and suggested well-known approximation techniques such as regular approximation -LRB- regular type descriptions -RRB- , depth-k abstractions and other variations based on most specific generalisations . These are interesting when the domain consists of free terms , but inadequate if the domain consists of numbers or other such structured domains . Example 3 Consider a pre-interpretation based on mapping each list to its length . The definition of pre-interpretation for -LSB- -RSB- and cons can be written down using our method as follows . -LSB- -RSB- = cons -LRB- n ; m -RRB- = 1 + m Here , the domain of interpretation is the set of natural numbers , and the definition of cons makes use of the arithmetic function + . Clearly , computing the least model of a domain program obtained with this pre-interpretation will typically generate an infinite number of abstract atoms . For instance , the abstract meaning of a list reverse program will contain atoms reverse -LRB- 0,0 -RRB- , reverse -LRB- 1,1 -RRB- , reverse -LRB- 2,2 -RRB- and so on . A reasonable approximation -LRB- over the rational numbers -RRB- would be the set freverse -LRB- n ; n -RRB- j n > = g. 4 Approximation of Constraint Logic Programs In order to implement our analysis method effectively for infinite pre-interpretations , the practical problem is to compute an approximate meaning for an arbitrary constraint logic program . For our purposes , we consider approximations of a specific form , namely constraint approximations . P is a constraint approximation if it contains only clauses of the form p -LRB- ? x -RRB- C where C is a constraint -LRB- or a system of constraints -RRB- and ? x is a tuple of distinct variables . We may assume that there is at most one clause defining each predicate p if we allow disjunctions in C . In other words no user-defined predicate appears in the body of a clause . This approach was also followed by Ramakrishnan et al. -LSB- RRS95 -RSB- and in our previous work on regular approximation -LSB- GdW94 -RSB- . The approximation of a program P is computed by an iterative fixed-point computation with widening . We compute a sequence of constraint approximations P0 ; P1 ; P2 ; : : : whose limit is the desired approximation . We do not discuss here the detailed conditions for ensuring that the limit of the sequence is an approximation of P , or that the sequence converges in a finite number of steps . The sequence is computed as follows : P0 = ; P1 = fq -LRB- ? x -RRB- solve -LRB- q ; P0 -RRB- j q 2 preds -LRB- P -RRB- g Pi +1 = Pi 5 fq -LRB- ? x -RRB- solve -LRB- q ; Pi -RRB- j q 2 preds -LRB- P -RRB- g -LRB- i > 0 -RRB- where , for each program predicate q , solve -LRB- q ; Pi -RRB- returns the constraint obtained by computing an upper bound of the solutions of the clauses for q . The \ upper bound '' here is defined with respect to the implication ordering on constraints . solve -LRB- q ; Pi -RRB- = U fprojvars -LRB- H -RRB- simpl -LRB- unfold -LRB- B ; Pi -RRB- -RRB- j H B 2 proc -LRB- q -RRB- g Here preds -LRB- P -RRB- stands for the set of user-defined predicates in P , and proc -LRB- q -RRB- stands for the set of clauses in P whose heads contain the predicate q . The operator unfold -LRB- B ; Pi -RRB- is defined as follows . Let B be a clause body -LRB- a conjunction of atoms -RRB- and Pi be a constraint approximation . Then unfold -LRB- B ; Pi -RRB- is the set of formulas obtained by unfolding each user-defined predicate in B using its defining clause in Pi -LRB- if any -RRB- . Example 4 Let B be p -LRB- U ; V -RRB- ; q -LRB- U -RRB- and let Pi be fp -LRB- X ; Y -RRB- X > = ; Y > = X ; q -LRB- X -RRB- X < = 10g . Then unfold -LRB- B ; Pi -RRB- is U > = ; V > = U ; U < = 10 . simpl -LRB- C -RRB- returns a simplified \ solved '' form of the system of constraints C . This is a standard constraint operator , implemented in CLP systems . projV -LRB- C -RRB- returns the system of constraints C projected onto the set of variables V . Note that from the point of view of implementation , our method has the advantage of exploiting the underlying CLP implementation to a large extent . The operators unfold , simpl and projV are all \ concrete '' operations implementable directly in terms of constraint logic programming primitives . The operators 5 and U are widening and upper bound operators respectively . Different variations on these operations are possible , depending on the constraint domain being considered . We consider several possibilities in the next section . The only requirement on these operations is that they should be safe with respect to the underlying order of the approximations . That is , Ci -RRB- C1 UC2 , i = 1 ; 2 and C -LSB- -LSB- Pi -RSB- -RSB- ? C -LSB- -LSB- P1 5 P2 -RSB- -RSB- , i = 1 ; 2 . -LRB- Note that we do not apply widening between the first and second approximations in the sequence P0 ; P1 ; P2 ; : : : , thus correcting an error in -LSB- CC92 -RSB- , which appears in Example 20 of that paper -RRB- . 5 Approximation of Constraints Suppose p = n is a program predicate . We assume that it can be reasonably approximated by constraints on its arguments . For example , we might have a constraint approximation p -LRB- X ; Y ; Z -RRB- X < = Y ; -LRB- Z = a _ Z = b -RRB- This is somewhat restricting , since it disallows constraints on subarguments . We believe that this restriction can be lifted , but it simplifies both the presentation and the implementation . This assumption allows us to consider separately the operations on different kinds of constraint . The appropriate upper bound and widening operations can be taken depending on the types of the predicate arguments . 5.1 Finite Pre-Interpretations We can reconstruct our previous work using finite pre-interpretations over atomic elements with the following definitions of widening and upper-bound . P1 5 P2 = P2 B1 UB2 = B1 _ B2 In this framework , the result of approximating the append program over the domain fg ; ngg , seen earlier , is the following constraint program . append -LRB- X ; Y ; Z -RRB- -LRB- X = g ; Y = Z -RRB- _ -LRB- X = ng ; Y = g ; Z = ng -RRB- _ -LRB- X = ng ; Y = ng ; Z = ng -RRB- 5.2 Infinite Pre-Interpretations over Term Domains Our previous work on regular approximation -LSB- GdW94 -RSB- can also be represented easily in this framework . P1 5 P2 = short -LRB- P2 -RRB- where short -LRB- P2 -RRB- is the shortening operation introduced in -LSB- GdW94 -RSB- for forming recursive regular approximations . Other widenings based on the type inference algorithms -LSB- HCCar -RSB- and -LSB- BJ92 -RSB- could be used instead . The operator B1 UB2 is the tuple distributive upper bound -LSB- YS90 -RSB- of the tuples of regular terms defined by B1 and B2 . 5.3 Infinite Pre-Interpretations over Arithmetic Domains The main power and precision comes from interpretations over numbers . There are several different possibilities in the literature for approximation of numeric constraints , such as intervals , signed inequalities , and convex polyhedra -LSB- JBE94 -RSB- , -LSB- MS93 -RSB- , -LSB- HPR94 -RSB- . Of these most interesting for general use appears to be convex polyhedra , and we now go into some detail on the handling of this kind of approximation . A convex polyhedron is described by a system of linear constraints . Both linear equalities and inequalities are linear constraints . An equation can be considered as two opposite inequalities . Definition 5.1 A subset C of IRn is said to be convex if and only if f8x1 ; x2 2 C ; 8 > = 2 -LSB- 0 ; 1 -RSB- ; > = x1 + -LRB- 1 ? > = -RRB- x2 2 Cg . Definition 5.2 Let V1 ; : : : ; Vp be vectors in IRn . A vector of the form Ppi = 1 -LRB- > = iVi -RRB- ; > = i 2 IR + and Ppi = 1 -LRB- > = i -RRB- = 1 is called a convex combination of V1 ; : : : ; Vp . Definition 5.3 The set of all convex combinations of V1 ; : : : ; Vp is the convex hull of V1 ; : : : ; Vp . The set of solutions to a finite system of loose linear inequalities can be interpreted geometrically as a closed convex polyhedron of IRn . -LRB- Note that there is no loss of generality in considering only loose linear inequalities since strict inequalities can be replaced by loose ones by adding an auxiliary variable ffl , < = ffl < = 1 -LSB- HPR94 -RSB- -RRB- . Definition 5.4 A vertex of a polyhedron P is a point x of P which is not a convex combination of other points of P . Definition 5.5 A ray -LRB- extreme ray -RRB- , intuitively , of a polyhedron P is a point -LRB- vertex -RRB- of P translated to infinity . Definition 5.6 A line of a polyhedron P is a vector d such that both d and ? d are rays of P . Definition 5.7 A bounded polyhedron is the convex hull of its vertices , i.e. each point of a bounded convex polyhedron is a convex combination of the vertices of the polyhedron . More definitions and algorithms over polyhedra can be found in -LSB- CH78 -RSB- . A convex hull , represented as a finite system of loose linear inequalities , can be used as an approximation of a set of points . Example 5 Let V1 = -LRB- 1 ; 1 -RRB- and V2 = -LRB- 2 ; 0 -RRB- be two points in IR2 . The convex hull of these points is the solution of the set of constraints fP2i = 1 > = ixi j > = i > = ; P2i = 1 > = i = 1 g = f > = 1 -LRB- 1 ; 1 -RRB- + > = 2 -LRB- 2 ; 0 -RRB- j > = 1 > = ; > = 2 > = ; > = 1 + > = 2 = 1g = f > = 1 -LRB- 1 ; 1 -RRB- + -LRB- 1 ? > = 1 -RRB- -LRB- 2 ; 0 -RRB- j > = 1 > = ; > = 1 < = 1g = f -LRB- > = 1 ; > = 1 -RRB- + -LRB- 2 ? 2 > = 1 ; 0 -RRB- j > = 1 > = ; > = 1 < = 1g = f -LRB- 2 ? > = 1 ; > = 1 -RRB- j > = 1 > = ; > = 1 < = 1g which describe the set of all points -LRB- 2 ? > = 1 ; > = 1 -RRB- in IR2 where < = > = 1 < = 1 . In other words it is the line X = 2 ? Y , between Y = and Y = 1 in IR2 . Note that the convex hull computed is a bounded polyhedron in IR2 . Given some extreme rays in addition to the vertices , we could compute new convex hulls incorporating these to the convex hull shown -LSB- CH78 -RSB- . The least closed convex upper bound of two closed convex polyhedra is defined in -LSB- CH78 -RSB- . The procedure for computing the least closed convex upper bound depends on using two representations , namely constraint and frame representations of polyhedra . Other upper bounds with reasonable precision can be defined which can avoid the expensive computation of the frame of a convex hull . For example , a coarser but very effective upper bound of two polyhedra could be defined as follows . Let S1 and S2 be two sets of linear inequalities S1 = f 1 ; : : : ; kg ; S2 = f 1 ; : : : ; mg defining two polyhedra in IRn . Then S1 US2 = f i 2 S1 j S2 -RRB- ig S f j 2 S2 j S1 -RRB- jg For widening , we simplify the widening operation suggested by Cousot and Cousot in -LSB- CC92 -RSB- which is an improved version of the one proposed in -LSB- CH78 -RSB- for enforcing the convergence of the iterations of the TP function . Let us quote their definition first -LSB- CC92 -RSB- . Let S1 and S2 be two sets of linear inequalities S1 = f 1 ; : : : ; kg ; S2 = f 1 ; : : : ; mg defining two polyhedra , H1 and H2 respectively , in IRn . Then H1 5H2 = S01 SS02 where 1 . S01 is a subset of S1 whose elements are satisfied by all points of H2 . 2 . S02 is a subset of S2 such that : i 2 S02 iff there exists j 2 S1 such that -LRB- -LRB- S1 ? f jg -RRB- -LSB- f ig -RRB- defines the same polyhedron as H1 . Our definition of widening is as follows . Let S1 and S2 be two sets of linear inequalities S1 = f 1 ; : : : ; kg ; S2 = f 1 ; : : : ; mg defining two polyhedra in IRn . Then S1 5 S2 = f l 2 S1 j S2 -RRB- lg S f i 2 S2 j S1 -RRB- i V 9j -LRB- -LRB- -LRB- S1 ? f jg -RRB- -LSB- f ig -RRB- -RRB- j -RRB- g These definitions are equivalent since finding the first group of inequalities , S01 , the elements of S1 satisfied by all points of H2 , in their definition is equivalent to finding the ones implied by S2 in our definition . The second group of inequalities S02 , namely the set of those elements i of S2 which do not change H1 when i replaces an element in S1 , are the same inequalities found in the second part of our definition . The equality of two closed convex polyhedra is decided by showing the double inclusion using both the system of inequalities and the system of generators -LRB- vertices and rays -RRB- , in other words the frame representation -LSB- CH78 -RSB- , in -LSB- HPR94 -RSB- . Our test for equality is much simpler . First we use only constraints without needing the system of generators . Second making use of the fact that they are not \ any '' two polyhedra we avoid checking S1 -RRB- 9j -LRB- -LRB- S1 ? f jg -RRB- -LSB- f ig -RRB- and S1 -LRB- 9j -LRB- -LRB- S1 ? f jg -RRB- -LSB- f ig -RRB- by checking only S1 -RRB- i V 9j -LRB- -LRB- -LRB- S1 ? f jg -RRB- -LSB- f ig -RRB- -RRB- j -RRB- . We can easily extend this definition of widening to act on constraint approximations . In Section 4 we defined widening between constraint approximations , rather than sets of constraints as above . Example 6 We can reconstruct the example given in -LSB- CC92 -RSB- concerning widening for linear inequality analysis , using our simpler implementation of widening . If H1 = fhx ; yi 2 IR2 j < = x < = 1 ^ y = g and H2 = fhx ; yi 2 IR2 j x < = 2 ^ < = y ^ y < = xg then S1 = f0 < = x ; x < = 1 ; y < = ; < = yg and S2 = fx < = 2 ; < = y ; y < = xg . The constraints in S1 implied by S2 are < = x , and < = y. fy < = x ; x < = 1 ; y < = ; < = yg -RRB- f0 < = xg and f0 < = x ; x < = 1 ; y < = ; < = yg -RRB- fy < = xg . The constraint < = y exists in both S1 and S2 . x < = 2 can not replace any constraint in S1 and meet the conditions . S1 5 S2 = f0 < = x ; < = yg -LSB- fy < = xg = f0 < = x ; < = y ; y < = xg where the redundant constraint < = x can be easily removed using the power of constraint solver . So S1 5 S2 = fhx ; yi 2 IR2 j < = y < = xg . Example 7 Argument-size analysis : As a final example , we take the following program discussed in -LSB- vG90 -RSB- and -LSB- CC92 -RSB- . p -LRB- X , X -RRB- . p -LRB- X , s -LRB- Y -RRB- -RRB- : - p -LRB- X , Y -RRB- We construct the following pre-interpretation , expressed as predicates domain/1 denotes/2 . domain -LRB- X -RRB- : - X > = 0 . denotes -LRB- s -LRB- N -RRB- , N1 -RRB- : - N1 = N +1 . The abstract compilation of the original program with this pre-interpretation is as follows . p -LRB- X , X -RRB- : - domain -LRB- X -RRB- . p -LRB- X , U -RRB- : - p -LRB- X , Y -RRB- , domain -LRB- X -RRB- , denotes -LRB- s -LRB- Y -RRB- , U -RRB- . The successive approximations produced with the widening and upper bound operations defined are as follows : P0 = ; P1 = fp -LRB- X ; Y -RRB- solve -LRB- p ; P0 -RRB- g = fp -LRB- X ; Y -RRB- < = X ; X = Yg P2 = P1 5 fp -LRB- X ; Y -RRB- solve -LRB- p ; P1 -RRB- g = P1 5 fp -LRB- X ; Y -RRB- f0 < = X ; X < = Y ; X > = Yg U1f0 < = X ; Y < = X + 1 ; Y > = X + 1g = fp -LRB- X ; Y -RRB- < = X ; X = Yg 5 fp -LRB- X ; Y -RRB- < = X ; X < = Y ; Y < = X + 1g = fp -LRB- X ; Y -RRB- < = X ; X < = Yg P3 = P2 5 fp -LRB- X ; Y -RRB- solve -LRB- p ; P2 -RRB- g = P2 5 fp -LRB- X ; Y -RRB- < = X ; X < = Y ; Y < = X + 2g = P2 6 Query-Answer Transforms and other Precision-Enhancing Transformations The aim of program analysis is often to derive information about specific computations , rather than all possible consequences of a program . In a bottom-up analysis framework , this can be achieved using query-answer transformations , which will be briefly described in this section -LSB- DR94 -RSB- , -LSB- Cod91 -RSB- . Well known examples of these are the ` magic ' set and ` Alexander ' transformations -LSB- BMSU86 -RSB- , but many variations on these are possible . More generally , such transformations allow top-down and bottom-up analyses to be mixed very flexibly . Transformations to increase the number of program points analysed can also be performed . As well as giving information about computations , goal-directed analyses can increase precision for the answers of goals . The trade-offs of precision and complexity can be accurately measured . 6.1 Left-Right Query-Answer Transformation The standard Prolog computation rule can be captured by a simple meta-program . The predicate left query defines the atoms selected using a left-right computation of an atomic goal < - G. left_query -LRB- G -RRB- . left_query -LRB- Bj -RRB- : - clause -LRB- A , B -RRB- , left_query -LRB- A -RRB- , split -LRB- B , Left , -LRB- Bj , Right -RRB- -RRB- , left_answer -LRB- Left -RRB- . split -LRB- -LRB- B , Bs -RRB- , true , -LRB- B , Bs -RRB- -RRB- . split -LRB- -LRB- B , Bs -RRB- , -LRB- B , Left -RRB- , Right -RRB- : - split -LRB- Bs , Left , Right -RRB- . split -LRB- B , true , -LRB- B , true -RRB- -RRB- : - atom -LRB- B -RRB- . The predicate split -LRB- B , Left , Right -RRB- is true if the conjunction Left is some left prefix of the clause body B , and Right is the remainder of B following Left . The clauses state that an instance of atom Bj in a clause body is selected if the head is selected and all atoms to the left of Bj are solved . The predicate left answer is defined by the following meta-program , based on the standard solve interpreter . left_answer -LRB- true -RRB- . left_answer -LRB- -LRB- G , Gs -RRB- -RRB- : - left_answer -LRB- G -RRB- , left_answer -LRB- Gs -RRB- . left_answer -LRB- A -RRB- : - left_query -LRB- A -RRB- , clause -LRB- A , B -RRB- , left_answer -LRB- B -RRB- . The only modification of the standard solve interpreter is that answers are restricted to those clause instances whose heads are queried . Thus left query and left answer are mutually dependent . Given a particular program and goal , the occurrences of clause and split in the interpreter can be completely unfolded and eliminated . Further unfolding of solve leads to a program similar to the ` magic ' transformation for that program and goal . The resulting program can be analysed bottom-up , resulting in a description of the left query and left answer atoms . These correspond to the call and success atoms respectively in a left-right computation of < - G. 6.2 Variations on basic Query-Answer Transformation The correct answers of logic programs are independent of the computation rule . So far as answer information is concerned , the computation rule is arbitrary . There is no need to stick to left-right computation . A version of the basic query-answer transformation incorporating right-to left computation can be defined similarly to the left-to-right version . The only difference is that the atoms to the right of a query Bj are answered rather than those to the left . The two transforms given above for left-right and right-left computation can be combined . A single extra clause can then be added . answer -LRB- A -RRB- : - left_answer -LRB- A -RRB- , right_answer -LRB- A -RRB- . The results for answer combine the precision of the left-right and the right-left computations . Note that using the optimisations based on strongly-connected components -LRB- SCCs -RRB- , the computations of the left answers and the right answers are completely independent since they are in separate SCCs neither of which depends on the other . Sometimes , left-right computation can give more precise results than right-left , and sometimes the other way round . It depends on the dataflow within the arguments of the program . Ideally , one would like to know which direction is more precise and perform the analysis in that direction , rather than going in both directions and taking the best . One can statically reorder the literals in a clause body prior to analysis One reordering that has proved useful in experiments can be achieved as follows : 1 . Generate the predicate dependency graph . 2 . Reorder each clause body so that \ higher '' predicates appear to the left of \ lower '' ones . 3 . Generate the left-right query-answer transformation of the resulting reordered program . Experiments show that the results are typically almost as precise as the combined left-right and rightleft analysis , at about half the computational cost . The rationale of this reordering is that information tends to be propagated from top to bottom of the dependency graph , since the starting point is the query . The effect of reordering is to delay calls to \ lower '' predicates until the \ higher '' ones have been solved . Other possibilities for source transformation prior to analysis include the addition of indices showing the position of each literal in the program text . More precise information can be obtained about queries to individual atoms in clause bodies . An index can simply be added to each query - and answer-literal in the query-answer transformation -LSB- Gal95 -RSB- . Also , separate results for each clause can simply be obtained by adding an extra predicate defining each clause body . 7 Implementation Considerations A prototype implementation has been made in SICStus-3 using the full power of CLP -LRB- Q , R -RRB- constraint solvers . The previous system described in -LSB- GBS95 -RSB- was used as a basis , and the domain-independent optimisations such as semi-naive evaluation and decomposition into strongly-connected components were carried over to the extended system . Operations over polyhedra , such as intersection , upper bound , inclusion , equivalence are effectively realised . Intersection of two convex polyhedra is a convex polyhedron consisting of the conjunction of the inequalities of the two convex polyhedra , and computed by solving this set of inequalities . Implication was implemented using the constraint solving facilities of SICStus-3 . Let S1 and S2 be two sets of linear inequalities S1 = f 1 ; : : : ; ng ; S2 = f 1 ; : : : ; mg defining two polyhedra in IRn . Since the constraint solver can only solve conjunctions of constraints , the constraints are written in conjunctive form . S1 -RRB- S2 ? S1 -RRB- 1 V : : : VS1 -RRB- m ? : S1 W 1 V : : : V : S1 W m ? : fS1 V : 1 V : : : VS1 V : mg : Negation of a single linear inequality is found by replacing < ; > = ; < > etc by < = ; > ; = respectively . The conjunction of the constraints is then solved . 8 Conclusions and Related Work We have explained a framework for analysis of -LRB- constraint -RRB- logic programs based on abstract compilation into constraint logic programs . This extends previous work -LSB- GBS95 -RSB- , -LSB- Gal95 -RSB- which handled mainly abstract compilation into Datalog programs . That approach was shown to be both practical and conceptually simple , and the current work considerably extends the possibilities of the approach . The first component of the method is the definition of a pre-interpretation capturing term properties of interest . We have clarified the kind of properties that naturally give rise to pre-interpretations . The second component is a set of techniques for approximation of constraint logic programs . Ramakrishnan and Ramakrishnan -LSB- RRS95 -RSB- have studied this general problem and our approach follows similar lines . But they did not yet consider the practicalities of handling infinite constraint domains such as arithmetic constraints , and this is essential for the power of the analysis method . We showed how our previous work on finite pre-interpretations and regular approximations could be integrated in this method . Techniques for integrating -LRB- and in some cases improving -RRB- constraint approximations by convex polyhedra were also outlined . Abstract compilation has been sued in several experiments in the literature , but one which is related more closely to ours -LRB- though it was not called abstract compilation -RRB- is the work of Mesnard -LSB- Mes95 -RSB- . He shows how to compile a logic program into a CLP -LRB- Q -RRB- program expressing size constraints of list arguments . Constraint-based analysis of the CLP -LRB- Q -RRB- program is then used to infer information about termination in the original program . Future work will focus on constructing analyses with our tools . Analysis of termination , complexity and types are among those which seem suitable . Improved approximation of arithmetic constraints will also be studied . Acknowledgements The ideas and experiments described in this paper developed partly out of discussions and joint work with Dmitri Boulanger , Marc Denecker , and Andr?e de Waal . References -LSB- AG94 -RSB- K. Apt and M. Gabbrielli . Declarative interpretations reconsidered . In P. Van Hentenryck , editor , Proceedings of the International Conference on Logic Programming -LRB- ICLP ' 94 -RRB- , Santa Margherita Ligure , Italy , MIT Press , 1994 . -LSB- BB94 -RSB- D. Boulanger and M. Bruynooghe . A systematic construction of abstract domains . In B. Le Charlier , editor , Proc . First International Static Analysis Symposium , SAS ' 94 , pages 61 -LCB- 77 , LNCS , Springer-Verlag , 1994 . -LSB- BBD94 -RSB- D. Boulanger , M. Bruynooghe , and M. Denecker . Abstracting s-semantics using a modeltheoretic approach . In M. Hermenegildo and J. Penjam , editors , Proc . 6th International Symposium on Programming Language Implementation and Logic Programming , PLILP ' 94 , pages 432 -LCB- 446 , LNCS , Springer-Verlag , 1994 . -LSB- BGLM94 -RSB- A. Bossi , M. Gabrielli , G. Levi , and M. Martelli . The s-semantics approach : theory and applications . J. Logic Programming , Special Issue : Ten Years of Logic Programming , Vols.19-20 :149 -LCB- 197 , 1994 . -LSB- BJ92 -RSB- M. Bruynooghe and G. Janssens . Deriving descriptions of possible values of program variables by means of abstract interpretation . Journal of Logic Programming , 13 -LRB- 2 & 3 -RRB- :205 -LCB- 258 , 1992 . -LSB- BMSU86 -RSB- F. Bancilhon , D. Maier , Y. Sagiv , and J. Ullman . Magic sets and other strange ways to implement logic programs . In Proceedings of the 5th ACM SIGMOD-SIGACT Symposium on Principles of Database Systems , 1986 . -LSB- CC92 -RSB- P. Cousot and R. Cousot . Comparing the Galois connection and widening/narrowing approaches to abstract interpretation . In Proceedings of the 4th International Symposium on Programming Language Implementation and Logic Programming , PLILP ' 92 , Leuven , Belgium , pages 269 -LCB- 295 , Springer-Verlag , 1992 . -LSB- CDY94 -RSB- M. Codish , D. Dams , and E. Yardeni . Bottom-up abstract interpretation of logic programs . Journal of Theoretical Computer Science , 124:93 -LCB- 125 , 1994 . -LSB- CH78 -RSB- P. Cousot and N. Halbwachs . Automatic discovery of linear restraints among variables of a program . In Proceedings of the 5th Annual ACM Symposium on Principles of Programming Languages , pages 84 -LCB- 96 , 1978 . -LSB- Cod91 -RSB- M. Codish . Abstract Interpretation of Sequential and Concurrent Logic Programs . PhD thesis , The Weizmann Institute of Science , 1991 . -LSB- DR94 -RSB- S. Debray and R. Ramakrishnan . Abstract Interpretation of Logic Programs Using Magic Transformations . Journal of Logic Programming , 18:149 -LCB- 176 , 1994 . -LSB- DW88 -RSB- S Debray and D.S. Warren . Automatic mode inference for logic programs . Journal of Logic Programming , 5 -LRB- 3 -RRB- :207 -LCB- 229 , 1988 . -LSB- Gal95 -RSB- J. Gallagher . A bottom-up analysis toolkit . In Proceedings of the Workshop on Analysis of Logic Languages -LRB- WAILL -RRB- ; Eilat , Israel ; -LRB- also Technical Report CSTR-95-016 , Department of Computer Science , University of Bristol , July 1995 -RRB- , June 1995 . -LSB- GBS95 -RSB- J. Gallagher , D. Boulanger , and H. Sa > = glam . Practical model-based static analysis for definite logic programs . In J. W. Lloyd , editor , Proc . of International Logic Programming Symposium , pages 351 -LCB- 365 , MIT Press , 1995 . -LSB- GdW94 -RSB- J. Gallagher and D.A. de Waal . Fast and precise regular approximation of logic programs . In P. Van Hentenryck , editor , Proceedings of the International Conference on Logic Programming -LRB- ICLP ' 94 -RRB- , Santa Margherita Ligure , Italy , MIT Press , 1994 . -LSB- HCCar -RSB- P. Van Hentenryck , A. Cortesi , and B. Le Charlier . Type analysis of prolog using type graphs . Journal of Logic Programming , -LRB- to appear -RRB- . -LSB- HPR94 -RSB- N. Halbwachs , Y. E. Proy , and P. Raymound . Verification of linear hybrid systems by means of convex approximations . In Proceedings of the First Symposium on Static Analysis , pages 223 -LCB- 237 , Springer-Verlag , September 1994 . -LSB- JBE94 -RSB- G. Janssens , M. Bruynooghe , and V. Englebert . Abstracting Numerical Values in CLP -LRB- H , N -RRB- . Technical Report CW189 , K.U. Leuven , Belgium , 1994 . -LSB- Mes95 -RSB- F. Mesnard . Towards automatic control for clp -LRB- O -RRB- programs . In Proceedings of the 5th International Workshop on Logic Program Synthesis and Transformation -LRB- LOPSTR-95 -RRB- ; Utrecht , Holland , pages 106 -LCB- 119 , Springer Lecture Notes in Computer Science , 1995 . -LSB- MS88 -RSB- K. Marriott and H. Sondergaard . Bottom-up abstract interpretation of logic programs . In Proceedings of the Fifth International Conference and Symposium on Logic Programming , Washington , August 1988 . -LSB- MS93 -RSB- K. Marriott and P.J. Stuckey . The 3 R 's of optimizing constraint logic programs : refinement , removal and reordering . In Proceedings of the 20th Annual ACM SIGPLAN - SIGACT Symposium on Princples of Programming Languages ; Charleston , South Carolina , pages 334 -LCB- 344 , January 1993 . -LSB- RRS95 -RSB- C.R. Ramakrishnan , I.V. Ramakrishnan , and R.C. Sekar . A symbolic constraint solving framework for analysis of logic programs . In Proceedings of PEPM-95 , 1995 . -LSB- vG90 -RSB- A. van Gelder . Deriving constraints among argument sizes in logic programs . In Principles of Database Systems ; Nashville , Tennessee , pages 47 -LCB- 60 , 1990 . -LSB- YS90 -RSB- E. Yardeni and E.Y. Shapiro . A type system for logic programs . Journal of Logic Programming , 10 -LRB- 2 -RRB- :125 -LCB- 154 , 1990 .

O O O O O O O O O O B I O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O B O O O O O O O O O O O O B I O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

abstract compilation
constraints
convex polyhedra
declarative semantics
static analysis