Theoremresearch
Transition invariant theorem
Also called disjunctive well-foundedness.
A program terminates iff its transition relation has a transition invariant that is a finite union of well-founded relations.
The transition invariant theorem of Podelski and Rybalchenko says that a program terminates if and only if the transitive closure of its step relation, on reachable states, is contained in a finite union of well-founded relations. Each relation in the union can be proved well-founded alone, often with one linear ranking function, and no single order for the whole program is needed. The "if" direction rests on the infinite form of Ramsey's theorem. The theorem is the basis of the Terminator tool and of many automatic termination provers.
Statement
Programs. A program is a set of states , a set of initial states and a transition relation . A computation is a finite or infinite sequence with and for each step. A state is reachable if it occurs in a computation; is the set of reachable states. The program terminates if it has no infinite computation.
Relations. A relation is well-founded if there is no infinite sequence with for all . is disjunctively well-founded if for some finite and well-founded . is the transitive closure of : the pairs such that is reached from in one or more steps.
Transition invariant. is a transition invariant of the program if , that is, if whenever is reachable and is reached from in at least one step.
Theorem. A program terminates if and only if it has a disjunctively well-founded transition invariant.
In plain words
To show that a loop stops, the classic way is one measure that drops on every step and cannot drop for ever. For a program with many paths, one such measure can be hard to find. This theorem says that you can use several simple measures instead. The condition is: for any two moments of a run, an earlier one and a later one, at least one of the measures has dropped between them. If each measure cannot drop for ever, the run must stop. The important detail is "any two moments", not only "two moments next to each other". With only next steps, two measures can take turns going down and up, and the run never stops.
Proof
Lemma (infinite Ramsey for pairs). Color every pair of natural numbers, , with one of colors. Then there is an infinite set and a color such that every pair of has color .
Proof of the lemma. Put . Given an infinite set , let . The infinitely many fall into classes by the color of , so one class is infinite, by the pigeonhole principle. Let be that class and its color. Then , since and is the least element of , and for the element lies in , so has color . The colors take only values, so some color equals for infinitely many , say . Put . For , the pair has color .
If. Let be a disjunctively well-founded transition invariant, and suppose that is an infinite computation. For , is reachable and is reached from in steps, so . Color the pair with the least such that . By the lemma there are indices whose pairs all have the same color . In particular for every , so is an infinite descending sequence of . This contradicts the well-foundedness of . So there is no infinite computation.
Only if. Suppose the program terminates. Take and . It is a transition invariant by definition. Suppose it is not well-founded, with an infinite sequence and . Then is reachable, so a computation reaches it. Each pair is in , so a path of one or more steps leads from to . Join the computation to and all these paths. The result is an infinite computation, since every path adds at least one step. This contradicts termination.
Consequences
- Termination proofs by parts. To prove termination it is enough to cover by finitely many relations and give each a ranking function. Terminator by Cook, Podelski and Rybalchenko does this: it guesses , asks a model checker for a pair in that is not covered, synthesizes a ranking function for the loop path of that pair with linear ranking function synthesis, adds it to , and repeats.
- The check is a safety property. " is a transition invariant" is a safety property of a program that runs , at some point saves a copy of the current state, and keeps running; the assertion is that the pair (saved state, current state) is in . So termination, a liveness property, is reduced to one safety check plus separate well-foundedness checks.
- No lexicographic order needed. A lexicographic ranking function asks for a fixed priority among the measures. A disjunctive one needs none, so it is easier to find and to compose. The price is that the inductive check must be about , not about .
- The same argument as size-change termination. Size-change termination by Lee, Jones and Ben-Amram uses Ramsey's theorem in the same way, on the size-change graphs of the closure.
- No decision procedure. Termination is undecidable, by the halting problem and Rice's theorem. The theorem does not change that: it says what a proof looks like, not how to find one. Tools search for in a restricted class, such as unions of linear ranking relations, and can fail.
Tightness
- instead of is not enough. Take and . Then is a union of two well-founded relations, each with one pair, but is an infinite computation. The closure contains , and no well-founded relation contains a pair , so no disjunctively well-founded covers . A union of well-founded relations is not well-founded in general, and the theorem uses the closure exactly to get around this.
- The union must be finite. Take and . The program does not terminate. But is the union of the infinitely many one-pair relations , and each is well-founded. The proof needs finite to apply Ramsey's theorem with colors.
- The restriction to reachable states is needed for "only if". Add to a terminating program a state with that no computation reaches. The program still terminates, but contains , so without the restriction to no disjunctively well-founded relation would cover it.
- The proof is not constructive. The "if" direction uses the infinite Ramsey theorem and gives no bound on the length of a run in terms of the ranking functions, unlike one ranking function, which bounds the run by its starting value.
History
Floyd proved termination in 1967 with a function into a well-founded set, which is one relation that covers . Lee, Jones and Ben-Amram used Ramsey's theorem in 2001 to prove the size-change termination principle. Podelski and Rybalchenko defined transition invariants and proved this theorem at LICS 2004, and gave the linear ranking function synthesis that it uses in the same year. Cook, Podelski and Rybalchenko built Terminator on it and reported termination proofs of Windows device drivers at PLDI 2006. Ramsey's theorem is from 1930.
References
- Andreas Podelski and Andrey Rybalchenko, Transition invariants, Proceedings of the 19th IEEE Symposium on Logic in Computer Science (LICS 2004), the definitions of transition invariant and disjunctive well-foundedness, and the theorem that a program terminates if and only if it has a disjunctively well-founded transition invariant, proved with Ramsey's theorem
- Byron Cook, Andreas Podelski and Andrey Rybalchenko, Termination proofs for systems code, Proceedings of PLDI 2006, the Terminator tool, which builds a disjunctively well-founded transition invariant one ranking function at a time and checks it as a safety property
- Chin Soon Lee, Neil D. Jones and Amir M. Ben-Amram, The size-change principle for program termination, Proceedings of POPL 2001, pp. 81 to 92, the earlier use of Ramsey's theorem to prove termination from the idempotent size-change graphs of the closure
- F. P. Ramsey, On a problem of formal logic, Proceedings of the London Mathematical Society s2-30(1), 264 to 286 (1930), the infinite form of the theorem on colorings of the r-subsets of an infinite set
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 D0628W Edit this page History Report an error Markdown