 | Lambda calculus: Encyclopedia II - Lambda calculus - Formal definition
Lambda calculus - Formal definition
Formally, we start with a countably infinite set of identifiers, say {a, b, c, ..., x, y, z, x1, x2, ...}. The set of all lambda expressions can then be described by the following context-free grammar in BNF:
- <expr> ::= <identifier>
- <expr> ::= (λ <identifier>. <expr>)
- <expr> ::= (<expr> <expr>)
The first two rules generate functions, while the third describes the application of a function to an argument. Usually the parentheses for lambda abstraction (rule 2) and function application (rule 3) are omitted if there is no ambiguity under the assumptions that (1) function application is left-associative, and (2) a lambda binds to the entire expression following it. For example, the expression ((λ x. (x x)) (λ y. y)) can be simply written as (λ x. x x) λ y. y.
Lambda expressions such as λ x. (x y) do not define functions because the occurrence of the variable y is free, i.e., it is not bound by any λ in the expression. The binding of occurrences of variables is (with induction upon the structure of the lambda expression) defined by the following rules:
- In an expression of the form V, where V is a variable, this V is the single free occurrence.
- In an expression of the form λ V. E, the free occurrences are the free occurrences in E except those of V. In this case the occurrences of V in E are said to be bound by the λ before V.
- In an expression of the form (E E′), the free occurrences are the free occurrences in E and E′.
Over the set of lambda expressions an equivalence relation (here denoted as ==) is defined that captures the intuition that two expressions denote the same function. This equivalence relation is defined by the so-called alpha-conversion rule and the beta-reduction rule.
Lambda calculus - α-conversion
The alpha-conversion rule is intended to express the idea that the names of the bound variables are unimportant; for example that λx.x and λy.y are the same function. However, the rule is not as simple as it first appears. There are a number of restrictions on when one bound variable may be replaced with another.
The alpha-conversion rule states that if V and W are variables, E is a lambda expression, and
E[V := W]
means the expression E with every free occurrence of V in E replaced with W, then
λ V. E == λ W. E[V := W]
if W does not appear freely in E and W is not bound by a λ in E whenever it replaces a V. This rule tells us for example that λ x. (λ x. x) x is the same as λ y. (λ x. x) y.
Lambda calculus - β-reduction
The beta-reduction rule expresses the idea of function application. It states that
((λ V. E) E′) == E[V := E′]
if all free occurrences in E′ remain free in E[V := E′].
The relation == is then defined as the smallest equivalence relation that satisfies these two rules.
A more operational definition of the equivalence relation can be given by applying the rules only from left to right. A lambda expression which does not allow any beta reduction, i.e., has no subexpression of the form ((λ V. E) E′), is called a normal form. Not every lambda expression is equivalent to a normal form, but if it is, then the normal form is unique up to naming of the formal arguments. Furthermore, there is an algorithm for computing normal forms: keep replacing the first (left-most) formal argument with its corresponding concrete argument, until no further reduction is possible. This algorithm halts iff the lambda expression has a normal form. The Church-Rosser theorem then states that two expressions result in the same normal form up to renaming of the formal arguments iff they are equivalent.
Lambda calculus - η-conversion
There is a third rule, eta-conversion, which may be added to these two to form a new equivalence relation. Eta-conversion expresses the idea of extensionality, which in this context is that two functions are the same iff they give the same result for all arguments. Eta-conversion converts between λ x. f x and f whenever x does not appear free in f. This can be seen to be equivalent to extensionality as follows:
If f and g are extensionally equivalent, i.e. if f a==g a for all lambda expressions a, then in particular by taking a to be a variable x not appearing free in f nor g we have f x == g x and hence λ x. f x == λ x. g x, and so by eta-conversion f == g. So if we take eta-conversion to be valid, we find extensionality is valid.
Conversely if extensionality is taken to be valid, then since by beta-reduction for all y we have (λ x. f x) y == f y, we have λ x. f x == f; i.e., eta-conversion is found to be valid.
Other related archives1930s, Actor model, Alonzo Church, Anonymous recursion, BNF, Church numerals, Church-Rosser theorem, Church-Turing thesis, Curry-Howard isomorphism, Entscheidungsproblem, Funarg problem, Gödel number, Gödel numbering, Gödel's first incompleteness theorem, H.P. Barendregt, Jean-Yves Girard, Lambda cube, Lisp, Process calculi, Recursion, Russell's paradox, SKI combinator calculus, Stephen Cole Kleene, System F, Turing machine, Typed lambda calculus, Unlambda, Y combinator, algorithm, calculus of constructions, combinator, combinatory logic, computability, computable function, computer science, concurrency, constants, context-free grammar, countably infinite, currying, datatypes, equivalence relation, extensionality, factorial, formal system, function, functional programming languages, halting problem, higher-order function, if and only if, iff, induction, left associative, natural numbers, parallelism, programming languages, recursion, set, typed lambda calculi, unbounded nondeterminism, undecidability, up to
 Adapted from the Wikipedia article "Formal definition", under the G.N U Free Docmentation License. Please also see http://en.wikipedia.org/wiki |