1.7.2008 Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.

Slides:



Advertisements
Similar presentations
Joint work with Mike Barnett, Robert DeLine, Manuel Fahndrich, and Wolfram Schulte Verifying invariants in object-oriented programs K. Rustan M. Leino.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Extended Static Checking for Java Cormac Flanagan K. Rustan M. Leino Mark Lillibridge Greg Nelson James B. Saxe Raymie Stata Compaq SRC 18 June 2002 PLDI02,
Demand-driven inference of loop invariants in a theorem prover
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,
1 Towards a Verifying Compiler: The Spec# Approach Wolfram Schulte Microsoft Research Formal Methods 2006 Joint work with Rustan Leino, Mike Barnett, Manuel.
Program Verification Using the Spec# Programming System ETAPS Tutorial K. Rustan M. Leino, Microsoft Research, Redmond Rosemary Monahan, NUIM Maynooth.
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 Summer school on Formal Models.
Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 0 Summer school on Formal Models.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
The Java Modeling Language JML Erik Poll Digital Security Radboud University Nijmegen.
JML and ESC/Java2: An Introduction Karl Meinke School of Computer Science and Communication, KTH.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Dept. of Computer Science A Runtime Assertion Checker for the Java Modeling Language (JML) Yoonsik Cheon and Gary T. Leavens SERP 2002, June 24-27, 2002.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
An overview of JML tools and applications Lilian Burdy Gemplus Yoonsik Cheon, Gary Leavens Iowa Univ. David Cok Kodak Michael Ernst MIT Rustan Leino Microsoft.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
K. Rustan M. Leino Research in Software Engineering (RiSE) Microsoft Research, Redmond, WA part 0 Summer School on Logic and Theorem-Proving in Programming.
JML and Class Specifications Class invariant JML definitions Queue example Running JML in Eclipse.
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Software Quality: Testing and Verification II. 2 1.A failure is an unacceptable behaviour exhibited by a system — The frequency of failures measures software.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Well-cooked Spaghetti: Weakest-Precondition of Unstructured Programs Mike Barnett and Rustan Leino Microsoft Research Redmond, WA, USA.
Chair of Software Engineering Automatic Verification of Computer Programs.
Describing Syntax and Semantics
Lecture 4 Requirements Testing & Requirements Modeling.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Extended Static Checking for Java  ESC/Java finds common errors in Java programs: null dereferences, array index bounds errors, type cast errors, race.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Semantics In Text: Chapter 3.
Spec# Andreas Vida. Motivation Correct and maintainable software Correct and maintainable software Cost effective software production Cost effective software.
CSE Winter 2008 Introduction to Program Verification January 15 tautology checking.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata Compaq Systems.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Formal Verification – Robust and Efficient Code Lecture 1
Dafny An automatic program verifier for functional correctness
Further with Hoare Logic Sections 6.12, 6.10, 6.13
Software Verification 2 Automated Verification
Programming Languages 2nd edition Tucker and Noonan
Hoare-style program verification
Dafny An automatic program verifier for functional correctness
Java Modeling Language (JML)
The Zoo of Software Security Techniques
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für Rechnerarchitektur und Softwaretechnik

Slide 2 H. Schlingloff, Logical Specification Assertion Languages OCL is an assertion language for UML Similar assertian languages have been defined for various programming languages  Java Modeling Language (JML) for Java  Spec# for C#  PSL for VHDL General idea  static analysis: try to verify the assertions without running the program  dynamic supervision: use the assertions to influence the execution of the program

Slide 3 H. Schlingloff, Logical Specification Example: JML Reference: using Hoare style pre- and postconditions and invariants specifications are added as Java annotations (comments) to the Java program  can also be stored in separate specification files @*/

Slide 4 H. Schlingloff, Logical Specification JML Syntax assert  Defines a JML assertion requires  Defines a precondition on the method that follows ensures  Defines a postcondition on the method that follows invariant  Defines an invariant property of the class signals  Defines a condition on when a given exception can be thrown by the method that follows assignable  Defines which fields are allowed to be assigned to by the method that follows

Slide 5 H. Schlingloff, Logical Specification JML expressions Boolean Java expressions \result  identifier for the return value of the method that follows \old( )  modifier to refer to the value of variable at the time of entry into a method \forall, \exists  universal and existential quantifier (for arrays etc.)  range of quantification limited! a ==> b, a b  logical implications

