Theories of Programming Languages Assignment 5

Size: px
Start display at page:

Download "Theories of Programming Languages Assignment 5"

Transcription

1 Theories of Programming Languages Assignment 5 December 17, Lambda-Calculus (see Fig. 1 for initions of = β, normal order evaluation and eager evaluation). (a) Let Ω = ((λx. x x) (λx. x x)), and M = (λx. λy. x x) Ω. i. Give the normal order evaluation sequence of M. ii. Does the eager evaluation of M terminate? If yes, give the whole evaluation sequence. Otherwise, give the first two steps of the evaluation and briefly explain why it does not terminate. (b) Let A = λx.λy.y(xxy), Θ = A A, and Y = λf.(λx.f(xx))(λx.f(xx)). i. (*) Show that for all F we have Θ F = β F (Θ F ); ii. Show that for all F we have Y F = β F (Y F ). 2. Below is the IMP language we have learned in class. (intexp) e ::= n x -e e+e e-e... where n represents natural numbers (boolexp) b ::= true false e=e e < e e < e... b b b b b... (comm) c ::= x := e skip c ; c if b then c else c while b do c Fill in the preconditions for the following specifications to make them valid. The preconditions should be as weak as possible. Then prove that the completed specifications could be derived from the Hoare-logic rules (see Fig. 2 in the appendix). In each step of your proof, you must show which rule is applied. You only need to select one from (a) and (b) below. (c) is required. (a) {?} while true do skip {true} (b) [? ] while true do skip [true] (c) (*) [? ] while (a > b) do (b := b + 1; y := x y) [y = x a ] 1

2 3. We extend the IMP language above with the following new commands, and get a new language IMP h. Selected rules for the operational semantics are given in the appendix (Fig. 3). (comm) c ::=... x := [e] [e] := e x := cons(e, e) dispose(e) repeat c until b (a) Let s 0 = {x 100, y 110} and h 0 =. Give two different execution sequences for the following command. One leads to a final heap containing a memory cell with value 3, and the other leads to a heap containing a memory cell with value 5. x := cons(3, 5) ; if (x = y) then dispose(y) else dispose(x + 1) (b) Give the operational semantics for the repeat command. (c) (*) We want a new instruction x := sbrk4, which allocates 4 consequtive memory cells with initial value 0. Different from cons, the starting address of the new memory cells will be max(dom(h)) + 1 if h, and 100 otherwise. Give the operational semantics for x := sbrk4. 4. Separation Logic. (a) The following two assertions are not valid (see Fig. 4 for assertion semantics). For each of them, find instantiations of p, q (and r), and the corresponding states in which the assertions are false. i. p r q r (p q) r; ii. (*) (p (p q)) q (b) We use SafeMono(c) and Frame(c) to represent c has safety monotonicity and the frame property, respectively. Their initions are given in the appendix (Fig. 4). i. Give a formal inition of SafeMono(c) using the predicate logic language (i.e. do not use any words of natural languages). You could use Safe(c, (s, h)) to represent c is safe at (s, h). ii. Let c be x := cons(e 1, e 2 ). Prove Frame(c) holds. iii. Is Frame(sbrk4) true? If yes, prove it; otherwise, explain why. Here sbrk4 is the command desribed in Problem 3 above. iv. (*) In the appendix (Fig. 4) we give another version of the frame property, i.e. Frm(c). Let c be x := cons(e 1, e 2 ). Is Frm(c) true? If yes, prove it; otherwise, explain why. 5. Let Γ =, c 0 = (y := [x + 1]), c 0 = (y := [x]), and c 1 = (z := [x]). (a) Fill in the preconditions of the judgment below. i. Γ {?}(c 0 c 1 ){(x m, n) y = n z = m} 2

