Parametricity and GADTs

Size: px
Start display at page:

Download "Parametricity and GADTs"

Transcription

1 Dimitrios Vytiniotis Stephanie Weirich Computer and Information Science Department University of Pennsylvania Boston, July 2006

2 A very simple GADT example data R :: * -> * where Rint :: R Int Rbool :: R Bool inc :: forall a. R a -> a -> a inc Rint x = x + 1 inc Rbool x = True

3 A very simple GADT example inc :: forall a. R a -> a -> a inc Rint x = x + 1 inc Rbool x = True This is a strange function: Can t apply inc to all types. The argument of type a is not treated parametrically. So, what does parametricity mean in this language?

4 Overview 1. System F + this GADT 2. Parametricity theorem for this language 3. Free theorems 4. Other GADTs

5 Overview 1. System F + this GADT 2. Parametricity theorem for this language 3. Free theorems 4. Other GADTs This is all work in progress.

6 System F τ, σ ::= int bool α σ σ a.σ e ::= i b λx.e e 1 e 2 Λα.e e[σ]... v ::= i λx.e

7 System F + R τ, σ ::= int bool α σ σ a.σ R τ e ::= i b λx.e e 1 e 2 Λα.e e[σ]... R int R bool case e e int e bool v ::= i λx.e R int R bool

8 System F + R τ, σ ::= int bool α σ σ a.σ R τ e ::= i b λx.e e 1 e 2 Λα.e e[σ]... R int R bool case e e int e bool v ::= i λx.e R int R bool inc :: a.r α α α inc = λx.case x (λy.y + 1) (λz.true)

9 Typing rules Γ R int : R int Γ R bool : R bool Γ e : R τ Γ e int : σ{int/α} Γ e bool : σ{bool/α} Γ case e e int e bool : σ{τ/α}

10 Bigstep, CBN Operational Semantics v v e 1 λx.e 1 e 1 {e 2/x} v e 1 e 2 v e R int e int v case e e int e bool v e 1 Λa.e 1 e 1 {σ/α} v e 1 [σ] v e R bool e bool v case e e int e bool v

11 Some Definitions Definition (Typed value relations) Let V(τ 1, τ 2 ) be the set of relations between closed values of closed type τ 1 and τ 2.

12 Some Definitions Definition (Typed value relations) Let V(τ 1, τ 2 ) be the set of relations between closed values of closed type τ 1 and τ 2. Definition (Type substitution) A type substitution η is a map from type variables to (τ 1, τ 2, r) where τ 1 and τ 2 are closed types and r V(τ 1, τ 2 ). If η(α) = (τ 1, τ 2, r), then let η 1 (α) = τ 1, η 2 (α) = τ 2 and η r (α) = r.

13 Some Definitions Definition (Typed value relations) Let V(τ 1, τ 2 ) be the set of relations between closed values of closed type τ 1 and τ 2. Definition (Type substitution) A type substitution η is a map from type variables to (τ 1, τ 2, r) where τ 1 and τ 2 are closed types and r V(τ 1, τ 2 ). If η(α) = (τ 1, τ 2, r), then let η 1 (α) = τ 1, η 2 (α) = τ 2 and η r (α) = r. Definition (Computational closure) If r V(τ 1, τ 2 ), then define r as {(e 1, e 2 ) e 1 : τ 1 e 2 : τ 2 e 1 v 1 e 2 v 2 (v 1, v 2 ) r}.

14 Logical Relation (System F) [int ] η = {(i, i)} [bool ] η = {(b, b)} [σ 1 σ 2 ] η = {(v 1, v 2 ) v 1 : η 1 (σ 1 σ 2 ) v 2 : η 2 (σ 1 σ 2 ) (e 1, e 2 ) [σ 1 ] η (v 1 e 1, v 2 e 2 ) [σ 2 ] η } [ α.σ] η = {(v 1, v 2 ) v 1 : η 1 ( α.σ) v 2 : η 2 ( α.σ) τ 1, τ 2, r V(τ 1, τ 2 ), (v 1 [τ 1 ], v 2 [τ 2 ]) [σ] η,α (τ1,τ 2,r) } [α] η = η r (α)

15 Parametricity Theorem Definition (Related substitution) Let γ be a mapping from term variables to pairs of closed expressions. Say Γ, η γ iff x : σ Γ, (γ 1 (x), γ 2 (x)) [σ] η.

16 Parametricity Theorem Definition (Related substitution) Let γ be a mapping from term variables to pairs of closed expressions. Say Γ, η γ iff x : σ Γ, (γ 1 (x), γ 2 (x)) [σ] η. Theorem (Fundamental theorem) If Γ e : σ and ftv(γ, e, σ) = dom(η) and Γ, η γ then (γ 1 (e), γ 2 (e)) [σ] η.

