CSE 3341.03 Winter 2008 Introduction to Program Verification symbolic execution continued.

Slides:



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

Semantics Static semantics Dynamic semantics attribute grammars
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.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Axiomatic Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 17.
Partial correctness © Marcelo d’Amorim 2010.
Axiomatic Semantics The meaning of a program is defined by a formal system that allows one to deduce true properties of that program. No specific meaning.
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.
Simple Example {i = 0} j := i * i {j < 100} Can we ‘verify’ this triple? Only if we know the semantics of assignment.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Predicate Transformers
CSE 331 Software Design & Implementation Dan Grossman Winter 2014 Lecture 2 – Reasoning About Code With Logic 1CSE 331 Winter 2014.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
ITEC200 Week02 Program Correctness and Efficiency.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
Axiomatic Semantics Dr. M Al-Mulhem ICS
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
4/17/2017 Section 3.6 Program Correctness ch3.6.
Describing Syntax and Semantics
Floyd Hoare Logic. Semantics A programming language specification consists of a syntactic description and a semantic description. Syntactic description:symbols.
SCRIPTING IN RUBY By Amber Bennett “Ruby is simple in appearance, but is very complex inside, just like our human body.” --Yukihiro Matsumoto.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
1 cs205: engineering software university of virginia fall 2006 Avoiding Software Disasters.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
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.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
CSE Winter 2008 Introduction to Program Verification for-loops; review.
“Discipline is the refining fire by which talent becomes ability.” – Roy L. Smith Thought for the Day.
Cs7100(Prasad)L18-9WP1 Axiomatic Semantics Predicate Transformers.
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.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Zach Tatlock / Winter 2016 CSE 331 Software Design and Implementation Lecture 2 Formal Reasoning.
CSE Winter 2008 Introduction to Program Verification February 5 calculating with simplify.
CORRECTNESS ISSUES AND LOOP INVARIANTS Lecture 8 CS2110 – Fall 2014.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 17 – Specifications, error checking & assert.
11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x.
Chapter 3 of Programming Languages by Ravi Sethi
Topics: jGRASP editor ideosyncrasies assert debugger.
CSE 374 Programming Concepts & Tools
CSE 143 Error Handling [Section 2.8] 3/30/98 CSE 143.
CSE 331 Software Design & Implementation
Formal Methods in Software Engineering 1
Introduction to Python
Mathematical Structures for Computer Science Chapter 1
Introduction to Python
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
CSC 143 Error Handling Kinds of errors: invalid input vs programming bugs How to handle: Bugs: use assert to trap during testing Bad data: should never.
Semantics In Text: Chapter 3.
Section 1: Code Reasoning
Axiomatic Verification I
Predicate Transformers
Formal Methods in software development
Axiomatic Verification I
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
COP4020 Programming Languages
Presentation transcript:

CSE Winter 2008 Introduction to Program Verification symbolic execution continued

well-behaved expression assumption Exercise 7.9 if (count > 2) flag = adjust(total - 1); else flag = adjust(total - 1); post-condition? how does it depend on the well-behaved expression assumption?

exception raising use a specification variable to "fill in" a partial function: example: x = 1/n; post-condition: n ≠ 0 implies x = 1/n ?? leaves case n = 0 unspecified better: have n = 0 raise an exception; post-condition: n ≠ 0 and x = 1/n or exceptionRaised Note: specification variable converts a test (run-time) into part of a general assertion

programs as "propositional transformers" start with a proposition (perhaps “true”) ‘execute’ a code segment calculate a resulting proposition symbolic execution maintains a description of the state of computation at each step

assignment statements if a variable is assigned a new value, we may need its initial value: x = x - y //{x = 'old x' - y} parallel assignment (corrected from Ch. 8, p. 21:) x 1, x 2,.., x k = e 1, e 2,.., e k ; means replace x j by old x i in each e k and assign x i = e i, for each x i

parallel assignment motivation for parallel assignment: x=1 and y=x is the same logically as y=x and x=1 but not if = is sequential assignment scripting languages with parallel assignment: Python, Perl, Ruby, Windows PowerShell, OCaml and JavaScript (since 1.7) (source: Wikipedia)

symbex symbex symbolically executes a code fragment containing assignment and conditional statements handles assignment operators: x += y; allows A[X] in the assigned expression gets changed to array(A, X) why? doesn't handle parallel assignments

symbex assertions pre-condition: //{... }... assertion or post-condition:... //{... }... current state: //{ false }..

exercise 8.4 //{ not b implies v = e } if (b) //{ (not b implies v=e)and b } v = e ; // assert: v=e // -- assertion is verified. //{ (not b implies v=e)and not b or (not b implies old v=e)and v=e and b } compare post-condition for each case what does "assuming everything is well- behaved” mean in this specific case?

stronger and weaker P is stronger (as a condition) than Q if P implies Q and (P xor Q) P is weaker than Q if Q is stronger than P simple refinement weakens the pre- condition, strengthens the post-condition why is this desirable?

strongest Suppose P is the strongest proposition such that P implies Q what is P's relation to Q? If R is stronger than (or =) Q, then P is stronger than R, (or = R) i. e., (R implies Q) implies (P implies R)

what does symbex compute? strongest post-condition resulting from executing the code, given the pre-condition what if P is false? strongest possible proposition, but can't be a (descriptive) post-condition !

symbex in detail symbex processes a code segment; interprets its input (up to an end-of-file (^D)) as a sequence of assignment and conditional statements annotated with comments in the form //{ term } maintains a table of computational states described in terms of the code’s variables initial value is given by a pre-condition or described as ‘old V’

states and relations description is complicated by having two parts: states of variables = "trace table" values don't involve code variables current values are substituted for variables relations among variables

relations and values relations are either pre-conditions or created by conditional statements: if(x>0) {y=2; x = 2*x;} pre-condition to the {} is x > 0 after "y=2;" we have x > 0 and y=2 now x changes: new description is 'old x'> 0 and y = 2 and x =2*'old x' what's the post-condition calculated for the if? x 0 and y = 2 and x =2*'old x'

symbex vs. Java assertions often we are only interested in some of the variables; insert assertions to verify the (partial) state difference between these assertions and assertions in Java (version 1.4 and after): the assertions in Java test the code executing on a specific set of values assertions in symbex are asserted to be true for all values in the domains of the functions and relations

executing conditionals p. 26: if ( i != 4 || i != 5) x =no; else x = yes; //{ x = no} where did //{not i=5 or not i=4} come from? why is the post-condition verified?

illogical Dan