100% found this document useful (1 vote)
44 views

Catmodel

This document describes a categorical model of the untyped lambda calculus. It defines the untyped lambda calculus terms inductively and shows that the collection of terms forms a functor from the category of finite ordinals to the category of sets. It then discusses properties of presheaf categories, showing that the category of presheaves over a small category is cartesian closed. Finally, it outlines defining an initial algebra in the presheaf category to model the untyped lambda calculus categorically.

Uploaded by

api-297332947
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
44 views

Catmodel

This document describes a categorical model of the untyped lambda calculus. It defines the untyped lambda calculus terms inductively and shows that the collection of terms forms a functor from the category of finite ordinals to the category of sets. It then discusses properties of presheaf categories, showing that the category of presheaves over a small category is cartesian closed. Finally, it outlines defining an initial algebra in the presheaf category to model the untyped lambda calculus categorically.

Uploaded by

api-297332947
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Categorical Modelling of the

Untyped Lambda Calculus


Pritam Choudhury

Introduction

Functions are fundamental to mathematics. Church (1941) defines a function as a rule of correspondence by which when anything is given (as argument) another thing (the value of the function
for that argument) may be obtained. Churchs original -calculus and its later variants have been
very successful as theories of functions. Out of all the -calculi, we look at the untyped -calculus.
Several models have been given for the untyped -calculus, starting from Scott (1972). Out of
these, we consider the categorical model described in Scott (1980), one which is given by a reflexive
object in a cartesian closed category.

The untyped -calculus

The terms of the untyped -calculus are built up from an infinite list of variables. We represent
the variables by positive natural numbers. The meta-linguistic definition of -term, then, can be
given as:
i N+
t term ::= i | i.t | (t1 t2 )

(2.1)

Application is taken to be right associative and so we may omit the brackets when there is no
ambiguity. Apart from (2.1), we can also give contextual rules of formation of -terms. Let
F be the category of finite ordinals and functions. We denote the objects of F by e , where
en = {1, 2, 3, . . . , n | 1 2 3 . . . n} for all n in N. These objects can be used to represent
cartesian contexts for -terms. The inductive definition for formation of -terms in context is
given by (2.2).
1in
[VAR]
en i

e n t1 e n t 2
[APP]
e n t1 t2

en+1 t
[ABS]
en (n + 1).t

(2.2)

We can define a map : F Set given as follows:


(en ) = {t term | en t}

(em
en ) = t.t[]

(2.3)

We use while speaking about -terms (as in en (n+1).t ) and as a notation for set-theoretic
functions (as in (2.3)). The notation t[] stands for t obtained by renaming all i in t by (i). (en )
is, in fact, the set of all -terms (modulo -equivalence) with free variables {1, 2, . . . , en }.
Now, we show that is a functor. First we check that the identity axiom is satisfied.
en : Obj F (iden ) = t.t[iden ] = t.t = iden
7

(2.4)

Properties of presheaf categories

Next, we verify the composition axiom by induction on the structure of -terms. Consider any
F(em , en ), F(en , eo ). We show by structural induction on terms that for all t (em ),
(( ) ())t = ( )t. First, let t = i. Then, we have,
(( ) ())(i) = ( )i
= ( )(i)
Now, let t = t1 t2 , such that
(( ) ())t1 = ( )t1
(( ) ())t2 = ( )t2
This gives us,
(( ) ())(t1 t2 ) = ((( ) ())t1 )((( ) ())t2 )
= (( )t1 )(( )t2 )
= ( )(t1 t2 )
Now, let t = (m + 1).t , where (( ) ())t = ( )t . This gives us,
(( ) ())((m + 1).t ) = ((( ) ())(m + 1)).((( ) ())t )
= (( )(m + 1)).(( )t )
= ( )((m + 1).t )
This verifies the composition axiom. Hence, Obj SetF .
We denote by SetF the category of set-valued covariant presheaves, with F acting as the index
category. Our aim now is to define, in SetF , an appropriate notion of algebra for the -calculus,
then find an initial algebra, and thereafter give the unique homomorphism from the initial algebra
to a -algebra corresponding to every categorical model of untyped -calculus, given by a reflexive
object in a cartesian closed category. We do this as in Fiore et al. (1999).

