Normalization by Evaluation

Size: px
Start display at page:

Download "Normalization by Evaluation"

Transcription

1 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 March 2017 Andreas Abel (GU) NbE EAFIT / 32

2 Introduction Context of This Work Dependently-typed (programming) languages allow to express functional specifications in types, to prove (correctness) properties in the language, formalize and prove mathematical propositions. Prominent proof assistent: Coq (INRIA 1984 ) CompCert: Certifed compiler for C (Leroy) Formalized proof of Four Color Theorem (Gonthier, 2005) Odd-Order Theorem (Gonthier, 2012) Theorem Feit_Thompson (gt : fingrouptype) (G : {group gt}) : odd # G -> solvable G. Experimental languages: Agda, Idris,... Andreas Abel (GU) NbE EAFIT / 32

3 Introduction Behind the Veil What made Coq ready for huge developments? Benjamin Grégoire, Xavier Leroy: A compiled implementation of strong reduction. ICFP 2002 Efficient normalization! Grégoire, Leroy: Efficient checking of β-equality. This talk: Framework for βη-equality. Andreas Abel (GU) NbE EAFIT / 32

4 Introduction A Taste of Programming with Dependent Types Descending lists: [x, y,..., z] List n iff n x y z Constructor carries proof p for descent. nil : List 0 x : N p : x y xs : List y cons x p xs : List x Singleton list carries a trivial proof. singleton : (x : N) List x singleton x = cons x nil where : x 0 Andreas Abel (GU) NbE EAFIT / 32

5 Introduction Correct Insert Case: Insert into empty list. insert : (x : N) List n List (max x n) insert x nil = singleton x Inferred type singleton x : List x. Expected type singleton x : List (max x 0). Type-checker needs to ensure List x = List (max x 0). Sufficient: x = max x 0. Compare expressions with free variables! Solution: normalize max x 0 to x. Andreas Abel (GU) NbE EAFIT / 32

6 Introduction Normalization Bring an expression with unkowns into a canonical form. Unknowns = free variables. Checking equality by comparing canonical forms. Examples: Expression arithmetical expression functional programming language stack maching code SQL query Normalizer symbolic evaluator (MathLAB) term rewriting, partial evaluation JIT compiler query compiler Andreas Abel (GU) NbE EAFIT / 32

7 Introduction Evaluation Compute the value of an expression relative to an environment. Environment assigns values to free variables of expressions. Examples: Expression Environment Evaluator arithmetical expression valuation calculator functional programming language stack & heap interpreter stack machine code stack stack machine SQL-query database SQL processor Andreas Abel (GU) NbE EAFIT / 32

8 Introduction Normalization by Evaluation (NbE) Adapt an interpreter to simplify expressions with unknowns. MLTT Martin-Löf 1975: NbE for Type Theory (weak conversion) STL Berger Schwichtenberg 1991: NbE for simply-typed λ-calculus T Danvy 1996: Type-directed partial evaluation F Altenkirch Hofmann Streicher 1996: NbE for λ-free System F λ Aehlig Joachimski 2004: Untyped NbE, operationally λ Filinski Rohde 2004: Untyped NbE, denotationally LF Danielsson 2006: strongly typed NbE for LF T Altenkirch Chapman 2007: Tait in one big step Andreas Abel (GU) NbE EAFIT / 32

9 Monoids Monoids Monoid (M,, ε): set M with a binary operation that has a unit ε. a (b c) = (a b) c associativity ε a = a left unit a ε = a right unit E.g.: (N, +, 0), (N,, 1), (Bool,, true), (Bool,, false), (R n n,, I n ). Free monoid: Sequences with concatenation (List A, ++, [ ]). [a 1,..., a m ] ++ [a m+1,..., a n ] = [a 1,..., a n ] Andreas Abel (GU) NbE EAFIT / 32

10 Monoids Monoid Expressions Fix a carrier A and a set of variables X. Terms (abstract syntax trees) representing monoid elements: Exp t ::= a singleton a A x variable x X ε empty sequence t 1 t 2 concatenation, right associative Example in concrete syntax: ex := (x 0 1) (((2 (ε x 1 )) (ε 4)) x 2 ) Andreas Abel (GU) NbE EAFIT / 32

