Definitioncore
Monotone dataflow framework
Also called monotone framework, Kam-Ullman framework.
A dataflow problem given by a semilattice of facts of finite height, a direction and monotone transfer functions for the nodes.
A monotone dataflow framework is the general form of a dataflow analysis: a semilattice of facts with no infinite descending chains, together with a set of transfer functions that are monotone, contain the identity and are closed under composition. Kam and Ullman (1977) defined it to cover analyses such as constant propagation that fail Kildall's condition of distributivity. This page gives the definition and what follows from monotonicity alone. The stronger distributive dataflow framework adds ; the gen-kill problems are the distributive bit-vector special case; the answers are defined on meet-over-all-paths solution and maximal fixed-point solution, and the solver is the worklist dataflow algorithm.
Definition
This page uses the meet convention of Kildall and the dragon book. A partial order is reflexive, antisymmetric and transitive. A meet semilattice is a set with an operation that is idempotent, commutative and associative. It defines the order , and is then the greatest lower bound of and . The element is the identity of meet, so for all . Lower facts claim less. A strict descending chain is , and the height of is the largest number of strict steps in such a chain.
The framework. A monotone dataflow framework is a triple where:
- is a meet semilattice with a top element in which every strict descending chain is finite. Most texts, and the bounds on these pages, ask for the stronger condition that the height is finite.
- is a set of functions , and each is monotone: implies .
- contains the identity function and is closed under composition.
Condition 3 makes the function of a path, the composition of the functions of its blocks, a member of ; the empty path has the identity.
An equivalent form of monotonicity. A function is monotone if and only if for all .
Proof. Assume is monotone. Since and , we get and . So is a lower bound of and , and it is below their greatest lower bound . Conversely, assume the inequality and let . Then , so .
So a monotone function may lose information at a meet: applying after the meet can give a strictly lower fact than meeting the results of . A distributive function never does.
An instance. An instance of the framework is a control flow graph with blocks and edges, a direction (forward or backward), a map , and a boundary value . A forward instance starts at the entry block. A backward instance runs on the reverse CFG and starts after each block that ends in ret. The boundary value describes what is known where the program starts (forward) or ends (backward). It is chosen by the problem, and it is only by coincidence.
The equations. For a forward instance, with the empty meet equal to :
A backward instance has the same equations on the reverse CFG, with in the meet of each exit block.
The two answers. The ideal answer is , the meet over all paths from the start to . The equations have a greatest solution, the maximal fixed point MFP, and iteration from computes it. In every monotone framework MFP MOP, so the computed answer is safe. The proofs are on the maximal fixed-point solution page.
Soundness. Assume that each is a safe description of block : if a fact holds before the block runs, then holds after it. Every execution follows some path of the CFG, so the fact after an execution is at least for its path , and MOP and MFP are below that. Paths of the CFG that no input follows only lower the answer, which keeps it safe.
Precision. MFP can be strictly below MOP. In constant propagation, let one branch set and the other , and let them join before z = x + y. On each path the transfer function gives , so MOP gives . MFP meets first: and both become "not a constant", and then is "not a constant" too. Here .
Cost. Each fact can fall at most times. A worklist solver therefore applies transfer functions and meets. MOP itself is not computable in general: Kam and Ullman (1977) show that no algorithm computes the MOP solution of every instance of every monotone framework.
Examples and non-examples
The four bit-vector problems. Each is a monotone framework whose lattice is the set of subsets of a finite universe , with height . The transfer functions have the form , which is monotone (in fact distributive, as the gen-kill problem page proves).
| problem | direction | may or must | meet | order | boundary | start value elsewhere | ||
|---|---|---|---|---|---|---|---|---|
| reaching definitions | forward | may | all definitions | at the entry | ||||
| live variables | backward | may | all variables | after each exit | ||||
| available expressions | forward | must | all expressions | at the entry | all expressions | |||
| very busy expressions | backward | must | all expressions | after each exit | all expressions |
On the running example of dataflow analysis the universes have 7 definitions, 7 variables (n, x, i, s, t, a, u) and 5 expressions (i < n, x * 2, i & 1, s + a, i + 1), so the heights are 7, 7, 5 and 5.
Constant propagation. For each variable the lattice is flat: ("no value seen yet") above every integer, and every integer above ("not a constant"). Two different integers are incomparable, so the meet of and is . The fact at a point is a map from the variables to this lattice, ordered pointwise. A strict step lowers at least one variable, and each variable can fall at most twice, so the height is ; the chain that lowers the variables one by one to a constant and then to has exactly steps. The transfer function of z = x + y is monotone but not distributive, as the precision example above shows. So constant propagation is a monotone framework and not a distributive one. Its lattice has infinitely many elements but finite height, which is all the iteration needs.
Non-example: a function that is not monotone. Let the universe be one definition , with meet , and let a block with a self-loop have , the complement. The equations and give , which no set satisfies. The equations have no fixed point at all. A solver that only lowers facts still stops, but the values it stops at do not solve the equations.
Non-example: infinite height. Let the fact be the set of values that i can hold, as a may problem over all integers. In the loop i = 0, then i = i + 1 back to the loop head, the fact at the head grows , , and so on, and iteration never stops. The meet semilattice here has strictly descending chains that never end. Analyses of this kind use abstract interpretation with a widening operator instead.
Non-example: no identity. If held only the transfer functions of blocks, then the function of the empty path, the identity, could be missing, and so could compositions. The MOP definition needs both. Adding them never breaks monotonicity, since the identity and compositions of monotone functions are monotone.
Related definitions
- Distributive dataflow framework: a monotone framework with . Then MFP = MOP.
- Gen-kill problem: the distributive frameworks whose functions are on sets.
- Meet-over-all-paths solution and maximal fixed-point solution: the ideal and the computed answer of an instance. The MOP-MFP coincidence theorem says when they agree.
- Kam-Ullman iteration bound: the number of round-robin passes for rapid frameworks, a subclass that contains the bit-vector problems.
- Knaster-Tarski theorem and fixed point: a monotone function on a complete lattice has a greatest fixed point. A meet semilattice of finite height with is a complete lattice, so the theorem applies, and here the iteration from also reaches it.
- Join semilattice and abstract interpretation: Nielson, Nielson and Hankin state monotone frameworks with a join, least solutions and the ascending chain condition. Turning the order upside down maps their convention onto this one.
References
- John B. Kam and Jeffrey D. Ullman, Monotone data flow analysis frameworks, Acta Informatica 7(3), 1977, 305-317, the whole paper (the definition of a monotone framework, the existence of the maximal fixed point and its computation by Kildall's algorithm, MFP below MOP, and the undecidability of MOP for monotone frameworks)
- John B. Kam and Jeffrey D. Ullman, Global data flow analysis and iterative algorithms, Journal of the ACM 23(1), 1976, 158-171, the whole paper (the semilattice formulation and the analysis of round-robin iteration)
- 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 meet semilattice of facts and the distributive optimizing functions that monotone frameworks generalize)
- 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 (9.3.1 Semilattices, 9.3.2 Transfer Functions, 9.3.3 The Iterative Algorithm for General Frameworks, 9.3.4 Meaning of a Data-Flow Solution) and Section 9.4 (constant propagation, 9.4.4 monotonicity and 9.4.5 nondistributivity)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Section 2.3 (Monotone Frameworks, stated with a join, the ascending chain condition and least solutions)
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 VCMGHG Edit this page History Report an error Markdown