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 Semantics is a way to assign a meaning to programs written in a programming language, in our case the imperative object calculus. The goal of my thesis is develop a step-indexed semantics for the imperative object calculus, which we plan to extend it in several directions. However, before that I m going to present the imperative object calculus with it s operational, axiomatic and denotational semantics.

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) The object calculi are object-oriented programming languages. They are abstractions (idealised morels) which capture the essence of object-oriented programming languages. 3 They have rigourously defined formal semantics And they are simple since only objects are considered as primitives. At the same time, they are expressive enough to encode all common features of practical object-oriented programming languages like classes and inheritance. But they can also easily encode functions - the lambda calculus can be easily encoded.

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] Since the object calculi only have objects as primitives they are called object-based in contrast to the much more widely used class-based programming languages like Java or C#. 4 And even though object-based programming languages are not very popular in practice, there is one important exception: JavaScript is object-based. And in the upcoming 2.0 version it will have classes, namespaces and optional types. The object calculi are of course all typed. and they are described in the book by Abadi and Cardelli: A Theory of Objects In this talk I will only discuss a variant of the imperative object calculus, as presented by Abadi and Leino in their paper from 2004.

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 Here is the syntax of our calculus. 5 Since the language is imperative, computations are described in terms of a store and statements can read and from the store and write to the store. Variables are identifiers and they are not mutable. Programs are flat -> this makes evaluation order explicit - given by the let constructs. The self reference can be used used for direct recursion - same role as this in Java, C++, C# Objects are references and the semantics allows for aliasing. Methods don t have arguments, but we can use the fields (in a similar way to the encoding of lambda calc.) We have update for fields but not for methods [-> method updates can be easily be simulated] Other than the objects we also have booleans and numbers which we will use in the examples. In the examples we will also use a lot of syntactic sugar.

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 In order to define an operational semantics one constructs a simple abstract machine. The meaning of a program is the result obtained by evaluating it using this machine. 7 Since for our imperative object calculus we use a small-step operational semantics, evaluation is defined as the reflexive transitive closure of a reduction relation, which (the reduction relation) defines transitions or steps between two configurations of the abstract machine. The configurations of our abstract machine are just pairs formed by a store and a partially evaluated program. Reduction relation is inductively defined by rules, one for each construct in our language.

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 This program defines an object with a method that directly calls itself and then calls that method. This or course diverges. 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 Simple types: booleans, naturals and object types. 10 The typing relation is just a tri-place relation, inductively defined by rules. So types are purely syntactical objects. A subtyping relation is defined on object types. Other than the subtyping in width (a subtype can have additional fields and methods compared to the supertype), we also have covariance on method types (an object having a method returning a subtype has a subtype of the same object having a method returning a supertype... complicated). But in order to have soundness the fields need to be invariant because they are mutable references.

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 The types of objects can be extended to specifications of program correctness - which brings us to the next concept we want to present: program logics. 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) A program logic is a deduction system for program correctness. The best example for a program logic is Hoare logic. 13 Explain rule: read from bottom up, triples: precondition, statement, postcondition Program logics are still widely used in program verification, for example the Verisoft project uses Hoare logic.

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 The Logic of Objects defined by Abadi and Leino is a refinement of the type system we have seen. But since we are now talking about program correctness in the logic type checking no longer decidable. There were attempts to partially mechanize this logic, for example [Hofmann & Tang, 02] build a verification condition generator for this logic. 14 Specifications generalize types. what was added to the usual typing judgement is a first-order logic formula talking about the store, both before and after the execution of the program. The authors call this formula phi, containing both precondition and postcondition, a transition relation. Sub-specification generalizes subtyping and subsumption corresponds to weakening in Hoare logic.

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] Explain rule for object creation. 15 The assertions about the store don t have tight semantics (as in separation logic), this leads to many useless proof steps, proving that things don t change. In the paper from 2004, Abadi and Leino prove agreement between the operational semantics and their program logic: if you can prove a program returns a certain value, then the program either diverges or it reduces to that value. The more usual soundness (everything that is derivable is valid) was much harder to prove [Schwinghammer & Reus, 06].

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 What makes the imperative object calculus particularly interesting from a theoretical point of view, is that it combines objects with higher-order store. Higher-order store = executable code can be stored Higher-order store is present in different forms in almost all practical programming languages: -> general references in ML -> pointers to functions in C/C++ -> or callbacks in Java And it s easy to check that you have higher order store by implementing recursion through the store. Also called, tying a knot in the store.

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] The imperative object calculus features: dynamically allocated, higher-order store. 17 Challenging to find good semantic models in which one can reason about the behavior of programs. Syntactic arguments, based solely on the operational semantics, are surely enough to prove properties such as type safety, but are not suitable as a basis for program logics like the one we just discussed. We believe that specifications should have a meaning independent of the particular proof system.

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 So it looks like we need to use something more abstract, like a denotational semantics. 18 In a denotational semantics the meaning of a program is a mathematical object. For example in the simply typed lambda calculus the meaning of a lambda abstraction can be a function. However, once one starts to study more realistic programming languages things are not so simple any more. Heavy machinery from domain theory, category theory and order theory is often necessary. For higher-order store the semantic domain is defined as mixed-variant recursive equation one has to solve (find fixed point?). Also, only for modeling dynamic allocation one has to move to a possible-world model, formalized as a category of functors over CPOs. The major advantage of a denotational semantics is that it abstracts away from evaluation, so it is can be used to derive much more powerful laws for reasoning about the behavior of programs.

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 Since the imperative object calculus has dynamically-allocated higher order store, its denotational semantics is of course complex - Jan just finished his Ph.D. thesis on this topic. 19 This approach is nice since separates the notion of logical validity from derivability and so it clarifies the meaning of specifications of the logic: -> A specification is a predicate over [the denotation of] programs However, even so the known models are still not abstract enough in that many natural equivalences involving state do not hold.

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] So what could be an alternative to using a denotational semantics here? Step-indexed semantics,might be one. Step-indexed semantics was was developed Appel and his collaborators in the context of foundational proof-carrying code. 20 PCC is a way of certifying that untrusted mobile code does not harm its host. Foundational PCC is a variant of PCC that aims to be more flexible and more secure than PCC, by avoiding commitment to a particular type system. Operational semantics, safety properties and type systems are directly defined in an expressive logic (e.g. HOL) and then the properties are not proved only wrt some type system, but down to the foundations of mathematics. The proponents of the step-indexed semantics argue that usual syntactic proofs of type soundness (subject reduction = progress + preservation) are hard to mechanize, since they require inductive definitions and reasoning about proofs. In general proof carrying code deals with very low-level languages, like assembler or even machine code. However, step-indexed semantics was also used for a lambda calculus with recursive types in Later this has been successfully extended to an imperative language with general references and impredicative polymorphism.

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] Based on a small-step operational semantics, and here types are just sets of indexed values - set-theoretical model. Informally, an expression has a certain type if it behaves like an element of that type for a fixed number of steps. 21 Like in a denotational semantics types have a meaning: they can be viewed as predicates over programs, while type constructors are just functions over these predicates. However, our model is purely set theoretical, so much simpler than the models one usually has with a denotational semantics. Especially the proofs are usually by direct induction on the index. Used as a model for a program logic (for a low-level languages) [Benton 05]

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 The main goal of my thesis is to develop a step-indexed semantics for the imperative object calculus with simple object types. And, once such a semantics is defined, prove the usual typing rules sound. Once this has been achieved, there are several extensions of the construction that can be investigated. The first one would be: ->Enriching the type system with features such as subtyping - should be simple recursive object types - like in Jan s thesis impredicative polymorphism - to our knowledge this was never done for the imperative object calculus before.

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] -> One further extension would be defining a program logic for the imperative object calculus, as an extension of the type system and using the step-indexed semantics we are currently developing. 23 Alternatives -> Augment the type systems with FOL assertions about the store - like we have seen in the logic of Abadi and Leino -> Extend the type systems with dependent types and use a shallow embedding to HOL (HTT) And then, well... there is the original question we had when I started reading about this thesis: Can we have local and modular reasoning for the imperative object calculus. Can we build a separation logic like the ones developed by Reynolds and O Hearn? (sep logic eases reasoning about aliasing, pointer programs) Can we reason about abstract data structures, similarly to the very recent results of Krishnaswami for Idealized ML? Those area all still open questions and will be subject to further investigation.

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 This slide won t be shown, it s here just for completeness. 25

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 This slide won t be shown, it s here just for completeness. 26

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project

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

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

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

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

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

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