3 ii. Γ {?}(c 0 c 1 ){(x m, n) y = m z = m} (b) (*) Concurrent separation logic does not allow simultaneous access of the same memory location, even if both access are read operations (like c 0 c 1 above). To support simultaneous read, we introduce fractional permissions e π n in the appendix (Fig. 5). To write a memory cell at location e, we need a full permission e 1 (which can be written as e ). To read, we only need e π for any 0 < π 1. i. Give the separation logic rules for (x := [e]), ([e] := e ) and c 1 c 2. For (x := [e]), assume x is not free in e. ii. Fill in the precondition of the judgment below Γ {?} (c 0 c 1 ) {(x 0.5 m) y = m z = m}. A Auxiliary Definitions (λx.m) N = β M[N/x] (β) M = β M M N = β M N (c1) N = β N M N = β M N (c2) M = β M λx.m = β λx.m (c3) (λx.m) N N M[N/x] (β-n) M n M M N n M N (nc1) (λx.m) (λy.n) E M[(λy.N)/x] (β-e) M E M M N E M N (ec1) N E N (λx.m) N E (λx.m) N (ec2) Figure 1: beta-equivalence, normal order evaluation, and eager evaluation 3

4 {p[e/x]}x := e{p} (as) {p}c 1{q} {q}c 2{r} {p}c 1 ; c 2{r} (sq) {p}skip{p} (sk) {p }c{q } p p q q {p}c{q} (csq) {i b}c{i} {i}while b do c{i b} (whp) [ i b e = x 0 ]c[ i e < x 0 ] i b e 0 (wht) [ i ]while b do c[ i b ] where x 0 is not free in c, e, b and i. {p 1} c {q 1} {p 2} c {q 2} {p 1 p 2} c {q 1 q 2} (disj) Figure 2: Selected Hoare Logic rules for IMP (all the rules for partial correctness except the whp rule could also be used for total correctness) (store) s Var Z (locs) l N (heap) h locs fin Z (state) σ store heap where fin means a set of partial functions whose domains are finite. {l, l + 1} dom(h) = s = s{x l} h = h{l e 1 s, l+1 e 2 s} (x := cons(e 1, e 2 ), (s, h)) (skip, (s, h )) l = e s l dom(h) h = h \ {l} (x := dispose(e), (s, h)) (skip, (s, h )) (c 1, σ) (c 1, σ ) (c 1 ; c 2, σ) (c 1 ; c 2, σ ) (skip ; c, σ) (c, σ) b s = true (if b then c 1 else c 2, (s, h)) (c 1, (s, h)) b s = false (if b then c 1 else c 2, (s, h)) (c 2, (s, h)) (while b do c, σ) (if b then (while b do c) else skip, σ Figure 3: Operational semantics for IMP h (only some selected rules are shown) 4

5 Semantics of separaiton logic assertions: h 1 h 2 = dom(h 1 ) dom(h 2 ) = h 1 h 2 = h 1 h 2 (s, h) = e e iff h = {(l, n)}, where e s = l, and e s = n (s, h) = p 1 p 2 iff there exist h 1, h 2 such that h 1 h 2, h = h 1 h 2, (s, h 1) = p 1, and (s, h 2) = p 2 (s, h) = p q iff for all h, if h h and (s, h ) = p, then (s, h h) = q SafeMono(c) iff for all h, h 0, h 1 and s, if h = h 0 h 1, h 0 h 1, and c is safe at (s, h 0), then c is safe at (s, h). Frame(c) iff for all h, h 0, h 1, s, h and s, if h = h 0 h 1, h 0 h 1, (c, (s, h)) (skip, (s, h )), and c is safe at (s, h 0 ), then there exists h 0 such that (c, (s, h 0 )) (skip, (s, h 0)), h 0 h 1, and h = h 0 h 1. Frm(c) iff for all h 0, h 1, s, h 0 and s, if h 0 h 1, (c, (s, h 0 )) (skip, (s, h 0)), then h 0 h 1 and (c, (s, h 0 h 1 )) (skip, (s, h 0 h 1 )). x not free in e Γ {e n}x := [e]{e x} Γ {e }[e] := e {e e } Γ {p 1 } c 1 {q 1 } Γ {p 2 } c 2 {q 2 } Γ {p 1 p 2 } c 1 c 2 {q 1 q 2 } c 1 (or c 2 ) does not update free variables in p 2 (or p 1 ), q 2 (or q 1 ), and Γ Figure 4: Separation Logic Assertions and Selected Rules (perm) π (0, 1] h 1 h 2 h 1 h 2 (heap) h locs fin Z perm = l (dom(h 1) dom(h 2)), n 1, π 1, n 2, π 2. h 1(l) = (n 1, π 1) h 2(l) = (n 2, π 2) (n 1 =n 2) (π 1+π 2 1) = λl. h 1 (l) l (dom(h 1 ) dom(h 2 )) h 2 (l) l (dom(h 2 ) dom(h 1 )) (n, π) exist π 1, π 2 such that h 1 (l) = (n, π 1 ), h 2 (l) = (n, π 2 ), π = π 1 + π 2, and π (0, 1] unined otherwise (s, h) = e π e iff h = {(l, (n, π))}, where e s = l, and e s = n (s, h) = p 1 p 2 iff there exist h 1, h 2 such that h 1 h 2, h = h 1 h 2, (s, h 1) = p 1, and (s, h 2) = p 2 Figure 5: Fractional Permissions: States and Assertions 5

Lectures on Separation Logic. Lecture 2: Foundations

Lectures 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 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

A Short Introduction to Hoare Logic

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

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering)

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

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

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

