Definitionadvanced
Narrowing operator
Also called narrowing in abstract interpretation.
An operator applied after widening that refines a post-fixed point downward while staying sound, in finitely many steps.
A narrowing operator refines the result of a widened analysis. The widening stops at an element with , often far above the least fixed point. Each narrowing step moves the value down toward of the value, but only so far that the result stays above the least fixed point and the steps stop after finitely many. On intervals the usual narrowing replaces an infinite bound by the finite bound that computes, and keeps every finite bound.
Definition
The setting is an abstract domain in the Cousot order and a monotone abstract function . The widening operator page explains how to reach the start point.
A narrowing is a map with two properties.
- Between the arguments. For all with : .
- Stabilization. For every decreasing chain , the chain , is eventually stationary.
The narrowed iteration. Start from with , for example the result of the widened iteration. Set , and stop when .
Theorem (soundness is kept). For every : and . Hence when is a complete lattice, and contains the collecting semantics when is sound.
Proof. By induction on . For , holds by the choice of . Assume . Property 1 with and gives
Since is monotone and , we get . This closes the induction. Each is an element with , so the Knaster-Tarski theorem puts below it, and the claim on the abstract domain page gives .
In the naming of the Knaster-Tarski page each is a pre-fixed point; Cousot calls it a post-fixed point. Either way, every step of the narrowed iteration is a sound result, so an analyzer may stop at any step, for example when a time budget runs out.
Theorem (termination). The narrowed iteration stops.
Proof. Put and . The chain is decreasing by the first theorem, so is decreasing by monotonicity, and . So is a decreasing chain, and . By property 2 the chain is eventually stationary, so some step has .
The monotonicity of is used in both proofs. Without it, may fail , and the narrowed value may be unsound. The widening has no such need in its stronger form.
The interval narrowing. For intervals,
Property 1: if , then and , and the new lower bound is or , both between and ; the upper bound is the same. Property 2: a finite bound never changes, and an infinite bound changes at most once, to a finite one. So a chain of narrowed values changes at most three times: once for each bound and once to . On a map from names to intervals the narrowing works name by name, and the chain changes at most times for names.
A narrowing is not a meet. For the meet gives , which is the plain decreasing step . It satisfies property 1 but not property 2, as the second example below shows. A narrowing may stop above , and the interval narrowing does so whenever a finite bound could still go down.
A narrowing is not a dual widening. A narrowing never jumps below its second argument; it stops early instead. To compute a greatest fixed point from above, which some backward analyses need, an analyzer uses a dual widening: an operator that jumps downward and makes every decreasing chain stop.
Examples and non-examples
Continuing the widened loop. The loop that sums i from 0 to 9 into s is on the widening operator page. The widening stops at with , at the loop head.
| step | at head | ||
|---|---|---|---|
| 0 | , | , | , |
| 1 | , | , | no change |
The infinite upper bound of i becomes 10. The upper bound of s stays infinite, because itself gives : here is the least fixed point of , and the bound on s is lost by the domain. At the exit the guard gives , .
Plain decreasing iteration may not stop. Take on intervals, the equation of a loop head that only its back edge reaches. Its least fixed point is . Start from , which satisfies . The plain decreasing steps give
and never stop. The interval narrowing gives , because the lower bound is finite, and it stops at once with a sound result.
The narrowing keeps a finite bound that is too large. Analyze the loop i = 0; while i < 10: i = i + 1 with a widening with the threshold list . The widening gives , and then . The interval narrowing gives and stops, because both bounds are finite. One plain decreasing step gives . For this reason many analyzers use a fixed number of plain steps after the widening, for example one or two; a bounded number of steps always stops, and each step is sound by the first theorem.
Non-example: a narrowing that goes below its second argument. The map makes every chain stop at once, but is in general strictly below , so property 1 fails. The result describes no state, and the analysis would claim that the loop head is unreachable. The lower bound is what keeps soundness in the proof above.
Related definitions
- Widening operator: the upward phase that gives the start point of the narrowed iteration.
- Interval domain: the domain of the examples, with its transfer functions.
- Weak topological ordering: the order of the blocks; the narrowed iteration uses the same order and the same set of heads.
- Abstract domain: the claim that any with is sound.
- Knaster-Tarski theorem: the least fixed point lies below every such .
- Abstract interpretation: the general technique, with a decreasing step on a worked loop.
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 narrowing and the downward iteration that starts from the limit of 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 decreasing iteration on intervals that refines the infinite bounds found by the widening
- 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 use of widening and narrowing together, and the dual operators for iterations from above
- Xavier Rival and Kwangkeun Yi, Introduction to Static Analysis, An Abstract Interpretation Perspective, MIT Press, 2020, Chapter 3 (the refinement of loop invariants after widening) and Appendix B (the soundness proofs)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Chapter 4 (Abstract Interpretation), the treatment of narrowing operators after the widening
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 AZWD5B Edit this page History Report an error Markdown