A Coalgebraic Approach To Lambda-Calculus: E-Mail Address: Yduppen@xs4all - NL URL: HTTP://WWW - Xs4all - NL/ Yduppen
A Coalgebraic Approach To Lambda-Calculus: E-Mail Address: Yduppen@xs4all - NL URL: HTTP://WWW - Xs4all - NL/ Yduppen
Lambda-calculus
Y. D. Duppen
E-mail address: [email protected]
URL: http://www.xs4all.nl/~yduppen
Contents
Introduction 5
Chapter 1. An Introduction to Lambda-calculus 7
1.1. Lambda-terms 8
1.2. Variables and Alpha-congruence 9
1.3. Substitution 10
1.4. Beta-reduction 11
1.5. Church-Rosser 13
1.6. The De Bruijn Representation of Lambda-terms 13
1.7. References 15
Chapter 2. An Introduction to Category Theory 17
2.1. The Category 18
2.2. Inverses and Isomorphisms 20
2.3. Initial and Terminal Objects 20
2.4. Combining Objects: Products and Coproducts 22
2.5. Functors 24
2.6. References 25
Chapter 3. An Introduction to Coalgebras and Coinduction 27
3.1. Lambda Calculus revisited 28
3.2. Coalgebras 28
3.3. The Category of Coalgebras 29
3.4. Bisimulations 32
3
4 Contents
3.5. The Flattening Lemma 33
3.6. References 34
Chapter 4. A Coalgebraic Approach to Lambda-calculus 35
4.1. Describing Lambda-terms 36
4.2. Alpha-congruence 40
4.3. Substitution 41
4.4. Beta-reduction 43
4.5. De Bruijn Trees 44
4.6. References 45
Chapter 5. Aftermath 47
Appendix A. Symbols used in this Paper 49
Appendix B. Proofs of Various Theorems and Propositions 51
B.1. The Proof of Proposition 4.3.2 51
B.2. The Proof of Proposition 4.4.2 52
Appendix. Bibliography 55
Introduction
Wiskunde is een zeer respectabele wetenschap, hoewel men
bij de beoefening ervan kan stuiten op perversiteiten, radicale
idealen, duistere motieven en smerige integralen
(J. F. A. A. Nagel, RU Leiden)
Lambda-calculus is a theory often used in computer science. Its appli-
cations are manifold, ranging from proof-checkers to functional program-
ming languages. Precisely because of these applications, innitary lambda-
calculus has recently become of interest among others at the Free University
of Amsterdam.
In this thesis I will use a new approach to describing innitary lambda-
calculus; using coalgebraic techniques I hope to nd a natural way to de-
scribe innite terms and the operations on these.
The objectives in writing this thesis were not restricted to describing my
results. Above all, I have tried to write something that is understandable
to a somewhat broader public than just myself. In order to accomplish this,
a large part of thesis consists of introductory material on the theories used
for my description.
In the rst chapter the concept of lambda-calculus will briey be de-
scribed. This chapter will merely explain the basics of the pure lambda
calculus without so much as hinting at other lambda-calculi such as the
typed lambda-calculus, the polymorphic lambda-calculus, and so on. Any
trade-os that had to be made between formal completeness and under-
standability were made in favor of the latter.
The next chapter deals with category theory, which forms the basis of
coalgebra. Again, only those elements necessary for the nal chapter have
5
6 Introduction
been described. Because category theory is very abstract, I have not tried to
keep the denitions understandable; instead, examples have been provided
for nearly every denition. This chapter can be read independently of the
rst.
The third chapter combines category theory with the notion of algebras
and coalgebras. The basics of coalgebras will be explained and accompanied
by the evergreen example of innite lists.
Finally, in chapter four all these chapters will be combined into a coalge-
braic account of lambda-calculus. Here, a coalgebra is created which maps
to innite trees in a natural way. The usual operations of substitution, one-
step beta-reduction and its reexive-transitive closure will be dened. As
with other theories of innite lambda-calculus, alpha-congruence will hardly
be addressed. In the end the theory will be rewritten to De Bruijn terms,
alleviating the problem of alpha-congruence. In order to keep the chapter
readable some lengthy proofs can be found in appendix B.
Of course, a lot of people have helped me these past years during my
studies. Of my teachers, I would like to thank Jan Willem Klop, Femke
van Raamsdonk and Roel de Vrijer. They have rst acquainted me with
this subject and helped me all the way from understanding the basics to
completing this thesis.
Furthermore, I would like to thank John Balder and Mark Lassche for
proofreading the contents, and Desiree van den Berg, who proofread my
English and saved the reader from my liberal views on interpunction.
Chapter 1
An Introduction to
Lambda-calculus
Knights of the Lambda Calculus
A semi-mythical organization of wizardly LISP and Scheme
hackers. The name refers to a mathematical formalism in-
vented by Alonzo Church, with which LISP is intimately con-
nected. There is no enrollment list and the criteria for induc-
tion are unclear, but one well-known LISPer has been known
to give out buttons and, in general, the members know who
they are....
(The Jargon File [6])
Lambda-calculus is a language of functions. Developed around 1930 by
Alonzo Church it nowadays plays an important role in computer science. It
is a powerful theory that (reputedly) can represent any kind of function, be it
a high level function or not, typed or not, polymorphic or not . . . The beauty
of lambda-calculus lies in its simple mechanism of representing functions and
executing computations. Because of this simplicity it forms the basis of all
functional programming languages.
This chapter will give an account of the so-called pure lambda-calculus.
It tries to cover enough ground to give an insight into lambda-calculus and
to make clear what this thesis is about.
First the lambda-terms (functions) will be introduced by means of a
structural inductive denition. Dierent notations of lambda-calculus are
given, together with some examples. The text continues with describing
7
8 1. An Introduction to Lambda-calculus
the notion of alpha-congruence; this will make it possible to freely change
certain variables.
After these basics, some time will be spent on substitution, i.e. replace-
ment of certain variables by complete lambda-terms. Substitution is nec-
essary to dene the powerful notion of beta-reduction, the equivalence of
computing.
Finally, the De Bruijn notation will be dealt with. This way of describing
lambda-terms is quite special in that it solves a lot of problems with substi-
tution, is easy to understand for a computer, and is impossible to read for
a human being.
All in all, this chapter will provide all the knowledge of lambda-calculus
that is necessary to understand Chapter 4, in which another approach to
lambda-calculus will be described.
1.1. Lambda-terms
Before we can do anything with lambda-calculus, it is necessary to dene the
elements of the calculus, the lambda-terms. They are inductively dened as
follows:
Denition 1.1.1 (-terms). The set of -terms is the smallest set satis-
fying the following:
if x is a variable, then x
if M , then (x.M)
if M, N , then (MN)
A term like (x.M) is called an abstraction over M. It corresponds with
a function that maps x to M. A term (MN) is called an application.
Example 1.1.2. Examples of -terms are:
(y.z) ((x.(y.x))(z.z))
(xy) (x.(y.(z.((xz)(yz)))))
(x(x.((y.((zz)z))x)))
As can be seen, the number of parentheses runs quickly out of hand. In
order to avoid this, an alternative notation can be used. In this notation
outer parentheses are elided and consecutive s are contracted; furthermore,
abstraction associates to the right and application associates to the left.
Example 1.1.3. The alternative notation enables us to rewrite the -terms
from Example 1.1.2 as follows:
y.z (xy.x)z.z
xy xyz.(xz)(yz)
x(x.(y.zzz)x)
1.2. Variables and Alpha-congruence 9
@
x
y x
z z
Figure 1.1.1. The tree-representation of (xy.x)z.z
Sometimes we draw -terms as trees. For instance the tree in Figure
1.1.1 represents the term (xy.x)z.z.
1.2. Variables and Alpha-congruence
As said before, abstractions correspond to functions. For example, the term
x.x corresponds to the function f(x) = x, the term z.z corresponds to the
function f(z) = z and the term x.y corresponds to the function f(x) = y.
These examples are not arbitrary, as will be explained below.
If we look at the rst two terms, we see that the functions they corre-
spond to behave identically; they both map something to itself. However,
syntactically they are dierent. The function of the last example is a strange
one; it maps everything to y, whatever y might be. The abstracted variable
x and the term y are not related at all.
In this section, rst the relation between terms and their abstractions
will be set out. Basically, if there is a term x.M and x appears in M, it
can be said that x is bound in M. If a variable is not bound in a term, it is
said to be free. Formally, the notion of free and bound variables is dened
as follows:
Denition 1.2.1. A variable x occurs free in a lambda-term M if it is not
in the scope of a x. It occurs bound otherwise.
Denition 1.2.2. The set free(M) which consists of the free variables in a
lambda-term M is dened as:
free(x) = x
free(x.M) = free(M) x
free(MN) = free(M) free(N)
Example 1.2.3. When revisiting Example 1.1.2, the following holds:
10 1. An Introduction to Lambda-calculus
Term M Bound occurrences Free occurrences free(M)
y.z none z z
(xy.x)z.z x and z none
xy none x and y x, y
xyz.(xz)(yz) x, y and both zs none
x(xy.zzzx) all zs and the last x the rst x x
As can be seen from this example, a variable may occur both bound and
free in a lambda-term. We now introduce alpha-congruence.
Denition 1.2.4. M
where N
is obtained by replacing
all occurrences of x in N by y. Here y is required to be fresh, i.e. it is not
used in building N.
Denition 1.2.5 (-congruence). M is -congruent with N, written as
M
x(x
1
y.zzzx
1
) and x.x
Q can be
derived from the following clauses:
(x.M)N
M[x := N] ()
M
NM
NM
(left)
M
MN
N
(right)
M
x.M
x.M
()
Example 1.4.2. We have e.g. the following reductions:
(xyz.xzy)xz.x
(xyz.xzy)xw.x
(yz.xzy)[x := xw.x]
yz.(xw.x)zy
yz.(w.z)y
yz.z
(xy.x)x.x
yx.x
(x.xx)x.xx
(x.xx)x.xx
We write -reduction relation
can do zero
or more steps at once. It can also be dened as follows:
Denition 1.4.3.
M
M (ref)
M
N
M
N
M
N N
L
M
L
(trans)
Example 1.4.4. We have for example:
(xyz.xzy)xz.x
yz.z
(x.xx)x.xx
(x.xx)x.xx
2
This might be the reason it is called one step -reduction
1.6. The De Bruijn Representation of Lambda-terms 13
but also
(xyz.xzy)xz.x
(xyz.xzy)xz.x
Denition 1.4.5.
(1) A -redex
3
is a term M, such that M (x.N)N
for some N, N
.
(2) A term is called a -normal form (nf), if it does not contain any
redexes.
(3) A term M has a -nf if there is a reduction M
N where N is
a -normal form.
Example 1.4.6. The term x.x has no redexes; it is a normal form. The
term (xyz.xzy)xz.x has exactly one redex; it eventually reduces to the
normal form yz.z. The term (x.xx)x.xx has one redex. However,
it can only reduce to itself; has no normal form.
1.5. Church-Rosser
When computing a function, it is often desired that for a given input there
is exactly one result. However, this is not necessarily so for the equivalent in
lambda-calculus, -reduction. When a term has multiple redexes, contract-
ing dierent redexes might yield dierent results. This is not a problem an
sich; after all, 2(2+4) also equals 26 and 4+8. It would be nice if these
dierent -terms would eventually reduce to a unique term.
Denition 1.5.1 (Church-Rosser). A reduction R is said to be Church-
Rosser (CR), if for all lambda-terms M, N
1
, N
2
such that M
N
1
and
M
N
2
a term P exists such that N
1
P and N
2
P.
With this denition in mind, the beginning of this section reduces to the
question: is reduction Church-Rosser? Luckily, the answer is yes. There
is the following fundamental result, which is given without proof:
Theorem 1.5.2. -reduction is Church-Rosser.
1.6. The De Bruijn Representation of
Lambda-terms
One of the problems that were encountered with substitution was that of
variable capture (see Section 1.3 above). The solution was to introduce the
notion of -congruence and assume a Variable Convention. There is however
another solution which is invented by De Bruijn. Quite aptly, this is called
the De Bruijn notation.
3
This is an acronym for reducible expression
14 1. An Introduction to Lambda-calculus
De Bruijn noted that it is not necessary to give bound variables a name.
All that is relevant for a variable is its connection with an abstraction. So
instead of using variables inside -terms, De Bruijn used natural numbers.
Each natural number corresponds with the distance to the corresponding .
So for instance, in xy.x all that is interesting about x is that it belongs to
the rst which is the second from x (counted from right to left). So he
represented this term as ..2.
Remark. Technically, it could be said that the De Bruijn is just a conve-
nient way of denoting an alpha-equivalence class of -terms.
Denition 1.6.1. Substitution on De Bruijn terms is dened as follows:
n[m := N] =
_
_
n if n < m
n 1 if n > m
rename
n,1
(N) if n = m
(M)[m := N] = (M[m+ 1 := N])
(M
1
M
2
)[m := N] = (M
1
[m := N])(M
2
[m := N])
where
rename
m,i
(j) =
_
j if j < i
j +m1 if j i
rename
m,i
(N) = (rename
m,i+1
(N))
rename
m,i
(N
1
N
2
) = (rename
m,i
(N
1
) rename
m,i
(N
2
))
And equation () on page 12 now becomes:
() (P)Q = P[1 := Q]
The resulting -reduction behaves identical to that on normal -terms.
For example:
Example 1.6.2. Just as (xy.x)x.x
(.2)[1 := .1]
= .(2[2 := .1])
= . rename
2,1
(.1)
= .. rename
2,2
(1)
= ..1
While the De Bruijn notation does prevent nasty problems with sub-
stitution, the example above probably makes clear why in this paper it is
avoided as much as possible; most humans nd it hard to use
4
.
4
Computers have dierent opinions on this matter
1.7. References 15
1.7. References
This chapter is based on the book by C. Hankin [4]. It does cover a lot of
ground and it has the advantage that it is very concise and descriptive at
the same time. Many denitions and examples in this chapter come from
this book. The others come from the book by Barendregt [2].
Proof of the fact that
Proposition 2.3.4. If A
1
and A
2
are both initial objects in category (, then
there is exactly one map A
1
A
2
, and that map is an isomorphism.
Proof. This proof is similar to the proof of Proposition 2.3.3.
1
I agree with [17] that nal sounds a lot better than terminal
22 2. An Introduction to Category Theory
X
B
1
B
2
B
1
B
2
f = f
1
, f
2
)
1
2
f
1
f
2
Figure 2.4.1. Denition of a product P = B
1
B
2
2.4. Combining Objects: Products and
Coproducts
The possibility to combine dierent objects into one is a powerful concept.
Many people do it on a daily basis, often without even realising it. For
example, the index of an atlas consists of entries like: Amsterdam, 14B8,
where the city of Amsterdam is combined with page 14, row B and column
8. Another example is the concept of fruit. A piece of fruit is either an
apple, or a banana, or . . . , but never more than one.
These concepts of combining objects are also present in category theory,
albeit in an abstract way. However, when these concepts are translated back
to o, the category of sets, they behave exactly as described above.
We begin with the notion of product, of which the atlas was an example:
Denition 2.4.1. An object P together with pair of maps
1
: P B
1
and
2
: P B
2
is called a product of B
1
and B
2
if for each object X and
each pair of maps f
1
: X B
1
, f
2
: X B
2
there is exactly one map
f : X P such that f
1
=
1
f and f
2
=
2
f (Figure 2.4.1).
Lemma 2.4.2. If (P,
1
2
) and (P
1
,
2
) are both products of A and B,
then P
= P
.
Proof. Since P and Q are both products of A and B, we can draw the
solid lines in Figures 2.4.2 (where P has been drawn twice). By denition
for each object X and each pair of maps f
1
: X A and f
2
: X B
there is exactly one map f : X P. In other words, there is a unique map
1
,
2
) : Q P. By the same line of reasoning, there is also a unique map
1
,
2
) : P Q.
This means that the map
1
,
2
)
1
,
2
) : P P is also unique and
therefore equal to id
P
: P P. In other words,
1
,
2
) and
1
,
2
) must
be inverses of each other. Which means that P
= Q.
2.4. Combining Objects: Products and Coproducts 23
P Q P
A
B
2
Figure 2.4.2. Proving Proposition 2.4.2
The previous lemma allows us to speak of the product of A and B. This
product is often written as A B, as in Figure 2.4.1. The unique map f
that was referred to in Denition 2.4.1 is written as f
1
, f
2
).
The other construct introduced here is the sum of two objects, of which
the fruit was an example. It is interesting to note that its denition is similar
to that of the product. Indeed, the sum is the dual of the product. For that
reason, sums are often called coproducts.
Denition 2.4.3. An object S together with a pair of maps
1
: B
1
S
and
2
: B
2
S is called a sum of B
1
and B
2
if for each object Y and each
pair of maps g
1
: B
1
Y , g
2
: B
2
Y there is exactly one map g : S Y
such that g
1
= g
1
and g
2
= g
2
(Figure 2.4.3).
Lemma 2.4.4. If (S,
1
,
2
) and (S
1
,
2
) are both sums of A and B, then
S
= S
.
Proof. Similar to the proof of Lemma 2.4.2.
Just as Lemma 2.4.2 allowed us to speak of the product of A and B, so
does this lemma allow us to speak of the sum of A and B, written as A+B.
The unique map g that the denition refers to is written as [g
1
, g
2
].
24 2. An Introduction to Category Theory
B
1
+B
2
Y
B
1
B
2
g = [g
1
, g
2
]
1
2
g
1
g
2
Figure 2.4.3. Denition of a sum S = B
1
+B
2
Lemma 2.4.5. For sums and products, the following equalities hold (among
others):
AB
= B A A+B
= B +A
A(B C)
= (AB) C A+ (B +C)
= (A+B) +C
And in some categories, called distributive categories, such as the category
of sets o, the following holds too:
A(B +C)
= (AB) + (AC)
This lemma allows us to leave out a lot of brackets; this means that we
can write e. g. AB (A+B +C) D.
In o, the category of sets, a product of two sets is equal to the classical
Cartesian product, while the sum of two sets is equal to the disjoint sum.
2.5. Functors
Everything can be turned into a category, as long as it satises the require-
ments in Denition 2.1.1. It turns out that it is also possible to create a
category of categories (
C
. In this category, the objects are categories and
the map are functors.
Denition 2.5.1. Let ( and T be categories. A functor F : ( T is a
map taking each (-object A to a T-object F(A) and each (-arrow A
f
B to
a T-arrow F(A)
F(f)
F(B), such that for all (-objects A and composable
(-arrows f and g
(1) F(id
A
) = id
F(A)
(2) F(g f) = F(g) F(f).
2.6. References 25
Example 2.5.2. Let F be the functor dened by
F(X) = 1 +(AX)
for a given set A and an arbitrary singleton set 1. Let us further assume
that we have a map
m : A
) to another
innite list.
Applying F to this map results in the map
F(m) : 1 +(AA
) 1 +(AA
)
with F(m) = [id
1
, id
A
, m)].
Remark. It has been explained that functors map objects to other objects.
This means that their domain and codomain are categories. In this thesis,
functors will always work on the category of sets. From now on, every
functor F will implicitly be dened as
F : o o
2.6. References
Category theory requires a dierent way of thinking than classical set the-
ory. I found the book Conceptual Mathematics, a rst Introduction to
Mathematics by Lawvere and Schanuel [7] a more than excellent book in
this regard. They have a relaxed attitude towards the subject and do not
try to cram as much information in as few pages as possible. The book is
full of pictures, examples and exercises. In my opinion, it is by far the best
book I have read on the subject of mathematics.
The book does have one drawback: it is not very suitable as a reference
book. Luckily, Lambda Calculi, a Guide for Computer Scientists by Ben-
jamin Pierce [15] can be used for that purpose. Its style is similar to that
of Hankin described in the previous chapter, in that it is very concise. Most
denitions in this chapter are based on Pierces book.
Both books describe many more concepts than those described in this
chapter. Proofs of the lemmas in this chapter can be found there too.
Funnily enough, Pierce describes more concepts than Lawvere and Schanuel,
even though it contains only one-third as many pages.
Chapter 3
An Introduction to
Coalgebras and
Coinduction
The mathematical sciences particularly exhibit order, symme-
try, and limitation; and these are the greatest forms of the
beautiful.
(Aristotle [14])
The formalisms in the previous chapter are also suitable to represent
algebras. Algebras are mathematical constructs where you can combine
small building blocks into larger blocks; these blocks can then be used to
build even larger blocks, which can be used to build still larger blocks and
so on. However, this and so on can not go on forever, making it dicult
to construct blocks that are innitely large.
That is were coalgebras come into play. Usually, algebras are described
as in Chapter 1. However, it is also possible to describe them categorically.
Coalgebras can then be seen as the dual of algebras. They are as powerful
as algebras, and it turns out that they have the advantage of being able to
deal with innite terms. Coalgebras are the subject of this chapter.
The rst section describes how an algebra can be described using cate-
gorical notions. This section does not contain formal denitions and merely
serves to show that algebras and coalgebras are related. The next section
gives a formal denition of a coalgebra. While not all coalgebras are useful,
some coalgebras are nal, and it turns out that this property is very impor-
tant. The denitions are accompanied by an example of innite streams.
27
28 3. An Introduction to Coalgebras and Coinduction
The remainder of the chapter deals with coinduction, the dual of in-
duction. Coinduction can be used to dene new functions and to prove
equalities. The latter is done by introducing bisimulations. These notions
too are claried using the example of innite streams.
The chapter nishes with the Flattening Lemma, a property that will
turn out to be useful in the next chapter. The proof of the lemma will
be given too; it is a beautiful example of the category theory involved in
coalgebras.
3.1. Lambda Calculus revisited
The denition of -terms in Section 1.1 is an example of an inductive de-
nition. It gives the smallest possible terms (variables) and it gives two rules
to combine existing terms into larger ones (abstraction and application).
But instead of looking at this denition as a set of rules, it can also be
seen as a set of three maps: the map lambda
var
: V , which turns a
variable into a -term, the map lambda
abs
: V which combines a
variable and an existing -term into a new -term, and the map lambda
app
:
which combines two existing -terms into a new -term, all with
the expected denitions.
Since these three maps all have the same codomain, they can be joined
together into the map
lambda : V + (V ) + ( )
where lambda = [lambda
var
, lambda
abs
, lambda
app
]. The function lambda is a
constructor: it can be used to construct new terms out of existing terms.
Another point worth of noting is that the domain and the codomain
share a common factor, . So if we introduce the functor F, dened as
F(X) = V + (V X) + (X X)
lambda can be written as
lambda : F()
If so desired, it is now possible to create the category of F-algebras,
where the objects are the algebras a : F(U) U and the mappings are
homomorphisms between algebras. The next sections will describe such a
category, but it will be the category of F-coalgebras.
3.2. Coalgebras
While algebras can be seen as methods to construct structures, coalgebras
are used to destruct them. Essentially, they are the duals of algebras. It
is the dierence between a mason and an archaeologist. A mason has a set
3.3. The Category of Coalgebras 29
of stones, from which he can create the most marvellous buildings. An ar-
chaeologist, on the other hand, encounters existing buildings and takes them
apart, very carefully so as not to destroy any information
1
. But while their
approaches dier, at the end they both know the entire building. Coalgebras
are the archaeologists of mathematical structures.
Denition 3.2.1. Let F be a functor. An F-coalgebra (or coalgebra for
short) is a pair (U, c) consisting of a set U and a function c : U F(U).
Here U is called the carrier and the function c is called the structure or
operation of the F-coalgebra.
Example 3.2.2. Let F be the functor
F(X) = AX
for a given set A. For the set A
, head, tail)).
This coalgebra is made by combining the functions head : A
A and
tail : A
AA
.
The intuition is that the function head maps an innite list of elements of
A to its rst element, which is in this way observed, and that the function
tail maps the innite list to its tail, i.e. the original list without its rst
element. Since the tail is an innite list too, we can apply head and tail
again and again.
3.3. The Category of Coalgebras
Coalgebras are not much fun in themselves. However, when we create the
category T, the category of F-coalgebras, the real fun begins. In order
to dene T, it is necessary to dene its objects and its maps. But rst
homomorphisms of coalgebras are introduced.
Denition 3.3.1. A homomorphism of coalgebras (or map of coalgebras, or
coalgebra map) from an F-coalgebra (U
1
, c
1
) to another F-coalgebra (U
2
, c
2
)
is a function h : U
1
U
2
between the carriers that has the property that:
c
2
h = F(h) c
1
as expressed in Figure 3.3.1.
It turns out that homomorphisms of coalgebras have exactly the desired
properties; they can be composed and they are associative.
Denition 3.3.2. The category T is the category with F-coalgebras as its
objects and homomorphisms of coalgebras as its arrows.
1
Of course archaeologists do not do this all the time. But sometimes they have to, and they
make a nice metaphor
30 3. An Introduction to Coalgebras and Coinduction
U
1
h
U
2
c
1
_
c
2
F(U
1
)
F(h)
F(U
2
)
Figure 3.3.1. A homomorphism of coalgebras
U
h
A
value,next
_
head,tail
AU
id
A
h
AA
. It is given by
h(u)(n) = value(next
(n)
(u))
Obviously, h is a function. However, since the following holds too:
head, tail) h = (id
A
h) value, next)
as in Figure 3.3.2, it is also a homomorphism. It can also be proven
2
that
this homomorphism is unique by assuming that there is also a function
h
: U A
_
=
_d
F(U)
F(f)
W(U)
Figure 3.3.3. Denition by nality of f
A
odd
A
.(head(),tail(tail()))
_
=
_
head,tail
AA
id
A
odd
AA
=
F(W) of the functor F.
The last lemma basically says that, if W is a carrier of a coalgebra, it is
the largest possible set in which each element can be decomposed into other
elements.
Finality of a coalgebra can be used to dene functions into the carrier.
Let us assume that (W, d) is a nal F-coalgebra, and that we wish to create
a function f : U W. If an F-coalgebra (U, c) can be created, there is
exactly one function from U to W (Figure 3.3.3).
Example 3.3.7. This example continues Example 3.2.2 on innite lists.
Suppose we want to dene a function odd that takes an innite list and
produces a new innite list. This new list contains all the elements occurring
in oddly numbered places of the original list. This function should have the
following observations:
head(odd()) = head() and tail(odd()) = odd(tail(tail()))
It can be dened coinductively, that is, by nality of A
as in Figure
3.3.4:
32 3. An Introduction to Coalgebras and Coinduction
U
1
R
2
U
c
_
c
T(U)
T(
1
)
T(R)
T(
2
)
T(U)
Figure 3.4.1. The bisimulation R
The unique coalgebra homomorphism that arises here can be called odd.
It can easily be shown that it has the desired observations.
3.4. Bisimulations
Proving that two innite structures are equal can be done using bisimula-
tions. Bisimulations are relations on structures that use the same technique
as coalgebras: observing and going on.
Example 3.4.1. Bisimulations can be used to prove that two innite lists
are equal. A bisimulation on the carrier A
is a relation R on A
satisfying
R(, ) =
_
head() = head() and
R(tail(), tail())
In other words, two lists are bisimilar if their heads are equal and their
tails are bisimilar too.
While the bisimulation in the previous example is quite ad hoc, there is
a more formal denition.
Denition 3.4.2. Let F be a functor, and (U, c) an F-coalgebra. A bisim-
ulation on U is a relation R on U for which there exists an F-coalgebra
structure : R T(R) such that the two projection functions
1
and
2
are homomorphisms of F-coalgebras (Figure 3.4.1).
The fact that bisimulation implies equality is captured in the coinduction
proof principle:
Theorem 3.4.3. Let c : U F(U) be the nal F-coalgebra. For all v and
w in U, if R(v, w), for some bisimulation R on U, then v = w.
There can be many bisimulations on a nal F-coalgebra. However, when
one is not interested in a specic bisimulation, it is always possible to talk
of the greatest bisimulation.
Proposition 3.4.4. The greatest bisimulation on a carrier U always exists,
and it is denoted by
U
or for short. It is the union of all bisimulations.
3.5. The Flattening Lemma 33
U
f
W
c
_
=
_d
F(U)
F(f)
F(W)
Figure 3.5.1. Dening a function f : U W
W
!f
U
f
_
=
_
c
F(V +W)
F([g
,f])
F(U)
Figure 3.5.2. The Flattening Lemma
3.5. The Flattening Lemma
The concept of coinductive denitions can be very powerful, as can be seen
in the next chapter, but it has some drawbacks. To dene a function f :
U W to an F-coalgebra (W, d), a coalgebra (U, c) must be created which
also maps to F(U) (Figure 3.5.1). However, sometimes the codomain of c is
more complex.
This problem can be overcome by the Flattening Lemma. This lemma
states that instead of using a function c : U F(U) it is also possible to
use a function c : U F(V +U). This will turn out to be very important
when substitution is dened in the next chapter.
The proof of the Flattening Lemma is very elegant. It shows the use of
describing the category T by merely using categoric techniques in order to
obtain a coalgebraic result.
Lemma 3.5.1 (The Flattening Lemma). Let c : U F(U) be a nal
coalgebra, let g : V F(V ) be an arbitrary F-coalgebra and let g
: V U
be the unique homomorphism between the two. Consider any f
: W
F(V +W). Then there is a unique map f : W U such that
(3.5.1) c f = F([g
, f]) f
]
1
)
= F(h) (F(
1
) g)
= F(h
1
) g
So by nality, h
1
= g
. Let f = h
2
. Then
c f = c (h
2
)
= F(h) ([F(
1
) g, f
]
2
)
= F(h) f
= F([g
, f]) f
satises equation
(3.5.1). Then [g
, f
, f
] = h = [g
, f]. So f
= f.
3.6. References
My rst introduction to category theory was A Tutorial on (Co)Algebras
and (Co)Induction by Bart Jacobs and Jan Rutten [8]. It is a good article
with a structure similar to this chapter; they begin by categorically describ-
ing algebras, after which they move on to coalgebras. The article is full of
examples, among others the innite list example used above.
The article Universal Coalgebras [17] is less accessible, but it covers
more ground. Exercises in Coalgebraic Specication [5] is more of a case
study and it shows the power of coalgebras in action.
After much struggling with substitution in the next chapter, I encoun-
tered the Flattening Lemma in Lawrence Moss article Parametric Core-
cursion [13]. It is a general article on corecursion, that builds upon the
Flattening Lemma.
Chapter 4
A Coalgebraic
Approach to
Lambda-calculus
Only two things are innite, the universe and human stupid-
ity, and Im not sure about the former.
(Albert Einstein [18])
In this chapter, the previous three chapters will be combined to give a
coalgebraic account of possibly innite lambda-terms, such as x.xxx. . . ,
I(I(I(I . . . ))) etc. Innite lambda-terms often arise in the semantics of lazy
funtional languages. For example, in such a language it is perfectly accept-
able to lter all primes from the (innite) list of all natural numbers.
It is not new to describe an innitary lambda-calculus; Innitary
Lambda Calculus[9] is an article on this subject in which the authors model
innite trees within an (ultra-) metric space. By using this approach they
identify several kinds of metrics that correspond with several kinds of inni-
tary lambda-calculus, each with its own properties.
M. Lenisa has another approach in her article Semantic Techniques for
Deriving Coinductive Characterizations of Observational Equivalences for -
calculi[11]; she compares dierent reduction strategies on possibly innite
terms. This approach assumes the existence of innite terms and reductions
on these terms. Furthermore, it only compares dierent types of reduction.
35
36 4. A Coalgebraic Approach to Lambda-calculus
Lambek and Scott give a categoric account of combinatory logic in In-
troduction to Higher Order Categorical Logic[10]. This book is an intro-
duction to categorical logic, and their combinators merely serve as an exam-
ple. They have the advantage that combinators are closed lambda-terms,
which makes reduction a lot easier.
This chapter will describe yet another approach. Lambda-terms are
viewed as possibly innite trees which can be represented by an appropriate
functor and structure. It will be shown that the set
T
of possibly innite
lambda-trees together with this structure is a nal coalgebra.
Based on these results a coinductive denition of substitution will be
given. The problems associated with free variables will be ignored and the
notion of alpha-congruence will be assumed. It turns out that the Flattening
Lemma makes the denition quite elegant. The text continues with dening
beta-reduction.
Finally, a similar denition of possibly innite De Bruijn trees will be
given. As it turns out, many results from this chapter also apply to De
Bruijn trees, albeit with some little modications.
4.1. Describing Lambda-terms
As described in Chapter 1, it is easy to represent an arbitrary -term as a
tree. To recapitulate, -trees are trees in which each node consists of either:
(1) a leaf node (a variable: x),
(2) a leaf node and another subtree (an abstraction:
x M
), or
(3) two subtrees (an application:
@
M N
)
This tree-structure can be captured in a functor T:
Denition 4.1.1. The -tree structure can be represented with the functor
T, dened as
(4.1.1) T(X) = V + (V X) + (X X)
In order to create a coalgebra from this functor we need to nd a suitable
structure and a carrier. As the carrier wed like to use the set
T
, the set
of all nite and innite lambda-trees.
To complete our denition of the coalgebra we dene the map unfold :
T
T(
T
). This function sends -trees to their respective subtrees.
Denition 4.1.2. The map unfold is the map
unfold :
T
V + (V
T
) + (
T
T
)
4.1. Describing Lambda-terms 37
@
I @
I @
I . . .
Figure 4.1.1. The innite term I
dened as
unfold (x) =
1
(x) (4.1.2a)
unfold
_
x M
_
=
2
(x, M) (4.1.2b)
unfold
_
@
M N
_
=
3
(M, N) (4.1.2c)
Example 4.1.3. As an example let us look at the unfolding of the term
K = xy.x:
unfold
_
_
y x
_
_
=
2
_
x,
y x
_
unfold
_
y x
_
=
2
(y, x)
unfold (x) =
1
(x)
Please note the last equation; a dierence is made between the -tree x,
which is an element of
T
, and the variable x, which is an element of V .
Example 4.1.4. Let us look at another example: the unfolding of the
innite term I
) =
2
(I, I
)
The functor T, the carrier
T
and the map unfold :
T
T(
T
) together
give us the T-coalgebra (
T
, unfold). Now we only need to prove that this
coalgebra is nal, which will allow us to give coinductive denitions and
proofs about this coalgebra.
Theorem 4.1.5. The T-coalgebra (
T
, unfold) is a nal coalgebra.
Proof. In order to prove this, we need to take an arbitrary T-coalgebra
(U, c) and show that:
38 4. A Coalgebraic Approach to Lambda-calculus
U
h
T
c
_
=
_unfold
T(U)
T(h)
T(
T
)
Figure 4.1.2. The diagram of unfold h = T(h) c
existence: There exists a homomorphism of coalgebras h : U
T
that satises the equation unfold h = T(h) c, and thus makes
Diagram 4.1.2 commute.
uniqueness: This homomorphism is the only homomorphism satis-
fying this equation (up to isomorphism of the coalgebras).
We begin with the proof of existence by introducing the function
h : U
T
dened by
(4.1.3) h(v) =
_
_
x if c(v) =
1
(x)
x h(w)
if c(v) =
2
(x, w)
@
h(w) h(w
)
if c(v) =
3
(w, w
)
It will be shown that this function is a homomorphism. This means that
the function satises the following equation:
unfold h = T(h) c (4.1.4)
with
T(h) : T(U) T(
T
)
dened by
T(h) = [id
V
, id
V
h, h h] (4.1.5)
To do this, we distinguish three cases:
4.1. Describing Lambda-terms 39
1. c(u) =
1
(x)
unfold h u = unfold(h(u))
= unfold(x) by (4.1.3)
=
1
(x) by (4.1.2a)
= T(h)
1
(x) by (4.1.5)
= T(h) c u by assumption
2. c(u) =
2
(x, w)
unfold h u = unfold
_
x h(w)
_
by (4.1.3)
=
2
(x, h(w)) by (4.1.2b)
= T(h)
2
(x, w) by (4.1.5)
= T(h) c u by assumption
3. c(u) =
3
(w, w
)
unfold h u = unfold
_
@
h(w) h(w
)
_
by (4.1.3)
=
3
(h(w), h(w
)) by (4.1.2c)
= T(h)
3
(w, w
) by (4.1.5)
= T(h) c u by assumption
This exhausts all possible cases, so we can conclude that h is indeed
a T-coalgebra map from (U, c) to (
T
, unfold). In order to show that this
homomorphism is unique let us assume that there is another function g :
U
T
that makes diagram 4.1.2 commute. In other words:
unfold g = T(g) c (4.1.6)
where
T(g) = [id
V
, id
V
g, g g] (4.1.7)
Again, consider these cases:
1. c(u) =
1
(x)
unfold g u = T(g) c u by (4.1.6)
= T(g)
1
(x) by assumption
=
1
(x) by (4.1.7)
40 4. A Coalgebraic Approach to Lambda-calculus
2. c(u) =
2
(x, w)
unfold g u = T(g) c u by (4.1.6)
= T(g)
2
(x, w) by assumption
=
2
(x, g(w)) by (4.1.7)
3. c(u) =
3
(w, w
)
unfold g u = T(g) c u by (4.1.6)
= T(g)
3
(w, w
) by assumption
=
3
(g(w), g(w
)) by (4.1.7)
As can be seen, g does exactly the same as h, so we can conclude that
g = h. But since g was chosen as an arbitrary homomorphism, h must be
the unique homomorphism that makes Diagram 4.1.2 commute. And so it
can be concluded that the coalgebra (
T
, unfold) is nal.
Note. From now on this paper will use the -term notation instead of the -
tree notation, when there can be no confusion. Examples of this conversion
can be found above, for instance in Example 4.1.3.
4.2. Alpha-congruence
The next logical step would be to dene alpha-congruence. Alpha-
congruence is intuitively clear for both nite and innite terms. However,
dening it for innite terms is not easy. First of all, it requires the set V
of variables to be uncountable and it should always be possible to nd an
unused variable.
Secondly, alpha-conversion is usually dened in terms of substitutions of
bound variables. The coalgebraic structure of lambda-terms is unfortunately
not well suited for the identication of bound variables. When lambda-terms
are destructed by the function unfold, the previous context gets lost.
Example 4.2.1. Let f
:
T
T
be a coinductively dened function
which maps lambda-terms to other lambda-terms by changes of bound vari-
ables (as in Denition 1.2.4). This function would for example have the
following observations for x.x:
unfold(f
(x.x)) =
2
(y, f
(x))
unfold(f
(x)) = y
On the other hand, for the term x this function would have the following
observation:
unfold(f
(x)) = x
4.3. Substitution 41
1
T
T
2
T
unfold
_unfold
T(
T
)
T(
1
)
T(
T
T
)
T(
2
)
T(
T
)
Figure 4.2.1. The hypothetical bisimulation relation
The dierence between these equations is a bit puzzling, but it all comes
down to the fact that the second equation automagically remembers the fact
that x was bound. Clearly, the function f
_
=
_unfold
T(
T
+V
T
T
)
T([id
T
,subst])
T(
T
)
Figure 4.3.1. The Flattening of f
subst
Note. The term subst(x, N, M) should be read as: substitute all oc-
curences of x by N in M. Usually we will write M[x := N] instead of
subst(x, N, M).
When we consider the rst equation, we notice that in this case substi-
tution is not dened in terms of itself, even though unfold(N) could contain
other -terms. This is problematic because coinductively dened functions
tend to traverse an entire data-structure, i.e. they are always dened in
terms of themselves.
To solve this problem we employ the Flattening Lemma (Lemma 3.5.1).
This lemma states that instead of having to dene a function f
subst
: V
T
T
T(V
T
T
) we can also dene the function f
subst
: V
T
T
T(
T
+V
T
T
). The resulting homomorphism subst is unique by this
lemma. The application of the attening lemma to this problem can be seen
in Diagram 4.3.1.
Denition 4.3.1. f
subst
is dened as follows:
f
subst
(x, y, x) =
1
(y)
f
subst
(x, z.N, x) =
2
(z,
1
(N))
f
subst
(x, N
1
N
2
, x) =
3
(
1
(N
1
),
1
(N
2
))
f
subst
(x, N, y) =
1
(y)
f
subst
(x, N, y.M) =
2
(y,
2
(x, N, M))
f
subst
(x, N, M
1
M
2
) =
3
(
2
(x, N, M
1
),
2
(x, N, M
2
))
Note. The rst three equations of this denition essentially say that
f
subst
(x, N, x) = N.
Proposition 4.3.2. The function subst that arises by the Flattening Lemma
as the unique homomorphism from V
T
T
to
T
is the function subst
as described above.
Proof. By the Flattening Lemma, there is a function subst that satises:
(4.3.1) unfold subst = T([id
T
, subst]) f
subst
4.4. Beta-reduction 43
Appendix B contains the proof that subst has the desired properties as
described at the beginning of this section.
4.4. Beta-reduction
Now that the -terms have been described and the notion of substitution
is clear, we would like to nally do some useful things with our terms.
However, we have not yet succeeded in giving a satisfactory denition of
beta-reduction.
For now, only the function reduce will be dened. The complete head
reduction map reduce is a map that walks down a -tree and reduces every
redex it encounters (but does not necessarily reduce to a normal form, even
if one exists). It satises the following equations:
unfold(reduce(x)) =
1
(x)
unfold(reduce(x.M)) =
2
(x, reduce(M))
unfold(reduce((x.M)N)) =
_
1
(y) if M[x:=N]=y
2
(y, reduce(M
)) if M[x:=N]=y.M
3
(reduce(M
1
), reduce(M
2
)) if M[x:=N]=M
1
M
2
unfold(reduce(MN)) =
3
(reduce(M), reduce(N))
As usual, we dene this function coalgebraically by creating a T-
coalgebra (f
reduce
,
T
) and show that reduce is the unique homomorphism of
coalgebras from this coalgebra to our nal T-coalgebra. Unfortunately, this
coalgebra is not easy to dene; the third equation maps to dierent parts of
T(
T
). That means that the following denition of f
reduce
is quite complex.
Denition 4.4.1 (The function f
reduce
). The function
f
reduce
:
T
T(
T
)
is dened by
f
reduce
(x) =
1
(x)
f
reduce
(x.M) =
2
(x, M)
f
reduce
((x.x)y) =
1
(y)
f
reduce
((x.x)y.M) =
2
(y, M)
f
reduce
((x.x)(MN)) =
3
(M, N)
f
reduce
((x.y)N) =
1
(y)
f
reduce
((x.y.M)N) =
2
(y, M[x := N])
f
reduce
((x.M
1
M
2
)N) =
3
(M
1
[x := N], M
2
[x := N])f
reduce
(MN) =
3
(M, N)
44 4. A Coalgebraic Approach to Lambda-calculus
Proposition 4.4.2. The map reduce that arises as the unique homomor-
phism from (
T
, f
reduce
) to (
T
, unfold) has the desired properties.
Proof. This proposition is proven by case distinction in Appendix B.
4.5. De Bruijn Trees
As promised in section 4.2 we will now show some related results for De
Bruijn trees. Most of these results will be given without extensive proofs.
To model De Bruijn trees, we consider the functor
DB(X) = N +X +X X
We equip this functor with a function unfold
DB
:
DB
T(
DB
), which
is dened as:
unfold
DB
(n) =
1
(n)
unfold
DB
(M) =
2
(M)
unfold
DB
(MN) =
3
(M, N)
Theorem 4.5.1. The DB-coalgebra (
DB
, unfold
DB
) is a nal coalgebra.
Proof. As the proof of theorem 4.1.5.
In order to do useful things with our De Bruijn trees, we need the notion
of renaming. This function rename should have the following observations:
unfold
DB
(rename(m, i, j)) =
_
1
(j) if j < i
1
(j +m1) if j i
unfold
DB
(rename(m, i, N)) =
2
(rename(N))
unfold
DB
(rename((m, i, N
1
N
2
)) =
3
(rename(m, i, N
1
), rename(m, i, N
2
))
We induce the function rename as usual by means of a DB-coalgebra
structure (N N
DB
, f
rename
), which is dened as follows:
f
rename
(m, i, j) =
_
1
(j) if j < i
1
(j +m1) if j i
f
rename
(m, i, N) =
2
(m, i, N)
f
rename
(m, i, N
1
N
2
) =
3
((m, i, N
1
), (m, i, N
2
))
Proposition 4.5.2. The function that arises as the unique homomorphism
from f
rename
to unfold
DB
is the function rename as dened above.
Proof. Identical to previous proofs of coinductive denitions
4.6. References 45
As with
T
, this allows us to dene the function subst
DB
by creating the
coalgebra f
subst,DB
: N
DB
DB
DB(
DB
+N
DB
DB
). In this
case, f
subst,DB
is dened as follows:
f
subst,DB
(m, N, n) =
_
1
(n) if n < m
1
(n 1) if n > m
1
(rename(n, 1, j)) if n = m
and N = j
2
(
1
(rename(n, 1, N
))) if n = m
and N = N
3
_
1
(rename(n, 1, N
1
)),
1
(rename(n, 1, N
2
))
_
if n = m
and N = N
1
N
2
f
subst,DB
(m, N, M) =
2
(
2
(m+ 1, N, M))
f
subst,DB
(m, N, M
1
M
2
) =
3
(
2
(m, N, M
1
),
2
(m, n, M
2
)))
Proposition 4.5.3. The function that arises as the unique homomorphism
from f
subst,DB
to unfold
DB
is the substitution function subst
DB
.
Proof. As the proof of subst.
As can be seen from this section, the results on normal lambda-terms
are easily extended to De Bruijn terms. This might indicate that there
exist natural transformations from T to DB and vice versa. If that is true,
it would be possible to recognize alpha-congruent terms by transforming
them to De Bruijn terms and showing that the resulting terms are bisimilar.
However, natural transformations are beyond the scope of this paper too.
4.6. References
While this chapter consists of original ideas
1
, it has of course been inuenced
by previous works.
Modelling innite lambda-terms as innite trees has been explored in the
paper Innitary Lambda Calculus by J. W. Klop et al. [9]; in this paper
the trees are examined using positions and metrics on these positions. Sub-
stitutions have been explored in Parametric Corecursion by L. Moss[13].
The papers on coinduction by Jacobs and Rutten ([5], [17] and [8]) have of
course been extremely valuable as well.
1
Any similarities with existing papers on this subject are coincidence and show that this
approach is indeed a natural one
Chapter 5
Aftermath
All of the things that you used to do
If it is done, it is done by you
(Rolling Stones, [16])
In this thesis I have explored some of the possibilities that coalgebras
have to oer for innitary lambda-calculus. While there are a lot of open
issues, the rst results seem promising.
It has turned out that the notion of innite trees is easily translated to
a coalgebraic structure. Using innite trees has the advantage that they are
intuitively clear. Furthermore, manipulations on these trees are very similar
to those on the nite lambda-calculus.
Of course, the absence of alpha-congruence is a big problem. However, it
is probably not unsolvable. As has been suggested, natural transformations
from (
T
, unfold) to (
DB
, unfold
DB
) probably exist; if so, they can be used
to identify alpha-congruent terms.
Apart from these observations, this thesis has been an interesting ex-
ercise in the use of coalgebras. This holds especially for the denition of
substitution, since such denitions do not occur in the standard example
of innite lists.
Once more, my gratitude goes out to everyone who helped me in writing
this thesis.
Yigal Duppen
Amsterdam, August 2000
47
Appendix A
Symbols used in this
Paper
In this chapter the contexts of all symbols in this paper are given. Subscripts
and primes are not given, so when looking for the context of x
or x
n
, look
at the context of x.
Functions and relations have long names when it was believed that this
would improve readability. Such functions and relations are all in sans serif
font. By convention, functions start with a lowercase character while rela-
tions start with an uppercase character.
49
50 A. Symbols used in this Paper
Symbol Context
a arbitrary constructor of an algebra
c arbitrary structure of a coalgebra
f, g, k, l arbitrary functions
h an arbitrary homomorphism
i, j, m, n arbitrary numbers
v, w variables occurring in U
x, y, z variables occurring in a -term
A, B, C, D objects in a coalgebra
F, G, H arbitrary functors
L, M, N arbitrary -terms
P arbitrary product in a coalgebra
S arbitrary sum in a coalgebra
T the lambda tree functor
U, V , W arbitrary carriers of a coalgebra
X arbitrary object in a coalgebra
Z nal object in a coalgebra
(, T arbitrary categories
T the category of F-coalgebras
o the category of sets
the set of all nite -terms
T
the set of all nite -trees
T
the set of all nite and innite -trees
Appendix B
Proofs of Various
Theorems and
Propositions
B.1. The Proof of Proposition 4.3.2
In order to prove that subst has the desired observations, six cases are dis-
tinguished for subst(x, N, M) (or M[x := N]):
1. M = x
1a. N = z
unfold subst (x, z, x) = T([id
T
, subst]) f
subst
(x, z, x)
= T([id
T
, subst])
1
(z)
=
1
(z)
= unfold(x)
51
52 B. Proofs of Various Theorems and Propositions
1b. N = z.N
1
unfold subst (x, z.N
1
, x) = T([id
T
, subst]) f
subst
(x, z.N
1
, x)
= T([id
T
, subst])
2
(z,
1
(N
1
))
=
2
(z, [id
T
, subst]
1
(N
1
))
=
2
(z, N
1
)
= unfold(z.N
1
)
1c. N = N
1
N
2
unfold subst (x, N
1
N
2
, x) = T([id
T
, subst]) f
subst
(x, N
1
N
2
, x)
= T([id
T
, subst])
3
(
1
(N
1
),
1
(N
2
))
=
3
(N
1
, N
2
)
= unfold(N
1
N
2
)
2. M = y
unfold subst (x, N, y) = T([id
T
, subst]) f
subst
(x, N, y)
= T([id
T
, subst])
1
(y)
=
1
(y)
3. M = y.M
1
unfold subst (x, N, y.M
1
) = T([id
T
, subst]) f
subst
(x, N, y.M
1
)
= T([id
T
, subst])
2
(y,
2
(x, N, M
1
))
=
2
(y, [id
T
, subst]
2
(x, N, M
1
))
=
2
(y, subst(x, N, M
1
))
4. M = M
1
M
2
unfold subst (x, N, M
1
M
2
) = T([id
T
, subst]) f
subst
(x, N, M
1
M
2
)
= T([id
T
, subst])
3
(
2
(x, N, M
1
),
2
(x, N, M
2
))
=
3
(subst(x, N, M
1
), subst(x, N, M
2
))
M[x := N] = M
unfold(reduce((x.x)y.M
) = T(reduce)(f
reduce
((x.x)y.M
)
= T(reduce)(
2
(y, M
))
=
2
(y, reduce(M
))
unfold(reduce((xy.M)N) = T(reduce)(f
reduce
((xy.M)N)
= T(reduce)(
2
(y, M[x := N])
= T(reduce)(
2
(y, M
)
=
2
(y, reduce(M
))
3c. (x.M)N = M
1
M
2
(M
)[x := N] = M
1
M
2
unfold(reduce((x.x)M
1
M
2
) = T(reduce)(f
reduce
((x.x)M
1
M
2
)
= T(reduce)(
3
(M
1
, M
2
))
=
3
(reduce(M
1
), reduce(M
2
))
unfold(reduce((x.M
)N) = T(reduce)(f
reduce
((x.M
)N)
= T(reduce)(
3
(M
1
, M
2
))
=
3
(reduce(M
1
), reduce(M
2
))
54 B. Proofs of Various Theorems and Propositions
4.
unfold(reduce(M
1
M
2
)) = T(reduce)(f
reduce
(M
1
M
2
))
= T(reduce)(
3
(M
1
, M
2
))
=
3
(reduce(M
1
), reduce(M
2
))
Bibliography
[1] Z. M. Ariola, J. W. Klop, Cyclic Lambda Graph Rewriting, Proceedings, Ninth Annual
IEEE Symposium on Logic in Computer Science, pages 416-425, IEEE Computer
Society Press, Paris, 1994
[2] H. P. Barendregt, The Lambda Calculus, its Syntax and Semantics, Studies in Logic
and the Foundation of Mathematics, vol. 103, North-Holland Publishing Company,
1984
[3] P. -L. Curien, Categorical Combinators, Sequential Algorithms, and Functional Pro-
gramming, 2nd edition, Birkhauser, Boston, 1993
[4] Chris Hankin, Lambda Calculi, a Guide for Computer Scientists, Clarendon Press,
Oxford, 1994
[5] Bart Jacobs, Exercises in Coalgebraic Specication,
http://www.cs.kun.nl/~bart/PAPERS
[6] Eric S. Raymond et al., The Jargon File, version 4.2.0, 31 Jan 2000,
http://www.tuxedo.org
[7] F. William Lawvere, Stephen H. Schanuel, Conceptual Mathematics, a First Intro-
duction to Categories, 2nd printing, Cambridge University Press, 1997
[8] Bart Jacobs, Jan Rutten, A Tutorial on (Co)Algebras and (Co)Induction,
http://www.cs.kun.nl/~bart/PAPERS/
[9] J. R. Kennaway, J. W. Klop, M. R. Sleep, F. -J. de Vries, Innitary Lambda Calculus,
Report CS-R9535, CWI, 1995
[10] J. Lambek, P. J. Scott, Introduction to Higher Order Categorical Logic, Cambridge
University Press, 1986
[11] Marina Lenisa, Semantic Techniques for Deriving Coinductive Characterizations of
Observational Equivalences for -calculi,
http://www.dimi.uniud.it/~lenisa/Papers/list-papers.html
[12] Marina Lenisa, From Set-theoretic Coinduction to Coalgebraic Coinduction: Some
Results, Some Problems,
http://www.dimi.uniud.it/~lenisa/Papers/list-papers.html
[13] Lawrence S. Moss, Parametric Corecursion,
http://math.indiana.edu/home/moss/articles.html
55
56 Bibliography
[14] Mathematical Quotations Server,
http://math.furman.edu/~mwoodard/mqs/mquot.shtml
[15] Benjamin C. Pierce, Basic Category Theory for Computer Scientists, 2nd printing,
Massachusets Institution of Technology, 1993
[16] The Rolling Stones, Aftermath, Decca, 1996
[17] J. J. M. M. Rutten, Universal Coalgebra: a Theory of Systems,
http://www.cwi.nl/~janr/papers/
[18] The Silly Stu Nexus,
http://www.animenetwork.com/sillystuff
[19] Masako Takahashi, Parallel Reductions in -Calculus, Revised version, Information
and Computation, 118(1):120-127, 1995