|
Slide 12.5: Syntax of the lambda calculus (cont.) Slide 12.7: Curried functions (cont.) Home |
|
sum(a,b) = a+b matches the
syntactic specification sum: N×N→N, where N denotes the natural numbers.
Lambda calculus admits two solutions to this problem:
<x,y>, and define the addition function on pairs:
sum <a, b> = a + b
add: N → N → N ≡ add: N → ( N → N ) (→ associates to the right)where
add a b = a + b.
An application of add has the form add a b, and is equivalent to (add a) b, since function application associates to the left.
In other words, applying add to one argument yields a new function which is then applied to the second argument.
Now (add a): N→N is a function with the property that ((add a) b) = a + b.
Using add, we can define inc:
inc = add 1