Definition
Abstraction and concretization are the two maps between the summaries computed by abstract interpretation §3.4, a kind of static analysis §3.1, and the program states described. Concretization sends a summary to the set of states it stands for. Abstraction sends a set of states to a summary that covers it. They form a Galois connection when, for every set of states and every summary , is at least as precise as exactly when contains all of . Then is the most precise summary covering .
The idea
A summary is only data. The interval is two numbers, and an analysis that stores it must say what it claims about the program: that the variable holds one of the integers 1, 2 or 3. Concretization is that meaning, written as a function. Without it, “the analysis is correct” has no content, because correctness means that the meaning of each computed summary includes every state a real run can be in at that point.
Abstraction goes the other way. Given an exact set of values, say , it picks the summary to store, and the natural choice is the most precise summary that still includes the set: the interval , which also admits 2 because an interval cannot leave a gap. The Galois connection condition says that the two directions agree. The question “does summary cover the set ?” gets the same answer whether it is asked about states, as , or about summaries, as .
A shop that sells boxes in a range of sizes, each of which fits inside the next, gives a fair picture. Concretization is the space inside a box. Abstraction is the smallest box in the range that holds a given object. The object fits in box exactly when its smallest box is no larger than . The picture stops being accurate when boxes come in different shapes: an object may fit a long thin box and a short wide box with no single smallest box that holds it. Some abstract domains §3.6 behave that way, and they have no abstraction map.
How it works
The setting has two ordered sets and two maps.
The concrete domain is , the set of all subsets of , where is the set of all states of the program. It is ordered by set inclusion §15.40 : a smaller set is a more precise claim.
The abstract domain is the set of summaries, with a partial order §19.2.6 in which means that is at least as precise as .
Concretization gives each summary its meaning. It is monotone: implies .
Abstraction gives each set of states a summary that covers it.
The Galois connection condition is for every set of states and every summary , where reads “exactly when”. It has four consequences.
Abstraction covers: . Take ; the left side holds, so the right side holds.
Abstraction is the best cover: whenever , also . So is at least as precise as every summary that covers .
Abstracting a meaning again loses nothing: . Take ; the right side holds, so the left side holds.
Each map determines the other. Because is the most precise summary with , a designer who has fixed has no freedom left in choosing .
When in addition for every summary , so that no two summaries stand for the same set, the pair is called a Galois insertion.
The connection is used to design abstract transfer functions, the counterparts of instructions on summaries. Let map a set of states to the set of states that one real instruction can produce from them, and let (read “F sharp”) be its counterpart on summaries. is sound when for every summary : the output covers every real result. The connection, applied with , turns this into the equivalent condition . The composition , which concretizes, applies the real instruction and abstracts again ( applies the right-hand map first), is therefore the most precise sound transfer function, called the best abstract transformer: no sound transfer function gives a more precise output for any summary.
Worked example
Use the interval domain for one integer variable. Its summaries are , which stands for the empty set, and the intervals with , whose bounds may be or . Concretization gives , the set of integers from to , and . Abstraction of a non-empty set of integers gives , with if has no smallest element and if it has no largest; .
Check the condition for , whose abstraction is .
With : contains 1 and 3, so holds; and holds because and . Both sides are true.
With : lacks 1, so fails; and fails because . Both sides are false.
Also , which contains and adds 2: abstraction covers, but it can lose information.
Now derive the transfer function for x = x + 1 on mathematical integers. Start from . Concretize: . Apply the instruction: . Abstract: . The same three steps for any give , the best abstract transformer for this instruction. The output would also be sound, since , but less precise. The output would be unsound, since it omits the real result 4.
For x = x * x with : , the squares are 1, 0, 1 and 4, so , and the best abstract transformer gives . A simpler rule multiplies the bounds as if the two factors were independent and takes the smallest and largest of , , and , giving . That rule is sound but less precise, because it forgets that both factors are the same number.
Stated precisely
Let be the set of program states and the set of its subsets, ordered by , and let be a partially ordered set of summaries. Maps and form a Galois connection when Equivalently: and are both monotone, for every , and for every . The pair is a Galois insertion when moreover for every .
Let be the real effect of an instruction on sets of states. A transfer function is sound when for every , which under a Galois connection holds exactly when for every . The conclusion for a whole program needs only , and the Abstract interpretation entry proves it: let now be one step of the whole program, a sound counterpart, monotone and the set of initial states. If a summary satisfies and , then every reachable state §3.21 lies in .
Limits and common mistakes
The connection does not make any code correct. It defines what the best transfer function is; each implemented must still be proved to satisfy the soundness §3.7 inclusion for every summary, including and unbounded intervals.
must be the machine’s real behavior. On a 32-bit unsigned register, x = x + 1 turns 4294967295 into 0, an unsigned wraparound §4.16. The rule is then unsound for : it claims an upper bound of 4294967296 and omits the real result 0. A sound rule returns the full range whenever exceeds 4294967295.
Abstracting after every step loses relationships between variables. After y = x with in , the interval domain stores in and in separately, so z = x - y gets , although is always 0. Each step used its best abstract transformer; the loss comes from abstracting between the steps. A relational domain §15.12, which records relations between variables, keeps .
Not every useful domain has an abstraction map. In the domain of convex polyhedra, regions bounded by flat sides, which in two dimensions are convex polygons, a disc has no smallest enclosing polygon: any polygon around a disc can be made smaller by cutting off a corner. Analyses with such domains use alone and state soundness with the inclusion above.
is a definition, not usually an algorithm §14.1. The set of reachable states is infinite or unknown, so an analysis never applies to it; it iterates and relies on the soundness inclusion. A correct initial summary, termination of the iteration and a faithful model of the machine are separate obligations.
Questions answered
What must an abstract transfer prove?
An abstract transfer function must prove that its output summary covers every state that the real instruction can produce from any state its input summary stands for. In symbols, for every summary . Here concretization maps a summary to the set of concrete states §3.5 it stands for, maps a set of states to the set of results of the real instruction, and is the abstract transfer function being checked.
When abstraction , which maps a set of states to its most precise covering summary, forms a Galois connection with , the same condition can be checked on summaries: , where means “is at least as precise as”. That is, the output may be no more precise than the best abstract transformer . For x = x + 1 and the input interval , the real results are 2, 3 and 4, so and are sound outputs and is not.
The proof must hold for every input summary, including the empty summary and unbounded intervals, and for the machine’s real arithmetic, including wraparound. The Galois connection does not supply this proof; each transfer function needs its own.
Related entries: Abstract interpretation (§3.4), Abstract domain (§3.6), Relational abstract domain (§15.12), Partial order, lattice, join, and meet (§19.2.6). Further reading: [68].