iso , 8M 9 2 M

2 downloads 0 Views 205KB Size Report
inj , 8M 9 2 M ! : is injective ii) ... 2. Proposition 2.4 ret ^ ret , iso . Proof. If ret , then there exist M ! and N ! in ..... exists ~M, having the same type and left-inverse as.
Retracts in simply typed  -calculus (Extended Abstract)

U.de'Liguoro A.Piperno Dipartimento di Scienze dell'Informazione Universita di Roma \La Sapienza" Via Salaria 113, I-00198 Roma, Italy

R.Statman Department of Mathematics Carnegie Mellon University Pittsburgh, PA 15213, USA

fdeliguoro,[email protected]

[email protected]

Abstract

In this paper retractions existing in all models of simply typed -calculus are studied, relating them to other relations among types as isomorphisms, surjections and injections. A formal system to deduce the existence of such retractions is shown to be sound and complete with respect to retractions de nable by linear -terms, and results aiming to a system complete w.r.t. the \provable retractions" tout court are established.

1 Introduction

The study of retractions and isomorphisms between domains is a central issue in the eld of denotational semantics. A rst syntactical characterization of typeisomorphisms valid in all models of the simply typed -calculus is presented in [3], and then (see [4]) extended to the richer type structure needed to deal with isomorphisms valid in any CCC. On the other hand, the more general problem of studying valid retractions has been left open. In the present paper we relate retractions to other relations between types, studied elsewhere (see [8]), such as surjections and injections: it comes out, rather surprisingly, that the retraction, injection and surjection problems are actually the same. Moreover, we study formal systems to deduce the existence of valid retractions. We show that (a subsystem of) the system presented in [3] is complete w.r.t. retractions valid in all -models but not w.r.t. those valid in all -models, even if a covariance rule is  Partially supported by ESPRIT 3230 grants

added. We exhibit a system for deriving linear retractions, that is retractions de nable by linear -terms, and we prove it to be complete and properly extending all known systems. Finally we study what is still lacking to get the full characterization of valid retractions. We introduce a generalization of the notion of valid retraction, calling it product, which enables us to show that linear retractions constitute a proper subset of the whole set of valid retractions, and we conjecture that non-linear retractions are exactly those necessarily involving products. We end by proving that there is no need for extending the language in order to express products.

2 Relations between types

In the sequel by -terms we understand simply typed ones, where types are generated from the basic type o closing under the type constructor !.

De nition 2.1 Let ;  2 Type, and M range over models of simply typed  -calculus; then

i)  inj  , 8M 9 2 M! :  is injective; ii)  surj  , 8M 9 2 M ! : is surjective; iii)  ret  , 8M 9 2 M! ; 2 M ! :   = IdM ;

iv)  iso  , 8M 9 2 M! :  is bijective.

We propose to call these relations \valid isomorphisms", \valid retractions", etc. Using the free model of open terms, we observe that  ret  i , for some M ! and N  ! , we have N  M  BNM =  I,

where B  xyz:x(yz). Similar remarks hold for the other relations above. It is for this reason that Bruce and Longo [3] called the relations iso and ret \provable isomorphisms" and \provable retractions". However, note that injectivity in the term model doesn't imply injectivity in all models.

De nition 2.2 (Bruce-Longo) Let T

iso be the formal system whose formulas are of the form  =  , for ;  2 Type, and axioms and rules are

A1  =  A2  !  !  =  !  !  R1  ==  R2  =  =  =  0 0 R3 !=  = 0 =! 0 .

Theorem 2.3 T

iso

