lambda-calculus-slides
lambda-calculus-slides
Lecture 3
January 30, 2020
Lambda Calculus
Alonzo Church
What is a computation/algorithm?
Church (1936):
Invents lambda calculus,
claims it should be the definition.
For example: (+ 4 5)
((+ 3) 4)
IF TRUE E1 E2 ➞ E1
IF FALSE E1 E2 ➞ E2
(Later we’ll see that the expressive power of our language is not
enhanced by any of these, by showing how to `implement’ these.)
Writing Your Own Functions – Lambda Abstractions
A way to write expressions that denote functions.
Example: (λx . + x 1)
(λx . + x 1) 5 ➞ 6
(λx. + x y) 4
(λx. + x 1) 4 ➞β + 4 1
β-Reduction (some more examples)
(λx. + x x) 5 ➞ + 5 5 ➞ 10
(λx. 3) 5 ➞ 3
It never terminates!
Solution: Greed: Find any vertex with current degree < 4. Delete
it. Repeat.
Exercise theorem: Any run of this algorithm will find the same
solution, which is the unique optimal one.
The Church-Rosser Property
This is an example of a reduction system with the Church-Rosser
Property.
λn.if (= n 0) 1 (* n (f (- n 1)))
(λf.λn.if (= n 0) 1 (* n (f (- n 1))))
Now if we write
FACT FACT 5
H = λf.λn.if (= n 0) 1 (* n (f (- n 1)))
λx.λy.x λx.λy.y
(λx.λy.x) a b ➞ a
(λx.λy.y) a b ➞ b
AND A B = A B FALSE
AND = λa.λb. a b a
Easy exercise: Work out OR and NOT.
What about Numbers?
Look at these normal form expressions….
λf.λx x 0
λf.λx f x 1
λf.λx f (f x) 2
λf.λx f (f (f x)) 3
λf.λx f (f (f (f x))) 4
PROD m n = λf.λx. m (n f) x
PROD = λm.λn.λf.λx. m (n f) x
Subtraction
PAIR := λx.λy.λf. f x y
0 0 0 0 1 1