Dependent Object Types - A foundation for Scala s type system

Dependent Object Types - A foundation for Scala s type system Dependent Object Types - A foundation for Scala s type system Draft of September 9, 2012 Do Not Distrubute Martin Odersky, Geoffrey Alan Washburn EPFL Abstract. 1 Introduction This paper presents a proposal

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

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

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

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

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

An Annotated Language

An Annotated Language Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of

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

From Hoare Logic to Matching Logic Reachability. Grigore Rosu and Andrei Stefanescu University of Illinois, USA

From Hoare Logic to Matching Logic Reachability. Grigore Rosu and Andrei Stefanescu University of Illinois, USA From Hoare Logic to Matching Logic Reachability Grigore Rosu and Andrei Stefanescu University of Illinois, USA Matching Logic Reachability - Goal - Language independent program verification framework Derives

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

Subtyping. Lecture 13 CS 565 3/27/06

Subtyping. Lecture 13 CS 565 3/27/06 Subtyping Lecture 13 CS 565 3/27/06 Polymorphism Different varieties of polymorphism: Parametric (ML) type variables are abstract, and used to encode the fact that the same term can be used in many different

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/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. #2 #3 Observations

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

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

Featherweight Java (FJ)

Featherweight Java (FJ) x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Featherweight Java (FJ) Ralf Lämmel This lecture is based on David Walker s lecture: Computer Science 441, Programming Languages, Princeton

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

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

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

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 design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

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