17 Relation for R types [R int ] η = {(R int, R int )} [R bool ] η = {(R bool, R bool )} [Rτ] when η 1 (α) = η 2 (α) = τ and η [Rα] η = r (α) = [τ] and τ is a closed monotype otherwise [R τ] η = otherwise

18 Relation for R types [R int ] η = {(R int, R int )} [R bool ] η = {(R bool, R bool )} C [Rτ] when η 1 (α) = η 2 (α) = τ and η [Rα] η = r (α) = C [τ] and τ is a closed monotype otherwise [R τ] η = otherwise

19 Closed relation C [int ] = {(i, i)} C [bool ] = {(b, b)} C [σ 1 σ 2 ] = {(v 1, v 2 ) v 1 : η 1 (σ 1 σ 2 ) v 2 : η 2 (σ 1 σ 2 ) (e 1, e 2 ) C [σ 1 ] (v 1 e 1, v 2 e 2 ) C [σ 2 ] } C [R int ] = {(R int, R int )} C [R bool ] = {(R bool, R bool )} C [σ] = otherwise Lemma If τ is a closed monotype then [τ] = C [τ]

20 A free theorem Consider a closed expression f of type α.α α. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (x, y) r (f [τ 1 ]x, f [τ 2 ]y) r

21 A free theorem Consider a closed expression f of type α.α α. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (x, y) r (f [τ 1 ]x, f [τ 2 ]y) r We can use this theorem to show that forall values v of type τ, f [τ]v v.

22 A free theorem Consider a closed expression f of type α.α α. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (x, y) r (f [τ 1 ]x, f [τ 2 ]y) r We can use this theorem to show that forall values v of type τ, f [τ]v v. Let r be the relation {(v, v)}.

23 A free theorem Consider a closed expression f of type α.α α. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (x, y) r (f [τ 1 ]x, f [τ 2 ]y) r We can use this theorem to show that forall values v of type τ, f [τ]v v. Let r be the relation {(v, v)}. Now, (x, y) r (f [τ]x, f [τ]y) r.

24 A free theorem Consider a closed expression f of type α.α α. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (x, y) r (f [τ 1 ]x, f [τ 2 ]y) r We can use this theorem to show that forall values v of type τ, f [τ]v v. Let r be the relation {(v, v)}. Now, (x, y) r (f [τ]x, f [τ]y) r. So (v, v) r (f [τ]v, f [τ]v) r.

25 Free theorem for inc Now consider a closed expression f of type α.rα α α.

26 Free theorem for inc Now consider a closed expression f of type α.rα α α. τ 1, τ 2, r V(τ 1, τ 2 ),

27 Free theorem for inc Now consider a closed expression f of type α.rα α α. τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (v, w) [Rτ], (x, y) r (f [τ 1 ] v x, f [τ 2 ] w y) r )

28 Free theorem for inc Now consider a closed expression f of type α.rα α α. τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (v, w) [Rτ], (x, y) r (f [τ 1 ] v x, f [τ 2 ] w y) r ) (τ 1 τ 2 r [τ 1 ] (v, w), (x, y) r, (f [τ 1 ] v x, f [τ 2 ] w y) r )

29 You get what you pay for Now consider a closed expression f of type α.rα Rα, which is an identity function. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (x, y) [Rτ 1 ], (f [τ 1 ] x, f [τ 2 ] y) [Rτ] ) (τ 1 τ 2 r [τ 1 ] (x, y), (f [τ 1 ] x, f [τ 2 ] y) ) This theorem is also uninteresting all it says is that when given equal arguments, f will produce equal results.

30 Not always useless Consider a closed expression f of type α.rα. The free theorem for this type is:

31 Not always useless Consider a closed expression f of type α.rα. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ),

32 Not always useless Consider a closed expression f of type α.rα. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (f [τ 1 ], f [τ 2 ]) [Rτ 1 ] )

33 Not always useless Consider a closed expression f of type α.rα. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (f [τ 1 ], f [τ 2 ]) [Rτ 1 ] ) (τ 1 τ 2 r [τ 1 ] (f [τ 1 ], f [τ 2 ]) )

34 Not always useless Consider a closed expression f of type α.rα. The free theorem for this type is: τ 1, τ 2, r V(τ 1, τ 2 ), (τ 1 = τ 2 r = [τ 1 ] (f [τ 1 ], f [τ 2 ]) [Rτ 1 ] ) (τ 1 τ 2 r [τ 1 ] (f [τ 1 ], f [τ 2 ]) ) By this theorem, (f [int], f [bool]). So there cannot be any such f.

35 Alternative reasoning Lemma (Canonical forms) 1. If v : R int then v = R int. 2. If v : R bool then v = R bool. 3. There are no closed values of type R σ, when σ is not int or bool.

36 Alternative reasoning Lemma (Canonical forms) 1. If v : R int then v = R int. 2. If v : R bool then v = R bool. 3. There are no closed values of type R σ, when σ is not int or bool. Using this this lemma, we can show that if f : α.rα Rα then for all v : Rτ, f [τ] v v.

