Lambda Calculus History and Syntax. History The lambda calculus is a formal system designed to investigate function definition, function application and.

Slides:



Advertisements
Similar presentations
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Advertisements

The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
First Order Logic Resolution
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
The Halting Problem of Turing Machines. Is there a procedure that takes as input a program and the input to that program, and the procedure determines.
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
HISTORY OF LOGIC BY JOHN NAGUIB. What is Logic? The science or study of how to evaluate arguments and reasoning. “Logic is new and necessary reasoning”
Applied Computer Science II Chapter 3 : Turing Machines Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from G. Klein, NICTA.
Foundations of Programming Languages: Introduction to Lambda Calculus
6. Introduction to the Lambda Calculus. © O. Nierstrasz PS — Introduction to the Lambda Calculus 6.2 Roadmap  What is Computability? — Church’s Thesis.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Prof. Fateman CS 164 Lecture 23
Lecture 20: λ Calculus λ Calculus & Computability Yan Huang Dept. of Comp. Sci. University of Virginia.
Class 37: Computability in Theory and Practice cs1120 Fall 2011 David Evans 21 November 2011 cs1120 Fall 2011 David Evans 21 November 2011.
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
CMSC 330: Organization of Programming Languages Lambda Calculus Introduction λ.
10/12/20151 GC16/3C11 Functional Programming Lecture 3 The Lambda Calculus A (slightly) deeper look.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
1 CO Games Development 2 Week 21 Turing Machines & Computability Gareth Bellaby.
Lambda Calculus1 The Untyped Lambda-Calculus Hossein Hojjat University of Tehran Formal Methods Laboratory.
The Recursion Theorem Pages 217– ADVANCED TOPICS IN C O M P U T A B I L I T Y THEORY.
Undecidable Languages (Chapter 4.2) Héctor Muñoz-Avila.
Lecture 18. Unsolvability Before the 1930’s, mathematics was not like today. Then people believed that “everything true must be provable”. (More formally,
CS 345: Chapter 8 Noncomputability and Undecidability Or Sometimes You Can’t Get It Done At All.
1 ML fun x -> e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors let f x = e variables These.
Course Overview and Road Map Computability and Logic.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Principles of programming languages 9: Lambda calculus Isao Sasano Department of Information Science and Engineering.
Lambda Calculus Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 11.
Lesson2 Lambda Calculus Basics 1/10/02 Chapter 5.1, 5.2.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
Lambda Calculus CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Dr. Philip Cannata 1 Simple Lisp John McCarthy Alonzo Church David Hilbert, Jules Richard, G. G. Berry, Georg Cantor, Bertrand Russell, Kurt Gödel, Alan.
Computation Motivating questions: What does “computation” mean? What are the similarities and differences between computation in computers and in natural.
Alonzo Church: Mathematician. Philosopher. Computer Scientist? Who is Alonzo Church? Alonzo Church was a man who was very important to the computer science.
CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.
On computable numbers, with an application to the ENTSCHEIDUNGSPROBLEM COT 6421 Paresh Gupta by Alan Mathison Turing.
Lambda Calculus A fairly simple system for representing functions The base of typed functional programming languages such as ML and Haskell.
Spring, 2011 –– Computational Thinking – Dennis Kafura – CS 2984 Lambda Calculus Introduction.
CS321 Functional Programming 2 © JAS The λ Calculus This is a formal system to capture the ideas of function abstraction and application introduced.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
CS 154 Formal Languages and Computability April 5 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L03-1 September 14, 2006http:// -calculus: A Basis for.
Chapter 2: Lambda Calculus
CS 550 Programming Languages Jeremy Johnson
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lambda Calculus CSE 340 – Principles of Programming Languages
Computable Functions.
Carlos Varela Rennselaer Polytechnic Institute September 5, 2017
More on Lambda Calculus
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
CS154, Lecture 11: Self Reference, Foundation of Mathematics
CS 320 Principles of Programming Languages
Lesson2 Lambda Calculus Basics
On Kripke’s Alleged Proof of Church-Turing Thesis
Announcements Quiz 6 HW7 due Tuesday, October 30
L Calculus.
CS154, Lecture 11: Self Reference, Foundation of Mathematics
CSE S. Tanimoto Lambda Calculus
CO Games Development 2 Week 21 Turing Machines & Computability
Carlos Varela Rennselaer Polytechnic Institute September 6, 2019
Presentation transcript:

Lambda Calculus History and Syntax

History The lambda calculus is a formal system designed to investigate function definition, function application and recursion. It was introduced by Alonzo Church and Stephen Cole Kleene in the 1930s Lambda calculus has greatly influenced functional programming languages, especially Lisp. Church used the lambda calculus in 1936 to give a negative answer to the Entscheidungsproblem

John McCarthy, AI Lab, Stanford Alonzo Church, Princeton ⋋ -Calculus LISP C Dennis Ritchie, Bell Labs

General Proof Machine Gottfried Leibniz asked if we can make a machine to validate all mathematical statemanets He realized that the first step would have to be a clean formal language

Entscheidungsproblem German: decision problem In 1900, at a mathematical conference in Paris, David Hilbert presented his famous 23 unsolved problems of Mathematics. Question that whether it was possible to determine the truth of any mathematical statement

Entscheidungsproblem In 1931 Kurt Gödel, in his incompleteness Theorem, showed that there exist mathematical statements that are true but cannot be proved as true within the framework of a formal system. The incompleteness theorem showed that mathematics was incomplete

Entscheidungsproblem all that remained to be done was to find a way that would decide whether it was possible to decide whether a given function could be solved mechanically or not

Entscheidungsproblem The negative answer to the Entscheidungsproblem was then given by Alonzo Church in 1936 and independently shortly thereafter by Alan Turing Turing reduced the Entscheidungsproblem to the halting problem for Turing machines

λ – Calculus Origins Originally, Church had tried to construct a complete formal system for the foundations of mathematics System turned out to be susceptible to the analog of Russell's paradox He separated out the lambda calculus and used it to study computability

Lambda Calculus, Definition Provides a mathematical model for computation using recursive functions. Shows that recursive functions have the same computing power as Turing machines. Serves as the basis for functional programming languages like Haskell and ML

Some Informal Definitions Consider definition in mathematic notations : ƒ(x) = x * x + 2 In λ–Calculus we denote This in form of λx.(x*x + 2) And if we have ƒ(5) return number is 27 In λ–Calculus λx.(x*x + 2)(5) we replace x by 5 : λx.(x*x + 2)(5) = (5*5 + 2) = 27

Some informal definitions introduce variables ranging over values define functions by (λ-) abstracting over variables apply functions to values x + 1 x. x + 1 ( x. x + 1) 2

-Expressions A lambda expression is any of the following: 1. Variable: x, y, z, … A variable denotes an abstraction to which it is bound, or denotes itself if it is not bound. 2. Function application: if x and y are -expressions, then (x y) is a - expression called function application. It denotes the result of applying the function x to the argument y.

-Expressions 3. Abstraction or function: If x is a variable and y is a -expression, then ( x. y) is an abstraction or function with dummy variable x and body y. ( x. y) denotes the function which when applied to argument a returns as result the abstraction (( x. y) a) = y [ a | x ]

Examples of -expressions ( x. x) is the identity function. (( x. x) y)  y is a function application returning a variable y. ( f. ( x. ( f x))) is a function returning a function as value, since its body which is to be returned, ( x. ( f x)), is a function. ( ( f. ( x. ( f x))) w)  ( x. (w x)) is a function application returning a function.

Formal Definition Formal Definition of λ expression is : ::= ::= (λ. ) ::= ( ) Where identifier is a member of countable infinite set like {a, b, c,..., x, y, z, x1, x2,...}

Notational Conventions 1. Function application is left- associative. w xmeans (w x) w x ymeans ((w x) y) w x y zmeans (((w x) y) z) 2. The scope of the dummy variable extends as far to the right as possible. w. x y z means ( w. ((x y) z))

Notational Conventions 3. ‘.’ is right associative. w. x. y. zmeans ( w. ( x. ( y. z))) 4. distributes up to the ‘.’. w x y. zmeans w. x. y. z which in turn means ( w. ( x. ( y. z)))

Example Notational Shortcuts 1. x y. f y xmeans ( x. ( y. ((f y) x))), a function. 2. ( x. y x)( y. x y)means ( ( x. (y x))( y. (x y)) ), a function application.

Bound Variables Def. A variable x occurs bound in a - expression if there is an enclosing abstraction of which x is the dummy variable. ( x. ( f … x … ))  dummy bound

Free Variables Def. An occurrence of a variable y is free if it is not bound -- that is, in the scope of the dummy variable x, it is not the variable x. (  x. (y …. x))  free bound

Example Bound and free variables x y. u x y = ( x. (  y. ((u x) y) )) u is free x and y are bound

 -Conversion Def. The variable x in ( x. … x … ) can be renamed in x and in all of its bound occurrences to a new variable u, giving ( u. … u … ). To denote this renaming, we write: ( x. y)   (  u. (y [ u | x ] ) where y [ u | x ] means all occurrences of x bound by x are replaced by u. The variable u must be fresh, and must not get bound when substituted in y, except by  u.

 -Conversion, Examples  x. w x   u. w u 2. x. w x  w. w w is not true since the original w becomes bound. 3. x. ( u. u) x   u. ( u. u) u is okay   y. ( u. u) y is better. 4. x. ( u. w u x )  u. ( u. w u u ) is not true, since u becomes bound.  y. ( u. w u y ) is better.

 -Conversion, Examples  w. x. w x ) x    w. u. w u ) x since the outer x is not in scope of x. 6. w. w x  w. w u is not correct since x is not the dummy variable.

