User:Thepigdog/Deductive Lambda Calculus

Deductive Lambda Calculus considers what happens when lambda expressions are regarded as mathematical expressions. Lambda calculus is defined as a programming language where evaluation proceeds by performing reductions on an expression until it is in normal form. Considered as mathematics, each reduction would not alter the value of the expression. The expression would equal the reduction of the expression.

History

edit

Alonzo Church invented the Lambda Calculus in the 1930s, originally to provide a new and simpler basis for mathematics[1][2]. However soon after inventing it major logic problems were identified with the definition of the Lambda Abstraction[3].

The Kleene–Rosser paradox is an implementation of Richard's paradox in Combinatory logic. Combinatory Logic is closely related to Lambda Calculus. Haskell Curry found that the key step in this paradox could be used to implement the simpler Curry's Paradox. The existence of this paradox meant that the Combinatory Logic, and Lambda Calculus, could not be both consistent and complete as a deductive system[4].

Later the Lambda Calculus was resurrected as a definition of a programming language.

Interpretation of Lambda calculus as mathematics

edit

In the mathematical interpretation, lambda expressions represent values. Eta and beta reductions are deductive steps that do not alter the values of expressions.

Eta reduction as mathematics

edit

An eta-redex is defined by,

 

In the mathematical interpretation,

 

Taking f to be a variable then,

 

or by letting  

 

This definition defines   to be the solution for f in the equation,

 

Beta reduction as mathematics

edit

A beta redex is,

 

and as,

 

then,

 

This rule is implied by the instantiation of quantified variables. If,

 

then   is the expression y with the quantified variable x instantiated as z.

 

so,

 

As beta reduction is implied from eta reduction, there is no contradiction between the two definitions.

Logical inconsistency

edit

From eta reduction,

 

This rule may be interpreted as defining   to be the solution of the equation  . In defining the solution to the equation in terms of x and y the definition implicitly assumes that there is one and only function f that satisfies the equation. However, for some equations there may be none or multiple solutions. The definition may be compared with defining   by,

 

This is not a valid definition as the equation   has two solutions. The proper definition is,

 

An expression in mathematics may represent multiple values if it has free variables. The variables may be existentially quantified. Existential quantification turns an equation into a disjunction of equations, with each variable populated with single value in each equation.

The solution set for   in   is,

 

For the definition   to be valid there must be only one solution in this solution set. Using the definition of function equality;

 

The left hand side may often be shown to be false where  

No solutions

edit

Starting with the equation,

 

defining   gives,

 

or

 

The cardinality is,

 

so it is not valid to get,

 

If we go ahead anyway and translate the let expression into lambda calculus,

 

Then,

 

There is no solution to the equation, and the value does not exist.

Multiple solutions

edit

Also it is possible to construct lambda expressions for which there are multiple values. For example,

 

gives,

 

Defining  

 

or,

 

The cardinality is given by,

 

If we go ahead anyway and translate the let expression into lambda calculus,

 

Then,

 

so,

 

Discussion

edit
 

Every variable, except an argument, is implicitly existentially quantified. Parameters are implicitly universally quantified.

Existentially and universally quantified variables skolemizing.

Mathematical statement with Existentially and universally quantified variables as a disjunction of conjunctions.

The effects of copying an expression.

Deconstructing Lambda calculus

edit

The alternate definition,

 

is valid in mathematics. Call mathematics with this definition deductive lambda calculus.

Translation function

edit

Define a translation function between deductive and normal lambda calculus.

Existentially qualified variables

edit

The locality implied by Lambda calculus semantics may be achieved by a one off unique renaming of the variables. This renaming may only be done once in the translation of Lambda calculus into Mathematics.

Implied variables

edit

The meaning of a Lambda calculus program may be taken to be that every anonymous function definition has a unique variable associated with it. So Lambda calculus may be translated into a deductive, mathematical form by adding these implied variables. Beta-reduction on anonymous functions may change the meaning of the program, unless the implied variable is carried.

Changes to a Deductive program induced by reductions

edit

Deduce the changes to the Deductive Lambda Calculus program made by,

  • Beta reduction
  • Alpha reduction

Two copies of a lambda abstraction, created by beta-reduction must have the same value in each dis-junction.

Beta reduction on an anonymous function changes the meaning

edit

Two copies may have separate values. In Deductive LC one value.

Alpha renaming

edit