37 Vector GADT Consider another GADT. data Z :: * data S :: * -> * data Vec :: * -> * -> * where Nil :: Vec Z a Cons :: a -> Vec n a -> Vec (S n) a

38 More formally Γ Nil : α.vec Z α Γ Cons : αβ.α Vec β α Vec (S β)α Γ e : Vec σ ind σ Γ e n : σ {Z/α} Γ e c : β.σ σ {β/α} σ {S β/α} Γ case e e n e c : σ {n/α}

39 Logical relation [Z ] η = [Sσ] η = [Vec Z σ] η = {(Nil, Nil)} [Vec (S σ i ) σ] η = {(Cons[η 1 (σ)][η 1 (σ i )] x 1 y 1, Cons[η 2 (σ)][η 2 (σ i )] x 2 y 2 ) { (x 1, x 2 ) [σ] η, (y 1, y 2 ) [Vec σ i σ] η } [Vec τ σ]η when η [Vec α σ] η = 1 (α) = η 2 (α) = τ otherwise [Vec σ i σ] η = otherwise

40 Logical relation [Z ] η = [Sσ] η = [Vec Z σ] η = {(Nil, Nil)} [Vec (S σ i ) σ] η = {(Cons[η 1 (σ)][η 1 (σ i )] x 1 y 1, Cons[η 2 (σ)][η 2 (σ i )] x 2 y 2 ) { (x 1, x 2 ) [σ] η, (y 1, y 2 ) [Vec σ i σ] η } [Vec τ σ]η when η [Vec α σ] η = 1 (α) = η 2 (α) = τ otherwise [Vec σ i σ] η = otherwise Note: Because the index type is empty, don t need to restrict η r (α).

41 Where to next? More free theorems. Leave the pure world. Parametricity for general GADTs. Mechanize everything in a theorem prover. Dimitrios has a good start in Isabelle/HOL.

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 Contents 1 Polymorphism 1 2 Polymorphic λ-calculus: Syntax 1 3 Static Semantics 2 4 Dynamic Semantics

More information

A proof of correctness for the Hindley-Milner type inference algorithm

A proof of correctness for the Hindley-Milner type inference algorithm A proof of correctness for the Hindley-Milner type inference algorithm Jeff Vaughan vaughan2@cis.upenn.edu May 5, 2005 (Revised July 23, 2008) 1 Introduction This report details a proof that the Hindley-Milner

More information

CMSC 631 Program Analysis and Understanding Fall Type Systems

CMSC 631 Program Analysis and Understanding Fall Type Systems Program Analysis and Understanding Fall 2017 Type Systems Type Systems A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according

More information

Introduction to lambda calculus Part 6

Introduction to lambda calculus Part 6 Introduction to lambda calculus Part 6 Antti-Juhani Kaijanaho 2017-02-16 1 Untyped lambda calculus 2 Typed lambda calculi 2.1 Dynamically typed lambda calculus with integers 2.2 A model of Lisp 2.3 Simply

More information

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints

A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints A Machine Checked Model of Idempotent MGU Axioms For a List of Equational Constraints Sunil Kothari, James Caldwell Department of Computer Science, University of Wyoming, USA Machine checked proofs of

More information

07 Equational Logic and Algebraic Reasoning

07 Equational Logic and Algebraic Reasoning CAS 701 Fall 2004 07 Equational Logic and Algebraic Reasoning Instructor: W. M. Farmer Revised: 17 November 2004 1 What is Equational Logic? Equational logic is first-order logic restricted to languages

More information

Propositional Dynamic Logic

Propositional Dynamic Logic Propositional Dynamic Logic Contents 1 Introduction 1 2 Syntax and Semantics 2 2.1 Syntax................................. 2 2.2 Semantics............................... 2 3 Hilbert-style axiom system

More information

A Generalized Let-Polymorphic Type Inference Algorithm

A Generalized Let-Polymorphic Type Inference Algorithm ROPAS Research On Program Analysis System National Creative Research Initiative Center Korea Advanced Institute of Science and Technology ROPAS MEMO 2000-5 March 31, 2000 A Generalized Let-Polymorphic

More information

Non-Parametric Parametricity

Non-Parametric Parametricity Non-Parametric Parametricity Georg Neis MPI-SWS neis@mpi-sws.org Derek Dreyer MPI-SWS dreyer@mpi-sws.org Andreas Rossberg MPI-SWS rossberg@mpi-sws.org Abstract Type abstraction and intensional type analysis

More information

Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions)

Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions) Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions) Contact: 15-814 Course Staff Due Tuesday, October 16, 2018, 10:30am This assignment is due by 10:30am

More information

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus

More information

Non-Parametric Parametricity

