+ All Categories
Home > Documents > Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for...

Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for...

Date post: 10-Jul-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
24
Mechanized Verification for Graph Algorithms Shengyi Wang, Qinxiang Cao, Aquinas Hobor
Transcript
Page 1: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Mechanized Verification for Graph Algorithms

Shengyi Wang, Qinxiang Cao, Aquinas Hobor

Page 2: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Our goals

• Verify graph-manipulating programs

• All proofs mechanized

• Real code

• Techniques able to handle sizable examples

Page 3: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Graph-manipulating programs

• Heap represented graphs – Traditional challenge for verification

• Nontrivial algorithms with “real” specs

– spanning tree – deep copy – union-find – sizable (~400-line) generational optimized garbage

collector for certified compiler (in progress)

Presenter
Presentation Notes
Show C code for UF, garbage collector
Page 4: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Mechanized proofs for real code

• All verification done in Coq

• Target language: CompCert Clight

• Hook into Verified Software Toolchain

Page 5: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Challenges

• Separation logic is a little tricky for graph-manipulating structures

• Real code is harder than toy code, sometimes in rather unexpected ways, e.g. – Garbage collectors break CompCert’s memory

model (and type system) due to the typical uniform treatment of data and pointers

Presenter
Presentation Notes
Show code for GC, line 128 (gc.c) line 65 (values.h) line 12 (gc.h)
Page 6: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Challenges

• Graph algorithms are easier to specify relationally rather than functionally – No “issues” with termination (esp. in Coq) – Some algorithms’ “natural specifications” involve

nondeterminism (e.g. union-find) – Some algorithms do not have easy/natural purely

functional implementations (e.g. union-find)

3 3

2 1 1 2

1

2

1 1

Presenter
Presentation Notes
Show specification for find and union, line 57
Page 7: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Challenges

• Graph algorithms are easier to specify relationally rather than functionally – No “issues” with termination (esp. in Coq) – Some algorithms’ “natural specifications” involve

nondeterminism (e.g. union-find) – Some algorithms do not have easy/natural purely

functional implementations (e.g. union-find) 4

3

2 1 1 2

1

2

1 1

Page 8: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Challenges

• Graph algorithms are easier to specify relationally rather than functionally – No “issues” with termination (esp. in Coq) – Some algorithms’ “natural specifications” involve

nondeterminism (e.g. union-find) – Some algorithms do not have easy/natural purely

functional implementations (e.g. union-find)

3 4

2 1 1 2

1

2

1 1

Page 9: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Challenges

• Formal graph reasoning is surprisingly subtle, we’d like to reuse definitions, proofs, etc. – Reachability – Labels – Validity – Subgraphs

• We’d like generic graphs, and they should be general enough to handle real algorithms.

Page 10: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some solutions

• Separation logic upgrades: “localization blocks”

Presenter
Presentation Notes
Show VST mark line 185
Page 11: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Localization is (upgraded) Ramification

Page 12: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Localization is (upgraded) Ramification

Page 13: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

A little jig for modified variables

• Uh oh… l, r, and x are modified in the localization block…

Page 14: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

A little jig for modified variables

Page 15: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

A little jig for modified variables

Page 16: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

A little jig for modified variables

Page 17: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

A little jig for modified variables

Presenter
Presentation Notes
Show unionfind proof, line 192
Page 18: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some other solutions: a sound “graph” predicate in SL

Page 19: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some other solutions: a sound “graph” predicate in SL

Page 20: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some other solutions: a sound “graph” predicate in SL

Page 21: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Modular mechanized proof engineering

Page 22: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some other solutions: A powerful and general graph library

Page 23: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some other solutions: mechanizing localization blocks in VST

Page 24: Mechanized Verification for Graph Algorithms · • Separation logic is a little tricky for graph-manipulating structures • Real code is harder than toy code, sometimes in rather

Some future work

• Increase modularity – Once you’ve done one union-find proof, have you

done them all?

• Overlaid data structures – Common case; can we make them easier?

• Increase confidence of scalability

– Garbage collector for a “real” client – Lots of “undefined operations” – Bonus: found a significant performance bug


Recommended