More information

Concurrent separation logic and operational semantics

Concurrent separation logic and operational semantics MFPS 2011 Concurrent separation logic and operational semantics Viktor Vafeiadis Max Planck Institute for Software Systems (MPI-SWS), Germany Abstract This paper presents a new soundness proof for concurrent

More information

Separation Logic and the Mashup Isolation Problem

Separation Logic and the Mashup Isolation Problem Separation Logic and the Mashup Isolation Problem Dept. of Computer Science, Stanford University Phd Qualifier Exam Talk Outline 1 Background Hoare Logic Intuition behind Separation Logic 2 The Mashup

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

Universität Augsburg

Universität Augsburg Universität Augsburg Algebraic Separation Logic H.-H. Dang P. Höfner B. Möller Report 2010-06 July 2010 Institut für Informatik D-86135 Augsburg Copyright c H.-H. Dang P. Höfner B. Möller Institut für

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

Program Verification using Separation Logic Lecture 0 : Course Introduction and Assertion Language. Hongseok Yang (Queen Mary, Univ.

Program Verification using Separation Logic Lecture 0 : Course Introduction and Assertion Language. Hongseok Yang (Queen Mary, Univ. Program Verification using Separation Logic Lecture 0 : Course Introduction and Assertion Language Hongseok Yang (Queen Mary, Univ. of London) Dream Automatically verify the memory safety of systems software,

More information

Completeness of Pointer Program Verification by Separation Logic

Completeness of Pointer Program Verification by Separation Logic ISSN 1346-5597 NII Technical Report Completeness of Pointer Program Verification by Separation Logic Makoto Tatsuta, Wei-Ngan Chin, and Mahmudul Faisal Al Ameen NII-2009-013E June 2009 Completeness of

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

Recent developments in concurrent program logics

Recent developments in concurrent program logics Recent developments in concurrent program logics Viktor Vafeiadis University of Cambridge PSPL 2010 Why program logic? Reasoning framework Capture common reasoning principles Reduce accidental proof complexity

More information

A Brief History of Shared memory C M U

A Brief History of Shared memory C M U A Brief History of Shared memory S t e p h e n B r o o k e s C M U 1 Outline Revisionist history Rational reconstruction of early models Evolution of recent models A unifying framework Fault-detecting

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

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

Separation Logic and the Mashup Isolation Problem

Separation Logic and the Mashup Isolation Problem Separation Logic and the Mashup Isolation Problem Ankur Taly Computer Science Department, Stanford University Abstract. This work was done as part of my PhD qualifier exam. My qualifier exam problem was

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural

More information

Axiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs

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

Collecting garbage concurrently (but correctly)

Collecting garbage concurrently (but correctly) Collecting garbage concurrently (but correctly) Kamal Lodaya The Institute of Mathematical Sciences, Chennai Joint work with Kalpesh Kapoor (IIT, Guwahati) and Uday Reddy (U. Birmingham) 1 First order

More information

Local Rely-Guarantee Reasoning

Local Rely-Guarantee Reasoning Technical Report TTIC-TR-2008-1 October 2008 Local Rely-Guarantee Reasoning Xinyu Feng Toyota Technological Institute at Chicago feng@tti-c.org ABSTRACT Rely-Guarantee reasoning is a well-known method

More information

Separation Logic and Graphical Models

Separation Logic and Graphical Models Separation Logic and Graphical Models John Wickerson and Tony Hoare Semantics Lunch, 25th October 2010 1 Trace composition Problem: Composition is non-deterministic. 2 Trace composition Problem: Composition

More information

CS558 Programming Languages

CS558 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 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 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

Chapter 3. Specifications. 3.1 Hoare Triples. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011

Chapter 3. Specifications. 3.1 Hoare Triples. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Chapter 3 An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Specifications From assertions, we move on to specifications, which describe the behavior of commands. In this chapter,

More information

Views: Compositional Reasoning for Concurrent Programs

Views: Compositional Reasoning for Concurrent Programs Views: Compositional Reasoning for Concurrent Programs Thomas Dinsdale-Young Imperial College td202@doc.ic.ac.uk Lars Birkedal IT University of Copenhagen birkedal@itu.dk Philippa Gardner Imperial College

More information

Programming Languages and Compilers (CS 421)

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

Local Rely-Guarantee Reasoning

Local Rely-Guarantee Reasoning Local Rely-Guarantee Reasoning Xinyu Feng Toyota Technological Institute at Chicago Chicago, IL 60637, U.S.A. feng@tti-c.org Abstract Rely-Guarantee reasoning is a well-known method for verification of

More information

Shared-Variable Concurrency

Shared-Variable Concurrency University of Science and Technology of China 12/17/2013 Parallel Composition (or Concurrency Composition) Syntax: (comm) c ::=... c 0 c 1... Note we allow nested parallel composition, e.g., (c 0 ; (c

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=

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

Problem Sheet 1: Axiomatic Semantics

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

Relational Parametricity and Separation Logic. Hongseok Yang, Queen Mary, Univ. of London Lars Birkedal, IT Univ. of Copenhagen

Relational Parametricity and Separation Logic. Hongseok Yang, Queen Mary, Univ. of London Lars Birkedal, IT Univ. of Copenhagen Relational Parametricity and Separation Logic Hongseok Yang, Queen Mary, Univ. of London Lars Birkedal, IT Univ. of Copenhagen Challenge Develop a theory of data abstraction for pointer programs. When

More information

AN INTRODUCTION TO SEPARATION LOGIC. 2. Assertions

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

Separation and Information Hiding

Separation and Information Hiding Separation and Information Hiding PETER W. O HEARN and HONGSEOK YANG Queen Mary, University of London and JOHN C. REYNOLDS Carnegie Mellon University 11 We investigate proof rules for information hiding,

More information

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC)

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC) University of Science and Technology of China (USTC) 09/26/2011 Overview Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic?

More information

A semantics for concurrent separation logic

A semantics for concurrent separation logic Theoretical Computer Science 375 (2007) 227 270 www.elsevier.com/locate/tcs A semantics for concurrent separation logic Stephen Brookes School of Computer Science, Carnegie Mellon University, 5000 Forbes

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

Predicate Logic. x. x + 0 = x. Predicate logic over integer expressions: a language of logical assertions, for example. Why discuss predicate logic?

Predicate Logic. x. x + 0 = x. Predicate logic over integer expressions: a language of logical assertions, for example. Why discuss predicate logic? Predicate Logic Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic? It is an example of a simple language It has simple denotational

More information

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F:

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F: CS 6371 Advanced Programming Languages Sample Spring 2018 Final Exam This sample final exam is LONGER than a real final exam (to give you more practice problems) and has a medium difficulty level. You

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

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

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready.

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready. CSE 505, Fall 2008, Midterm Examination 29 October 2008 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

COP4020 Programming Languages. Introduction to Axiomatic Semantics Prof. Robert van Engelen

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

Automata-Theoretic Model Checking of Reactive Systems

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

Predicate Logic. Xinyu Feng 11/20/2013. University of Science and Technology of China (USTC)

Predicate Logic. Xinyu Feng 11/20/2013. University of Science and Technology of China (USTC) University of Science and Technology of China (USTC) 11/20/2013 Overview Predicate logic over integer expressions: a language of logical assertions, for example x. x + 0 = x Why discuss predicate logic?

More information

Hoare Examples & Proof Theory. COS 441 Slides 11

Hoare Examples & Proof Theory. COS 441 Slides 11 Hoare Examples & Proof Theory COS 441 Slides 11 The last several lectures: Agenda Denotational semantics of formulae in Haskell Reasoning using Hoare Logic This lecture: Exercises A further introduction

More information

Trace semantics: towards a unification of parallel paradigms Stephen Brookes. Department of Computer Science Carnegie Mellon University

Trace semantics: towards a unification of parallel paradigms Stephen Brookes. Department of Computer Science Carnegie Mellon University Trace semantics: towards a unification of parallel paradigms Stephen Brookes Department of Computer Science Carnegie Mellon University MFCSIT 2002 1 PARALLEL PARADIGMS State-based Shared-memory global

More information

Program Analysis and Verification

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

Floyd-Hoare Style Program Verification

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

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

Proofs of Correctness: Introduction to Axiomatic Verification

Proofs 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 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

CIS (More Propositional Calculus - 6 points)

CIS (More Propositional Calculus - 6 points) 1 CIS6333 Homework 1 (due Friday, February 1) 1. (Propositional Calculus - 10 points) --------------------------------------- Let P, Q, R range over state predicates of some program. Prove or disprove

More information

States and Actions: An Automata-theoretic Model of Objects

States and Actions: An Automata-theoretic Model of Objects States and Actions: An Automata-theoretic Model of Objects Uday S. Reddy 1 Brian P. Dunphy 2 1 University of Birmingham 2 University of Illinois at Urbana-Champaign Portland, Oct 2011 Uday S. Reddy (Univ

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

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

The Expressivity of Universal Timed CCP: Undecidability of Monadic FLTL and Closure Operators for Security

The Expressivity of Universal Timed CCP: Undecidability of Monadic FLTL and Closure Operators for Security The Expressivity of Universal Timed CCP: Undecidability of Monadic FLTL and Closure Operators for Security Carlos Olarte and Frank D. Valencia INRIA /CNRS and LIX, Ecole Polytechnique Motivation Concurrent

More information

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

More information

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies Flow Interfaces Compositional Abstractions of Concurrent Data Structures Siddharth Krishna, Dennis Shasha, and Thomas Wies Background Verifying programs, separation logic, inductive predicates Verifying

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

What 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 )

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

Local Reasoning for Storable Locks and Threads

Local Reasoning for Storable Locks and Threads Local Reasoning for Storable Locks and Threads Alexey Gotsman Josh Berdine Byron Cook Noam Rinetzky Mooly Sagiv University of Cambridge Microsoft Research Tel-Aviv University April, revised September Technical

More information

A Monadic Analysis of Information Flow Security with Mutable State

A Monadic Analysis of Information Flow Security with Mutable State A Monadic Analysis of Information Flow Security with Mutable State Karl Crary Aleksey Kliger Frank Pfenning July 2003 CMU-CS-03-164 School of Computer Science Carnegie Mellon University Pittsburgh, PA

More information

Foundations of Computation

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

Lecture 2: Axiomatic semantics

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

Reasoning about Optimistic Concurrency Using a Program Logic for History (Extended Version)

Reasoning about Optimistic Concurrency Using a Program Logic for History (Extended Version) Reasoning about Optimistic Concurrency Using a Program Logic for History (Extended Version) Ming Fu 1, Yong Li 1, Xinyu Feng 1,2, Zhong Shao 3, and Yu Zhang 1 1 University of Science and Technology of

More information

Computability and Complexity Results for a Spatial Assertion Language for Data Structures

Computability and Complexity Results for a Spatial Assertion Language for Data Structures Computability and Complexity Results for a Spatial Assertion Language for Data Structures Cristiano Calcagno 12, Hongseok Yang 3, and Peter W. O Hearn 1 1 Queen Mary, University of London 2 DISI, University

More information

Computer Science and State Machines

Computer Science and State Machines Computer Science and State Machines Leslie Lamport 8 June 2008 minor correction on 13 January 2018 Contribution to a Festschrift honoring Willem-Paul de Roever on his retirement. Computation Computer science

More information

Probabilistic Program Analysis

Probabilistic Program Analysis Probabilistic Program Analysis Data Flow Analysis and Regression Alessandra Di Pierro University of Verona, Italy alessandra.dipierro@univr.it Herbert Wiklicky Imperial College London, UK herbert@doc.ic.ac.uk

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

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

Structuring the verification of heap-manipulating programs

Structuring the verification of heap-manipulating programs Structuring the verification of heap-manipulating programs Aleksandar Nanevski (IMDEA Madrid) Viktor Vafeiadis (MSR / Univ. of Cambridge) Josh Berdine (MSR Cambridge) Hoare/Separation Logic Hoare logic

More information

micromodels of software declarative modelling and analysis with Alloy lecture 4: a case study MIT Lab for Computer Science Marktoberdorf, August 2002

micromodels of software declarative modelling and analysis with Alloy lecture 4: a case study MIT Lab for Computer Science Marktoberdorf, August 2002 micromodels of software declarative modelling and analysis with Alloy lecture 4: a case study Daniel Jackson MIT Lab for Computer Science Marktoberdorf, August 2002 on research strategy 2 on research strategy

More information

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

From Separation Logic to Systems Software

From Separation Logic to Systems Software From Separation Logic to Systems Software Peter O Hearn, Queen Mary Based on work of the SpaceInvader team: Cristiano Calcagno, Dino Distefano, Hongseok Yang, and me Special thanks to our SLAyer colleagues

More information

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

λ S : A Lambda Calculus with Side-effects

λ S : A Lambda Calculus with Side-effects L14-1 λ S : A Lambda Calculus with Side-effects delivered by Jacob Schwartz Laboratory for Computer Science M.I.T. Lecture 14 M-Structures and Barriers L14-2 Some problems cannot be expressed functionally

More information

Lecture Notes: Program Analysis Correctness

Lecture Notes: Program Analysis Correctness Lecture Notes: Program Analysis Correctness 15-819O: Program Analysis Jonathan Aldrich jonathan.aldrich@cs.cmu.edu Lecture 5 1 Termination As we think about the correctness of program analysis, let us

More information

Verifying Concurrent Memory Reclamation Algorithms with Grace

Verifying Concurrent Memory Reclamation Algorithms with Grace Verifying Concurrent Memory Reclamation Algorithms with Grace Alexey Gotsman, Noam Rinetzky, and Hongseok Yang 1 IMDEA Software Institute 2 Tel-Aviv University 3 University of Oxford Abstract. Memory management

More information

The Assignment Axiom (Hoare)

The 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 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

First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods

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

An Introduction to Logical Relations Proving Program Properties Using Logical Relations

An Introduction to Logical Relations Proving Program Properties Using Logical Relations An Introduction to Logical Relations Proving Program Properties Using Logical Relations Lau Skorstengaard lask@cs.au.dk July 27, 2018 Contents 1 Introduction 2 1.1 Simply Typed Lambda Calculus....................

More information

Marie Farrell Supervisors: Dr Rosemary Monahan & Dr James Power Principles of Programming Research Group

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

Abstraction and Refinement for Local Reasoning

Abstraction and Refinement for Local Reasoning Under consideration for publication in Math. Struct. in Comp. Science Abstraction and Refinement for Local Reasoning Thomas Dinsdale-Young, Philippa Gardner and Mark Wheelhouse Department of Computing,

More information

Verification and Validation

Verification 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 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

Hoare Logic: Reasoning About Imperative Programs

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

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 CakeML Has: references, modules, datatypes, exceptions, a FFI,... Doesn t have:

More information

Introduction to Permission-Based Program Logics Part II Concurrent Programs

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

Technical Report. Deny-guarantee reasoning. Mike Dodds, Xinyu Feng, Matthew Parkinson, Viktor Vafeiadis. Number 736. January Computer Laboratory

Technical Report. Deny-guarantee reasoning. Mike Dodds, Xinyu Feng, Matthew Parkinson, Viktor Vafeiadis. Number 736. January Computer Laboratory Technical Report UCAM-CL-TR-736 ISSN 1476-2986 Number 736 Computer Laboratory Deny-guarantee reasoning Mike Dodds, Xinyu Feng, Matthew Parkinson, Viktor Vafeiadis January 2009 15 JJ Thomson Avenue Cambridge

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

CS477 Formal Software Dev Methods

CS477 Formal Software Dev Methods 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 by Mahesh Vishwanathan, and by Gul Agha

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

Compositional Verification of Termination-Preserving Refinement of Concurrent Programs (Technical Report)

Compositional Verification of Termination-Preserving Refinement of Concurrent Programs (Technical Report) Compositional Verification of Termination-Preserving Refinement of Concurrent Programs (Technical Report) Hongjin Liang 1, Xinyu Feng 1, and Zhong Shao 2 1 University of Science and Technology of China

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