One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

Similar documents
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

Introduction to Lambda Calculus. Lecture 7 CS /08/09

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Pure Lambda Calculus. Lecture 17

Lambda Calculus. Lecture 4 CS /26/10

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

Chapter 5: The Untyped Lambda Calculus

Lambda Calculus. Variables and Functions. cs3723 1

CMPUT 325 : Lambda Calculus Basics. Lambda Calculus. Dr. B. Price and Dr. R. Greiner. 13th October 2004

Type Systems Winter Semester 2006

CMSC 330: Organization of Programming Languages. Lambda Calculus

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

dynamically typed dynamically scoped

Untyped Lambda Calculus

CIS 500 Software Foundations Fall September 25

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages. Lambda Calculus

Untyped Lambda Calculus

CITS3211 FUNCTIONAL PROGRAMMING

1 Scope, Bound and Free Occurrences, Closed Terms

Fundamentals and lambda calculus

Chapter 5: The Untyped Lambda Calculus

Introduction to the Lambda Calculus

VU Semantik von Programmiersprachen

Lambda Calculus. Lambda Calculus

Concepts of programming languages

Formal Systems and their Applications

INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS. Instructors: Crista Lopes Copyright Instructors.

Last class. CS Principles of Programming Languages. Introduction. Outline

Introduction to the Lambda Calculus. Chris Lomont

A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus

Recursive Definitions, Fixed Points and the Combinator

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson

> module Lambda where > import Data.List -- I need some standard list functions

CSCI.4430/6969 Programming Languages Lecture Notes

lambda calculus History 11/28/13 Jianguo Lu A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion.

The Lambda Calculus. 27 September. Fall Software Foundations CIS 500. The lambda-calculus. Announcements

Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

The Untyped Lambda Calculus

Constraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013

Elixir, functional programming and the Lambda calculus.

Functional Programming

Lambda Calculus.

Computer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus

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

Lambda Calculus and Type Inference

COMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland

Introduction to the λ-calculus

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable?

Lambda Calculus and Extensions as Foundation of Functional Programming

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion

Lexicografie computationala Feb., 2012

CSE 505: Concepts of Programming Languages

From the λ-calculus to Functional Programming Drew McDermott Posted

Functional Programming

Lecture 9: More Lambda Calculus / Types

- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.

Lambda Calculus. Gunnar Gotshalks LC-1

CS 6110 S14 Lecture 1 Introduction 24 January 2014

Homework. Lecture 7: Parsers & Lambda Calculus. Rewrite Grammar. Problems

The Untyped Lambda Calculus

Introductory Example

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete

Lambda Calculus LC-1

Functional Programming. Big Picture. Design of Programming Languages

TILC: The Interactive Lambda-Calculus Tracer 1

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

Lecture 5: The Untyped λ-calculus

CMSC330. Objects, Functional Programming, and lambda calculus

10.6 Theoretical Foundations

Part I. Historical Origins

λ calculus is inconsistent

1.3. Conditional expressions To express case distinctions like

Functional Programming

The Typed λ Calculus and Type Inferencing in ML

CITS3211 FUNCTIONAL PROGRAMMING. 14. Graph reduction

Urmas Tamm Tartu 2013

Lambda Calculus-2. Church Rosser Property

Programming Languages

Programming Language Pragmatics

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010

More Lambda Calculus and Intro to Type Systems

Functional Languages and Higher-Order Functions

Functional Languages. Hwansoo Han

Costly software bugs that could have been averted with type checking

Introduction to lambda calculus Part 3

More Lambda Calculus and Intro to Type Systems

Lambda Calculus. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca

The Untyped Lambda Calculus

Simple Lisp. Alonzo Church. John McCarthy. Turing. David Hilbert, Jules Richard, G. G. Berry, Georg Cantor, Bertrand Russell, Kurt Gödel, Alan

Lambda Calculus. Concepts in Programming Languages Recitation 6:

Chapter 11 :: Functional Languages

(Refer Slide Time: 4:00)

Transcription:

λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to be constructible?) aka "effective computability", "computability" Work in parallel included: Turing's work on Turing machines Gödel's work on general recursive functions 1

History (continued) In late 30's, Church, Kleene and Turing showed equivalence of their respective notions. Led to Church's thesis: notion of a computable function should be identified with the notion of a general recursive function. Church's Lambda Calculus: Formally specifies the difference between functions and forms. Form: specifies operations that are to be applied to the parameters of the form (with corresponding free variables and constants). e.g. of a form: a X 2 + X + Y X, Y: parameters a: free variable (not parameter to form) 2: constant 2

Forms Note: if actual arguments are applied to form, there is no way to specify their bindings. P, Q a X 2 + X + Y P X & Q Y? P Y & Q X? λ Functions Lambda function resolves ambiguity and defines difference between functions and forms: (λ x. (λy. a x 2 + x + y)) function with two parameters, x & y, where first actual is to be bound to x and second to y. Curried interpretation: function of x which yields a function of y which... Two interesting characteristics of lambda calculus: 1) Church defined argument substitution assuming static scope. (and actuals bound by λ were to be unique throughout form) 3