Alpha-renaming after beta-reduction may change the meaning of the expression. This is because beta reduction may create multiple copies of an abstraction. The abstractions share the same variable and must have the same value in each dis-junction.

Alpha renaming is wrong.

A function is not a canonical value

edit

Due to the undecidability of equivalence from Church's theorem in general it is not possible to prove that two functions are equal. Functions are not an appropriate choice as values because there is no canonical representation of a function. The intrinsic view of a function as a rule does not allow for the application of mathematical laws to a function to transform it into an equivalent function.

Implicit Variable Semantics

edit

Implicit variable semantics resolves the problems of lambda expressions by creating implicit variables to hold the values. To describe this firstly I will introduce the "let" expression, as a mathematical object. The "let" expression is implemented in many functional languages.

Let Expression

edit

The expression,

 

is defined by,

  1.   where f is a tuple of the free variables of C
  2.  

[1] moves the condition C out. In [2] if B is a Boolean the let expression is the conjunction of C and B.

Redefining the lambda expression

edit

A lambda expression with an explicit variable may be defined as,

 

Cardinality

edit

The meta function "implicit" converts the explicit variable lambda expression into the implicit form, by removing all the implicit variables in the expression.

 

The two expressions are equivalent if the cardinality of the expression is 1.

 

Example 1. k can not be dropped in,

 

because,

 
 
 
 

Example 2.

 

equals

 

because,

 
 
 
 

Example 3. k cannot be dropped in,

 

because,

 
 
 
 
 

Cardinality and termination

edit

If a lambda expression terminates (the series of reductions reaches a normal form), then this series of reductions shows that the original expression equals the reduction value. Therefore the cardinality of the expression is one and the implicit variable may be dropped.

The inverse is not necessarily true. Proving that an expression has a cardinality of one does not prove that it terminates. In particular the fixed point combinator Y may never terminate, when applied to a function, even where the functions has a single fixed point.

Implicit variable

edit

Most lambda expressions have a cardinality of 1. Lambda expressions with a cardinality other than 1 do not obey mathematical rules. In particular substitution may not be performed.

Non-mathematical lambda expressions may be converted to mathematics by the "explicit" meta function, which realizes the implied variables.

 

where k is a unique variable implicitly defined with scope defined using implicit scoping rules.

Intrinsic versus extrinsic equality

edit

The untyped lambda calculus is implemented by performing reductions on a lambda term, until the term is in normal form. The intrinsic interpretation of equality is that the reduction of a lambda term to normal form is the value of the lambda term.

This interpretation considers the identify of a lambda expression to be its structure. Two lambda terms are equal if they are alpha convertible.

The mathematical (or extrinsic) definition of function equality is that two functions are equal if they perform the same mapping;

 

The extrinsic definition of equality is incompatible with the intrinsic definition. This can be seen in the example below, where applying a mathematical law changes a function to an equivalent function, yet the intrinsic interpretation of equality says that the two functions are not equal.

This incompatibly is created by considering lambda terms as values. In typed lambda calculus this is not a significant problem, because built in types may be added to carry values that are in a canonical form and have both extrinsic and intrinsic equality.

Example

edit

In arithmetic the distributive law implies that  . Using the Church encoding of numerals the left and right hand sides may be represented as lambda terms.

Left hand side;

 
 
 

Right hand side;

 
 
 

Comparison;

 
 

The two expressions beta reduce to remarkable similar expressions. Still they are not alpha convertible, so according to intrinsic equality, the distributive law does not hold.

edit

References

edit
  1. ^ A. Church, "A set of postulates for the foundation of logic", Annals of Mathematics, Series 2, 33:346–366 (1932).
  2. ^ For a full history, see Cardone and Hindley's "History of Lambda-calculus and Combinatory Logic" (2006).
  3. ^ Kleene, S. C.; Rosser, J. B. (1935). "The inconsistency of certain formal logics". Annals of Mathematics. 36 (3): 630–636. doi:10.2307/1968646. {{cite journal}}: Unknown parameter |lastauthoramp= ignored (|name-list-style= suggested) (help)
  4. ^ The Inconsistency of Certain Formal Logic Haskell B. Curry The Journal of Symbolic Logic Vol. 7, No. 3 (Sep., 1942), pp. 115-117 Published by: Association for Symbolic Logic Article Stable URL: http://www.jstor.org/stable/2269292