Programming Languages
|
|
- Derek Cook
- 5 years ago
- Views:
Transcription
1 CSE 230: Winter 2008 Principles of Programming Languages Lecture 7: Axiomatic Semantics Axiomatic Semantics over low Graphs c {P} if P P {P } {Q} c if Q Q {Q} {Q } Ranjit Jhala UC San Diego Relaxing specifications via rule of consequence Sequential Composition Conditionals C 1 C 2 {P} {Q} {R} {x-1 y} y-1} {x y} x:= x-1 {x y-1} { x 0. x 0 y y:= y-1 Æ x=x 0-1} {x y} Backwards using weakest preconditions orwards using strongest postconditions { y 0 x 0. x 0 y 0 Æ x=x 0-1 Æ y=y 0-1} {P} E {PÆE} { PÆ E} { x 0 } x=0 {x 0Æx=0} { x 0 {x 1} Æ x=0 } orwards {(P 1 ÆE)Ç(P 2 Æ E)} E {P 1 } { P 2 } { x=0 Ç x 1} x=0 {x=0} {x 1} Backwards
2 Joins Conditional+Join: orward { x 0 Ç a = 0 } {P 1 } {P 2 } {P} {P} { x 0 } a := 2*x x<>0 { x=0 Æ a=0 } { x 0 Ç a = 2*x} {P 1 Ç P 2 } {P} { a == 2*x } orwards Backwards Check the implications (simplifications) Conditionals+Joins: Backward { (x 0 Æ true) Ç (x = 0 Æ a = 2*x) } x<>0 { 2*x = 2*x } { a = 2*x } { a = 2*x} a := 2*x { a = 2*x } orward or Backward? orward reasoning Know the precondition Want to know what postcond the code guarantees Backward reasoning Know what we want to code to establish Want to know under what preconditions this happens
3 Another Example: Double Locking lock Locking Rules Boolean variable locked = lock is held or not unlock unlock lock { locked Æ P[true/locked] } lock { P } lock behaves as assert(!locked);locked:=true An attempt to re-acquire an acquired lock or release a released lock will cause a deadlock. { locked Æ P[false/locked] } unlock { P } unlock behaves as assert(locked);locked:=false Calls to lock and unlock must alternate. Locking Example { locked Æ x = 0 } { locked Æ x = 0 } { locked Æ x = 0 } lock x=0 { locked } { locked Æ x 0 } {lockedæx=0 Ç lockedæ x 0) } x=0 { locked Æ x = 0 } { locked Æ x 0 } { locked Æ (x = 0) } unlock { locked } Review x:=e { Q } { P } if Q P[E\x] } { P } { P 1 } { P 2 } { P } if P 1 P and P 2 P E { P 1 } { P 2 } if PÆE P 1 if PÆ E P 2 Implication is always in the direction of the control flow
4 What about real languages? Loops unction calls Pointers Reasoning about loops: Rules ` {A Æ b} c {A} ` {A} while b do c {AÆ b} Rewrite A with I : Loop Invariant P I ` {I Æ b} c {I} ` {I} while b do c {IÆ b} ` {P} while b do c {Q} Rule of Consequence IÆ b Q Reasoning about loops: low Graphs Loops can be handled using conditionals and joins Consider the while b do S statement { P } { I } Loop invariant { I } S b { Q } { I Æ E } if P I (loop invariant holds initially) and IÆ b Q (loop establishes the postcondition) and { I Æ b } S { I } (loop invariant is preserved) Loop Example Verify: {x=8 Æ y=16} while(x>0){x--; y-=2;} {y=0} x--; y-=2 { I } { I Æ x>0 } x>0 { x = 8 Æ y = 16 } { I } ind an appropriate invariant I Holds initially x = 8 Æ y = 16 Holds at the end y == 0 { y = 0 }
5 Loop Example (II) Guess invariant y = 2*x { y = 2*x } x--; y-=2 { x = 8 Æ y = 16 } { y = 2*x } x>0 { y = 0 } { y = 2*x Æ x > 0 } Check : Initial: x = 8 Æ y = 16 y = 2*x Preservation: y = 2*x Æ x>0 y 2 = 2*(x 1) inal: y = 2*x Æ x 0 y = 0 Invalid Loop Example (III) Guess invariant y = 2*x Æ x 0 { y=2*x Æ x 0} { x = 8 Æ y = 16 } { y = 2*x Æ x 0} x>0 { y = 0 } x--; y-=2 { y = 2*x Æ x 0 Æ x>0 } Check Initial: x = 8 Æ y = 16 y = 2*x Æ x 0 Preservation: y = 2*x Æ x 0 Æ x>0 y 2 = 2*(x 1) Æ x 1 0 inal: y = 2*x Æ x 0 Æ x 0 y = 0 Loops Discussion Simple forward/backward propagation fails Require loop invariants Hardest part of program verification Guess the invariants (existing programs) Write the invariants (new programs) Note: Invariant depends on what you want to prove! Verification Example int square(int n) { int k=0, r=0, s=1; while(k!= n) { { true } r = r + s; k:=0 s=s+2; Pick I: r = k r:=0 2 k=k + 1; s:=1 } { r=0 Æ k=0} return r;??? } I : {r = k 2 } r:=r+s s:=s+2 k!=n k:=k+1 k {r=n 2 } {r=k 2 {r=k Æ k=n} 2 Æk=n} Need: {r=k 2 Æ k=n} c {r=k 2 } i.e. {r=k 2 Æ k=n} WP(c,{r=k 2 }) i.e. {r=k 2 Æ k=n} {r+s=(k+1) 2 } Invalid
6 Verification Example Need: {r=k 2 Æ s=2k+1 Æ } c {r=k 2 Æ s=2k+1} i.e. {r=k 2 Æ s=2k+1 } WP(c,{r=k 2 Æs=2k+1}) i.e. {r=k 2 Æ s=2k+1 } {r+s=(k+1) 2 Æ (s+2) = 2(k+1)+1}??? { true } Valid k:=0 r:=0 s:=1 { r=0 Æ k=0 Æ s=0} I : {r=k 2 Æ s=2k+1} r:=r+s s:=s+2 k!=n {r=k 2 k:=k+1 {r=n 2 } {r=k 2 Æs=2k+1Æ } Æs=2k+1 Æk=n} What about real languages? Loops unction calls Pointers unctions are big instructions Suppose we have verified bsearch int bsearch(int a[], int p) { { sorted(a) } Precondition { r=-1 Ç (r 0 Æ r < a.length Æ a[r]=p)} return res; Postcondition } unction spec = precondition i + postconditon Also called a contract unction Calls Consider a call to function y:=f(int E) return variable r precondition Pre, postcondition Post Rule for function call: ` P Pre[E/x] `{Pre} f {Post} ` Post[E/x,y/r] Q ` {P} y:=f(e){q}
7 unction Calls Consider a call to function y:=f(int x) return variable r precondition Pre, postcondition Post Rule for function call: y = (E) { P } if P Pre[E/x] } { Q } and Post[E/x,y/r] Q unction Call: Example int bsearch(int a[],int p) { Consider the call { sorted(a) } {sorted(arr) } { r=-1ç(r 0 Æ r<a.lengthæ a[r]=p)} [] y:=bsearch(arr,5) return res; {y=-1 Ç arr[y]=5} } if(y!=-1){ {y!=-1 Æ (y=-1çarr[y]=5} {arr[y]=5} sorted[array] ay] Pre[a := array] ay] Post[y/r,arr/a, 5/p] (y=-1 Ç arr[y]=5) What about real languages? Loops unction calls Pointers Assignment and Aliasing Does assignment rule work with aliasing? If *x and *y are aliased then: {x=y} *x:=5 {*x+*y=10}
8 Hoare Rules: Assignment and References When is the following Hoare triple valid? { A } *x := 5 { *x + *y = 10 } Ashould be *y = 5 or x = y but Hoare rule for assignment gives: [5/*x](*x + *y = 10) = 5 + *y = 10 = *y = 5 (uh oh! we lost one case! What gives?) Hoare Rules: Assignment and References Modeling writes with memory expressions reat memory as a whole w/ memory variables (M) upd(m,e 1,E 2 ) : update M at addr E 1 with value E 2 sel(m,e 1 ) : read M at address E 1 Reason about memory expressions with McCarthy s rule sel(upd(m, E 1, E 2 ), E 3 ) = E 2 if E 1 = E 3 sel(m, E 3 ) if E 1 E 3 Assignment (update) changes the value of memory {B[upd(M, E 1 1, E 2 2) )/M]} *E 1:=E 2 {B} Memory Aliasing Consider again: {A} *x:=5 {*x+*y=10 {x+y=10} We obtain: A = [upd(m, x, 5)/M] (*x+*y=10) = [upd(m, x, 5)/M] (sel(m,x) + sel(m,y) = 10) = sel(upd(m, x, 5), x) + sel(upd(m, x, 5), y) = 10 = 5 + sel(upd(m, x, 5), y) = 10 = if x = y then = 10 else 5 + sel(m, y) = 10 = x=y or *y = 5 Program Verification ools Semi-automated You write some invariants and specifications ool tries to fill in the other invariants And to prove all implications Explains when implication is invalid: counterexample for your specification ESC/Java is one of the best tools
9 Algorithmic Program Verification or how does ESC/Java work? Q: How to algorithmically i ll prove {P} c {Q}? If no loops: 1. Compute: WP(c,Q) 2. Prove: P WP(c,Q) Verification Condition Discharged using Auto. heorem Prover VC Generation for Loops Suppose all loops annotated with Invariant while I b do c Again, lets compute a VC such that: if VC is valid (true) then {P} c {Q} Q: Why not iff? as the loop invariants i may be bogus VCGen We will write a function VCG: comm (pred pred list) (pred pred list) Suppose (Q,L ) = VCG(c,(Q,L)) hen VC for {P} c {Q} is: P Q Æ {f in L } f L : the set of conditions that must be true rom loops (init,preservation,final) Q : precondition modulo invariants VCGen VCG: comm (pred pred list) (pred pred list) VCG(c,(Q,L)) (Q = (Q,L L ) hen VC for {P} c {Q} is: P Q Æ {f in L } f let rec VCG(c,(Q,L)) = match c with x:= e -> (Q[e/x], L) c1;c2 -> VCG(c1,VCG(c2,(Q, L))) c1;c2 > VCG(c1,VCG(c2,(Q, L))) if b then c1 else c2 -> let (Q1,L1) = VCG( c1,(q, L)) (Q2 L2) VCG( 2 (Q L)) (Q2,L2) = VCG( c2,(q, L)) in ((bæq1)ç( bæq2), L1 L2 ) while I b do c -> let (Q,L ) = VCG(c,(Q, L)) in (I, L {IÆb Q } {IÆ b Q} )
10 ESC/Java Semi-automated You write the invariants ESC/Java: VCGen: Simplify: heoremprover to prove VC Explains when implication is invalid: counterexample for your specification
Programming Languages
CSE 230: Winter 2008 Principles of Programming Languages Lecture 6: Axiomatic Semantics Deriv. Rules for Hoare Logic `{A} c {B} Rules for each language construct ` {A} c 1 {B} ` {B} c 2 {C} ` {A} skip
More informationAxiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs
Review Operational semantics relatively l simple many flavors (small vs. big) not compositional (rule for while) Good for describing language implementation reasoning about properties of the language eg.
More informationHoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples
Hoare Logic I Introduction to Deductive Program Verification Işıl Dillig Program Spec Deductive verifier FOL formula Theorem prover valid contingent Example specs: safety (no crashes), absence of arithmetic
More informationAxiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements
Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review
More informationProgram verification. 18 October 2017
Program verification 18 October 2017 Example revisited // assume(n>2); void partition(int a[], int n) { int pivot = a[0]; int lo = 1, hi = n-1; while (lo
More informationAxiomatic Semantics. Lecture 9 CS 565 2/12/08
Axiomatic Semantics Lecture 9 CS 565 2/12/08 Axiomatic Semantics Operational semantics describes the meaning of programs in terms of the execution steps taken by an abstract machine Denotational semantics
More informationProgram Analysis Part I : Sequential Programs
Program Analysis Part I : Sequential Programs IN5170/IN9170 Models of concurrency Program Analysis, lecture 5 Fall 2018 26. 9. 2018 2 / 44 Program correctness Is my program correct? Central question for
More informationLecture Notes: Axiomatic Semantics and Hoare-style Verification
Lecture Notes: Axiomatic Semantics and Hoare-style Verification 17-355/17-665/17-819O: Program Analysis (Spring 2018) Claire Le Goues and Jonathan Aldrich clegoues@cs.cmu.edu, aldrich@cs.cmu.edu It has
More informationAxiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements
Axiomatic Semantics: Verification Conditions Meeting 18, CSCI 5535, Spring 2010 Announcements Homework 6 is due tonight Today s forum: papers on automated testing using symbolic execution Anyone looking
More informationSoundness and Completeness of Axiomatic Semantics
#1 Soundness and Completeness of Axiomatic Semantics #2 One-Slide Summary A system of axiomatic semantics is sound if everything we can prove is also true: if ` { A } c { B } then ² { A } c { B } We prove
More informationIntroduction to Axiomatic Semantics
#1 Introduction to Axiomatic Semantics #2 How s The Homework Going? Remember that you can t just define a meaning function in terms of itself you must use some fixed point machinery. #3 Observations A
More informationFloyd-Hoare Style Program Verification
Floyd-Hoare Style Program Verification Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 9 Feb 2017 Outline of this talk 1 Overview 2 Hoare Triples 3
More informationProgram verification using Hoare Logic¹
Program verification using Hoare Logic¹ Automated Reasoning - Guest Lecture Petros Papapanagiotou Part 2 of 2 ¹Contains material from Mike Gordon s slides: Previously on Hoare Logic A simple while language
More informationHoare Calculus and Predicate Transformers
Hoare Calculus and Predicate Transformers Wolfgang Schreiner Wolfgang.Schreiner@risc.uni-linz.ac.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.uni-linz.ac.at
More informationAxiomatic semantics. Semantics and Application to Program Verification. Antoine Miné. École normale supérieure, Paris year
Axiomatic semantics Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 6 18 March 2016 Course 6 Axiomatic semantics Antoine Miné p. 1 /
More informationIn this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and
In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and shows how a program can sometimes be systematically constructed
More informationAxiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)
More informationThe Assignment Axiom (Hoare)
The Assignment Axiom (Hoare) Syntax: V := E Semantics: value of V in final state is value of E in initial state Example: X:=X+ (adds one to the value of the variable X) The Assignment Axiom {Q[E/V ]} V
More informationCOP4020 Programming Languages. Introduction to Axiomatic Semantics Prof. Robert van Engelen
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen Assertions and Preconditions Assertions are used by programmers to verify run-time execution An assertion is a
More informationA Short Introduction to Hoare Logic
A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking
More informationDeductive Verification
Deductive Verification Mooly Sagiv Slides from Zvonimir Rakamaric First-Order Logic A formal notation for mathematics, with expressions involving Propositional symbols Predicates Functions and constant
More informationDynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics
Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated
More informationCSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.
Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify
More informationDecision Procedures. Jochen Hoenicke. Software Engineering Albert-Ludwigs-University Freiburg. Winter Term 2016/17
Decision Procedures Jochen Hoenicke Software Engineering Albert-Ludwigs-University Freiburg Winter Term 2016/17 Jochen Hoenicke (Software Engineering) Decision Procedures Winter Term 2016/17 1 / 436 Program
More informationFormal Reasoning CSE 331. Lecture 2 Formal Reasoning. Announcements. Formalization and Reasoning. Software Design and Implementation
CSE 331 Software Design and Implementation Lecture 2 Formal Reasoning Announcements Homework 0 due Friday at 5 PM Heads up: no late days for this one! Homework 1 due Wednesday at 11 PM Using program logic
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Kevin Zatloukal Summer 2017 Lecture 2 Reasoning About Code With Logic (Based on slides by Mike Ernst, Dan Grossman, David Notkin, Hal Perkins, Zach Tatlock) Recall
More informationCSE 331 Winter 2018 Reasoning About Code I
CSE 331 Winter 2018 Reasoning About Code I Notes by Krysta Yousoufian Original lectures by Hal Perkins Additional contributions from Michael Ernst, David Notkin, and Dan Grossman These notes cover most
More informationSolutions to exercises for the Hoare logic (based on material written by Mark Staples)
Solutions to exercises for the Hoare logic (based on material written by Mark Staples) Exercise 1 We are interested in termination, so that means we need to use the terminology of total correctness, i.e.
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 2b Andrew Tolmach Portland State University 1994-2017 Semantics Informal vs. Formal Informal semantics Descriptions in English (or other natural language)
More informationWhat happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )
Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:
More informationSpring 2015 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University
Spring 2015 Program Analysis and Verification Lecture 6: Axiomatic Semantics III Roman Manevich Ben-Gurion University Tentative syllabus Semantics Static Analysis Abstract Interpretation fundamentals Analysis
More informationProgramming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a Based in part on slides by Mattox Beckman, as updated by Vikram Adve, Gul
More informationINVARIANT RELATIONS: A CONCEPT FOR ANALYZING WHILE LOOPS. Ali Mili, NJIT NII, Tokyo, Japan December 20, 2011
INVARIANT RELATIONS: A CONCEPT FOR ANALYZING WHILE LOOPS Ali Mili, NJIT NII, Tokyo, Japan December 20, 2011 PLAN 2 Motivation Relational Mathematics Invariant Relations Invariant Relations and Loop Functions
More informationFormal Specification and Verification. Specifications
Formal Specification and Verification Specifications Imprecise specifications can cause serious problems downstream Lots of interpretations even with technicaloriented natural language The value returned
More informationHoare Logic (I): Axiomatic Semantics and Program Correctness
Hoare Logic (I): Axiomatic Semantics and Program Correctness (Based on [Apt and Olderog 1991; Gries 1981; Hoare 1969; Kleymann 1999; Sethi 199]) Yih-Kuen Tsay Dept. of Information Management National Taiwan
More informationSpring 2014 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University
Spring 2014 Program Analysis and Verification Lecture 6: Axiomatic Semantics III Roman Manevich Ben-Gurion University Syllabus Semantics Static Analysis Abstract Interpretation fundamentals Analysis Techniques
More informationReview. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007
CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation
More informationCS156: The Calculus of Computation
Page 1 of 61 CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 5: Program Correctness: Mechanics Page 2 of 61 Program A: LinearSearch with function specification @pre 0 l u < a @post rv
More informationFormal Methods in Software Engineering
Formal Methods in Software Engineering An Introduction to Model-Based Analyis and Testing Vesal Vojdani Department of Computer Science University of Tartu Fall 2014 Vesal Vojdani (University of Tartu)
More information5. Program Correctness: Mechanics
5. Program Correctness: Mechanics Program A: LinearSearch with function specification @pre 0 l u < a @post rv i. l i u a[i] = e bool LinearSearch(int[] a, int l, int u, int e) { for @ (int i := l; i u;
More informationProgram Analysis and Verification
Program Analysis and Verification 0368-4479 Noam Rinetzky Lecture 4: Axiomatic Semantics Slides credit: Tom Ball, Dawson Engler, Roman Manevich, Erik Poll, Mooly Sagiv, Jean Souyris, Eran Tromer, Avishai
More informationCS156: The Calculus of Computation
CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between
More informationReasoning About Imperative Programs. COS 441 Slides 10b
Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program
More informationCSE 331 Winter 2018 Homework 1
Directions: - Due Wednesday, January 10 by 11 pm. - Turn in your work online using gradescope. You should turn in a single pdf file. You can have more than one answer per page, but please try to avoid
More informationProbabilistic Guarded Commands Mechanized in HOL
Probabilistic Guarded Commands Mechanized in HOL Joe Hurd joe.hurd@comlab.ox.ac.uk Oxford University Joint work with Annabelle McIver (Macquarie University) and Carroll Morgan (University of New South
More informationHoare Logic and Model Checking
Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the
More informationCS156: The Calculus of Computation Zohar Manna Autumn 2008
Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)
More informationProgramming Languages
CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2
More informationAbstractions and Decision Procedures for Effective Software Model Checking
Abstractions and Decision Procedures for Effective Software Model Checking Prof. Natasha Sharygina The University of Lugano, Carnegie Mellon University Microsoft Summer School, Moscow, July 2011 Lecture
More informationProofs of Correctness: Introduction to Axiomatic Verification
Proofs of Correctness: Introduction to Axiomatic Verification Introduction Weak correctness predicate Assignment statements Sequencing Selection statements Iteration 1 Introduction What is Axiomatic Verification?
More informationSpring 2015 Program Analysis and Verification. Lecture 4: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University Agenda Basic concepts of correctness Axiomatic semantics (pages 175-183) Hoare Logic
More informationWeakest Precondition Calculus
Weakest Precondition Calculus COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Most lecture slides due to Ranald Clouston) COMP 2600 Weakest
More informationSoftwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany
Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationModel Checking: An Introduction
Model Checking: An Introduction Meeting 3, CSCI 5535, Spring 2013 Announcements Homework 0 ( Preliminaries ) out, due Friday Saturday This Week Dive into research motivating CSCI 5535 Next Week Begin foundations
More informationSpring 2016 Program Analysis and Verification. Lecture 3: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2016 Program Analysis and Verification Lecture 3: Axiomatic Semantics I Roman Manevich Ben-Gurion University Warm-up exercises 1. Define program state: 2. Define structural semantics configurations:
More informationSMT-based Verification of Heap-manipulating Programs
SMT-based Verification of Heap-manipulating Programs Ruzica Piskac VTSA 2016 Maiden Flight of Ariane 5 Rocket Ariane 5 exploded on its first test flight in 1996 Cause: failure of flight-control software
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building
More informationFirst Order Logic vs Propositional Logic CS477 Formal Software Dev Methods
First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods Elsa L Gunter 2112 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 Slides based in part on previous lectures
More informationSoftwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany
Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationHoare Logic: Part II
Hoare Logic: Part II COMP2600 Formal Methods for Software Engineering Jinbo Huang Australian National University COMP 2600 Hoare Logic II 1 Factorial {n 0} fact := 1; i := n; while (i >0) do fact := fact
More informationVerification and Validation
2010-2011 Cycle Ingénieur 2 ème année Département Informatique Verification and Validation Part IV : Proof-based Verification (III) Burkhart Wolff Département Informatique Université Paris-Sud / Orsay
More informationProof Calculus for Partial Correctness
Proof Calculus for Partial Correctness Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 7, 2016 Bow-Yaw Wang (Academia Sinica) Proof Calculus for Partial Correctness September
More informationSoftware Engineering
Software Engineering Lecture 07: Design by Contract Peter Thiemann University of Freiburg, Germany 02.06.2014 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationLoop Invariants and Binary Search. Chapter 4.4, 5.1
Loop Invariants and Binary Search Chapter 4.4, 5.1 Outline Iterative Algorithms, Assertions and Proofs of Correctness Binary Search: A Case Study Outline Iterative Algorithms, Assertions and Proofs of
More informationLast Time. Inference Rules
Last Time When program S executes it switches to a different state We need to express assertions on the states of the program S before and after its execution We can do it using a Hoare triple written
More informationAxiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers
Axiomatic Semantics Hoare s Correctness Triplets Dijkstra s Predicate Transformers Goal of a program = IO Relation Problem Specification Properties satisfied by the input and expected of the output (usually
More informationIC3 and Beyond: Incremental, Inductive Verification
IC3 and Beyond: Incremental, Inductive Verification Aaron R. Bradley ECEE, CU Boulder & Summit Middle School IC3 and Beyond: Incremental, Inductive Verification 1/62 Induction Foundation of verification
More informationAutomata-Theoretic Model Checking of Reactive Systems
Automata-Theoretic Model Checking of Reactive Systems Radu Iosif Verimag/CNRS (Grenoble, France) Thanks to Tom Henzinger (IST, Austria), Barbara Jobstmann (CNRS, Grenoble) and Doron Peled (Bar-Ilan University,
More informationSAT-Based Verification with IC3: Foundations and Demands
SAT-Based Verification with IC3: Foundations and Demands Aaron R. Bradley ECEE, CU Boulder & Summit Middle School SAT-Based Verification with IC3:Foundations and Demands 1/55 Induction Foundation of verification
More informationLecture 2: Axiomatic semantics
Chair of Software Engineering Trusted Components Prof. Dr. Bertrand Meyer Lecture 2: Axiomatic semantics Reading assignment for next week Ariane paper and response (see course page) Axiomatic semantics
More informationLecture Notes on Compositional Reasoning
15-414: Bug Catching: Automated Program Verification Lecture Notes on Compositional Reasoning Matt Fredrikson Ruben Martins Carnegie Mellon University Lecture 4 1 Introduction This lecture will focus on
More informationProgram Verification as Probabilistic Inference
Program Verification as Probabilistic Inference Sumit Gulwani Microsoft Research, Redmond sumitg@microsoft.com Nebojsa Jojic Microsoft Research, Redmond jojic@microsoft.com Abstract In this paper, we propose
More informationIntroduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014
Introduction Pedro Cabalar Department of Computer Science University of Corunna, SPAIN cabalar@udc.es 2013/2014 P. Cabalar ( Department Introduction of Computer Science University of Corunna, SPAIN2013/2014
More informationCIS 500: Software Foundations
CIS 500: Software Foundations Midterm II November 8, 2016 Directions: This exam booklet contains both the standard and advanced track questions. Questions with no annotation are for both tracks. Other
More informationUnderstanding IC3. Aaron R. Bradley. ECEE, CU Boulder & Summit Middle School. Understanding IC3 1/55
Understanding IC3 Aaron R. Bradley ECEE, CU Boulder & Summit Middle School Understanding IC3 1/55 Further Reading This presentation is based on Bradley, A. R. Understanding IC3. In SAT, June 2012. http://theory.stanford.edu/~arbrad
More informationDesign of Distributed Systems Melinda Tóth, Zoltán Horváth
Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Publication date 2014 Copyright 2014 Melinda Tóth, Zoltán Horváth Supported by TÁMOP-412A/1-11/1-2011-0052
More informationLecture 11: Non-Interactive Zero-Knowledge II. 1 Non-Interactive Zero-Knowledge in the Hidden-Bits Model for the Graph Hamiltonian problem
CS 276 Cryptography Oct 8, 2014 Lecture 11: Non-Interactive Zero-Knowledge II Instructor: Sanjam Garg Scribe: Rafael Dutra 1 Non-Interactive Zero-Knowledge in the Hidden-Bits Model for the Graph Hamiltonian
More informationProgram verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program
Program verification Assertional semantics of a program Meaning of a program: relation between its inputs and outputs; specified by input assertions (pre-conditions) and output assertions (post-conditions)
More informationProblem Sheet 1: Axiomatic Semantics
Problem Sheet 1: Axiomatic Semantics Chris Poskitt ETH Zürich Starred exercises ( ) are more challenging than the others. 1 Partial and Total Correctness Recall the Hoare triple from lectures, {pre} P
More informationSMT and Its Application in Software Verification
SMT and Its Application in Software Verification Yu-Fang Chen IIS, Academia Sinica Based on the slides of Barrett, Sanjit, Kroening, Rummer, Sinha, Jhala, and Majumdar Assertion in C int main(){ int x;
More informationDeterministic Program The While Program
Deterministic Program The While Program Shangping Ren Department of Computer Science Illinois Institute of Technology February 24, 2014 Shangping Ren Deterministic Program The While Program February 24,
More informationDisjunctive relational abstract interpretation for interprocedural program analysis
Disjunctive relational abstract interpretation for interprocedural program analysis Nicolas Halbwachs, joint work with Rémy Boutonnet Verimag/CNRS, and Grenoble-Alpes University Grenoble, France R. Boutonnet,
More informationComplexity and algorithms for monomial and clausal predicate abstraction
Complexity and algorithms for monomial and clausal predicate abstraction Shuvendu K. Lahiri and Shaz Qadeer Microsoft Research Abstract. In this paper, we investigate the asymptotic complexity of various
More informationVerifying Properties of Parallel Programs: An Axiomatic Approach
Verifying Properties of Parallel Programs: An Axiomatic Approach By Susan Owicki and David Gries (1976) Nathan Wetzler nwetzler@cs.utexas.edu University of Texas, Austin November 3, 2009 Outline Introduction
More informationNull Dereference Verification Via Over-approximated Weakest Precondition analysis
Null Dereference Verification Via Over-approximated Weakest Precondition analysis Ravichandhran Madhavan Microsoft Research, India Joint work with Raghavan Komondoor, Indian Institute of Science Problem
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationStrength; Weakest Preconditions
12/14: solved Strength; Weakest Preconditions CS 536: Science of Programming, Spring 2018 A. Why To combine correctness triples, we need to weaken and strengthen conditions. A weakest precondition is the
More informationProgram Verification Using Separation Logic
Program Verification Using Separation Logic Cristiano Calcagno Adapted from material by Dino Distefano Lecture 1 Goal of the course Study Separation Logic having automatic verification in mind Learn how
More informationLoop Convergence. CS 536: Science of Programming, Fall 2018
Solved Loop Convergence CS 536: Science of Programming, Fall 2018 A. Why Diverging programs aren t useful, so it s useful to know how to show that loops terminate. B. Objectives At the end of this lecture
More informationBilateral Proofs of Safety and Progress Properties of Concurrent Programs (Working Draft)
Bilateral Proofs of Safety and Progress Properties of Concurrent Programs (Working Draft) Jayadev Misra December 18, 2015 Contents 1 Introduction 3 2 Program and Execution Model 4 2.1 Program Structure..........................
More informationProof Rules for Correctness Triples
Proof Rules for Correctness Triples CS 536: Science of Programming, Fall 2018 A. Why? We can t generally prove that correctness triples are valid using truth tables. We need proof axioms for atomic statements
More informationAxiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare
Axiomatic Semantics Semantics of Programming Languages course Joosep Rõõmusaare 2014 Direct Proofs of Program Correctness Partial correctness properties are properties expressing that if a given program
More informationClassical Program Logics: Hoare Logic, Weakest Liberal Preconditions
Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will
More informationIntroduction to Axiomatic Semantics
Introduction to Axiomatic Semantics Meeting 9, CSCI 5535, Spring 2009 Announcements Homework 3 is out, due Mon Feb 16 No domain theory! Homework 1 is graded Feedback attached 14.2 (mean), 13 (median),
More informationAsynchronous Communication 2
Asynchronous Communication 2 INF4140 22.11.12 Lecture 11 INF4140 (22.11.12) Asynchronous Communication 2 Lecture 11 1 / 37 Overview: Last time semantics: histories and trace sets specification: invariants
More informationPredicate Transforms I
Predicate Transforms I Software Testing and Verification Lecture Notes 19 Prepared by Stephen M. Thebaut, Ph.D. University of Florida Predicate Transforms I 1. Introduction: weakest pre-conditions (wp
More informationIntroduction to Permission-Based Program Logics Part II Concurrent Programs
Introduction to Permission-Based Program Logics Part II Concurrent Programs Thomas Wies New York University Example: Lock-Coupling List 2 3 5 7 8 9 There is one lock per node; threads acquire locks in
More informationAn Introduction to Symbolic Trajectory Evaluation. Koen Lindström Claessen Chalmers University / Jasper AB Gothenburg, Sweden
An Introduction to Symbolic Trajectory Evaluation Koen Lindström Claessen Chalmers University / Jasper AB Gothenburg, Sweden An Example A 7-input AND gate? in in1 in2 in3 OR out in4 in5 in6 OR Verification
More informationCentral Algorithmic Techniques. Iterative Algorithms
Central Algorithmic Techniques Iterative Algorithms Code Representation of an Algorithm class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (int i = 1; i < a.length;
More information