Lambda calculus is the basis of functional programming. It deals with the definition and evaluation of functional expressions. We take a complex expression and successively reduce (transform) it to reach a final canonical form. For the sake of brevity we shall give an incomplete, slightly inaccurate presentation of lambda calculus. The subject itself is beyond the scope of this project; a good self-sustained introduction to lambda calculus, and a nice build-up into functional programming is given in [SLPJ87].
An expression in lambda calculus is one of the following:
.
where
specifies that
is the name of the function argument, and
is the function body (which can be a compound expression).
, where
is a function expression (a lambda abstraction).
or a constant
).A variable is bound in an expression if it appears as a function argument, and the expression is inside the function definition. For example
is bound in
. Otherwise, a variable is free.
Functions can only take a single argument. When more are needed, we can nest functions:
takes
, and returns a function that takes
. This is known as currying (after the logician Haskell Curry). A common abbreviation is to write
in place of the nested expression.
Lambda calculus also defines rules for transforming expressions (reduction rules):
-conversion: Changing the name of a bound variable. For example,
.
appears free in the expression
we can perform a substitution, replacing
with another expression. We denote it like this:
. You can think of it as ‘dividing’
by
and ‘multiplying’ by
.
-reduction: Function application. This rule transforms
into
, using substitution.
-conversion: Reduces ‘redundant’ functions. An expression
can be
-converted to
, because the two expressions are equivalent.Note that recursion is not allowed, which seems to strictly limit the expressiveness of the language. Fortunately, there turns out to be a function that we can define inside lambda calculus (the ‘Y-combinator’) that essentially allows recursion.
The aforementioned ‘canonical form’ is a unique, final minimal expression (not further reducible) that is guaranteed to exist by the Church-Rosser theorem. There is a specific reduction order that must be taken in order to reach the canonical form.
Here are a few examples of expressions:
is the identity function. For example, the function application
evaluates to
for any
.

Applying
gives the following transformations:

Thus, we have:



Church took the next step to also define functions for addition, multiplication, subtraction, exponentiation, etc.