λ Functions 2) Form can only contain applications of other functions, not their definitions. instances of other formal parameters bound to other lambdas cannot exist in a given lambda function. functions cannot be used as arguments or function values because a function would appear where a form or object is expected. McCarthy s LISP McCarthy's LISP (1958-1960) - First language to be based on Lambda Calculus - Two major differences: 1) LISP used dynamic scope so: (Define poly (λ (X Y) (+ (+ (* a (* X X)) X) Y) ) ) (Define p1 (λ (a) (poly 2 3) ) ) (Define p2 (λ (a) (poly 4 5) ) ) (p1 10) (p2 20) "a" has different bindings in poly when called by p1, p2. - so LISP maintained "a-list" 4

(continue) McCarthy's LISP 2) LISP (many versions before Scheme, ML) allowed functions as arguments. quoted lambda expressions were passed as "funargs." (passby-name definitions) each time funarg was referenced it caused evaluation of actual parameter's lambda definition in its defining scope. Note: Scheme, ML, Haskell allow functions as arguments they evaluate to themselves. McCarthy has suggested that the reason LISP used dynamic scope was that he did not fully understand the Lambda Calculus of Church during the development of LISP... λ Expressions <exp> ::= <constant> built-in constant <variable> variable names <exp> <exp> applications λ <variable>. <exp> lambda abstractions 5

λ Abstractions Purpose is to denote new functions: (λx. + x 1) (λ x. + x 1) That function of x which adds x to 1 Free and Bound Variables ( λx. + x y ) -- x is bound (by the λ) but y is free λx. + ( ( λy. + y z ) 7 ) x -- x & y are bound; z is free + x ( ( λx. + x 1 ) 4 ) -- first x is free; second is bound Occurrence of variable is bound if an enclosing λ expression binds it, and it is free otherwise. 6

Conversions, BAH! Beta (β): (abstraction and reduction) reduction: applying λ abstraction to an argument, making new instance of abstraction body, and substituting argument for free occurrence of formal abstraction: going the opposite way Alpha (α): changing names consistent formal parameter name change in λ expression. Eta (η): elimination of redundant λ abstractions Substitution E[M/x] -- expression E with all free occurrences of x replaced by M x [M/x] = M c [M/x] = c, where c is variable or constant other than x (E F)[M/x] = E [M/x] F[M/x] (λx.e)[m/x] = λx.e (because no free occurrences of x) (λy.e)[m/x] where y is not x = λy.e[m/x] if x does not occur free in E or y does not occur free in M = λz.(e[z/y]) [M/x] otherwise where z is new variable not free in E or M 7

Conversions Summary β: (λx. E) M E[M/x] α: if y is not free in E then (λx. E) (λy. E[y/x]) η: if x is not free in E and E denotes a function then (λx. E x) α β η E when applied left to right ( called reductions ), β and η rules are Beta Reduction Reducing an expression: (λx. 3) x 3 (λx. + 4 x) 5 9 (λx. (λy. - y x)) 4 5 (λy. - y 4) 5-5 4 (λf. f 3) (λx. + x 1) (λx. + x 1) 3 + 3 1 function argument 1 4 8

Alpha Conversion Ought to be equivalent... (λx. + 1 x) & (λy. + 1 y) and, indeed (λx. + 1 x) (λy. + 1 y) α...as long as newly introduced name does not occur freely in body of original lambda expression. Eta Conversion Ought to be equivalent... (λx. + 1 x) & (+ 1) and, indeed (λx. + 1 x) (+ 1) In general (λx. F x) η η provided x is not free in F and F is a function F 9

Normal Form Def: When an expression contains no reducible expressions (redexes). There may be more than one route to normal form for an expression E e.g. ( + ( * 3 4 ) ( * 7 8 )) Not every expression has a normal form e.g. ( D D ) where D is ( λx. x x ) produces ( D D ) Some reductions may reach normal form while others do not e.g. ( λx. 3 ) ( D D ) OK not OK (CRT-I): If E 1 E 2 then there exists an E such that E 1 E and E 2 E --- in words: two expressions that can be converted to each other share a common normal form. Corollary: No expression can be convereted to two distinct normal forms (CRT-II): Normal Form (CRT) If E 1 E 2 and E 2 is in normal form, then there exists a normal order reduction sequence from E 1 to E 2. --- Normal order reduction: reduce leftmost, outermost redex first 10

λ Calculus Utility Supports expression of recursion! Y H = H ( Y H ) Y: a fixed point combinator: takes a function H and produces a fixed point of H See Peyton-Jones, section 2.4.1 Supports typed, untyped and polymorphic systems Underlies denotational semantics... 11