Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
(c) 2007 Mauro Pezzè & Michal Young Ch 7, slide 1 Symbolic Execution and Proof of Properties.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
CS 355 – Programming Languages
1 Formal Methods in SE Qaisar Javaid Assistant Professor Lecture 05.
Rahul Sharma Işil Dillig, Thomas Dillig, and Alex Aiken Stanford University Simplifying Loop Invariant Generation Using Splitter Predicates.
1 Model Checking, Abstraction- Refinement, and Their Implementation Based on slides by: Orna Grumberg Presented by: Yael Meller June 2008.
Copyright W. Howden1 Lecture 13: Programming by Contract.
Discrete Mathematics Lecture 4 Harper Langston New York University.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Program Verification using Templates over Predicate Abstraction Saurabh Srivastava University of Maryland, College Park Sumit Gulwani Microsoft Research,
Describing Syntax and Semantics
Propositional Calculus Math Foundations of Computer Science.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Cristian Gherghina Joint work with: Wei-Ngan Chin, Razvan Voicu, Quang Loc Le Florin Craciun, Shengchao Qin TexPoint fonts used in EMF. Read the TexPoint.
From Program Verification to Program Synthesis Saurabh Srivastava * Sumit Gulwani ♯ Jeffrey S. Foster * * University of Maryland, College Park ♯ Microsoft.
Dagstuhl Seminar "Applied Deductive Verification" November Symbolically Computing Most-Precise Abstract Operations for Shape.
By: Pashootan Vaezipoor Path Invariant Simon Fraser University – Spring 09.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
June 27, 2002 HornstrupCentret1 Using Compile-time Techniques to Generate and Visualize Invariants for Algorithm Explanation Thursday, 27 June :00-13:30.
Program Analysis with Dynamic Change of Precision Dirk Beyer Tom Henzinger Grégory Théoduloz Presented by: Pashootan Vaezipoor Directed Reading ASE 2008.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
CS 363 Comparative Programming Languages Semantics.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Cristian Gherghina 1, Cristina David 1, Shengchao Qin 2, Wei-Ngan Chin 1 1 National University of Singapore 2 University of Teesside Structured Specifications.
Application: Correctness of Algorithms Lecture 22 Section 4.5 Fri, Mar 3, 2006.
Lazy Annotation for Program Testing and Verification Speaker: Chen-Hsuan Adonis Lin Advisor: Jie-Hong Roland Jiang November 26,
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
1 Lock-Free concurrent algorithm for Linked lists: Verification CSE-COSC6490A : Concurrent Object-Oriented Languages York University - W09 Speaker: Alexandre.
Application: Correctness of Algorithms Lecture 22 Section 4.5 Fri, Feb 18, 2005.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Proving Non-Termination Gupta, Henzinger, Majumdar, Rybalchenko, Ru-Gang Xu presentation by erkan.
A Simple Optimistic skip-list Algorithm Maurice Herlihy Brown University & Sun Microsystems Laboratories Yossi Lev Brown University & Sun Microsystems.
Predicate Abstraction. Abstract state space exploration Method: (1) start in the abstract initial state (2) use to compute reachable states (invariants)
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Lightweight Support for Magic Wands in an Automatic Verifier Malte Schwerhoff and Alexander J. Summers 10 th July 2015, ECOOP, Prague.
SkipLists and Balanced Search The Art Of MultiProcessor Programming Maurice Herlihy & Nir Shavit Chapter 14 Avi Kozokin.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
A Calculus of Atomic Actions Tayfun Elmas, Shaz Qadeer and Serdar Tasiran POPL ‘ – Seminar in Distributed Algorithms Cynthia Disenfeld 27/05/2013.
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
1 Computer Algorithms Tutorial 2 Mathematical Induction Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
IS 2620: Developing Secure Systems Formal Verification/Methods Lecture 9 March 15, 2012.
IS 2935: Developing Secure Systems
Multicore programming
Predicate Transformers
COP4020 Programming Languages
Presentation transcript:

Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla

Outline Motivation Methodology Results and Future Work

Motivation How do we verify skiplist algorithms? Why? Why: Skiplists are important data structures, eg in databases, distributed systems Verifying is complicated because skiplists are multi-pointers structures There is no previous work that formally verify skiplists algorithms Our Motivation: Employ transitive closure logic to handle multi-pointers data structures Introduce a method to discover and verify quantified invariants for multi-pointers programs Apply such method to skiplist algorithms.

