Lambda Calculus

Formal Definition

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. xx) is a valid lambda term

  • 1: if xx and MM are lambda terms, then (λx.M)(\lambda x.M) is a lambda term

  • 2: if MM and NN are lambda terms, then (MN)(MN) is a lambda term

  • nothing else is a lambda term.

Variables Above, the zero rule just states that xx is a lambda term, which would imply that xx on its own is a lambda term, but that's pretty vague; that xx 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 xx.

, called a lambda abstraction. , called an application (function application, lambda application).

Application, MNMN, associate to the left: fxyzfxyz is ((fx)y)z((fx)y)z

Abstraction, λx.M\lambda x.M, associate to the right: λf.xyz\lambda f.xyz λf.(xyz)\lambda f.(xyz)

Assume given an infinite set V\mathcal{V} of variables, denoted by x,y,zx, y, z\dots The set of lambda terms is given by the following Backus-Naur Form (MM and NN are lambda terms, xx is a variable):

M,N::=x  (MN)  (λx.M)M, N ::= x \ |\ (MN)\ |\ (\lambda{x}.M)

Traditional definition:

  • Assume given an infinite set V\mathcal{V} of variables

  • Let AA be an alphabet consisting of the elements of V\mathcal{V} and the special symbols, λ\lambda, ., (, )

  • Let AA^∗ be the set of strings (finite sequences) over the alphabet AA

  • The set of lambda terms is the smallest subset ΛA\Lambda \subseteq A^∗ such that:

    • Whenever xVx\in \mathcal{V} then xΛx\in \Lambda

    • Whenever M,NΛM,N\in \Lambda then (MN)Λ(MN)\in \Lambda

    • Whenever xVx\in \mathcal{V} and MΛM\in \Lambda then λx.MΛ\lambda{x}.M \in \Lambda

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.

Last updated