`  =  ,  iso :

)-part, this is a straightforward induction using the term model; the ( part is proved on the basis of

Dezani's theorem [5] about invertible terms in the pure -calculus. We give an alternative proof, since the ideas involved will be useful later. De ne the class E of exponential monomials inductively: x 2 E and if e1 ; e2 2 E then (ee12 ) 2 E . For each type , de ne ^ by o^ = x and (1 ! 2 ) = ^2 ^1 . Note that ^ (n) =j }n j, where } is the full type structure over a ground domain of size . On the other hand, setting e1  e2 i e2 can be obtained from e1 replacing submonomials (ab )c by (ac )b , we know from number theory that

d

e1  e2 , 8n 2 !: e1 (n) = e2 (n):  iso  ) 8n 2 !: j}nj=j}nj ) 8n 2 !: ^ (n) = ^(n) ) ^  ^:

Proposition 2.4  ret  ^  ret  ,  iso  .

0 s.t. BNM =  I. In [10], it has been shown that 8X 2 0 9m 2 ! 8Y 2 0 : X =  Y , }m j= X = Y: (1) It follows that, for some n, }n j= BNM = I; hence [ M]]}n is injective, that is j }n jj }n j. Similarly, from  ret  we conclude that j }n j=j }n j. It follows that [ N]]}n is injective, too. From this, and from BX(BY Z) =  B(BXY )Z: }n j= M(Nx) 6= x ) }n j= N(M(Nx)) 6= Nx ) }n j= BNM(Nx) 6= Nx ) }n j= Nx 6= Nx: From the contradiction, we conclude that }n j= BMN = I; that is, by (1), BMN =  I: hence  iso . 2

Proposition 2.5  surj  ,  ret  . Proof. ( is obvious. ):  surj  implies that in the

Proof. The theorem was established in [3]: for the

Now

Proof. If  ret , then there exist M ! and N  ! in

free model of open terms 9M  ! 8Y  9Z  : MZ =  Y ; in particular, for any x 62 FV(M), there exists an x-free Z s.t. M((z:Z)x) =  x. It follows that BM(z:Z) =  I. 2 Summarizing:

Corollary 2.6 i) iso  ret = surj  inj ; ii) iso = ret \ ret ; = surj \ surj ; . 1

1

Proof. From the previous theorem and propositions;

the inclusion iso  ret is strict, e.g. o ret o ! o, but :(o iso o ! o) being x 6 xx . 2 About the relation inj much less has been known so far. To investigate this point, some machinery is needed. The following notion was introduced in [6].

De nition 2.7 If M  ; N  ; U  ; V  2  , then M U;V  N i there exist P ; : : :; Pn (n  0) such that 1

2

M =  P1UV P1 V U =  P2UV



Pn V U =  N:

Lemma 2.8 Let M range over models of the simply typed -calculus; then

M U;V  N , 8M: M j= U = V ) M j= M = N: Proof. ) If M j= U = V then, for all 1  i  n, M j= PiUV = Pi V U; it follows that, for all 1  i < n, M j= PiUV = Pi+1UV , since M is a model for -convertibility: hence M j= M = N.

( As shown in [6], U;V  is a congruence for all U; V ;

then =U;V is a model of -convertibility; more over U U;V  V , that is =U;V j= U = V ; now if 

U;V

M 6 N, then =U;V 6j= M = N, and the thesis  follows by contraposition. 2

De nition 2.9 Let M  be any term; then i) M is n-weakly injective i there exist X1 ; : : :; Xn and a variable y 62 FV(X1 ) [ : : : [ FV(Xn ) such that

8M: M j= Mx = My ) M j= xX1 : : :Xn = yX1 [y=x] : : :Xn [y=x]:

ii) x n-Bohms-out of Mx i there exist X1 ; : : :; Xn and X , where x 62 FV(X), such that

X(Mx) =  xX1 : : :Xn :

Theorem 2.10 M is n-weakly injective , x n-Bohms-out of Mx: Proof. ( Obvious. ) By lemma 2.8, the hypothesis is equivalent to xX1 : : :Xn Mx;My  yX1 : : :Xn where  = [y=x]. It follows that, for some P1 ; : : :; Pk xX1 : : :Xn =  P1 xy(Mx)(My) P1xy(My)(Mx) =  P2 xy(Mx)(My)



Pk xy(My)(Mx) =  yX1 : : :Xn :

It follows from the Church-Rosser theorem that P1xy(Mx)(My) and xX1 : : :Xn have a common reduct with the form xX10 : : :Xn0 . If the head variable of the last term is a residual of the underlined x above, then P2xy(Mx)(My) =  P1 xy(My)(Mx)  xY : : :Y ; ;! 1 n where each Yi di ers from Xi0 at most for some occurrences of x in place of y, and of y in place of x; it follows that  xY 0 : : : Y 0 P2 xy(Mx)(My) ;! 1 n

for some Y10; : : :; Yn0 . But this cannot go on until Pn, otherwise we would have xZ1 : : :Zn ; Pnxy(My)(Mx) =  yX1 : : :Xn

contradicting the Church-Rosser theorem. It follows that, for some j  n,  xT : : :T Pj xy(Mx)(My) ;! 1 n

where the head variable x on the right side is a residual of the second (underlined) occurrence of x on the left side. Hence there are V1; : : :; Vn such that  xV : : :V ; Pj zy(Mx)(My) ;! 1 n so that the desired X is v:Pj zyv(My). 2 The following corollary was conjectured by Albert Meyer.

Corollary 2.11 If M de nes an injection in every model, then M has a left inverse. 2 Obviously ret  inj . The corollary doesn't imply that inj = ret since there is no evidence of the fact that if  inj  then there exists an M ! de ning an injection in every model. However this can be proved in a similar way as the previous theorem. Theorem 2.12  inj  )  ret  . Proof. (Hint) We build a model using Henkin's construction and Jacopini's theorem where every injective functional is left invertible. 2 Proof. In the theorem take n = 0.

3 Formal Systems

In this section we explore formal systems to derive formulas of the form  < , whose intended meaning is  ret .

De nition 3.1 The system T , whose formulas have 1

the form  <  , is de ned as follows:

A1  <  A2  <  !  R1  <  <  <  composition. In [3], such system has been proved to be complete w.r.t. the retractions valid in all models of the simply typed -calculus. Actually it was established, using a result in [7], that  is a retract of  in all models of the typed -calculus i   1 ! : : : ! n !  (2) for some 1 ; : : :; n , where  stands for synctactical identity. In the same paper, a further rule was considered: 0 0 R2 !< < 0
Such rule is however incorrect w.r.t. models of the -calculus, since adding it to T1, we derive o ! o < (o ! o) ! (o ! o) ! o, thus contradicting (2).

Proposition 3.2 The system T = T + R is correct 2

1

2

w.r.t. the relation ret ; it is however not complete.

Proof. Correctness of R2: from the hypothesis we know

that

On the other hand, de ning the map f : Type ! !: f(o) = 0 f( ! ) = 1 + f(); it is routine to verify that T2 `  <  ) f()  f(): Let   o ! o ! o,   ((o ! o ! o) ! o) ! o and take M !  xy:yx N  !  uvw:u(z:zvw): Now, N  M =  I but f() = 2 > 1 = f(): 2

