Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
Semantics Static semantics Dynamic semantics attribute grammars
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
50.530: Software Engineering Sun Jun SUTD. Week 10: Invariant Generation.
Reasoning About Code; Hoare Logic, continued
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
11111 Functional Program Verification CS 4311 A. M. Stavely, Toward Zero Defect Programming, Addison-Wesley, Y. Cheon and M. Vela, A Tutorial on.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
1 University of Toronto Department of Computer Science © 2001, Steve Easterbrook Lecture 10: Formal Verification Formal Methods Basics of Logic first order.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 330 Programming Languages 09 / 19 / 2006 Instructor: Michael Eckmann.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
1 Static Testing: defect prevention SIM objectives Able to list various type of structured group examinations (manual checking) Able to statically.
CSE115/ENGR160 Discrete Mathematics 04/12/11 Ming-Hsuan Yang UC Merced 1.
White Box Testing and Symbolic Execution Written by Michael Beder.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
White Box Testing and Symbolic Execution Written by Michael Beder.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Describing Syntax and Semantics
Testing Dr. Andrew Wallace PhD BEng(hons) EurIng
Formal Methods 1. Software Engineering and Formal Methods  Every software engineering methodology is based on a recommended development process  proceeding.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Reading and Writing Mathematical Proofs
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
1 Program Correctness CIS 375 Bruce R. Maxim UM-Dearborn.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Proofs of Correctness: An Introduction to Axiomatic Verification Prepared by Stephen M. Thebaut, Ph.D. University of Florida CEN 5035 Software Engineering.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Muhammad Idrees Lecturer University of Lahore 1. Outline Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.5 Application: Correctness of Algorithms 1 [P]rogramming reliability – must be an activity.
Reasoning about programs March CSE 403, Winter 2011, Brun.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
Verification & Validation By: Amir Masoud Gharehbaghi
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.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
1 Software Correctness Proofs CIS 376 Bruce R. Maxim UM-Dearborn.
Loop Invariants and Binary Search Chapter 4.4, 5.1.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
A Review of Software Testing - P. David Coward
Software Testing.
Reasoning About Code.
Syntax Questions 6. Define a left recursive grammar rule.
Programming Languages 2nd edition Tucker and Noonan
Semantics In Text: Chapter 3.
Functional Program Verification
The Zoo of Software Security Techniques
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

Static Techniques for V&V

Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal Analysis Formal Analysis Static Techniques Proofs Review Inspection Walkthrough

Analysis Different from experimenting (testing). – Based on a model –Source code or abstracted source code –Not the actual product (executable).

Analysis Can be subject to failure itself (wrong proof) –Similar to mathematical proofs –Start with conjecture –Try to show it is a theorem Find either

Informal Analysis Reviews Inspections Walkthroughs

Code Reviews: Read. If you can’t read it, neither can the people trying to maintain it Do this for any artifact This is a team effort

Walk-through: Simulate by hand, pick test cases, generalize Looking for any bugs Keep size small (3-5) Players get documentation ahead of time Meeting is restricted to a few hours

Code Inspections: Looking for specific bugs Common bugs: –Un-initialized variables –Jumps into loops –Incompatible assignments (type errors) –Non-termination –Out-of-bounds –Memory leaks –Parameter mismatches

(Semi) Formal Analysis Techniques Proofs Static checking –Code analysis: syntax errors and simple error patterns (i.e. Pointer problems) –Structure checking: CFGs with structural error detection (dead code, logic errors)

Formal correctness proofs {true} Begin read (a); read (b); x = a + b; write (x) end; {output = input1 + input2} Precondition Post condition

Proof Step 1 {true} Begin read (a); read (b); x = a + b; write (x) end; {output = input1 + input2} Due to the semantics of write(), the post condition holds iff {x=input1 + input2} holds

Proof Step 2 {true} Begin read (a); read (b); x = a + b; write (x) end; {output = input1 + input2} {x=input1 + input2} holds iff {a+b = input1 + input2}

Proof Step 3 {true} Begin read (a); read (b); x = a + b; write (x) end; {output = input1 + input2} Since the semantics of read(a) and read(b) assign input1 to a and input2 to b, {a+b = input1 + input2} holds

Basic Idea For any postcondition POST on program variables, and For any assignment statement x = expr, –expr is an expression containing variables POST holds after the assignment iff POST’ holds before the assignment

Basic Idea We want to show that whenever the preconditions hold, the postconditions must hold, that is –Pre -> Post We can take post conditions and derive necessary and sufficient conditions, then show the preconditions match these.

Notes We assume there are no side effects in expr.

Consider examples {x = 5} x = x + 1 {x = 6} {z-43 > y + 7} x = z – 43 {x > y + 7}

Sequences Suppose you have shown {F1} S1 {F2} and {F2} S2 {F3} You can deduce –{F1} S1;S2 {F3}

Consider conditional: {true} if x >= y then max = x else max = y; { (max = x or max = y) AND (max >= x and max >= y) }

Proof informally by cases: assume x >= y. then { (x = x or x = y) AND (x >= x and x >= y) }, which is true.

Rules of inference, conditional: Given {pre and condition} s1 {post} and {pre and not condition} s2 {post} Infer {pre} if condition then s1 else s2 {post}

Loop invariants I is a loop invariant cond is the loop condition (while loop) S is the body of the loop

Loop example: {x > y} while (x <> 0) x = x –2 y = y –2 end while {x > y and x = 0} Invariant

Loop example: {x > y} while (x <> 0) x = x –2 y = y –2 end while {x > y and x = 0} Note: Loop is not guaranteed to terminate

Loops example: Can easily show that if x > y at exit, it must have been so at entry. Might need induction to do these in general. Notice, this loop does not end if x is odd on entry.

Example {input1>0 and input2>0} begin read(x); read(y); div=0; while x>=y loop div = div + 1; x = x – y; end loop; write (div); write (x); end {input1 = output1*input2 + output2 and 0<=output2<input2}

Notes: Formal proofs may be more complex than the program Proofs are error prone if done by hand Proofs require mathematical sophistication Proofs may be overwhelming to do

Notes 2: Proofs rely on a semantic model of the environment (language, processor): They only provide assurance under this model Proofs may depend on continuous systems, not discrete systems Are they useful? –only for very small parts of the code. –they can be automated (PVS, for example) Many research issues here

Notes 3 Automated Theorem Provers: ACL2, HOL, Isabelle, Clam/Oyster –Theorem proving frameworks for software Outline:

Symbolic execution Similar to testing, but instead of individual test cases, you have symbolic generalization each test is a test of an entire class of tests. (testing, one element of equiv class. symbolic, entire class). Plan: try to get path coverage. How? In general, abstract the source code with respect to some property. Then do symbolic execution of every path through abstracted code. Research problem.

Model Checking Exhaustive search through state space of program (complete state space expansion) Form of symbolic execution Problem: state space

Model Checker Model software as FSA (what’s that?) Model properties in some logic, usually temporal logic (LTL, CTL) Represent FSA as a graph (what’s that?) Traverse graph (how?) Show properties hold in each node of graph

Model Checking What does it mean if an assertion does not hold in the model? What does it mean if the assertion does hold in the model?

Automated Programming Automatically generate programs from specifications Deductive Synthesis: extract a program from a proof

Cleanroom Build software in such a way as to prevent defects from being introduced. No testing. Specify system. Refine specification systematically, proving that the refinement meets the specification

Transformational Programming Take an input string and rewrite it: –aBc => axyc –Rules can have conditions –Rules can have procedural attachment or be higher order Formal, stepwise refinement of specification to program Can check each step individually “correct” by construction