Title: Automatically proving program termination
1Automatically proving program termination Byron
Cook Microsoft Research Cambridge joint work
with Andreas Podelski Andrey Rybalchenko http
//research.microsoft.com/Terminator
2Introduction
3Introduction
4Introduction
5Introduction
6Introduction
7Introduction
8Introduction
9Introduction
Terminator
10Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
11Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
12Terminator for sequential programs
- Termination prover for sequential C programs
- Iteratively finds and checks the validity of a
candidate termination argument - Nifty trick
- Iterative search considers potential
counterexamples to termination in isolation of
the rest of the program (conditionals, nested
loops, recursion, pointers, function pointers,
gotos, etc)
13Well-founded relations
14Well-founded relations
15Well-founded relations
16Well-founded relations
17Well-founded relations
18Well-founded relations
19Well-founded relations
20Termination proof rule
21Termination proof rule
22Termination proof rule
23Termination proof rule
24Termination proof rule
25Termination proof rule
26Termination proof rule
27Termination proof rule
28Termination proof rule
29Termination proof rule
30Termination proof rule
31Termination proof rule
32Terminator
33Terminator
34Terminator
35Terminator
Ø
36Terminator
Ø
37Terminator
Ø
38Terminator
39Terminator
40Terminator
41Terminator
42Terminator
43Terminator
44Terminator
45Terminator
46Terminator
47Terminator
48Terminator
49Terminator
50Terminator
x f(x,y) g(y,x)
copied 0 . . . if (!copied)
if () Hx x
Hy y copied 1
else assert(T1 T2 T3)
while(xlty)
copied 0
51Examples
52Examples
53Examples
54Examples
55Examples
56Examples
57Examples
58Examples
59Experimental results
- More details on Terminator and experiments
- Termination proofs for systems code PLDI06
- Experiments were performed in PLDI06 on 30
Windows device drivers (lt35k LOC) - Weve found some interesting bugs in cases where
Terminator has failed to find a proof
60Example
- Introduction
- Abstraction refinement
- Abstraction refinement for termination
- Experimental results Demo
- Conclusion Discussion
61Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
62Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
63Proving thread termination
- Until recently program termination tools didnt
natively support multithreaded programs - Most of the code that were interested in
verifying is multithreaded
64Introduction
- Until recently program termination tools didnt
natively support multithreaded programs - Most of the code that were interested in
verifying is multithreaded
65Introduction
- Until recently program termination tools didnt
natively support multithreaded programs - Most of the code that were interested in
verifying is multithreaded
66Introduction
67Introduction
68Concurrent programs
- Thread-modular algorithm finds an environment
model binary relation expressed as CNF formula - Implements iterative weakening strengthening
based on spurious counterexamples - Strengthening add conjuncts
- Weakening add disjuncts
- Nifty trick
- Iterative search considers potential
counterexamples to termination in isolation of
the other threads
69Concurrent programs
- Thread-termination Thread T is thread
terminating in P if in each P-computation T makes
only finite many steps. - Important to note
- Were not ruling out deadlock
- Deadlock is a safety property that other tools
should rule out - Thus not proving that functions called in T
eventually return control back to their caller
70Example
71Example
72Example
73Example
74Example
75Example
76Example
77Example
78Example
79Example
80Example
81Example
82Example
83Example
84Example
85Example
86Example
87Example
88Example
89Example
90Example
91Example
92Example
93Example
94Example
95Example
96Example
97Experimental results
- More details on Terminator concurrency extension
and experiments - Proving thread termination PLDI07
- Experiments were performed in PLDI07 on 30
Windows device drivers (lt35k LOC) - Weve found some interesting bugs in cases where
Terminator has failed to find a proof
98Introduction
99Introduction
100Introduction
101Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
102Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
103Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
104Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
105Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
106Variance analyses
107Variance analyses
108Variance analyses
109Variance analyses
110Variance analyses
111Variance analyses
112Variance analyses
113Variance analyses
114Variance analyses
115Variance analyses
116Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
117Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
118Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from variance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
119Extensions, optimizations, etc
120Extensions, optimizations, etc
121Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
122Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
123Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from variance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
124Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
125Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
126Extensions, optimizations, etc
- Better performance with variance analyses
- Variance analyses from invariance analyses
POPL07a - Support for the full spectrum of liveness
properties (fair termination) - Proving that software eventually does something
good POPL07b - Rank function synthesis for simple non-linear
cases - Proving termination by divergence SEFM07
- Better support for heap-manipulating programs
- Automatic termination proofs for programs with
shape-shifting heaps CAV06
127Experimental results
128Experimental results
129Experimental results
130Experimental results
131Experimental results
132Experimental results
133Experimental results
134Experimental results
135Experimental results
136Experimental results
137Experimental results
138Experimental results
139Experimental results
140Experimental results
141Experimental results
142Experimental results
143Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
144Outline
- Introduction
- Sequential programs
- Concurrent programs
- Extensions, optimizations, etc
- Conclusion
145Conclusion
- Reactive systems need terminating components
- Termination is one of the frontiers of automatic
program correctness proof tools - Together with shape and concurrency
- Terminator automatically proves termination (and
other liveness properties) of programs
146Conclusion
- See research.microsoft.com/Terminator
- Write to bycook_at_microsoft.com
- Thank you for your attention