Properties of presheaf categories

Before proceeding further, let us look at some properties of presheaf categories.


Theorem 3.1. The set-valued presheaves of any small category form a cartesian closed category.
Proof
Let C Obj Cat, where Cat is the category of all small categories and functors between them.
A set-valued contravariant presheaf of C is a functor U CAT(Cop , Set), where CAT is the
category of all locally small categories. The category CAT is a cartesian closed category
with the
b = Set(Cop ) .
exponential object of X, Y Obj CAT given by Y X := CAT(X, Y ). Let C
We can verify that the functor mapping every C Obj C to (the terminal object in Set) and
b
every p C(C, D) to id (the identity morphism on ) is a terminal object in C.
Cartesian structure

b is cartesian. Consider any U, V Obj C.


b We define a mapping U V from
Now we show that C
op
C to Set given by:
(U V )C = UC VC = {(uc , vc ) | uc UC , vc VC }

(U V )p = Up Vp = (ud , vd ) : UD VD .(Up (ud ), Vp (vd ))

C Obj C

p C(C, D)

(3.1)

Pritam Choudhury / Modelling the Lambda Calculus

Since both U, V are functors and U V acts point-wise, so U V is a functor, by (3.2) and(3.3).
C : Obj C (U V )idC = UidC VidC
functoriality

= idUC idVC

(3.2)

= idUC VC
= id(U V )C
p : C(C, D), q : C(D, E) (U V )p (U V )q
= (Up Uq ) (Vp Vq )
contravariant functoriality

(3.3)

= Uqp Vqp
= (U V )qp
b
So, U V Obj C.
We define mappings , from U V to U and V respectively, given by:
C = (uc , vc ) : (U V )C .uc

C Obj C

C Obj C

= (uc , vc ) : (U V )C .vc

(3.4)

Now let C, D Obj C and let p C(C, D). So we have the following diagrams in Set:
U C VC
Up Vp

U D VD

U C VC

UC

U D VD

UD

VC

Up Vp

Up

Vp

VD

1 commutes since
(ud , vd ) : UD VD (C (Up Vp ))(ud , vd ) = C (Up ud , Vp vd )
= U p ud
= Up (D (ud , vd ))

(3.5)

= (Up D )(ud , vd )
b
b
This shows that is natural. Similarly, is natural. Hence, C(U
V, U ), C(U
V, V ).
b
b
b
Now let W Obj C and C(W, U ), C(W, V ). Let us define a mapping h, i from W to
U V , given by:
h, iC = wc : WC .(C (wc ), C (wc ))

C Obj C

Now let C, D Obj C and let p C(C, D). So we have the following diagrams in Set:
WC
Wp

WD

h,iC

3
h,iD

U C VC
Up Vp

U D VD

(3.6)

Properties of presheaf categories

10

Then, we have,
wd : WD ((Up Vp ) h, iD )(wd )
= (Up Vp )(D wd , D wd )
= (Up (D wd ), Vp (D wd ))
= ((Up D )wd , (Vp D )wd )
(3.7)

naturality of , , see 4 and 5 below

= ((C Wp )wd , (C Wp )wd )


= h, iC (Wp wd )
= (h, iC Wp )wd
In Set

WC

Wp

WD

Wp

Up

WD

UD

WC

UC

VC
Vp

VD