Skiplist Skiplist is a list with a number of sorted single linked lists, each linked list is located at a layer Properties: Every single linked list at any layer is sorted accorrding to node’s key values List at higer layer is a sublist of list at lower layer mmm ss -∞ 510 +∞ headtail

Example Add(8) mmm ss -∞ 510 +∞ headtail 8 m s m s sPred = mPred sSucc = mSucc

How to verify program invariants Assume that we have the invariant I of program P and we want to verify it. We need to: Annotate program P by computing assertions at program points and then verify I at all assertions

Program Assertion Assertion : Assertion at each program point is a conjunction of atomic predicates which are valid in that point and taken from abstract domain Example: P1: (x = y)  (y  * z)  (x  * t) Abstract Domain: Set of predicates P = { P 1, …, P n } given by users Each predicate describes relations between program variables

Example 1.int insert(x) Abstract Domain 2.{ head → * tail, head = pred head → * tail pred → * x, x → * tail 3. node* pred = head head = pred ˄ head → * tail 4. pred.next := x head = pred ˄ pred → * x 5. x.next := tail ? } How to get assertion for each program point?

Compute Post Assertion Let A’ is successor of program point A, then its assertion is obtained as below For each predicate P from the abstract domain If it is valid in A' that means if post(A,S)  P Add P to the assertion Here post(A,S) is post-condition which are program states reached from A when we execute the statement S

Example Abstract Domain head → * tail, head = pred pred → * x, x → * tail A.head = pred ˄ pred → * x x.next := tail A’.? } head = pred ok pred → * x: ok x → * tail: ok head → * tail: ok For each predicate P from the abstract domain If it is valid in A' that means that if post(A,S)  P Add P to the assertion For each predicate P from the abstract domain If it is valid in A' that means that if post(A,S)  P Add P to the assertion Post(head = pred ˄ pred → * x, x.next := tail ) = head = pred ˄ pred → * x ˄ x → tail Assertion : head = pred ˄ pred → * x ˄ x → * tail ˄ head → * tail

Assertion Template for Skiplists Invariant:  u,v  (P i (u,v)  e i (u,v)) Assertion form at each program point E   u,v  (P i (u,v)  e i (u,v)) Where ♦ E: conjunction of atomic predicates valid at that point ♦ e i (u,v): an atomic predicate of u and v ♦ P i (u,v): conjunction of atomic predicates of u and v global variables Example: E   u,v (u → m * v  u ≤ v)

Assertion Inferring Start with an empty list Run for a loop to insert and delete nodes randomlly For each loop iteration Generate environments for program points When the loop is terminated, take intersection of environments at the same program points. For each common environment: Find minimal conjunction P i (u,v) such that P i (u,v)  e i (u,v)

Example 1.int insert(x) 2.{ 3.find(x, mPred,sPred, mSucc,sSucc) head = mPred ˄ head = sPred ˄ tail = mSucc ˄ tail = sSucc 4.node* n := Node(x,2) 5.n.mNext = mPred 6.mPred.mNext := n 7.n.sNext = sPred 8.mPred.mNext := n head = mPred ˄ head = sPred ˄ tail = mSucc ˄ tail = sSucc ˄ mPred = sPred ˄ mSucc = sSucc ˄ mPred → m* n ˄ n → m* mSucc ˄ sPred → s* n ˄ n → s* sSucc ˄ mPred < n ˄ n < mSucc ˄ sPred < n ˄ n < sSucc 9.return 0 10.} 1.int insert(x) 2.{ 3.find(x, mPred,sPred, mSucc,sSucc) head → m mPred ˄ head → s sPred ˄ mSucc → m tail ˄ sSucc → s tail 4.node* n := Node(x,2) 5.n.mNext = mPred 6.mPred.mNext := n 7.n.sNext = sPred 8.mPred.mNext := n head  m mPred ˄ head  s sPred ˄ mSucc  m tail ˄ sSucc  s tail mPred = sPred ˄ mSucc = sSucc ˄ mPred → m* n ˄ n → m* mSucc ˄ sPred → s* n ˄ n → s* sSucc ˄ mPred < n ˄ n < mSucc ˄ sPred < n ˄ n < sSucc 9.return 0 10.}

