Example 3.1.3.
Recall the earlier example. If
M
= (
λx
·
xx
), then the
β
-reduction of
MM
does
not terminate.
Suppose we have a projection function
P
= (
λxy
·
x
), that projects out one of the arguments
alone, then we know that the reduction
PMM
terminates in
M
.
You can use these two observations to construct two reduction sequences for the following
expression, one which terminates, and another which does not.
(
λxyz
·
xz
(
yz
))
PMM.
So the answer to even our second question is no.
3.2
Church-Rosser Theorem
However, we could ask for a simpler requirement. If two reduction sequences terminate, do they
terminate in the same normal form? The following is a classical result in
λ
-calculus.
Theorem 3.2.1.
If
M
*
-→
M
1
and
M
*
-→
N
1
, then there exists a
P
such that
M
1
*
-→
P
and
N
1
*
-→
P
.
That is, there is at most one normal form of any
λ
-term. Of course, some terms may not have
normal forms at all, as discussed in the previous subsection.
We omit the proof of this theorem.
4

** Subscribe** to view the full document.

4
Abstract Data Types
We now see how to implement some abstract data types in
λ
-calculus.
4.1
Numbers
One encoding of the numbers we consider is the following.
True
=
⇒
0
≡
λxy.y
n
=
λxy.M
=
⇒
n
+ 1
≡
λxy.x
(
M
)
Thus
1
≡
λxy
·
x
(
y
)
2
≡
λxy
·
x
(
x
(
y
))
3
≡
λxy
·
x
(
x
(
x
(
y
)))
and so on.
One way to think about this encoding is that it is the unary representation of natural numbers. Consider
the expression
0
xy
=
y
. This can be thought of as a “blank board”. The expression
nxy
can be thought of as
one obtained by making
n
number of
x
marks on the blank board.
This notation makes it possible for us to do arithmetic operations.
•
Successor is defined to satisfy Successor(n) = n+1. This can be encoded as the function
(
λnxy
·
x
(
nxy
))
Verify that Successor(
n
) is a representation of
n
+ 1.
•
Addition of two numbers
m
and
n
should return
m
+
n
.
(
λmnxy
·
mx
(
nxy
) )
.
•
Multiplication of two numbers
m
and
n
should return their product.
(
λmnx
·
m
(
nx
))
.
4.2
Booleans
Define False to be (
λxy
·
y
). We denote this by the reserved term
F
. Note that False has the same
representation as 0. True is defined as (
λxy
·
x
). We denote it consistently by
T
.
Now, it is possible to encode conditional blocks in the
λ
-calculus. An if block, of the form [
if
E
is true
then
M
else
N] can be encoded as
(
λemn
·
emn
)
.
Verify that (
λemn
·
emn
)
T
=
m
and (
λemn
·
emn
)
F
=
n
.
5

4.3
Lists
We define the empty list to be
nil
= (
λxy
·
y
). Again, this is the same representation as that of 0
and of False.
A list is essentially a pair of values. The first is a “head” element of the list. The second element
is the “tail” of the list, which is the list without the first element.
Cons, the list constructor, is defined as follows.
Cons
= (
λv‘f
·
fv‘
)
.
For example,
Cons
a
nil
= (
λf
·
f a
nil
)
Cons
b
(
Cons
a
nil
) = (
λf
·
f b
(
Cons
a
nil
))
.

** Subscribe** to view the full document.

- Fall '19
- Satyadev Nandakumar