Catmodel
Catmodel
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 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)
(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)
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).
C Obj C
p C(C, D)
(3.1)
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)
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)
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
C
h, iC (wc ) = C
(C (wc ), C (wc )) = C (wc )
(3.8)
= . 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
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
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
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:
12
VCU UC
VpU Up
VDU UD
VC
Vp
VD
Now, we have,
(d , ud ) : VDU UD
(3.12)
(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,
(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
(3.18)
c
= (Vf w
Y )(mcy , uy )
In Set
WX U X
12
Wf Uf
WY U Y
VX
Vf
VY
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
d
= w
X (p mcx , ux )
(3.12)
= ((VpU
D )wd )X (mcx , ux )
(3.19)
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)
(3.22)
15
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)
(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
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
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
-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:
= 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 )
(4.3)
17
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)
(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)
= (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:
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)
(4.10)
(4.9)
Yeen1
In Set
1
Yeem
varean
22
vaream
Aen
A
Aem
(4.11)
19
(4.9)
(4.12)
(4.9)
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)
(4.14)
(4.9)
In Set
Aen+1
A
Aem+1
absa
en
24
absa
em
Aen
A
Aem
20
Yeen1 + 2en + en+1
en
25
en
a
[varean ,appa
en ,absen ]
Aen
2en
(4.15)
varean )(mi )
(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)
(4.21)
This holds iff en+1 t = en+1 t . Hence, by structural induction = . The theorem follows.
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
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)
(5.4)
(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)
(5.6)
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)
(5.7)
22
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)
(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.
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
-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.