Title: Proving termination of software
1 Proving termination of software
Byron Cook bycook_at_microsoft.com
Microsoft Research, Cambridge Joint work with
Josh Berdine, Dino Distefano, Alexey Gotsman,
Peter OHearn, Andreas Podelski, Andrey
Rybalchenko, and others
2Introduction
3Introduction
4Introduction
5Introduction
6Introduction
Lines of code (x1000)
Cut-point set size
7Introduction
Lines of code (x1000)
Cut-point set size
8Introduction
Lines of code (x1000)
Cut-point set size
9Introduction
Lines of code (x1000)
Cut-point set size
10Introduction
Lines of code (x1000)
Cut-point set size
11Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
12Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
13Proof rule for termination
14Proof rule for termination
15Proof rule for termination
16Proof rule for termination
17Proof rule for termination
18Proof rule for termination
19Proof rule for termination
20Proof rule for termination
21Proof rule for termination
22Proof rule for termination
23Proof rule for termination
24Proof rule for termination
25Proof rule for termination
26Proof rule for termination
27Proof rule for termination
28Proof rule for termination
29Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
30Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
31Proof rule for termination
32Proof rule for termination
33Proof rule for termination
Ø
34Proof rule for termination
Ø
35Proof rule for termination
Ø
36Proof rule for termination
37Proof rule for termination
38Proof rule for termination
39Proof rule for termination
40Proof rule for termination
41Proof rule for termination
42Proof rule for termination
43Proof rule for termination
44Proof rule for termination
45Proof rule for termination
46TERMINATOR
47TERMINATOR
48 Binary reachability
x f(x,y) g(y,x)
copied 0 . . . if (!copied)
if () Hx x
Hy y copied 1
else assert(T)
while(xlty)
copied 0
49Examples
50Examples
51Examples
52Examples
53Examples
54Examples
55Examples
56Examples
57Examples
58Examples
59Example
- Introduction
- Abstraction refinement
- Abstraction refinement for termination
- Experimental results Demo
- Conclusion Discussion
60Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
61Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
62What about the false bugs?
Lines of code (x1000)
Cut-point set size
63What about the false bugs?
Lines of code (x1000)
Cut-point set size
64What about the false bugs?
Lines of code (x1000)
Cut-point set size
65Reversing the strategy
66Reversing the strategy
67Reversing the strategy
68Reversing the strategy
69Reversing the strategy
70Reversing the strategy
71MUTANT/TERMINATOR
72MUTANT/TERMINATOR
73MUTANT/TERMINATOR example
74MUTANT/TERMINATOR example
75MUTANT/TERMINATOR example
76MUTANT/TERMINATOR example
77MUTANT/TERMINATOR example
78MUTANT/TERMINATOR example
79Experimental results
- Revisiting loops previously (falsely) accused
80Introduction
81Introduction
82Introduction
83Introduction
84Introduction
85Introduction
86Introduction
87Introduction
88Introduction
89Introduction
90Introduction
91Introduction
92Introduction
93Introduction
94Introduction
95Introduction
96Introduction
97Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
98Outline
- Introduction
- Proof rule for termination
- TERMINATOR
- MUTANT/TERMINATOR
- Conclusion Discussion
99Introduction
- Termination is one of the frontiers of automatic
program correctness proof methods - Together with concurrency and shape analysis
- Applications
- OS dispatch routines
- HTTP request handling code
- Database query handling
- Standard library functions (e.g. string
manipulation, math functions, etc) - Acquire/Release (spinlocks, thread priority, etc)
100Conclusion Discussion
- See http//research.microsoft.com/TERMINATOR
- Questions?
101 EXTRA SLIDES
102 Binary Reachability
103Binary reachability
104Binary reachability
105 Binary reachability
x f(x,y) g(y,x)
copied 0 . . . if (!copied)
if () Hx x
Hy y copied 1
else assert(T)
while(xlty)
copied 0
106 Rank function synthesis
107Rank function synthesis
- What if weve find a path that appears not to
terminate? - Prove it to be well-founded
- compute a witness (ranking relation)
- Refine the set of ranking relations
108Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
109Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
110Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
111Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
112Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
113Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
114Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
115Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
116Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
117Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
118Rank function synthesis
. . . if (ngt0 mgt1) cnt 0
for() AcquireLock() rst0
while(i j gt 1) i i-n
j jm
ReleaseLock() . . . .
L (i,j) (i,j) -i j -1 ? -i i
0 ? j - j -1
119Rank function synthesis
L (i,j) (i,j) -i j -1 ? -i i
0 ? j - j -1
120Rank function synthesis
L (i,j) (i,j) -i j -1 ? -i i
0 ? j - j -1
(-1)i (1)j (0)i (0)j -1 (-1)i (0)j
(1)i (0)j 0 (0) i (1)j (0)i
(-1)j -1
121Rank function synthesis
L (i,j) (i,j) -i j -1 ? -i i
0 ? j - j -1
(-1)i (1)j (0)i (0)j -1 (-1)i (0)j
(1)i (0)j 0 (0) i (1)j (0)i
(-1)j -1
122Rank function synthesis
123Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
124Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
125Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
126Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
127Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
128Rank function synthesis
0 1 0
0 0 -1
P
0 0
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
129Rank function synthesis
P
1 0 0
0 1 0
0 0 1
P
0 0
Q
0 1 1
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
130Rank function synthesis
P
1 0 0
0 1 0
0 0 1
P
0 0
Q
0 1 1
-1 -1 0
1 0 1
-1 0 -1
(P Q)
Q
0
(
)
-1 -1 0
1 0 1
0 1 0
0 0 -1
P
0 0 0
Q
Q
0 0 0
131Rank function synthesis
P
1 0 0
Q
0 1 1
0 1 0
0 0 -1
rank(x,y)
Q
132Rank function synthesis
P
1 0 0
Q
0 1 1
0 1 0
0 0 -1
rank(x,y)
Q
rank(x,y) x - y
d 1
b 1
133Rank function synthesis
P
1 0 0
Q
0 1 1
0 1 0
0 0 -1
- R(V,V) b rank(V) ? rank(V) rank(V) d
- R is an abstraction of p (ie. p ? R)
- In this case 1 i-j ? i-j (Hi-Hj) 1
rank(x,y)
Q
rank(x,y) x - y
d 1
b 1