Non-Parametric Parametricity Non-Parametric Parametricity Georg Neis MPI-SWS neis@mpi-sws.org Derek Dreyer MPI-SWS dreyer@mpi-sws.org Andreas Rossberg MPI-SWS rossberg@mpi-sws.org Abstract Type abstraction and intensional type analysis

More information

Modal Logics. Most applications of modal logic require a refined version of basic modal logic.

Modal Logics. Most applications of modal logic require a refined version of basic modal logic. Modal Logics Most applications of modal logic require a refined version of basic modal logic. Definition. A set L of formulas of basic modal logic is called a (normal) modal logic if the following closure

More information

State-Dependent Representation Independence (Technical Appendix)

State-Dependent Representation Independence (Technical Appendix) State-Dependent Representation Independence (Technical Appendix) Amal Ahmed Derek Dreyer Andreas Rossberg TTI-C MPI-SWS MPI-SWS amal@tti-c.org dreyer@mpi-sws.mpg.de rossberg@mpi-sws.mpg.de Contents August

More information

Foundations of Programming Languages. Paul Downen

Foundations of Programming Languages. Paul Downen Foundations of Programming Languages Paul Downen July 3 8, 2018 2 Contents 1 Static and Dynamic Semantics of a Little Language 7 1.1 Syntax................................. 7 1.2 Static Scope..............................

More information

Contextual equivalence

Contextual equivalence Techniques 16/22 ACS L16, lecture 2 4/10 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx ) if occurrences of the first phrase in any program

More information

Non-parametric parametricity

Non-parametric parametricity JFP 21 (4 & 5): 497 562, 2011. c Cambridge University Press 2011 doi:10.1017/s0956796811000165 497 Non-parametric parametricity G E O R G N E I S, D E R E K D R E Y E R and A N D R E A S R O S S B E R

More information

Chapter 11: Automated Proof Systems (1)

Chapter 11: Automated Proof Systems (1) Chapter 11: Automated Proof Systems (1) SYSTEM RS OVERVIEW Hilbert style systems are easy to define and admit a simple proof of the Completeness Theorem but they are difficult to use. Automated systems

More information

Techniques. Contextual equivalence

Techniques. Contextual equivalence Techniques 16/22 Contextual equivalence Two phrases of a programming language are ( Morris style ) contextually equivalent ( = ctx )if occurrences of the first phrase in any program can be replaced by

More information

Chapter 4: Classical Propositional Semantics

Chapter 4: Classical Propositional Semantics Chapter 4: Classical Propositional Semantics Language : L {,,, }. Classical Semantics assumptions: TWO VALUES: there are only two logical values: truth (T) and false (F), and EXTENSIONALITY: the logical

More information

Combined Satisfiability Modulo Parametric Theories

Combined Satisfiability Modulo Parametric Theories Intel 07 p.1/39 Combined Satisfiability Modulo Parametric Theories Sava Krstić*, Amit Goel*, Jim Grundy*, and Cesare Tinelli** *Strategic CAD Labs, Intel **The University of Iowa Intel 07 p.2/39 This Talk

More information

Beyond First-Order Logic

Beyond First-Order Logic Beyond First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Beyond First-Order Logic MFES 2008/09 1 / 37 FOL

More information

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007 CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

Functional Reachability

Functional Reachability Functional Reachability Luke Ong Nikos Tzevelekos Oxford University Computing Laboratory 24th Symposium on Logic in Computer Science Los Angeles, August 2009. Ong & Tzevelekos Functional Reachability 1

More information

The Reflection Theorem

The Reflection Theorem The Reflection Theorem Formalizing Meta-Theoretic Reasoning Lawrence C. Paulson Computer Laboratory Lecture Overview Motivation for the Reflection Theorem Proving the Theorem in Isabelle Applying the Reflection

More information

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

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

More information

Typed Closure Conversion Preserves Observational Equivalence

Typed Closure Conversion Preserves Observational Equivalence Typed Closure Conversion Preserves Observational Equivalence Amal Ahmed Matthias Blume Abstract Language-based security relies on the assumption that all potential attacks are bound by the rules of the

More information

Typed Closure Conversion Preserves Observational Equivalence

Typed Closure Conversion Preserves Observational Equivalence Typed Closure Conversion Preserves Observational Equivalence Amal Ahmed Matthias Blume Abstract Language-based security relies on the assumption that all potential attacks are bound by the rules of the

More information

Normalization by Evaluation

Normalization by Evaluation Normalization by Evaluation Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University PhD Seminar in Mathematical Engineering EAFIT University, Medellin, Colombia 9

More information

Homological Processing of Biomedical digital images: automation and certification 1

Homological Processing of Biomedical digital images: automation and certification 1 Homological Processing of Biomedical digital images: automation and certification 1 Jónathan Heras, Gadea Mata, María Poza and Julio Rubio Department of Mathematics and Computer Science University of La

