1 / 19

Specification and Verification of Object-Oriented Software

Specification and Verification of Object-Oriented Software. K. Rustan M. Leino Research in Software Engineering ( RiSE ) Microsoft Research, Redmond, WA. part 4 International Summer School Marktoberdorf Marktoberdorf , Germany 11 August 2008. Example: Queue. Demo: Queue.dfy. :Queue.

Download Presentation

Specification and Verification of Object-Oriented Software

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Specification and Verification of Object-Oriented Software K. Rustan M. Leino Research in Software Engineering (RiSE)Microsoft Research, Redmond, WA part 4 International Summer School Marktoberdorf Marktoberdorf, Germany 11 August 2008

  2. Example: Queue • Demo: Queue.dfy :Queue tail head :Node :Node :Node :Node

  3. Parallel field update • foreach (x in S) { x.f := E; } Homework

  4. Capturing a parameter method Init() { this.g := new Guitar;} methodInitFromGuitar(gt: Guitar) { this.g := gt;}

  5. Capturing a parameter methodInitFromGuitar(gt: Guitar)requiresgt ≠ null gt.Valid();requiresthis  gt.footprint;modifies {this};ensures Valid();ensuresfresh(footprint – {this} – gt.footprint);{this.g := gt; this.footprint := {this} + {g} + g.footprint; } Does gt.Valid() holdafter InitFromGuitar?

  6. A caller method Client() {varkim := new Guitar; callkim.Init(); var r := newRockBand; callr.InitFromGuitar(kim); callkim.Strum(); callr.Play(); } allowed error

  7. Demo • RockBand0.dfy

  8. Borrowing a parameter method Session(org: Organ) { … callg.Strum(); callorg.Grind(); … }

  9. Borrowing a parameter method Session(org: Organ) requires Valid()  org ≠ null  org.Valid(); modifies footprint, org.footprint; ensures Valid  org.Valid(); ensuresfresh(footprint – old(footprint)); ensuresfresh(org.footprint – old(org.footprint));

  10. A client method Client() { var r := newRockBand; callr.Init(); var b3 := new Organ; call b3.Init(); callr.Session(b3); callr.Play(); call b3.Grind(); }

  11. Demo • RockBand1.dfy

  12. Borrowing a parameter, variation method Session(org: Organ) … ensuresfresh(footprint – old(footprint)); ensuresfresh(org.footprint – old(org.footprint)); ensuresfresh(footprint + org.footprint – old(footprint) – old(org.footprint)); ensures footprint !! org.footprint; requires footprint !! org.footprint;

  13. Demo • RockBand1.dfy, variation

  14. Hiding a definition • function F(p: T) returns (U) reads R; • axiom ( h0: HeapType, h1: HeapType, this: C, p: T IsHeap(h0)  IsHeap(h1) ( o,f  (o,f)  R  h0[o,f] = h1[o,f])  #F(h0,this,p) = #F(h1,this,p));

  15. Example: BinaryTree • IntSet.dfy

  16. Example: List • List.dfy (see pre-lecture notes for Reverse)

  17. Specifications in Spec# • non-null types • Valid() implicit (declared via invariant) • [Rep] for components of aggregates • [Captured] (“borrowed” is default) • modifies this.* implicit • modifies p.* implicit for “committed” p

  18. Combining access and value • Implicit dynamic frames [Smans et al.] • Separation logic[Reynolds, O’Hearn, Parkinson, …]

  19. Summary • Design semantics in terms of an intermediate language! • can support different logics: first-order, higher-order, separation, etc. • Research problem: how to specify programs • Trade-offs in specification styles: • economic (non-verbose) specifications • flexibility, expressibility • automation • Links: • http://research.microsoft.com/~leino • http://research.microsoft.com/specsharp

More Related