Semantics and Verification of Software

Size: px
Start display at page:

Download "Semantics and Verification of Software"

Transcription

1 Semantics and Verification of Software Thomas Noll Software Modeling and Verification Group RWTH Aachen University

2 The Denotational Approach Denotational Semantics of WHILE Primary aspect of a program: its effect, i.e., input/output behavior In operational semantics: indirect definition of semantic functional by execution relation O. : Cmd (Σ Σ) Now: abstract from operational details Denotational semantics: direct definition of program effect by induction on its syntactic structure 3 of 24 Semantics and Verification of Software

3 Denotational Semantics of Expressions Semantics of Arithmetic Expressions Again: value of an expression determined by current state Definition 6.1 (Denotational semantics of arithmetic expressions) The (denotational) semantic functional for arithmetic expressions, A. : AExp (Σ Z), is given by: A z σ := z A x σ := σ(x) A a 1 +a 2 σ := A a 1 σ + A a 2 σ A a 1 -a 2 σ := A a 1 σ A a 2 σ A a 1 *a 2 σ := A a 1 σ A a 2 σ 5 of 24 Semantics and Verification of Software

4 Denotational Semantics of Expressions Semantics of Boolean Expressions Definition 6.2 (Denotational semantics of Boolean expressions) The (denotational) semantic functional for Boolean expressions is given by B. : BExp (Σ B) where B t σ := t{ true if A a1 σ = A a B a 1 =a 2 σ := 2 σ false otherwise { true if A a1 σ > A a B a 1 >a 2 σ := 2 σ false otherwise { true if B b σ = false B b σ := false otherwise { true if B b1 σ = B b B b 1 b 2 σ := 2 σ = true false otherwise { false if B b1 σ = B b B b 1 b 2 σ := 2 σ = false true otherwise 6 of 24 Semantics and Verification of Software

5 Denotational Semantics of Statements The Goal Now: semantic functional C. : Cmd (Σ Σ) Same type as operational functional O. : Cmd (Σ Σ) (in fact, both will turn out to be the same equivalence of operational and denotational semantics) 8 of 24 Semantics and Verification of Software

6 Denotational Semantics of Statements Auxiliary Functions Inductive definition of C. employs following auxiliary functions: identity on states: id Σ : Σ Σ : σ σ (strict) composition of partial state transformations: : (Σ Σ) (Σ Σ) (Σ Σ) where, for every f, g : Σ Σ and σ Σ, { g(f (σ)) if f (σ) defined (g f )(σ) := undefined otherwise semantic conditional: cond : (Σ B) (Σ Σ) (Σ Σ) (Σ Σ) where, for every p : Σ B, f, g : Σ Σ, and σ Σ, { f (σ) if p(σ) = true cond(p, f, g)(σ) := g(σ) otherwise 9 of 24 Semantics and Verification of Software

7 Denotational Semantics of Statements Semantics of Statements I Definition 6.3 (Denotational semantics of statements) The (denotational) semantic functional for statements, is given by: C. : Cmd (Σ Σ), C skip := id Σ C x := a σ := σ[x A a σ] C c 1 ;c 2 := C c 2 C c 1 C if b then c 1 else c 2 end := cond(b b, C c 1, C c 2 ) C while b do c end := fix(φ) where Φ : (Σ Σ) (Σ Σ) : f cond(b b, f C c, id Σ ) 10 of 24 Semantics and Verification of Software

8 Denotational Semantics of Statements Semantics of Statements II Remarks: Definition of C c given by induction on syntactic structure of c Cmd in particular, C while b do c end only refers to B b and C c (and not to C while b do c end again) note difference to O c : (wh-t) b, σ true c, σ σ while b do c, σ σ while b do c end, σ σ In C c 1 ;c 2 := C c 2 C c 1, function composition has to be strict since non-termination of c 1 implies non-termination of c 1 ;c 2 In C while b do c end := fix(φ), fix denotes a fixpoint operator (which remains to be defined) fixpoint semantics But: why fixpoints? 11 of 24 Semantics and Verification of Software

9 Denotational Semantics of Statements Why Fixpoints? Goal: preserve validity of equivalence C while b do c end ( ) = C if b then c;while b do c end else skip end (cf. Lemma 4.3) Using the known parts of Definition 6.3, we obtain: C while b do c end ( ) = C if b then c;while b do c end else skip end Def. 6.3 = cond(b b, C c;while b do c end, C skip ) Def. 6.3 = cond(b b, C while b do c end C c, id Σ ) Abbreviating f := C while b do c end this yields: f = cond(b b, f C c, id Σ ) Hence f must be a solution of this recursive equation In other words: f must be a fixpoint of the mapping Φ : (Σ Σ) (Σ Σ) : f cond(b b, f C c, id Σ ) (since the equation can be stated as f = Φ(f )) 12 of 24 Semantics and Verification of Software

10 Denotational Semantics of Statements Well-Definedness of Fixpoint Semantics But: fixpoint property not sufficient to obtain a well-defined semantics Potential problems: Existence: there does not need to exist any fixpoint. Examples: 1. φ 1 : N N : n n + 1 has no fixpoint { g1 if f = g 2. Φ 1 : (Σ Σ) (Σ Σ) : f 2 g 2 otherwise has no fixpoint if g 1 g 2 Solution: in our setting, fixpoints always exist Uniqueness: there might exist several fixpoints. Examples: 1. φ 2 : N N : n n 3 has fixpoints {0, 1} 2. every state transformation f is a fixpoint of Φ 2 : (Σ Σ) (Σ Σ) : f f Solution: uniqueness guaranteed by choosing a special fixpoint 13 of 24 Semantics and Verification of Software

11 Characterisation of fix(φ) Characterisation of fix(φ) Let b BExp and c Cmd Let Φ(f ) := cond(b b, f C c, id Σ ) Let f 0 : Σ Σ be a fixpoint of Φ, i.e., Φ(f 0 ) = f 0 Given some initial state σ 0 Σ, we will distinguish the following cases: 1. loop while b do c end terminates after n iterations (n N) 2. body c diverges in the n-th iteration (as it contains a non-terminating while statement) 3. loop while b do c end itself diverges 15 of 24 Semantics and Verification of Software

12 Characterisation of fix(φ) Case 1: Termination of Loop Loop while b do c end terminates after n iterations (n N) Formally: there exist σ 1,..., σ n Σ such that { true if 0 i < n B b σ i = and false if i = n C c σ i = σ i+1 for every 0 i < n Now the definition Φ(f ) := cond(b b, f C c, id Σ ) implies, for every 0 i < n, Φ(f 0 )(σ i ) = (f 0 C c )(σ i ) since B b σ i = true = f 0 (σ i+1 ) and Φ(f 0 )(σ n ) = σ n since B b σ n = false Since Φ(f 0 ) = f 0 it follows that { f0 (σ f 0 (σ i ) = i+1 ) if 0 i < n σ n if i = n and hence f 0 (σ 0 ) = f 0 (σ 1 ) =... f 0 (σ n ) = σ n All fixpoints f 0 coincide on σ 0 (with result σ n )! 16 of 24 Semantics and Verification of Software

13 Characterisation of fix(φ) Case 2: Divergence of Body Body c diverges in the n-th iteration (since it contains a non-terminating while statement) Formally: there exist σ 1,..., σ n 1 Σ such that B b σ i = true { σi+1 if 0 i n 2 C c σ i = undefined if i = n 1 for every 0 i < n and Just as in the previous case (setting σ n := undefined) it follows that f 0 (σ 0 ) = undefined Again all fixpoints f 0 coincide on σ 0 (with undefined result)! 17 of 24 Semantics and Verification of Software

14 Characterisation of fix(φ) Case 3: Divergence of Loop Loop while b do c end diverges Formally: there exist σ 1, σ 2,... Σ such that B b σ i = true C c σ i = σ i+1 and for every i N Here only derivable: f 0 (σ 0 ) = f 0 (σ i ) for every i N Value of f 0 (σ 0 ) not determined! 18 of 24 Semantics and Verification of Software

15 Characterisation of fix(φ) Summary For Φ(f 0 ) = f 0 and initial state σ 0 Σ, case distinction yields: 1. Loop while b do c end terminates after n iterations (n N) f 0 (σ 0 ) = σ n 2. Body c diverges in the n-th iteration f 0 (σ 0 ) = undefined 3. Loop while b do c end diverges no condition on f 0 (only f 0 (σ 0 ) = f 0 (σ i ) for every i N) Not surprising since, e.g., for the loop while true do skip end every f : Σ Σ is a fixpoint: Φ(f ) = cond(b true, f C skip, id Σ ) = f On the other hand, our operational understanding requires, for every σ 0 Σ, Conclusion fix(φ) is the least defined fixpoint of Φ. C while true do skip end σ 0 = undefined 19 of 24 Semantics and Verification of Software

16 Making It Precise Making It Precise I To use fixpoint theory, the notion of least defined has to be made precise. Given f, g : Σ Σ, let f g for every σ, σ Σ : f (σ) = σ g(σ) = σ (g is at least as defined as f ) Equivalent to requiring graph(f ) graph(g) where graph(h) := {(σ, σ ) σ Σ, σ = h(σ) defined} Σ Σ for every h : Σ Σ 21 of 24 Semantics and Verification of Software

17 Making It Precise Making It Precise II Example 6.4 Let x Var be fixed, and let f 0, f 1, f 2, f 3 : Σ Σ be given by f 0 (σ) := undefined { σ if σ(x) even f 1 (σ) := undefined otherwise { σ if σ(x) odd f 2 (σ) := f 3 (σ) := σ undefined otherwise This implies f 0 f 1 f 3, f 0 f 2 f 3, f 1 f 2, and f 2 f 1 22 of 24 Semantics and Verification of Software

18 Making It Precise Characterisation of fix(φ) I Now fix(φ) can be characterised by: fix(φ) is a fixpoint of Φ, i.e., Φ(fix(Φ)) = fix(φ) fix(φ) is minimal with respect to, i.e., for every f 0 : Σ Σ such that Φ(f 0 ) = f 0, fix(φ) f 0 Example 6.5 For while true do skip end we obtain for every f : Σ Σ: Φ(f) = cond(b true, f C skip, id Σ ) = f fix(φ) = f where f (σ) := undefined for every σ Σ (that is, graph(f ) = ) 23 of 24 Semantics and Verification of Software

19 Making It Precise Characterisation of fix(φ) II Goals: Prove existence of fix(φ) for Φ(f ) = cond(b b, f C c, id Σ ) Show how it can be computed (more exactly: approximated) Sufficient conditions: on domain Σ Σ: chain-complete partial order on function Φ: monotonicity and continuity 24 of 24 Semantics and Verification of Software

Semantics and Verification of Software

Semantics and Verification of Software Semantics and Verification of Software Thomas Noll Software Modeling and Verification Group RWTH Aachen University http://moves.rwth-aachen.de/teaching/ws-1718/sv-sw/ Recap: The Denotational Approach Semantics

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Lecture 13: Abstract Interpretation III (Abstract Interpretation of WHILE Programs) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de

More information

Static Program Analysis

Static 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 information

Denotational Semantics

Denotational Semantics 5 Denotational Semantics In the operational approach, we were interested in how a program is executed. This is contrary to the denotational approach, where we are merely interested in the effect of executing

More information

Denotational semantics

Denotational semantics Denotational semantics The method define syntax (syntactic domains) define semantic domains define semantic functions use compositional definitions Andrzej Tarlecki: Semantics & Verification - 63 - Syntactic

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-18/spa/ Recap: Interprocedural Dataflow Analysis Outline of

More information

Formal Techniques for Software Engineering: Denotational Semantics

Formal Techniques for Software Engineering: Denotational Semantics Formal Techniques for Software Engineering: Denotational Semantics Rocco De Nicola IMT Institute for Advanced Studies, Lucca rocco.denicola@imtlucca.it May 2013 Lesson 4 R. De Nicola (IMT-Lucca) FoTSE@LMU

More information

COSE312: Compilers. Lecture 14 Semantic Analysis (4)

COSE312: Compilers. Lecture 14 Semantic Analysis (4) COSE312: Compilers Lecture 14 Semantic Analysis (4) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 14 May 8, 2017 1 / 30 Denotational Semantics In denotational semantics, we are interested

More information

Denotational Semantics of Programs. : SimpleExp N.

Denotational Semantics of Programs. : SimpleExp N. Models of Computation, 2010 1 Denotational Semantics of Programs Denotational Semantics of SimpleExp We will define the denotational semantics of simple expressions using a function : SimpleExp N. Denotational

More information

CS422 - Programming Language Design

CS422 - Programming Language Design 1 CS422 - Programming Language Design Denotational Semantics Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 Denotational semantics, also known as fix-point semantics,

More information

AAA616: Program Analysis. Lecture 3 Denotational Semantics

AAA616: Program Analysis. Lecture 3 Denotational Semantics AAA616: Program Analysis Lecture 3 Denotational Semantics Hakjoo Oh 2018 Spring Hakjoo Oh AAA616 2018 Spring, Lecture 3 March 28, 2018 1 / 33 Denotational Semantics In denotational semantics, we are interested

More information

Semantics with Applications: Model-Based Program Analysis

Semantics with Applications: Model-Based Program Analysis Semantics with Applications: Model-Based Program Analysis c Hanne Riis Nielson c Flemming Nielson Computer Science Department, Aarhus University, Denmark (October 1996) Contents 1 Introduction 1 1.1 Side-stepping

More information

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 17 & 18 p.1/33 These Two Lectures Revisit attempt to define denotational

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Software Architektur Praxis-Workshop Bringen Sie Informatik

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Software Architektur Praxis-Workshop Bringen Sie Informatik

More information

Hoare Logic: Part II

Hoare 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 information

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

Dynamic 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 information

Denotational Semantics

Denotational Semantics Q Lecture Notes on Denotational Semantics Part II of the Computer Science Tripos 2010/11 Dr Marcelo Fiore Cambridge University Computer Laboratory c A. M. Pitts, G. Winskel, M. Fiore Contents Notes ii

More information

Algebraic Reasoning for Probabilistic Action Systems and While-Loops

Algebraic Reasoning for Probabilistic Action Systems and While-Loops Algebraic Reasoning for Probabilistic Action Systems and While-Loops Larissa Meinicke Ian J. Hayes September 006 Technical Report SSE-006-05 Division of Systems and Software Engineering Research School

More information

0.1 Random useful facts. 0.2 Language Definition

0.1 Random useful facts. 0.2 Language Definition 0.1 Random useful facts Lemma double neg : P : Prop, {P} + { P} P P. Lemma leq dec : n m, {n m} + {n > m}. Lemma lt dec : n m, {n < m} + {n m}. 0.2 Language Definition Definition var := nat. Definition

More information

Software Engineering

Software 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 information

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Classical 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 information

CMSC 631 Program Analysis and Understanding Fall Abstract Interpretation

CMSC 631 Program Analysis and Understanding Fall Abstract Interpretation Program Analysis and Understanding Fall 2017 Abstract Interpretation Based on lectures by David Schmidt, Alex Aiken, Tom Ball, and Cousot & Cousot What is an Abstraction? A property from some domain Blue

More information

Axiomatic Semantics. Lecture 9 CS 565 2/12/08

Axiomatic 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 information

Theoretical Computer Science

Theoretical Computer Science Theoretical Computer Science 411 (2010) 1372 1386 Contents lists available at ScienceDirect Theoretical Computer Science journal homepage: www.elsevier.com/locate/tcs A trajectory-based strict semantics

More information

Operational Semantics

Operational Semantics Operational Semantics Semantics and applications to verification Xavier Rival École Normale Supérieure Xavier Rival Operational Semantics 1 / 50 Program of this first lecture Operational semantics Mathematical

More information

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program

Program 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 information

CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions

CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers. 1 Complete partial orders (CPOs) 2 Least fixed points of functions CS 6110 Lecture 21 The Fixed-Point Theorem 8 March 2013 Lecturer: Andrew Myers We saw that the semantics of the while command are a fixed point. We also saw that intuitively, the semantics are the limit

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Axiomatic 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 information

CIS 500 Software Foundations. Midterm II. March 28, 2012

CIS 500 Software Foundations. Midterm II. March 28, 2012 CIS 500 Software Foundations Midterm II March 28, 2012 Name: Pennkey: Scores: 1 2 3 4 5 6 Total (80 max) This exam concentrates on the material on the Imp programming language, program equivalence, and

More information

Probabilistic Model Checking and [Program] Analysis (CO469)

Probabilistic Model Checking and [Program] Analysis (CO469) Probabilistic Model Checking and [Program] Analysis (CO469) Program Analysis Herbert Wiklicky herbert@doc.ic.ac.uk Spring 208 / 64 Overview Topics we will cover in this part will include:. Language WHILE

More information

Formal Methods in Software Engineering

Formal 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 information

CIS 500: Software Foundations. November 8, Solutions

CIS 500: Software Foundations. November 8, Solutions CIS 500: Software Foundations Midterm II November 8, 2018 Solutions 1. (8 points) Put an X in the True or False box for each statement. (1) For every b : bexp and c1, c2 : com, either the command IFB b

More information

Lecture 2. Least Fixed Points

Lecture 2. Least Fixed Points Lecture 2 Least Fixed Points 20 Thesis All domains of computation are partial orders with a least element. All computable functions are mononotic. 21 Partially ordered sets A binary relation on a set D

More information

Hoare Logic and Model Checking

Hoare 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 information

Axiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare

Axiomatic 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 information

Denotational semantics

Denotational semantics Denotational semantics Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 4 4 March 2016 Course 4 Denotational semantics Antoine Miné p.

More information

Tutorial on Semantics Part I

Tutorial on Semantics Part I Tutorial on Semantics Part I Basic Concepts Prakash Panangaden 1 1 School of Computer Science McGill University on sabbatical leave at Department of Computer Science Oxford University Fields Institute,

More information

Introduction to Kleene Algebras

Introduction to Kleene Algebras Introduction to Kleene Algebras Riccardo Pucella Basic Notions Seminar December 1, 2005 Introduction to Kleene Algebras p.1 Idempotent Semirings An idempotent semiring is a structure S = (S, +,, 1, 0)

More information

CIS 500: Software Foundations

CIS 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 information

Modular Bisimulation Theory for Computations and Values

Modular Bisimulation Theory for Computations and Values Modular Bisimulation Theory for Computations and Values Swansea University, UK FoSSaCS, Rome March 2013 Part of the project: PLanCompS http://www.plancomps.org EPSRC-funded, 2011-2015 {Swansea, Royal Holloway,

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

SEMANTICS OF PROGRAMMING LANGUAGES Course Notes MC 308

SEMANTICS OF PROGRAMMING LANGUAGES Course Notes MC 308 University of Leicester SEMANTICS OF PROGRAMMING LANGUAGES Course Notes for MC 308 Dr. R. L. Crole Department of Mathematics and Computer Science Preface These notes are to accompany the module MC 308.

More information

CIS 500 Software Foundations. Final Exam. May 9, Answer key. Hoare Logic

CIS 500 Software Foundations. Final Exam. May 9, Answer key. Hoare Logic CIS 500 Software Foundations Final Exam May 9, 2011 Answer key Hoare Logic 1. (7 points) What does it mean to say that the Hoare triple {{P}} c {{Q}} is valid? Answer: {{P}} c {{Q}} means that, for any

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. 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 information

Origin in Mathematical Logic

Origin in Mathematical Logic Lambda Calculus Origin in Mathematical Logic Foundation of mathematics was very much an issue in the early decades of 20th century. Cantor, Frege, Russel s Paradox, Principia Mathematica, NBG/ZF Origin

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. 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 information

Denotational Semantics

Denotational Semantics Q Lecture Notes on Denotational Semantics for Part II of the Computer Science Tripos Dr Andrew M. Pitts Cambridge University Computer Laboratory c A. M. Pitts, 1997-9 First edition 1997. Revised 1998,

More information

Simply Typed Lambda-Calculi (II)

Simply Typed Lambda-Calculi (II) THEORY AND PRACTICE OF FUNCTIONAL PROGRAMMING Simply Typed Lambda-Calculi (II) Dr. ZHANG Yu Institute of Software, Chinese Academy of Sciences Fall term, 2011 GUCAS, Beijing Introduction PCF Programming

More information

A Trajectory-based Strict Semantics for Program Slicing

A Trajectory-based Strict Semantics for Program Slicing A Trajectory-based Strict Semantics for Program Slicing Richard W. Barraclough a David Binkley b Sebastian Danicic a Mark Harman c Robert M. Hierons d Ákos Kiss e Mike Laurence a Lahcen Ouarbya a a Dept.

More information

Bi-inductive Structural Semantics

Bi-inductive Structural Semantics Bi-inductive Structural Semantics Patrick Cousot Département d informatique, École normale supérieure, 45 rue d Ulm, 75230 Paris cedex 05, France Radhia Cousot CNRS & École polytechnique, 91128 Palaiseau

More information

Program Analysis. Lecture 5. Rayna Dimitrova WS 2016/2017

Program Analysis. Lecture 5. Rayna Dimitrova WS 2016/2017 Program Analysis Lecture 5 Rayna Dimitrova WS 2016/2017 2/21 Recap: Constant propagation analysis Goal: For each program point, determine whether a variale has a constant value whenever an execution reaches

More information

On the Hardness of Analyzing Probabilistic Programs

On the Hardness of Analyzing Probabilistic Programs Acta Informatica manuscript No. (will be inserted by the editor) On the Hardness of Analyzing Probabilistic Programs Benjamin Lucien Kaminski Joost-Pieter Katoen Christoph Matheja Received: September 15

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Online Registration for Seminars and Practical Courses

More information

Program verification using Hoare Logic¹

Program 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 information

CSE20: Discrete Mathematics

CSE20: Discrete Mathematics Spring 2018 Summary Today: Induction, Program Correctness Reading: Chap. 5 Division Theorem Theorem: For every integer a and positive integer d 1, there exist integers q, r such that a = qd + r and 0 r

More information

Introduction to Axiomatic Semantics

Introduction 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 information

Recursion and Intro to Coq

Recursion and Intro to Coq L02-1 Recursion and Intro to Coq Armando Solar Lezama Computer Science and Artificial Intelligence Laboratory M.I.T. With content from Arvind and Adam Chlipala. Used with permission. September 21, 2015

More information

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers

Axiomatic 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 information

Static Program Analysis using Abstract Interpretation

Static Program Analysis using Abstract Interpretation Static Program Analysis using Abstract Interpretation Introduction Static Program Analysis Static program analysis consists of automatically discovering properties of a program that hold for all possible

More information

Program Analysis Part I : Sequential Programs

Program 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 information

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK Midlands Graduate School, University of Birmingham, April 2008 1 Operational Semantics Abstract Machines and Correctness Roy L. Crole University of Leicester, UK Midlands Graduate School, University of

More information

A State-Space Based Approach to the Specification and Verification of Hybrid Systems and Its Axiomatic Basis

A State-Space Based Approach to the Specification and Verification of Hybrid Systems and Its Axiomatic Basis A State-Space Based Approach to the Specification and Verification of Hybrid Systems and Its Axiomatic Basis A Thesis Submitted for the Degree of Master of Science by Wu Dinghao Advisor: Prof. Lü Jian

More information

Spring 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 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 information

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach

EDA045F: Program Analysis LECTURE 10: TYPES 1. Christoph Reichenbach EDA045F: Program Analysis LECTURE 10: TYPES 1 Christoph Reichenbach In the last lecture... Performance Counters Challenges in Dynamic Performance Analysis Taint Analysis Binary Instrumentation 2 / 44 Types

More information

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007

Dynamic Noninterference Analysis Using Context Sensitive Static Analyses. Gurvan Le Guernic July 14, 2007 Dynamic Noninterference Analysis Using Context Sensitive Static Analyses Gurvan Le Guernic July 14, 2007 1 Abstract This report proposes a dynamic noninterference analysis for sequential programs. This

More information

Model Theory MARIA MANZANO. University of Salamanca, Spain. Translated by RUY J. G. B. DE QUEIROZ

Model Theory MARIA MANZANO. University of Salamanca, Spain. Translated by RUY J. G. B. DE QUEIROZ Model Theory MARIA MANZANO University of Salamanca, Spain Translated by RUY J. G. B. DE QUEIROZ CLARENDON PRESS OXFORD 1999 Contents Glossary of symbols and abbreviations General introduction 1 xix 1 1.0

More information

Symbolic execution based on language transformation

Symbolic execution based on language transformation Symbolic execution based on language transformation Andrei Arusoaie, Dorel Lucanu, Vlad Rusu To cite this version: Andrei Arusoaie, Dorel Lucanu, Vlad Rusu. Symbolic execution based on language transformation.

More information

C241 Homework Assignment 7

C241 Homework Assignment 7 C24 Homework Assignment 7. Prove that for all whole numbers n, n i 2 = n(n + (2n + The proof is by induction on k with hypothesis H(k i 2 = k(k + (2k + base case: To prove H(, i 2 = = = 2 3 = ( + (2 +

More information

Basic Concepts of Abstract Interpretation

Basic Concepts of Abstract Interpretation Programming Research Laboratory Seoul National University Basic Concepts of Abstract Interpretation Soonho Kong http://ropas.snu.ac.kr/ soon/ May 25, 2007 Work of P. Cousot and R.Cousot Basic Concepts

More information

Precise Relational Invariants Through Strategy Iteration

Precise Relational Invariants Through Strategy Iteration Precise Relational Invariants Through Strategy Iteration Thomas Gawlitza and Helmut Seidl TU München, Institut für Informatik, I2 85748 München, Germany {gawlitza, seidl}@in.tum.de Abstract. We present

More information

Proving Inter-Program Properties

Proving 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 information

Design 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 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 information

A Logic for Information Flow Analysis with an Application to Forward Slicing of Simple Imperative Programs

A Logic for Information Flow Analysis with an Application to Forward Slicing of Simple Imperative Programs A Logic for Information Flow Analysis with an Application to Forward Slicing of Simple Imperative Programs Torben Amtoft and Anindya Banerjee a,1,2 a Department of Computing and Information Sciences Kansas

More information

The Formal Semantics of Programming Languages. Yuxin Deng Shanghai Jiao Tong University

The Formal Semantics of Programming Languages. Yuxin Deng Shanghai Jiao Tong University The Formal Semantics of Programming Languages Yuxin Deng Shanghai Jiao Tong University http://basics.sjtu.edu.cn/ yuxin/ March 4, 2015 Formal semantics of programming languages Y. Deng@SJTU 1 Instructor

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Chapter 2 An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Assertions In this chapter, we give a more detailed exposition of the assertions of separation logic: their meaning,

More information

A note on coinduction and weak bisimilarity for while programs

A note on coinduction and weak bisimilarity for while programs Centrum voor Wiskunde en Informatica A note on coinduction and weak bisimilarity for while programs J.J.M.M. Rutten Software Engineering (SEN) SEN-R9826 October 31, 1998 Report SEN-R9826 ISSN 1386-369X

More information

Operationally-Based Theories of Program Equivalence

Operationally-Based Theories of Program Equivalence Operationally-Based Theories of Program Equivalence Andrew Pitts Contents 1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : 241 2 Contextual Equivalence : : : : : : : : : : : : : :

More information

Axiomatic 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 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 information

Overall organisation and objectives. Semantics and Validation. Example of validation. Principle of course/tp relationship

Overall organisation and objectives. Semantics and Validation. Example of validation. Principle of course/tp relationship Overall organisation and objectives Semantics and Validation Eric Goubault Modelling and Analysis of Systems in Interaction lab. CEA-X-CNRS and X-Thalès chair 2nd of november 2011 How to give a formal

More information

Reasoning About Imperative Programs. COS 441 Slides 10b

Reasoning 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 information

III.2 (b) Higher level programming concepts for URMs Anton Setzer

III.2 (b) Higher level programming concepts for URMs Anton Setzer CS 275 Automata and Formal Language Theory Course Notes Additional Material Part III: Limits of Computation Chapt. III.2: The URM III.2 (a) Definition of the URM III.2 (b) Higher level programming concepts

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements

Axiomatic 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 information

Deductive Verification

Deductive 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 information

Abstract Interpretation II

Abstract Interpretation II Abstract Interpretation II Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 11 13 May 2016 Course 11 Abstract Interpretation II Antoine

More information

Imperative Insertion Sort

Imperative Insertion Sort Imperative Insertion Sort Christian Sternagel April 17, 2016 Contents 1 Looping Constructs for Imperative HOL 1 1.1 While Loops............................ 1 1.2 For Loops.............................

More information

What does the partial order "mean"?

What does the partial order mean? What does the partial order "mean"? Domain theory developed by Dana Scott and Gordon Plotkin in the late '60s use partial order to represent (informally): approximates carries more information than better

More information

A Language-Independent Proof System for Full Program Equivalence

A Language-Independent Proof System for Full Program Equivalence A Language-Independent Proof System for Full Program Equivalence Ștefan Ciobâcă, Dorel Lucanu, Vlad Rusu and Grigore Roșu 3 Faculty Of Computer Science, Alexandru Ioan Cuza University, Iași, Romania, Inria

More information

Probabilistic Programming

Probabilistic Programming Joost-Pieter Katoen 1/41 Lecture #10: Conditioning Joost-Pieter Katoen RWTH Lecture Series on 2018 Joost-Pieter Katoen 2/41 Overview 1 Motivation 2 Observe statements 3 Operational semantics 4 Conditional

More information

Spring 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 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 information

Soundness and Completeness of Axiomatic Semantics

Soundness 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 information

A Trajectory-based Strict Semantics for Program Slicing

A Trajectory-based Strict Semantics for Program Slicing A Trajectory-based Strict Semantics for Program Slicing Richard W. Barraclough b David Binkley a Sebastian Danicic b Mark Harman c Robert M. Hierons d Ákos Kiss e Mike Laurence b Lahcen Ouarbya b a Computer

More information

In 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 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 information

Program Verification Using Separation Logic

Program 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 information

ESE601: Hybrid Systems. Introduction to verification

ESE601: Hybrid Systems. Introduction to verification ESE601: Hybrid Systems Introduction to verification Spring 2006 Suggested reading material Papers (R14) - (R16) on the website. The book Model checking by Clarke, Grumberg and Peled. What is verification?

More information

The WHILE Hierarchy of Program Schemes is Infinite

The WHILE Hierarchy of Program Schemes is Infinite The WHILE Hierarchy of Program Schemes is Infinite Can Adam Alayrak and Thomas Noll RWTH Aachen Ahornstr. 55, 52056 Aachen, Germany alayrak@informatik.rwth-aachen.de and noll@informatik.rwth-aachen.de

More information

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready.

CSE 505, Fall 2005, Midterm Examination 8 November Please do not turn the page until everyone is ready. CSE 505, Fall 2005, Midterm Examination 8 November 2005 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

Program verification. 18 October 2017

Program 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 information

Hoare Calculus and Predicate Transformers

Hoare 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 information