More information

Taming Selective Strictness

Taming Selective Strictness Taming Selective Strictness Daniel Seidel and Janis Voigtländer Technische Universität Dresden, 01062 Dresden, Germany {seideld,voigt}@tcs.inf.tu-dresden.de Abstract: Free theorems establish interesting

More information

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen Anthony Hall

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen   Anthony Hall GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen www.cs.ucl.ac.uk/staff/j.bowen/gs03 Anthony Hall GS03 W1 L3 Predicate Logic 12 January 2007 1 Overview The need for extra structure

More information

Computational Semantics Day 4: Extensionality and intensionality

Computational Semantics Day 4: Extensionality and intensionality Computational Semantics Day 4: Extensionality and intensionality Jan van Eijck 1 & Christina Unger 2 1 CWI, Amsterdam, and UiL-OTS, Utrecht, The Netherlands 2 CITEC, Bielefeld University, Germany ESSLLI

More information

Truth-Functional Logic

Truth-Functional Logic Truth-Functional Logic Syntax Every atomic sentence (A, B, C, ) is a sentence and are sentences With ϕ a sentence, the negation ϕ is a sentence With ϕ and ψ sentences, the conjunction ϕ ψ is a sentence

More information

The Many Faces of Modal Logic Day 4: Structural Proof Theory

The Many Faces of Modal Logic Day 4: Structural Proof Theory The Many Faces of Modal Logic Day 4: Structural Proof Theory Dirk Pattinson Australian National University, Canberra (Slides based on a NASSLLI 2014 Tutorial and are joint work with Lutz Schröder) LAC

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

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

More information

Mildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata

Mildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata Mildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Sommersemester 2011 Intuition (1) For a language L, there is a TAG G with

More information

Structuring the verification of heap-manipulating programs

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

More information

An extension of HM(X) with bounded existential and universal data-types

An extension of HM(X) with bounded existential and universal data-types Groupe de travail Cristal July, 2003 An extension of HM(X) with bounded existential and universal data-types (To appear at ICFP 03) Vincent Simonet INRIA Rocquencourt Cristal project Vincent.Simonet@inria.fr

More information

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54 Propositional Logic CS 3234: Logic and Formal Systems Martin Henz and Aquinas Hobor August 26, 2010 Generated on Tuesday 31 August, 2010, 16:54 1 Motivation In traditional logic, terms represent sets,

More information

Depending on equations

Depending on equations Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many

More information

An Introduction to Modal Logic III

An Introduction to Modal Logic III An Introduction to Modal Logic III Soundness of Normal Modal Logics Marco Cerami Palacký University in Olomouc Department of Computer Science Olomouc, Czech Republic Olomouc, October 24 th 2013 Marco Cerami

More information

Relational Parametricity for Polymorphic Linear Lambda Calculus

Relational Parametricity for Polymorphic Linear Lambda Calculus University of Pennsylvania ScholarlyCommons Departmental Papers (CIS) Department of Computer & Information Science 1-2010 Relational Parametricity for Polymorphic Linear Lambda Calculus Jianzhou Zhao University

More information

Constraint-Based Typing for ML via Semiunification Computer Science Technical Report CS

Constraint-Based Typing for ML via Semiunification Computer Science Technical Report CS Constraint-Based Typing for ML via Semiunification Computer Science Technical Report CS-2008-10 Brad Lushman Gordon V. Cormack May 15, 2008 Abstract We characterize ML type inference as a constraint satisfaction

More information

A Calculus of Definitions

A Calculus of Definitions A Calculus of Definitions June 13, 2017 1 Type theory We describe how to implement a core type theory. This is very close to a functional programming language with λ abstraction and data types defined

More information

Principal Type Schemes for Functional Programs with Overloading and Subtyping

Principal Type Schemes for Functional Programs with Overloading and Subtyping Principal Type Schemes for Functional Programs with Overloading and Subtyping Geoffrey S. Smith Cornell University December 1994 Abstract We show how the Hindley/Milner polymorphic type system can be extended

More information

A SYSTEMATIC TRANSLATION OF GUARDED RECURSIVE DATA TYPES TO EXISTENTIAL TYPES WANG MENG. (B.Comp.(Hons.), NUS)

A SYSTEMATIC TRANSLATION OF GUARDED RECURSIVE DATA TYPES TO EXISTENTIAL TYPES WANG MENG. (B.Comp.(Hons.), NUS) A SYSTEMATIC TRANSLATION OF GUARDED RECURSIVE DATA TYPES TO EXISTENTIAL TYPES WANG MENG (B.Comp.(Hons.), NUS) A THESIS SUBMITTED FOR THE DEGREE OF MASTER OF SCIENCE DEPARTMENT OF COMPUTER SCIENCE NATIONAL

More information

Lectures Notes on Progress

