Definitionadvanced
Convex polyhedra abstract domain
Also called Cousot-Halbwachs polyhedra, linear relation analysis.
A relational domain of conjunctions of linear inequalities between variables, precise but exponential in the worst case.
The polyhedra domain describes the numeric names of a program by a conjunction of linear inequalities with rational coefficients, such as and . The set of points that satisfy them is a convex polyhedron. It is the most precise of the classic numeric domains: it keeps every linear relation that holds on all paths through a join. Patrick Cousot and Nicolas Halbwachs introduced it in 1978, and it is also called linear relation analysis. Its cost is the price. A polyhedron is kept in two forms at once, as inequalities and as generators, and the size of either form can be exponential in the number of names .
Definition
The order is the Cousot order: lower is more precise, and means that no state reaches the point. The dataflow pages that use Kildall's convention turn it round. The framework is on the abstract domain page.
Polyhedra. A convex polyhedron in is a set for a rational matrix and vector . An equality is a pair of inequalities. The elements of the domain are the polyhedra, with the empty one as and as . For a program over integers, . This is sound, but integer facts that need rounding, such as being impossible, are lost unless the analyzer adds them.
The double description. By the Minkowski-Weyl theorem, every polyhedron also has a generator form
with points , rays and lines . A double description of is a pair (a constraint system , a generator system ) that describe the same polyhedron. The name and the method come from Motzkin, Raiffa, Thompson and Thrall (1953). Each operation uses the form in which it is easy, and the conversion from one form to the other is done by Chernikova's algorithm, which adds one constraint (or one generator) at a time and keeps both forms in step. A system is minimal when no constraint (or generator) can be dropped; for a polyhedron of full dimension the minimal constraint system is unique up to scaling, one inequality per facet.
Order, meet and join.
- when every generator of satisfies every constraint of : points satisfy them, rays satisfy , and lines satisfy . This is exact inclusion.
- is the union of the two constraint systems. It is exact.
- is the union of the two generator systems. It gives the closed convex hull of , the least polyhedron that contains both. A union of two polyhedra is not convex in general, so the join loses precision, but it is the best that the domain can do.
Abstraction. There is no best abstraction in general. The disk is contained in polyhedra that come closer and closer to it, and no least one exists; the Galois connection page shows this. So the domain is used with a concretization only, and soundness is proved operation by operation.
Transfer functions.
- Guard : add the constraint (a meet). Exact. A strict guard over integer coefficients and integer names is the same as . A nonlinear guard is ignored or replaced by a linear consequence.
- Forget : add the line to the generators. On the constraint side this is Fourier-Motzkin elimination of , which can square the number of constraints in one step.
- Assignment with : the map is invertible, so substitute in the constraints, or apply the map to the generators. Exact.
- Assignment with : forget , then add the equality . Exact.
- Any other assignment: forget , then add what is known, for example interval bounds. Sound.
Widening. The domain has infinite ascending chains, so it needs a widening. Let be a minimal constraint system of . The standard widening of Cousot and Halbwachs, as completed by Halbwachs (1979), is
The first part keeps the constraints of that are stable. The second part was added because a polyhedron of lower dimension has many minimal systems: its equalities can be written in many ways, and the first part alone would give results that depend on the choice. A strict step either raises the dimension of the polyhedron or drops at least one constraint, which can happen only finitely often, so the widened chain stops. Bagnara, Hill, Ricci and Zaffanella (2005) define widenings that are never less precise than this one. Delayed widening (join for the first few steps) and widening with thresholds are often used with polyhedra.
Cost. Meet, guard and the constraint side of inclusion are linear in the size of the constraint system; join and forget are linear in the size of the generator system. Inclusion costs . The conversion between the forms is the expensive part, and so is keeping the systems minimal. Each form can be exponential in while the other is small, as the examples show. The total cost of an analysis is therefore exponential in the worst case, and in practice analyzers split the names into small groups that are known to be related, and keep one polyhedron per group.
Examples and non-examples
A loop with a linear relation.
entry:
x = 0
y = 0
jump head
head:
t = x < 10
br t body exit
body:
x = x + 1
y = y + 2
jump head
exit:
ret y
Write for the value at head after steps and for the value computed from entry and the end of body.
| step | value at head |
how |
|---|---|---|
| 0 | the point | from entry |
| 1, before widening | the segment , | join of and |
| 1, after widening | , | standard widening, see below |
| 2 | stable: gives , | the guard , then and |
| exit | , | the guard |
| exit, after one decreasing step | , | head becomes , so |
At step 1, is a point. If its minimal system is written as , , , , the first part of the widening keeps only and . The second part adds and from the segment, because each can replace or in the system of the point without changing it. So the standard widening keeps . With the first part alone, the head would become the quarter plane , , and the exit would get only and after one decreasing step (a narrowing of the simplest kind). A delayed widening, which joins once before it widens, also keeps , since the segment of step 1 has the stable equality in every minimal system. Neither intervals nor octagons can express ; octagons would keep only bounds such as .
The cross-polytope: exponentially many constraints. Join the points . The result is the cross-polytope
Each of the inequalities defines a facet: it holds with equality at the points , which are affinely independent, and has full dimension. Different sign vectors give different facets. So the minimal constraint system has exactly rows, while the generator system has points. An analysis that joins simple states and then applies one guard must convert to constraints and write rows.
The hypercube: exponentially many generators. The box has constraints and vertices, each a point of every generator system. An analysis that adds interval guards and then joins the result with one point must write points. Together the two families show that neither form is small in the worst case, and that converting between them takes exponential time just to write the output.
Not a polyhedron. The set and the set have no exact polyhedral description. The first one is not convex; its best linear facts on a bounded range come from the join of sample points. The second needs a congruence domain, which is often combined with polyhedra by a reduced product.
Not a join. Taking the union of the two constraint systems as the join gives the intersection, which is unsound. Taking only the constraints common to both systems (as written) is sound but depends on how the constraints are written: in one state and in the other would be dropped.
Related definitions
- Interval domain and octagon domain: the polyhedra whose constraints have one name, or two names with coefficients . They cost polynomial time per operation.
- Minkowski-Weyl theorem: every polyhedron is both an intersection of half-spaces and the sum of a polytope and a cone, the fact behind the double description.
- Fourier-Motzkin elimination: projection on the constraint side, used to forget a name.
- Convex hull: the join of the domain.
- Widening operator and narrowing operator: the general definitions behind the standard widening.
References
- Patrick Cousot and Nicolas Halbwachs, Automatic discovery of linear restraints among variables of a program, POPL 1978, pages 84 to 96, the polyhedra domain, the convex hull as join, the transfer functions for linear assignments and tests, and the widening that keeps the stable constraints
- Nicolas Halbwachs, Détermination automatique de relations linéaires vérifiées par les variables d'un programme, thèse de troisième cycle, Université scientifique et médicale de Grenoble, 1979, the standard widening, with the constraints of the new polyhedron that can replace a constraint of the old one, and the use of the double description
- T. S. Motzkin, H. Raiffa, G. L. Thompson and R. M. Thrall, The double description method, in H. W. Kuhn and A. W. Tucker (eds.), Contributions to the Theory of Games II, Annals of Mathematics Studies 28, Princeton University Press, 1953, pages 51 to 73, the method that keeps a cone both as a system of inequalities and as a set of generating rays, and adds one inequality at a time
- Roberto Bagnara, Patricia M. Hill, Elisa Ricci and Enea Zaffanella, Precise widening operators for convex polyhedra, Science of Computer Programming 58(1-2), 2005, pages 28 to 56, the statement of the standard widening, its termination, and a family of widenings that are never less precise
- Xavier Rival and Kwangkeun Yi, Introduction to Static Analysis, An Abstract Interpretation Perspective, MIT Press, 2020, Chapter 3 (relational abstract domains for numeric states, among them octagons and convex polyhedra)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag FC44XR Edit this page History Report an error Markdown