b
U V ).
Hence, 3 commutes. So, h, i C(W,

b
Now we have the following diagram in C.

6
U

h,i

U V

Then, for any C Obj C and any wc WC , we have


C h, iC (wc ) = C (C (wc ), C (wc )) = C (wc )

C
h, iC (wc ) = C
(C (wc ), C (wc )) = C (wc )

(3.8)

Since , , , , h, i are all natural in C, from (3.8), we conclude that h, i = and


h, i = . This proves the existence condition in the universal property for product of U and
V.
b
To prove the uniqueness condition, consider any C(W,
U V ) such that = and

= . Let C Obj C and let wc WC . Also let C (wc ) = (uc , vc ), where (uc , vc ) UC VC .
Now, we have,
C (wc ) = ( )C (wc ) = C (uc , vc ) = uc
(3.9)

C (wc ) = ( )C (wc ) = C
(uc , vc ) = vc
yielding (uc , vc ) = (C (wc ), C (wc )) = h, iC (wc ). Hence = h, i. This proves the uniqueness
b is a cartesian category.
condition in the universal property of the product of U and V . Hence, C
It is worth mentioning here that not only the set-valued presheaves but also the CC-valued
presheaves (where CC is a cartesian category) of a small category form a cartesian category.
Cartesian closure
b is cartesian closed. But before doing so, let us define a special family of
Now we prove that C
functors, known as the representable presheaves, which are indexed by C Obj C and denoted

11

Pritam Choudhury / Modelling the Lambda Calculus

b The functor Y C is defined as


by Y Obj C.

C
YX
= HomC (X, C)
YfC = f = mcy : HomC (Y, C).mcy f

X Obj C
f C(X, Y )

(3.10)

Now, we have,
C
C
X : Obj C Yid
= mcx : YX
.mcx idX = mcx .mcx = idYXC
X
C
f : C(X, Y ), g : C(Y, Z) YfC YgC = mcz : YZC .(mcz g) f = Ygf

(3.11)

showing that Y C is indeed a functor. This functor is called the Yoneda embedding of C.
Let us also take a look at natural transformations between representable presheaves. For any
b C , Y D ) is a natural transformation, whose each component composes p
p C(C, D), p C(Y
with the elements of the domain, as is clear from 8 in Set for X, Y Obj C and f C(X, Y ).
C
YX

D
YX

YYC

YYD

b and we wish to find the exponential V U . We define a functor V U given by,


Now, let U, V Obj C
C
VCU
= HomC
b (Y U, V )
U
D
Vp () = : HomC
b (Y U, V ). ((p ) idU )

C Obj C
p C(C, D)

(3.12)

(p )idU

b
We have, Y C U Y D U
V in C.

That (p ) idU is a natural transformation follows from the fact that (p ), idU are natural
transformations. So VpU () is well-defined. We now show that V U is indeed a functor. For any
C, D, E Obj C and any p C(C, D), q C(D, E) we have,
: VCU VidUC () = ((idC ) idU )
= (idY C idU )
= idY C U

(3.13)

=
: VEU (VpU VqU )() = ((q ) idU ) ((p ) idU )
= (((q p) ) idU )
=

(3.14)

U
Vqp
()

b
Hence, V U Obj C.
Now, we define a morphism from V U U to V as:
C = (c , uc ) : VCU UC .cC (idC , uc )
c

C Obj C

(3.15)

cC

b So Y C UC VC in Set. Hence, c (idC , uc ) VC .


We have, Y C U V in C.
C
C

To show that is natural in C, let us consider D Obj C and p C(C, D), giving us the following
diagram in Set:

Properties of presheaf categories

12
VCU UC

VpU Up

VDU UD

VC
Vp

VD

Now, we have,
(d , ud ) : VDU UD

(3.12)

(C (VpU Up ))(d , ud ) = C (d ((p ) idU ), Up (ud ))


(3.15)

= (d ((p ) idU ))C (idC , Up (ud ))


= (dC ((p ) idUC ))(idC , Up (ud ))
= dC (p idC , Up (ud ))
= dC (p, Up (ud ))

(3.16)

= (dC (( p) Up ))(idD , ud )
see 10 below

= (Vp dD )(idD , ud )
(3.15)

= (Vp D )(d , ud )
As d VDU is a natural transformation:
YCD UC
( p)Up

D
YD
UD

d
C

10

d
D

VC
Vp

VD

b U U, V ).
Hence, 9 commutes and as such, C(V
b and C(W
b
Now, let W Obj C
U, V ). Let us define for any C Obj C, a function,

C Set(WC , VCU ). For every wc WC , wc :=


C (wc ) must be a natural transformation. We
define it for any X Obj C as:
C
c
w
X = (mcx , ux ) : YX UX .X (Wmcx (wc ), ux )

(3.17)

That this is a well-defined function follows from the facts that W is a contravariant functor, so
Wmcx Set(WC , WX ), and is a natural transformation so that X Set(WX UX , VX ).
c
Now, we need to prove that w
X is natural in X. For this, let us consider any Y Obj C and
f C(X, Y ). We have then in Set, the following diagram:
C
YX
UX

( f )Uf

YYC UY

c
w
X

11
c
w
Y

VX
Vf

VY

13

Pritam Choudhury / Modelling the Lambda Calculus

This gives us,


wc
c
(mcy , uy ) : YYC UY (w
X (( f ) Uf ))(mcy , uy ) = X (mcy f, Uf (uy ))
(3.17)

= X (Wmcy f (wc ), Uf (uy ))


W s contravariant functoriality

= X ((Wf Wmcy )(wc ), Uf (uy ))

(3.18)

= (X (Wf Uf ))(Wmcy (wc ), uy )


s naturality, see 12 below

= (Vf Y )(Wmcy (wc ), uy )


(3.17)

c
= (Vf w
Y )(mcy , uy )
In Set

WX U X

12

Wf Uf

WY U Y

VX
Vf

VY

So wc VCU . This shows that


C := wc : WC .wc is a well-defined function.
Now we need to show that
C is natural in C. Let D Obj C and p C(C, D). So we have the
following diagram in Set.
WC
Wp

WD

VCU

13

VpU

VDU

Now we have,
C
wd : WD , X : Obj C, mcx : YX
, ux : U X

s
definition

((
C Wp )wd )X (mcx , ux ) = (Wp (wd ) )X (mcx , ux )
(3.17)

= X (Wmcx Wp (wd ), ux )
W s contravariant functoriality

= X (Wp mcx (wd ), ux )


(3.17)

d
= w
X (p mcx , ux )
(3.12)

= (VpU (wd ))X (mcx , ux )


s
definition

= ((VpU
D )wd )X (mcx , ux )

(3.19)

Properties of presheaf categories

14

So by (3.19),(
C Wp )wd = (VpU
is natural, i.e.
is in
D )wd . Hence 13 commutes and
U
b
b
C(W, V ). Thus, we have the following diagram in C:
VU U

14

id

W U

To prove that 14 commutes, we need to show that the corresponding diagram in Set commutes
for any C Obj C. For (wc , uc ) WC UC , we have,
(C (
C idUC ))(wc , uc ) = C (
C (wc ), uc )
s
definition

= C (wc , uc )
(3.15)

c
= w
C (idC , uc )

(3.20)

(3.17)

= C (WidC (wc ), uc )
W s functoriality

= C (idWC (wc ), uc )
= C (wc , uc )
Hence (
idU ) = . This proves the existence condition in the universal property of exponentials. We now prove the uniqueness condition.
b
Let C(W,
V U ) such that
( idU ) =
(3.21)

Now, we have,

C
C : Obj C, wc : WC , X Obj C, (mcx , ux ) : YX
UX
s
definition

(3.17)

c
(
C (wc ))X (mcx , ux ) = w
X (mcx , ux ) = X (Wmcx (wc ), ux )
(3.21)

= (X (X idUX ))(Wmcx (wc ), ux ) = X (X (Wmcx wc ), ux )


(3.15)

= (X (Wmcx wc ))X (idX , ux ) = ((X Wmcx )wc )X (idX , ux )


s naturality, see 15 below

= ((VmUcx C )wc )X (idX , ux )


(3.12)

= (C (wc ) ((mcx ) idU ))X (idX , ux )


= (C (wc ))X (mcx idX , ux ) = (C (wc ))X (mcx , ux )

(3.22)

15

Pritam Choudhury / Modelling the Lambda Calculus


In Set

WX

VXU

15

Wmcx

WC

U
Vm
cx

VCU

So by (3.22),
C (wc ) = C (wc ). Further, since ,
are natural, therefore
= . This proves the
uniqueness condition. The theorem follows.

We now state and prove a lemma which we shall use to prove Theorem 3.3.
Lemma 3.2. For any cartesian category C and C, D Obj C, Y D Y C
= Y DC .
Proof
DC
DC
D
C
D
C
, YX
YX
) as:
) and X Set(YX
Let X Obj C. We define X Set(YX
YX
, YX
X = (mdx , mcx ).hmdx , mcx i

(3.23)

X = mdcx .(1 mdcx , 2 mdcx )

(3.24)

Here hmdx , mcx i is the unique morphism in C from X to D C, given mdx and mcx while 1 and
2 are the first and second projection morphisms from D C to D and C respectively. Now we
prove that X and X are natural in X. Let Y Obj C and f C(X, Y ). Then we have the
following diagrams in Set:
D
C
YX
YX

16

( f )( f )

YYD YYC

DC
YX

DC
YX

YYDC

YYDC

D
C
YX
YX

17

( f )( f )

YYD YYC

Now, for any (myd , myc ) YYD YYC , we have,


X (mdy f, mcy f ) = hmdy f, mcy f i
= hmdy , mcy i f
= Y (mdy , mcy ) f
showing that is natural. Again, for any mdcy YYDC , we have,
X (mdcy f ) = (1 (mdcy f ), 2 (mdcy f ))
= ((1 mdcy ) f, (2 mdcy ) f )

showing that is natural.


For any (myd , myc ) YYD YYC , we have,
(Y Y )(myd , myc ) = Y (hmyd , myc i)
= (1 hmyd , myc i, 2 hmyd , myc i)
= (myd , myc )

16

-algebras
showing that = idY D Y C . Again, for any mdcy YYDC , we have,
(Y Y )mdcy = Y (1 mdcy , 2 mdcy )
= h1 mdcy , 2 mdcy i
= mdcy

universal property of products

showing that = idY DC . The lemma follows.


We can now give an explicit description of exponentiation by representable presheaves:

b and C Obj C, U (Y C )
Theorem 3.3. For every small cartesian category C, U C,
= U ( C).

Proof
For any X Obj C, we have,

Lemma 3.2

Yoneda Lemma
(Y C )

UX

Yoneda Lemma

b X YC, U )
b X , U (Y C ) )
b XC , U )
= UXC
= C(Y
= C(Y
= C(Y

universal property of exponentials

The theorem follows.

-algebras

Now we shall use SetF to give a semantics to the untyped -calculus. For this, we define an
endo-functor CAT(SetF , SetF ) given by:
X = V + X 2 + X V

X Obj SetF

(4.1)

Here, V = Y e1 .
Theorem 4.1. is an initial -algebra.
Proof
We have:

dual of Theorem 3.2

= V + 2 + V = Y e1 + 2 + Y

e1

= Y e1 + 2 + ( + e1 )

Now, we define a morphism in SetF from to . Let us define for any en F, a map varen
Set(Yeen1 , en ) as:
varen = mi : Yeen1 .i
where mi (1) = i
(4.2)
That this is a well-defined function follows from [VAR]. Now, we show that varen is natural in en .
Let em Obj F and let F(em , en ). So we have the following diagram in Set:
Yeen1

1
Yeem

(4.2)

Now,

varen

18

en
[]

em
varem
(4.2)

1
mi : Yeem
( [] varem )(mi ) = [](i) = i = varen (mi ) = varen ( mi )

showing that 18 commutes. Hence var SetF (Y e1 , ).

(4.3)

17

Pritam Choudhury / Modelling the Lambda Calculus

Now, let us define for any en Obj F, a map appen Set(2en , en ) given by:
appen = (t1 , t2 ) : 2en .t1 t2

(4.4)

That this is a well-defined function follows from [APP]. Now, we show that appen is natural in en .
Let em Obj F and let F(em , en ). So we have the following diagram in Set:
2en
[] []

2em

appen

19
appem

en
[]

em

(4.4)

Now,
(t1 , t2 ) : 2em

(4.4)

appen (t1 [], t2 []) = (t1 [])(t2 []) = (t1 t2 )[] = (appem (t1 , t2 ))[]

(4.5)

showing that 19 commutes. Hence app SetF (2 , ).


Now, we define en + e1 , en+1 , with the injection morphisms given by:
oldn F(en , en+1 )
oldn (i) := i

newn F(e1 , en+1 )


newn (1) := (n + 1)

Since is a functor and en + e1 , en+1 , so (en + e1 ) , (en+1 ).


Hence (e + e1 ) , (e +1 ).
Now, we define a map absen Set(en+1 , en ) given by:
absen = t : en+1 .((n + 1).t )

(4.6)

That this is a well-defined function follows from [ABS]. Now, we show that absen is natural in en .
Let em Obj F and let F(em , en ). Then, ((e +e1 )) = ((e +1 )) , where F(em+1 , en+1 )
is given by:
(
(i)
1im

(i) =
(4.7)
n+1
i=m+1
Now we have the following diagram in Set:
en+1
[ ]

em+1

absen

20
absem

en
[]

em

Then,
(4.6)

t : em+1 ( [] absem )t = ((m + 1).t )[]


= (m + 1).(t [])
[ABS]

= (n + 1).(t [ ])
(4.6)

= absen (t [ ])

(4.8)

18

-algebras

So 20 commutes. Hence abs SetF (( + e1 ), ). Therefore, [var, app, abs] is a natural transformation in SetF (Y e1 + 2 + ( + e1 ), ), and so (, [var, app, abs]) is a -algebra.
Now let (A, [vara , appa , absa ]) be any -algebra. For any en Obj F, let us define a map
en Set(en , Aen ), given by:

varen mi , where mi F(e1 , en ) (1) = i


en (t) = appaen ((en t1 ), (en t2 ))

a
absen (en+1 t )

t=i
t = t1 t2
t = (n + 1).t

(4.9)

The above definition of en is structurally recursive, i.e. given any t en , en (t) is defined in
terms of t e , where t is structurally smaller than t. Now we show that en is natural in
en . We prove, by induction on t em , that for all em Obj F and F(em , en ), the following
diagram commutes in Set:
en

en

21

[]

em

em

Aen
A

Aem

Case t = i. We have,
vaream s naturality, see 22 below

(4.9)

(A em )(i) = A (vaream mi ) = (A vaream )mi = (varean ( ))mi


= varean mi = en (i) = (en [])i

(4.10)

(4.9)

Yeen1

In Set

1
Yeem

varean

22
vaream

Aen
A

Aem

and the hypothesis holds in this base case.


Case t = t1 t2 . The induction hypothesis is that for all , 21 commutes for t1 and t2 , i.e.,
en (t1 []) = A (em t1 )
en (t2 []) = A (em t2 )

(4.11)

19

Pritam Choudhury / Modelling the Lambda Calculus


Now, we have,

(4.9)

en ((t1 t2 )[]) = appaen (en (t1 []), en (t2 []))


(4.11)

= appaen (A (em t1 ), A (em t2 ))


= (appaen (A A ))(em t1 , em t2 )
appa
em s naturality, see 23 below

(4.12)

(4.9)

= (A appaem )(em t1 , em t2 ) = (A em )(t1 , t2 )


A2en

In Set

A A

A2em

appa
en

23
appa
em

Aen
A

Aem

This shows that em is natural for any t = t1 t2 whenever it is natural for t1 and t2 .
Case t = (m + 1).t . The induction hypothesis is that, for all , 21 commutes for t and ,
i.e.
(4.13)
A (em+1 t ) = en+1 (t [ ])
where is as in (4.7).
Now, we have,
[ABS]

(4.9)

en (((m + 1).t )[]) = en ((n + 1).(t [ ])) = absaen (en+1 (t [ ]))


(4.13)

= absaen (A (em+1 t )) = (absaen A )(em+1 t )


absa
em s naturaliy, see 24 below

(4.14)

(4.9)

= (A absaem )(em+1 t ) = (A em )((m + 1).t )

In Set

Aen+1
A

Aem+1

absa
en

24
absa
em

Aen
A

Aem

This shows the inductive step for t = (m + 1).t .


Thus, by structural induction, 21 commutes for all t em and . Hence SetF (, A).
Now, for any en Obj F, we have the following diagram in Set:

Scotts categorical models

20
Yeen1 + 2en + en+1

[varen ,appen ,absen ]

idV +en en +en+1

en

25

Yeen1 + A2en + Aen+1


Then,

en

a
[varean ,appa
en ,absen ]

Aen

mi : Yeen1 en (varen mi ) = en (i)


= varean (mi )
= (idV
(t1 , t2 ) :

2en

(4.15)

varean )(mi )

en (appen (t1 , t2 )) = en (t1 t2 )


= appaen (en t1 , en t2 )
= (appaen (en en ))(t1 , t2 )

t : en+1 en (absen t ) = en ((n + 1).t )


= absaen (en+1 t )

(4.16)

(4.17)

This shows that 25 commutes. This implies, due to the naturality of all the morphisms involved,
[var, app, abs] = [vara , appa , absa ]

(4.18)

Now, let SetF (, A) such that [var, app, abs] = [vara , appa , absa ] . Then, for any
en Obj F, we have,
{t : en = i} en (i) = varean mi
(4.19)
= en (i)
{t : en = t1 t2 } en (t1 t2 ) = appaen (en t1 , en t2 )
= en (t1 t2 )

(4.20)

This holds iff en t1 = en t1 and en t2 = en t2 .


{t : en = (n + 1).t } en ((n + 1).t ) = absaen (en+1 t )
= en ((n + 1).t )

(4.21)

This holds iff en+1 t = en+1 t . Hence, by structural induction = . The theorem follows. 

Scotts categorical models

Now we look at categorical models of the untyped -calculus. Let C Obj Cat be a cartesian
closed category with a reflexive object U , along with the morphisms i C(U U , U ), j C(U, U U )
such that j i = idU U .
We can then define a presheaf hU, U i CAT(F, Set), given by,
hU, U ien = HomC (U n , U )
hU, U i = f : HomC (U n , U ).f h[] i

en Obj F
F(em , en )

(5.1)

Here, h[] i , h1 , 2 , . . . m i.
Then,
en : Obj F, f : hU, U ien hU, U iiden (f ) = f h[iden ] i
=f
= idhU,U ien (f )

(5.2)

21

Pritam Choudhury / Modelling the Lambda Calculus


: F(em , en ), : F(en , eo ), f : hU, U iem (hU, U i hU, U i )(f ) = f h[] i h[ ] i
= f h[ ] i
= hU, U i (f )

This shows that hU, U i is a functor in SetF . This presheaf is called the clone of operations on U .
Theorem 5.1. The clone of operations hU, U i has a -algebra structure.
Proof
hU,U i = Y e1 + hU, U i2 + hU, U i( + e1 ). We define for any en Obj F, the following maps:
vareun Set(Yeen1 , hU, U ien )
vareun := mi .i where mi (1) = i

(5.3)

appuen Set(hU, U i2en , hU, U ien )


appuen := (t1 , t2 ).ev hj t1 , t2 i

(5.4)

absuen Set(hU, U ien+1 , hU, U ien )

(5.5)

absuen

:= t .i (cur t )

Here i is the i-th projection morphism, ev is application or evaluation morphism, cur is currying.
Now, we show that these functions are natural in en . Let em Obj F and let F(em , en ).
We have the following diagram in Set:
Yeen1

1
Yeem

Then, we have,
mi : Yeen1

vareun

C(U n , U )

26
vareum

h[] i

C(U m , U )

(5.3)

(5.3)

vareun ( mi ) = vareun (mi ) = i = i h[] i = vareum (mi ) h[] i

(5.6)

showing that 26 commutes. Hence varu SetF (Y e1 , hU, U i).


Now, we have the following diagram in Set:
C(U n , U ) C(U n , U )
( h[] i)( h[] i)

C(U m , U ) C(U m , U )

appu
en

27
appu
em

C(U n , U )
h[] i

C(U m , U )

Then, we have,
(t1 , t2 ) : C(U m , U ) C(U m , U )
appuen (t1 h[] i, t2 h[] i) = ev hj t1 h[] i, t2 h[] ii

(5.4)
(5.4)

= ev hj t1 , t2 i h[] i = appuem (t1 , t2 ) h[] i

(5.7)

Semantics of categorical models

22

showing that 27 commutes. Hence appu SetF (hU, U i2 , hU, U i).


Now, we have the following diagram in Set:
C(U n+1 , U )
h[ ] i

absu
en

C(U n , U )

28

C(U m+1 , U )

h[] i

absu
em

C(U m , U )

Then, we have,
(5.5)

t : C(U m+1 , U ) absuem (t ) h[] i = i cur t h[] i


= i cur (uncur (cur t h[] i))
= i cur (ev ((cur t h[] i) idU ))
= i cur (ev (cur t idU ) (h[] i idU ))

(5.8)

(4.7)

= i cur (t h[ ] i)
(5.5)

= absuen (t h[ ] i)
showing that 28 commutes. Hence, absu SetF (hU, U i( + e1 ), hU, U i).
Hence,
[varu , appu , absu ] SetF (Y e1 + hU, U i2 + hU, U i( + e1 ), hU, U i)
and therefore (hU, U i, [varu , appu , absu ]) is a -algebra.

Semantics of categorical models

Goguen et al. (1977) points out that the syntax S of a theory is an initial algebra whereas
any other algebra A is a possible semantic algebra, whose semantics is given by the unique
homomorphism hA : S A, which assigns a meaning hA (s) to each syntactic structure s
in S. In our case, (, [var, app, abs]) is an initial algebra while (hU, U i, [varu , appu , absu ]) is a
semantic algebra. Now, we find the unique homomorphism JK SetF (, hU, U i) such that
JK [var, app, abs] = [varu , appu , absu ] JK by combining the general definition of for
any (A, [vara , appa , absa ]) with that of [varu , appu , absu ] for hU, U i. This gives the semantics
of (hU, U i, [varu , appu , absu ]). For any en Obj F and t en , we have,

Conclusion

i
JtK = ev hj Jt1 K, Jt2 Ki

i (cur Jt K)

t=i
t = t1 t2
t = (n + 1).t

(6.1)

In this essay, we have modelled the untyped -calculus in a category of set-valued covariant
presheaves, indexed by the category of finite ordinals and functions. Due to the representation
of contexts of -terms by finite ordinals, the syntax (, [var, app, abs]) automatically considers

23

Pritam Choudhury / Modelling the Lambda Calculus

-equivalent classes of -terms. The semantics of any other -model can be given by imposing
the structure of this syntax on the algebra corresponding to that model. With this idea, we gave
the semantics for a -model which is the clone of operations on a reflexive object in a cartesian
closed category. But we did not give the semantics for substitution, nor validated the , rules.
As a closing remark, we observe that the -calculus is a rich field for exploration it is simple,
yet at the same time subtle.

References
Church, A. (1941). The Calculi of Lambda Conversion. (AM-6) (Annals of Mathematics Studies).
Princeton University Press, Princeton, NJ, USA.
Fiore, M., Plotkin, G., and Turi, D. (1999). Abstract Syntax and Variable Binding. In LICS 99:
Proceedings of the 14th Annual IEEE Symposium on Logic in Computer Science, Washington,
DC, USA. IEEE Computer Society.
Goguen, J. A., Thatcher, J. W., Wagner, E. G., and Wright, J. B. (1977). Initial algebra semantics
and continuous algebras. J. ACM , 24(1), 6895.
Scott, D. (1972). Continuous lattices. In F. Lawvere, editor, Toposes, Algebraic Geometry and
Logic, volume 274 of Lecture Notes in Mathematics, pages 97136. Springer Berlin Heidelberg.
Scott, D. (1980). Relating theories of the lambda-calculus. In J. Hindley and J. Seldin, editors,
To H. B. Curry: Essays on combinatory logic, lambda calculus and formalism, pages 403450.
Academic Press.

You might also like