Evaluating -expressions:  -reduction  -reduction describes how to evaluate an application of a function to its actual argument.

Function Application Def. Function application is carried out as follows: (  x   B [ A | x ] where B [ A | x ] means all occurrences of x not bound by other  inside the body B are replaced by A. Further, the free variables occurring in A can not become bound when substituted in A.

 -Redex Rem. A -expression  consisting of a function applied to an argument is called a  -reducible expression or is a  -redex.

 -reduction, Examples 1. (  x. x) a   a 2. (  x.  y. x) a b   (  y. a) b   a 3. (  x. x a) (  x. x)   (  x. x) a   a 4. (  x.  y. x y) y   (  x.  z. x z) y   (  z. y z)

 -Functions Def. A  -function is a name given to a  - expression. Whenever the  -expression is needed, we can use the name instead. It is a shortcut or macro for the  - expression. Example: Some  -functions are true, false, not, and, or, 0, 1, 2,.., n, iszero, suc, and add.

 -Functions 1. true=  x y. x 2. false=  x y. y 3. (x?y:z)= x y z 4. not=  x. x false true 5. and=  x y. x y false 6. or=  x y. x true y

 -Functions 7. 0=  f x. x 8. 1=  f x. f x 9. 2=  f x. f (f x) 10. n=  f x. f n x 11. iszero=  n. n (  x. false) true 12. succ=  n f x. n f (f x) 13. add=  m n f x. m f (n f x)

 -Reduction Any abstraction of the form  x. (E x) in which x has no free occurrences in E can be reduced to E. For example  x. (succ x)   succ An abstraction which is  -reducible is called an  -redex.

Rationale for  -Reduction If x has no free occurrences in E, then  x. (E x)) A)   (E x) [ A | x ] = (E A) Thus the effect of  x. (E x)) on A is the same as the effect of E on A.

