Theoremcore
MOP-MFP coincidence theorem
Also called Kildall's theorem, Kam-Ullman coincidence theorem.
In a distributive framework the maximal fixed-point solution equals the meet-over-all-paths solution; in a monotone one it is below it.
The MOP-MFP coincidence theorem compares the two answers of a dataflow analysis. The maximal fixed-point solution (MFP) is what an iterative solver computes. The meet-over-all-paths solution (MOP) is the ideal answer, the meet of the facts that each path produces. In every monotone dataflow framework, MFP is below MOP, so it is safe; in a distributive dataflow framework where every block is reachable, the two are equal. The definitions of the two solutions are on their own pages; this page states the theorem in full, proves it through an exact description of the iterates of the solver, and shows which hypotheses it needs.
Statement
The page uses the meet convention of Kildall and the dragon book. is a meet semilattice with top , means , and has finite height . Lower facts are weaker and safer. Turning the order upside down gives the join convention of abstract interpretation, where the same theorem speaks of least fixed points and joins.
The instance. A control flow graph with blocks and an entry block , a monotone transfer function for each block , and a boundary value . Let and for . The equation function is
where gives each block the fact at its start and the empty meet is . MFP is the greatest fixed point of .
Paths and walks. A walk of length is a sequence of blocks with for each . Its function is , the identity when . A path to is a walk with and . Write for the paths to of length less than , and for the walks of length exactly that end at , from any start block. Then
The iterates. at every block, and . Define the path bound
Theorem. For every instance of a monotone framework of finite height:
- for every and every block .
- The iterates reach MFP after finitely many steps, and for every block .
- If moreover every is distributive, , and every block is reachable from , then for every and , and .
Part 3 is the coincidence theorem. Part 1 gives more than the usual statement: the -th iterate is exactly the meet of the facts of the paths shorter than and of the facts that walks of length produce from . A backward problem is the same on the reverse CFG, with the ret blocks in place of .
In plain words
An analysis can be exact in two ways. The ideal way follows every route from the start to a point, works out what each route proves, and keeps only what all routes agree on. The practical way gives every point a note and lets neighbors exchange notes until nothing changes, so it combines facts where routes meet instead of at the end.
Combining early can only lose information, never invent it, so the practical answer is never wrong where the ideal one is right. The theorem says when it loses nothing: when the effect of each block on a combined fact is the same as combining the effects on each fact. The proof watches the note exchange round by round and shows that after a given number of rounds a note holds exactly what the short routes prove, plus a hopeful guess that shrinks each round.
Proof
Two facts are used. First, the iterates go down and stop: , and for some . This is proved on the maximal fixed-point solution page. Second, the meet over the infinite set of paths exists, because in a semilattice of finite height with a top every nonempty set has a greatest lower bound (proved on the distributive dataflow framework page); the meet of the empty set is .
Lemma 1 (splitting the last edge). For every and block :
- the paths to of length less than are the path when , together with the paths for an edge and a path ;
- the walks of length that end at are the walks for an edge and a walk ;
- in both cases and .
Proof. Remove the last block of a path or walk of length at least 1; what remains ends at a predecessor of and is one edge shorter. The only path of length 0 is . The function of a walk applies the function of each block except the last, so adding at the end adds on the outside.
Let be the set of the elements met in , that is . It is finite, since is finite and the lengths are bounded, so is a finite meet.
Lemma 2 (the meet of the set is nonempty when is reachable). If is reachable from , then is not empty for every .
Proof. For , the walk is in . For , take a path to of some length . If , then . Otherwise the last edges of form a walk in .
Part 1. Induction on . For , is empty and with the identity function, so . Assume for every . For each we have , so monotonicity gives . So is a lower bound of , and
By Lemma 1, the right side meets exactly the elements of : the term is the path , the term for changes nothing, and the other terms are and . So .
Part 2. Take with for all . Let be a path to of length , and . Then , so by part 1, . So is a lower bound of all path facts, and therefore . If no path reaches , then and the claim is trivial.
Part 3, the iterates. Repeat the induction of part 1 with equalities. The only step that was an inequality is . A distributive function satisfies for every , by induction on . By Lemma 2, is a nonempty finite set, so the step is an equality, and with we get . So . The nonempty condition matters: for the empty set the left side would be and the right side , and these differ for most functions.
Part 3, MOP is below MFP. We show for every . If for a path , this holds because is the meet over all paths. If for a walk with , take a path from to , which exists because is reachable. Joining and at gives a path to with . Since and is monotone,
So is a lower bound of , hence for every . With this gives , and part 2 gives the other direction.
A worked example. Take reaching definitions (meet , , ) on this loop, with the definitions of i in entry, of t in head and of i in body:
entry:
i = 0
jump head
head:
t = i < n
br t body exit
body:
i = i + 1
jump head
exit:
ret i
The edges are entry to head, head to body, body to head and head to exit. The iterates at head are , and . Part 3 predicts : no path to head is shorter than one edge, and the walks of length 1 that end at head are (entry, head), which gives , and (body, head), which gives . At the path (entry, head) gives and the only walk of length 2, (head, body, head), gives . The fixed point is also MOP: the path (entry, head) brings , and the path (entry, head, body, head) brings and .
Consequences
- Iterative solvers are exact for the bit-vector problems. The four classic gen-kill problems are distributive, so the worklist dataflow algorithm, round-robin iteration and every other fair order compute MOP on a CFG whose blocks are all reachable. How many rounds that takes is the subject of the Kam-Ullman iteration bound.
- An early stop is unsafe. By part 1, an iterate that is not yet stable still holds the terms of walks that start from the optimistic value. In the example, misses , which does reach
head. A solver must run to the fixed point before a client uses its facts. - Monotone frameworks are safe. Part 2 needs no distributivity and no reachability. So constant propagation, which is monotone but not distributive, has a safe MFP even where it is less precise than MOP.
- MOP is not computable in general. Kam and Ullman (1977) proved that no algorithm computes the MOP solution of every instance of every monotone framework. The fixed point is therefore the answer that analyses compute; the theorem says when it is also the ideal one.
- Interprocedural analysis. Across procedures the ideal answer is the meet over valid paths, in which returns match calls (see interprocedural dataflow analysis). The functional approach of Sharir and Pnueli and the IFDS framework and IDE framework reach that ideal for distributive problems, by the same argument applied to summary functions.
Tightness
- Distributivity is needed. Let and with , and let produce and . Build a diamond: the entry has the identity function and two successors and with the functions and , both go to a block with the function , and goes to an exit. The two paths give . MFP meets first, so and , which is strictly below by monotonicity and the choice of . Constant propagation with on one branch and on the other, followed by
z = x + y, is this case: MOP finds and MFP does not. Kam and Ullman (1977) showed that every monotone framework that is not distributive has an instance where MFP differs from MOP. - Reachability is needed. A block that the entry does not reach still passes its function value to its successors in every solution of the equations, while MOP ignores it. The distributive dataflow framework page gives an instance where this makes MFP strictly below MOP.
- Distributivity is not necessary on a given instance. If every block has at most one predecessor, the CFG is a tree, each block has exactly one path, no meet is ever taken, and MFP = MOP for every monotone framework.
- Finite height is needed for the finite iteration. Take with the meet and , an entry with the identity and , and a loop block with a self-loop and , which is distributive. The iterates at are and never stop. The greatest fixed point and MOP are both , but they are reached only in the limit. Abstract interpreters on such lattices use a widening operator.
History
Kildall (1973) set dataflow analysis in a semilattice with distributive transfer functions. He gave the iterative algorithm that starts from the top element and showed that it computes the meet over all paths. Kam and Ullman (1977) noticed that useful analyses, constant propagation first, are monotone but not distributive. They defined monotone frameworks, proved that the maximal fixed point exists and is below the meet over all paths, showed that every monotone framework that is not distributive has an instance with a gap, and proved that the meet over all paths cannot be computed in general. Textbooks give the result in both conventions: the dragon book with meets, and Nielson, Nielson and Hankin with joins and least fixed points.
References
- Gary A. Kildall, A unified approach to global program optimization, Proceedings of the 1st ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1973), 194-206, the whole paper (the lattice framework, the iterative algorithm from the top element, and the result that it reaches the meet over all paths when the functions are distributive)
- John B. Kam and Jeffrey D. Ullman, Monotone data flow analysis frameworks, Acta Informatica 7(3), 1977, 305-317, the whole paper (monotone frameworks, the maximal fixed point below the meet over all paths, a gap in some instance of every monotone framework that is not distributive, and no algorithm for the meet over all paths in general)
- Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman, Compilers, Principles, Techniques, and Tools, second edition, Pearson Addison-Wesley, 2007, Section 9.3.4 (Meaning of a Data-Flow Solution, the maximum fixedpoint against the meet-over-paths solution)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Section 2.4 (Equation Solving, the MFP and MOP solutions and when they agree), in the join convention
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 9MJ0B6 Edit this page History Report an error Markdown