De nition 3.3 We de ne the system T = T + A + A4 , where: A3  !  !  <  !  ! 

3

2

3

A4  < ( ! o) ! o:

Remark 3.4 Actually A is equivalent to the axiom 4

scheme: 1 ! : : : ! n !  < ((1 ! : : : ! n ! ) ! ) ! :

Lemma 3.5 The system T is sound w.r.t. ret , and it is a proper extension of T . Proof. By the invertibility of the combinators C  xyz:xzy and C  xy:yx; in particular if C has 3

2

type

9P  ! 0 ; Q 0 ! : Q  P =  I : Thus, taking T  xyz:x  z  y =  xyzt:x(z(yt)),

(1 ! : : : ! n ! ) ! ((1 ! : : : ! n ! ) ! ) ! ; then its left inverse is xy1 : : :yn :x(z:zy1 : : :yn ). It follows from the proof of proposition 3.2 that T3 is a proper extension of T2 . 2

U (! )!(0 ! 0 )  TP N

Remark 3.6 Although the previous proofs rely on

and

we set and

9M !0 ; N 0 ! : N  M =  I

( 0 ! 0 )!( ! )

V  TQM it is straightforward to prove that V  U =  I! .

simple facts about invertibility in the pure calculus, we have to proceed with some care. In the case of isomorphisms of [3], the soundness and completeness proof was a consequence of the following facts:

