User:Thepigdog/Lambda Calculus - standard definition

The standard definition of Lambda Calculus uses some definitions which I would prefer to consider as theorems, which can be proved based on the Canonical naming definition.

The canonical naming definition deals with the problem of variable identity by constructing a unique name for each variable based on the position of the lambda abstraction for the variable name in the expression.

This definition introduces the rules used in the standard definition and relates explains them in terms of the canonical renaming definition.

Free and bound variables

edit

The lambda abstraction operator, λ, takes a formal parameter variable and a body expression. When evaluated the formal parameter variable is identified with the value of the actual parameter.

Variables in a lambda expression may either be "bound" or "free". Bound variables are variable names that are already attached to formal parameter variables in the expression.

The formal parameter variable is said to bind the variable name wherever it occurs free in the body. Variable (names) that have already been matched to formal parameter variable are said to be bound. All other variables in the expression are called free.

For example, in the following expression y is a bound variable and x is free:  . Also note that a variable is bound by its "nearest" lambda abstraction. In the following example the single occurrence of x in the expression is bound by the second lambda:  

Changes to the substitution operator

edit

In the definition of the Substitution Operator the rule,

  •  

must be replaced with,

  1.  
  2.  

This is to stop bound variables with the same name being substituted. This would not have occurred in a canonically renamed lambda expression.

For example the previous rules would have wrongly translated,

 

The new rules block this substitution so that it remains as,

 

Transformation

edit

The meaning of lambda expressions is defined by how expressions can be transformed or reduced.[1]

There are three kinds of transformation:

  • α-conversion: changing bound variables (alpha);
  • β-reduction: applying functions to their arguments (beta), calling functions;
  • η-conversion: which captures a notion of extensionality (eta).

We also speak of the resulting equivalences: two expressions are β-equivalent, if they can be β-converted into the same expression, and α/η-equivalence are defined similarly.

The term redex, short for reducible expression, refers to subterms that can be reduced by one of the reduction rules.

Alpha Conversion

edit

Alpha-conversion, sometimes known as alpha-renaming,[2] allows bound variable names to be changed. For example, alpha-conversion of   might give  . Terms that differ only by alpha-conversion are called α-equivalent.

In an alpha conversion, names may be substituted for new names if the new name is not free in the body, as this would lead to the capture of free variables.

 

Note that the substitution will not recurse into the body of lambda expressions with formal parameter   because of the change to the substitution operator described above.

See example;

Alpha conversion Lambda Expression Canonically named Comment
    Original expressions.
correctly rename y to k, (because k is not used in the body)     No change to canonical renamed expression.
naively rename y to z, (wrong because z free in  )       is captured.

Beta reduction (capture avoiding)

edit

Beta-reduction captures the idea of function application (also called a function call), and implements the substitution of the actual parameter expression for the formal parameter variable. Beta-reduction is defined in terms of substitution.

If no variable names are free in the actual parameter and bound in the body, beta reduction may be performed on the the lambda abstraction without canonical renaming.

 

Alpha renaming may be used on   to rename names that are free in   but bound in  , to meet the pre-condition for this transformation.

See example;

Beta Reduction Lambda Expression Canonically named Comment
    Original expressions.
Naive beta 1,  
Canonical  
Natural  
x (P) and y (PN) have been captured in the substitution.

Alpha rename inner, x -> a, y -> b

   
Beta 2,  
Canonical  
Natural  
x and y not captured.
  1.  
  2.  

In this example,

  1. In the beta-redex,
    1. The free variables are,  
    2. The bound variables are,  
  2. The naive beta-redex changed the meaning of the expression because x and y from the actual parameter became captured when the expressions were substituted in the inner abstractions.
  3. The alpha renaming removed the problem by changing the names of x and y in the inner abstraction so that they are distinct from the names of x and y in the actual parameter.
    1. The free variables are,  
    2. The bound variables are,  
  4. The beta-redex then proceeded with the intended meaning.

Eta reduction

edit

Eta-conversion expresses the idea of extensionality, which in this context is that two functions are the same if and only if they give the same result for all arguments.

Eta reduction may be used without change on lambda expressions that are not canonically renamed.

 

The problem with using an eta-redex when f has free variables is shown in this example,

Reduction Lambda expression Beta-reduction
   
Naive eta-reduction    

This improper use of eta-reduction changes the meaning by leaving   in   unsubstituted.

Normalization

edit

The purpose of beta-reduction is to calculate a value. A value in Lambda Calculus is a function. So beta-reduction continues until the expression looks like a function abstraction.

An lambda expression that cannot be reduced further, by either beta-redex, or eta-redex is in normal form. Note that alpha-conversion may convert functions. All normal forms that can be converted into each other by alpha conversion are defined to be equal. See the main article on Beta normal form for details.

Normal Form Type Definition.
Normal Form No beta or eta reductions are possible.
Head Normal Form In the form of a lambda abstraction whose body is not reducible.
Weak Head Normal Form In the form of a lambda abstraction.
edit

References

edit
  1. ^ de Queiroz, Ruy J.G.B. "A Proof-Theoretic Account of Programming and the Role of Reduction Rules." Dialectica 42(4), pages 265-282, 1988.
  2. ^ Turbak, Franklyn; Gifford, David (2008), Design concepts in programming languages, MIT press, p. 251, ISBN 978-0-262-20175-9