Normal Forms Def. A -expression is in normal form if it contains no  -redexes or  -redexes. A -expression has a normal form if there exists a finite sequence of reduction steps that results in a nromal form.

Examples of Normal Forms 1. x is in normal form 2. (  x. x x  (  y. y  is not in normal form but has a normal form, since (  x. x x  (  y. y   (  y. y  (  y. y    (  y. y 

Examples of Normal Forms 3. (  x. x x  (  y. y y  is not in normal form and has no normal form, since the reduction sequence does not terminate: (  x. x x  (  y. y y   (  y. y y  (  y. y y  ...

Reduction Order A -expression can contain several redexes. For example, (  x. (  y. y) (  z. z)) (  u. u) 1 5 An outer redex starts at character 1. An inner redex starts at character 5. In this case, more than one reduction sequence is possible.

Reduction Sequences Inner redex: (  x. (  y. y) (  z. z)) (  u. u)   (  x. (  z. z)) (  u. u)   (  z. z) Outer redex: (  x. (  y. y) (  z. z)) (  u. u)   (  y. y) (  z. z)   (  z. z) The normal form is the same for the two.

Reduction Sequences, Example 2 Inner redex: (  y.  z. z) ((  x. x x) (  x. x x))   (  y.  z. z) ((  x. x x) (  x. x x))  ... Outer redex: (  y.  z. z) ((  x. x x) (  x. x x))   (  z. z) 1st sequence is infinite. 2nd has normal form.

Reduction Strategies 1. Normal order strategy - repeatedly reduce the leftmost-outermost redex. 2. Applicative order strategy - repeatedly reduce the leftmost-innermost redex.

Normalization Theorem If a -expression  has a normal form, then the normal order strategy will terminate in a normal form. (Curry & Feys, 1958)

Church-Rosser Corollary The normal form of a -expression, if it exists, is unique.

Church’s Thesis The class of effectively computable functions is the same as the class of functions that can be defined in - calculus (1936)

Church’s Theorem The class of Turing-computable functions is the same as the class of - definable functions.

New Models Australian Mathematician, published a paper16 in late 2001 that stated that “incomputable” problems can be computed by exploiting the laws of Quantum Mechanics A Quantum computer would be able to perform an infinite search in a finite amount of time and hence would solve the halting problem and would show the computability of incomputable functions.

Question