Lambda Calculus
Last updated
Was this helpful?
Last updated
Was this helpful?
The syntax of LC defines some expressions (sequence of symbols allowed in LC) as valid and some as invalid. Lambda term is a valid LC expression.
These rules give an inductive definition that can be applied to build all syntactically valid lambda terms:
0: a variable (e.g. ) is a valid lambda term
1: if and are lambda terms, then is a lambda term
2: if and are lambda terms, then is a lambda term
nothing else is a lambda term.
Variables Above, the zero rule just states that is a lambda term, which would imply that on its own is a lambda term, but that's pretty vague; that alone is obviously not a function, and it couldn't stand for (represent) some other lambda term (that would be external binding). It can only be a free variable, meaning we're not seeing the entire expression; we have to zoom out to see the acual binding site for that .
, called a lambda abstraction. , called an application (function application, lambda application).
Application, , associate to the left: is
Abstraction, , associate to the right:
Assume given an infinite set of variables, denoted by The set of lambda terms is given by the following Backus-Naur Form ( and are lambda terms, is a variable):
Traditional definition:
Examples:
Variables: x
, y
Applications: xx
, xy
, (λx.(xx))(λy.(yy))
Abstractions: λx.x
, λf.ff
, λf.(λx.(f(fx)))
Abstraction and application: (λx.x)(2)
, ((λf.f(f))(λx.x+2))(3)
This, λx.x+1
, defines an anonymous function that takes a parameter x
and evaluates (returns) it to x+1
. This applies this function to the argument 5: (λx.x+1)(5)
; the 5 replaces the x
in the function's body, so this expression evaluates to 6.
Assume given an infinite set of variables
Let be an alphabet consisting of the elements of and the special symbols, , .
, (
, )
Let be the set of strings (finite sequences) over the alphabet
The set of lambda terms is the smallest subset such that:
Whenever then
Whenever then
Whenever and then