Lambda Calculus

1. Syntax

-calculus is the simplest programming language:

1.1 Free & Bound Variables

For example, in the following expressions, bound variables are and free variables are :

Terms which have no free variables are called closed terms. More formally, free variables are:

1.2 Substitution

For -equivalence, we can rename bound variables without changing the meaning of the term. For example, is -equivalent to . So, we check:

Formally, substitution is written as where is replaced by in . For example:

Or, more formally:

2. -Reduction

-reduction is the process of applying a function to an argument. For example, reduces to . More formally , where is the function and is the argument. In this example, is the function, is the argument. The result is obtained by replacing every occurence of the function parameter , with the argument , in the function body . Some rules for -reduction are:

An example of -reduction is shown below.

invert center screen Small

2.2 Normal Forms

A normal form is a term that cannot be reduced further. Critically, any term that has a normal form will eventually reach it. From the example above, we can see that sometimes, there are many different "pathways", or sequences of -reductions that can take place. However, no matter which pathway is chosen, the term will always reach the same normal form.

We call this pathway a multi-step--reduction, or . This multi-step reduction enforces the reflexive transitive closure of -reduction under -conversion:

Confluence states that . Or, visually:

invert center screen Small

-terms are -normal if they contain no redexes:

Normal forms are unique, i.e. . We can prove this using confluence.

-equivalence is the smallest equivalence relation that contains , or with symmetry. . Any two of the terms below are -equivalent:

invert center screen Small

2.3 Reduction Strategies

A redex means a reducible expression. For example, is a redex.

Not all -terms have a normal form. For example, has no normal form. The order of reduction also matters - some terms only have a normal form under certain reduction strategies.

Take a redex :

This provides a way to define many different reduction strategies:

3. Definability

A partial function is -definable iff there exists a closed -term with the following properties:

The Church-Turing Thesis states that a function is computable iff it is -definable. If a function is lambda-computable, it is also register-machine computable and Turing-machine computable, and vice versa.

3.1 Church Numerals

Church numerals are defined as .

To encode addition, we need a function . To do this, we must obtain the body of (), put it into the body of (), and then abstract over and : . Hence:

More encodings can be found for multiplication, exponentiation, if zero, and more:

3.2 Recursion

IKSTCVBB'W

Combinators are -terms with no free variables:

It is possible to define any computable function with just S, K, I and application, getting rid of the -abstraction. This is called the SKI combinator calculus.

Recursion can be easily defined with calculus. For example, the fact function:

However, we can also rewrite fact as . This means that fact is a fixpoint of . To help with this, we can define the famous Y-combinator:

This is important because step of -reduction leads to , which is the fixpoint equation. is the fixpoint operator. So:

Back to Home