i) M  is (left and right) invertible i the untyped M is invertible; ii) a -normal form M 2  is invertible i M 2 FHP, the set of Dezani's hereditary permutators (see [5]); iii) M 2 FHP ^ M 2  !  ) M ;1 2  ! . This doesn't apply in our case; indeed, in the case of one side invertibility in the -calculus, we know that iv) M is right-invertible in the -calculus 6) M has a type; v) M ! is right-invertible in the -calculus ) 9N  ! : BMN = I. In case of the -calculus things are even worse since: vi) M is -left-invertible and has a type  !  6) 9N  ! : BNM =  I. Consider for example the following type for C  xy:yx: ! ( ! ) ! ; then C possesses a left inverse (take e.g. x:xI), but it has no inverse at all, if :( ret ). vii) there exists M s.t. M is -left-invertible and, for every type  !  such that M has this type, a typable left inverse doesn't exists. We conclude that the problem of characterizing the invertibility in the pure -calculus, which is an open one, even if solved, would be of little help in the study of \provable retractions". On the other hand, we note that the -de nability conjecture implies that the relation ret is decidable, and well partial ordering theory (see [9]) tells us that, for any xed , f j  ret  g is recursive. We end this section by showing that the system T3 actually catches all \linear retractions", in the following sense. De nition 3.7 Let lin be the set of simply typed terms such that each bound variable has at most one occurrence; then we de ne

 retl  , 9M ! ; N  ! 2 lin : BNM =  I: For the sake of simplicity, we consider retractions up to isomorphisms (which are linear since FHP  lin ); actually, by corollary 2.6, we could add to T3 the rules R3  == 

R4  n is impossible. Let r = m = n; now, if  = [V1 =y1; : : :; Vr =yr ], then x1 : : :xr :vU1 : : :Ur =  v ) Ui =  xi for i = 1; : : :; r. But by the hypothesis and by linearity, for all i it must be case that Ui =  Ui0 yp(i) and Vp(i) =  Vp0(i) xi , where p is a permutation of the indexes. It follows that i retl p(i) ; clearly len(i ) + len(p(i) ) < k, hence T3 ` i < p(i) . Using covariance rule R2 we get the thesis.

Case 2: z 6 x; then, since M is invertible, it must be the case that z  yi for some i: the thesis follows from lemma 3.10 and from the inductive hypothesis. 2

4 Retracts and products

Linear retractions are a proper subset of the whole set of retractions: consider ( ! o) ! ( ! o) ! o ret ( ! (o ! o ! o) ! o) ! o: (3) This is proved de ning the following combinators: D  xyuv:v(xu)(yu) D1  zu:zu(ab:a) D2  zu:zu(ab:b): We have D 2 ( ! o) ! ( ! o) !  ! (o ! o ! o) ! o and D1 ; D2 2 ( ! (o ! o ! o) ! o) ! o; moreover Di (Dx1 x2 ) =  xi for i = 1; 2: The terms M  xy:x(D1 y)(D2 y) and N  zx1 x2:z(Dx1 x2) de ne the retraction (3). It is routine to check that, if T3 `  <  then len()  len(); but, choosing  suitably large in (3), the length of the left hand side becomes striclty greater than the length of the right hand side; it follows that (3) is not derivable in T3 ; hence, by completeness of T3 w.r.t. retl , it is not linear. The retraction (3) suggests that non-linear retractions are de nable using the following generalization of the notion of \provable retraction". De nition 4.1 We de ne a type  to be the product of types 1 ; : : :; n (and we write  2 1 ;:::;n ) i there exist D 2 1 !    ! n !  and (1  i  n) Di 2  ! i such that Di (Dx1 : : :xn) = xi

Remark 4.2 We use the word \product" par abus

de langage, since it is known that the -calculus, both

typed and pure, cannot de ne surjectve pairing. One may wonder whether we need to extend the language to express existence of products, in order to construct a system complete w.r.t. ret : The next theorems show that this is not the case. Theorem 4.3 (Witness theorem) Let   1 !    ! m ! o ret 1 !    ! n ! o   . There exist P1; : : :; Pm ; Q1; : : :; Qn such that, taking