Subsumption. Principle of safe substitution

Subsumption. Principle of safe substitution Recap on Subtyping Subsumption Some types are better than others, in the sense that a value of one can always safely be used where a value of the other is expected. Which can be formalized as by introducing:

More information

Reasoning About Imperative Programs. COS 441 Slides 10

Reasoning About Imperative Programs. COS 441 Slides 10 Reasoning About Imperative Programs COS 441 Slides 10 The last few weeks Agenda reasoning about functional programming It s very simple and very uniform: substitution of equal expressions for equal expressions

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

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

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

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

6. Hoare Logic and Weakest Preconditions

6. Hoare Logic and Weakest Preconditions 6. Hoare Logic and Weakest Preconditions Program Verification ETH Zurich, Spring Semester 07 Alexander J. Summers 30 Program Correctness There are many notions of correctness properties for a given program

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

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital

More information

Introduction to Axiomatic Semantics (1/2)

Introduction to Axiomatic Semantics (1/2) #1 Introduction to Axiomatic Semantics (1/2) How s The Homework Going? Remember: just do the counterexample guided abstraction refinement part of DPLL(T). If you notice any other errors, those are good

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

Main Goal. Language-independent program verification framework. Derive program properties from operational semantics

Main Goal. Language-independent program verification framework. Derive program properties from operational semantics Main Goal Language-independent program verification framework Derive program properties from operational semantics Questions: Is it possible? Is it practical? Answers: Sound and complete proof system,

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

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

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions. CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations

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

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

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich From IMP to Java Andreas Lochbihler ETH Zurich parts based on work by Gerwin Klein and Tobias Nipkow 2015-07-14 1 Subtyping 2 Objects and Inheritance 3 Multithreading 1 Subtyping 2 Objects and Inheritance

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

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

