cav14 - Stanford University

Rahul Sharma and Alex Aiken (Stanford University)
1
x = i;
y = j;
while y!=0 do
x = x-1;
y = y-1;
if( i==j )
assert x==0
๏‚ก
๏‚ก
๐‘ฅ=0
๐‘ฅ+๐‘ฆ =0
โ‹ฎ
๏‚ก
๐‘–+๐‘ฆ =๐‘ฅ+๐‘—
๏‚ก
๏‚ก
No!
Yes!
2
Numerical
Arrays
Heap
delete
PLDI08-1
NECLA-2
init
d-swap
delete-all
PLDI08-2
NECLA-3
init-nc
strcpy
find
PLDI08-3
SVCOMP-1
init-p
strlen
filter
PLDI08-4
SVCOMP-2
init-e
memcpy
last
synergy-1
SVCOMP-3
2darray
find
reverse
synergy-2
SVCOMP-4
copy
find-n
TACAS06
monniaux
copy-p
append
Strings
NECLA-1
nested
copy-o
merge
length
reverse
alloc-f
replace
swap
alloc-nf
index
substring
3
assume P
while B do
S
assert Q
๏‚ก
Find ๐ผ that satisfies
๏‚ก
๐‘ƒโ‡’๐ผ
๏‚ก
๐ผ โˆง ๐ต ๐‘† {๐ผ}
๏‚ก
๐ผ โˆง ¬๐ต โ‡’ ๐‘„
Find a valuation of unknown predicates that
makes the verification conditions (VCs) valid
4
๏‚ก
Given a set ๐‘† of candidates
๏‚ง Goal is to find a candidate that satisfies the VCs
๏‚ก
This problem is hard!
๏‚ก
Effective domain specific approaches
๏‚ง Numerical, arrays, linked lists, etc.
๏‚กIs it possible to have a general search procedure?
5
๏‚ก
(Domain-specific) Checker + (General) Search = Inference
๏‚ก
To obtain an invariant inference engine
๏‚ง Instantiate the search with a search space
๏‚ง An SMT solver to check
6
๏‚ก
A generally applicable randomized search
๏‚ก
Numerical, array, linked lists, and strings
๏‚ก
Competitive performance with specialized approaches
7
๏‚ก
Markov Chain Monte Carlo (MCMC) sampling
๏‚ก
The only known tractable solution method for high
dimensional irregular search spaces [andrieu
03][chenney 00]
8
37
73
47
17
29
42
23
9
1.
2.
3.
4.
5.
6.
7.
๐ถ โ‰” ๐‘ก๐‘Ÿ๐‘ข๐‘’
while( ๐‘๐‘œ๐‘ ๐‘ก ๐ถ โ‰  0 )
Propose a random modification to ๐ถ
if cost decreased then accept
if cost increased then
with some probability accept anyway
return ๐ถ
10
๏‚ก
๐‘๐‘œ๐‘ ๐‘ก ๐ถ =
๏‚ก
Problems
0
1
if ๐ถ makes VCs valid
if ๐ถ is not an invariant
๏‚ง Throughput < 1000 iterations per second
๏‚ง No incremental feedback
11
๏‚ก
Given sets of concrete states
๏‚ง G: some reachable states
๏‚ง B: some bad states
b
g
๏‚ง Z: some implications
๏‚ก
๐‘๐‘œ๐‘ ๐‘ก(๐ถ) =
๐‘”โˆˆ๐บ ¬๐ถ(๐‘”)
๐‘โˆˆ๐ต ๐ถ(๐‘)
๐‘ ,๐‘ก
โ€ฆ
+
s
I
t
Incremental feedback
+
โˆˆ๐‘ ๐ถ ๐‘  โˆง ¬๐ถ(๐‘ก) +
Efficient to evaluate
12
๏‚ก
๐‘ƒโ‡’๐ถ
๏‚ก
Reachable state ๐‘”, ๐ผ ๐‘” = true
๏‚ง ๐ถ ๐‘” = false
๏‚ก
๐ถ โˆง ๐ต ๐‘† {๐ถ}
๏‚ก
๏‚ก
๏‚ง ๐ถ ๐‘  โˆง ¬๐ถ ๐‘ก = true
๐ถ โˆง ¬๐ต โ‡’ ๐‘„
assume P
while B do
S
assert Q
Pair (๐‘ , ๐‘ก), ๐ผ ๐‘  โ‡’ ๐ผ(๐‘ก)
๏‚ก
Bad state ๐‘, ๐ผ ๐‘ = false
๏‚ง ๐ถ ๐‘ = true
13
๏‚ก
Given G, Z, and B, for the cost function
๏‚ก
Run search until a 0-cost candidate ๐ถ is found
๏‚ก
๐ถโ„Ž๐‘’๐‘๐‘˜ ๐ถ, ๐‘‰๐ถ
๏‚ง SMT solver checks that ๐ถ satisfies all the VCs
๏‚ง If yes, then done
๏‚ก
Update G, Z, or B and repeat
๏‚ง SMT solvers can generate counterexamples
๏‚ง If not then generate from executions
14
๏‚ก
Program has integral variables ๐‘ฅ1 โ€ฆ ๐‘ฅ๐‘›
๏‚ก
Search space:
๏‚ก
Transformations for MCMC:
10
๐‘–=1
10
๐‘—=1
๐‘–,๐‘—
๐‘›
๐‘ค
๐‘˜=1 ๐‘˜ ๐‘ฅ๐‘˜
โ‰ค ๐‘‘๐‘–,๐‘—
๏‚ง Update a ๐‘ค
๏‚ง Update a ๐‘‘
๏‚ง Update all ๐‘ค โ€ฒ ๐‘  and ๐‘‘ of a single inequality
15
16
17
๏‚ก
Fluid updates abstraction of DDA (ESOPโ€™10)
๏‚ง โˆ€๐‘ข, ๐‘ฃ. ๐‘‡ ๐‘ฅ1 , โ€ฆ , ๐‘ฅ๐‘› , ๐‘ข, ๐‘ฃ โ‡’ ๐‘“ ๐‘ข = ๐‘”[๐‘ฃ]
๏‚ก
Z3 fails to generate counterexamples
๏‚ก
MCMC on this search space times out on ~30%
๏‚ง Restrict search space: handle each in under a second
18
๏‚ก
Search space: Boolean combinations of atoms
๏‚ง Atoms are relations ๐‘…(๐‘ฅ1 , โ€ฆ , ๐‘ฅ๐‘› )
๏‚ง Reachability relations
๏‚ก
Use EPR (CAVโ€™13) for check
19
๏‚ก
Operations that intermix strings and integers
๏‚ง length(s), indexOf(s1, s2), substr(s1, i1, i2), โ€ฆ
๏‚ก
Search space: Boolean combinations of predicates
๏‚ก
Z3-Str (FSEโ€™13) for check
20
๏‚ก
Static invariant inference is a hard problem,
made easier by separating search and check
๏‚ก
Search based techniques can work
๏‚ง Competitive with other methods
๏‚ง Easier to retarget to new domains
๏‚ก
Future work, scale MCMC to full program proofs
21
๏‚ก
Pranav Garg, Christof Löding, P. Madhusudan, Daniel Neider: ICE: A Robust
Framework for Learning Invariants. CAV 2014
๏‚ก
Shachar Itzhaky, Nikolaj Bjørner, Thomas W. Reps, Mooly Sagiv, Aditya V. Thakur:
Property-Directed Shape Analysis. CAV 2014
๏‚ก
Rajeev Alur, Rastislav Bodík, Garvit Juniwal, Milo M. K. Martin, Mukund
Raghothaman, Sanjit A. Seshia, Rishabh Singh, Armando Solar-Lezama, Emina
Torlak, Abhishek Udupa: Syntax-guided synthesis. FMCAD 2013
๏‚ก
Ashutosh Gupta, Rupak Majumdar, Andrey Rybalchenko: From tests to proofs.
STTT 15(4) (2013)
๏‚ก
Yungbum Jung, Soonho Kong, Bow-Yaw Wang, KwangkeunYi:
Deriving Invariants by Algorithmic Learning, Decision Procedures,
and Predicate Abstraction. VMCAI 2010
๏‚ก
Sumit Gulwani, Nebojsa Jojic: Program verification as probabilistic
inference. POPL 2007: 277-289
22