# The Lambda Calculus

## Some history

• 1932: Alonzo Church develops the (type-free) Lambda Calculus as part of a general theory of functions and logic, intended as a foundation for mathematics. The whole system was proved inconsistent by Kleene and Rosser, but the Lambda Calculus (taken alone) was proved consistent.
• 1936: Kleene proves that all recursive functions can be represented in the Lambda Calculus.
• 1937: Turing proves that every function computable by a Turing machine can be represented in the Lambda Calculus, and viceversa.
• In the same years, Church formulates the statement which is known as Church's Thesis: These systems (Lambda Calculus, Turing machines, Recursive functions, and other proposed formalisms) characterize the notion of computability. Namely, every function which can ever be computed algoritmically can be defined in any of these systems. This statement cannot be proved, of course, because the notion of "algoritmic computability" is not defined formally. Actually, this statement can better be understood as a proposal for the definition of this notion.
• Based on the Lambda Calculus, a class of programming languages have been developed: the so-called Functional Languages (Lisp, Scheme, ML, Askell, ...)

## Type-Free Lambda Calculus

### Sintax

The terms of the lambda calculus are constructed over variables and two basic operations:
• Abstraction: if M = M[x] is an expression depending on x, then \x.M[x] denotes the mapping x |-> M[x]. Namely the function that, for each term x, gives the term M[x]. The symbol "\" stands for the Greek letter lambda.

Example (assuming a language enriched with numerical constant and primitive operations): (\x. x+1) represents the function which, on input x, outputs x+1.

• Application: M N represents the function M applied to the argument N.

#### Formal syntax

Variables: V ::= x | y | z | ...
Lambda-Terms: M ::= V | (\V M) | (M M)

#### Notational convention

M1M2 ... Mk stands for ( ... (M1M2) ... Mk)
\x1x2 ... xk.M stands for (\x1(\x2 ... (\xk M) ... ))

#### Free and Bound variables

An occurrence of x is free in M if it is not in the scope of a \x (i.e. is not in a subterm of M of the form \x.N). Is is bound (by the innermost such \x) otherwise. The free variables of M are all the variables which occur free in M. Formally:
FV(x) = {x}
FV(\x.M) = FV(M) - {x}
FV(M N) = FV(M) union FV(N)

#### Alpha conversion

The alpha conversion (or alpha renaming) axiom formalizes the concept that "the names of bound variables don't matter". Formally:
\x.M =alpha \y.M[y/x]
provided that y is neither free nor bound in M.

#### Substitution

Given a term M, a variable x, and a term N which does not contain free any of the bound variables of M, the term M[N/x] (also denoted by M[x:=N]) is the term obtained from M by replacing every free occurrence of x by N.

The condition "N does not contain free variables which occur bound in M" is meant to avoid "variable capture". For example, given M = \y.xy, and N = y, if we simply replace x by N in M, we would obtain the term \y.yy, which is intuitively incorrect since y, which was free in N, has become bound in M[N/x].

Variable assumption: To avoid the problems related to the "variable capture", we will assume that the free variables are different from the variables which occur bound. Note that this assumption is not restrictive since we can always alpha-rename the bounded variables. Another solution would be to define the notion of substitution so that it renames the variables automatically when needed. For this approach see for instance Hindley and Seldin, Definition 1.1.

#### Beta conversion

The beta axiom formalizes the concept of transformation which takes place when a function is applied to an argument. Formally:
(\x.M) N =beta M[N/x]
where the variable convention is adopted so to avoid variable capture.

Example: (\x. x+1) 5 =beta 5+1 = 6

#### The theory of lambda calculus

We will say that M = N is provable in the lambda calculus, or that M and N are lambda-convertible (notation: |- M = N or simply M = N) if M = N can be derived using the alpha axiom, the beta axiom, associativity, reflexivity, transitivity, and the following rules:
• M = N => M P = N P (Congruence 1)
• M = N => P M = P N (Congruence 2)
• M = N => \x.M = \x.N (Xi rule)