Example (cont) Common environment at program point 9 head → m* mPred ˄ head → s* sPred ˄ mSucc → m* tail ˄ sSucc → s* tail ˄ mPred = sPred ˄ mSucc = sSucc ˄ mPred → m* n ˄ n → m* mSucc ˄ sPred → s* n ˄ n → s* sSucc ˄ mPred < n ˄ n < mSucc ˄ sPred < n ˄ n < sSucc Invariant : u → s* v  u → m* v

Inductive Assertion Inductive Assertion Assertion is inductive  Holds at initial program points  If it holds at a program point A, it also holds at A’s sucssesor

Assertion Verifing Is  u,v  (P i (u,v)  e i (u,v)) valid in A’ ? E   u,v  (P i (u,v)  e i (u,v)) E’  post(  u,v  (P i (u,v)  e i (u,v))) S A’ A

Assertion Verifing Check that: E’   u,v post(  (P i (u,v)  e i (u,v)))   u,v  (P i (u,v)  e i (u,v)) General Form: E’   X  (X)   X  (Y)

Quantifier Instantiation To prove: E’   X  (X)   X  (Y)  Using terms Y 1, Y 2,…., Y n that appear in E’  Expand as ψ (Y 1 )  …  ψ (Y n )  ψ (Y)   (Y) If unsatisfiable, then so is quantified formula The approach is sound, but incomplete

Example Assume that the invariant  u,v (x → s* y  x → m* y) holds in program point 8 of previous insert function. Then we will show how to prove that its preserved in program point 9 1.int insert(x) 2.{ 3.find(x, mPred,sPred,mSucc,sSucc) head = mPred ˄ head = sPred ˄ tail = mSucc ˄ tail = sSucc 4.node* n := Node(x,2) 5.n.mNext = mPred 6.mPred.mNext := n 7.n.sNext = sPred 8.mPred.mNext := n head = mPred ˄ head = sPred ˄ tail = mSucc ˄ tail = sSucc ˄ mPred = sPred ˄ mSucc = sSucc ˄ mPred → m* n ˄ n → m* mSucc ˄ ˄ n < sSucc sPred → s* n ˄ n → s* sSucc ˄ mPred < n ˄ n < mSucc ˄ sPred < n 9.return 0 10.}

Example(cont) Program point 8  = u → s* v  u → m* v = ˥ (u → s* v) ˅ u → m* v After statement: sPred.sNext := n E’ = sPred  m * n ˄ Program point 9  = ˥ (u → s* v) ˅ (u → s* sPred ˄ n → s* v) ˅ u → m* v Prove : E’   u,y  (u,v)   u,v  (u,v) E’   u,y  (u,v) ˄ ˥  (u 1, v 1 ) is unsastifiable  (u 1,sPred) = ˥ (u 1 → s* sPred) ˅ u 1 → m* sPred  (n, v 1 ) = ˥ (n → s* v 1 ) ˅ n → m* v 1  (u 1, v 1 ) = ˥ (u 1 → s* v 1 ) ˅ (u 1 → s* sPred ˄ n → s* v 1 ) ˅ u → m* v 1 ˥  (u 1, v 1 ) = u 1 → s* v 1 ˄ ˥ (u 1 → m* v 1 ) E ˄  (u 1, v 1 ) ˄ ˥  (u 1, v 1 ) ˄  (u 1,sPred) ˄  (n, v 1 ) = u 1 → m* sPred ˄ sPred → m* n ˄ n → m* v 1 ˄ ˥ (u 1 → m* v 1 ) ˄ (u 1 → s* sPred ˄ n → s* v 1 ) contradiction

Results New method to infer and verify quantidied invariants of multi-pointers structures Apply such method to skiplist algorithms, manually infer and verify the invariant of the skiplist algorithm in the paper: A Simple Optimistic skip-list Algorithm df when we simplify it to two layers skiplist algorithm. df  x,y(x → s* y  x → m* y)  (x → m* y  x ≠ y  x< y) This algorithm is concurrent, so we use thread modular technique compute assertions but its not too important in this thesis

Future Work Implement the framework Develop methods to refine abstract domain automatically

Thank You