11 Monoids Interpreting Monoid Expressions Monoid values Val = List A. Environment ρ X Val. Interpretation t ρ Val. x ρ = ρ(x) ε ρ = [ ] empty list a ρ = [a] singleton list t 1 t 2 ρ = t 1 ρ ++ t 2 ρ append Example. Recall ex = (x 0 1) (((2 (ε x 1 )) (ε 4)) x 2 ) ex (x0 =0,x 1 =3,x 2 =5) = [0, 1, 2, 3, 4, 5] Andreas Abel (GU) NbE EAFIT / 32

12 Monoids Normalizing Monoid Expressions I Val = List (A X ). Reflection of variables into values. : X Val x = [x] Reification of values as expressions. : Val Exp [] = ε (a :: v) = a v (x :: v) = x v Andreas Abel (GU) NbE EAFIT / 32

13 Monoids Normalizing Monoid Expressions II Normalization: nf : Exp Exp nf(t) = t Example. Recall ex = (x 0 1) (((2 (ε x 1 )) (ε 4)) x 2 ) nf(ex) = x x 1 4 x 2 ε Andreas Abel (GU) NbE EAFIT / 32

14 Untyped Lambda Calculus Untyped Lambda Calculus, Informally Calculus of functions. Everything is a function. Examples: id = λx. x identity function app = λf. λx. f x application function (also identity) twice = λf. λx. f (f x) apply f twice comp = λf. λg. λx. f (g x) compose two functions Calculation: app twice id = twice id = λx. id (id x) = λx. id x = λx. x = id. Andreas Abel (GU) NbE EAFIT / 32

15 Untyped Lambda Calculus Numbers in the Untyped Lambda Calculus Numbers n N are represented by Church numerals n. 0 = λf. λx. x 1 = λf. λx. f x 2 = λf. λx. f (f x) n = λf. λx. f n x Addition is a sort of composition. plus = λn m f x. n f (m f x) plus n m = λf x. n f (m f x) = λf x. f n (f m x) = λf x. f n+m x = n + m Andreas Abel (GU) NbE EAFIT / 32

16 Untyped Lambda Calculus Recursion in the Untyped Lambda Calculus Reduction: (λx. t) s t[s/x] A looping term: (λx. x x) (λx. x x) (x x)[(λx. x x)/x] = (λx. x x) (λx. x x) Alan Turing s fixed-point combinator. Let θ = (λx. λf. f (x x f )). θ θ f f (θ θ f ) Andreas Abel (GU) NbE EAFIT / 32

17 Untyped Lambda Calculus Untyped Lambda Calculus, Formally Grammar: Exp r, s, t ::= x variable λx. t abstracting variable x in body t r s applying r to s Equational theory (β): (λx. t) s = t[s/x] β-normal forms. Nf v ::= λx. v u normal form Ne u ::= x u v neutral term Andreas Abel (GU) NbE EAFIT / 32

18 Untyped Lambda Calculus Evaluation of Lambda-Expressions Values a, b, f D with (partial) application : D D D. Evaluation (specification): x ρ = ρ(x) r s ρ. = r ρ s ρ λx. t ρ a. = t (ρ,a/x) Instance: compiled execution. f a λx. t ρ Call f with argument a Code for function λx. t with predefined variables ρ Andreas Abel (GU) NbE EAFIT / 32

19 Untyped Lambda Calculus Implementation via Closures Instance: do nothing. λx. t ρ = (λxt)ρ Initial applicative structure: closures. D a, b, f ::= (λxt)ρ waiting for value of x Application and evaluation are mutually defined. (λxt)ρ a = t (ρ,a/x) r s ρ = r ρ s ρ Andreas Abel (GU) NbE EAFIT / 32

20 Untyped Lambda Calculus Residual Model: Adding Unknowns For normalization, we need free variables in D. Application x a of a free variable stores argument a. Need neutrals/accumulators x a in D. D a, b, f ::= (λxt)ρ e D ne e ::= x e a Application extended: (λxt)ρ a = t (ρ,a/x) x a a = x ( a, a) Andreas Abel (GU) NbE EAFIT / 32

21 Untyped Lambda Calculus Reading Back Expressions from Values Reading back values: R nf : D Nf R nf ((λxt)ρ) = λy. R nf ( t (ρ,y/x) ) where y fresh R nf (e) = R ne (e) Reading back neutrals: R ne : D ne Ne R ne (x) = x R ne (e a) = R ne (e) R nf (a) Andreas Abel (GU) NbE EAFIT / 32

22 Untyped Lambda Calculus Fresh Name Generation Freshness problem: 9 approaches. Simple solution: R nf ξ reads fresh names from supply ξ. E.g., ξ is an infinite stream of distinct identifiers. R nf (y,ξ)((λxt)ρ) = λy. Rnf ξ ( t (ρ,y/x)) R nf ξ (e) = R ne ξ (e) R ne ξ (x a) = x R nf ξ ( a) Normalization: nf ξ (t) = R nf ξ ( t ρ id ) Andreas Abel (GU) NbE EAFIT / 32

23 Untyped Lambda Calculus Summary: NbE for Untyped Lambda-Calculus Semantics D [ ] R nf D ne Syntax Exp Nf R ne Ne Var Andreas Abel (GU) NbE EAFIT / 32

24 Typed Lambda Calculus Simply-Typed Lambda Calculus Types S, T ::= N S T. Typing contexts Γ ::= x 1 :S 1,..., x n :S n. Typing Γ t : T. (x :T ) Γ Γ x : T Equational theory (βη). Γ, x :S t : T Γ λx. t : S T Γ r : S T Γ s : S Γ r s : T (β) Γ, x :S t : T Γ s : S Γ (λxt) s = t[s/x] : T (η) Γ t : S T Γ t = λx. t x : S T Andreas Abel (GU) NbE EAFIT / 32

25 Typed Lambda Calculus Bidirectional η-expansion T reflection : η-expansion inside-out T reification : η-expansion outside-in Example (terms): (N N) (N N) f = λy. N N (f ( N N y)) = λy. λx. N (f ( N N y) ( N x)) = λy. λx. N (f (λz. N (y ( N z))) ( N x)) = λy. λx. f (λz. y z) x Andreas Abel (GU) NbE EAFIT / 32

26 Typed Lambda Calculus Adding η-expansion Semantics (β) D T T Semantics (βη) [ ] D nf D ne R nf R ne Syntax Exp Nf Ne Var Andreas Abel (GU) NbE EAFIT / 32

27 Typed Lambda Calculus Eta-expansion: reflection and reification Values now include delayed η-expansions. D a, b, f ::= (λxt)ρ T e D ne e ::= x e d D nf d ::= T a Application and readback trigger these expansions. (λxt)ρ a = t (ρ,a/x) S T e a = T (e S a) R nf (y,ξ) ( S T f ) = λy. R nf ξ ( T (f S y)) R nf ξ ( N N e) = R ne ξ (e) Andreas Abel (GU) NbE EAFIT / 32

28 Typed Lambda Calculus Normalization for STL Canonical environment: ρ Γ (x) = T x where (x : T ) Γ Variable supply: ξ Γ = Var \ Γ Normalization of Γ t : T : nf T Γ (t) = Rnf ξ Γ ( T t ργ ) Andreas Abel (GU) NbE EAFIT / 32

29 Typed Lambda Calculus Correctness of Normalization Normalization is sound if for all expressions Γ t : T, Γ t = nf T Γ (t) : T. Normalization is complete if for all Γ t, t : T, Γ t = t : T = nf T Γ (t) = α nf T Γ (t ) Implies idempotence nf T Γ (t) = α nf T Γ (nft Γ (t)). Andreas Abel (GU) NbE EAFIT / 32

30 Typed Lambda Calculus Completeness of Normalization Well-typed βη-equal terms have the same normal form. Γ t = t : T = a {}}{ t ργ = a {}}{ t ργ A {}}{ T ργ = a = a A = A a = A a = R nf ξ Γ A a = α R nf ξ Γ A a Andreas Abel (GU) NbE EAFIT / 32

31 Typed Lambda Calculus Soundness of Normalization A well-typed term is βη-equal to its normal form. Γ t : T = Γ t : T R = Γ t = R nf ξ Γ A a : T a A {}}{{}}{ t ργ T ργ Γ t = nf T Γ (t) : T Andreas Abel (GU) NbE EAFIT / 32

32 Conclusions Conclusions Interpreters can be turned into normalizers in a systematic way. Normalization-by-evaluation has helped to understand η-equality. NbE is also a theoretical tool to investigate Type Theory. E.g., to prove decidability of type checking. Andreas Abel (GU) NbE EAFIT / 32

Normalisation by evaluation

Normalisation by evaluation Normalisation by evaluation Sam Lindley Laboratory for Foundations of Computer Science The University of Edinburgh Sam.Lindley@ed.ac.uk August 11th, 2016 Normalisation and embedded domain specific languages

More information

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

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

More information

Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types

Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University

More information

Normalisation by Evaluation for Dependent Types

Normalisation by Evaluation for Dependent Types Normalisation by Evaluation for Dependent Types Ambrus Kaposi Eötvös Loránd University, Budapest, Hungary (j.w.w. Thorsten Altenkirch, University of Nottingham) FSCD, Porto 24 June 2016 Introduction Goal:

More information

COMP6463: λ-calculus

COMP6463: λ-calculus COMP6463: λ-calculus 1. Basics Michael Norrish Michael.Norrish@nicta.com.au Canberra Research Lab., NICTA Semester 2, 2015 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics

More information

CS522 - Programming Language Semantics

CS522 - Programming Language Semantics 1 CS522 - Programming Language Semantics Simply Typed Lambda Calculus Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 We now discuss a non-trivial extension of

More information

A proof checking kernel for the λπ-calculus modulo

A proof checking kernel for the λπ-calculus modulo A proof checking kernel for the λπ-calculus modulo Mathieu Boespflug, École Polytechnique PhD defense, 18 january 2011 Funded by Pythia of Delphi Pythia of Delphi True False Proof implies truth. 1 1 For

More information

Strong Normalization for Guarded Types

Strong Normalization for Guarded Types Strong Normalization for Guarded Types Andreas Abel Andrea Vezzosi Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden PLS Seminar ITU, Copenhagen, Denmark 20 August

More information

Extending the Lambda Calculus: An Eager Functional Language

Extending the Lambda Calculus: An Eager Functional Language Syntax of the basic constructs: Extending the Lambda Calculus: An Eager Functional Language canonical forms z cfm ::= intcfm boolcfm funcfm tuplecfm altcfm intcfm ::= 0 1-1... boolcfm ::= boolconst funcfm

More information

Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl)

Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl) Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl) Leran Cai, Ambrus Kaposi, and Thorsten Altenkirch University of Nottingham {psylc5, psxak8, psztxa}@nottingham.ac.uk

More information

On the Correctness of the Krivine Machine

On the Correctness of the Krivine Machine On the Correctness of the Krivine Machine Mitchell Wand Northeastern University 2003-10-03 15:55:00 wand October 3, 2003 Abstract We provide a short proof of the correctness of the Krivine machine by showing

More information

Operational Semantics Using the Partiality Monad

Operational Semantics Using the Partiality Monad page.1 Operational Semantics Using the Partiality Monad Nils Anders Danielsson (Göteborg) Shonan Meeting 026: Coinduction for computation structures and programming languages The research leading to these

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

Normalization by Evaluation for Intuitionistic Propositional Logic

Normalization by Evaluation for Intuitionistic Propositional Logic Normalization by Evaluation for Intuitionistic Propositional Logic Andreas Abel July 2018 1 Intuitionistic Propositional Logic (IPL) Formulas and hypotheses lists (contexts). Atom P, Q atomic propositions

More information

A MODULAR TYPE-CHECKING ALGORITHM FOR TYPE THEORY WITH SINGLETON TYPES AND PROOF IRRELEVANCE

A MODULAR TYPE-CHECKING ALGORITHM FOR TYPE THEORY WITH SINGLETON TYPES AND PROOF IRRELEVANCE A MODULAR TYPE-CHECKING ALGORITHM FOR TYPE THEORY WITH SINGLETON TYPES AND PROOF IRRELEVANCE ANDREAS ABEL, THIERRY COQUAND, AND MIGUEL PAGANO Ludwig-Maximilians-Universität München e-mail address: andreas.abel@ifi.lmu.de

More information

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification

λ Slide 1 Content Exercises from last time λ-calculus COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Content COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ Slide 1 Intro & motivation, getting started [1] Foundations & Principles Lambda

More information

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University

The Lambda Calculus. Stephen A. Edwards. Fall Columbia University The Lambda Calculus Stephen A. Edwards Columbia University Fall 2014 Lambda Expressions Function application written in prefix form. Add four and five is (+ 4 5) Evaluation: select a redex and evaluate

More information

On the Syntax and Semantics of Quantitative Typing

On the Syntax and Semantics of Quantitative Typing On the Syntax and Semantics of Quantitative Typing Andreas Abel 1 1 Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden Workshop on Mixed Inductive-Coinductive Reasoning

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

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

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

On the Correctness and Efficiency of the Krivine Machine

On the Correctness and Efficiency of the Krivine Machine On the Correctness and Efficiency of the Krivine Machine Mitchell Wand Northeastern University Daniel P. Friedman Indiana University February 12, 2003 Abstract We provide a short derivation of the Krivine

More information

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 P. 1 of 7 THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 December, 2014 Time: 2 hrs. Instructions The exam contains questions totaling 100 points. Answer all questions.

More information

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

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

More information

Normalisation by Evaluation for Dependent Types

Normalisation by Evaluation for Dependent Types Normalisation by Evaluation for Dependent Types Thorsten Altenkirch 1 and Ambrus Kaposi 1 1 School for Computer Science, University of Nottingham Nottingham, United Kingdom {txa auk}@cs.nott.ac.uk Abstract

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

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

Static Program Analysis

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

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2016.6.1 COMPUTER SCIENCE TRIPOS Part IB Thursday 2 June 2016 1.30 to 4.30 COMPUTER SCIENCE Paper 6 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.

More information

λ-calculus and types

λ-calculus and types λ-calculus and types Lecture notes Midland Graduate School / APPSEM Spring School 2004 Thorsten Altenkirch School of Computer Science and Information Technology, Nottingham University txa@cs.nott.ac.uk

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

Type Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth.

Type Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth. Type Systems Lecture 2 Oct. 27th, 2004 Sebastian Maneth http://lampwww.epfl.ch/teaching/typesystems/2004 Today 1. What is the Lambda Calculus? 2. Its Syntax and Semantics 3. Church Booleans and Church

More information

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521

THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 P. 1 of 7 THE UNIVERSITY OF CALGARY FACULTY OF SCIENCE FINAL EXAMINATION COMPUTER SCIENCE 521 December, 2016 Time: 2 hrs. Instructions The exam contains questions totaling 100 points. Answer all questions.

More information

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

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

More information

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge Mathematical Synthesis of Equational Deduction Systems Marcelo Fiore Computer Laboratory University of Cambridge TLCA 2009 3.VII.2009 Context concrete theories meta-theories Context concrete theories meta-theories

More information

Models of computation

Models of computation Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal ethods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables odels of computation

More information

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Lambda-Calculus (I) jean-jacques.levy@inria.fr 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010 Plan computation models lambda-notation bound variables conversion

More information

CSCI 490 problem set 6

CSCI 490 problem set 6 CSCI 490 problem set 6 Due Tuesday, March 1 Revision 1: compiled Tuesday 23 rd February, 2016 at 21:21 Rubric For full credit, your solutions should demonstrate a proficient understanding of the following

More information

Operational Semantics

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

More information

Midterm Exam Types and Programming Languages Frank Pfenning. October 18, 2018

Midterm Exam Types and Programming Languages Frank Pfenning. October 18, 2018 Midterm Exam 15-814 Types and Programming Languages Frank Pfenning October 18, 2018 Name: Andrew ID: Instructions This exam is closed-book, closed-notes. You have 80 minutes to complete the exam. There

More information

Notes on Inductive Sets and Induction

Notes on Inductive Sets and Induction Notes on Inductive Sets and Induction Finite Automata Theory and Formal Languages TMV027/DIT21 Ana Bove, March 15th 2018 Contents 1 Induction over the Natural Numbers 2 1.1 Mathematical (Simple) Induction........................

More information

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw Applied Logic Lecture 1 - Propositional logic Marcin Szczuka Institute of Informatics, The University of Warsaw Monographic lecture, Spring semester 2017/2018 Marcin Szczuka (MIMUW) Applied Logic 2018

More information

The lambda calculus with constructors

The lambda calculus with constructors The lambda calculus with constructors Categorical semantic and Continuations Barbara Petit Focus - Univ. Bologna CaCos 2012 Barbara Petit (Focus - Univ. Bologna) The lambda calculus with constructors 1

More information

HORSes: format, termination and confluence

HORSes: format, termination and confluence HORSes: format, termination and confluence Jean-Pierre Jouannaud INRIA-LIAMA and singhua Software Chair Joint on-going work with Jianqi Li School of Software, singhua University Project CoqLF NList Cross-discipline

More information

Copatterns Programming Infinite Objects by Observations

Copatterns Programming Infinite Objects by Observations Copatterns Programming Infinite Objects by Observations Andreas Abel Department of Computer Science Ludwig-Maximilians-University Munich Mathematical Logic Seminar Ludwig-Maximilians-University Munich

More information

Matching Logic: Syntax and Semantics

Matching Logic: Syntax and Semantics Matching Logic: Syntax and Semantics Grigore Roșu 1 and Traian Florin Șerbănuță 2 1 University of Illinois at Urbana-Champaign, USA grosu@illinois.edu 2 University of Bucharest, Romania traian.serbanuta@unibuc.ro

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

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg

Type Theory and Constructive Mathematics. Type Theory and Constructive Mathematics Thierry Coquand. University of Gothenburg Type Theory and Constructive Mathematics Type Theory and Constructive Mathematics Thierry Coquand University of Gothenburg Content An introduction to Voevodsky s Univalent Foundations of Mathematics The

More information

The Lifting Lemma. Ralf Hinze

The Lifting Lemma. Ralf Hinze The Lifting Lemma Ralf Hinze Computing Laboratory, University of Oxford Wolfson Building, Parks Road, Oxford, OX1 3QD, England ralf.hinze@comlab.ox.ac.uk http://www.comlab.ox.ac.uk/ralf.hinze/ June 2009

More information

CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55

CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55 CBV and CBN Eduardo Bonelli TP para LP 2012C1 1/55 Reduction Strategies Call-By-Value Call-by-Name Relating CBN and CBV λ-calculus Continuation Passing Style Bibliography 2/55 Reduction Strategies Reduction

More information

Internship Report Game Semantics and Normalization by Evaluation for Brouwer Ordinals

Internship Report Game Semantics and Normalization by Evaluation for Brouwer Ordinals Internship Report Game Semantics and Normalization by Evaluation for Brouwer Ordinals Léo Exibard August 28, 2015 Abstract P. Clairambault and P. Dybjer developed a Normalization by Evaluation (NbE) algorithm

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Mathias Vorreiter Pedersen November 13, 2015 1 Recalling the untyped lambda calculus 1.1 Syntax t ::= x λ x. t t t 1.2 Evaluation x x t t λx.t λx.t t 1 t 1 t 2 t 2 t 1 t 2

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 7 November 29 November 29, 2006 - version 1.0 Plan PREVIOUSLY: 1. type safety as progress and preservation 2. typed arithmetic expressions 3. simply typed lambda

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

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages ) Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) This Saturday, 10 November 2018, room 335 (FSEGA), we will recover the following activities: 1 Formal Methods

More information

Kleene realizability and negative translations

Kleene realizability and negative translations Q E I U G I C Kleene realizability and negative translations Alexandre Miquel O P. D E. L Ō A U D E L A R April 21th, IMERL Plan 1 Kleene realizability 2 Gödel-Gentzen negative translation 3 Lafont-Reus-Streicher

More information

Classical First-Order Logic

Classical First-Order Logic Classical 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) First-Order Logic (Classical) MFES 2008/09

More information

Formal Techniques for Software Engineering: Denotational Semantics

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

More information

A call-by-name lambda-calculus machine

A call-by-name lambda-calculus machine A call-by-name lambda-calculus machine Jean-Louis Krivine University Paris VII, C.N.R.S. 2 place Jussieu 75251 Paris cedex 05 (krivine@pps.jussieu.fr) Introduction We present, in this paper, a particularly

More information

Foundations of Computation. Ana Bove

Foundations of Computation. Ana Bove Foundations of Computation Ana Bove Programming Logic (ProgLog) Group February 13th 2018 Outline of the talk: What we do in ProgLog Origines of computer science Courses in the area Warming-up Exercise

More information

Justifying Algorithms for βη-conversion

Justifying Algorithms for βη-conversion Justifying Algorithms for βη-conversion Healfdene Goguen AT&T Labs, 180 Park Ave., Florham Park NJ 07932 USA hhg@att.com. Abstract. Deciding the typing judgement of type theories with dependent types such

More information

Computer Proof Assistants and Univalent Foundations of Mathematics

Computer Proof Assistants and Univalent Foundations of Mathematics Nov. 16, 2014, CMA2014, Kuwait. Computer Proof Assistants and Univalent Foundations of Mathematics by Vladimir Voevodsky from the Institute for Advanced Study in Princeton, NJ. Kepler s Conjecture. In

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

Coinductive big-step operational semantics

Coinductive big-step operational semantics Coinductive big-step operational semantics Xavier Leroy a, Hervé Grall b a INRIA Paris-Rocquencourt Domaine de Voluceau, B.P. 105, 78153 Le Chesnay, France b École des Mines de Nantes La Chantrerie, 4,

More information

1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages

1. Object Calculus. Object calculus is to OO languages what lambda calculus is to functional languages 1. Object Calculus In this section we will introduce a calculus of objects that gives a simple but powerful mathematical model to study object based languages. Object calculus is to OO languages what lambda

More information

The Curry-Howard Isomorphism

The Curry-Howard Isomorphism The Curry-Howard Isomorphism Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) The Curry-Howard Isomorphism MFES 2008/09

More information

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability The Turing Machine Computability Motivating idea Build a theoretical a human computer Likened to a human with a paper and pencil that can solve problems in an algorithmic way The theoretical provides a

More information

ADVENTURES IN TIME & SPACE. Jim Royer Syracuse University

ADVENTURES IN TIME & SPACE. Jim Royer Syracuse University ADVENTURES IN TIME & SPACE Jim Royer Syracuse University Joint work with Norman Danner Wesleyan University GeoCal 06 Based on: Adventures in Time and Space, by N. Danner and J.S. Royer, Proceedings of

More information

Introduction to Kleene Algebras

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

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 5 November 15 November 15, 2006 - version 1.0 Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed last

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

Simply Typed Lambda Calculus

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

More information

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 28, 2003 These supplementary notes review the notion of an inductive definition and give

More information

The Calculus of Inductive Constructions

The Calculus of Inductive Constructions The Calculus of Inductive Constructions Hugo Herbelin 10th Oregon Programming Languages Summer School Eugene, Oregon, June 16-July 1, 2011 1 Outline - A bit of history, leading to the Calculus of Inductive

More information

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

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

More information

Supplementary Notes on Inductive Definitions

Supplementary Notes on Inductive Definitions Supplementary Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 29, 2002 These supplementary notes review the notion of an inductive definition

More information

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

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

More information

A probabilistic lambda calculus - Some preliminary investigations

A probabilistic lambda calculus - Some preliminary investigations A probabilistic lambda calculus - Some preliminary investigations Ugo Dal Lago, Margherita Zorzi Università di Bologna, Università di Verona June, 9-11, 2010, Torino Introduction: Λ P We present some results

More information

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

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

More information

Orthogonality and Algebraic Lambda-Calculus

Orthogonality and Algebraic Lambda-Calculus Orthogonality and Algebraic Lambda-Calculus Benoît Valiron March 28, 2010 Abstract Directly encoding lambda-terms on quantum strings while keeping a quantum interpretation is a hard task. As shown by van

More information

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages )

Formal Methods Lecture 6. (B. Pierce's slides for the book Types and Programming Languages ) Formal Methods Lecture 6 (B. Pierce's slides for the book Types and Programming Languages ) Programming in the Lambda-Calculus, Continued Testing booleans Recall: tru = λt. λf. t fls = λt. λf. f We showed

More information

NORMALISATION BY EVALUATION FOR TYPE THEORY, IN TYPE THEORY

NORMALISATION BY EVALUATION FOR TYPE THEORY, IN TYPE THEORY Logical Methods in Computer Science Vol. 134:1)2017, pp. 1 26 https://lmcs.episciences.org/ Submitted Dec. 09, 2016 Published Oct. 23, 2017 NORMALISATION BY EVALUATION FOR TYPE THEORY, IN TYPE THEORY THORSTEN

More information

Isomorphism is equality

Isomorphism is equality Isomorphism is equality Thierry Coquand, Nils Anders Danielsson University of Gothenburg and Chalmers University of Technology Abstract The setting of this work is dependent type theory extended with the

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

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

Equality and dependent type theory. CIRM, May 31

Equality and dependent type theory. CIRM, May 31 CIRM, May 31 The Axiom of Univalence, a type-theoretic view point In type theory, we reduce proof-checking to type-checking Hence we want type-checking to be decidable This holds as soon as we have the

More information

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65 Undecidable Problems Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, 2018 1/ 65 Algorithmically Solvable Problems Let us assume we have a problem P. If there is an algorithm solving

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

Local computation of β-reduction A concrete presentation of Game Semantics

Local computation of β-reduction A concrete presentation of Game Semantics 1 2 3 4 Local computation of β-reduction A concrete presentation of Game Semantics William Blum and C.H. Luke Ong Oxford University Computing Laboratory 5 6 Abstract We show that... Key words: Lambda calculus,

More information

Extended Abstract: Reconsidering Intuitionistic Duality

Extended Abstract: Reconsidering Intuitionistic Duality Extended Abstract: Reconsidering Intuitionistic Duality Aaron Stump, Harley Eades III, Ryan McCleeary Computer Science The University of Iowa 1 Introduction This paper proposes a new syntax and proof system

More information

CIS 500 Software Foundations Final Exam Answer key December 20, 2004

CIS 500 Software Foundations Final Exam Answer key December 20, 2004 CIS 500 Software Foundations Final Exam Answer key December 20, 2004 True/False questions For each of the following statements, circle T if the sentence is true or F otherwise. 1. (10 points) (a) T F The

More information

CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers

CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers To develop a denotational semantics for a language with recursive types, or to give a denotational semantics for the untyped

More information

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

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

More information

The Nuggetizer: Abstracting Away Higher-Orderness for Program Verification

The Nuggetizer: Abstracting Away Higher-Orderness for Program Verification The Nuggetizer: Abstracting Away Higher-Orderness for Program Verification Paritosh Shroff 1, Christian Skalka 2, and Scott F. Smith 1 1 The Johns Hopkins University, Baltimore, MD, USA, {pari,scott}@cs.jhu.edu

More information

Introduction to Turing Machines

Introduction to Turing Machines Introduction to Turing Machines Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 12 November 2015 Outline 1 Turing Machines 2 Formal definitions 3 Computability

More information

Introduction to lambda calculus Part 2

Introduction to lambda calculus Part 2 Introduction to lambda calculus Part 2 Antti-Juhani Kaijanaho 2017-01-24... 1 Untyped lambda calculus 1.1 Syntax... x, y, z Var t, u Term t, u ::= x t u λx t... In this document, I will be using the following

More information

Blame for All. Amal Ahmed, Robert Bruce Findler, Jeremy Siek, Philip Wadler

Blame for All. Amal Ahmed, Robert Bruce Findler, Jeremy Siek, Philip Wadler Blame for All Amal Ahmed, Robert Bruce Findler, Jeremy Siek, Philip Wadler Vs. Part I The bit you know from before with a twist A simple untyped program let inc = λx. x + 1 in let app = λf. λx. f x in

More information

Non-Idempotent Typing Operators, beyond the λ-calculus

Non-Idempotent Typing Operators, beyond the λ-calculus Non-Idempotent Typing Operators, beyond the λ-calculus Soutenance de thèse Pierre VIAL IRIF (Univ. Paris Diderot and CNRS) December 7, 2017 Non-idempotent typing operators P. Vial 0 1 /46 Certification

More information

Certification of Safe Polynomial Memory Bounds (Extended Version)

Certification of Safe Polynomial Memory Bounds (Extended Version) Certification of Safe Polynomial Memory Bounds (Extended Version) Javier de Dios and Ricardo Peña Departamento de Sistemas Informáticos y Computación Universidad Complutense de Madrid, Spain jdcastro@aventia.com,

More information

Programming Language Concepts: Lecture 16

Programming Language Concepts: Lecture 16 Programming Language Concepts: Lecture 16 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 16, 23 March 2009 λ-calculus:

More information