static program checking and verification correctness
play

Static program checking and verification Correctness class ArraySet - PowerPoint PPT Presentation

Chair of Softw are Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 June 2007 Slides: Based on KSE06 With kind permission of Peter Mller Static program checking and verification Correctness class ArraySet


  1. Chair of Softw are Engineering Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Slides: Based on KSE06 – With kind permission of Peter Müller Static program checking and verification

  2. Correctness class ArraySet implements Set { class ArraySet implements Set { class ArraySet implements Set { class ArraySet implements Set { class ArraySet implements Set { Behavioral private int [ ] array; private int [ ] array; private int [ ] array; private int [ ] array; private int [ ] array; Specification private int next; private int next; private int next; private int next; private int next; … … … … … Semantic Rules public void insert( int i ) { public void insert( int i ) { public void insert( int i ) { public void insert( int i ) { public void insert( int i ) { for ( int j = 0; j < next; j-- ) for ( int j = 0; j < next; j-- ) for ( int j = 0; j < next; j-- ) for ( int j = 0; j < next; j-- ) for ( int j = 0; j < next; j-- ) if array[ j ] == i then return true ; if array[ j ] == i then return true ; if array[ j ] == i then return true ; if array[ j ] == i then return true ; if array[ j ] == i then return true ; Context return false ; return false ; return false ; return false ; return false ; Conditions } } } } } } } } } } Syntax Rules Software Engineering, lecture 20: Static program checking and verification 2

  3. Aspects of correctness Behavioral Specification Test, Semantics Verification Semantic Rules Context Semantic Analysis, Conditions Type Checking Syntax Syntax Rules Scanning, Parsing Software Engineering, lecture 20: Static program checking and verification 3

  4. Test and verification Test Verification Objective Objective � Detect bugs � Prove correctness Examples Examples � White box test � Formal verification based on a logic � Black box test � Symbolic execution Problems Problems � Expensive � Successful test does not guarantee correctness � Formal specification of behavior is required Software Engineering, lecture 20: Static program checking and verification 4

  5. Levels of coverage Coverage Program verification Extended static checking Decidability ceiling Type checking Effort Software Engineering, lecture 20: Static program checking and verification 5

  6. Extended static checking ESC/Java developed at DEC, Compaq, and HP Research Fully automated tool Tries to verify � Absence of runtime exceptions and common mistakes e.g. null dereference, array bounds, type cast errors, deadlocks � Simple user-specified contracts invariants, pre/postconditions, loop invariants, assertions Program Program with Error Program with Error specifications Checker/Verifier messages specifications messages Bag.java:18: Array index possibly too large Software Engineering, lecture 20: Static program checking and verification 6

  7. Program checker design tradeoffs Objectives � Fully automated reasoning � As little annotation overhead as possible � Performance Main reason why it’s Not sound called checker and � Errors may be missed not verifier Not complete � Warnings do not always report errors (false alarms) Goal � Cost-effective tool � Find source of possible bugs quickly Software Engineering, lecture 20: Static program checking and verification 7

  8. Tool architecture Annotated Java program Annotated Java program Translator Translator Verification condition Verification condition Valid Automatic Theorem Prover Automatic Theorem Prover Resource exhausted Counterexample context Counterexample context Post Processor Post Processor Warning messages Warning messages Software Engineering, lecture 20: Static program checking and verification 8

  9. Theorem prover: “Simplify” Automatic: No user interaction Refutation based : To prove ϕ it will attempt to satisfy ¬ ϕ � If this is possible, a counterexample is found, and we know a reason why ϕ is invalid � If it fails to satisfy ¬ ϕ then ϕ is considered to be valid Software Engineering, lecture 20: Static program checking and verification 9

  10. Time limits Logic used in Simplify is semi-decidable � Each procedure that proves all valid formulas loops forever on some invalid ones Simplify works with a time limit � When time limit is reached, counterexample is returned � Longer computation might show that returned counterexample is inconsistent Time limits are a source of incompleteness � Spurious counterexamples lead to spurious warnings Software Engineering, lecture 20: Static program checking and verification 10

  11. ESC/ Java2 Successor of ESC/Java Eclipse integration Made specification language compatible with JML Made open source Give it a try! http://secure.ucd.ie/products/opensource/escjava2 Software Engineering, lecture 20: Static program checking and verification 11

  12. Spec# Program verification tool developed at MS Research Superset of C# � non-null types contracts C# everywhere � pre- and postconditions into the future � object invariants Tool support type run-time static checking checks verification � more type checking degree of checking, � compiler-emitted run-time checks effort � static program verification � fully integrated into Visual Studio .NET 2005 Software Engineering, lecture 20: Static program checking and verification 12

  13. Spec# vs. ESC/ Java(2) Similarities � Architecture � Full automation (even theorem prover is the same) � Essential contract language Differences � Spec# is sound � Spec# does modular reasoning price to pay: need to understand methodology Software Engineering, lecture 20: Static program checking and verification 13

  14. Non-null types T x; The value of x is - null or - reference to object whose type is a subtype of T. T ! y; The value of y is - reference to object whose type is a subtype of T, and not null . Software Engineering, lecture 20: Static program checking and verification 14

  15. Types versus assertions Without non-null types: Person(string name) requires name != null; With non-null types: Person(string! name) Software Engineering, lecture 20: Static program checking and verification 15

  16. Comparing against null public void M(T x){ if (x == null) { … } else { T! y = x; … } } Spec# performs a data-flow analysis to allow this Software Engineering, lecture 20: Static program checking and verification 16

  17. Spec# DEMO

  18. References ESC/Java � Flanagan et al.: Extended Static Checking for Java ESC/Java2 � http://secure.ucd.ie/products/opensource/ESCJava2 Spec# � Barnett et al.: Boogie: A Modular Reusable Verifier for Object-Oriented Programs � http://research.microsoft.com/specsharp Rustan Leino’s lectures � http://research.microsoft.com/~leino/talks.html Software Engineering, lecture 20: Static program checking and verification 18

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