19.1.2012 Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.

Slides:



Advertisements
Similar presentations
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Advertisements

Technologies for finding errors in object-oriented software K. Rustan M. Leino Microsoft Research, Redmond, WA Lecture 1 Summer school on Formal Models.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Reasoning About Code; Hoare Logic, continued
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
50.530: Software Engineering Sun Jun SUTD. Week 9: Hoare Logic.
1 University of Toronto Department of Computer Science © 2001, Steve Easterbrook Lecture 10: Formal Verification Formal Methods Basics of Logic first order.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Partial correctness © Marcelo d’Amorim 2010.
1 Discrete Structures Lecture 29 Predicates and Programming Read Ch
Predicate Transformers
Program Proving Notes Ellen L. Walker.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
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 Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Hoare-style program verification K. Rustan M. Leino Guest lecturer Rob DeLine’s CSE 503, Software Engineering University of Washington 26 Apr 2004.
ECI 2007: Specification and Verification of Object- Oriented Programs Lecture 1.
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 Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Floyd Hoare Logic. Semantics A programming language specification consists of a syntactic description and a semantic description. Syntactic description:symbols.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Pre/Post Condition Logic 03/06/2013. Agenda Hoare’s Logic Overview Application to Pre/Post Conditions.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 2 Automated Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität and Fraunhofer Institut für.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer.
Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut.
SS 2017 Software Verification Bounded Model Checking, Outlook
SS 2017 Software Verification SMT Solving, Partial Order Methods
Software Verification 2 Automated Verification
Proving Loops Testing debugging and verification
Formal Methods in Software Engineering 1
Predicate Transforms II
Hoare-style program verification
SS 2018 Software Verification LTL Satisfiability applied
Predicate Transforms I
Lecture 5 Floyd-Hoare Style Verification
SS 2018 Software Verification ML, state machines
Software Verification 2 Automated Verification
Programming Languages 2nd edition Tucker and Noonan
Software Verification 2 Automated Verification
Section 1: Code Reasoning
Predicate Transformers
Formal Methods in software development
Predicate Transforms I
Predicate Transforms II
The Zoo of Software Security Techniques
Predicate Transforms I
Program correctness Axiomatic semantics
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Software Verification 1 Deductive Verification Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt Universität und Fraunhofer Institut für Rechnerarchitektur und Softwaretechnik

Folie 2 H. Schlingloff, Software Verification I Lehrevaluation Verpflichtend für die HU, im Interesse der Studierenden Zeitraum: bis online:  Passwort (Token): inf-ws Verbesserung der Sicherheit durch sogenanntes Captcha  Completely Automated Public Turing test to tell Computers and Humans Apart Bei Rückfragen: Dr. Elke Warmuth, Studiendekanin  Tel ,

Folie 3 H. Schlingloff, Software Verification I Pre- and Postconditions Dijkstra: wp-calculus (weakest precondition)  characterize the “weakest” formula which makes a Hoare- triple valid   =wp( .  ) iff ⊢    and ⊢ (  '  ) for every  ’ for which ⊢  ’      =wlp( .  ) iff ⊢ {  }  {  } and ⊢ (  '  ) for every  ’ for which ⊢ {  ’}  {  } (weakest liberal precondition, see later) Example: wp(x++, x==7) = (x==6) Dijkstra gives a set of rules for wp which can be seen as notational variant of Hoare logic