P ! = xy1 : : : yn :x(P1yp1 ) : : :(Pm ypm )

(4)

and

Q ! = yx1 : : :xm :y(Q1 x1 : : :xm ) : : :(Qn x1 : : :xm ); then Q  P = I . Proof. See Appendix. 2

Theorem 4.4 (Products and retractions)  2 1 ;:::;n ,  !    ! n ! o ret  ! o: 1

Proof.

) We choose the terms: M  xy:x(D1 y) : : :(Dn y) 2 (1 !    ! n ! o) !  ! o and

N  zx1 : : :xn :z(Dx1 : : :xn) 2 ( ! o) ! (1 !    ! n ! o); then the hypothesis implies that they de ne the desired retraction. ( Let   1 !    ! n ! o. Since  ret  ! o, there exist terms M : !  ! o and N : ( ! o) !  de ning the given retraction. By Theorem 4.3, it is not restrictive to assume M = xy:x(M1 y) : : :(Mn y); for some M1 ; : : :; Mn; by lemma3.8 it must be the case that N  zy1 : : :yn :z(N 0y1 : : :yn ). Now the hypothesis implies that Mi (N 0 y1 : : :yn ) = yi ; and we are done putting D  N 0 and Di  Mi . 2

The existence of products is assured by the result of [2], and, looking at axiom A4 in this perspective, a little e ort allows to recognize the type of Church tupling combinators as an instance of it.

Acknowledgments

We are grateful to Corrado Bohm and Mariangiola Dezani for their valuable support.

References

[1] H.P. Barendregt, The Lambda-Calculus: Its Syntax and Semantics, North-Holland, 1984. [2] H.P. Barendregt, \Pairing without conventional restraints", Z. Math. Logik Grundlag. Math. 20, 1974. [3] K. Bruce, G. Longo, \Provable isomorphisms and domain equations in models of typed languages" in A.C.M. Symp. on Theory of Computing (STOC 85), 1985. [4] K. Bruce, R. Di Cosmo, G. Longo, \Provable Isomorphisms of Types" Technical Report of LIENS, 1990. [5] M. Dezani-Ciancaglini, \Characterization of normal forms possessing inverse in the  calculus", TCS 2, 1976. [6] G. Jacopini, \A condition for identifying two elements of whatever model of combinatory logic", LNCS 37, 1975. [7] I. Margaria, M. Zacchi, \Right and Left Invertibility in  -calculus", R.A.I.R.O. 17, 1983. [8] R. Statman, \On the existence of closed terms in the typed -calculus I", in To H.B. Curry: essays on Combinatory Logic, Lambda-Calculus and Formalism, R. Hindley, J.P. Seldin (eds.),

Academic Press 1980. [9] R. Statman, \On the existence of closed terms in the typed -calculus II", TCS 15, 1981. [10] R. Statman, \Completeness, invariance and de nability" JSL 47, 1982. [11] R. Statman, \Logical Relations and the Typed -calculus", Information and Control 65, 1985.

Appendix: the proof of Theorem 4.3 The hypothesis  ret  implies the existence of terms M  xy1 : : :yn :V (where V is -free) and N  yx1 : : :xm :yN1 : : :Nn such that N  M = I . We will consider the case where the head variable of V is di erent from x, and we will transform M in such a way to obtain a new term P, having the same type and left-inverse of M, whose head variable is the rst abstracted one, as in (4). We observe that it is not restrictive to assume that the variable x occurs exactly once in M; it comes out from the type of such variable that there exists a context C[ ] and m terms M1 ; : : :; Mm such that M = C[xM1 : : :Mm ] (5) Let us put our attention on the term M1 in (5) (the remaining M2 ; : : :; Mm are treated in a similar way) and let us consider the free variables of M1 which are bound in M: fv1 ; : : :; vk g = FV(M1 ) \ BV(M): The left-invertibility hypothesis for M implies the existence of terms V1 ; : : :; Vk such that (v1 : : :vk :M1 )V1 : : :Vk = x1: (6) Again, it is not restrictive to assume that the variable x1 occurs exactly once in fV1 ; : : :; Vk g, say in Vj . It follows that, taking M10 = vj :(v1 : : :vk :M1)V1 : : :Vj ;1vj Vj +1 : : :Vk ; the term M 0 = C[x(M10 vj )M2 : : :Mm ] (7) has the same type and left-inverse of M and furthermore FV(M10 ) \ BV(M) = ;: Now, starting from M 0 , we will prove that there ~ having the same type and left-inverse as exists M, M 0, s.t. M~ = C[x(M~ 1yp1 )M2 : : : Mm ]; (8) where yp1 2 fy1 ; : : :; yng and FV(M10 ) \ BV(M) = ;. We distinguish two possible cases: Case 1: vj 2 fy1 ; : : :; yng. In such case we just take M~ 1 = M10 and we are done.

Case 2: vj 62 fy ; : : :; yng. 1

Let, for suitable '1 ; : : :; 'r , vj 2 '1 !    ! 'r ! o: Furthermore, let Z = zR1 : : :(w~1 vj w~2:S) : : :Rt (9) be the subterm of M 0 in which the -binding of vj appears. We shall prove that the term M 00 = C[x(M10 (u1 : : :ur :zR1 : : : : : :(w~1 vj w~2 :vj u1 : : :ur ) : : :Rt)) M2 : : : Mm ] (10) has the same type and left-inverse as M 0. In e ect, we note that: (i) the variable x occurs free in S; (ii) there exists a context D[ ] such that D[Z] = M 0; (iii) the context Z[ ] = zR1 : : :[ ] : : :Rt is such that Z[w~1 vj w~2 :S] = Z. It follows from the left-invertibility of M 0 that, for some W~ 1; W~ 2 : N  D[Z[ ]] = xx1 : : :xm :[ ]W~ 1Vj W~ 2 ; hence, indicating by  the substitution induced by the left-inverse N of M 0 over the free variables of Z[ ], we have (u1 : : :ur :Z[w~1vj w~2:vj u1 : : :ur ]) = Vj ; which is exactly what we aimed to prove. It comes out, following the same construction which enables us to build M 0 (see (7)) from M (see (5)) that there exists M1000 and a variable v such that M 000 = C[x(M1000v)M2 : : :Mm ] (11) (where FV(M1000) \ BV(M 000) = ;) has the same type and left-inverse of M and furthermore, by construction, the  which binds v appears, in the structure of M, above the one which binds vj . It follows, by induction on the structure of M, that there exists M~ = C[x(M~ 1y)M2 : : :Mm ] such that y 2 fy1 ; : : :; yn g and M~ has the same type and left inverse of M 0.

Now, a similar construction can be applied to M2 ; : : :; Mm ; thus obtaining a term P~ = C[x(M~ 1yp1 ) : : :(M~ m ypm )] having the same type and left-inverse as M. Now, recalling that we started from M  xy1 : : :yn :V and that both V and x(M~ 1yp1 ) : : :(M~ m ypm ) have type o, we obtain the thesis, simply taking Q = N and, for 1  i  m, Pi = M~ i : 2 Example Let   1 ! 2 ! o. We have  ret ( ! o) ! o;

(12)

since

M  !( !o)!o  xy:y(ab:xab) has left-inverse N (( !o)!o)!  yx1 x2 :y(a:ax1x2) We have M = C[xab], where C[ ]  xy:y(ab:[ ]). Following the construction described in the proof of theorem 4.3, we perform the following replacements for the variables a and b: a ( y(ab:a) ; b ( y(ab:b) thus obtaining the term P~  !( !o)!o  xy:y(ab:x(y(ab:a))(y(ab:b))); which has the same type and left-inverse as M. We can then take as witness of the given retraction the term P  xy:x(y(ab:a))(y(ab:b)): To complete the example, let us consider the case where, in (12), we have   o. In such case, starting from M o!(o!o)!o  xy:yx; we obtain the term

K  xy:x as witness of o ret (o ! o) ! o.