Lectures Notes on Progress Lectures Notes on Progress 15-312: Foundations of Programming Languages Frank Pfenning Lecture 7 September 21, 2004 In this lecture we prove the progress property for MinML, discuss type safety, and consider

More information

Safety Analysis versus Type Inference

Safety Analysis versus Type Inference Information and Computation, 118(1):128 141, 1995. Safety Analysis versus Type Inference Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus

More information

M. VAN BAREL Department of Computing Science, K.U.Leuven, Celestijnenlaan 200A, B-3001 Heverlee, Belgium

M. VAN BAREL Department of Computing Science, K.U.Leuven, Celestijnenlaan 200A, B-3001 Heverlee, Belgium MATRIX RATIONAL INTERPOLATION WITH POLES AS INTERPOLATION POINTS M. VAN BAREL Department of Computing Science, K.U.Leuven, Celestijnenlaan 200A, B-3001 Heverlee, Belgium B. BECKERMANN Institut für Angewandte

More information

Minimal logic for computable functionals

Minimal logic for computable functionals Minimal logic for computable functionals Helmut Schwichtenberg Mathematisches Institut der Universität München Contents 1. Partial continuous functionals 2. Total and structure-total functionals 3. Terms;

More information

Lazy Strong Normalization

Lazy Strong Normalization Lazy Strong Normalization Luca Paolini 1,2 Dipartimento di Informatica Università di Torino (ITALIA) Elaine Pimentel 1,2 Departamento de Matemática Universidade Federal de Minas Gerais (BRASIL) Dipartimento

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove

More information

Typed Arithmetic Expressions

Typed Arithmetic Expressions Typed Arithmetic Expressions CS 550 Programming Languages Jeremy Johnson TAPL Chapters 3 and 5 1 Types and Safety Evaluation rules provide operational semantics for programming languages. The rules provide

More information

A Calculus for Dynamic Loading

A Calculus for Dynamic Loading A Calculus for Dynamic Loading Michael Hicks University of Pennsylvania Stephanie Weirich Cornell University February 6, 2001 Abstract We present the load-calculus, used to model dynamic loading, and prove

More information

Boxes Go Bananas: Encoding Higher-Order Abstract Syntax with Parametric Polymorphism (Extended Version)

Boxes Go Bananas: Encoding Higher-Order Abstract Syntax with Parametric Polymorphism (Extended Version) Boxes Go Bananas: Encoding Higher-Order Abstract Syntax with Parametric Polymorphism (Extended Version) Geoffrey Washburn Stephanie Weirich Department of Computer and Information Science University of

More information

Chapter 11: Automated Proof Systems

Chapter 11: Automated Proof Systems Chapter 11: Automated Proof Systems SYSTEM RS OVERVIEW Hilbert style systems are easy to define and admit a simple proof of the Completeness Theorem but they are difficult to use. Automated systems are

More information

Mechanizing Metatheory in a Logical Framework

Mechanizing Metatheory in a Logical Framework Under consideration for publication in J. Functional Programming 1 Mechanizing Metatheory in a Logical Framework Robert Harper and Daniel R. Licata Carnegie Mellon University (e-mail: {rwh,drl}@cs.cmu.edu)

More information

Church and Curry: Combining Intrinsic and Extrinsic Typing

Church and Curry: Combining Intrinsic and Extrinsic Typing Church and Curry: Combining Intrinsic and Extrinsic Typing Frank Pfenning Dedicated to Peter Andrews on the occasion of his retirement Department of Computer Science Carnegie Mellon University April 5,

More information

Typing-by-encoding. A reductionistic approach to building type systems. François Pottier.

Typing-by-encoding. A reductionistic approach to building type systems. François Pottier. Typing-by-encoding A reductionistic approach to building type systems François Pottier Francois.Pottier@inria.fr Overview What is typing-by-encoding? Encoding exceptions into sums (folklore). Encoding

More information

Negative applications of the ASM thesis

Negative applications of the ASM thesis Negative applications of the ASM thesis Dean Rosenzweig and Davor Runje University of Zagreb Berlin, February 26-27, 2007 Outline 1 Negative applications of the ASM thesis Motivation Non-interactive algorithms

More information

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2

More information

02 Propositional Logic

02 Propositional Logic SE 2F03 Fall 2005 02 Propositional Logic Instructor: W. M. Farmer Revised: 25 September 2005 1 What is Propositional Logic? Propositional logic is the study of the truth or falsehood of propositions or

More information

Cylindrical Algebraic Decomposition in Coq

Cylindrical Algebraic Decomposition in Coq Cylindrical Algebraic Decomposition in Coq MAP 2010 - Logroño 13-16 November 2010 Assia Mahboubi INRIA Microsoft Research Joint Centre (France) INRIA Saclay Île-de-France École Polytechnique, Palaiseau

More information

Floyd-Hoare Style Program Verification

