Definitioncore
Abstract domain
Also called abstract lattice.
A lattice of abstract properties with a concretization map and sound abstract versions of the program operations, join and widening.
An abstract domain is a set of machine-readable descriptions of sets of program states, together with the operations that an analyzer needs on them: an order, a join, sound versions of the program instructions, and a widening. Each description has a meaning , the set of states it allows. The domain fixes what an analysis can say. The interval domain can say and cannot say ; the polyhedra domain can say both, at a higher cost.
Definition
The concrete side is the collecting semantics: for each program point, a set of environments, ordered by inclusion. This page uses the Cousot order: lower is more precise, and describes the empty set of states. The dataflow pages, such as monotone dataflow framework, use the dual order of Kildall, where the meet combines paths and the top element means "unreachable".
An abstract domain for the set of environments is a tuple with these parts and conditions.
- Elements and order. is a set with a preorder , and a program can decide . Often is a lattice, but it need not be complete, and two representations of the same set may be equivalent without being equal.
- Concretization. is monotone: implies .
- Extremes. and .
- Join. is an upper bound of and that a program can compute. It is sound: . It need not be the least upper bound, and is often larger than the union.
- Transfer functions. For each instruction there is , and for each branch condition there is . Each one is sound: for every ,
- Widening. If has an infinite strictly ascending chain, a widening operator is part of the domain. Without it the iteration may not stop.
These parts are optional: a meet with , a narrowing operator, and an abstraction that gives the best description of each set. When exists and , the pair is a Galois connection. The definition does not require it: the polyhedra domain has no best description of a disk.
From local conditions to a sound result. For an edge , let be the composition of the transfer functions of the instructions of , followed by of the branch condition that selects (or of its negation). Let satisfy . Define on maps in the same shape as the concrete :
Claim. For every , pointwise.
Proof. First, a composition of sound steps is sound. If and the same holds for , then, since the concrete is monotone,
By induction on the length of the block, . Second, a join of sound terms is sound. If for each , then , by condition 4 and induction on the number of terms. The entry term is covered by . Put the two parts together at each .
Consequence. If pointwise, then , by the claim and condition 2. So is an element with , and the least fixed point is below it: . The abstract interpretation page gives this last step as its soundness theorem; Knaster-Tarski calls such an a pre-fixed point, and Cousot calls the abstract with a post-fixed point. Two points matter in practice. The proof does not use the monotonicity of , so a non-monotone transfer function or a widening does not break soundness. And a map with is a certificate: to check it, a program evaluates once and tests at each point.
Non-relational and relational domains. A non-relational domain keeps one value description per name. It is built from a value domain that describes sets of integers: , with the pointwise order and
A map in which one name has the empty description describes no state, so it is identified with . A relational domain describes sets of tuples directly, and it can keep a relation between names, such as or .
Examples and non-examples
Parity. The value domain has four elements, , with the even integers and the odd ones. Its sum gives when both arguments are equal and not , and when they differ; its product gives when one argument is and when both are . Both are the best transformers: a check over all argument pairs gives exactly these results. Analyze this program with the parameter n:
entry:
x = 1
jump head
head:
t = x < n
br t body exit
body:
x = x + 2
jump head
exit:
y = x * x
ret y
At head the first pass gives from the entry edge, and the body edge gives , so the second pass changes nothing. The domain has finite height, so no widening is needed. At exit : the program always returns an odd number. The guard x < n gives no parity information, so its transfer function is the identity.
A table of common domains. All of these are domains in the sense above. The height is that of the value lattice of one name, and is the number of names.
| domain | kind | height | example fact | cost of one operation |
|---|---|---|---|---|
| sign | non-relational | 2 | ||
| parity | non-relational | 2 | odd | |
| constants (constant propagation) | non-relational | 2 | ||
| intervals | non-relational | infinite | ||
| octagons | relational, weakly | infinite | , | for closure |
| convex polyhedra | relational | infinite | , | exponential in in the worst case |
The constant lattice has height 2 but infinite width, so its iteration still stops. The interval, octagon and polyhedra domains need a widening.
Non-relational loses relations. Two runs reach a point with and . Intervals give and , which also allows , so they cannot prove . Octagons keep exactly.
Non-example: an unsound transfer function. Take the sign domain and define . Then contains 1 and 2, and is not in . Condition 5 fails, and an analysis with this rule can prove that y = x - z is positive when it is not. The sound rule gives .
Non-example: an order that does not follow the meaning. Order intervals by their width: because . Then is not inside , so is not monotone and condition 2 fails. A test in this order proves nothing about the program.
Non-example: a join that is too small. Use the intersection of intervals as the join. Then , and the point after an if with these two branches would look unreachable. Condition 4 fails. Any computable upper bound is acceptable, but a lower bound is not.
Related definitions
- Collecting semantics: the concrete meaning that the domain approximates, and the target of the soundness claim.
- Galois connection: the extra structure when each set of states has a best description; it gives the best transfer function .
- Widening operator and narrowing operator: the operators that make the iteration stop on domains of infinite height, and then recover precision.
- Interval domain, octagon domain and polyhedra domain: three numeric domains, in order of growing precision and cost.
- Reduced product: a way to combine two domains, with a reduction that passes facts from one to the other.
- Join-semilattice: the order structure that most domains have.
- Abstract interpretation: the general technique that runs a program over an abstract domain.
- Predicate abstraction and three-valued logic shape analysis: domains whose elements are formulas over chosen predicates, and logical structures for the heap.
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 an abstract interpretation as a lattice of abstract contexts with abstract operations, its consistency with the static semantics, and the widening for lattices with infinite ascending chains
- Patrick Cousot and Radhia Cousot, Abstract interpretation frameworks, Journal of Logic and Computation 2(4), 1992, pages 511 to 547, the frameworks that use a concretization function only, with no best abstraction, and their comparison with the Galois connection framework
- Patrick Cousot and Radhia Cousot, Systematic design of program analysis frameworks, POPL 1979, pages 269 to 282, the design of abstract domains and of their combinations from the concrete semantics
- Xavier Rival and Kwangkeun Yi, Introduction to Static Analysis, An Abstract Interpretation Perspective, MIT Press, 2020, Chapter 3 (abstract domains for sets of states, the non-relational and relational domains, and the soundness of the abstract operations)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Chapter 4 (Abstract Interpretation), the property spaces and the correctness relations
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 KJGF11 Edit this page History Report an error Markdown