Professional Documents
Culture Documents
In mathematics function application is written as f(2), but in the lambda calculus (and Lisp) function application is written as (f 2). Appling a function is evaluation is -reduction. Application has higher precedence than abstraction. Application is left-associative. So that s t x (s t) x and (f a b c) (((f a) b) c) (BTW: We see the same in arithmetic: 1 2 3 = 4 (12)3 1(23) = 1(1) = 2) As a lambda expression (x. y. z.xyz) 1 2 3 (x. (y. (z.xyz))) 1 2 3 (y. (z.1yz)) 2 3 (z.12z)) 3 (z.1z)) 3 (13) Abstraction is right-associative. So the scope of extends as far to the right as possible. So x.y.x y (x.(y.(x y))) and x.x z y.x y x.((x z) (y.(x y)))
Complicated Example
Consider (m. n. a. b. m (n a b) b) (f. x. x) (f. x. f x) First we introduce explicit parentheses everywhere to avoid confusion ((m. n. a. b. m ((n a) b) b) (f. x. x)) (f. x. f x) Application has higher precedence and it is right associative ((m. ( n. (a. (b. (m ((n a) b) b))))) (f. (x. x))) (f. (x. ( f x))) Abstraction () is
left associative and extends as far as possible Now we can start with the reduction: (m. ( n. (a. (b. (m ((n a) b) b)))) (f. (x. x))) (f. (x. ( f x))) Bind m to (f. (x. x))
=> n. (a. (b. ((f. (x. x)) ((n a) b) b))) (f. (x. ( f x))) Bind n to (f. (x. ( f x))) => ( a. (b. ((f. (x. x)) (((f. (x. ( f x))) a) b) b)) ) Nothing bound to a and b => a. b. ((f. (x. x)) ((. (x. ( f x)) ) b) b) => a. b. ((f. (x. x)) ((. ( a x)) ) b) => a. b. (f. (x. x) ( a b) b) => a. b. ((x. x) b) => a. b. b Bind f to a (we could have left the outer parentheses Bind x to b Bind f to (a b) and discard since no f in expression Bind x to b (identity) Done (did not have to remove parentheses)