On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.

Slides:



Advertisements
Similar presentations
Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Soundness of Higher-order Frame Rules (How did category theory help me?) Hongseok Yang Seoul National University Joint work with Lars Birkedal and Noah.
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Verifying Executable Object-Oriented Specifications with Separation Logic Stephan van Staden, Cristiano Calcagno, Bertrand Meyer.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
A Rely-Guarantee-Based Simulation for Verifying Concurrent Program Transformations Hongjin Liang, Xinyu Feng & Ming Fu Univ. of Science and Technology.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
A simple sequential reasoning approach for sound modular verification of mainstream multithreaded programs Wolfram Schulte & Bart Jacobs Microsoft Research.
Ashish Kundu CS590F Purdue 02/12/07 Language-Based Information Flow Security Andrei Sabelfield, Andrew C. Myers Presentation: Ashish Kundu
Modular Verification of Concurrent Assembly Code with Dynamic Thread Creation and Termination Xinyu Feng Yale University Joint work with Zhong Shao.
An Open Framework for Certified System Software Xinyu Feng Yale University.
Certifying Low-Level Programs with Hardware Interrupts and Preemptive Threads Xinyu Feng Toyota Technological Institute at Chicago Joint work with Zhong.
Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac.
10/19/2007TTI-C PL-Lunch Certified Concurrent Code with Interrupts Xinyu Feng Joint work with Zhong Shao (Yale University) and Yuan Dong (Tsinghua University)
An Open Framework for Foundational Proof-Carrying Code Xinyu Feng Yale University Joint work with Zhaozhong Ni (Yale, now at MSR), Zhong Shao (Yale) and.
Modular Verification of Assembly Code with Stack-Based Control Abstractions Xinyu Feng Yale University Joint work with Zhong Shao, Alexander Vaynberg,
Local Reasoning Peter O’Hearn John Reynolds Hongseok Yang.
1 A Modular Checker for Multithreaded Programs Cormac Flanagan HP Systems Research Center Joint work with Shaz Qadeer Sanjit A. Seshia.
Thread-Modular Verification Shaz Qadeer Joint work with Cormac Flanagan Stephen Freund Shaz Qadeer Joint work with Cormac Flanagan Stephen Freund.
Mechanized Metatheory for User- Defined Type Extensions Dan Marino, Brian Chin, Todd Millstein UCLA Gang Tan Boston College Robert J. Simmons, David Walker.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 0 1 September 2009 FOSAD 2009, Bertinoro, Italy.
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
Compositional Verification of Termination-Preserving Refinement of Concurrent Programs Hongjin Liang Univ. of Science and Technology of China (USTC) Joint.
Verifying Concurrent Objects under Fair Scheduling Hongjin Liang University of Science and Technology of China (USTC) Joint work with Xinyu Feng.
Aquinas Hobor and Cristian Gherghina (National University of Singapore) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Concurrency Verification. Why concurrency verification Concurrent programs show in many systems –Multi-task support in OS kernels –Handling interrupts.
Checking Reachability using Matching Logic Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
A Certifying Compiler and Pointer Logic Zhaopeng Li Software Security Lab. Department of Computer Science and Technology, University of Science and Technology.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
Semantics In Text: Chapter 3.
Separation and Information Hiding Peter W. O’Hearn (Queen Mary, University of London) John C. Reynolds (Carnegie Mellon University) Hongseok Yang (Seoul.
Defining Liveness by Bowen Alpern and Fred B. Schneider Presented by Joe Melnyk.
Beyond Reachability: Shape Abstraction in the presence of Pointer Arithmetic Hongseok Yang (Queen Mary, University of London) (Joint work with Dino Distefano,
Program Logic for Concurrency Refinement Verification Xinyu Feng University of Science and Technology of China Joint work with Hongjin Liang (USTC) and.
Encoding Ownership Types in Java Nicholas Cameron James Noble Victoria University of Wellington, New Zealand.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Properties as Processes : FORTE slide Properties as Processes: their Specification and Verification Joel Kelso and George Milne School of Computer.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
Presented by: Belgi Amir Seminar in Distributed Algorithms Designing correct concurrent algorithms Spring 2013.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
1 Verification of object-oriented programs with invariants Mike Barnett, Robert DeLine, Manuel Fahndrich, K. Rustan M. Leino, Wolfram Schulte ECOOP 2003.
VPERM: Variable Permissions for Concurrency Verification Duy-Khanh Le, Wei-Ngan Chin, Yong-Meng Teo ICFEM, Kyoto, Japan, Nov 2012.
Program Analysis and Verification
Extension of Separation Logic for Stack Reasoning Jiang Xinyu.
Matching Logic An Alternative to Hoare/Floyd Logic
Threads Cannot Be Implemented As a Library
Joint work with Yong Li, Xinyu Feng, Zhong Shao and Yu Zhang
(One-Path) Reachability Logic
Concurrency Verification
Stateful Manifest Contracts
Concurrent Separation Logic
Lecture 5 Floyd-Hoare Style Verification
Progress of Concurrent Objects with Partial Methods
Axiomatic semantics Points to discuss: The assignment statement
Separation Logic and Concurrency Verification
Predicate Transformers
Concurrent Separation Logic
Concurrent Separation Logic
Xinyu Feng University of Science and Technology of China
Program correctness Axiomatic semantics
Program Analysis and Verification
Presentation transcript:

On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and Zhong Shao

Motivation Concurrency verification is challenging! T1 T2 Exponential state space caused by interleaving of execution. Memory aliasing makes it harder to ensure non-interference. Modularity is the key!

Two kinds of modularity Control modularity –a.k.a. thread-modularity –each thread is verified independently of others Data modularity –a.k.a. information hiding –each thread only cares about data it uses

Existing work Assume-Guarantee (A-G) reasoning [Misra&Chandy’81, Jones’83] thread modularity general: no restriction over synchronization pattern  spec of A&G requires global data invariants Concurrent Separation Logic (CSL) [O’Hearn, Brookes 2004] thread modularity data modularity: local reasoning  restrictive synchronization pattern  shared resources can be accessed only inside critical regions

Our Contributions SAGL: combining CSL and A-G reasoning –extend A-G logic with local reasoning better data modularity (than A-G reasoning) thread modularity no restriction over synchronization pattern A formal study of the relationship between CSL and A-G reasoning

Outline of this talk Background –Concurrent Separation Logic –Assume-Guarantee reasoning SAGL: combination of CSL & A-G reasoning Interpretation of CSL in SAGL

Concurrent Separation Logic Assertions capture ownerships of resources Cannot access resource without ownership Shared resources are protected by critical regions (CRs) Transfer of ownership at boundary of CR l  n

CSL assertions l  n n l p  qp  q pq emp empty heap p  qp  q p  q

Locks and Critical Regions Lock-based critical regions (CR): l.acq(); … l.rel() Invariants about memory protected by locks:  = {l 1  r 1, …, l n  r n } r 1  rn rn l1l1 lnln

p1p1 (l2)(l2) p2p2 (l1)(l1) p1p1 (l2)(l2) (l1)  p2(l1)  p2 Concurrent Separation Logic p1p1 (l2)(l2) p2p2 (l1)(l1) l 1.acq() l 1.rel() … p1p1 (l2)(l2) (l1)  p2(l1)  p2

Example: List x …  = { l  List(x) } getNode(): l.acq(); … l.rel(); -{emp} -{emp * List(x)}; -{Node(y) * List(x)} -{Node(y)} x … y

Concurrent Separation Logic Thread modularity Data modularity by local reasoning –do not need knowledge of other threads’ data  Ownership transfer is bound with CRs –requires built-in critical regions –hard to support ad-hoc synchronizations  ┝ {p} C {q}

Outline of this talk Background –Concurrent Separation Logic –Assume-Guarantee reasoning SAGL: combination of CSL & A-G reasoning Interpretation of CSL in SAGL

Assume-Guarantee Reasoning Thread T and its environment –Environment: the collection of all other threads except T A: assumption about environment’s transition G: guarantee to the environment a: precondition

Assume-Guarantee Reasoning To certify each thread:  S, S'. a S  A S S'  a S' Non-Interference of threads: G 1  …  G i-1  G i+1  …  G n  A i G i  A 1  …  A i-1  A i+1  …  A n preservation of precondition: G S Next c (S) transitions satisfy the guarantee:

A-G reasoning a1a2a1a2 a 1  a 2 a1a2a1a2 G2G2 A1A1 A2A2 G1G1 a2a2 a2a2 a1a1 a1a1

A-G reasoning Thread modular –separate verification of threads Not require CRs –but need to know smallest granularity of transitions  A, G: global invariants about all resources –hard to define –lack data modularity  Need to check A and G at every step (A,G) ┝ {a} C {a’}

Example: data modularity broken … [100] := m; … [101] := n; … G 1 : [101] = [101]' A 1 : [100] = [100]' G 2 : [100] = [100]' A 2 : [101] = [101]'

Outline of this talk Background –Concurrent Separation Logic –Assume-Guarantee reasoning SAGL: combination of CSL & A-G reasoning Interpretation of CSL in SAGL

SAGL: Separated A-G Logic Partition of each thread’s resource –shared and private –shared can be accessed at any time governed by A and G –exclusive access to private resources follows local reasoning in CSL not specified in A and G better memory modularity Dynamic change of partition –may occur at any point, not tied with CR boundaries

SAGL: Specification of Threads A, G: assumption and guarantee a: precondition about shared resources p: precondition about private resources Spec for T i : (( a i, p i ), A i, G i )

p1p1 a1a2a1a2 p2'p2' p1p1 a1a2a1a2 p2p2 SAGL – Access Private Resource

Example: regained data modularity … [100] := m; … [101] := n; … {(emp, 100  _) } -{(emp, 101  _)} G 1 : emp A 1 : emp G 2 : emp A 2 : emp

p1p1 a1a2'a1a2' p2p2 p1p1 a1a2a1a2 p2p2 SAGL – Access Shared Resource A1A1 G2G2 a1a1 a1a1 A-G reasoning: a special case where p 1 and p 2 are emp.

p1p1 a 1  a 2  p 2  p1p1 a1a2a1a2 p2p2 p1p1 a1a2'a1a2' p2p2 SAGL - Redistribution A1A1 G2G2 A1A1 G2G2

SAGL Thread modular –separate verification of threads Not require CRs –but need to know smallest granularity of transitions A, G: only specifies shared resources –better modularity Need to check A and G at every step –but the check is trivial if only private resource is used (A,G) ┝ {(a,p)} C {(a’,p’)}

Outline of this talk Background –Concurrent Separation Logic –Assume-Guarantee reasoning SAGL: combination of CSL & A-G reasoning Interpretation of CSL in SAGL

p1p1 (l2)(l2) p2p2 (l1)(l1) p1p1 (l2)(l2) (l1)  p2(l1)  p2 Concurrent Separation Logic p1p1 (l2)(l2) p2p2 (l1)(l1) l 1.acq() l 1.rel() … p1p1 (l2)(l2) (l1)  p2(l1)  p2

Implicit Invariants in CSL Shared resources are well-formed outside of critical regions. Invariants of shared resources: a   Inv( l 1 )  …  Inv( l n ) At each program point: (p 1  …  p n )  a  S Inv( l i )  ( free (l i )   (l i ))  (  free (l i )  emp )

p1p1 a1a2a1a2 p2p2 Specialization of SAGL At each program point in SAGL: (p 1  …  p n )  (a 1  …  a n ) Specialize a i into a  (p 1  …  p n )  (a   …  a  ) Specialize A and G to enforce a  at every step A  S S'  a  S  a  S' G  S S'  a  S  a  S'  (p 1  …  p n )  a 

Interpretation of CSL in SAGL If  ┝ CSL {p} C {q}, then (A ,G  ) ┝ SAGL {(a ,p)} C {(a ,q)} Also a new way to prove the soundness of CSL! The soundness of SAGL is proved following the syntactic approach (by proving progress & preservation). Proofs have been formalized in Coq.

getNode(): l.acq(); … l.rel(); -{(a , emp)} Example: List  = { l  List(x) } -{(emp, emp * List(x))}; -{(emp, Node(y) * List(x))} -{(List(x), Node(y))} a  = free( l )  List(x)   free( l )  emp x … x … y  a a  a a  a a

Conclusion SAGL –combination of local reasoning with A-G reasoning –improved modularity than A-G reasoning –more flexible than CSL Embedding of CSL in SAGL –formalization of invariants: shared resources are well-formed outside of CRs –a new way to prove the soundness of CSL

Thank you!

Example: GCD while(x <> y){ if (x > y) x = x – y; } while(x <> y){ if (y > x) y = y – x; } initially: x =  ; y =  ; result: x = GCD( ,  ); y = GCD( ,  ); G 1 : (y = y')  (x  y  x = x')  (GCD(x, y) = GCD(x', y')) A 1 : (x = x')  (y  x  y = y')  (GCD(x, y) = GCD(x', y')) G 2 = A 1 ; A 2 = G 1

Example: GCD while(x <> y){ if (x > y) x = x – y; } while(x <> y){ if (y > x) y = y – x; } initially: x =  ; y =  ; result: x = GCD( ,  ); y = GCD( ,  ); Hard to certify using CSL without rewriting the program and adding auxiliary variables.

Problem with CSL Needs to rewrite code using CRs –then needs to prove semantic preservation CSL is a program logic –what if the language does not support CRs? only use “ cas ” to do synchronization

Example: malloc x = alloc(1); [x] = 2; if ( odd([x]) ){ //should never reach here } y = alloc(1); [y] = 3; if ( even([y]) ){ //should never reach here } G 1 : ??? A 1 : ??? G 2 : ??? A 1 : ??? { emp }  { x  _ } { y  _ } 

Example: malloc x = alloc(1); [x] = 2; if ( odd([x]) ){ //should never reach here } y = alloc(1); [y] = 3; if ( even([y]) ){ //should never reach here } G 1 : emp A 1 : emp G 2 : emp A 1 : emp -{ (emp, emp) } -{ (emp, emp } -{ (emp, x  _) } -{ (emp, y  _) }

Soundness of SAGL Safety: progress & preservation Partial correctness: –assertions assigned to program points hold when we reach these points