Folie 4 H. Schlingloff, Software Verification I wp(skip,  ) =  wp(x=t,  ) =  [x:=t] wp({  1 ;  2 },  ) = wp(  1, wp(  2,  )) wp(if (b)  1 else  2,  ) = ((b  wp(  1,  ))  (¬b  wp(  2,  ))) wp(while (b) ,  ) =  z  (z)   z((b  (z))   z’ (z’<z  wp( ,  (z’)))   z((¬b  (z))   ) where  is a loop variant and < a wfo, z new var. ! This is a non-constructive definition ! Existence???

Folie 5 H. Schlingloff, Software Verification I Examples wp(x=x-3, x>7) = x>7 [x:=x-3] = x-3>7 = x>10 wp({x*=2; x-=3}, x>7) = wp(x*=2, wp(x-=3, x>7)) = wp(x*=2, x>10) = x>5 wp(if(a =b) = ((a =b)  (a>=b  wp(skip, a>=b)) =((a =b)  (a>=b  a>=b)) = T wp(while (i>0) i--, i==0) = i>=

Folie 6 H. Schlingloff, Software Verification I Partial Correctness Weakest liberal precondition wlp( ,  ) wlp(while (b) ,  ) =   ((b  )  wlp( ,  ))  ((¬b  )   ) Dijkstra also used nondeterministic programs („guarded commands“)  guarded-command-program ::= while-program | guarded-command  guarded-command ::= b : e | b : e [] guarded-command  b: condition, e: guarded-command-program

Folie 7 H. Schlingloff, Software Verification I Strongest Postconditions Dual to weakest precondition: the strongest formula which can be guaranteed to hold after execution  =sp( ,  ) iff ⊢    and ⊢ (    ') for every  ’ for which ⊢    ’  sp(x=t,  )=  z (x==t[x:=z]   [x:=z]) (z new)  e.g. sp(x=x-3, x>7) =  z (x==z-3  z>7) = x>4 Pre- and postconditions are important in the presence of methods and procedures

Folie 8 H. Schlingloff, Software Verification I Functions and Procedures while-Programs: whileProg ::= skip | V=T | {whileProg; whileProg} | if (FOL - ) whileProg else whileProg | while (FOL - ) whileProg T is the set of terms in the signature  =( D, F, R ) Now: extended signature  ’=(D  {void}, F  F ’, R ) If f is of type void, then f(x 1,...x n ) is an (imperative) program term ::= F(T,..., T) | F ’ (T,..., T) for each f  F’ there must be a declaration: decl ::= type F’ ( V,... V); whileProg V in decl are called formal parameters T in terms are called actual parameters

Folie 9 H. Schlingloff, Software Verification I No alias: formal parameters should be pairwise different No scoping: formal parameters must be different from program variables return statement as assignment to the function name If a function or procedure name occurs directly or indirectly in the call graph of its declaration, it is called recursive  for the time being: no recursion There are various ways to pass actual parameters for formal ones (value, reference, name,...)  for the time being, we use only call-by-value  passing value w to formal parameter v has the same effect as the assignment v=w at the entry of the procedure or function

Folie 10 H. Schlingloff, Software Verification I Example int min (int a, int b) if (a<b) min=a else min=b; int max (int a, int b) if (a>b) max=a else max=b; int gcd(int a, int b) while (a!=b) { c = max(a,b)-min(a,b); a = min(a,b); b = c; }

Folie 11 H. Schlingloff, Software Verification I Example int min (int a, int b) if (a<b) min=a else min=b; {x = 5; y = 7; z = min (x, y)} is equivalent to { x = 5; y = 7; a = x; b = y; if (a<b) min=a else min=b; z = min; } need pre- and postconditions to show assertions

Folie 12 H. Schlingloff, Software Verification I Example int min (int a, int b) if (a<b) min=a else min=b; {a<=min  b<=min  (a=min  b=min)} int max (int a, int b) if (a>b) max=a else max=b; {a>=max  b>=max  (a=min  b=min)} int gcd(int a, int b) {a==m>0  b==n>0} while (a!=b) { c = max(a,b)-min(a,b); a = min(a,b); b = c; } gcd = a; {gcd|m  gcd|n ...} }

Folie 13 H. Schlingloff, Software Verification I Contracts weakest preconditions and strongest postconditions are related to the require-ensure-paradigm (also called assume-guarantee-paradigm): requires  ensures  */ void foo(...)  ; is equivalent to (  wp( ,  ))  (sp( ,  )  ) such a statement is called contract  use of contract: {  [x 1 :=t 1,..., x n :=t n ]} foo(t 1,...,t n ) {  }