2004 - Transition Invariants
2004 - Transition Invariants
Andreas Podelski
Andrey Rybalchenko
Abstract
Proof rules for program verification rely on auxiliary
assertions. We propose a (sound and relatively complete)
proof rule whose auxiliary assertions are transition invariants. A transition invariant of a program is a binary relation over program states that contains the transitive closure
of the transition relation of the program. A relation is disjunctively well-founded if it is a finite union of well-founded
relations. We characterize the validity of termination or another liveness property by the existence of a disjunctively
well-founded transition invariant. The main contribution of
our proof rule lies in its potential for automation via abstract interpretation.
1. Introduction
Temporal verification of concurrent programs is an active research topic; for entry points to the literature see
e.g. [6, 9, 11, 13, 14, 15, 23]. In the unifying automatatheoretic framework of [23], a temporal proof is reduced to
the proof of fair termination, which again can be done using
deductive proof rules, e.g. [11]. The application of these
proof rules requires the construction of auxiliary assertions.
This construction is generally considered hard to automate,
especially when ranking functions and well-founded (lexicographic) orderings are involved.
We propose a proof rule whose auxiliary assertions are
transition invariants. We introduce the notion of a transition invariant as a binary relation over program states that
contains the transitive closure of the transition relation of
the program. We formulate an inductiveness principle for
transition invariants. This principle allows us to identify a
given relation as a transition invariant. We also introduce
This work was partly supported by the German Research Foundation (DFG) as part of the Transregional Collaborative Research Center
Automatic Verification and Analysis of Complex Systems (SFB/TR 14
AVACS) and by the German Federal Ministry of Education and Research
(BMBF) in the framework of the Verisoft project under grant 01 IS C38.
Examples We write example programs in the programming language SPL (Simple Programming Language [14]).
To simplify the presentation, we ignore idling transitions for
the presented concurrent programs. The depicted controlflow graphs treat each straight-line code segment as a single
statement. For each of the example programs, we give a
(non-inductive) transition invariant, along with an informal
argument, in Sections 3 resp. 4; the corresponding formal
argument is based on a stronger inductive transition invariant, which we present in Section 5.
Usually the termination argument for the program
on Figure 1 is based on a lexicographic combination
of well-founded orderings.
: integer
lo al x; y
3
while
2 ax > 0 ^ y > 0 do
3
7
6
` : (x; y ) := (x 1; x)
7
6
5 5
4 4 or
`b : (x; y ) := (y 2; x + 1)
2
x > 0; y > 0,
x0 = x 1,
y0 = x
x > 0; y > 0,
x0 = y 2,
y0 = x + 1
LOOPS
LOOPS
in n
: integer where n > 0
lo
al x; y
: integer where x = n
2
3
`0 :2while x 0 do
3
6
7
`1 : y := 1
6
7
6 6 `2 : while y < x do 7 7
6 6
7 7
4 4
5 5
`3 : y := 2y
`4 : x := x 1
x 0,
x0 = x; y 0 = 1
`0
`2
y x,
x0 = x 1; y 0 = y
y < x,
x0 = x,
y 0 = 2y
lo
al x; y
: integer where x = 1; y = 0
2
3
`0 : while x = 1 do
6
`1 : y := y + 1 7
7 k P2 :: m0 : x := 0
P1 :: 6
4 `2 : while y > 0 do 5
m1 :
`3 : y := y 1
x = 1,
x0 = x; y 0 = y + 1
y > 0,
x0 = x; y 0 = y
`0
`2
x 6= 1,
x0 = x; y 0 = y
m0
m1
x0 = 0; y 0 = y
The program is not terminating if we consider all possible scheduler behaviors. E.g., in the following infinite computation of ANY-DOWN the process P2 is never executed (a
program state is a tuple containing the location of P1 , the
location of P2 , the value of x, and the value of y ).
:::
CONC-WHILES
lo al x; y
x > 0,
x0 = x; y 0 = x
x 0,
x 0 = x,
y0 = 0
y > 0,
x0 = y 1; y 0 = y
`0
m0
`2
m2
y 0,
x0 = 0,
y0 = y
2. Transition Invariants
This section deals with properties of general binary relations. For concreteness we formulate the properties for the
transition relation of a program and its restriction to the set
of accessible states. We next formalize programs.
Program P
A program P
W : a set of states,
W,
R: a transition relation, such that R W W .
I : a set of starting states, such that I
R+ \ (A A )
T:
R is well-founded if R T
does not hold (for a counterexample, take R and T to be the
relation ACK-REQ). However, the implication:
R is well-founded if R+ T
does hold, as we show below.
=
def
( ) =
def
( )
[(
(
(
( ) ( )
( )
1
1
(s
ki
=
def
R+ \ (A A )
The relation ACK-REQ shows that we cannot drop the requirement that not just the transition relation of a program,
but also its transitive closure must be contained in the disjunctively well-founded relation T .
The next example shows that we cannot drop the finiteness requirement in the definition of disjunctive wellfoundedness. The following transition relation
= f(i; i + 1) j i 1g
has a transition invariant T = T1 [ T2 [ : : : that is the union
R
def
def
T1 [ [ T n
and for all i there is a non-empty computation segment leading from si to si+1 (i.e. si ; si+1 2 R+ ), there
exists an infinite computation s1 ; : : : ; s1 ; : : : ; s2 ; : : : . This
fact is a contradiction to our assumption that P is terminating. Hence, T is (disjunctively) well-founded.
Ti
= f(i; i + j ) j j 1g;
def
for all i :
3. Termination
Theorem 1 gives a (complete) characterization of program termination by disjunctively well-founded transition
invariants.
We next present disjunctively well-founded transition invariants for the first resp. second program shown in the introduction. Here, we only give informal arguments; in Section 5 we will show how one can formally prove that the
relations are indeed transition invariants, and give the formal argument in the form of (stronger) inductive transition
invariants.
LOOPS
over the unprimed and primed program variables is a transition invariant for the program LOOPS; here p
is a variable
ranging over the set of location labels f`0 ; : : : ; `4 g.
T1
T2
Tij
x 0 ^ x0 < x
x y > 0 ^ x0 y 0 < x y
p
= `i ^ p
0 = `j where i 6= j 2 f0; : : : ; 4g
T1
T2
T3
x > 0 ^ x0 < x
x + y > 0 ^ x0 + y 0 < x + y
y > 0 ^ y0 < y
)
def
Q:
)
(( ) (
))
F:
WF
4. Liveness
WQ
(computations are infinite words over the alphabet W ; finite computations are added an idling transition for the last
state). We export the program computations to the automaton by the parallel composition P; of the program and the
automaton, which we introduce next.
The program P; , which in fact is equipped with the
Buchi acceptance condition, is obtained by the synchronous
parallel composition of P and A; . The set of states of
P; is the Cartesian product
def
)(
Proof. if-direction (sketch): Assume, for a proof by contraposition, that the finite union
=
def
T1 [ [ T n ;
only if-direction: Assume that the program P; is fair terminating (i.e., has no (infinite) fair computation). Let A
denote the set of accessible states of P; . We define the
following relations on the accessible states of P; .
T1
T2
= R+ \ (A
\ W A
)
= R+ \ (A
n W A
)
def
def
T 1 [ T2
def
=
(
= ( = )
= q ^ y > 0 ^ y0 < y
p
6= q
p
= q0 ^ p
0 = q
p
2 = m0 ^ p
02 = m1
p
1 = ` ^ p
01 = `
where i 6= j 2 f0; : : : ; 3g
p
Q
))
GF (p
1 6= 0) ^ GF (p
1 6= 1) ^
GF (p
2 6= 0) ^ GF (p
2 6= 1)
T1
T2
T3
T4
Tij
(( ) (
T1
T2
T3
Tij4
Tij5
Tij6
= q ^ x > 0 ^ x0 < x
p
= q ^ y > 0 ^ y 0 < y
p
=
6 q
where i 6= j 2 f0; 1; 2g
p
= q ^ p
0 = q
0
p
1 = ` ^ p
1 = `
where i 6= j 2 f0; 1; 2g
0
p
2 = m ^ p
2 = m
where i 6= j 2 f0; 1; 2g
p
Q
012
012
5. Inductiveness
[ T R
T:
P Q
premises P1 and P2 (i.e., one identifies T as as transition invariant by strengthening T with the inductive relation T 0 ).
The two formulations are equivalent since the disjunctive
well-foundedness of a relation is inherited by its subset.
Program P ,
liveness property ,
fairness assumption ,
Buchi automaton A; ,
parallel composition of P and A; is program P;
with:
transition relation R,
states WQ ,
accepting states WF ,
relation T WQ WQ
P1:
P2:
P3:
T T
Corollary 1 (Compositionality) A finite union of wellfounded relations is well-founded if it is closed under relational composition with itself.
Proof. Let the relation T be the finite union of the wellfounded relations that is closed under the composition with
itself, i.e. T T T .
By Remark 1, T is an inductive transition invariant for
itself. Since T is disjunctively well-founded, we have that
T is well-founded by Theorem 1.
Proof Rule Theorem 2 and Remark 1 give rise to a proof
rule for the verification of liveness properties; see Figure 5.
Again, the formulation uses the automata-based framework
for verification of concurrent programs [23]. We obtain a
proof rule for termination by taking R as the transition relation of the program P , a relation T W W and replacing
T \ WF WF by T in the premise P3.
In our examples we split the reasoning on disjunctive
well-foundedness and inductiveness. This can be seen as
using an alternative, equivalent formulation of the proof
rule: one takes two relations T and T 0 such that T satisfies the premise P3 and T 0 is a subset of T that satisfies the
R
T R
T \ (WF
W )
F
T
T
disjunctively
well-founded
P satisfies under
6 T:
T0
= T \ (S S )
def
=1
has not brought any simplification and is as hard as before the reduction. In the other cases, with a well-chosen
transition invariant and partitioning, the premise P3 can be
established by a number of pairwise independent simple
well-foundedness tests.
Note that all relations Ti in the transition invariants of
the programs presented in this paper correspond to simple while programs that consist of a single while loop with
only update statements in its body.
~ ^eX
~ 0; X
~ is wellMore generally, the relation g X
founded if and only if the while loop
( )
~ ) do
while g (X
0
~
~
e(X ; X )
is terminating.
In the case of concurrent programs with linear-arithmetic
expressions, the well-foundedness test in the premise P3
amounts to the termination test of simple while programs,
for which an efficient test exists; see [17, 22].
In the special case of finite-state systems (a case that we
do not target), each small termination problem is to check
whether a transition is a self-loop.
Inductive Transition Invariants for Examples Each of
the relations T shown in Section 3 and 4 is not inductive
(i.e., the composition of one of the relations Ti and one of
the program transitions Rj is not a subset of T ). We formally identify each T as a transition invariant by presenting
an inductive one that strengthens T (i.e., is a subset of T ).
We thus complete the termination resp. liveness proof according to the proof rule.
The union of the following relations is an inductive transition invariant for the program LOOPS (in the version according to the depicted control-flow graph).
LOOPS
= `0 ^ x 0 ^ x0 x ^ p
0 = `2
p
= `2 ^ x0 < x ^ p
0 = `0
p
= `2 ^ x y > 0 ^ x0 x ^ y 0 > y ^ p
0 = `2
p
= `0 ^ x 0 ^ x0 < x ^ p
0 = `0
p
= `2 ^ x 0 ^ x0 < x ^ p
0 = `2
p
The inductiveness can be easily verified. E.g., the composition of the relation below (which is the transition for the
straight-line code from the location `2 to `0 ; it is obtained
by composing the transition between the locations `2 and `4
and the transition from `4 to `0 ),
p
= `2 ^ y x ^ x0 = x 1 ^ y0 = y ^ p 0 = `0
with the first of the five relations above yields the relation
below, a relation that entails the fourth.
p
= `0 ^ x 0 ^ x0 x 1 ^ p 0 = `0
p
Q
p
Q
p
Q
p
Q
p
Q
p
Q
=q
=q
=6 q
=6 q
=6 q
=6 q
F
F
^ p
1 = `2 ^ p
2 = m1 ^ y > 0 ^ x0 = x ^ y0 < y
^ p
1 = `3 ^ p
2 = m1 ^ y > 0 ^ x0 = x ^ y0 < y
^ p
1 = `0 ^ p
2 = m0 ^ x0 = x
^ p
1 = `1 ^ p
2 = m0 ^ x0 = x
^ p
1 = `2 ^ p
2 = m1 ^ y > 0 ^ x0 = x ^ y0 < y
^ p
1 = `3 ^ p
2 = m1 ^ y > 0 ^ x0 = x ^ y0 < y
p
Q
p
Q
p
Q
p
Q
=
=q
=q
=6 q
=6 q
F
F
F
=
^ x > 0 ^ x0 < x ^ y 0 < x
^ y > 0 ^ x0 < y ^ y 0 < y
^ x > 0 ^ x0 x ^ y 0 < x
^ y > 0 ^ x0 y ^ y 0 y
Soundness and Completeness The separation of the temporal reasoning from the reasoning about the auxiliary assertions in the relative completeness statement below is
common practice; see e.g. [13, 14].
Theorem 3 (Proof Rule LIVENESS) The rule LIVENESS is
sound, and complete relative to the first-order assertional
validity and the well-foundedness validity of the relations
that constitute the transition invariant.
Proof. The soundness of the rule follows directly from
Remark 1 and Theorem 2.
F (T )
= T R:
def
( )
( )
6. Related Work
There is a large body of work on proof rules for liveness
properties of concurrent programs, see [6, 11, 13, 15]. They
all rely on auxiliary well-founded (lexicographic) orderings
for the transition relation, and not on independent orderings
for sub-relations, as in our approach.
The automata-theoretic approach for verification of concurrent programs [23] reduces the verification problem to
proving termination. It leaves open how to prove termination. We indicate one possible way.
A rank predicate [24] (a notion directly related to
progress measures [9]) proves fair termination of a program
if the rank does not increase in every computation step and
decreases in the accepting states. In a disjunctively wellfounded transition invariant a rank need not decrease in all
sub-relations if an accepting state is visited, i.e., the rank
of one sub-relation must decrease and all other ranks may
increase.
In [12], an axiomatic approach to prove total correctness (safety property + termination) of sequential programs
uses assertions connecting the initial and final values of the
program variables. This must not be confused with transition invariants that capture all pairs of intermediate values
in computations of arbitrary length, possibly going through
loops.
It is interesting to compare our use of Ramseys theorem
in the proofs of Theorems 1 and 2 with its use in the theory
of (finite) Buchi automata (see e.g. [19, 21]). The equivalence classes over computation segments in our proofs are
related to the state transformers in the transition monoid of
the Buchi automaton. In both uses of Ramseys theorem,
the sets of transformers are finite and thus induce an equivalence relation of finite index (which is why Ramseys theorem can be applied). However, our proofs consider finite
sets of transformers over an infinite state space, as opposed
to transformers over a finite state space.
The termination analysis for functional programs in [10]
has been the starting point of our work. The analysis is
based on the comparison of infinite paths in the control flow
graph and in size-change graphs; that comparison can be
reduced to the inclusion test for Buchi automata. The transitive closure of a (finite) set of size-change graphs can be
seen as a graph representation of a special case of a transition invariant.
7. Conclusion
We have presented a (sound and relatively complete)
proof rule for the temporal verification of concurrent programs. In a well-chosen instantiation, this proof rule allows
one to decompose the verification problem into a number of
independent smaller verification problems: one for establishing a transition invariant, and the others for establishing
the disjunctive well-foundedness. The former is done in a
way that is reminiscent of establishing state invariants, using a familiar inductive reasoning. The other ones amount
to testing the termination of simple while loops.
Our conceptual contribution is the notion of a transition
invariant, and its usefulness in temporal proofs. This notion
is at the basis of our proof rule. In particular, it allows one
to account for Buchi accepting conditions (and hence for
fairness) in a direct way, namely by intersecting relations.
Our technical contribution is the characterization of the
validity of termination or another liveness property by the
existence of a disjunctively well-founded transition invariant. The application of Ramseys theorem allows us to re-
rf
vs.
R+
()
( )
T1 [ [ T n :
References
[1] T. Ball, R. Majumdar, T. Millstein, and S. Rajamani. Automatic predicate abstraction of C programs. In Proc. of
PLDI2001: Programming Language Design and Implementation, volume 36 of ACM SIGPLAN Notices, pages
203213. ACM Press, 2001.
[2] B. Blanchet, P. Cousot, R. Cousot, J. Feret, L. Mauborgne,
A. Mine, D. Monniaux, and X. Rival. A static analyzer
for large safety-critical software. In Proc. of PLDI2003:
Programming Language Design and Implementation, pages
196207. ACM Press, June 714 2003.
[3] S. Chaki, E. Clarke, A. Groce, S. Jha, and H. Veith. Modular verification of software components in C. In Proc. of
ICSE2003: Int. Conf. on Software Engineering, pages 385
395, 2003.
[4] P. Cousot and R. Cousot. Abstract interpretation: a unified
lattice model for static analysis of programs by construction
or approximation of fixpoints. In Proc. of POPL1977: Principles of Programming Languages, pages 238252. ACM
Press, 1977.
[5] P. Cousot and R. Cousot. Systematic design of program
analysis frameworks. In Proc. of POPL1979: Principles
of Programming Languages, pages 269282. ACM Press,
1979.