Semantics of Imperative Objects

Size: px
Start display at page:

Download "Semantics of Imperative Objects"

Transcription

1 Semantics of Imperative Objects Catalin Hritcu Supervisor: Jan Schwinghammer Responsible: Prof. Gert Smolka Programming Systems Lab Saarland University, Saarbrücken November

2 Overview Imperative Object Calculus Operational Semantics Syntactic Types Axiomatic Semantics Denotational Semantics Step-indexed Semantics Possible Extensions 2

3 Object Calculi Object-oriented programming languages Idealized models Rigorously defined semantics Simple - only one primitive: objects Expressive can encode: classes and inheritance but also functions (the lambda calculus) 3

4 Object Calculi Object-based (not class-based) In practice: JavaScript, Self, etc. Strongly-typed A Theory of Objects [Abadi & Cardelli 96] We study the imperative object calculus [Abadi & Leino, 04] 4

5 Imperative Object Calculus Syntax a, b ::= x variable let x = a in b variable binding [f i = x i, m j = ς(y j )b j ] i I,j J object construction clone x object cloning x.f field selection x.f := y field update x.m method call true false booleans if x then a else b conditional 0 succ x pred x numbers More syntactic sugar used in examples 5

6 Example Programs Factorial [fac = ς(y)λn.if n = 0 then 1 else n y.fac(n 1)] Euclid s gcd algorithm [gcd = ς(y)λx.λz.if x < z then y.gcd x (z x) else if z < x then y.gcd (x z) z else x] 6

7 Operational Semantics Abstract machine Small-step: evaluation = Reduction Relation: Config Config Configurations: σ, a Config = Store LProg (Red-Let1) (Red-Let2) σ, a σ, a σ, let x = a in b σ, let x = a in b σ, let x = v in b σ, b[x v] (Red-If-True) σ, if true then a else b σ, a (Red-If-False) σ, if false then a else b σ, b 7

8 Operational Semantics (Rel-Obj) (Red-Clone) (Rel-Sel) (Red-Inv) (Red-Upd) l dom σ o = [f i = v i, m j = ς(y j )b j ] i I,j J σ, [f i = v i, m j = ς(y j )b j ] i I,j J σ[l o], l l dom σ σ l = o σ, clone l σ[l o], l σ l f = v σ, l.f σ, v σ l m = ς(y)b σ, l.m σ, b[y l] σ l f σ = σ[l (σ l)[f v]] σ, l.f := v σ, l 8

9 Example Reduction, let y = [m = ς(x)x.m] in y.m l = [m = ς(x)x.m], let y = l in y.m l = [m = ς(x)x.m], l.m l = [m = ς(x)x.m], l.m... Nonterminating evaluation 9

10 Types of Objects Simple types: T ::= Bool Nat [f i : T i, m j : S j ] i I,j J Typing relation: (Γ a : T ) : (Var fin Ty) Prog Ty Types are purely syntactical Subtyping (fields invariant, methods covariant) Bool Bool Nat Nat j J : S j R j I I J J [f i : T i, m j : S j ] i I,j J [f i : T i, m j : R j ] i I,j J 10

11 Typing Rules (T-Sub) T T Γ a : T Γ a : T (T-True) Γ true : Bool (T-Var) Γ x = T Γ x : T (T-False) Γ false : Bool (T-If) Γ x : Bool Γ a : T Γ b : T Γ if x then a else b : T (T-Let) Γ a : S Γ, x : S b : T Γ let x = a in b : T 11

12 Typing Rules (T-Obj) Γ x i : T i Γ, y j : T b j : S j Γ [f i = x i, m j = ς(y j )b j ] i I,j J : T where T = [f i : T i, m j : S j ] i I,j J (T-Clone) Γ x : T T = [f i : T i, m j : S j ] i I,j J Γ clone x : T (T-Upd) Γ x : [f : T ] Γ x.f := y : [] Γ y : T (T-Sel) Γ x : [f : T ] Γ x.f : T (T-Inv) Γ x : [m : T ] Γ x.m : T 12

13 Program logic Deduction system for program correctness E.g. Hoare logic [Floyd, 67] [Hoare, 69] {p b}s 1 {q} {p b}s 2 {q} {p}if b then S 1 else S 2 {q} Widely used in program verification (E.g. Verisoft) 13