Slide 6 H. Schlingloff, Logical Specification Example public class Account { public static final int MAX_BALANCE = 1000; private int balance; private boolean isLocked = false; invariant balance >= 0 && balance <= MAX_BALANCE; assignable balance; ensures balance == 0; public Account() { } requires amount > 0; ensures balance = \old(balance) + amount; public void deposit(int amount) { … } ensures isLocked == true; public void lockAccount() { this.isLocked = true; } }

Slide 7 H. Schlingloff, Logical Specification Dynamic Analysis Generate extra code from annotations to check violations  assert: check at the given statement  requires: check before entering the method  ensures: check at the end of the method  invariant: check after each statement - obviously, only when statement might affect expression Use assertions to generate JUnit test cases  set preconditions, get postconditions

Slide 8 H. Schlingloff, Logical Specification Static Analysis Tools Abstract interpretation tries to calculate possible values of variables  sound approximation to the possible ranges  e.g., i  [-maxint..16], [17..21], [22..maxint] i += 1  i  [-maxint..17], [18..22], [23..maxint] Formally, an abstraction function is a mapping from a (large) concrete domain into a (small) abstract domain; e.g., int  {neg, zero, pos}  operations on concrete objects are replaced by operations on abstract objects

Slide 9 H. Schlingloff, Logical Specification JML Screenshot www-sop.inria.fr/.../bcwp/img/jmlCompile.jpeg

Slide 10 H. Schlingloff, Logical Specification Spec# and Spec Explorer Microsoft‘s Road to Specification Evolving algebras (Egon Börger et al., 1990‘s)  „Philosophical“ background ASMs and the ASML (Yuri Gurevich et al.)  Theoretical background Spec# (Wolfram Schulte et al.)  Interactive program verification Spec Explorer (Wolfgang Grieskamp et al.)  Support for model-based testing

Slide 11 H. Schlingloff, Logical Specification Spec# Overview Aiming at program verification Based on C# (which in turn is based on C++ and Java) Spec# is an extension of C# by non-null types, method contracts, object invariants, and checked exceptions  can be seen as a programming language of its own Tool support  compiler - statically enforces non-null types - emits run-time checks for method contracts and invariants - records the contracts as metadata for consumption by downstream tools  static program verifier „Boogie“ - generates logical verification conditions from a Spec# program - uses automatic theorem prover - analyzes the verification conditions to prove the correctness of the program or find errors in it

Slide 12 H. Schlingloff, Logical Specification Use of Spec# Write each class containing methods and their specification together in a Spec# source file  Invariants that constrain the data fields of objects may also be included Run the verifier (either from IDE or command line)  push button, wait (maybe long), get a list of compilation/verification error messages  Interaction with the verifier is done by modifying the source file

Slide 13 H. Schlingloff, Logical Specification Screenshot Freely available, needs MSVS.Net Wrong input Precondition not satisfied Log messages for programmer

Slide 14 H. Schlingloff, Logical Specification Example // non-null argument assume: not checked but taken as granted assert: statically or dynamically validated

Slide 15 H. Schlingloff, Logical Specification Swap Example How can the proof be performed?

Slide 16 H. Schlingloff, Logical Specification Spec# Verification focus on automation of verification rather than full functional correctness of specifications  No verification of liveness (termination or other temporal eventuality properties)  No arithmetic overflow checks (yet) Active research on extensions (e.g. comprehensions)

Slide 17 H. Schlingloff, Logical Specification Quantifiers Quantification on finite domains!  Verification can be expensive (search all values)

Slide 18 H. Schlingloff, Logical Specification Loop Invariants Can help the solver to reach its goal !

Slide 19 H. Schlingloff, Logical Specification Loop Invariants Can help the solver to reach its goal !

Slide 20 H. Schlingloff, Logical Specification

Slide 21 H. Schlingloff, Logical Specification BoogiePL Simple procedural language for.Net if (condition) S else T Spec#: assume condition ; S assume ! condition ; T Then branch Else branch BoogiePL:

Slide 22 H. Schlingloff, Logical Specification BoogiePL syntax

Slide 23 H. Schlingloff, Logical Specification

Slide 24 H. Schlingloff, Logical Specification BoogiePL Verifier Based on HP‘s „Simplify“ theorem prover   first-order theorem prover (satisfiability)  includes complete decision procedures for the theory of equality and for linear rational arithmetic  heuristics for linear integer arithmetic  propositional connectives are solved by backtracking  handling of quantifiers by pattern-driven instantiation (incomplete) Translation from Boogie PL to Simplify  weakest precondition of each statement  each statement and each procedure gives rise to one verification condition