Chapter 3 (part 3) Describing Syntax and Semantics

Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings

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

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

Hiding local state in direct style: a higher-order anti-frame rule

Hiding local state in direct style: a higher-order anti-frame rule 1 / 65 Hiding local state in direct style: a higher-order anti-frame rule François Pottier January 28th, 2008 2 / 65 Contents Introduction Basics of the type system A higher-order anti-frame rule Applications

More information

Lecture 13: Subtyping

Lecture 13: Subtyping Lecture 13: Subtyping Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Subtyping CS546, 2018-2019 1 / 15 Subtyping Usually found

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

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

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

Towards a Semantic Web Modeling Language

Towards a Semantic Web Modeling Language Towards a Semantic Web Modeling Language Draft Christoph Wernhard Persist AG Rheinstr. 7c 14513 Teltow Tel: 03328/3477-0 wernhard@persistag.com May 25, 2000 1 Introduction The Semantic Web [2] requires

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

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

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

DEFINING A LANGUAGE. Robert Harper. Friday, April 27, 12

DEFINING A LANGUAGE. Robert Harper. Friday, April 27, 12 DEFINING A LANGUAGE Robert Harper ACKNOWLEDGEMENTS I am honored to have had the privilege of working with Robin on the development of Standard ML. It is also a pleasure to thank my collaborators, Karl

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

Verifying JML specifications with model fields

Verifying JML specifications with model fields Verifying JML specifications with model fields Cees-Bart Breunesse and Erik Poll Department of Computer Science, University of Nijmegen Abstract. The specification language JML (Java Modeling Language)

More information

On Meaning Preservation of a Calculus of Records

On Meaning Preservation of a Calculus of Records On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract

More information

Part III. Chapter 15: Subtyping

Part III. Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

CITS5501 Software Testing and Quality Assurance Formal methods

CITS5501 Software Testing and Quality Assurance Formal methods CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

Type Theory meets Effects. Greg Morrisett

Type Theory meets Effects. Greg Morrisett Type Theory meets Effects Greg Morrisett A Famous Phrase: Well typed programs won t go wrong. 1. Describe abstract machine: M ::= 2. Give transition relation: M 1 M 2

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

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

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

Formal Semantics. Aspects to formalize. Lambda calculus. Approach Formal Semantics Aspects to formalize Why formalize? some language features are tricky, e.g. generalizable type variables, nested functions some features have subtle interactions, e.g. polymorphism and

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

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

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

A Typed Lambda Calculus for Input Sanitation

A Typed Lambda Calculus for Input Sanitation A Typed Lambda Calculus for Input Sanitation Nathan Fulton Carthage College nfulton@carthage.edu April 11, 2013 Abstract Programmers often wish to validate or sanitize user input. One common approach to

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

Formal Systems II: Applications

Formal Systems II: Applications Formal Systems II: Applications Functional Verification of Java Programs: Java Dynamic Logic Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

The Rule of Constancy(Derived Frame Rule)

The Rule of Constancy(Derived Frame Rule) The Rule of Constancy(Derived Frame Rule) The following derived rule is used on the next slide The rule of constancy {P } C {Q} {P R} C {Q R} where no variable assigned to in C occurs in R Outline of derivation

More information

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE Type Systems Pierce Ch. 3, 8, 11, 15 CSE 6341 1 A Simple Language ::= true false if then else 0 succ pred iszero Simple untyped expressions Natural numbers encoded as succ succ

More information

Chapter 3. Describing Syntax and Semantics ISBN

Chapter 3. Describing Syntax and Semantics ISBN Chapter 3 Describing Syntax and Semantics ISBN 0-321-49362-1 Chapter 3 Topics Describing the Meanings of Programs: Dynamic Semantics Copyright 2015 Pearson. All rights reserved. 2 Semantics There is no

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information