Floyd-Hoare Style Program Verification Floyd-Hoare Style Program Verification Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 9 Feb 2017 Outline of this talk 1 Overview 2 Hoare Triples 3

More information

An Introduction to Logical Relations Proving Program Properties Using Logical Relations

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

More information

An Algebraic Proof of the Disjunction Property

An Algebraic Proof of the Disjunction Property An Algebraic Proof of the Disjunction Property Rostislav Horčík joint work with Kazushige Terui Institute of Computer Science Academy of Sciences of the Czech Republic Algebra & Coalgebra meet Proof Theory

More information

Optimal Representations of Polymorphic Types with Subtyping (Extended Abstract)

Optimal Representations of Polymorphic Types with Subtyping (Extended Abstract) Optimal Representations of Polymorphic Types with Subtyping (Extended Abstract) Alexander Aiken 1 and Edward L. Wimmers 2 and Jens Palsberg 3 1 EECS Department, University of California at Berkeley, Berkeley,

More information

Lattices and Orders in Isabelle/HOL

Lattices and Orders in Isabelle/HOL Lattices and Orders in Isabelle/HOL Markus Wenzel TU München October 8, 2017 Abstract We consider abstract structures of orders and lattices. Many fundamental concepts of lattice theory are developed,

More information

EXERCISE 10 SOLUTIONS

EXERCISE 10 SOLUTIONS CSE541 EXERCISE 10 SOLUTIONS Covers Chapters 10, 11, 12 Read and learn all examples and exercises in the chapters as well! QUESTION 1 Let GL be the Gentzen style proof system for classical logic defined

More information

arxiv: v8 [stat.co] 28 Jan 2018

arxiv: v8 [stat.co] 28 Jan 2018 OPTIMAL QUANTIZATION FOR NONUNIFORM CANTOR DISTRIBUTIONS LAKSHMI ROYCHOWDHURY arxiv:151.00379v8 [stat.co] 8 Jan 018 Abstract. Let P be a Borel probability measure on R such that P = 1 4 P S 1 1 + 3 4 P

More information

Safety Analysis versus Type Inference for Partial Types

Safety Analysis versus Type Inference for Partial Types Safety Analysis versus Type Inference for Partial Types Jens Palsberg palsberg@daimi.aau.dk Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department, Aarhus University Ny Munkegade, DK-8000

More information

Relational Parametricity for a Polymorphic Linear Lambda Calculus

Relational Parametricity for a Polymorphic Linear Lambda Calculus Relational Parametricity for a Polymorphic Linear Lambda Calculus Jianzhou Zhao, Qi Zhang, and Steve Zdancewic University of Pennsylvania {jianzhou,qzh,stevez}@cis.upenn.edu Abstract. This paper presents

More information

Subtyping and Intersection Types Revisited

Subtyping and Intersection Types Revisited Subtyping and Intersection Types Revisited Frank Pfenning Carnegie Mellon University International Conference on Functional Programming (ICFP 07) Freiburg, Germany, October 1-3, 2007 Joint work with Rowan

More information

System F with Constraint Types

System F with Constraint Types Boston University OpenBU Computer Science http://open.bu.edu CAS: Computer Science: Technical Reports 2007 System F with Constraint Types Donnelly, Kevin Boston University Computer Science Department https://hdl.handle.net/2144/1692

More information

Herbrand Theorem, Equality, and Compactness

Herbrand Theorem, Equality, and Compactness CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Herbrand Theorem, Equality, and Compactness The Herbrand Theorem We now consider a complete method for proving the unsatisfiability of sets of first-order

More information

Validating QBF Invalidity in HOL4

Validating QBF Invalidity in HOL4 Interactive Theorem Proving (ITP) 14 July, 2010 Quantified Boolean Formulae Quantified Boolean Formulae Motivation System Overview Related Work QBF = propositional logic + quantifiers over Boolean variables

More information

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem Valentine Kabanets October 27, 2016 1 Gödel s Second Incompleteness Theorem 1.1 Consistency We say that a proof system P is consistent

More information

FINITE STATE AUTOMATA

FINITE STATE AUTOMATA FINITE STATE AUTOMATA States An FSA has a finite set of states A system has a limited number of configurations Examples {On, Off}, {1,2,3,4,,k} {TV channels} States can be graphically represented as follows:

More information

A Note on Generalized Topology

A Note on Generalized Topology International Mathematical Forum, Vol. 6, 2011, no. 1, 19-24 A Note on Generalized Topology Gh. Abbaspour Tabadkan and A. Taghavi Faculty of Mathematics and Computer Sciences Damghan University, Damghan,

More information

States and Actions: An Automata-theoretic Model of Objects

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

More information

The Computational SLR: A Calculus for Verifying Cryptographic Proofs

The Computational SLR: A Calculus for Verifying Cryptographic Proofs The Computational SLR: A Calculus for Verifying Cryptographic Proofs Yu Zhang Institute of Software Chinese Academy of Sciences BASICS 09, Shanghai, China October 13, 2009 Background Formal verification

