verification techniques for
play

Verification Techniques for Object Invariants Peter Mller - PowerPoint PPT Presentation

A Unified Framework for Verification Techniques for Object Invariants Peter Mller Microsoft Research Joint work with Sophia Drossopoulou and Adrian Francalanza 2 Object Invariants Express consistency criteria of objects Support


  1. A Unified Framework for Verification Techniques for Object Invariants Peter Müller Microsoft Research Joint work with Sophia Drossopoulou and Adrian Francalanza

  2. 2 Object Invariants  Express consistency criteria of objects  Support induction scheme - Established by constructors - Preserved by all methods - Potentially broken within method body  Challenges - Call-backs - Multi-object invariants - Subclass invariants Peter Müller – FOOL 2008

  3. 3 Textbook Solution class C { class Client { int a, b; C c; invariant 0 ≤ a < b; invariant c.a ≤ 10 ; } C( ) { a := 0; b := 3; } Assume invariant  void m( ) { class Sub extends C { int k := 10 / ( b – a ); invariant a ≤ 10 ; Prove a := a + 3; } invariant of n( ); C and its b := ( k + 4 ) * b; subclasses } class Client { void set(C c) { c.a := -1; } n( ) { m( ); } } } Peter Müller – FOOL 2008

  4. 4 Verification Techniques Differ in  Invariant semantics - When are which invariants expected to hold?  Admissible invariants - Which objects may an invariant depend on  Proof obligations - What has to be proven when?  Program restrictions - Which objects may receive method calls or field updates?  Type systems Peter Müller – FOOL 2008

  5. 5 Approach  Develop formal framework - Independent of type system and verification logic - Characterize techniques in terms of 7 framework parameters  Define soundness - Identify 5 criteria on framework parameters that are sufficient for soundness  Instantiate framework - Obtain six techniques from the literature Peter Müller – FOOL 2008

  6. 6 Areas and Regions  Object areas - Describe sets of objects - Assume (do not define) interpretation [[ a ]]h,o  dom( h )  Invariant regions - Describe sets of object-class pairs - Assume (do not define) interpretation [[ r ]]h,o  { (o’, C) | class(o’) <: C } Peter Müller – FOOL 2008

  7. 7 Areas and Regions: Example  Areas a ::= self | any [[ self ]]h,o = { o } [[ any ]]h,o = dom( h )  Regions r ::= emp | self | any [[ emp ]]h,o = { } [[[ self ]]h,o = { (o, C) | class(o) <: C } [[ any ]]h,o = { (o’, C) | class(o’) <: C } Peter Müller – FOOL 2008

  8. 8 Framework Parameters  Invariant semantics - X (C) Invariants expected at visible states of C.m - V (C) Invariants possibly violated by C.m  Admissible invariants - D (C) Invariants depending on C fields  Proof obligations - P (C, a ) Proof obligation for C.m before calls in a - E (C) Proof obligation C.m before end  Program restrictions - U (C,D) Objects whose D-fields may be updated by C.m - C (C,D) Objects whose D-methods may be called from C.m Peter Müller – FOOL 2008

  9. 9 Meaning of Parameters: Example invariant 0 ≤ this .a < this .b; // check ( this ,C) is in D invariant 0 ≤ this .a < this .b; // check ( this ,C) is in D invariant 0 ≤ this .a < this .b; // check ( this ,C) is in D invariant 0 ≤ this .a < this .b; // check ( this ,C) is in D invariant 0 ≤ this .a < this .b; void m( ) { void m( ) { void m( ) { void m( ) { void m( ) { // assume X // assume X int k := 10 / ( b – a ); int k := 10 / ( b – a ); int k := 10 / ( b – a ); int k := 10 / ( b – a ); int k := 10 / ( b – a ); // check this is in U // check this is in U // check this is in U this .a := this .a + 3; this .a := this .a + 3; this .a := this .a + 3; this .a := this .a + 3; this .a := this .a + 3; // prove P X \ V holds // check this is in C // check this is in C // check this is in C this .n( ); this .n( ); this .n( ); this .n( ); this .n( ); this .b := ( k + 4 ) * this .b; // check this is in U this .b := ( k + 4 ) * this .b; // check this is in U this .b := ( k + 4 ) * this .b; // check this is in U this .b := ( k + 4 ) * this .b; this .b := ( k + 4 ) * this .b; // prove E // assume X // assume X } } } } } Peter Müller – FOOL 2008

  10. 10 Parameters: Textbook Invariants Textbook X (C) any V (C) self D (C) self P (C, a ) emp E (C) self U (C,D) self C (C,D) any Peter Müller – FOOL 2008

  11. 11 Programming Language  Expressions and types e ::= this | x | … | e& prove r t ::= C a  Runtime expressions e ::= o| s∙e | … | FatalExc | VerifExc  Assume judgment: h ╞ o,C  Assume (do not define) type system  ├ e : C a - Main judgment - Make requirements (soundness, etc.) Peter Müller – FOOL 2008

  12. 12 Invariant Semantics  Method calls h ╞ [[ X ]]h,s( this ) h ╞ [[ X ]]h,s( this ) s ∙ call e,h → s ∙ ret e,h s ∙ call e,h → FatalExc,h  Method termination h ╞ [[ X ]]h,s( this ) h ╞ [[ X ]]h,s( this ) s ∙ ret v,h → v,h s ∙ ret v,h → FatalExc,h  Proof obligation h ╞ [[ r ]]h,s( this ) h ╞ [[ r ]]h,s( this ) s ∙v& prove r ,h → v,h s ∙v& prove r ,h → VerifExc,h Peter Müller – FOOL 2008

  13. 13 Verified Programs  Field updates: check area  ├ e : C a a  U (class(  ),C’) C has field f defined in C’ …  ├ vf e.f := e’  Method calls: check area, verify invariants  ├ e : C a a  C (class(  ),C’) C inherits m from C’ …  ├ vf e.m(e’ & prove P (C’, a )) Peter Müller – FOOL 2008

  14. 14 Soundness  A verification technique is sound if the following properties hold for each well-typed, verified program P:  Execution of P does not lead to FatalExc  In each execution state  of P, the following properties hold for each stack frame for a method C.m: - The invariants in X (C) \ V (C) hold - If  is a visible state of m, the invariants in X (C) hold Peter Müller – FOOL 2008

  15. 15 Soundness Criteria S1: a  C (C,D)  ( a  X (D)) \ ( X (C) \ V (C))  P (C, a ) S2: V (C)  X (C)  E (C) C (C,D)  ( V (D) \ X (D) )  V (C) S3: U (C,D)  D (D)  V (C) S4: X (C)  X (D) C <: D  S5: V (C) \ X (C)  V (D) \ X (D) Peter Müller – FOOL 2008

  16. 16 Soundness Theorem A verification technique that satisfies S1 – S5 is sound Peter Müller – FOOL 2008

  17. 17 Soundness: Textbook Invariants any \ ( X (C) \ V (C))  P (C, a ) any \ (any \ self)  emp a  C (C,D)  ( a  X (D)) \ ( X (C) \ V (C))  P (C, a ) X (C) any V (C) self self  any  self V (C)  X (C)  E (C) D (C) self any  (self \ any)  self P (C, a ) C (C,D)  ( V (D) \ X (D) )  V (C) emp E (C) self self  self  self U (C,D)  D (D)  V (C) U (C,D) self C (C,D) any any  any X (C)  X (D) C <: D  C <: D  self \ any  self \ any V (C) \ X (C)  V (D) \ X (D) Peter Müller – FOOL 2008

  18. 18 Summary  Parametric w.r.t. underlying type system and verification logic  Abstract explanation how technique works  Criteria for comparisons  Guidelines for the development of further techniques  Instantiation for six techniques from the literature, found one unsoundness Peter Müller – FOOL 2008

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend