COMP6463: λ-calculus

Size: px
Start display at page:

Download "COMP6463: λ-calculus"

Transcription

1 COMP6463: λ-calculus 1. Basics Michael Norrish Canberra Research Lab., NICTA Semester 2, 2015

2 Outline Introduction Lambda Calculus Terms Alpha Equivalence Substitution Dynamics Beta Reduction Eta Reduction Normal Forms Evaluation Strategies Conclusion

3 The Lambda Calculus The λ-calculus is a fundamental computational model. It also has a number of connections to logic. Alonzo Church ( ) The next five lectures (including this one) will concentrate on the untyped calculus. The typed calculus has the most elegant connections to logic, so we will focus on computation. But there is also an interesting equational logic to consider. Introduction 3/30

4 Course Plan By me: 1. Basics (today) 2. Equational Logic connection to β examples inconsistent assumptions soundness & completeness 3. Soundness via Church-Rosser 4. Standardisation 5. Computation Church Numerals Encoding Other Types Encoding the Recursive Functions And then, five lectures on the typed calculus by Jeremy Dawson. Introduction 4/30

5 Some Sources H. P. Barendregt, The Lambda Calculus: Its Syntax and Semantics. Elsevier, ISBN Chris Hankin, Lambda Calculi: A Guide for Computer Scientists. Oxford University Press, ISBN Introduction 5/30

6 What are Lambda Terms? Lambda terms make up the world s simplest programming language. A lambda term is either a variable v; or the application of term M to term N, written M N; or the abstraction of variable v in term M, written (λv. M). Examples: f x f, a function, applied to an argument x (f x) y a function applied to two arguments f (g x) two function calls (λv. v) the identity function (λu. (λv. u z)) x abstraction and application Lambda Calculus Terms 6/30

7 Term Shorthands Applications are left-associative. So, you can write M N P, and don t have to write (M N) P (You do have to write M (N P) with the parentheses.) You can chain binders. Instead of (λu. (λv. M)), just write (λu v. M) Thus: instead of S = (λa b c. a c (b c)) S = (λa. (λb. (λc. (a c) (b c)))) Think of abstract syntax trees if necessary. Lambda Calculus Terms 7/30

8 Abstractions are (Anonymous) Functions In secondary school mathematics, you learn to write things like f(x) = x 2 + 2x + 1 meaning that f is a function that takes a parameter x and returns a value derived from that x. When you learnt to program, you might have learnt to write int f (int x) { return x*x + 2*x + 1; } instead. Lambda Calculus Terms 8/30

9 Abstractions are (Anonymous) Functions In λ-calculus (with arithmetic added), you might write f = (λx. x 2 + 2x + 1) In other words, (λx. x 2 + 2x + 1) is a function that takes a value x as a parameter, and calculates a return value. This λ-term is a function without a name. We can decide to give it the name f (or g, or nothing) later. Lambda Calculus Terms 9/30

10 Free and Bound Names Consider: (λv. u v) The variable v is bound. It s the name of a parameter. The variable u is free. It s not the name of an enclosing parameter. The same notions are apparent in other languages: int f (int v) { return u + v; } Lambda Calculus Terms Alpha Equivalence 10/30

11 Bound Names Can be Renamed These two functions are the same: int f (int v) { return u + v; } int f (int x) { return u + x; } But this one is different: int f (int u) { return u + u; } Clearly, not all bound variable renaming is OK. Lambda Calculus Terms Alpha Equivalence 11/30

12 Alpha Equivalence Two λ-terms M and N are alpha-equivalent (written M N) if they are the same up to renaming of bound variables Proof rules v v M 1 M 2 N 1 N 2 M 1 N 1 M 2 N 2 v not free in M N (uv) M (λu. M) (λv. N) where (uv) M = swap u and v everywhere they appear in M Lambda Calculus Terms Alpha Equivalence 12/30

13 Alpha Equivalence Examples Rule for (λv. M) again: v not free in M N (uv) M (λu. M) (λv. N) where (uv) M = swap u and v everywhere they appear in M So, (λv. v u) x (λw. w u) x (λu. u u) x Lambda Calculus Terms Alpha Equivalence 13/30

14 Alpha Equivalence Examples Rule for (λv. M) again: v not free in M N (uv) M (λu. M) (λv. N) where (uv) M = swap u and v everywhere they appear in M So, (λv. v u) x (λw. w u) x (λu. u u) x (λu. (λv. u v) u) (λv. (λu. v u) v) (λu. (λu. u v) u) Lambda Calculus Terms Alpha Equivalence 13/30

15 Alpha Equivalence Examples Rule for (λv. M) again: v not free in M N (uv) M (λu. M) (λv. N) where (uv) M = swap u and v everywhere they appear in M So, (λv. v u) x (λw. w u) x (λu. u u) x (λu. (λv. u v) u) (λv. (λu. v u) v) (λu. (λu. u v) u) (λx. (λy. f y) x) (λy. (λy. f y) y) (λf. (λy. f y) f) Lambda Calculus Terms Alpha Equivalence 13/30

16 Substitution Substitution is a ternary operation: M[v := N] means replace free occurrences of v in M with N Conditions: (making sure that free variables in N are not captured by binders in M) (alpha-convert M as necessary) Freeness: (λv. M)[v := N] (λv. M) (as v is not free in (λv. M)) Capture-avoiding: (λv. u v)[u := v] (λv. v v) (!!!) Lambda Calculus Terms Substitution 14/30

17 Substitution Substitution is a ternary operation: M[v := N] means replace free occurrences of v in M with N Conditions: (making sure that free variables in N are not captured by binders in M) (alpha-convert M as necessary) Freeness: (λv. M)[v := N] (λv. M) (as v is not free in (λv. M)) Capture-avoiding: (λv. u v)[u := v] (λv. v v) (!!!) (λv. u v)[u := v] (λw. u w)[u := v] (λw. v w) Lambda Calculus Terms Substitution 14/30

18 Substitution: Please Take Care! Substitution is tricky! You have seen it before (in handling f.o.l. quantifiers) Use the Barendregt Variable Convention: rename bound variables so they don t overlap with free variables. Lambda Calculus Terms Substitution 15/30

19 Substitution Drives Computation A General Programming Language Axiom: When you apply a function to an argument, the result is as if you substituted the actual argument for the formal parameter and then performed the specified computation For example, how do we figure out what f(3,5) will return? int f (int x, int y) { return 2*x + y; } Dynamics Beta Reduction 16/30

20 Beta Reduction: λ-terms Doing Things Substitution of actuals for formals is the essence of beta-reduction: (λv. M) N β M[v := N] Reduction can occur anywhere within a term. Examples: (λv. v) (λx. x v) β (λx. x v) Dynamics Beta Reduction 17/30

21 Beta Reduction: λ-terms Doing Things Substitution of actuals for formals is the essence of beta-reduction: (λv. M) N β M[v := N] Reduction can occur anywhere within a term. Examples: (λv. v) (λx. x v) β (λx. x v) (λu. (λv. v z) (u z)) β (λu. (u z) z) Dynamics Beta Reduction 17/30

22 Beta Reduction: λ-terms Doing Things Substitution of actuals for formals is the essence of beta-reduction: (λv. M) N β M[v := N] Reduction can occur anywhere within a term. Examples: (λv. v) (λx. x v) β (λx. x v) (λu. (λv. v z) (u z)) β (λu. (u z) z) (λu. (λv. v u) (u z)) v z β (λw. w v) (v z) z β (v z) v z Dynamics Beta Reduction 17/30

23 Beta Reduction: λ-terms Doing Things Substitution of actuals for formals is the essence of beta-reduction: (λv. M) N β M[v := N] Reduction can occur anywhere within a term. Examples: (λv. v) (λx. x v) β (λx. x v) (λu. (λv. v z) (u z)) β (λu. (u z) z) (λu. (λv. v u) (u z)) v z β (λw. w v) (v z) z β (v z) v z (λx. x x) (λy. y y) β (λy. y y) (λy. y y) (λx. x x) (λy. y y) Dynamics Beta Reduction 17/30

24 Beta Reduction Rules and Notation (λv. M) N β M[v := N] M β M M N β M N N β N M N β M N M β M (λv. M) β (λv. M ) Write M β N to mean M can take zero or more β-reduction steps and evolve to N. Write M + β N to mean M can take one or more β-reduction steps and evolve to N. Dynamics Beta Reduction 18/30

25 Beta Reduction Does It All! Lambda Terms + Beta Reduction = All Computation Any computation can be encoded in what we have just seen. We will look at computational aspects of the λ-calculus in detail in later lectures. In particular, it is easy to encode Numbers Recursion And that s all you need. Dynamics Beta Reduction 19/30

26 Eta Reduction We can also add another computational rule, η-reduction: v not free in M (λv. M v) η M (Can perform η-reduction anywhere within a term, as with β.) We will later see how η ties into extensionality. Eta-reduction and eta-expansion (!) also play a role in the typed λ-calculus. Dynamics Eta Reduction 20/30

27 Can Combine Beta and Eta For example: βη βη (λf. f x) (λy. g y) (λf. f x) g g x Dynamics Eta Reduction 21/30

28 Can Combine Beta and Eta For example: Or: (λf. f x) (λy. g y) βη (λf. f x) g βη g x (λf. f x) (λy. g y) βη (λy. g y) x βη g x (Eta and Beta coincide here) Dynamics Eta Reduction 21/30

29 Normal Forms A normal form is a term that cannot be further reduced. For example, (λx. g x) is a β-normal form, but not an η-normal form. It is reasonable to think of normal forms as values towards which we want evaluation to proceed. Dynamics Normal Forms 22/30

30 Normal Form Questions It is natural to ask: 1. Does term M have a normal form? 2. Does M have more than one normal form? And, we can ask these questions of all terms too. Dynamics Normal Forms 23/30

31 Lambda Term Evaluation is Non-Deterministic Recall: M β M M N β M N N β N M N β M N Remember also: (λx. x x) (λy. y y) β (λy. y y) (λy. y y) Call (λx. x x) (λy. y y), the self-looping term, Ω. Dynamics Evaluation Strategies 24/30

32 Infinite Loops (Depending on Evaluation Order) Consider what (λx. y) Ω might do. If we keep evaluating the argument (Ω), we never stop: (λx. y) Ω β (λx. y) Ω β (λx. y) Ω β If we apply the top-level function, substituting Ω for x we get: Done! (λx. y) Ω β y This term ((λx. y) Ω) has one normal form (y), but not all evaluation choices reach it. Dynamics Evaluation Strategies 25/30

33 How Do Other Languages Do This? int g l o b a l = 3; unsigned f (void) { unsigned x = 0; while (1) { x++; } return x; } int g(unsigned i ) { return g l o b a l ; } int main(void) { return g( f ()); } What happens in C? Dynamics Evaluation Strategies 26/30

34 Evaluation Strategy #1: Applicative Order Evaluate everything from the bottom up. I.e., in (λv. M) N work will start with M, passing to N and performing the top-level β-reduction last A function s arguments (and the function itself) will be evaluated before the argument is passed to the function. Also known as strict evaluation. (Used in Fortran, C, Pascal, Ada, SML, Java... ) Causes (λx. y) Ω to go into an infinite loop. Dynamics Evaluation Strategies 27/30

35 Evaluation Strategy #2: Normal Order Evaluate top-down, left-to-right. With (λv. M) N, start by performing the β-reduction, producing M[v := N] Find the top-most, left-most β-redex and reduce it. Keep going This strategy is behind the lazy evaluation of languages like Haskell. Normal order evaluation will always terminate with a normal form if a term has one. (Proof in Lecture 4) Dynamics Evaluation Strategies 28/30

36 Strategy Rules Write M n N for M normal order reduces to N. Then: (λv. M) N n M[v := N] M n M (λv. M) n (λv. M ) M n M M not an abstraction M N n M N N n N M not an abstraction M in β-nf M N n M N Rules for applicative order evaluation will be an assignment question. Dynamics Evaluation Strategies 29/30

37 Summary Lambda Terms: Variables, applications, abstractions Bound names, free names, alpha equivalence Substitution Dynamic Behaviour: Beta reduction: computation through substitution Eta reduction Normal forms, and strategies for achieving them Conclusion 30/30

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

Simply Typed λ-calculus

Simply Typed λ-calculus Simply Typed λ-calculus Lecture 1 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 1 Semester 2, 2017 1 / 23 A Brief History of Type Theory First developed

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

Lambda-Calculus (cont): Fixpoints, Naming. Lecture 10 CS 565 2/10/08

Lambda-Calculus (cont): Fixpoints, Naming. Lecture 10 CS 565 2/10/08 Lambda-Calculus (cont): Fixpoints, Naming Lecture 10 CS 565 2/10/08 Recursion and Divergence Consider the application: Ω ((λ x. (x x)) (λ x. (x x))) Ω evaluates to itself in one step. It has no normal

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

Traditional and Non Traditional lambda calculi

Traditional and Non Traditional lambda calculi Strategies July 2009 Strategies Syntax Semantics Manipulating Expressions Variables and substitutions Free and bound variables Subterms and substitution Grafting and substitution Ordered list of variables

More information

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule.

3.2 Reduction 29. Truth. The constructor just forms the unit element,. Since there is no destructor, there is no reduction rule. 32 Reduction 29 32 Reduction In the preceding section, we have introduced the assignment of proof terms to natural deductions If proofs are programs then we need to explain how proofs are to be executed,

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

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

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

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

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth Today 1. What is the Lambda Calculus? Type Systems 2. Its Syntax and Semantics 3. Church Booleans and Church Numerals 4. Lazy vs. Eager Evaluation (call-by-name vs. call-by-value) Lecture 2 Oct. 27th,

More information

Consequence Relations and Natural Deduction

Consequence Relations and Natural Deduction Consequence Relations and Natural Deduction Joshua D. Guttman Worcester Polytechnic Institute September 9, 2010 Contents 1 Consequence Relations 1 2 A Derivation System for Natural Deduction 3 3 Derivations

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

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

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

Simply Typed λ-calculus

Simply Typed λ-calculus Simply Typed λ-calculus Lecture 2 Jeremy Dawson The Australian National University Semester 2, 2017 Jeremy Dawson (ANU) COMP4630,Lecture 2 Semester 2, 2017 1 / 19 Outline Properties of Curry type system:

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:

More information

COMP4630: λ-calculus

COMP4630: λ-calculus COMP4630: λ-calculus 4. Standardsaton Mcael Norrs Mcael.Norrs@ncta.com.au Canberra Researc Lab., NICTA Semester 2, 2015 Last Tme Confluence Te property tat dvergent evaluatons can rejon one anoter Proof

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

Lambda Calculus. Syntax. i ::= a b c d e... etc L ::= i i L L L ( L ) A Few Examples. x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a))

Lambda Calculus. Syntax. i ::= a b c d e... etc L ::= i i L L L ( L ) A Few Examples. x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a)) Syntax Lambda Calculus A Few Examples i ::= a b c d e... etc L ::= i i L L L ( L ) x x y a x a (b a) c d (c e (d e)) (x (x x)) (y (y a)) Semantics With Examples α β Anywhere that something of the form

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

Advanced Lambda Calculus Lecture 5

Advanced Lambda Calculus Lecture 5 Advanced Lambda Calculus Lecture 5 The fathers Alonzo Church (1903-1995) as mathematics student at Princeton University (1922 or 1924) Haskell B. Curry (1900-1982) as BA in mathematics at Harvard (1920)

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

Lecture 14 Rosser s Theorem, the length of proofs, Robinson s Arithmetic, and Church s theorem. Michael Beeson

Lecture 14 Rosser s Theorem, the length of proofs, Robinson s Arithmetic, and Church s theorem. Michael Beeson Lecture 14 Rosser s Theorem, the length of proofs, Robinson s Arithmetic, and Church s theorem Michael Beeson The hypotheses needed to prove incompleteness The question immediate arises whether the incompleteness

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

Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012

Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. Radboud University Nijmegen. March 5, 2012 1 λ Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 5, 2012 2 reading Femke van Raamsdonk Logical Verification Course Notes Herman Geuvers Introduction to

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

Equivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why?

Equivalent Computers. Lecture 39: Lambda Calculus. Lambda Calculus. What is Calculus? Real Definition. Why? #,, - Lecture 39: Lambda Calculus Equivalent Computers z z z... term = variable term term (term) λ variable. term λy. M α λv. (M [y α v]) where v does not occur in M. (λx. M)N β M [ x α N ] Turing Machine

More information

The Lambda-Calculus Reduction System

The Lambda-Calculus Reduction System 2 The Lambda-Calculus Reduction System 2.1 Reduction Systems In this section we present basic notions on reduction systems. For a more detailed study see [Klop, 1992, Dershowitz and Jouannaud, 1990]. Definition

More information

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018 Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This

More information

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT

Lambda Calculus. Andrés Sicard-Ramírez. Semester Universidad EAFIT Lambda Calculus Andrés Sicard-Ramírez Universidad EAFIT Semester 2010-2 Bibliography Textbook: Hindley, J. R. and Seldin, J. (2008). Lambda-Calculus and Combinators. An Introduction. Cambridge University

More information

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

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

More information

Lambda Calculus! Gunnar Gotshalks! LC-1

Lambda Calculus! Gunnar Gotshalks! LC-1 Lambda Calculus! LC-1 λ Calculus History! Developed by Alonzo Church during mid 1930 s! One fundamental goal was to describe what can be computed.! Full definition of λ-calculus is equivalent in power

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

The λ-calculus and Curry s Paradox Drew McDermott , revised

The λ-calculus and Curry s Paradox Drew McDermott , revised The λ-calculus and Curry s Paradox Drew McDermott drew.mcdermott@yale.edu 2015-09-23, revised 2015-10-24 The λ-calculus was invented by Alonzo Church, building on earlier work by Gottlob Frege and Moses

More information

Categories, Proofs and Programs

Categories, Proofs and Programs Categories, Proofs and Programs Samson Abramsky and Nikos Tzevelekos Lecture 4: Curry-Howard Correspondence and Cartesian Closed Categories In A Nutshell Logic Computation 555555555555555555 5 Categories

More information

Diagrams for Meaning Preservation

Diagrams for Meaning Preservation Diagrams for Meaning Preservation 2003-06-13 Joe Wells Detlef Plump Fairouz Kamareddine Heriot-Watt University University of York www.cee.hw.ac.uk/ultra www.cs.york.ac.uk/ det Diagrams for Meaning Preservation

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

Equivalent Forms of the Axiom of Infinity

Equivalent Forms of the Axiom of Infinity Equivalent Forms of the Axiom of Infinity Axiom of Infinity 1. There is a set that contains each finite ordinal as an element. The Axiom of Infinity is the axiom of Set Theory that explicitly asserts that

More information

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula: Logic: The Big Picture Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and

More information

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)

More information

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands Advanced Lambda Calculus Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands Form of the course Ordinary lecture Seminar form Exam: working out an exercise

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

Lecture Notes on Compositional Reasoning

Lecture Notes on Compositional Reasoning 15-414: Bug Catching: Automated Program Verification Lecture Notes on Compositional Reasoning Matt Fredrikson Ruben Martins Carnegie Mellon University Lecture 4 1 Introduction This lecture will focus on

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

Consequence Relations and Natural Deduction

Consequence Relations and Natural Deduction Consequence Relations and Natural Deduction Joshua D Guttman Worcester Polytechnic Institute September 16, 2010 Contents 1 Consequence Relations 1 2 A Derivation System for Natural Deduction 3 3 Derivations

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

Programming Language Concepts: Lecture 18

Programming Language Concepts: Lecture 18 Programming Language Concepts: Lecture 18 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 18, 30 March 2009 One step reduction

More information

Typed Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23

Typed Lambda Calculi. Nikos Tzeveλekos Queen Mary, University of London 1 / 23 Typed Lambda Calculi Nikos Tzeveλekos Queen Mary, University of London 1 / 23 What is the Lambda Calculus A minimal formalism expressing computation with functionals s ::= x λx.s ss All you need is lambda.

More information

Models of Computation,

Models of Computation, Models of Computation, 2010 1 The Lambda Calculus A brief history of mathematical notation. Our notation for numbers was introduced in the Western World in the Renaissance (around 1200) by people like

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

Denoting computation

Denoting computation A jog from Scott Domains to Hypercoherence Spaces 13/12/2006 Outline Motivation 1 Motivation 2 What Does Denotational Semantic Mean? Trivial examples Basic things to know 3 Scott domains di-domains 4 Event

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

Gödel s Incompleteness Theorem. Overview. Computability and Logic

Gödel s Incompleteness Theorem. Overview. Computability and Logic Gödel s Incompleteness Theorem Overview Computability and Logic Recap Remember what we set out to do in this course: Trying to find a systematic method (algorithm, procedure) which we can use to 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

Proving Completeness for Nested Sequent Calculi 1

Proving Completeness for Nested Sequent Calculi 1 Proving Completeness for Nested Sequent Calculi 1 Melvin Fitting abstract. Proving the completeness of classical propositional logic by using maximal consistent sets is perhaps the most common method there

More information

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC)

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC) Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras Lecture - 15 Propositional Calculus (PC) So, now if you look back, you can see that there are three

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

A Common Notation System for the Lambda-Calculus and Combinatory Logic

A Common Notation System for the Lambda-Calculus and Combinatory Logic A Common Notation System for the Lambda-Calculus and Combinatory Logic Masahiko Sato Graduate School of Informatics, Kyoto University Joint work with Takafumi Sakurai and Helmut Schwichtenberg IFIP WG

More information

First Order Logic: Syntax and Semantics

First Order Logic: Syntax and Semantics CS1081 First Order Logic: Syntax and Semantics COMP30412 Sean Bechhofer sean.bechhofer@manchester.ac.uk Problems Propositional logic isn t very expressive As an example, consider p = Scotland won on Saturday

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

Logic. Propositional Logic: Syntax

Logic. Propositional Logic: Syntax Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 15 Ana Bove May 17th 2018 Recap: Context-free Languages Chomsky hierarchy: Regular languages are also context-free; Pumping lemma

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

3. The λ-calculus and Implication

3. The λ-calculus and Implication 3. The λ-calculus and Implication (a) (b) (c) (d) (e) (f) The untyped λ-calculus. The typed λ-calculus. The λ-calculus in Agda. Logic with Implication Implicational Logic in Agda. More on the typed λ-calculus.

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

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

Nameless Representation of Terms

Nameless Representation of Terms Nameless Representation of Terms CIS500: Software Foundations Nameless Representation of Terms p.1/29 First, some review... A Proof on λ-terms Nameless Representation of Terms p.2/29 Proof (1) We want

More information

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig First-Order Logic First-Order Theories Roopsha Samanta Partly based on slides by Aaron Bradley and Isil Dillig Roadmap Review: propositional logic Syntax and semantics of first-order logic (FOL) Semantic

More information

Notes on multivariable calculus

Notes on multivariable calculus Notes on multivariable calculus Jonathan Wise February 2, 2010 1 Review of trigonometry Trigonometry is essentially the study of the relationship between polar coordinates and Cartesian coordinates in

More information

Origin in Mathematical Logic

Origin in Mathematical Logic Lambda Calculus Origin in Mathematical Logic Foundation of mathematics was very much an issue in the early decades of 20th century. Cantor, Frege, Russel s Paradox, Principia Mathematica, NBG/ZF Origin

More information

Realisability methods of proof and semantics with application to expansion

Realisability methods of proof and semantics with application to expansion Realisability methods of proof and semantics with application to expansion First Year Examination Supervisors : Professor Fairouz Kamareddine and Doctor Joe B. Wells Student : Vincent Rahli ULTRA group,

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

Logic and Probability Lecture 3: Beyond Boolean Logic

Logic and Probability Lecture 3: Beyond Boolean Logic Logic and Probability Lecture 3: Beyond Boolean Logic Wesley Holliday & Thomas Icard UC Berkeley & Stanford August 13, 2014 ESSLLI, Tübingen Wesley Holliday & Thomas Icard: Logic and Probability, Lecture

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

Propositional Logic: Part II - Syntax & Proofs 0-0

Propositional Logic: Part II - Syntax & Proofs 0-0 Propositional Logic: Part II - Syntax & Proofs 0-0 Outline Syntax of Propositional Formulas Motivating Proofs Syntactic Entailment and Proofs Proof Rules for Natural Deduction Axioms, theories and theorems

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

Polynomial Space. The classes PS and NPS Relationship to Other Classes Equivalence PS = NPS A PS-Complete Problem

Polynomial Space. The classes PS and NPS Relationship to Other Classes Equivalence PS = NPS A PS-Complete Problem Polynomial Space The classes PS and NPS Relationship to Other Classes Equivalence PS = NPS A PS-Complete Problem 1 Polynomial-Space-Bounded TM s A TM M is said to be polyspacebounded if there is a polynomial

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

How to Think of Intersection Types as Cartesian Products

How to Think of Intersection Types as Cartesian Products Available online at www.sciencedirect.com Electronic Notes in Theoretical Computer Science 325 (2016) 305 312 www.elsevier.com/locate/entcs How to Think of Intersection Types as Cartesian Products Rick

More information

Simply Typed Lambda-Calculi (II)

Simply Typed Lambda-Calculi (II) THEORY AND PRACTICE OF FUNCTIONAL PROGRAMMING Simply Typed Lambda-Calculi (II) Dr. ZHANG Yu Institute of Software, Chinese Academy of Sciences Fall term, 2011 GUCAS, Beijing Introduction PCF Programming

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

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

Seminaar Abstrakte Wiskunde Seminar in Abstract Mathematics Lecture notes in progress (27 March 2010)

Seminaar Abstrakte Wiskunde Seminar in Abstract Mathematics Lecture notes in progress (27 March 2010) http://math.sun.ac.za/amsc/sam Seminaar Abstrakte Wiskunde Seminar in Abstract Mathematics 2009-2010 Lecture notes in progress (27 March 2010) Contents 2009 Semester I: Elements 5 1. Cartesian product

More information

15-424/ Recitation 1 First-Order Logic, Syntax and Semantics, and Differential Equations Notes by: Brandon Bohrer

15-424/ Recitation 1 First-Order Logic, Syntax and Semantics, and Differential Equations Notes by: Brandon Bohrer 15-424/15-624 Recitation 1 First-Order Logic, Syntax and Semantics, and Differential Equations Notes by: Brandon Bohrer (bbohrer@cs.cmu.edu) 1 Agenda Admin Everyone should have access to both Piazza and

More information

Further discussion of Turing machines

Further discussion of Turing machines Further discussion of Turing machines In this lecture we will discuss various aspects of decidable and Turing-recognizable languages that were not mentioned in previous lectures. In particular, we will

More information

Lecture 3. Lambda calculus. Iztok Savnik, FAMNIT. October, 2015.

Lecture 3. Lambda calculus. Iztok Savnik, FAMNIT. October, 2015. Lecture 3 Lambda calculus Iztok Savnik, FAMNIT October, 2015. 1 Literature Henk Barendregt, Erik Barendsen, Introduction to Lambda Calculus, March 2000. Lambda calculus Leibniz had as ideal the following

More information

Introduction to Logic in Computer Science: Autumn 2006

Introduction to Logic in Computer Science: Autumn 2006 Introduction to Logic in Computer Science: Autumn 2006 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Plan for Today Today s class will be an introduction

More information

Propositional Logic: Syntax

Propositional Logic: Syntax Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic

More information

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

Recursion Theorem. Ziv Scully Ziv Scully Recursion Theorem / 28

Recursion Theorem. Ziv Scully Ziv Scully Recursion Theorem / 28 Recursion Theorem Ziv Scully 18.504 Ziv Scully Recursion Theorem 18.504 1 / 28 A very λ-calculus appetizer P-p-p-plot twist! λ Ziv Scully Recursion Theorem 18.504 2 / 28 A very λ-calculus appetizer The

More information

The Greek Alphabet. (a) The Untyped λ-calculus

The Greek Alphabet. (a) The Untyped λ-calculus 3. The λ-calculus and Implication Greek Letters (a) The untyped λ-calculus. (b) The typed λ-calculus. (c) The λ-calculus in Agda. (d) Logic with Implication (e) Implicational Logic in Agda. (f) More on

More information

Decidability: Church-Turing Thesis

Decidability: Church-Turing Thesis Decidability: Church-Turing Thesis While there are a countably infinite number of languages that are described by TMs over some alphabet Σ, there are an uncountably infinite number that are not Are there

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 13 CHAPTER 4 TURING MACHINES 1. The definition of Turing machine 2. Computing with Turing machines 3. Extensions of Turing

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

More information

17.1 Correctness of First-Order Tableaux

17.1 Correctness of First-Order Tableaux Applied Logic Lecture 17: Correctness and Completeness of First-Order Tableaux CS 4860 Spring 2009 Tuesday, March 24, 2009 Now that we have introduced a proof calculus for first-order logic we have to

More information