14 The Logic of Objects [Abadi & Leino, 97] [Abadi & Leino, 04] Specifications generalize types A refinement of the type system (undecidable) Attempt to mechanize [Hofmann & Tang, 02] Γ a : T E a : A :: ϕ φ is a first-order logic formula (pre + post) Sub-specification generalizes subtyping Subsumption corresponds to weakening 14

15 The Logic of Objects (S-Obj) E x i : A i :: Res(x i ) E, y j : A b j : B j :: ϕ j E [f i = x i, m j = ς(y j )b j ] i I,j J : A :: ϕ where A = [f i : A i, m j : ς(y i )B j :: ϕ j ] i I,j J and ϕ = alloc(r) ` alloc(r) i I σ(r, f i) = x i ( z. z r ( alloc(z) ` alloc(z) w. `σ(z, w) σ(z, w))) and Res(e) r = e ( x. w. alloc(x) ` alloc(x) Specifications not tight (as in separation logic) `σ(x, w) = σ(x, w)) Soundness hard to prove [Reus & Schwinghammer, 06] 15

16 Higher-order Store Executable code can be stored General references in ML Pointers to functions in C Callbacks in Java Recursion by tying a knot in the store Example (factorial through a field) let x = [f = ς(y)λn.n] in let z = [f = x, fac = ς(y)λn.if n = 0 then 1 z.f := z else n y.f.fac(n 1)] in 16

17 Higher-order Store Imperative object calculus Operational Semantics Dynamically allocated, higher-order store Challenge: finding good semantic models Reasoning about the behavior of programs Program correctness (using a program logic) Useful for proving safety(progress&preservation) Not suitable as the basis for a program logic [Benton, 05] [Reus & Schwinghammer, 06] 17

18 Denotational Semantics The meaning of a program is a mathematical object E.g. denotation of a lambda abstraction = function Higher-order store Solving recursive domain equations Dynamic Allocation Possible-world model = category of functors over CPOs Domain theory, category theory, order theory More abstract - reasoning about program behavior 18

19 Denotational Semantics For the imperative object calculus Complex [Reus & Schwinghammer, 06] Separates logical validity from derivability Specification = predicate on programs Current models are still not abstract enough Many natural equivalences do not hold 19

20 Step-indexed Semantics Foundational proof-carrying code by Appel et al. Simpler machine-checkable proofs Type soundness For (very) low-level languages Lambda calculus Recursive types [Appel & McAllester, 01] General references and polymorphism [Ahmed et al., 03] 20

21 Step-indexed Semantics Based on a small-step operational semantics Type = set of indexed values e : k T if e behaves like an element of T for k steps Semantic approach to typing Types are predicates Type constructors functions Simpler than a cpo-based denotational semantics Used as a model for a program logic [Benton 05] 21

22 What We Are Working On Main goal Develop a step-indexed semantics for the imperative object calculus with simple object types Proving soundness of the typing rules Extensions Enriching the type system with: Subtyping Recursive object types [Reus & Streicher, 02] [Schwinghammer, 06] Impredicative polymorphism 22

23 More Possible Extensions Defining a program logic extending types Construct a sound deduction system FOL assertions about the store [Benton, 05] [Abadi & Leino, 04] [Podelski & Schaefer 05] Dependent types+shallow embedding to HOL - e.g. Hoare Type Theory [Nanevski et al., 06] Local and modular reasoning Separation Logic [Reynolds, 02] ADTs - Idealized ML [Krishnaswami et al., 06] 23

24 Thank you! 24

25 References [1] Martín Abadi and Luca Cardelli. A Theory of Objects. Springer, [2] Martín Abadi and K. Rustan M. Leino. A logic of object-oriented programs. In Michel Bidoit and Max Dauchet, editors, Proceedings of Theory and Practice of Software Development, volume 1214 of Lecture Notes in Computer Science, pages Springer, [3] Martín Abadi and K. Rustan M. Leino. A logic of object-oriented programs. In Nachum Dershowitz, editor, Verification: Theory and Practice. Essays Dedicated to Zohar Manna on the Occasion of his 64th Birthday, Lecture Notes in Computer Science, pages Springer, [4] Amal J. Ahmed, Andrew W. Appel, and Roberto Virga. An indexed model of impredicative polymorphism and mutable references. Princeton University, January [5] Amal J. Ahmed, Matthew Fluet, and Greg Morrisett. A step-indexed model of substructural state. In Olivier Danvy and Benjamin C. Pierce, editors, International Conference on Functional Programming (ICFP 05), pages ACM Press, [6] Andrew W. Appel and David McAllester. An indexed model of recursive types for foundational proof-carrying code. ACM Transactions on Programming Languages and Systems, 23(5): , September [7] Nick Benton. A typed, compositional logic for a stack-based abstract machine. In Zoltan Esik, editor, Asian Symposium on Programming Languages and Systems APLAS 05, volume 3780 of Lecture Notes in Computer Science, pages Springer, [8] Nick Benton. Abstracting allocation: the new new thing. In Computer Science Logic, volume 4207 of Lecture Notes in Computer Science, pages Springer, [9] Robert W. Floyd. Assigning meanings to programs. In Jacob T. Schwartz, editor, Proceedings of Mathematical Aspects of Computer Science, volume 19 of Proceedings of Symposia in Applied Mathematics, pages American Mathematical Society, April

26 References [10] C. A. R. Hoare. An Axiomatic Basis of Computer Programming. Communications of the ACM, 12: , [11] Neelakantan R. Krishnaswami, Lars Birkedal, Jonathan Aldrich, and John C. Reynolds. Idealized ML and its separation logic. Submitted, [12] Aleksandar Nanevski, Amal Ahmed, Greg Morrisett, and Lars Birkedal. Abstract predicates and mutable adts in hoare type theory. Technical Report TR-14-06, Harvard University, [13] Andreas Podelski and Ina Schaefer. Local reasoning for termination. In Workshop on Verification of Concurrent Systems with Dynamic Allocated Heap (COSMICAH05), Lisabon, July [14] Bernhard Reus and Jan Schwinghammer. Denotational semantics for a program logic of objects. Mathematical Structures in Computer Science, 16(2): , April [15] Bernhard Reus and Thomas Streicher. Semantics and logic of object calculi. In Proceedings of 17th Annual IEEE Symposium Logic in Computer Science, pages IEEE Computer Society Press, [16] John C. Reynolds. Separation logic: A logic for shared mutable data structures. In Proceedings of the 17th IEEE Symposium on Logic in Computer Science, pages IEEE Computer Society, [17] Jan Schwinghammer. Reasoning about Denotations of Recursive Objects. PhD thesis, Department of Informatics, University of Sussex, [18] Francis Tang and Martin Hofmann. Generation of verification conditions for Abadi and Leino s logic of objects. Presented at 9th International Workshop on Foundations of Object-Oriented Languages, January

Semantics of Imperative Objects

Semantics of Imperative Objects Semantics of Imperative Objects Catalin Hritcu Supervisor: Jan Schwinghammer Responsible: Prof. Gert Smolka Programming Systems Lab Saarland University, Saarbrücken November 2006 1 Overview Imperative

More information

A CRASH COURSE IN SEMANTICS

A CRASH COURSE IN SEMANTICS LAST TIME Recdef More induction NICTA Advanced Course Well founded orders Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Well founded recursion Calculations: also/finally {P}... {Q}

More information

Logical Relations. Amal Ahmed. Northeastern University. OPLSS Lecture 5, June 26, 2015

Logical Relations. Amal Ahmed. Northeastern University. OPLSS Lecture 5, June 26, 2015 Logical Relations Amal Ahmed Northeastern University OPLSS Lecture 5, June 26, 2015 Unary Logical Relations or: Logical Predicates --- can be used to prove: strong normalization type safety (high-level

More information

Gang Tan, Boston College Andrew W. Appel, Princeton University

Gang Tan, Boston College Andrew W. Appel, Princeton University A Compositional Logic for Control Flow Gang Tan, Boston College Andrew W. Appel, Princeton University Jan 8, 2006 1 Mobile Code Security Protect trusted system against untrusted code cyberspace ce program

More information

Com S 541. Programming Languages I

Com S 541. Programming Languages I Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR

More information

Reasoning about modules: data refinement and simulation

Reasoning about modules: data refinement and simulation Reasoning about modules: data refinement and simulation David Naumann naumann@cs.stevens-tech.edu Stevens Institute of Technology Naumann - POPL 02 Java Verification Workshop p.1/17 Objectives of talk

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines A Typed Calculus Supporting Shallow Embeddings of Abstract Machines Aaron Bohannon Zena M. Ariola Amr Sabry April 23, 2005 1 Overview The goal of this work is to draw a formal connection between steps

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

Application: Programming Language Semantics

Application: Programming Language Semantics Chapter 8 Application: Programming Language Semantics Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 527 Introduction to Programming Language Semantics Programming Language

More information

Chapter 1. Introduction

Chapter 1. Introduction 1 Chapter 1 Introduction An exciting development of the 21st century is that the 20th-century vision of mechanized program verification is finally becoming practical, thanks to 30 years of advances in

More information

Official Survey. Cunning Plan: Focus On Objects. The Need for a Calculus. Object Calculi Summary. Why Not Use λ-calculus for OO?

Official Survey. Cunning Plan: Focus On Objects. The Need for a Calculus. Object Calculi Summary. Why Not Use λ-calculus for OO? Modeling and Understanding Object-Oriented Oriented Programming Official Survey Please fill out the Toolkit course survey 40142 CS 655-1 Apr-21-2006 Midnight May-04-2006 9am Why not do it this evening?

More information

Lecture 5 - Axiomatic semantics

Lecture 5 - Axiomatic semantics Program Verification March 2014 Lecture 5 - Axiomatic semantics Lecturer: Noam Rinetzky Scribes by: Nir Hemed 1.1 Axiomatic semantics The development of the theory is contributed to Robert Floyd, C.A.R

More information

Inductive Proof Outlines for Multithreaded Java with Exceptions

Inductive Proof Outlines for Multithreaded Java with Exceptions Inductive Proof Outlines for Multithreaded Java with Exceptions Extended Abstract 30. April, 2004 Erika Ábrahám1, Frank S. de Boer 2, Willem-Paul de Roever 1, and Martin Steffen 1 1 Christian-Albrechts-University

More information

The Essence of Compiling with Continuations

The Essence of Compiling with Continuations RETROSPECTIVE: The Essence of Compiling with Continuations Cormac Flanagan Amr Sabry Bruce F. Duba Matthias Felleisen Systems Research Center Compaq cormac.flanagan@compaq.com Dept. of Computer Science

More information

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England The Formal Semantics of Programming Languages An Introduction Glynn Winskel The MIT Press Cambridge, Massachusetts London, England Series foreword Preface xiii xv 1 Basic set theory 1 1.1 Logical notation

More information

Extracting the Range of cps from Affine Typing

Extracting the Range of cps from Affine Typing Extracting the Range of cps from Affine Typing Extended Abstract Josh Berdine, Peter W. O Hearn Queen Mary, University of London {berdine, ohearn}@dcs.qmul.ac.uk Hayo Thielecke The University of Birmingham

More information

Second-Order Type Systems

Second-Order Type Systems #1 Second-Order Type Systems Homework 5 Summary Student : 37.9704 Student : 44.4466 ORIGINAL : 50.2442 Student : 50.8275 Student : 50.8633 Student : 50.9181 Student : 52.1347 Student : 52.1633 Student

More information

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers.

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. Semantics The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers. The semantics of a programming language assigns a precise

More information

Type Systems. Today. 1. Organizational Matters. 1. Organizational Matters. Lecture 1 Oct. 20th, 2004 Sebastian Maneth. 1. Organizational Matters

Type Systems. Today. 1. Organizational Matters. 1. Organizational Matters. Lecture 1 Oct. 20th, 2004 Sebastian Maneth. 1. Organizational Matters Today Type Systems 1. Organizational Matters 2. What is this course about? 3. Where do types come from? 4. Def. of the small language Expr. Its syntax and semantics. Lecture 1 Oct. 20th, 2004 Sebastian

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

Contents. Chapter 1 SPECIFYING SYNTAX 1

Contents. Chapter 1 SPECIFYING SYNTAX 1 Contents Chapter 1 SPECIFYING SYNTAX 1 1.1 GRAMMARS AND BNF 2 Context-Free Grammars 4 Context-Sensitive Grammars 8 Exercises 8 1.2 THE PROGRAMMING LANGUAGE WREN 10 Ambiguity 12 Context Constraints in Wren

More information

Capsules and Separation

Capsules and Separation Capsules and Separation Jean-Baptiste Jeannin Computer Science Department Cornell University Ithaca, NY 14853-7501, USA Dexter Kozen Computer Science Department Cornell University Ithaca, NY 14853-7501,

More information

Lambda Calculi With Polymorphism

Lambda Calculi With Polymorphism Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from x = 1 [Järvi], with permission of the original author, by copy & let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in...

Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

A Partial Correctness Proof for Programs with Decided Specifications

A Partial Correctness Proof for Programs with Decided Specifications Applied Mathematics & Information Sciences 1(2)(2007), 195-202 An International Journal c 2007 Dixie W Publishing Corporation, U. S. A. A Partial Correctness Proof for Programs with Decided Specifications

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

More information

Grad PL vs. The World

Grad PL vs. The World Grad PL vs. The World #1 Grad PL Conclusions You are now equipped to read the most influential papers in PL. You can also recognize PL concepts and will know what to do when they come up in your research.

More information

Proof Pearl: The Termination Analysis of Terminator

Proof Pearl: The Termination Analysis of Terminator Proof Pearl: The Termination Analysis of Terminator Joe Hurd Computing Laboratory Oxford University joe.hurd@comlab.ox.ac.uk Abstract. Terminator is a static analysis tool developed by Microsoft Research

More information

Simply-Typed Lambda Calculus

Simply-Typed Lambda Calculus #1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 CS 565: Programming Languages Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 Administrivia Who am I? Course web page http://www.cs.purdue.edu/homes/peugster/cs565spring08/ Office hours By appointment Main

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Lecture slides & distribution files:

Lecture slides & distribution files: Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type

More information

Hoare triples. Floyd-Hoare Logic, Separation Logic

Hoare triples. Floyd-Hoare Logic, Separation Logic Hoare triples Floyd-Hoare Logic, Separation Logic 1. Floyd-Hoare Logic 1969 Reasoning about control Hoare triples {A} p {B} a Hoare triple partial correctness: if the initial state satisfies assertion

More information

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242 Spring 2013 Foundations Yu Zhang Acknowledgement: modified from Stanford CS242 https://courseware.stanford.edu/pg/courses/317431/ Course web site: http://staff.ustc.edu.cn/~yuzhang/fpl Reading Concepts

More information

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture

Reminder of the last lecture. Aliasing Issues: Call by reference, Pointer programs. Introducing Aliasing Issues. Home Work from previous lecture Reminder of the last lecture Aliasing Issues: Call by reference, Pointer programs Claude Marché Cours MPRI 2-36-1 Preuve de Programme 18 janvier 2017 Additional features of the specification language Abstract

More information

Proving the Correctness of Distributed Algorithms using TLA

Proving the Correctness of Distributed Algorithms using TLA Proving the Correctness of Distributed Algorithms using TLA Khushboo Kanjani, khush@cs.tamu.edu, Texas A & M University 11 May 2007 Abstract This work is a summary of the Temporal Logic of Actions(TLA)

More information

HOARE TYPE THEORY: DEPENDENT TYPES FOR STATE

HOARE TYPE THEORY: DEPENDENT TYPES FOR STATE HOARE TYPE THEORY: DEPENDENT TYPES FOR STATE LECTURE AND NOTES BY JAMES T. PERCONTI MATERIAL TAKEN FROM WORK BY NANEVSKI ET AL. In this lecture, we ll discuss Hoare Type Theory, a powerful system that

More information

Polymorphism. Lecture 19 CS 565 4/17/08

Polymorphism. Lecture 19 CS 565 4/17/08 Polymorphism Lecture 19 CS 565 4/17/08 The Limitations of F 1 (simply-typed λ- calculus) In F 1 each function works exactly for one type Example: the identity function id = λx:τ. x : τ τ We need to write

More information

Gradual Typing with Union and Intersection Types

Gradual Typing with Union and Intersection Types Gradual Typing with Union and Intersection Types Giuseppe Castagna, Victor Lanvin ICFP 17 September 6, 2017 1 / 14 Outline 1 Motivating Example 2 Types and Subtyping 3 Function Types and Operators 4 Conclusion

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

Lectures 20, 21: Axiomatic Semantics

Lectures 20, 21: Axiomatic Semantics Lectures 20, 21: Axiomatic Semantics Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Based on slides by George Necula Pratikakis (CSD) Axiomatic Semantics

More information

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs? Part II. Hoare Logic and Program Verification Part II. Hoare Logic and Program Verification Dilian Gurov Props: Models: Specs: Method: Tool: safety of data manipulation source code logic assertions Hoare

More information

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics There is no single widely acceptable notation or formalism for describing semantics Operational Describe the meaning of a program by executing its statements on a machine, either simulated or actual. The

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Hoare logic. A proof system for separation logic. Introduction. Separation logic Introduction Hoare logic Lecture 6: Examples in separation logic In the previous lecture, we saw how reasoning about pointers in Hoare logic was problematic, which motivated introducing separation logic.

More information

Lambda Calculi With Polymorphism

Lambda Calculi With Polymorphism Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Axiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof

Axiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof Lecture 18: Axiomatic Semantics & Type Safety CSCI 131 Fall, 2011 Kim Bruce Axiomatic Rules Assignment axiom: - {P [expression / id]} id := expression {P} - Ex: {a+47 > 0} x := a+47 {x > 0} - {x > 1} x

More information

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going?

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going? Types for References, Exceptions and Continuations Annoucements How s the midterm going? Meeting 21, CSCI 5535, Spring 2009 2 One-Slide Summary Review of Subtyping If τ is a subtype of σ then any expression

More information

Lambda Calculus.

Lambda Calculus. Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto, Stephen A. Edwards) Benjamin Pierce Types and Programming Languages http://www.cs.cornell.edu/courses/cs3110/2008fa/recitations/rec26.html

More information

Lecture 4. Towards a Verifying Compiler: Data Abstraction

Lecture 4. Towards a Verifying Compiler: Data Abstraction Lecture 4 Towards a Verifying Compiler: Data Abstraction W olfram Schulte Microsoft Research Formal Methods 2006 Purity, Model fields, Inconsistency Joint work with Rustan Leino, Mike Barnett, Manuel Fähndrich,

More information

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Brigitte Pientka and Joshua Dunfield McGill University, Montréal, Canada {bpientka,joshua}@cs.mcgill.ca Abstract.

More information

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA Thunks (continued) Olivier Danvy, John Hatcli Department of Computing and Information Sciences Kansas State University Manhattan, Kansas 66506, USA e-mail: (danvy, hatcli)@cis.ksu.edu Abstract: Call-by-name

More information

Programming Proofs and Proving Programs. Nick Benton Microsoft Research, Cambridge

Programming Proofs and Proving Programs. Nick Benton Microsoft Research, Cambridge Programming Proofs and Proving Programs Nick Benton Microsoft Research, Cambridge Coffee is does Greek 1. To draw a straight line from any point to any point. 2. To produce a finite straight line continuously

More information

Computing Fundamentals 2 Introduction to CafeOBJ

Computing Fundamentals 2 Introduction to CafeOBJ Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal Faria, Prof. Heinrich Hußmann. See notes on slides

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

From proposition to program

From proposition to program From proposition to program Embedding the refinement calculus in Coq Wouter Swierstra 1 and Joao Alpuim 2 1 Universiteit Utrecht w.s.swierstra@uu.nl 2 RiskCo joao.alpuim@riskco.nl Abstract. The refinement

More information

Introduction to System F. Lecture 18 CS 565 4/20/09

Introduction to System F. Lecture 18 CS 565 4/20/09 Introduction to System F Lecture 18 CS 565 4/20/09 The Limitations of F 1 (simply-typed λ- calculus) In F 1 each function works exactly for one type Example: the identity function id = λx:τ. x : τ τ We

More information

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,

More information

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.

More information

Mutable References. Chapter 1

Mutable References. Chapter 1 Chapter 1 Mutable References In the (typed or untyped) λ-calculus, or in pure functional languages, a variable is immutable in that once bound to a value as the result of a substitution, its contents never

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2002 Vol. 1, No. 2, July-August 2002 The Theory of Classification Part 2: The Scratch-Built

More information

Static analysis and all that

Static analysis and all that Static analysis and all that Martin Steffen IfI UiO Spring 2014 uio Static analysis and all that Martin Steffen IfI UiO Spring 2014 uio Plan approx. 15 lectures, details see web-page flexible time-schedule,

More information

Hoare Logic: Proving Programs Correct

Hoare Logic: Proving Programs Correct Hoare Logic: Proving Programs Correct 17-654/17-765 Analysis of Software Artifacts Jonathan Aldrich Reading: C.A.R. Hoare, An Axiomatic Basis for Computer Programming Some presentation ideas from a lecture

More information

A Compositional Logic for Control Flow

A Compositional Logic for Control Flow A Compositional Logic for Control Flow Gang Tan 1 and Andrew W. Appel 2 1 Computer Science Department, Boston College. gtan@cs.bc.edu 2 Computer Science Department, Princeton University. appel@cs.princeton.edu

More information

Leslie Lamport: The Specification Language TLA +

Leslie Lamport: The Specification Language TLA + Leslie Lamport: The Specification Language TLA + This is an addendum to a chapter by Stephan Merz in the book Logics of Specification Languages by Dines Bjørner and Martin C. Henson (Springer, 2008). It

More information

A Theory of Linear Objects

A Theory of Linear Objects A Theory of Linear Objects Matthew Kehrt University of Washington mkehrt@cs.washington.edu Jonathan Aldrich Carnegie Mellon University aldrich@cs.cmu.edu Abstract Recently, linearity has been proposed

More information

CSE-321 Programming Languages 2014 Final

CSE-321 Programming Languages 2014 Final Name: Hemos ID: CSE-321 Programming Languages 2014 Final Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Total Score Max 15 12 14 14 30 15 100 There are six problems on 12 pages in this exam.

More information

Reasoning about Denotations of Recursive Objects

Reasoning about Denotations of Recursive Objects Reasoning about Denotations of Recursive Objects Jan Schwinghammer Submitted for the degree of D. Phil. University of Sussex September, 2005 Declaration I hereby declare that this thesis has not been previously

More information

Derivation for the Necessity of Recursive Types and its Basic Usage

Derivation for the Necessity of Recursive Types and its Basic Usage Derivation for the Necessity of Recursive Types and its Basic Usage Philipp Koster Supervised by Prof. Dr. Farhad D. Mehta Seminar AT 2016 1 Abstract This paper derives the need for recursive types by

More information

Formal Methods. CITS5501 Software Testing and Quality Assurance

Formal Methods. CITS5501 Software Testing and Quality Assurance Formal Methods CITS5501 Software Testing and Quality Assurance Pressman, R. Software Engineering: A Practitioner s Approach. Chapter 28. McGraw-Hill, 2005 The Science of Programming, David Gries, 1981

More information

Why. an intermediate language for deductive program verification

Why. an intermediate language for deductive program verification Why an intermediate language for deductive program verification Jean-Christophe Filliâtre CNRS Orsay, France AFM workshop Grenoble, June 27, 2009 Jean-Christophe Filliâtre Why tutorial AFM 09 1 / 56 Motivations

More information

Weak updates and separation logic

Weak updates and separation logic Weak updates and separation logic Gang Tan 1, Zhong Shao 2, Xinyu Feng 3, and Hongxu Cai 4 1 Lehigh University, 2 Yale University 3 Toyota Technological Institute at Chicago, 4 Google Inc. Abstract. Separation

More information

Lesson 11 Universal Types. Universal Types and System F

Lesson 11 Universal Types. Universal Types and System F Lesson 11 Universal Types 2/28 Chapter 23 Universal Types and System F Varieties of polymorphism System F Examples Basic properties Erasure Evaluation issues Parametricity Impredicativity Lesson 11: Universal

More information

Hoare logic. WHILE p, a language with pointers. Introduction. Syntax of WHILE p. Lecture 5: Introduction to separation logic

Hoare logic. WHILE p, a language with pointers. Introduction. Syntax of WHILE p. Lecture 5: Introduction to separation logic Introduction Hoare logic Lecture 5: Introduction to separation logic In the previous lectures, we have considered a language, WHILE, where mutability only concerned program variables. Jean Pichon-Pharabod

More information

More Untyped Lambda Calculus & Simply Typed Lambda Calculus

More Untyped Lambda Calculus & Simply Typed Lambda Calculus Concepts in Programming Languages Recitation 6: More Untyped Lambda Calculus & Simply Typed Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky,

More information

Proving Properties on Programs From the Coq Tutorial at ITP 2015

Proving Properties on Programs From the Coq Tutorial at ITP 2015 Proving Properties on Programs From the Coq Tutorial at ITP 2015 Reynald Affeldt August 29, 2015 Hoare logic is a proof system to verify imperative programs. It consists of a language of Hoare triples

More information

The Essence of Reynolds

The Essence of Reynolds The Essence of Reynolds 3. State and Abstraction Uday S. Reddy 1 1 University of Birmingham POPL, 2014 John C. Reynolds, 1935-2013 Emmy Noether, 1882-1935 According to Mac Lane, she emphasized the importance

More information

From Types to Sets in Isabelle/HOL

From Types to Sets in Isabelle/HOL From Types to Sets in Isabelle/HOL Extented Abstract Ondřej Kunčar 1 and Andrei Popescu 1,2 1 Fakultät für Informatik, Technische Universität München, Germany 2 Institute of Mathematics Simion Stoilow

More information

We defined congruence rules that determine the order of evaluation, using the following evaluation

We defined congruence rules that determine the order of evaluation, using the following evaluation CS 4110 Programming Languages and Logics Lectures #21: Advanced Types 1 Overview In this lecture we will extend the simply-typed λ-calculus with several features we saw earlier in the course, including

More information

How to Make a Correct Multiprocess Program Execute Correctly on a Multiprocessor

How to Make a Correct Multiprocess Program Execute Correctly on a Multiprocessor How to Make a Correct Multiprocess Program Execute Correctly on a Multiprocessor Leslie Lamport 1 Digital Equipment Corporation February 14, 1993 Minor revisions January 18, 1996 and September 14, 1996

More information

A Simpl Shortest Path Checker Verification

A Simpl Shortest Path Checker Verification A Simpl Shortest Path Checker Verification Christine Rizkallah Max-Planck-Institut für Informatik, Saarbrücken, Germany Abstract. Verification of complex algorithms with current verification tools in reasonable

More information

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth Today Parametric Polymorphism Type Systems Lecture 9 Dec. 15th, 2004 Sebastian Maneth 1. Recall Let-Polymorphism 4. System F-sub 5. Properties of F-sub http://lampwww.epfl.ch/teaching/typesystems/2004

More information

Hoare logic. Lecture 5: Introduction to separation logic. Jean Pichon-Pharabod University of Cambridge. CST Part II 2017/18

Hoare logic. Lecture 5: Introduction to separation logic. Jean Pichon-Pharabod University of Cambridge. CST Part II 2017/18 Hoare logic Lecture 5: Introduction to separation logic Jean Pichon-Pharabod University of Cambridge CST Part II 2017/18 Introduction In the previous lectures, we have considered a language, WHILE, where

More information

COMP 507: Computer-Aided Program Design

COMP 507: Computer-Aided Program Design Fall 2014 April 7, 2015 Goal: Correctness proofs Prove that an algorithm written in an imperative language is correct Induction for algorithmic correctness Induction for functional programs: The program

More information

Program certification with computational

Program certification with computational Program certification with computational effects Burak Ekici j.w.w. Jean-Guillaume Dumas, Dominique Duval, Damien Pous y LJK, University Joseph Fourier, Grenoble y LIP, ENS-Lyon November 5, 2014 JNCF 14,

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front

More information

Proof Carrying Code(PCC)

Proof Carrying Code(PCC) Discussion p./6 Proof Carrying Code(PCC Languaged based security policy instead of OS-based A mechanism to determine with certainity that it is safe execute a program or not Generic architecture for providing

More information

Modular Verification of the Subject-Observer Pattern via Higher-Order Separation Logic

Modular Verification of the Subject-Observer Pattern via Higher-Order Separation Logic Modular Verification of the Subject-Observer Pattern via Higher-Order Separation Logic Neelakantan R. Krishnaswami, Jonathan Aldrich 1, and Lars Birkedal 2 1 Carnegie Mellon University, {neelk, aldrich}@cs.cmu.edu

More information

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy! Introduction to Denotational Semantics Class Likes/Dislikes Survey would change [the bijection question] to be one that still tested students' recollection of set theory but that didn't take as much time

More information

Type Inference for Scripting languages with Implicit Extension

Type Inference for Scripting languages with Implicit Extension Type Inference for Scripting languages with Implicit Extension Tian Zhao University of Wisconsin Milwaukee tzhao@uwm.edu Abstract This paper presents a constraint-based type inference algorithm for a subset

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Constrained Types and their Expressiveness

Constrained Types and their Expressiveness Constrained Types and their Expressiveness JENS PALSBERG Massachusetts Institute of Technology and SCOTT SMITH Johns Hopkins University A constrained type consists of both a standard type and a constraint

More information

Transforming Programs into Recursive Functions

Transforming Programs into Recursive Functions SBMF 2008 Transforming Programs into Recursive Functions Magnus O. Myreen, Michael J. C. Gordon 1 Computer Laboratory, University of Cambridge 15 JJ Thomson Avenue, Cambridge, UK Abstract This paper presents

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information