Normal order reduction will perform reductions both inside and outside
abstractions. If we wish to regard reduction as a model of
computation then only reductions outside of
abstractions can be
regarded as corresponding to running a program. Reductions inside a
-abstraction
are in effect manipulating program, something that is
usually done by a compiler. Thus we introduce the ideas of weak normal
order reduction and weak normal form in which the only reductions
performed are performed outside of any
-abstraction. This is also
called call by name, and is safe in the sense that if a
weak normal form exists, weak normal order reduction will find it.
Recall that normal order reduction takes the leftmost outermost redex. An alternative strategy is to take the leftmost innermost redex. This is call by value and is unsafe in the sense that an infinite sequence of reductions may arise despite the fact that a (weak) normal form exists.
Nevertheless most languages use some kind of call by value for almost all reductions because it is easier to implement efficiently than call by name (call by reference does not really make sense from the functional point of view).
Russell and Whitehead's approach would require us to have a typed
-calculus. Such a edifice can be built, and is indeed a very desirable mansion
that actual programming languages may inhabit. However that elegant
creature the Y combinator cannot dwell therein.
But it is not mathematically necessary to have a typed -calculus: it was shown in
1969 by Scott and Strachey that it is possible to devise an interpretation
of the untyped
-calculus in ZF set theory.
Answer:
To make the -calculus suitable as a basis for
practical computation we need to introduce entities which correspond to the
capabilities of a real computer on which a program will run.
A minimal capability would be provided by
with the property that (if true E1E2) evaluates to E1, and (if false E1E2) evaluates to E2, and
In secondary school we learned that expressions can be ``worked out'' or
evaluated, by substitution and arithmetic. Thus x+2, with x=4,
evaluates to 6. -
and
- reduction play the `working out'
role for
-calculus. However we also learned ways of determining that two
expressions were identically equal. Thus x+2 and 2+x are
identically equal in school algebra. In this section we want to examine the
question `can we say whether two expressions in the
-calculus are equal?'.
In school algebra the symbols stand for numbers. In the -calculus
they stand for, or as we say denote, functions (and other entities as
well if we have added constants to make our
-calculus impure). It turns out to be
non-trivial to develop a theory of denotation for the
-calculus - it took
mathematicians nearly 30 years to come up with a satisfactory one, which we
will not discuss here. However we will use some informal ideas of
denotation in our discussion.
For example we may say that x. + x 3 denotes the
function `add 3', which is commonly regarded formally as the infinite set
{... (-4,-1), (-3,0), (-2,1),(-1,2),(0,3),(1,4)...} of pairs of
integers - you might think of it as a graph drawn on an infinite piece of
graph paper.
Thus we will discuss, informally, some rules that allow us to say that two
expressions in the -calculus always denote the same thing.
The -calculus is a powerful formalism, capable of expressing any computation. We
know we can't decide whether two programs perform the same
computation, so we should not expect to be able to decide whether two
-calculus expressions are equal - we may be able to say `yes for sure', `no for
sure', or `I can't tell'.
The -reduction rule that we have already met can also be used as a
equality inference rule - in both directions.