Object Invariants in Dynamic Contexts K.R.M. Leino and P. Muller 15-819: Objects and Aspects Presented by Jonathan Aldrich.

Slides:



Advertisements
Similar presentations
1 Lecture 5 Towards a Verifying Compiler: Multithreading Wolfram Schulte Microsoft Research Formal Methods 2006 Race Conditions, Locks, Deadlocks, Invariants,
Advertisements

Verification of object-oriented programs with invariants Mike Barnett, Robert DeLine, Manuel Fahndrich, K. Rustan M. Leino, Wolfram Schulte Formal techniques.
Joint work with Mike Barnett, Robert DeLine, Manuel Fahndrich, and Wolfram Schulte Verifying invariants in object-oriented programs K. Rustan M. Leino.
Checking correctness properties of object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 4 EEF summer school on Specification,
Object Invariants in Specification and Verification K. Rustan M. Leino Microsoft Research, Redmond, WA Joint work with: Mike Barnett, Ádám Darvas, Manuel.
Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 3 Summer school on Formal Models.
Lecture 4 Towards a Verifying Compiler: Data Abstraction Wolfram Schulte Microsoft Research Formal Methods 2006 Purity, Model fields, Inconsistency _____________.
Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 8.
Constraint Semantics for Abstract Read Permissions 28 th July 2014, FTfJP, Uppsala John Tang Boyland (UW-Milwaukee/ETH Zurich) Peter Müller, Malte Schwerhoff,
Automated Software Verification with a Permission-Based Logic 20 th June 2014, Zürich Malte Schwerhoff, ETH Zürich.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
Reasoning About Code; Hoare Logic, continued
A simple sequential reasoning approach for sound modular verification of mainstream multithreaded programs Wolfram Schulte & Bart Jacobs Microsoft Research.
K. Rustan M. Leino Microsoft Research Peter Müller ETH Zurich Angela Wallenburg Chalmers University.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 9.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA, USA 3 December 2008 U. Lugano Lugano, Switzerland.
Inferring Object Invariants Bor-Yuh Evan ChangK. Rustan M. Leino University of California, BerkeleyMicrosoft Research January 21, 2005 AIOOL 2005 Paris,
ECI 2007: Specification and Verification of Object-Oriented Programs Lecture 2 Courtesy: K. Rustan M. Leino and Wolfram Schulte.
Lecture 2 Towards a Verifying Compiler: Logic of Object oriented Programs Wolfram Schulte Microsoft Research Formal Methods 2006 Objects, references, heaps,
Verifying Correct Usage of Atomic Blocks and Typestate Nels E. Beckman Nels E. Beckman, Kevin Bierhoff, and Jonathan Aldrich Carnegie Mellon University.
Alias Annotations for Program Understanding Jonathan Aldrich Valentin Kostadinov Craig Chambers University of Washington.
Introduction to Spec# Programming System Yossi Peery Advanced SW Tools Seminar TAU Nov 2006.
K. Rustan M. Leino RiSE, Microsoft Research Typing, Analysis and Verification of Heap-Manipulating Programs Dagstuhl, Germany 20 July 2009.
Modular Specification of Frame Properties in JML Peter Müller Arnd Poetszch Heffter Gary T. Leavens Encapsulation Seminar Tel Aviv University 2005 Presented.
ECI 2007: Specification and Verification of Object-Oriented Programs Lecture 3 Courtesy: K. Rustan M. Leino and Wolfram Schulte.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Building a program verifier K. Rustan M. Leino Microsoft Research, Redmond, WA 10 May 2006 Guest lecture, Shaz Qadeer’s cse599f, Formal Verification of.
Modular Shape Analysis for Dynamically Encapsulated Programs Noam Rinetzky Tel Aviv University Arnd Poetzsch-HeffterUniversität Kaiserlauten Ganesan RamalingamMicrosoft.
Using data groups to specify and check side effects K. Rustan M. Leino Microsoft Research Arnd Poetzsch-Heffter Universität Kaiserslautern Yunhong Zhou.
Going beyond a basic ownership system in Spec# K. Rustan M. Leino Microsoft Research, Redmond, WA Joint work with: Peter Müller Angela Wallenburg ESF workshop.
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Modular Shape Analysis for Dynamically Encapsulated Programs Noam Rinetzky Tel Aviv University Arnd Poetzsch-HeffterUniversität Kaiserlauten Ganesan RamalingamMicrosoft.
Using data groups to specify and check side effects K. Rustan M. Leino Microsoft Research Arnd Poetzsch-Heffter Universität Kaiserslautern Yunhong Zhou.
Reasoning about Multiple Related Abstractions with MultiStar Stephan van Staden, Cristiano Calcagno Chair of Software Engineering.
Ownership Types for Object Encapsulation Authors:Chandrasekhar Boyapati Barbara Liskov Liuba Shrira Presented by: Charles Lin Course: CMSC 631.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Inference and Checking of Object Ownership Wei Huang 1, Werner Dietl 2, Ana Milanova 1, Michael D. Ernst 2 1 Rensselaer Polytechnic Institute 2 University.
Using Data Groups to Specify and Check Side Effects K. Rustan M. Leino, Arnd Poetzsch- Heffter, and Yunhong Zhou Presented by Jonathan Aldrich.
Model Programs for Preserving Composite Invariants SAVCBS 2008 Challenge Problem Solution by Steve Shaner, Hridesh Rajan, Gary T. Leavens Iowa State and.
Using and Building an Automatic Program Verifier K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond Lecture 3 Marktoberdorf.
Semantic Analysis. Find 6 problems with this code. These issues go beyond syntax.
Applications of extended static checking K. Rustan M. Leino Compaq SRC K. Rustan M. Leino Compaq SRC Systems Research Center Invited talk, SAS’01, Paris,
Reasoning about object structures with Spec# K. Rustan M. Leino Microsoft Research, Redmond, WA Joint work with: Mike Barnett, Ádám Darvas, Manuel Fähndrich,
1 Proving aspect-oriented programming laws Leonardo Cole Paulo Borba Alexandre Mota Informatics Center Federal University of.
Rustan Leino RiSE, Microsoft Research, Redmond MIT 5 June 2009 Joint work with: Peter Müller, ETH Zurich Jan Smans, KU Leuven.
Verification of Programs with Inspector Methods Bart Jacobs and Frank Piessens Dept. CS, K.U.Leuven, Belgium.
A Universe-Type-Based Verification Technique for Mutable Static Fields and Methods Alexander J Summers Sophia Drossopoulou Imperial College London Peter.
Spec# Andreas Vida. Motivation Correct and maintainable software Correct and maintainable software Cost effective software production Cost effective software.
K. Rustan M. Leino and Wolfram Schulte Microsoft Research, Redmond ESOP 2007 Braga, Portugal 28 March 2007.
A Type System for Borrowing Permissions Karl Naden, Rob Bocchino Jonathan Aldrich, Kevin Bierhoff POPL – January 27, 2012 School of Computer Science.
Encoding Ownership Types in Java Nicholas Cameron James Noble Victoria University of Wellington, New Zealand.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 2 International Summer School Marktoberdorf Marktoberdorf,
An Introduction to Automated Program Verification with Permission Logics 15 th May 2015, Systems Group, ETH Zurich Uri Juhasz, Ioannis Kassios, Peter Müller,
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Spec# John Lefor Program Manager Developer Division, Microsoft.
1 Verification of object-oriented programs with invariants Mike Barnett, Robert DeLine, Manuel Fahndrich, K. Rustan M. Leino, Wolfram Schulte ECOOP 2003.
Reasoning about object structures with Spec# K. Rustan M. Leino Microsoft Research, Redmond, WA Joint work with: Mike Barnett, Ádám Darvas, Manuel Fähndrich,
Jeremy Nimmer, page 1 Automatic Generation of Program Specifications Jeremy Nimmer MIT Lab for Computer Science Joint work with.
Enhancing Modular OO Verification with Separation Logic
Specification techniques for verifying object-oriented software
Class-local object invariants
Objects and Aspects: What we’ve seen so far
Hoare-style program verification
Method Verification CS/SWE 332 Paul Ammann.
Object Encapsulation CSC 422 Dr. Spiegel.
A Considerate Specification of the Composite Pattern
Method Verification Paul Ammann.
Presentation transcript:

Object Invariants in Dynamic Contexts K.R.M. Leino and P. Muller : Objects and Aspects Presented by Jonathan Aldrich

Outline Problem –Modular enforcement of invariants –Separate reasoning with callbacks and inheritance Solution –Class invariants –Partial packing and unpacking –“Ownership” relation Discussion

Callbacks and Invariants class T { int a, b ; invariant 0 <= a < b public T( ) { a := 0 ; b := 3 ; } public void m(...) { int k := 100/(b - a) ; a := a +3 ; P(...) ; b := (k + 4). b ; } What if P calls m? –Soundness: Must ensure it doesn’t, or that the invariant is not assumed by m

Inheritance and Invariants class Derived extends Base { int a, b ; invariant 0 <= a < b public void m(...) { int k := 100/(b - a) ; super.m(...) ; a := a +3 ; P(...) ; b := (k + 4). b ; } What about the invariants of Base? –Modularity: would like to assume that super call ensures them –Need notion entering and leaving a class scope

Class Invariants class C extends B { int w ; invariant w < 100 ;... } class B extends A { int z ; invariant y < z ;... } class A extends object { int x, y ; invariant x < y ;... } inv = A –Invariant A must hold –B and C may or may not hold C:w = 43 B:z = 6 A:x = 5 y = 7 object: inv = A

Class Invariants class C extends B { int w ; invariant w < 100 ;... } class B extends A { int z ; invariant y < z ;... } class A extends object { int x, y ; invariant x < y ;... } o.z = y+1; pack o as B; pack o as C; continue… C:w = 43 B:z = 6 A:x = 5 y = 7 object: inv = A

Class Invariants class C extends B { int w ; invariant w < 100 ;... } class B extends A { int z ; invariant y < z ;... } class A extends object { int x, y ; invariant x < y ;... } o.z = y+1; pack o as B; pack o as C; continue… C:w = 43 B:z = 8 A:x = 5 y = 7 object: inv = A

Class Invariants class C extends B { int w ; invariant w < 100 ;... } class B extends A { int z ; invariant y < z ;... } class A extends object { int x, y ; invariant x < y ;... } o.z = y+1; pack o as B; pack o as C; continue… C:w = 43 B:z = 8 A:x = 5 y = 7 object: inv = B

Class Invariants class C extends B { int w ; invariant w < 100 ;... } class B extends A { int z ; invariant y < z ;... } class A extends object { int x, y ; invariant x < y ;... } o.z = y+1; pack o as B; pack o as C; continue… C:w = 43 B:z = 8 A:x = 5 y = 7 object: inv = C

Inheritance and Invariants class Derived extends Base { int a, b ; invariant 0 <= a < b public void m(...) { unpack this from Derived int k := 100/(b - a) ; super.m(...) ; // unpacks and re-packs Base a := a +3 ; P(...) ; b := (k + 4). b ; pack this as Derived } Incremental unpacking and re-packing supports modular verification

Callbacks and Invariants class T { int a, b ; invariant 0 <= a < b public T( ) { a := 0 ; b := 3 ; } public void m(...) requires this. inv = T { unpack this from T ; int k := 100/(b - a) ; a := a +3 ; P(...) ; b := (k + 4). b ; pack this as T ; } What if P calls m? –It must first restore the invariant and pack this as T, because m’s precondition assumes that T is packed

Invariants and Sub-objects class BTree { int i ; BTree left, right ; invariant (left != null)  left.i < i  (right != null)  right.i ≥ i ; } How to ensure invariant modularly? –What if someone modifies left.i without going through the current object?

Ownership, Boogie Style p is owned by o at T –p.owner = [o,T] p is committed –p.committed All invariants hold for committed objects –p.committed  p.inv = type(p) Object is committed when owner is packed –p.owner = [o,T]  (p.committed  o.inv ≤ T)

Invariants and Sub-objects class BTree { int i ; rep BTree left, right ; invariant left.owner = [this, BTree] ; invariant right.owner = [this, BTree] ; invariant (left != null)  left.i < i  (right != null)  right.i ≥ i ; } Invariant can rely on owned objects –unpack this, invariants hold for children –children can’t be unpacked (and thus can’t have broken invariants) unless owner is first unpacked

Ownership Transfer transferable class Possession {...} class Person { rep Possession possn ; void donateTo(Person p) requires ¬committed È inv = Person ; requires possn = nullÈ Ètype(possn) = Possession ; requires p = null È p = this È ¬p.committed È p.inv = Person ; modifies possn, p.possn ; { unpack this from Person ; unpack p from Person ; unpack possn from Possession ; transfer possn to [p, Person] ; pack possn as Possession ; p.possn := possn ; pack p as Person ; possn := null ; pack this as Person ; }... }

Is “ownership” really Ownership? Ownership in Boogie –Allows external aliases (but can’t mutate through them) –Supports ownership transfer –Heavyweight: must track precisely Classical Ownership –External aliases –No ownership transfer –Lightweight: can track with types I find this all a bit misleading… probably better to use a different term

explain visibility rules field update rules

Discussion Practicality –Requires very careful tracking of containing object state –Forbids iterators, etc. –Strong conditions for transfer Lessons for informal reasoning? Applicability to aspects?