Definitioncore
Widening operator
Also called widening.
An upper bound operator whose iteration stabilizes in finitely many steps, used to force fixed-point iteration on infinite height domains to end.
A widening operator takes the current approximation of a loop invariant and a new value , and returns an upper bound of both that grows in big jumps, so that any chain of widened values stops after finitely many steps. It lets an analysis over a domain of infinite height, such as intervals, reach an element with in a few steps, where plain iteration would run forever. A widening is not a join: it is not monotone, not commutative, and it gives up precision on purpose.
Definition
The setting is an abstract domain in the Cousot order (lower is more precise) and an abstract function , for example the abstract transfer function of a loop. The general idea and the interval widening are on the abstract interpretation page; this page gives the definition, the proofs and the properties.
A widening is a map with two properties.
- Upper bound. For all : and .
- Stabilization. For every increasing chain , the chain , is eventually stationary: there is a with for all .
Some texts require property 2 for every sequence , increasing or not. That stronger form is needed when is not monotone. The interval widening has it: each bound of can move only once, to an infinity, whatever is.
The widened iteration. Start from . At step , if , stop and return . Otherwise set .
Theorem (termination). If is monotone, the widened iteration stops, and it returns an element with .
Proof. Suppose the iteration never stops. Put and . Then and . By property 1, for each , so is increasing. Since is monotone, is increasing too, and is below . So is an increasing chain, and is its widened chain. By property 2 there is a with . Then, by property 1,
so the stop test holds at step , which contradicts the assumption. The iteration therefore stops at some , and the stop test is exactly .
With the stronger form of property 2 the same proof works without the monotonicity of .
Soundness of the result. The result has . By the claim on the abstract domain page, contains the collecting semantics when is sound; that proof does not use monotonicity either. When is monotone on a complete lattice, the Knaster-Tarski theorem also gives . Such a is a pre-fixed point in the naming of that page, and a post-fixed point in the naming of Cousot. It need not be a fixed point, and it is often above ; a narrowing then improves it.
Where to widen. In a program with many blocks, works on a map from blocks to . It is enough to widen at a set of blocks that cuts every cycle of the control flow graph, and to use the join elsewhere. The heads of a weak topological ordering form such a set, and that page proves that the iteration then stops.
A widening is not monotone. For intervals, , but
and . So a more precise first argument can give a less precise result: the widening looks at how far a bound moved, not only at where it ended. In practice this means that the result of an analysis depends on the order of the iteration, and that a more precise input fact can give a less precise output.
A widening is not a join. The join is commutative and gives the least upper bound. The interval widening is neither:
The first argument is the old value and the second is the new one; the order matters. Using the join in place of the widening loses termination, and using the widening in place of the join at every block loses precision for nothing.
Widening against finite domains. A widening on a domain of infinite height can prove more than any finite domain. Take the family of programs : x = 0, then while x < n: x = x + 1, for each constant . Intervals with widening and one narrowing step give at the loop head, the exact set . Now fix a finite domain with a concretization . To prove at the head of , an analysis must return some with , so . The sets differ for different , so the elements are pairwise different, and has infinitely many elements. This contradicts the choice of . So for each finite domain, some program of the family has an invariant that it cannot prove; Cousot and Cousot (1992) make this point in general.
Examples and non-examples
A loop with two names. The loop sums i into s.
entry:
i = 0
s = 0
jump head
head:
t = i < 10
br t body exit
body:
s = s + i
i = i + 1
jump head
exit:
ret s
At head, joins the entry state () with the body applied to after the guard . The widening is applied at head only, name by name.
| step | at head | stop? | |
|---|---|---|---|
| 0 | , | no | |
| 1 | , | , | no |
| 2 | , | , | no |
| 3 | , | , | yes |
Step 0 gives . At step 1 the upper bound of i moves, so it jumps to ; s does not move. At step 2 the upper bound of s moves and jumps. At step 3 the test passes. The exit state is , . The narrowing operator page continues from here and gets at the exit.
Plain iteration does not stop on the same loop. Without widening, the iterates at head are and for , which reaches and . From then on i stays at , and each step adds the upper bound 9 of i to the upper bound of s: 54, 63, 72, and so on, without end. The loop runs ten times, but the interval domain does not know that and are linked. Here the least fixed point of is , , and it is the limit of an infinite chain. The bound is lost by the domain, not by the widening.
Delayed widening. A common variant uses the join for the first steps and the widening after that. With in the loop above, the first widening takes the old value , and the new value , ; both upper bounds jump at once, and the result is the same. In a loop whose bounds stop moving after a few passes, the delay keeps the exact bounds.
Thresholds. A widening with thresholds moves a bound to the next value of a fixed list, such as the constants of the program, before it moves it to infinity. With the list the first widening in the table gives , and the exit state gets with no narrowing step. Each bound can move at most once per threshold plus once to infinity, so property 2 still holds.
Widening on other domains. The standard widening of the polyhedra domain keeps the constraints of the old polyhedron that the new one still satisfies; it terminates because each strict step either raises the dimension or drops a constraint. The octagon domain has a widening that works on the matrix of bounds, and its first argument must not be closed between steps, or the chain can grow forever.
Non-example: the join on intervals. The join is an upper bound, so property 1 holds. On the chain the joined chain is the chain itself, which never stops. Property 2 fails.
Non-example: a jump to . The map when , and otherwise, is a widening: it is an upper bound, and a chain can change at most once. It is also useless: it gives in the loop above and loses the lower bound . A good widening keeps every bound that has not moved.
Related definitions
- Narrowing operator: the decreasing phase after the widening, which recovers some of the lost precision.
- Weak topological ordering: where to place the widenings and in which order to iterate.
- Interval domain, octagon domain and polyhedra domain: domains of infinite height, each with its own widening.
- Abstract interpretation: the general technique and the interval widening.
- Kleene fixed-point theorem: the plain iteration from , which reaches the least fixed point only as a limit when the domain has infinite chains.
- Fixed point and Knaster-Tarski theorem: the reason a widened result lies above the least fixed point.
References
- Patrick Cousot and Radhia Cousot, Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints, POPL 1977, pages 238 to 252, the definition of a widening by its upper bound property and the stabilization of every widened increasing chain, and the upward iteration with widening
- Patrick Cousot and Radhia Cousot, Static determination of dynamic properties of programs, Proceedings of the Second International Symposium on Programming, B. Robinet (ed.), Dunod, Paris, 1976, pages 106 to 130, the first widening, on intervals, used to analyze loops in finitely many steps
- Patrick Cousot and Radhia Cousot, Comparing the Galois connection and widening/narrowing approaches to abstract interpretation, PLILP 1992, LNCS 631, pages 269 to 295, the argument that widenings on domains of infinite height give results that no single finite abstract lattice gives for all programs
- 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 standard widening on polyhedra and a framework for widenings that are more precise
- Xavier Rival and Kwangkeun Yi, Introduction to Static Analysis, An Abstract Interpretation Perspective, MIT Press, 2020, Chapter 3 (the analysis of loops with widening) and Appendix B (the soundness proofs, including the widening iterates)
Where this leads
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 AKGMSN Edit this page History Report an error Markdown