Deterministic Program The While Program
|
|
- Jemimah Cunningham
- 5 years ago
- Views:
Transcription
1 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, / 25
2 Outline 1 Verification Total Correctness: Proof System TW 2 Developing Programs 3 Proof Outlines Shangping Ren Deterministic Program The While Program February 24, / 25
3 Verification Total Correctness: Proof System TW Proof System (TW) Axiom 1: Skip : the same as in PW Axiom 2: Assignment : the same as in PW Rule 3: Composition : the same as in PW Rule 4: Conditional : the same as in PW Rule 5: Loop : different from PW (given as Rule 7) Rule 6: Consequence : the same as in PW Shangping Ren Deterministic Program The While Program February 24, / 25
4 Verification Total Correctness: Proof System TW Rule 7 : Total Correctness for Loops {p B} S {p}, {p B t = z} S {t < z}, p t 0 {p} while B do S od {p B} Where t is an integer expression and z is an integer variable that does not occur in p, B, t, or S. Why are we talking about variables that don t exist? Shangping Ren Deterministic Program The While Program February 24, / 25
5 Verification Total Correctness: Proof System TW Example 2, Revisited Verify the Total Correctness DIV quo := 0; rem := x; while rem >= y do rem := rem - y; quo := quo + 1 od Verify under total correctness: {x 0 y > 0}DIV {quo y + rem = x 0 rem < y} Shangping Ren Deterministic Program The While Program February 24, / 25
6 Verification Total Correctness: Proof System TW Example 2, Revisited Verify the Total Correctness DIV quo := 0; rem := x; while rem >= y do rem := rem - y; quo := quo + 1 od inv: p quo y + rem = x rem 0 y > 0; B: B rem y; bd t: t rem; z: an integer variable that does not occur in p, B, t, and DIV Shangping Ren Deterministic Program The While Program February 24, / 25
7 Verification Total Correctness: Proof System TW Example 2, Revisited Verify the Total Correctness inv: p quo y + rem = x rem 0 y > 0; B: B rem y; bd t: t rem; z: an integer variable that does not occur in p, B, t, and DIV 1 Invariant is established: {x 0 y > 0}quo := 0; rem := x{p} 2 Loop body does not change the loop invariant {p B}rem := rem y; quo := quo + 1{p} 3 Bounded integer decreases after each iteration {p B rem = z}rem := rem y; quo := quo + 1{rem < z} 4 Invariant implies bounded integer is non-negative: p t 0 5 When it terminates, the postcondition holds p B p rem < y Shangping Ren Deterministic Program The While Program February 24, / 25
8 The Five Equations Developing Programs To do this we need to develop five equations. 1 {r}t {p} 2 {p B}S{p} 3 {p B t = z} S {t < z} 4 p t 0 5 p B q Shangping Ren Deterministic Program The While Program February 24, / 25
9 Extended Example Developing Programs Given an array A, populate array B with the running sum of A. E.g., if A = {1, 1, 2, 3, 4}, then B = {1, 2, 4, 7, 11}. Shangping Ren Deterministic Program The While Program February 24, / 25
10 Proof Outlines for Loops Partial Correctness {p B}S {p} {inv : p}while B do {p B}S {p} od {p B} Total Correctness {p B} S {p}, {p B t = z} S {t < z}, p t 0 {inv : p}{bd : t}while B do {p B}S {p} od {p B} Shangping Ren Deterministic Program The While Program February 24, / 25
11 The Proof Outline for Total Correctness We have a program of the form satisfying under total correctness {r} T ; {inv : p} {bd : t} while B do {p B} S {p} od {p B} {q} R T ; while B do S od {r}r{q} Shangping Ren Deterministic Program The While Program February 24, / 25
12 The Proof Outline for Total Correctness {r} T ; {inv : p} {bd : t} while B do {p B} S {p} od {p B} {q} 21 {x y y > 0} 22 quo := 0; rem := x; 23 {inv : p}{bd : rem} 24 while rem y do 25 {p rem y} 26 rem := rem - y; quo := quo {p} 28 od 29 {p rem < y} 30 {quo y + rem = x 0 rem < y} where p quo y + rem = x rem 0 y > 0 Still need to verify the other two promises in Rule 7. Shangping Ren Deterministic Program The While Program February 24, / 25
13 Decomposition for the Total Correctness Proof Proof under total correctness: {p}s{q} We can separate the proof process into two steps: 1 Establish a partial correctness formula {p}s{q} 2 Proof termination with simpler total correctness formula {p}s{true } Axiom A1: Decomposition p {p}s{q}, t {p}s{true } {p}s{q} Shangping Ren Deterministic Program The While Program February 24, / 25
14 Auxiliary Axims and Rules Axiom A2: Invariance and where free(p) change(s) = φ Rule A3: Disjunction Rule A4: Conjunction {p}s{p} {r}s{q} {p r}s{p q} {p}s{q}, {r}s{q} {p r}s{q} {p 1 }S{q 1 }, {p 2 }S{q 2 } {p 1 p 2 }S{q 1 q 2 } Shangping Ren Deterministic Program The While Program February 24, / 25
15 Auxiliary Axims and Rules Axiom A5: Substitution where u var(s) t change(s). {p}s{q} {p[u := t]}s{q[u := t]} Axiom A6: -Introduction {p}s{q} { x : p]}s{q} where x does not occur in S or in free(q). Shangping Ren Deterministic Program The While Program February 24, / 25
16 Strengthening Precondition and Weakening Postconditions Given a valid triple {p}s{q}, how can we modify p and q and maintain validity? if p 0 p 1 then p 0 is stronger than p 1 and p 1 is weaker than p 0. Example: x = 0 is stronger than x = 0 x = 1 is stronger than x 0 Consequence Rule: we can strength a precondition and weaken a postcondition. What is the strongest predicate? What is the weakest one? Shangping Ren Deterministic Program The While Program February 24, / 25
17 Strengthening Precondition and Weakening Postconditions Given a valid triple {p}s{q}, how can we modify p and q and maintain validity? if p 0 p 1 then p 0 is stronger than p 1 and p 1 is weaker than p 0. Example: x = 0 is stronger than x = 0 x = 1 is stronger than x 0 Consequence Rule: we can strength a precondition and weaken a postcondition. What is the strongest predicate? What is the weakest one? Shangping Ren Deterministic Program The While Program February 24, / 25
18 Strengthening Precondition and Weakening Postconditions Given a valid triple {p}s{q}, how can we modify p and q and maintain validity? if p 0 p 1 then p 0 is stronger than p 1 and p 1 is weaker than p 0. Example: x = 0 is stronger than x = 0 x = 1 is stronger than x 0 Consequence Rule: we can strength a precondition and weaken a postcondition. What is the strongest predicate? What is the weakest one? Shangping Ren Deterministic Program The While Program February 24, / 25
19 Strengthening Precondition and Weakening Postconditions Given a valid triple {p}s{q}, how can we modify p and q and maintain validity? if p 0 p 1 then p 0 is stronger than p 1 and p 1 is weaker than p 0. Example: x = 0 is stronger than x = 0 x = 1 is stronger than x 0 Consequence Rule: we can strength a precondition and weaken a postcondition. What is the strongest predicate? What is the weakest one? Shangping Ren Deterministic Program The While Program February 24, / 25
20 What about Weakening Preconditions and Strengthening Postconditions? if p p 0 and {p}s{q} is valid, can we conclude {p 0 }S{q} is valid? Consider {x = 0}y := x x{y = x}, what about {x = 0 x = 1}y := x x{y = x} or {x 0}y := x x{y = x} if q 0 q and {p}s{q} is valid, can we conclude {p}s{q 0 } is valid? Shangping Ren Deterministic Program The While Program February 24, / 25
21 Definitions about wlp and wp Definition: let S be a while program and Φ a set of proper states, Weakest Liberal Precondition wlp of S with respect to Φ: wlp(s, Φ) = {σ M[[S]](σ) Φ} Weakest Precondition wp of S with respect to Φ: wp(s, Φ) = {σ M tot [[S]](σ) Φ} Shangping Ren Deterministic Program The While Program February 24, / 25
22 Definitions about wlp and wp Definition: let S be a while program and Φ a set of proper states, Weakest Liberal Precondition wlp of S with respect to Φ: wlp(s, Φ) = {σ M[[S]](σ) Φ} Weakest Precondition wp of S with respect to Φ: wp(s, Φ) = {σ M tot [[S]](σ) Φ} Shangping Ren Deterministic Program The While Program February 24, / 25
23 Theorem about wlp and wp Remember the notation of [[p]]? Theorem: let S be a while program and q an assertion. Then the following holds: 1 There is an assertion p defining wlp(s, [[q]]), i.e., with [[p]] = wlp(s, [[q]]) 2 There is an assertion p defining wp(s, [[q]]), i.e., with [[p]] = wp(s, [[q]]). We also write wlp(s, [[q]]) as wlp(s, q) and wp(s, [[q]]) as wp(s, q) Shangping Ren Deterministic Program The While Program February 24, / 25
24 Weakest Liberal Precondition The following statements hold for all while programs and assertions: 1 skip: wlp(skip, q) q, 2 assignment: wlp(u := t, q) q[u := t], 3 sequence: wlp(s 1 ; S 2, q) wlp(s 1, wlp(s 2, q)), 4 conditional: wlp(if B then S 1 else S 2 fi, q) (B wlp(s 1, q) ( B wlp(s 2, q)), 5 S while B do S 1 od : wlp(s, q) B wlp(s 1, wlp(s, q)), 6 S while B do S 1 od : wlp(s, q) B q 7 {p}s{q}: = {p}s{q}iff p wlp(s, q) Shangping Ren Deterministic Program The While Program February 24, / 25
25 wlp(s, q) as Loop Invariant Previous slides (5) S while B do S 1 od : wlp(s, q) B wlp(s 1, wlp(s, q)), and (7) {p}s{q}: = {p}s{q}iff p wlp(s, q) We have = {wlp(s, q) B}S 1 {wlp(s, q)}, i.e., wlp(s, q) is a loop invariant of S. Shangping Ren Deterministic Program The While Program February 24, / 25
26 Weakest Precondition The following statements hold for all while programs and assertions: 1 skip: wp(skip, q) q, 2 assignment: wp(u := t, q) q[u := t], 3 sequence: wp(s 1 ; S 2, q) wp(s 1, wp(s 2, q)), 4 conditional: wp(if B then S 1 else S 2 fi, q) (B wp(s 1, q) ( B wp(s 2, q)), 5 S while B do S 1 od : wp(s, q) B wp(s 1, wp(s, q)), 6 S while B do S 1 od : wp(s, q) B q 7 {p}s{q}: = tot {p}s{q}iff p wp(s, q) Shangping Ren Deterministic Program The While Program February 24, / 25
27 Strongest Postcondition For given p and S, there exists a strongest postcondition q such that {p}s{q} is valid, i.e., For partial correctness, {p}s{q} iff sp(p, S) q. For total correctness, {p}s{q} iff sp(p, S) q and S terminates on all states of p Shangping Ren Deterministic Program The While Program February 24, / 25
28 Strongest Postcondition For given p and S, there exists a strongest postcondition q such that {p}s{q} is valid, i.e., For partial correctness, {p}s{q} iff sp(p, S) q. For total correctness, {p}s{q} iff sp(p, S) q and S terminates on all states of p Shangping Ren Deterministic Program The While Program February 24, / 25
29 Strongest Postcondition For given p and S, there exists a strongest postcondition q such that {p}s{q} is valid, i.e., For partial correctness, {p}s{q} iff sp(p, S) q. For total correctness, {p}s{q} iff sp(p, S) q and S terminates on all states of p Shangping Ren Deterministic Program The While Program February 24, / 25
30 Strongest Postconditions for Loop-Free Programs sp(p, skip ) p sp(p, u := v) p[u := u 0 ] u = (v[u := u 0 ]) sp(p, S 1 ; S 2 ) sp(sp(p, S 1 ), S 2 ) sp(p, if B then S 1 else S 2 fi ) sp(p B, S 1 ) sp(p B, S 2 ) Shangping Ren Deterministic Program The While Program February 24, / 25
31 Strongest Postcondition Examples sp(y 0, x := y) y 0[x := z] x = (y[x := z]) y 0 x = y Therefore, we have {y 0}x := y{y 0 x = y}, and the y 0 x = y is the strongest postcondition for the given precondition and the assignment statement. As y 0 x = y x 0, apply consequence rule to {y 0}x := y{y 0 x = y}, we have {y 0}x := y{x 0}. The weakest precondition of given post condition x 0 and program x := y is nevertheless y 0, i.e., wp(x := y, x 0) y 0. Shangping Ren Deterministic Program The While Program February 24, / 25
Floyd-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 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 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 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. 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationWhat? Correctness? Bugs!
Program Correctness Literatuur Verification of Sequential and Concurrent Programs. Krzysztof R. Apt, Frank S. de Boer, Ernst-Rüdiger Olderog. Series: Texts in Computer Science. Springer. 3rd ed. 2nd Printing.
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 informationVerification Frameworks and Hoare Logic
CMSC 630 February 11, 2015 1 Verification Frameworks and Hoare Logic Sources K. Apt and E.-R. Olderog. Verification of Sequential and Concurrent Programs (Second Edition). Springer-Verlag, Berlin, 1997.
More informationCOMP2111 Glossary. Kai Engelhardt. Contents. 1 Symbols. 1 Symbols 1. 2 Hoare Logic 3. 3 Refinement Calculus 5. rational numbers Q, real numbers R.
COMP2111 Glossary Kai Engelhardt Revision: 1.3, May 18, 2018 Contents 1 Symbols 1 2 Hoare Logic 3 3 Refinement Calculus 5 1 Symbols Booleans B = {false, true}, natural numbers N = {0, 1, 2,...}, integers
More informationMid-Semester Quiz Second Semester, 2012
THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Quiz Second Semester, 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 1 hour duration Study Period: 10 minutes duration Permitted
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 informationA Humble Introduction to DIJKSTRA S A A DISCIPLINE OF PROGRAMMING
A Humble Introduction to DIJKSTRA S A A DISCIPLINE OF PROGRAMMING Do-Hyung Kim School of Computer Science and Engineering Sungshin Women s s University CONTENTS Bibliographic Information and Organization
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 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 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 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 informationTHE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering)
THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2016 COMP2600/COMP6260 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials:
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 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 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 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 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 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 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 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 informationGalois Connections. Roland Backhouse 3rd December, 2002
1 Galois Connections Roland Backhouse 3rd December, 2002 Fusion 2 Many problems are expressed in the form evaluate generate where generate generates a (possibly infinite) candidate set of solutions, and
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 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 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 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 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 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 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 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
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 informationVerificación de Programas!
Verificación de Programas! rafael ramirez rafael.ramirez@upf.edu 55.316 (Tanger) Porque verificar programas Debido a un error de programación, el cohete que llevaba al Mariner I, en viaje sin tripulación
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 informationProgramming 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 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 informationTHE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)
THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4
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 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 informationDeclarative View of Imperative Programs
Declarative View of Imperative Programs Hugh Gibbons, Trinity College, Dublin, Ireland. Abstract By giving a declarative meaning to an imperative program, the verification of the imperative program is
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 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 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 informationthat shows the semi-decidability of the problem (i.e. a semi-decision procedure for EXISTS-HALTING) and argue that it is correct.
Exercise 1 (15) Consider the following problem: EXISTS-HALTING INSTANCE: A program Π, which takes as input a string over the alphabet {a, b, c,..., z}. QUESTION: Does there exist an input I, such that
More informationFoundations of Computation
The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 6 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the
More informationProving Inter-Program Properties
Unité Mixte de Recherche 5104 CNRS - INPG - UJF Centre Equation 2, avenue de VIGNATE F-38610 GIERES tel : +33 456 52 03 40 fax : +33 456 52 03 50 http://www-verimag.imag.fr Proving Inter-Program Properties
More informationCalculating axiomatic semantics from program equations by means of functional predicate calculus
Calculating axiomatic semantics from program equations by means of functional predicate calculus (Some initial results of recent work not for dissemination) Raymond Boute INTEC Ghent University 2004/02
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 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 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 informationUnifying Theories of Programming
1&2 Unifying Theories of Programming Unifying Theories of Programming 3&4 Theories Unifying Theories of Programming designs predicates relations reactive CSP processes Jim Woodcock University of York May
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 informationCS 336. We use the principle of inclusion and exclusion. Let B. = {five digit decimal numbers ending with a 5}, and
CS 336 1. The important issue is the logic you used to arrive at your answer. 2. Use extra paper to determine your solutions then neatly transcribe them onto these sheets. 3. Do not submit the scratch
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 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 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 informationFoundations of Quantum Programming
Foundations of Quantum Programming Mingsheng Ying University of Technology Sydney, Australia Institute of Software, Chinese Academy of Sciences Tsinghua University, China Outline Introduction Syntax of
More informationMarie Farrell Supervisors: Dr Rosemary Monahan & Dr James Power Principles of Programming Research Group
EXAMINING REFINEMENT: THEORY, TOOLS AND MATHEMATICS Marie Farrell Supervisors: Dr Rosemary Monahan & Dr James Power Principles of Programming Research Group PROBLEM Different formalisms do not integrate
More informationProgram Construction and Reasoning
Program Construction and Reasoning Shin-Cheng Mu Institute of Information Science, Academia Sinica, Taiwan 2010 Formosan Summer School on Logic, Language, and Computation June 28 July 9, 2010 1 / 97 Introduction:
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 informationAxiomatic Verification II
Axiomatic Verification II Software Testing and Verification Lecture Notes 18 Prepared by Stephen M. Thebaut, Ph.D. University of Florida Axiomatic Verification II Reasoning about iteration (while loops)
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 informationExtending the theory of Owicki and Gries with a logic of progress
Extending the theory of Owicki and Gries with a logic of progress Brijesh Dongol Doug Goldson August 2005 Technical Report SSE-2005-03 Division of Systems and Software Engineering Research School of Information
More informationStatic Program Analysis
Static Program Analysis Lecture 16: Abstract Interpretation VI (Counterexample-Guided Abstraction Refinement) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de
More informationVerifying Java-KE Programs
Verifying Java-KE Programs A Small Case Study Arnd Poetzsch-Heffter July 22, 2014 Abstract This report investigates the specification and verification of a simple list class. The example was designed such
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 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 informationAN INTRODUCTION TO SEPARATION LOGIC. 2. Assertions
AN INTRODUCTION TO SEPARATION LOGIC 2. Assertions John C. Reynolds Carnegie Mellon University January 7, 2011 c 2011 John C. Reynolds Pure Assertions An assertion p is pure iff, for all stores s and all
More informationFormal Methods for Probabilistic Systems
1 Formal Methods for Probabilistic Systems Annabelle McIver Carroll Morgan Source-level program logic Introduction to probabilistic-program logic Systematic presentation via structural induction Layout
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 informationControl Predicates Are Better Than Dummy Variables For Reasoning About Program Control
Control Predicates Are Better Than Dummy Variables For Reasoning About Program Control LESLIE LAMPORT Digital Equipment Corporation When explicit control predicates rather than dummy variables are used,
More informationLecture Notes on Software Model Checking
15-414: Bug Catching: Automated Program Verification Lecture Notes on Software Model Checking Matt Fredrikson André Platzer Carnegie Mellon University Lecture 19 1 Introduction So far we ve focused on
More informationICS141: Discrete Mathematics for Computer Science I
ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by
More informationLectures on Separation Logic. Lecture 2: Foundations
Lectures on Separation Logic. Lecture 2: Foundations Peter O Hearn Queen Mary, University of London Marktoberdorf Summer School, 2011 Outline for this lecture Part I : Assertions and Their Semantics Part
More informationn Empty Set:, or { }, subset of all sets n Cardinality: V = {a, e, i, o, u}, so V = 5 n Subset: A B, all elements in A are in B
Discrete Math Review Discrete Math Review (Rosen, Chapter 1.1 1.7, 5.5) TOPICS Sets and Functions Propositional and Predicate Logic Logical Operators and Truth Tables Logical Equivalences and Inference
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 information