


































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



































































c 2005 by Spencer Rugaber
One way to understand basic programming languagedesign issues is to look at very simple languages
-^
The
λ
-calculus has traditionally served this role. It
was invented before computers by the logicianChurch and refined by Kleene and Landin
-^
It contains only one type of value, the function, and itssyntax is minimal
-^
Moreover, its semantics consist of nothing more thanstring rewriting
-^
Functional programming languages, like SML, providethe features of the
λ
-calculus with a more traditional
syntax
c 2005 by Spencer Rugaber
The
λ
-calculus, like any language, is a notation for
denoting computations. The denotations are called
λ
expressions
-^
As such, it provides ways of expressing operations andoperands– The only operations are function definition and
application
Syntactically, the formal operands are denoted byidentifiers (usually a single character variable name).The actual operands are themselves
λ
-expressions
Semantically, the meaning of a
λ
-expression is defined
by three simple rules describing how to textuallysimplify (rewrite) it
c 2005 by Spencer Rugaber
Syntactic sugar
stand for other
λ
-expressions
λx, y. x
2
instead of
λx. (
λy. x
2
(
(λ
role:
variables
applications
abstractions
examples:
x^
(f x)
(λ
x. (f x))
c 2005 by Spencer Rugaber
Although there are no literals in the
λ
-calculus,
λ
expressions can be given that denote all of theconstructs from traditional programming languages,such as truth values, numbers, and lists
-^
For the time being, we will assume that this has beendone, and abbreviate the results with literals like
(for
) and
Consequently, many of the examples will evaluate tonumbers or truth values
-^
Formally, however, the only values in the
λ
-calculus
are functions - another reason it is so simple
c 2005 by Spencer Rugaber
c 2005 by Spencer Rugaber
The semantics of the
λ
-calculus are defined in terms of
simple textual manipulation operations
bound
and
free
variables must first be
presented
substitution
must be given
α
-conversion,
β
-reduction, and
η
reduction, are then presented
are applied
λ
-abstractions
must be addressed
c 2005 by Spencer Rugaber
2
2
− "That function of
x
and
y
which is
x
2
2
c 2005 by Spencer Rugaber
-^
c 2005 by Spencer Rugaber
That is, just replace
with
That is, there is no substitution to be made
c 2005 by Spencer Rugaber
c 2005 by Spencer Rugaber
c 2005 by Spencer Rugaber
c 2005 by Spencer Rugaber
That is, there are no conflicts with parameternames to worry about, so just substitute into thebody of the abstraction
c 2005 by Spencer Rugaber
That is, there is a naming conflict with the parameterof the abstraction
. The parameter must be
renamed and the new name
substituted into
Then the substitution of
for
can be made