How to define functionals on free structures in typed λ calculus
-
Upload
jagiellonian -
Category
Documents
-
view
2 -
download
0
Transcript of How to define functionals on free structures in typed λ calculus
HOW TO DEFINE FUNCTIONALS ON FREE STRUCTURES IN TYPED x CALCULUS
Marek Zaionc Ins ty tu t Informatyki , Jagiellonian Universi ty
Kopernika 27~ 31-501 Krakbw, Poland
1.INTRODUCTION.
In papers of S c h w i c h t e n b e r g and Statman ( c f . [ S c h 7 5 ] , [ S t a 7 9 ] ) there is
a characteristic of the ;k definable functions over natural number type
(0~0)~(0~0) i.e algebra base on the signature [I,0]. Paper [Zai87]
have solved the same problem for a word X definable functions over the
type (O~O)n~(O~O) i.e algebra [1 ..... 1,0]. The result about ;k
d e f i n a b l e t r e e o p e r a t i o n s i .e in a l g e b r a £2 ,0 ] is d i s c u s e d in [ Z a i S 8 ] .
This paper try to characterize ~ definability in arbitrary free
a l g e b r a . T h e r e is a n a t u r a l i s o m o r p h i s m w h i c h i d e n t i f i e s f r e e
a l g e b r a s w i t h n o n e m p t y s e c o n d o r d e r t y p e s . I f A is an f r e e a l g e b r a
d e t e r m i n e d by t h e s i g n a t u r e S A = [ a i , . . . , a n ] t h e n by a t y p e T A we mean
Ti, . . ,~T ~0 w h e r e T =0 L~0. i t c a n be s e e n t h a t c l o s e d t e r m s o f t h e
type T r e f l ex const ruc t ions in the algebra A. There fo re any term o f
the type (TA)n~T A defines some n-ary mapping in algebra A. The problem
is t o c h a r a c t e r i z e A d e f i n a b l e m a p p i n g s in a n y f r e e a l g e b r a . I t is
p r o v e d t h a t t h e s e t o f A d e f i n a b l e o p e r a t i o n s is t h e min ima l s e t
c o n t a i n i n g c o n s t a n t f u n c t i o n s , p r o j e c t i o n s and c l o s e d f o r c o m p o s i t i o n
and t i m i t e d r e c u r s i o n .
2. TYPED >- CALCULUS.
Our language is derived from Church's [Chu40],[Chu41] simple theory o f
types. Every term possesses a unique type which indicates i ts posi t ion
in a funct ional hierarchy. The se t TYPES is def ined as fol lows: 0 is a
type and i f T and T 2 are types then T -~T is a type. Y/e use the i 2
fol lowing notat ion: i f T,Ti~ ...:T n are types then by T i .... ,T n ~T we
understand the type T ~(T ~(..,~(T ~T)).,.). There fo re , every type T 2 n
has the unique form T ~(T ~(...~(T ~0)..,), The type T is called the i 2 n t
component o f T and is denoted by T[i]. Y/e define inductively type
T[i I .... , i k] b y (TE i i ] . . . [ i k_ i ] ) [ i k ] . We sha l ! a b b r e v i a t e r ~
T i *(T z ~(...~(T n ~T),..) by L XITL~T (both no ta t ions adopted from
[StaB1] p 330). By a Tn~H we mean the type T~(T~(... (T~p)..,) with n
occurrences o f T (with T°-~H=H). For any type T we define numbers
rank(T> and arg(T) as fo l lows: arg(O)=rank(O)=O and arg(Ti,...,Tn~O)=n
and rank(Ti, ...,T ~0)= max (rank(T)>+I, Regular type introduced n l = l , , , n "
in [Zai85] is type T which s a t i s f y the fol lowing condition: rank(T)-<3
567
a n d i f i < a r g ( T ) t h e n a r g ( T [ i ] ) < l .
A s s o c i a t e d w i t h e a c h t y p e T is a d e n u m e r a b l e s e t o f v a r i a b l e s
V ( T ) , A n y v a r i a b l e o f t y p e T is a t e r m o f t y p e T. I f T is a t e r m o f
t y p e T ~T 2 a n d S is a t e r m o£ t y p e T t h e n TS is a t e r m o f t y p e ~ z i£
T is a t e r m o f t y p e T a n d x is a v a r i a b l e o f t y p e T t h e n ~x .T i s a 2 1
t e r m o f t y p e T ~T . I f T is ~ t e r m o f t y p e T we w r i t e T~T. I f T is a i 2
t e r m a n d x is a v a r i a b l e o f t h e s a m e t y p e a s a t e r m S, t h e n b y T [ x / S ]
d e n o t s t h e s u b s t i t u t i o n o f t h e t e r m S f o r e a c h f r e e o c c u r r e n c e o f x in
T. T [ x / / S ] d e n o t e s a n y o f t h e t e r m s o b t a i n e d b y s u b s t i t u t i o n f o r a t
m o s t o n e f r e e o c c u r r e n c e o f x b y t h e t e r m S in T. T h e a x i o m s o f
e q u a l i t y b e t w e e n t e r m s h a v e t h e f o r m o f ~ c o n v e r s i o n s ( s e e [ B e r 8 1 ]
o r [ F r i 7 5 ] ) a n d t h e c o n v e r t i b l e t e r m s a r e w r i t t e n a s T = / ~ S . By t h e
C I (T ) we m e a n t h e s e t o f a l l c l o s e d t e r m s ( w i t h o u t f r e e v a r i a b l e s ) o f
t y p e T. T e r m T is in t h e l o n g n o r m a l f o r m i f T=;~x ,..x .yT ...T k w h e r e
y is an × f o r s o m e i<n o r ~v is a f r e e v a r i a b l e , T f o r j_<k a r e in t h e 3
l o n g n o r m a l f o r m a n d ~ T . . . T is a t e r m o f g r o u n d t y p e . L o n g n o r m a l
f o r m s e x i s t a n d a r e u n i q u e f o r ~ c o n v e r s i o n s ( c o m p a r e [ C u r e S ] o r
[ S t a S 0 ] ) .
3. ;~ CALCULUS WITH TUPLE TYPES.
In o r d e r t o e a s i l y r e p r e s e n t a n d m a n i p u l a t e on f i n i t e s t r i n g s o f t e r m s
o f p o t e n t i a l l y d i f f e r e n t t y p e s we e x t e n d o u r l a n g u a g e b y a d d i n g n e w
constructor for forming cartesian product of types and terms. By
TYPES* w e m e a n t h e m in ima l s e t c o n t a i n i n g TYPES a n d c l o s e d f o r t h e
cartes ian product format ion : i f zl, ..., Tn~TYPES* then
[ T i , . . . , T n ] ~ T Y P E S * . T h e e m p t y t u p l e is d e n o t e d b y ~ T Y P E S * . We u s e t h e
a b b r e v i a t i o n ~=xiT ~ f o r s t r i n g [? , , . . ,Tn ] . We a s s u m e t h a t s t r i n g o f n
e m p t y t y p e s is e m p t y , s o x ~=w. In t h e c a s e w h e n a l l T. a r e t h e s a m e
we u s e n o t a t i o n T n i n s t e a d o f x T ( w i t h T0=W). We a l s o e x t e n d t h e L = l
n
t y p e f o r m a t i o n ~ f o r s t r i n g t y p e s a s f o l l o w s : =XlT~H' m e a n s rn Tn
~(~ ~. . . (T ~H) . . . ) i n c l u d i n g c0~=H a n d "r-~i~j m e a n s x ( z ~ H ) Tt 2 n j = i j
i n c l u d i n g T~w=w. P a r t i c u l a r l y we h a v e x ? .~ x H.= _x i (~x T . ~ . ) a n d L = i ~ j = i 3 ~ = I t 3
0 T ~ H = H . S i n c e t y p e s a r e u s u a l l y e m p l o y e d f o r d e s c r i b i n g c o n s t r u c t i o n
o f f u n c t i o n s p a c e s t h e a b o v e d e f i n i t i o n s a r e in f a c t " t y p i c a l "
i d e n t i f i c a t i o n s . T h e f i r s t e q u a t i o n i d e n t i f i e s A BxC w i t h A BC w h i c h
u s u a l l y is c a l l e d " C u r r y i n g " . T h e s e c o n d e q u a t e s ( A x B ) C w i t h A C x B C. We
w i l l c a l l e l e m e n t s o f T Y P E S * t y p e s a n d e l e m e n t s of TYPES s i m p l e t y p e s .
I t is e a s y t o o b s e r v e t h a t e v e r y s i m p l e t y p e a d m i t s t h e u n i q u e f o r m n
x T ~O w h e r e T a r e a l s o s i m p l e t y p e s c a l l e d c o m p o n e n t s o f T. We c a n ~ = i g i.
p r o v e s e v e r a l e q u a t i o n b e t w e e n t y p e s , f o r e x a m p l e
568
(~_ R)n =T~/n 3.1
('ok ~/ /) n = w k - ~ n 3 , 2
k k n n
f o r s i m p l e t y p e T o f a r i t y k , T =('~:tx T . ~ 0 ) n t = ~:XtTt~0' 3 .3
n ~ n k ~ . k n ~
x T J= x ( x T-~0 J)= x T-~ x 0 j 3.4 j=i j=s t=i t ~=i L j=i
L a n g u a g e o v e r t u p l e t y p e s is bu i ld in t h e s i m i l a r w a y . I f M is a
f i n i t e a t r i n g o f t e r m s [ ~ . . . . . M n ] o f t y p e s T t , ...,T n r e s p e c t i v e l y n 13
t h e n M is d e n o t e d by t x ~ o f t h e t y p e ~=x iT U We u s e t h e s a m e
n o t a t i o n MeT t o s a y t h a t M is a t e r m o f t y p e r f o r i<n. Th i s
d e f i n i t i o n m a y by i t e r a t e d so we may c o n s i d e r s t r i n g s of s t r i n g s of
t e r m s and s o on . The e m p t y t u p l e o f t e r m s is d e n o t e d by ~ o f t y p e ox n
In t h e c a s e w h e n a l l H a r e t h e s a m e w e u s e H n i n s t e a d of txiM w i t h t3 13
~n----l~. T e r m f o r m a t i o n is f o l l o w i n g : If Me t : " x IT ~ U a n d Ne ~.~: l ' r then by n
MN we m e a n MN , . .N o f t y p e ~ w i t h MD=M w h e n x "r =~ ( n = 0 ) . I f i n t = i t
m
MeT-*j_xiH j and NeT t hen by MN we mean [~N~, .... MmN] o r e q u i v a l e n t l y m
x M.N o f t y p e xn~Hj w i t h ON=S3 in c a s e w h e n m=0. I f Me/~ a n d x is = ~=i ~ j n
v a r i a b l e of t y p e t ~ i v t t h e n by ~x.M we m e a n ;kx l . . .x .H of n t y p e ~ x~Tt~/~ m
w i t h ;kx0./V=M f o r v a r i a b l e x o f t y p e co. I f Me ~=x /~ and x is a v a r i a b l e
o f t y p e T t h e n by Xx.M we mean [ A x . ~ , . . . , ~ x . M ] w h i c h is i d e n t i c a l #1
m ~q
w i t h L=x t (Xx .H t ) o f t y p e T~ x U w i t h ;kx.Q=13 w h e n ms0 . I f M is a t e r m j=i-j 13 rt
o f t y p e t = x (T~H~) a n d N is a t e r m o f t y p e ~ x l ' r t t h e n b y p a r a l l e l r~ n
a p p l i c a t i o n HBN w e m e a n t h e t e r m x l ~ N c o f t y p e x /~. I f x is a 13 n
v a r i a b l e of type ~= " i,=xl/a~ x "r t and M~ then b y p a r a l l e l a b s t r a c t i o n kxeM r~
we m e a n t h e t e r m [Xx i .M i . . . . . Xxn.M n] o f t y p e t ~ i ( ~ t ) " We m a y
s u m m a r i z e a l l t h o s e d e f i n i t i o n s by :
n
M( x N) --- MN ...N with hK~ = M t=l t I n
n
( x M)N ---- tx1(MtN) w i t h ~3N = i,=,t =
n
A(~xlxt)'M = ~'xi'"xn'M w i t h
r~ n
~x.(txl/4 ~) = x10,x.M ~) w i t h
n rl
Xx ./4 = M CO
3 .5
3.S
3 . 7
3 .8
3 ,9
569
X( x l × i ) e ( i x i M L ) . = = x i ( X x ~ ' = . M). 3.10
By s imp le t e r m we mean m t e r m o f e s imp le t y p e , I f M is a s imp le t e r m n
and × is a v a r i a b l e o f t y p e ~ x t ~ i and N ~ i ~ i T L t h e n ~ : < / N ] d e n o t e s t h e
t e r m o b t a i n by s i m u l t a n e o u s s u b s t i t u t i o n o f t h e t e r m s N f o r e a c h f r e e k
o c c u r r e n c e s o f ×~ r e s p e c t i v e l y in M. I f M~ ~x~H~ t h e n h E x / N ] means
[ M i [ x / N ] .... , M k [ × / N ] ] and i f n=k t h e n ~ x / / N ] m e a n s
. . . . . w e d e f i n e c o n v e r s i o n s a n d t h e n o t i o n o f
long normal form recursively of the complexity of tuple types. Two
terma P/ and N of the ssme type t__x /~ are equal modulo conversions M
=~gN i f and only i f M =/~ ~ fo r all i<n. We say that term M of type
~xiH ~ is in long-normal form if every M is in long-normal form and M
is called closed i£ every M is closed. We can prove the following
extensions o f conversions
XxeM = ~;eM[×//~]
(Xx.M)N = Mtx/A r]
(XxOM)BN = F K x / / N ]
~x.(Mx) = M
XxO(Mgx) = M F~9
3.11 ( s e q u e n t i a l ~ c o n v e r s i o n )
3.1Z ( p a r a l l e l ~ c o n v e r s i o n )
3.13 ( s e q u e n t i a l /3 c o n v e r s i o n )
3.14 ( p a r a l l e l # c o n v e r s i o n )
3.15 ( s e q u e n t i a l T/ c o n v e r s i o n )
3.16 ( p a r a l l e l T/ c o n v e r s i o n )
Hav ing p r o v e d t h e e x i s t a n c e o f t h e l o n g - n o r m a l f o r m in o r d i n a r y t y p e d
X c a l c u l u s we can show t h e same f o r t u p l e t e r m s by i n d u c t i o n . I f M is n
a t e r m o f t y p e ~ x H~ t h e n by ~ we mean i - t h c o o r d i n a t e o f M,
there fore we h a v e
(MN){ = MiN 3.17
(X×.M) = Xx.M~ 3.18
= 3 1 9
CXxeM) L = XxcM ~ 3.Z0
( x H.). = M 3.21 L = i t 3 3
~L = 13 3.22
In t h e p a r a g r a p h 4 we wi l l ~ n v e s t i g a t e r e p r e s e n t a b i l i t y o£ o p e r a t i o n s
in a f r e e a l g e b r a by X t e r m s . I f S A = [~ i .... "~n ] is a s i g n a t u r e o f
some a l g e b r a A t h e n by T A we mean t h e t y p e [ i=x t (O { * 0 ) ] * 0 . T j is t h e
s imp le t y p e . We wi l l s e e t h a t c l o s e d t e r m s o f t h i s t y p e r e f l e c t
c o n s t r u c t i o n s in a l g e b r a A. By T A we mean i - t h c o m p o n e n t o f t y p e T A
cx (TA)~. i . e . T A = 0 ~ 0 . L e t Z L be a v a r i a b l e o f t y p e and × be a i
570
n CX v a r i a b l e o f t y p e [ × ( 0 ~ 0 ) ] . L e t C be a c l o s e d t e r m o f t y p e
t = t
n [(TA)CXi. T A ] [ C i . . . . . Cn ] x d e f i n e d by C = w h e r e C o f t h e t y p e C~
A t A . ( T ) -*? IS C.=~.Zix.×i(Z×). L e t ~ be a c o l l e c t i o n o f c l o s e d t e r m s o f A p t y p e s ( T ) ~T d e f i n e d r e c u r s i v e l y a s a min imal s e t c o n t a i n i n g >.s.$i
and Xs.C i f o r ~ = 0 and s a t i s f y i n g f o l l o w i n g p r o p e r t y : I f D is a
c l o s e d t e r m o f t y p e (TA)P~(TA) ~ f o r ~ > 0 s u c h t h a t D E~ f o r a l l j_<~ J
t h e n a c l o s e d t e r m ;ksoC(Ds) o f t y p e (TA)P~T A b e l o n g s t o ~. Th is
i n c l u d e s t h e s i t u a t i o n when ~ is 0, t h e r e f o r e e c l o s e d t e r m ~s.C~
b e l o n g s t o ~ w h e n e v e r ~i=O. In n e x t f e w l emmas we u s e v a r i a b l e s and
c o n s t a n t s o f some s p e c i a l t y p e s . Bar o v e r a name o f t e r m i n d i c a t e s
t h a t i t is a c l o s e d t e r m o f a p p r o p r i a t e type+ L e t A be a c l o s e d t e r m
of type (TA) p, B be aterm of type O, C be a closed term of type
n [(,rA)at_~TA], (TA)P.,(TA)Oti, x D be a closed term of type E be a
v a r i a b l e o f t y p e ('rA)P-,~r A, [" be a c l o s e d t e r m o f t y p e
×n [(TA)0t+k+,zA)] G, G' n [(~_A)~i,. A], i=~ , be terms o f type × ~{ be a
c l o s e d t e r m of t y p e (TA)k+I~TA, I be a c l o s e d t e r m o f t y p e
n n (TA)k_~( A)C~t (TA)k~(. × TA)~( × T A) J be a closed term o f type
n A ~" K,K',K i, .... K terms of type ~xi(~)+(O ~+0), P be a closed term of
l
t y p e (TA)k~T A, R be a v a r i a b l e o f t y p e ~ x i 0 , S be a v a r i a b l e o f
t y p e T A, T be a v a r i a b l e o f t y p e ( A)k %,Y be v a r i a b l e o f t y p e
~x ( ~ ) , Z~ be a v a r i a b l e o f t y p e ~ be a v a r i a b l e o f t y p e
(TA)Px,~,~ be v a r i a b l e s of t y p e ~=XT A
(TA)k >(TA) c~t" Lem~a 3. 1 • Let ] be a closed term o f type Let
-H=XTx. ×C-~TxD. For every closed term T o f type (TA) ~, ~=~Ci ( : ]T ) .
P r o o f . T r i v i a l l y f o l l o w s f r o m t h e d e f i n i t i o n s o f H and C~
n ;-i Lemma 3. P~ L e t T be a c l o s e d t e r m o f t y p e ( A ) k ( × ?A)~( x A ) L e t
t = t ~ t = ~ L n A O~+k A
be a c l o s e d t e r m o f t y p e × [ (~ ) ~T ) ] d e f i n e d by t = t
FmXY~(;kTx. ((TTxDBCY×))). Let H be a closed term of type ('cA)k+*-,-~ A
defined by -H,=XSTx. S(TTx). For every closed term T o f type ( A)k and
every closed term ~ of type Y~ ~ D C(
P r o o f . We can check t h a t b o t h t e r m s h a v e t h e s a m e t y p e ( A)n We m u s t
remember tha t since Y is a closed term of type~=xi(TA) ~ then ~ has a
form ~x ¥ = x Jx~(Y~)~"
571
Le~mla 3 . 3 I f E iS a c l o s e d t e r m o f t y p e (?A)p~TA f r o m t h e c o l l e c t i o n
t h e n f o r e v e r y c l o s e d t e r m s T, A a n d H, t e r m s kx. ECkz. CH'PlADTxD× a n d
ECCHP.,ADTD a r e /~q conver t ib le . A
P r o v e . I t is e a s y t o c h e c k t h a t b o t h t e r m s h a v e t h e s a m e t y p e T . The
p r o v e o f t h e l emma is by ~nduc t i on on t h e c o n s t r u c t i o n o f f u n c t i o n
f r o m ~.
n _ O~*k x [ ( n ) t ~ A)] s u c h t h a t Lemma 3,4 Let F be a closed term o f type ~--i
n
x [(~A)at+~ A] def ined by f o r every closed term ~ ~ term G o f type ~=~
;kXI(~IX)T belongs t o n. Let H be a closed term o f type (TA)k+~+~ A
def ined by kET×.~CkRICFICk~.~DT×D. For every closed term T o f type n a x { A) ( ' rA) k and every closed term Y o f type ~ = i
r i a .
(Hnu(~nY))~=/~ (yn([ t __xH ~BYt]T))T.
P r o o f . We c a n c h e c k t h a t b o t h t e r m s h a v e t h e s a m e t y p e (TA) n. L e t
a n d Y be c l o s e d t e r m s .
n n A Lemma 3 . 5 L e t T b e s c l o s e d t e r m o f t y p e ( A)k ( x TA~ x i T ) . L e t L= I t ~= •
A a+k A n be a c l o s e d t e r m o f t y p e x [ (T ) ~T )1 d e f i n e d by
F=XY41~Tx . CCTT×DICYx))D. F o r e v e r y c l o s e d t e r m T a c l o s e d t e r m
n [(TA)a~ A)] d e f i n e d a s XXOC~lX)T of t y p e x b e l o n g s t o ~.
n C~ +k Proof . Type o f F is xi[(TA)= ~ +rA)]. We prove t h a t ~ r ~ f o r every
r_<n. Let T b e a c l o s e d t e r m . N is XXr.FrXT = ~ , kX ×.T T'-x(X x ) . T ~ a , n
is a s i m p l e c l o s e d t e r m o f t y p e x ~A-,r n = ~= i ~ r t_xtT ~ { 0 ~ 0 ) . S i n c e
rank{ ~' =x TA~(o. t~O))<2_ then the re is a f i n i t e term grammar which
p r o d u c e s a l l c l o s e d t e r m s o f t h i s t y p e . C o n s u l t f o r d e t a i l s t h e o r e m
1.2.3 o r [ Z a i 8 7 a ] p a g e 31S p r o p o s i t i o n 5 .2 o r [ Z a i 8 7 b ] p a g e 4 Lemma
2.3. Proof is by induction on the grammar cons t ruc t ion o f the term
I T . r
Lemma 3 . 0 E v e r y l o n g - n o r m a l c l o s e d t e r m P o f t y p e ('rA)k-*~ "A i s in o n e
o f t h r e e f o r m s
1. P=XTx. ×t i f a t=0
2. P=XTx. ×CJT×D f o r s o m e c l o s e d t e r m ~ i f ~ t>0
3. P=XT×. ~CTT×D f o r s o m e c l o s e d t e r m I-
&. FREE ALGEBRAS.
A l g e b r a A g i v e n b y a s i g n a t u r e SA = [ a i , . . . ,a n] h a s n c o n s t r u c t o r s
c t , . . . c n o f a r i t i e s a i , .... a n r e s p e c t i v e l y . E x p r e s s i o n s o f t h e a l g e b r a
A a r e d e f i n e d r e c u r s i v e l y a s a m in ima l s e t s u c h t h a t i f a = O t h e n c~
572
is an e x p r e s s i o n and i f t ,._,t a r e e x p r e s s i o n s t h e n c ( t , . . . , t a ) t
is an e x p r e s s i o n . We may a s s u m e t h a t a t l e a s t one ~ is e q u a l O,
o t h e r w i s e t h e s e t o f e x p r e s s i o n s is e m p t y . L e t A be t h e s e t o f a l l
e x p r e s s i o n s in a l g e b r a A. We a r e go ing t o i n v e s t i g a t e m a p p i n g s f :Ak+A. a .
Any c o n s t r u c t o r can be e e e n as a f u n c t i o n ct:A ~+A. Th is i n c l u d e s t h e
s i t u a t i o n when ~ = 0 . L e t x be a l i s t o f e x p r e s s i o n s x i . . . . . x k and
f1' " " ' f n be f u n c t i o n s o f a r i t y k + ~ r e s p e c t i v e l y . A c l a s s X o f
m a p p i n g s is c l o s e d f o r p r i m i t i v e r e c u r s i o n i f t h e k + l a r y f u n c t i o n h
d e f i n e d by
h ( c i ( Y i , .... Y a ) , X ) = f ( h ( y l , x ) . . . . . h(Ycx , ~ ) , x ) L
f o r a l l i_<n b e l o n g s t o X w h e n e v e r f u n c t i o n s f i ' .... f n a r e in X. In t h e
c a s e when a~:O t h e e q u a t i o n is r e d u c e d t o h ( c t , x ) : f t ( x ) . L e t us
d i s t i n g u i s h t h e f o l l o w i n g o p e r a t i o n s , p~ is t h e k - a r y p r o j e c t i o n wh ich
e x t r a c t s i - t h a r g u m e n t i .e. p~(x t , . . . , xk )=x ~, The c l a s s F o f
o p e r a t i o n s is d e f i n e d a s a min imal c l a s s c o n t a i n i n g c o n s t r u c t o r s ,
p r o j e c t i o n s and c l o s e d f o r c o m p o s i t i o n and p r i m i t i v e r e c u r s i o n . The
c F is a min imal c l a s s c o n t a i n i n g p r o j e c t i o n s , c o n s t r u c t o r s s u b c l a s s F o_
and c l o s e d f o r c o m p o s i t i o n . The s u b c l a s s F k _c F f o r k>_0 is a c l a s s o f
a l l k + p - a r y f u n c t i o n s f such t h a t f o r e v e r y e x p r e s s i o n s E i , . , . ,EPE A
t h e f u n c t i o n p d e f i n e d a s P(X t , . . . , x ] ) = f ( x i , +..,xk,E i , ..+,Ep) b e l o n g s
t o F o. Th is i n c l u d e s a c a s e when k=O wh ich m e a n s t h a t F ° is a s e t o f
c o n s t a n t O - a r y c o n s t r u c t o r s . The c l a s s F~ is a min imal c l a s s
c o n t a i n i n g c o n s t r u c t i o n s , p r o j e c t i o n s and c l o s e d f o r c o m p o s i t i o n and
t h e f o l l o w i n g l i m i t e d v e r s i o n o f p r i m i t i v e r e c u r s i o n : i f f EFxn F C~ t
f o r i_<n t h e n t h e f u n c t i o n h d e f i n e d a s :
h(c~(Y i , .... Ya ),:;~) = f ~ ( h ( y i , x ) . . . . . h ( y ~ ,~ : ) ,x ) t
b e l o n g s t o F;~.
5. REPRESENTABILITY. I f A is an a l g e b r a g i ven by a s i g n a t u r e SA=[a t . . . . . a n] t h e n by T A we
n a t mean a A t y p e ~=xi[O ~O]+O. A s s u m i n g t h a t a t l e a s t one =~ is 0 we h a v e
t h a t T is n o t e m p t y . F o r e x a m p l e we may a p p l y S t a t m a n t e s t ( s e e
[S taT@] p r o p o s i t i o n 4 p a g e 7 9 ) . T h e r e is a n a t u r a l 1-1 i s o m o r p h i s m
b e t w e e n e x p r e s s i o n s o f a l g e b r a A and c l o s e d t e r m s o f t y p e r A. I f c~ is
an O - a r y c o n s t r u c t o r in A t h e n ~=;~x i . . . xn .x~ r e p r e s e n t s c t. I f a > O
and t t , . . . , t a a r e e x p r e s s i o n s in A r e p r e s e n t e d by c l o s e d t e r m s o f t
t y p e T A T i , . . . ,T a t h e n e x p r e s s i o n c ( t i + . . . , t a } is r e p r e s e n t e d by
t h e t e r m N x . . . x . x ( T × . . . x ) . . . . ( T x . . . x ) o r wh ich is I n t i i m C ( i n
573
equivalent, by term kx ,x i (Tx) or <T where T=[Ti, ..,,To~ ], Thus, we
h a v e a I-I c o r r e s p o n d e n c e b e t w e e n CI(T A) and A. The un ique (up t o t3~
c o n v e r s i o n ) t e r m wh ich r e p r e s e n t s an e x p r e s s i o n t is d e n o t e d by t . A
f u n c t i o n h:An~A is r e p r e s e n t e d by c l o s e d t e r m H o f t y p e (TA)~+7 A i f f
f o r a l l e x p r e s s i o n s t i , . . . , t n, H t i . . . t = /~gh( t t , . . . . i n ) . Any t e r m wh ich
r e p r e s e n t s t h e f u n c t i o n h is d e n o t e d by h. A f u n c t i o n h:An+A is c a l l e d
k d e f i n a b l e i f t h e r e is a t e r m H~'CI((~A)n-*+r A) which r e p r e s e n t s h. I t
is easy to observe t ha t any closed term H o f the type (TA)n-*T A
un ique l y d e f i n e t h e f u n c t i o n h :An+A a s f o l l o w s : If t i ' " " ' t n=--A a r e
e x p r e s s i o n s t h e n t h e v a l u e is an e x p r e s s i o n r e p r e s e n t e d by t h e t e r m
Ht i ' ...,t n" Contrar i ly one funct ion can be represented by many
unconvert ib le terms. Let gi" .... gn are funct ions such t ha t g~ is
n O~L TA] X [ (T A) ~ - a r y f u n c t i o n f o r a l l tSn. A c l o s e d t e r m G o f t y p e ~=
r ep resen ts the system g~ .... "gn i f f f o r all i_<n gL is represen ted by
G+
Example 5.1. (adopted f rom [Zai88]) Let A=[2,O] be a algebra o f binary
t r ees . Let ~ be a O-ary cons t ruc to r (empty t r e e ) and ^ be binary t r e e
cons t ruc to r . In th is example inf ix no ta t ion f o r binary cons t ruc to r ^
is used. By t i ^ t z we mean a t r e e such t h a t t l and tz are respec t i ve ly
l e f t and r ight subt rees . In th is example A is a se t o f all binary
t rees . Type T A is (0+(0~0))+(0+0). Let H be a closed term
kTSp×. T[~Spx) o f t y p e (TA)Z-~T A . I t is e a s y t o o b s e r v e t h a t H
r e p r e s e n t s f u n c t i o n append:AZ+A d e f i n e d by
(zppend(~, S ) =S
czppeTtd( ti^tz , s )=( czppe nd( tl , s ) ) ̂ ( clp~c~gnd( tz , s ) )
Function c~ppeT~C~ iS obtain by recursion schema from the functions
g(s)=s and f(y,z,s)=y^z. Since gEF k and fc--Fkr3= z the function append
belongs to F k.
Lemma 5 . 2 The t e r m ~ r e p r e s e n t s t h e s y s t e m o f f u n c t i o n s ( c o n s t r u c t o r s )
,...,C ). (Cl n
Proof . Tr iv ial ly fo l lows from the def in i t ion o f C.
Lemma 5.3 The col lect ion ~ o f terms is j u s t the se t o f r ep resen ta t i ves
o f elements f rom the class F . 0
Proof . By induction o f the const ruc t ion o f elements f rom ~. The
c o n s t r u c t o r s are rep resen ted (lemma 5.2). Pro jec t ions are represented .
L e t f :AnnA be a f u n c t i o n r e p r e s e n t e d by F ~ . L e t f u n c t i o n s
gt:Ak+A ... . ,gn:Ak~A be r e p r e s e n t e d by t e r m s Gt,.. . ,Gn f r o m ~. A
f u n c t i o n h d e f i n e d by h ( e . . . . . e k ) = f ( g (e i . . . . . e k) . . . . g n ( e . . . . . ek ) )
is r e p r e s e n t e d by t e r m AT. FCGiTD.. ,CGnT~. By s imp le i n d u c t i o n on t h e construction on F we can check that H~.
574
n ~ ÷k A t A
Lemma 5 . 4 L e t F be s c l o s e d t e r m o f t y p e t ~ [ (~ ) +~- ] r e p r e s e n t i n g
t h e s y s t e m o f f u n c t i o n s f i ' - " f n " L e t h:Ak+i+A be a f u n c t i o n d e f i n e d
by r e c u r s i o n f r o m f u n c t i o n s f ~.. . , f . L e t H be a c l o s e d t e r m o f t y p e
( A)k+~ A The f o l l o w i n g t w o s t a t e m e n t s a r e e q u i v a l e n t :
"1. T e r m H r e p r e s e n t s h
2. ( H n l I ( C I I Y ) ) T = ~ ( F e ( [ x H = ~ B ~ ] T ) ) T f o r e v e r y c l o s e d ~ and
P r o o f . By s imp le e n c o d i n g in N c a l c u l u s t h e d e f i n i t i o n o f p r i m i t i v e
r e c u r s i o n .
Theo rem 5 . 5 ( s o u n d n e s s ) I f f~F~, t h e n f is ;~ d e f i n a b l e .
P r o o f . By i n d u c t i o n on t h e c o n s t r u c t i o n o f f u n c t i o n s f r o m F~. Al l
c o n s t r u c t o r s a r e r e p r e s e n t e d ( s e e lemma 5.2 . ) T r i v i a l l y a l l
p r o j e c t i o n s a r e r e p r e s e n t e d and r e p r e s e n t a b i l i t y is p r e s e r v e d by
c o m p o s i t i o n . We w a n t t o s h o w t h a t r e p r e s e n t a b i l i t y is a l s o p r e s e r v e d
by l i m i t e d p r i m i t i v e r e c u r s i o n . L e t f t " " " ' f n be k+~ - a r y f u n c t i o n s C(.
s u c h t h a t f t ~ F ~ f o r i_<n. L e t h be a n + l - a r y f u n c t i o n d e f i n e d by
l i m i t e d p r i m i t i v e r e c u r s i o n f r o m f l ' """ f n" L e t t h e s y s t e m f i ' """ f n n A ~i. +k A
be r e p r e s e n t e d by a c l o s e d t e r m F o f t y p e x [ (w ) ~T ]. t = i
A s s u m p t i o n t h a t f b e l o n g s t o F t m e a n s t h a t f o r e v e r y e x p r e s s i o n s
t i , . . . , t k f u n c t i o n (× ~...,x ) ~ f (× , , . . ,× , t , . . . , t k) b e l o n g s t o t a t ~ i c~ t l
F o. Th is f u n c t i o n is r e p r e s e n t e d by a t e r m ~ d e f i n e d a s ;~X C FXtT
w h e r e T is a r e p r e s e n t a t i o n o f t h e s y s t e m t t . . . . . t k. A c c o r d i n g t o
lemma 5.3 ~ b e l o n g s t o ~. T h e r e f o r e a t u p l e t e r m
G=[G i .... , ~ ] = ~ X e C F I X D T b e l o n g s t o ~ f o r e v e r y T. L e t H be a c l o s e d
t e r m o f t y p e (TA)k+i~TA d e f i n e d by X3Tx. 3C%RICPlCN=. R)DTx3. By lemma
354 we h a v e t h a t f o r e v e r y ~ and 7 n C~, x=iH BYt]T))T. A c c o r d i n g t o Bemma 5.4 i t m e a n s
t h a t H r e p r e s e n t h.
L e t we i n t r o d u c e s s p e c i a l m e a s u r e o f c o m p l e x i t y p f o r c l o s e d
t e r m s o f a n y o f t y p e s t y p e ( T A ) k - * ( X TA-~O) f o r k:>~l. I f ~ T x . B i s s
c l o s e d t e r m o f t h i s t y p e t h e n by p(;kT×.B) we mean a n u m b e r o f
o c c u r r e n c e s o f T , , . . . ,T k in t h e l o n g - n o r m a l f o r m o f t h e t e r m B s u c h
t h a t any T. f o r j_<k d o e s no:t o c c u r in a c o n t e x t T.x. A f o r m a l J J
d e f i n i t i o n is f o l l o w i n g :
p (XT×.× t )=0 f o r a l l i s u c h t h a t ~t=0
<x i p(XTx.xi,('JTx))= ~, p ( ~ . ) f o r ~t>0
J j = t
575
p(NTx.TI (~Tx))=O i f ~Tx =[~q x r~
p(XTx.Tt(TTx))=I+ ~. ~(~)~ i f TTx ~ / ~ x j = i
In t h e n e x t t h e o r e m we a r e go ing t o d e s i g n a p r o c e d u r e wh ich r e d u c e
t h e p r o b l e m of" r e p r e s e n t a b H i t y o f a c l o s e d t e r m t o p o s s i b l y f e w
" s i m p l e r " p r o b l e m s . F o r t h e r e a s o n o f t e r m i n a t i o n o f t h i s p r o c e d u r e we
a r e go ing t o i n v e s t i g a t e s o m e q u a s i - o r d e r o f t e r m s . L e t we c o n s i d e r
t h e s e t o f p a i r s o f n a t u r a ~ n u m b e r s w e l l - o r d e r e d in t h e o r d i n a l ~x~.
For e v e r y c losed te rm P o f t ype (TA)k~(XI~[A-~O)= ~ we de f ine the pair o f
two numbers (#(P),~(P)). In the completeness theorem we will see t h a t
the p rocedure works in th is way t h a t the pai r Js decreas ing in the
ord ina l ~x~.
n A n A Le t T be a c losed te rm o f t ype ( ' r A ) k - , ( . x T -,~x ~ t ) . ~ = Le t F be Lenm~ 5 . 6
n A t i t +~= A a closed te rm o f t ype × [(~ ) ~ ] de f ined by
F=xYe(X.Tx. ((TTx)sCYx))), L e t P be a c l o s e d t e r m o f t y p e (TA)k-~ A
d e f i n e d by -P=XTx. TCTTx). If TTx ~[,~ x t h e n p ( ~ ) < p ( P ) f o r a l l i<n.
P r o o f , T e r m --F~ h a s a f o r m ~.YTx. t~T×CYix). I t is o b v i o u s t h a t t h e
n u m b e r o f o c c u r r e n c e s o f T ' s in F is l e s s by one t h e n t h e n u m b e r o f
T ' s in ;~Tx. TtCTTx). New v a r i a b l e s ( Y ) . f o r j_<~ o f t y p e A in t h e
te rm _Ft a re in t he c o n t e x t s o f Ytx t h e r e f o r e i t ' s occur rences does not
inc rease p.
T h e o r e m 5, 7 ( c o m p l e t e n e s s ) I f p is X d e f i n a b l e t h e n p~F~.
P r o o f . L e t P be a c l o s e d t e r m o f t y p e (TA)k~T A r e p r e s e n t i n g p. We a r e
go ing t o p r o v e t h e o r e m i n d u c t i v e l y on t h e c o m p l e x i t y ( p ( P ) , ~ ( P ) ) o f
t he te rm P. I f (p(P),~(P))=(O,m) then P mast be in one o f two possible
f o r m s , XT×.×i, w h e n c~.=O~ o r ?~T×.T~(TTx) if TTx=~×. ( s e e l e m m a 3 .S a n d
d e f i n i t i o n o f p ) . I f P=X.Tx.×i. t h e n ~ r e p r e s e n t s f u n c t i o n p:Ak~A wh ich
m a p s o n t o c o n s t r u c t o r c t c o n s t a n t l y p ( e 1 . . . . . p k ) = c u I f P=XTx. T(TTx) w h e r e TTx=/~gx t h e n i t m e a n s t h a t P=t~gXTx.T× =t~T.T~. In t h i s c a s e
r e p r e s e n t s p r o j e c t i o n p ( e i , . , .ek)=e U I n d u c t i o n s t e p . S u p p o s e t h e
t h e o r e m is t r u e f o r a l l c l o s e d t e r m s P" o f any o f t h e t y p e s (TA)r~T A
s u c h t h a t (p(-P'),~(-P))<(p(-F),r~(-P)). I f p ( P } > 0 t h e n a c c o r d i n g t o lemma
3 , 6 a n d d e f i n i t i o n o f p, P m a s t be in o n e o f t w o p o s s i b l e f o r m s :
P=XTx. x tC~T×) f o r s o m e c l o s e d t e r m ~ o r ~ ; ~ T x . T~CZ~x) f o r s o m e c l o s e d
t e rm T such t h a t TTx ~ x If P=XTx. x(.~-[x) f o r some closed te rm
then ~ {~ )<~(P) f o r al l r-<~ and # ( ~ ) < p ( P ' ) f o r all r<_~. T h e r e f o r e
a c c o r d i n g t o i n d u c t i o n a s s u m p t i o n ~ r e p r e s e n t s f u n c t i o n Jr f r o m
F~. We h a v e t h a t pCe i . . . . . e k ) = c ~ C j i ( e l . . . . ,e k) . . . . ~ j~ Ce I , . . . ,ek ) )
t h e r e f o r e p~F~. L e t P=;~T×. TiC'[Tx.) f o r s o m e c l o s e d t e r m T s u c h t h a t TTx
676
n ~ ~ . + k x [ ( T ~ ) ~ ~ A ] d e f i n e d by ~ D x . L e t F be a c l o s e d t e r m o f t y p e ~= i
~-=kYICXTx. ¢C-[Tx)eCYx))). By lemma 5.6 p(~) <p(P) for all j<n.
T h e r e f o r e F f o r i<n r e p r e s e n t s f u n c t i o n f.~ f r o m F k wh ich m e a n s t h a t
r e p r e s e n t s t h e s y s t e m o f f u n c t i o n s f , . . . , f . By lemma 3.5 we h a v e
t h a t f o r e v e r y T, c l o s e d t e r m G d e f i n e d by kXe~FBX)T b e l o n g s t o ~.
S ince ;KXeCFBXbT b e l o n g s t o ~ t h e n a c c o r d i n g t o lemma 5.3 f u n c t i o n f £ as a f u n c t i o n o f f i r s t a a r g u m e n t s b e l o n g s t o F o. Th is m e a n s t h a t
O~. O(
f ~ F ~. T h e r e f o r e f u n c t i o n f eFk~ F ~. L e t h:A ~ be a f u n c t i o n
d e f i n e d by l i m i t e d p r i m i t i v e r e c u r s i o n f r o m t h e s y s t e m f . . . . " fn" L e t
be a c l o s e d t e r m o f t y p e (TA)k+I'-*-TA d e f i n e d by kSTx. SC-fTx). By
lemma 3.2 we h a v e t h a t f o r e v e r y T and Y,
(HnB(~BY))T=/~ ( F e ( [ t x H ~B~ ]T ) )T , Thanks t o lemma 5.4 i t m e a n s t h a t
r e p r e s e n t s h, T h e r e f o r e h~F k. T h e r e is t h e f o l l o w i n g r e l a t i o n b e t w e e n
f u n c t i o n s h and p : p ( e i , . . . , e k ) = h ( e c e ~, .o.,ek). S ince t h e c l a s s F k is
c l o s e d f o r c o m p o s i t i o n s we h a v e p~Fk.
REFERENCES.
[Ber81] H. P. Berendregt The Lambda CalcuLus Studies tn Logic and th~ / o u n d a t t o ~ o / M a t h e n ~ t t c s , N o r t h - H o l l a n d 1981.
[CoH85] Coguand T, Huet G., ;1 t h e o r y o~ C o n s t r u c t i o n s , E u r o c a l 8 5 , L i nz , A u s t r i a ( 1 9 8 5 ) .
r chu40 ] A. Church ,4 f o r m u l a t i o n o / t he s i m p l e t h e o r y o / t y p e s , J o u r n a l o f Symbo l i c L o g i c 5 (1 ) 5 6 - 6 8 (1940)
[Chu41] A. Church TAe Cancel t o/ Lambda-Conuerston. Princeton U n i v e r s i t y P r e s s , P r i n c e t o n , N.J., 1941.
[ C u r B 8 ] H. B. C u r r y , R. F e y s Comb~.nator w L o g i c vo l 1, N o r t h - H o l l a n d , A m s t e r d a m 1968.
r F r i 7 5 ] H. F r i e d m a n EquaL~ t ~ b e t w e e n / u n c t t o n a T . s , L e c t u r e N o t e s in M a t h e m a t i c s vo l . 453 , 197'5, 2 2 - 3 7 .
[Hue75] G. Huet A ~ntftcat ton a~ort tam /or typed h-calculus, T h e o r e t i c a l C o m p u t e r S c i e n c e 1, 1975, 2 7 - 5 8 .
[ S c h 7 5 ] S c h w i c h t e n b e r g H., Deftnterbare F~nct torten tn~ X-Ka~u~t n~t t Ty/:~n, A r c h Ma th . Log i c G r u n d l a g e n f o r s c h 17 ( 1 9 7 5 - 7 6 ) pp 113-114.
[Sta79] S t a t m a n R. TAe T})ped k Ca~c~s ts Not ELementary) Rec~Lrstve T h e o r e t i c a l C o m p u t e r S c i e n c e 9, (1979) pp. 7"3-81.
[StaSO] R.Statman On tAe existence of c ~osed tern~s l'.n tAe t ~/ped k c a £ c u L ~ s I , In: H ind ley , R., Se ld i n , d. ( e d s ) : C o m b i n a t o r y Iog l c , l ambda c a l c u l u s , and f o r m a l s y s t e m s . New Y o r k : A c a d e m i c Press 1980.
[StaS3] Statman R. h-De/tnab~e F~Inc t 6ona~s clTtd (9~9 Cor~ez's~on.~ Arch. Math. L o g i c 23 ( 1983 ) pp. 21-26
[ Z a i 8 5 ] M. Z a i o n c TAe set o/ un~/~ers tn typed X c a l . c z ~ s as rea~u~ar expression, Lecture Notes in Computer Science 202, 1985, 430-440.
[ZaiST] M. Zaionc The Re~l~ar Expz'ess~on Descri.pt~on o/ Un~ff.er Set tn the Typed k CaLc~i~s, Fundamenta Informaticae X (1987) 309-322
[Zai87a]Zaionc M. Word operc~t fons deftruxbbe £n tAe t~lped k c~Zc~iL~J~ T h e o r e t i c a l C o m p u t e r S c i e n c e 52 ( 1987 ) pp . 1-14
[Za188 ] Z a i o n c M. A Chc~z'acter~st~c o/ k de/~rca~e Tree O p e r a t i o n s , S u b m i t t e d t o I n f o r m a t i o n & C o m p u t a t i o n