More information

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

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

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering First-Order Logic Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel, Reiner Hähnle (Chalmers

More information

Short Cut Fusion: Proved and Improved

Short Cut Fusion: Proved and Improved Short Cut Fusion: Proved and Improved Patricia Johann Department of Mathematics and Computer Science Dickinson College, Carlisle, PA 17013 USA johannp@dickinson.edu Abstract. Short cut fusion is a particular

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering First-Order Logic Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel, Reiner Hähnle (Chalmers

More information

EXTRACTING COST RECURRENCES FROM SEQUENTIAL AND PARALLEL FUNCTIONAL PROGRAMS

EXTRACTING COST RECURRENCES FROM SEQUENTIAL AND PARALLEL FUNCTIONAL PROGRAMS Wesleyan University EXTRACTING COST RECURRENCES FROM SEQUENTIAL AND PARALLEL FUNCTIONAL PROGRAMS By Justin Raymond Faculty Advisor: Norman Danner A Dissertation submitted to the Faculty of Wesleyan University

More information

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS

CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS CHAPTER 4 CLASSICAL PROPOSITIONAL SEMANTICS 1 Language There are several propositional languages that are routinely called classical propositional logic languages. It is due to the functional dependency

More information

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

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

More information

Fields and Galois Theory. Below are some results dealing with fields, up to and including the fundamental theorem of Galois theory.

Fields and Galois Theory. Below are some results dealing with fields, up to and including the fundamental theorem of Galois theory. Fields and Galois Theory Below are some results dealing with fields, up to and including the fundamental theorem of Galois theory. This should be a reasonably logical ordering, so that a result here should

More information

Admissible Rules of (Fragments of) R-Mingle. Admissible Rules of (Fragments of) R-Mingle. Laura Janina Schnüriger

Admissible Rules of (Fragments of) R-Mingle. Admissible Rules of (Fragments of) R-Mingle. Laura Janina Schnüriger Admissible Rules of (Fragments of) R-Mingle Admissible Rules of (Fragments of) R-Mingle joint work with George Metcalfe Universität Bern Novi Sad 5 June 2015 Table of contents 1. What and why? 1.1 What

More information

An Abstract Decision Procedure for a Theory of Inductive Data Types

An Abstract Decision Procedure for a Theory of Inductive Data Types An Abstract Decision Procedure for a Theory of Inductive Data Types lark Barrett Igor Shikanian Department of omputer Science ourant Institute of Mathematical Sciences New York University esare Tinelli

More information

Typed Closure Conversion Preserves Observational Equivalence

Typed Closure Conversion Preserves Observational Equivalence Typed Closure Conversion Preserves Observational Equivalence Amal Ahmed Matthias Blume Toyota Technological Institute at Chicago {amal, blume}@tti-c.org Abstract Language-based security relies on the assumption

More information

The Underlying Semantics of Transition Systems

The Underlying Semantics of Transition Systems The Underlying Semantics of Transition Systems J. M. Crawford D. M. Goldschlag Technical Report 17 December 1987 Computational Logic Inc. 1717 W. 6th St. Suite 290 Austin, Texas 78703 (512) 322-9951 1

More information

Denotational semantics: proofs

Denotational semantics: proofs APPENDIX A Denotational semantics: proofs We show that every closed term M has a computable functional [[M ] as its denotation. A.1. Unification We show that for any two constructor terms one can decide

More information

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic Mathematics 114L Spring 2018 D.A. Martin Mathematical Logic 1 First-Order Languages. Symbols. All first-order languages we consider will have the following symbols: (i) variables v 1, v 2, v 3,... ; (ii)

More information

Theoretical Computer Science. Representing model theory in a type-theoretical logical framework

Theoretical Computer Science. Representing model theory in a type-theoretical logical framework Theoretical Computer Science 412 (2011) 4919 4945 Contents lists available at ScienceDirect Theoretical Computer Science journal homepage: www.elsevier.com/locate/tcs Representing model theory in a type-theoretical

More information

Polymorphism, Subtyping, and Type Inference in MLsub

Polymorphism, Subtyping, and Type Inference in MLsub Polymorphism, Subtyping, and Type Inference in MLsub Stephen Dolan and Alan Mycroft November 8, 2016 Computer Laboratory University of Cambridge The select function select p v d = if (p v) then v else

More information

SPECIAL VALUES OF j-function WHICH ARE ALGEBRAIC

SPECIAL VALUES OF j-function WHICH ARE ALGEBRAIC SPECIAL VALUES OF j-function WHICH ARE ALGEBRAIC KIM, SUNGJIN. Introduction Let E k (z) = 2 (c,d)= (cz + d) k be the Eisenstein series of weight k > 2. The j-function on the upper half plane is defined

More information