Preliminaries
Calculus is a formal system for expressing computation in terms of function application and abstraction.
Info
Vanilla calculus is untyped (or type-free), that is, any function can be applied to any term. It is Turing complete (being allowed to consider expressions like allows us to simulate recursion), but you can easily write meaningless or non-terminating terms, like .
Application and abstraction are the two basic operations of the Calculus.
The expression denotes being considered as an operator being applied to being considered as data.
The other basic operation is abstraction: If is an expression containing , then denotes the function .
Notation
denotes an expression containing variable .
Abstraction binds the variables of the local scope.
- It is a notational convention that the bound variables that occur in an expression are always different form the free ones.
- Expressions that differ only in the names of bound variables are identical.
Iterated application uses association to the left
Dually, iterated abstraction used association to the right:
For arguments, we have (recall currying):
Using vector notation, we have
However, considering our notational convention from above, it would be more appropriate to write
The formal definitions
Definition 1( terms).
The set of -terms, denoted by , is built up from an infinite set of variables using application and abstraction:
It is a convention that lower case letters denote variables and upper case letters denote -terms. denotes that and are the same term or can be obtained from each other by renaming bound variables. We also associate iterated application to the left and iterated abstraction to the right.
Definition 2(free variables).
The set of free variables of , denoted by , is defined inductively as follows:
A variable in is said to be bound if it is not free.
Definition 3(Combinator).
is a closed -term (or combinator) if . The set of closed -terms is denoted by .
Variable convention: If occur in a certain mathematical context, then in these terms all bound variables are chosen to be different from the free variables.
Definition 4.
The result of substituting for the free occurrences of in , denoted by , is defined as follows:
Note that in the fourth clause of the above definition, it is not needed to say “Provided that “. By the variable convention, this is the case: is a bound variable in , and hence cannot be a free variable in .
Now, we can introduce the calculus as a formal theory:
Definition 5.
The principal axiom of the -calculus is
for all .
There are also the logical axioms:
and compatibility rules:
If is provable in the -calculus, then we write .
Thanks to the compatibility rules, one can replace subterms by equal terms in any term context. For example, , so .
The following lemma is clear from the principal axiom:
Lemma 6.
Fixed point theorem
Definition 7(Standard combinators).
Define standard combinators
Theorem 8(Fixed point theorem).
For all , there exists such that . More precisely, for all , there exists a fixed point combinator
such that .
Proof.
Define and . Then, □
Example 9.
Show that there exists such that for all , .
Let . Then, is a fixed point of , and
Note that taking also works.
Example 10.
Show that there exists such that for all , .
Let . Then,
so for all .
Alternatively, for a solution that does not use the fixed point combinator, let and :
More alternative solutions can be obtained by taking the s in in powers of :
Note that all the proofs converge when we obtain . In general, we have:
Church numerals
Definition 11(Notation for repeated application).
with and is defined inductively as follows:
Definition 12(Church numerals).
The Church numerals are defined by .
Theorem 13(Arithmetic on Church numerals).
Booleans and conditionals
Definition 15.
, , where and are the combinators defined here.
Note that if is a boolean, then
is equivalent to the -term
Definition 16.
For , define
Then, , and . can serve as an ordered pair.
We can use the pairing construction for an alternative representation of natural numbers.
Definition 17(Barendregt Numerals).
For each , the numeral is defined inductively as follows:
Lemma 18.
The exist combinators , and such that
Proof.
Take
□
Definition 19(Lambda definability).
A numeric function is a map for some . In this case, is called -ary.
A numeric -ary function is called -definable if for some combinator ,for all , in which case, is said to be -defined by .