Definitionadvanced
Octagon abstract domain
Also called octagons.
A relational domain of constraints plus or minus x plus or minus y <= c, kept in a difference-bound matrix with cubic time closure.
The octagon domain describes the numeric names of a program by constraints of the form , such as or , together with bounds on one name. In the plane, such a set is a polygon with at most eight sides, which gives the domain its name. It keeps relations between names that the interval domain loses, but it costs much less than the polyhedra domain: space and time for its most expensive operation, for names. Antoine Miné introduced it in 2001. An octagon is stored as a difference-bound matrix over two copies of each name, one for and one for , so the closure of the matrix is a shortest-path computation followed by one extra step.
Definition
The order is the Cousot order: lower is more precise, and means that no state reaches the point. On the dataflow pages that use Kildall's convention the order is the other way round. The general framework is on the abstract domain page.
Octagonal constraints. Let the names be . An octagonal constraint is with , or . A bound on one name is the same as , so it needs no special case below.
The doubled names. For each name take two forms, and . For an index write for the index of the other form of the same name, so (flip the last bit) and . Each octagonal constraint becomes one or two differences :
| constraint | differences |
|---|---|
| and | |
| and | |
| and | |
The matrix. An octagon is or a matrix with entries in (or for rational names). The entry is a bound on , so is a difference-bound matrix over the forms. Its meaning is
The two differences in one row of the table are the same fact, since . A matrix is coherent when for all . Every operation below keeps matrices coherent, so half the matrix can be stored.
Strong closure. Many matrices have the same meaning. The difference-bound matrix page computes the tightest bounds of a DBM as all-pairs shortest paths with Floyd-Warshall. For octagons this is not enough, because the forms are linked by . From and follows , but no path in the graph of the matrix gives it. One more rule is needed. The entry bounds , and bounds , so
The strong closure is computed in two steps:
- Run Floyd-Warshall on , as on a DBM with vertices. If some diagonal entry becomes negative, the octagon is empty, and the result is .
- For all , set .
Miné's first algorithm applied the strengthening of step 2 inside every round of Floyd-Warshall. Bagnara, Hill and Zaffanella (2009) proved that one pass at the end gives the same result. Step 1 costs updates and step 2 costs , so the closure takes time. For a non-empty octagon over the rationals, for every pair: each entry is the best bound that the octagon implies. So two octagons have the same meaning if and only if they have the same strong closure, and the strong closure is a normal form.
Integers. Over the strong closure can miss facts, because means . The tight closure rounds each unary bound down to an even number between steps 1 and 2. The integer octagon is then empty exactly when step 1 finds a negative diagonal entry or, after the rounding, some . Bagnara, Hill and Zaffanella (2008) showed that this also takes time. This is notable, because integer linear constraints in general are NP-hard to solve.
Order, join and meet. Let and be octagons that are not .
- when for all . Over this is exact: it holds if and only if . Only the left side needs to be closed. Over it is exact only with the tight closure in place of : and have the same integer points, but .
- is the entry-wise maximum of and . Over it is the least octagon that contains both, so the join is the best one. Over this needs the tight closure of both arguments: with and on one side and and on the other, the strong closures give , while both sides have . The result is again strongly closed. The maximum of matrices that are not closed is still sound, but it can lose relations (see the examples).
- is the entry-wise minimum. It is exact: . It is not closed in general.
Abstraction. Over , the map is a Galois connection between sets of integer points and matrices. It is not a Galois insertion on all matrices, because many matrices share a meaning; on tightly closed matrices plus it is. Over the rationals, with rational bounds, there is no best abstraction in general: the sup of over the rational points of the disk is , and there is no least rational bound above it.
Transfer functions. On a closed matrix:
- is exact. Add to the bounds of , subtract it from those of , and do the reverse on column and . Cost .
- , and are exact. Forget (set its rows and columns to , except the diagonal), then add the new constraints, for example and . Cost , with the incremental closure for the few new constraints.
- Any other assignment forgets and then bounds it by interval arithmetic on the bounds of the operands. This is sound but not best.
- A guard is exact: take the meet with the constraint and close again, in time for one constraint. Other guards, such as , are applied through their interval bounds or ignored.
Widening and narrowing. The widening keeps the stable bounds and drops the others:
The right argument may be closed, and should be, for precision. The left argument must be the previous widened iterate exactly as it is, and must not be closed. Each strict widening step then turns at least one finite entry into , so a chain of widened iterates that starts from a matrix has at most strict steps. Closing the left argument can make entries finite again, and Miné (2006) gives a sequence where the iteration then never stops. The narrowing replaces only the entries: if , and otherwise.
Cost. An octagon takes entries, or about with coherence. Closure, and so an exact inclusion test or a join on unclosed inputs, costs . Join, meet, widening and the simple transfer functions cost on closed inputs.
Examples and non-examples
Strengthening. Take and , with and . Then and , and all other entries off the diagonal are . Floyd-Warshall finds no new bound, since no path leads from form 0 to form 3. Step 2 gives , which is .
An absolute value. The interval domain page analyzes this program, where the parameter x has the precondition :
entry:
t = x < 0
br t neg pos
neg:
y = 0 - x
jump join
pos:
y = x
jump join
join:
d = y - x
ret d
In neg the octagon holds and ; in pos it holds and . After closure each branch bounds all four sums and differences, and the join takes the larger bound of each.
| bound | neg |
pos |
join |
|---|---|---|---|
So d , and the true set is . The intervals give , because they lose and .
A loop with two counters.
entry:
x = 0
y = 10
jump head
head:
t = x < 10
br t body exit
body:
x = x + 1
y = y - 1
jump head
exit:
ret y
The analysis widens at head, the head of the loop in the weak topological ordering. The guard on the edge to body adds ; the guard on the edge to exit adds . Both assignments in body are exact.
| step | point | ||||
|---|---|---|---|---|---|
| 1 | head | ||||
| 1 | end of body | ||||
| 2 | head, before widening | ||||
| 2 | head, after widening | ||||
| 2 | end of body | ||||
| 3 | head | stable | |||
| exit | |||||
| head, after narrowing | |||||
| exit, after narrowing |
The relation is stable from the start, so the widening keeps it. With it, the guard in the body gives , and the exit gets after one narrowing step. Intervals alone get at exit, even with narrowing, because nothing bounds from below.
A join without closure. In the loop above, the state after entry holds only the unary bounds and . If the analyzer takes the entry-wise maximum with the state , without closing either matrix first, the entries for are in both, so the result is the box and the relation is gone. The join must close its arguments.
Not octagonal. The constraint has a coefficient 2, and has three names. An octagon can only keep their consequences of the form . The polyhedra domain keeps them exactly.
A widening that closes its left argument. Using in place of looks harmless, since has the same meaning as . It is not a widening: an entry dropped to by one step can come back as a finite sum of other entries after the closure, and Miné (2006) gives an increasing chain on which the iterates then never stabilize.
Related definitions
- Difference-bound matrix: the zones , used for the clocks of timed automata. An octagon is a DBM over the forms, with coherence and the extra strengthening step.
- Difference constraints: systems solved by shortest paths, the graph view behind both DBMs and octagons.
- Interval domain: the octagons with only unary constraints; an octagon analysis costs about times more per operation.
- Polyhedra domain: any linear constraints, more precise and exponential in the worst case. Octagons sit between intervals and polyhedra.
- Reduced product: octagons are often combined with other domains, such as congruences, by a reduced product.
- Widening operator and narrowing operator: the general definitions behind the octagon widening and narrowing.
References
- Antoine Miné, The octagon abstract domain, Higher-Order and Symbolic Computation 19(1), 2006, pages 31 to 100, the encoding of octagonal constraints in a difference-bound matrix over the positive and negative forms of each name, coherence, strong closure, the lattice operations, the transfer functions, and the widening whose left argument must not be closed
- Antoine Miné, The octagon abstract domain, Proceedings of the Eighth Working Conference on Reverse Engineering (WCRE 2001), IEEE, 2001, the first presentation of the domain and of its cubic closure
- Roberto Bagnara, Patricia M. Hill and Enea Zaffanella, Weakly-relational shapes for numeric abstractions: improved algorithms and proofs of correctness, Formal Methods in System Design 35(3), 2009, pages 279 to 323, the proof that one strengthening pass after the shortest-path closure gives the strong closure, and the semantic view of octagons as shapes
- Roberto Bagnara, Patricia M. Hill and Enea Zaffanella, An improved tight closure algorithm for integer octagonal constraints, VMCAI 2008, LNCS 4905, pages 8 to 21, the tight closure of integer octagons in cubic time, with the rounding of the unary bounds and the test for emptiness
- 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 RFWPGY Edit this page History Report an error Markdown