[Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with...

15
,-Calculi with Explicit Substitutions and Composition Which Preserve [3-Strong Normalization (Extended Abstract) Maria C. F. Ferreira I and Delia Kesner 2 and Laurence Puel 2 i Dep. de Inform~tica, Fac. de Ci~ncias e Tecnologia, Univ. Nova de Lisboa, Quinta da Torre, 2825 Monte de Caparica, Portugal, cfOfct.unl.pt. 2 CNRS & Lab. de Rech. en Informatique, Bat 490, Univ. de Paris-Sud, 91405 Orsay Cedex, France, {kesner,puel}@Iri.fr. Abstract. We study preservation of/~-strong normalizatio~l by ~,~ and A~n, two confluent ~-calcul] with explicit substitutions defined in [10]; the par- ticularity of these calculi is that both have a composition operator for subs- titutions. We develop an abstract simulation technique allowing to reduce preservation of/~-strong normalization of one calculus to that of another one, and apply said technique to reduce preservation of fl-strong normaliza- tion of ~ and Adn to that of A f, another calculus having no composition operator. Then, preservation of l~-strong normalization of A/is shown using the same technique as in [2]. As a consequence, Ad and Adn become the first A-calculi with explicit substitutions having composition and preserving fl-strong normalization. We also apply our technique to reduce preservation of fl-strong normalization of the calculus A~ in [14] to that of X/. 1 Introduction The ~-calculus is a convenient framework to study functional languages, with evaluation modeled by the/3-reduction rule (Ax.M)N --~ M{x ~- N). The main mechanism used to perform H-reduction is substitution, the ope- ration between brackets, which consists of the replacement of formal parame- ters by actual arguments. This operation is treated as an atomic step in the A-calculus, ancl is defined in a meta level by functions external to the lan- guage. But substitutions need to be treated expMicitly when implementing functional languages, and a mechanism to dea~ with them becomes neces- sary. in A-calculi with explicit substitutions, this is achieved by letting the substitution operation be handled by symbols and reduction rules belong- ing to the calculus. Most calculi with expticit substitutions also use natural numbers to represent variables (de Bruijn's indices), avoiding in this way the systematic renaming of bound variables (a-conversion) which is necessary in classical h-calculus to guarantee the correctness of substitution. in the following, let R-SN stand for R-strong normalization, i. e., strong normalization of the calculus or rule R, and let K stand for AK minus the

Transcript of [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with...

Page 1: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

,-Calculi with Explicit Substitutions and Composition Which Preserve [3-Strong Normalization

(Extended Abstract)

Maria C. F. Ferreira I and Delia Kesner 2 and Laurence Puel 2

i Dep. de Inform~tica, Fac. de Ci~ncias e Tecnologia, Univ. Nova de Lisboa, Quinta da Torre, 2825 Monte de Caparica, Portugal, cfOfct.unl.pt.

2 CNRS & Lab. de Rech. en Informatique, Bat 490, Univ. de Paris-Sud, 91405 Orsay Cedex, France, {kesner,puel}@Iri.fr.

Abstract. We study preservation of/~-strong normalizatio~l by ~,~ and A~n, two confluent ~-calcul] with explicit substitutions defined in [10]; the par- ticularity of these calculi is that both have a composition operator for subs- titutions. We develop an abstract simulation technique allowing to reduce preservation of/~-strong normalization of one calculus to that of another one, and apply said technique to reduce preservation of fl-strong normaliza- tion of ~ and Adn to that of A f, another calculus having no composition operator. Then, preservation of l~-strong normalization of A/is shown using the same technique as in [2]. As a consequence, Ad and Adn become the first A-calculi with explicit substitutions having composition and preserving fl-strong normalization. We also apply our technique to reduce preservation of fl-strong normalization of the calculus A~ in [14] to that of X/.

1 Introduction

The ~-calculus is a convenient framework to study functional languages, with evaluation modeled by the/3-reduction rule (Ax.M)N - - ~ M{x ~- N). The main mechanism used to perform H-reduction is substitution, the ope- ration between brackets, which consists of the replacement of formal parame- ters by actual arguments. This operation is treated as an atomic step in the A-calculus, ancl is defined in a meta level by functions external to the lan- guage. But substitutions need to be treated expMicitly when implementing functional languages, and a mechanism to dea~ with them becomes neces- sary. in A-calculi with explicit substitutions, this is achieved by letting the substitution operation be handled by symbols and reduction rules belong- ing to the calculus. Most calculi with expticit substitutions also use natural numbers to represent variables (de Bruijn's indices), avoiding in this way the systematic renaming of bound variables (a-conversion) which is necessary in classical h-calculus to guarantee the correctness of substitution.

in the following, let R-SN stand for R-strong normalization, i. e., strong normalization of the calculus or rule R, and let K stand fo r AK minus the

Page 2: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

285

Beta rule, for any arbitrary calculus AK. The A~-calculus was introduced in [1] as a bridge between the classical A-

calculus and concrete implementations of functional programming languages. Substitutions in A~ can be combined by a composition operator. Strong normalization of the a-calculus is proved in [4], but Aa does not preserve fl-SN [16]. The A~-calculus is confluent on closed terms but is no longer confluent on open terms. To overcome this, Hardin and L~vy introduced the A~-calculus [9] which allows to recover the confluence property on open terms [3]. However, A~, as Aa, does not preserve/3-SN either [15].

The A~-calculus [14] also implements the A-calculus and it has as few forms of substitutions as possible, eliminating the possibility of composing substitutions; Av preserves/~-SN [2] but it is not confluent on open terms. Another calculus with explicit substitutions, the As-calculus [12], is inspired by the A-calculus ~ la de Bruijn as it explicitly handles the meta-operators used to define substitutions in the de Bruijn's calculus; thus, there are no composition operators for substitutions. As preserves/3-SN, however it is not confluent on open terms; an extension of it exists [11] which is confluent on open terms, but for which the preservation of/3-SN is still open.

Recently, another calculus with explicit substitutions was proposed in [17]; this calculus is confluent on open terms and preserves ~-SN, however, the calculus does not only lack a composition operator for substitutions, but it implements a particular strategy of the A-calculus: the distribution of substi- tutions to applications is only possible if the head term is a variable. Thus, there are some/~-reduction sequences in classical A-calculus which can not be simulated in the calculus.

Apparently, there is a choice between confluence on open terms, compo- sition and preservation of/~-SN, which is an interesting challenge that we partially answer in this paper: composition is possible in calculi preserving /~-SN and being confluent on closed terms. We study Ad and Adn, two dif- ferent calculi with explicit substitutions initially defined in [20]; these calculi, do have composition, are confluent on closed terms 3 and preserve /~-SN. The Ad-calculus is inspired by the At-calculus from [18], which is in turn inspired by [7], the difference being that the MapEnv rule of A~-, namely # (a) o s > Ii" (s) o #(a[s]) is replaced here by the two following rules: ! [ # (a )os ] ~ a[s] and T o(#(a)os) > 8. This may seem irrelevant, but it is essential to prove confluence and strong normalization of the d-calculus, in contrast with the case of the r-calculus, for which confluence remains still as a conjecture, and for which strong normalization does not hold, as was

3 To see why the calculi are not confluent on open terms, consider the term ((,~X)a)[s] that reduces to X[~(a) o s] and X[fi" (s) o ~:(a[s])], which cannot be joined.

Page 3: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

286

shown by Pierre Lescanne [13]. However, the rule MapEnv (or a similar one) is essential if one wants to recover the confluence property on open terms, and is at the same time, as explained in [16], the cause of non-termination in many A-calculi with explicit substitutions. Indeed, analysing [16], it seems that the main difference between our calculi and other calculi that do not preserve/~-SN stems from the (in)existence of a rule of the form of MapEnv in A~-, or Map in )~.

We show that preservation of ~-SN of hd and ;~dn reduces to that of another calculus, called h/. The h/-calculus, which can be seen as the h,- calculus of [14] without variables of the form n + 1, arose from transforma- tions of the original calculi hd and hd~. The transformations applied to both calculi work at two levels. First substitution composition is eliminated (and for hdn, the representation of variables is standardized), giving rise to an- other intermediate calculus, )%. Then, we eliminate the identity substitution from he obtaining h/. Those transformations are defined by complete rewrite systems. Reduction sequences in h d (resp.)~dn) are translated, via a simu- lation technique, to reduction sequences in h.f, in such a way that h]-SN is preserved. Consequently, if h/ preserves/~-SN, so do hd and hd~ (and the intermediate calculus )~e). It remains then to see that ),/does itself preserve /3-SN. This is done applying the same technique used in [2]. The simulation technique is an interesting and useful tool; we also apply it to show that preservation of/~-SN of ~v reduces to that of h i .

It would be possible to skip h i (thus keeping the identity substitution) and prove preservation of/~-SN of ~ using the technique presented in [2]. But we prefer to work directly with ~f, which is, in some sense, the minimal calculus of substitutions that one can expect to preserve/3~SN and to be confluent on closed terms. Also separating the transformations as opposed to combining both in a single transformation, allows us to break down the problem into much simpler ones (for more technical considerations see Sec. 5).

The paper is organized as follows, in Sec. 2 we introduce some notations and definitions and we give the syntax of all the calculi we are going to deaB with. In Sec, 3 we give the simulation technique that will be used along the paper to show that our different calculi preserve/~-SN. Sec. 4 is devoted to the translations used by our simulation technique: we define a translation from ,~d to ~e and another one from he to hi . In Sec. 5 we apply the simulation technique introduced in Sec. 3 to show that )~d (resp. he) preserves he (resp. h i ) strong normalization, in Sec. 6, a translation from hdn to he is given; the translation is made in such way that makes it possible to show that ~dn preserves he-SN. In Sec. 7 we show that )~] preserves/3-SN, using a technique from [2]. This result is essential, since it allows us to conclude that )~d, 3dn,

Page 4: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

287

and Ae also preserve/~-SN (Sec. 8). In Sec. 9 we discuss some further topics, including how to reduce preservation of fl-SN of Av to that of Ay. Due to the restrictions of space, we were forced to omit most technical proofs, the reader willing to check the results should consult [8].

2 Definitions and Notations

A classical way to avoid c~-conversion problems in A-calculus, is to use the de Bruijn's notation [5, 6] for A-terms, where names of variables are replaced by natural numbers. Hence, the set of A-terms (also called pure terms) is defined by the following grammar:

N a t u r a l s n : := 1 ] n + 1 P u r e T e r m s a : : - n I aa [ Aa

In A-calculi with explicit substitutions, objects denoting substitutions are incorporated to the language explicitly, as well as manipulation of substitu- tions, which is incorporated via a set of rewrite rules. This syntactic presen- tation is defined, for the calcuEi we are going to present, as follows:

Definition I Substitution Signatures. Let us consider two distinguished symbols T (for terms) and 8 (for substitutions). A substitution declaration is a (possibly empty) word over the alphabet {T , S}. A substitution signature is defined to be a signature ~' (a set of symbols) such that every symbol in

is equipped with an arity n and a declaration of length n. We usually write : (n, az . . .an) i f~ has arity n and declaration a l . . . a n .

Definition 2 Substitution Language. The set of objects over a substitution signature ~' is defined to be the union of objects- of sort "T and 8. They are constructed in the following way:

�9 If n is a natural number, then _n, called a variable, is of sort T.

�9 If a and b are of sort T, then (a b), called an application, is' of sort T.

�9 If a is of sort T, then A(a), called an abstraction, is of sort T.

�9 If a is of sort ~F, s is of sort 8, then a[s], called a closure, is of sort T.

�9 If every f i is of sort (ri, and ~ : (n, cyl.., an), then ~ ( f l , . . . , fn), called a substitution, is of sort 8.

For each substitution language W, the set of objects of sort T is denoted by Tw, and called the set of terms of W. Similarly, 8w, the set of substitu- tions of W, denotes the set of objects of sort S. COw stands for Tw CI 8w.

Page 5: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

288

We omit parenthesis when association is clear from the context. If W is a substitution language and s is a substitution of W, [s]n denotes the con- catenation of substitutions [~].. . [s], assuming that [s] ~ denotes the empty

n times word. We also use the fol lowing no ta t ion for mul t ip le appl ica t ions of a unary substitution operator: ~~ = s and ~n+ l ( s ) = ~r

We write )~w for the set of rewriting rules of the ~.-calculus W, and simply W for the set A w - B e t a . The notations --~/~ and =~ are used to denote resp., ?~-reduction and 7?~-equality, where ~ can be either a set of rewrite rules or a single rule. We abbreviate ~-strong normalization to ~-SN, and ??.-strongly normalizing to ~-sn. Finally we note that both reduction rules and reductions we are interested in, apply to objects of the appropriate sort, the ones constructed by our grammars.

We now introduce the rewriting rules of the calculi ~d, )~dn, '~e and ,~]. The signature associated to the substitution language of the ,~d-calculus is given by the set { # , # , o , T , i d ) , where # : (1,7") , ~: ( 1 , S ) , o : (2, S S ) , ~: (0, e) and i d : (0, e); note that these declarations apply to other calculi as well. The set of reduction rules of the Ad-calculus is given in table 1; these rules can be decomposed into two disjoint sets of rewriting rules:

(Beta) ()~a)b ~ a[#(b)] (App) (a b)[s] --~ (a[s] b[s]) (Lambda) (,ka)[s] ~ A(a[1~ (s)]) (C~os) (a[s])[t] - - ~ ~[s o t] (FYarl) ! [ # ( ~ ) ] - - ~ (FVar2 ) ~ # ( ~ ) ~ d ~ ~[sl ( F V a r L i f t l ) ![~ (s)] --~, 1__ ( F V a r L i f t 2 ) 1[# (s) o t] - -~ 1_.It] (Ass) (sl o s2) o s3 ~ 8t o (s2 o s3) (Sh iy t l ) T o # ( a ) - - ~ id ( Sh ip2 ) T o ( # ( a ) o ~) - - ~ s ( S h i p L i y t l ) T o ~ (s) - ,~ so T ( S h i f t L i f t 2 ) T o(# (s) o t) - - * s o (T or) (L i f t 1 ) ~" (s)o ~ (t) ---+ I'~ (s o t) (L i f t 2 ) it (s) o (~r (t) o u) - ~ # (s o t) o u ( IdL) id o s - - * s ( IdR) s o id - - ~ s ( L i f a d ) ~r (id) - ~ i,~ (Id) a[id] - -+ a

Table 1. Reduction rules of the hal-calculus.

Page 6: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

289

(VarShi f t l ) n i t ] -----* n + 1 (VarShif t2) nil" os] ------+ n + l[s] (RVarl) n + l [ # ( a ) ] -----+ n (RVar2) n + l [~:(a) o s] ----* n[s] (RVaTZif t l ) ~ + 1[~ (s)] - -- . ~_[so T] (RVarLif t2) n + l[fr (a) o t] - - * his o (T ot)]

Table 2. Additional reduction rules for the Aa,~-calculus (see also table 1).

(Beta) (Aa)b , a[#(b)] (App) (a b)[s] , (a[s] b[s]) (Lambda) (Aa)[s] , A(a[~i" (s)]) ( F r e t ) l_[#(a)] , a (FYarLi f t ) 1__[~" (s)] , 1 (Shif t ) a[l~' (T)][I~' (#(b))]------+ a[l~' (id)] (Sh i f tL i f t ) a[l~' (T)][I~ i+1 (s)] , a[l~ i (s)][~ "i (T)] (Li f t ld) a[~ i+~ (id)] , a[~ ~ (id)] (Id) a[id] ~ a

Table 3. Reduction rules of the ,~-calcu!us

�9 system A, with rules Beta, App, Lambda, FVarLiftl, FVarLift2, FVarl, FVar2, Shiftl, Shift2, ShiftLiftl, ShiftLift2, IdL, IdR, Li ftId and Id;

�9 system B, which contains rules Clos, Ass, Liftl and Lift2. The signature associated to the Adn-calculus is the same as before. Re-

duction rules of the Ad~-calculus are those given for the Ad-calculus in table 1 plus some additional rules for handling constants of the form n; the addi- tional rules are given in table 2. The set of rules of the Aan-calculus can be decomposed into two disjoint sets of rewriting rules:

�9 system An, with rules Beta, App, Lambda, FVarLiftl, FVarLift2, FVarl, FVar2, Shi ftl, Shift2, Shi ftLi ftl, Shi ftLi ft2, IdL, IdR, LiftId, Id, RVarl, RVar2, RVarLiftl and RVarLift2;

�9 system Bn, which contains rules Clos, Ass, Lift1, Lift2, VarEhiftl and VarShift2. In Ar there is no substitution composition, so the signature associated to

the substitution language of this calculus is { # , ~1", T, id}. The reduction rules

Page 7: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

290

(a ~)[fr (#(r --~ (Zam-~da) (Xa)[~' (T)] - - ,

(,ka) [1~ i (~(c))] ~ *

(FVarL i f t ) lift ~+~ (I)] ~ t ~+~ (#(~))] - ~

(s~qt) ~[l~' (T)][fr (#(~))] - - . (Shi]t~Lift) a[l~ ~ (T)][f[ ~+j+~ (i")]

~[it' (1)][~ ~+'+~ (#(~))1--~

,,[#q,)]

(ale (#(~))] b[~, (#(~))]) ,k(a[~ ~+1 (T)]) x(~[~ '+~ (#(~))])

1

a[~ i (id)]

~[~+~ (T)][ir (T)] ~[i? +j (#(b))][~ ~ (T)]

Table 4. Reduction ~ules of the C-calculus

(ap-~_L) (a b)[~' (,d)] - ~ (~[~' (,d)] b[~ ~ (~d)]) (Lamb da) (,~a)[l~ / (id)] ~ A(a[l~ i+1 ({d)]) ( f V a r L i f t ) 1[]] ~+1 (id)] ----* 1 (Shirt--Lift) a[f~ ~ ([)lift ~+j+x (id)] ~ a[fi "~'+-i ({d)][l~ ~ (1")] (L i f t ld ) a[~ i+~ (id)] ~ a[# i (id)]

Table 5. Reduction rules of the D-calculus

of Ae are given in table 3 (the system is infinite since i ranges over iN). The reduction rules of )~e originate two disjoint infinite sets of rewriting rules C and D, shown in tables 4 and 5, resp. (i and j range over IN). Even though Ae does not coincide, syntactically speaking, with the calculus C U D, when we consider reductions on objects constructed by our grammar, the reduction relations defined by both calculi are the same, i. e,

ps if and only if p p'. If p,p' E Te, then p ---+:~ ---~CuD (1)

As a consequence, from now on we will indistinctly use A~ or C U D. In A/there is no substitution composition, nor identity substitution, so the

signature associated to the substitution language of A / i s the set { # , ~, T}. The reduction rules of A/ are given in table 6 (i ranges over ~ ) .

A variable n + 1 (n _> ] ) is represented by the term ![7 c>(T o(. . . o T))) n times

in ~d, and the term ! [T ] . . . [T ] in ~ and )~f; in every case we can assume

n titans t he s a m e set o f pure t e rms , given in Sec. 2,

Page 8: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

291

(Beta) (Aa)b ----* a[#(b)] (App) (a b)[s] - - * (a[s] b[s]) (L mbaa) ( a)N (FVar) l_[#(a)] ----* a (fVarLift) l_[~t (s)] ~ 1 (Shif*) a[~ i (T)][~ "i (#(b))] ~ a (ShiftLift) a[ft ~ (T)][~ i+1 (s)] ----* a[ft ~ (s)][~ i (T)]

Table 6. Reduction rules of the )~l-calculus

3 The Simulation Technique

We present the abstract simulation technique used in the rest of the paper.

Definition 3. Let A = ( O , R) and B = ( O 1, R ' ) be two a b s t r a c t reduct ion

systems such that O' _C O. We say that A preserves B-SN (or that I l preserves II'-SN), if every a E 01 which is B-sn (R'-sn), is also A-sn (ii-sn).

Theorem 4. Let R = ( 0 , R1U R2 ) be an abstract reduction system such that Il2 is strongly normalizing and there exists a reduction system S = ( (Y, II/I, with 01 C_ (9, and a translation T from (9 to 01 such that T(a) = a, /:or any a E 0 I, and a )R1 b implies T(a) ~+R' T(b); a ~n2 b implies T(a) = T(b). Then Ill U R2 preserves RI-strong normalization. 4

4 The Translations

In this section we present the transformations that allow us to go from )'d to h i via the intermediate calculus he. The first transformation is defined by the complete rewrite system de and allows us to eliminate substitution com- position from )~d- The second transformation is defined by the also complete system e f , and allows us to eliminate the identity substitution frpm he.

From Xd to Xe

The following infinite system will be used to translate hd to he:

(de) (s o , (t)] (i >_ 0)

W e s t a t e s o m e p roper t i e s enjoyed by the s y s t e m de.

* Note that some conditions can be weakened. Namely instead of requiring that for any a E 0', T(a) -- a, we can require that T(O') C_ O' and that T respects strong normalization, i. e., T(a) is RCstrongly normalizing, if a E O' is.

Page 9: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

292

Lemma 5. The system defined by the rules de is confluent and strongly normalizing. Furthermore i f a E 7"d then de(a) E T~, where de(a) is the normal form ore with respect to de.

Lemma 5 tells us that the system de defines a function, namely the func- tion that associates to each object its unique normal form wrt de. From now on we use the notation de(s) meaning the normal form of s wrt system de. The previous lemma also tells us that de-normal forms of terms from Td do not contain substitution composition.

From ,ke to A[

The following infinite system will be used to translate he to by:

(e f ) a[~ i ( id ) ] - -+ a (i >_ O)

Lemma 6. The system e f is confluent and strongly normalizing. Furthermore ira E Te then ef(a) E Tf, where ef(a) is the normal form of a wrt e f .

Just like the system de, the system ef defines a function that associates to each object in Oe its normal form wrt ef. It also states that e f-normal forms of terms of Te, do not contain the substitution id.

5 Simulating the ,~d-Calculus

We show that ha preserves h]-SN. For that, we proceed in two steps, by showing first that hd preserves he-SN, and then, that he preserves hy-SN.

~d preserves )~e-strong normalization

We consider the partition A U B of the hal-calculus; B is a sub-calculus of cry, which is strongly normalizing [9], so we can state:

Proposition 7. The B-calculus is strong/,]/ normalizing.

Lemma 8. Let p,p~ be objects in (ga such that p '-~'*1a P~"

1. I fp E Td, then p -'-+A P~ implies de(p')-->+~ de(if), and p ~B pl implies de(p') = de(p').

2. Vd E Te if diP] E Td, then Vi > 0 : P ---+A P' implies de(d[~ "i (p)])----~+ ~,, de(d[l~ i (p')]) P ---+B pl implies de(d[~f i (p)]) = de(d[~ i (p')])

Page 10: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

293

Corollary 9. Let a, b E 7"d. If a r A b, then de(a)---- ,+~, de(b), and if a 'B b, then de(a) = de(b).

Corollary 10. )~d preserves )%-strong normalization.

Proof. Since t E Te does not contain occurrences of the symbol o, then de(t) = t. Combining this with proposition 7 and corollary 9 allows us to use theorem 4 (with (.9 as Td, R1 as A, R2 as B, (O r as ~e, R I as )% and 7- as de), to conclude that )~d preserves /~e-strong normalization.

,Xe preserves ,X f-strong normalization

We will actually prove that the (CUD)-calculus preserves )~]-SN. Due to the fact 1, in Sec. 2, we can then immediately conclude that he preserves ~f-SN.

Proposition 11. The D-calculus is strongly normalizing.

For a proof of the previous result, see [8]. As in lemma 8 one can show:

Lemma 12. Let p,p' be terms in ~ such that p >~ pr. Then, p >c pr implies ef(p)----~+as ef(pr), and p 'D pr implies ef(p) = ef(pr).

As remarked in Sec. 2, fact 1, whenever p and p~ are terms in Te, then p ; ~ pr if and only if p ---+CUD pr. As a consequence, we have:

Corollary 13. The calculus ~ preserves )V-strong normalization.

Proof. For t E Ty, e f ( t ) = t, since t does not contain occurrences of the identity substitution. Combining this with proposition 11 and lemma 12 al- lows us to use theorem 4 (with (_9 as ~e, R1 as C, R2 as D, (_O r as ~ , R r as )~y and 7- as e f ) to conclude that C U D preserves )~]-SN. Due to the observation above, the result follows.

Some considerations about the transformations

We make some relevant comments on the strategy used. Our aim is to prove /~-SN of the ,~a-calculus, so we transform this calculus by eliminating both substitution composition and the identity substitution, and this is done in two steps via the complete rewrite systems de and of. It is possible to put these systems together to form a system, say 79.T', that turns out to be also complete. Therefore this system 7~" would define a function we could use to translate the calculus ~.d into the calculus ly . The problem is that instead of obtaining a simple partition of Ad like the systems A and 13, we obtain a partition that is constituted by two conditional rewrite systems. By separating the transformation, we obtain one more calculus but the solution is cleaner and definitively simpler, since no conditional systems are involved.

Page 11: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

294

6 Simulating the ~a~-calculus

Preservation of fl-SN of the Adn-calculus can also be reduced to preservation of fl-SN of the Ae-calculus (for pure terms). The proof follows closely the proof of the same result for the )~d-calculus: one defines a translation from the Adn-calculus to the Ae-calculus, and proves that ,\dn preserves ~e-SN.

To define the translation, consider the following infinite rewrite system:

(dn ) o t)] (t)] (4 _> O) + - -* Z_IT]" (n > 1)

The system dne is confluent and strongly normalizing; furthermore

Lemma 14. Ira E Tdn then dne(a) E ~.

in order to apply the simulation techniques, one needs the following:

Lemma 15. Let p, pt be objects in Codn such that p - - - ~ . p~. Then

1. If p is a term, then p ----~A. P' implies dne(p)--.->+~ dne(p ~) p ---~B~ .P' implies dne(p) = dne(p')

2. If p is an object, then for every d E Te such that d[p] E Tdn, and every i > 0 we have p ----*A, P' implies dne(d[~ ~i (p)])---*+:~ dne(d[~ ~ (p')])

- p' implies dne(d[~ ~ (p)]) = dne(d[~ ~ (p')]) p - * B ~

Corollary 16. Let a E Tdn. Ira --~A~ b, then dne(a)---++~ dne(b), and if a ----+B= b, then dne(a) = dne(b).

In order to see that the ),dn-calculus preserves ~e-SN, we still need to show that the the Bn-calculus is strongly normalizing. This is stated in the following proposition (for the full proof see [8]).

Proposition 17. The Bn-calculus is strongly normalizing.

Corollary 18. The Adn-calculus preserves ~e-strong normalization.

Proof. ff t E ~ , t does not contain occurrences of the symbol o nor any variable n + 1, so dnc(t) = t. Combining this with proposition 1.7 and corol- lary 16 allows us to use theorem 4 (with CO as 3~, R1 as An, .R~. as Bn, CO~ as "re, R r as Ae and T as dne),, to conclude that Adn preserves Ae-SN.

Page 12: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

295

7 Preservation of fl-Strong Normalization of the ~:-calculus

We show that the As-calculus preserves fl-SN for pure terms. The proof technique used is a minimality construction similar to the one used in [2].

Theorem 19. The f-calculus is strongly normalizing and confluent.

So the system f defines a function, namely the function that given any object in (.9: associates to it its unique normal form wrt the f-calculus.

Proposition 20. For every object p in O/, (1) i f p is a term, then f (p) is a pure term; and (2) for every pure term d, if d~] E T:, then for every i >_ O, f(d[~ ~ (p)]) is a pure term.

Corollary 21. f -normal forms of terms are pure terms.

Theorem 22 Projection Lemma. Let a, b be terms in T]. Ira then f(a)---+*Z f(b).

>Beta b,

For a proof of the previous result, we refer the reader to [8]. A position in an object o C COy is a word over {1, 2} satisfying:

�9 o1~ = o (e is the empty word);

�9 ojp.~ = a, if olp is either (ab), Aa, a[s], #(a) or ~ (a);

�9 olp.2 = b, if Olp is either (ab) or a[b]. The set of all positions of an object o is denoted by Pos(o). We want to distinguish between external and internal positions. Intuitively, internal posi- tions are the positions that occur inside [ ] symbols; external positions are the positions occurring outside the outermost [ ] symbol. Given a term t E 7/, the set of its external, resp. internal, positions is denoted by Ext( t ) , resp. In t ( t ) . These sets are inductively defined as follows:

�9 if t = 1, then Ext(t) = {e} and Int( t) = ~;

�9 if t = (a b), then Ext(t) = {1.pl p E Ext(a)}U{2.pJp E Ext(b)}U{e}, and Int( t) = {1-Pl P E Int(a)} U {2 "Pl P C Int(b)};

�9 if t = Aa, then Ext(t) = { 1 . p l p C Ext (a ) }U {e}, and Int( t) = {1 "Pl P E Int(a)};

�9 if t = a[s] then Ext(t) = { 1 . Pl P E Ext(a)} U {e}, and Int( t) = {1.pip E Int(a)} U {2.p! p E Pos(s)}. It is not difficult to see that a position in a term is either internal or

external, i. e., for any term t E ~F/, Pos(t) = Ex t ( t )U In t ( t ) . Furthermore the notion of external/internal can be extended to reduction steps. For al, a2 Ty, we say that the reduction is external (resp. internal) and denote it by

Page 13: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

296

ext int a l ) a2 (resp. al > a 2 ) i f a l

external (resp. internal) position in a l .

a2 and the reduction occurs at an

cxt Proposition 23. Let a, b E Ty. I ra ---+Beta b then f(a)---~+~ f(b).

Lemma 24 Commutation Lemma. Let a, b E Ty be such that f ( a ) is ~-sn

int ext _._+~ . int b. and f ( a ) - f ( b ) . Ira "AI �9 - - + I b, then a - - , ~ j

Lemma 25 Iterative Commutation Lemma. [2] Let a0,. . . , a= be n + 1 terms in 7-j, such that f(ao) is t3-sn and f (a i ) = f (a j ) , for all 0 < i , j <_ n;

int cxt n,ext i int and ai ---~*~I " ---+J ai+l, for all 0 < i < n - 1. Then ao - -+y �9 L--+~]

U - - ~ ] )* an.

Lemma 26. Let e be a ~-sn pure term. For every infinite Aj-derivation a = bo ---+A I bl - - ~ s b2 --+A I . . . , there exists N > 0 such that for i >_ N all the reduction steps bi .. )Aj bi+l are internal

Theorem 27. I f a is a ~-sn pure term, then it is A]-sn.

The previous result is the main result of this section and relies heavily on the preceding ones. The proof proceeds by contradiction; we admit there is an infinite hi-derivation minimal in some sense and arrive at a smaller derivation. Many details have been left out; the reader should consult [8].

8 ~d and ,~d,~ preserve ~-strong normalization

We present our main result: preservation of ~-SN by ha and Adn.

Theorem 28. I ra is a ~-sn pure term, then it is le, Ad and Aa,~..sn.

Proof. Let a be a/~-sn pure term. By theorem 27, a is also )~]-sn and since )~e preserves )~]-SN (by corollary 13), we conclude that a is ,~e-sn. Since Ad preserves ~-SN (by corollary 10), we conclude that a is Ad-sn, and since )~dn preserves Ae-SN (by corollary 18), we conclude that a is hdn-sn.

9 Further topics

Preservation of/~-SN of the ~v-calculus also reduces to preservation of/3- SN of the A]-calculus. The proof can be done using the same simulation technique explained in sections 3 and 5, where the system used to translate the ~v-calculus to the Aj-calcu]us is given by the following rewrite system:

Page 14: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

297

(vf) + ![T] >

Consider the VarSh i f t rule of Av, defined as n_[T] ) n + 1; taking 0 as Tv, R1 as Av - VarShi f t , R2 as VarShi f t , 01 as T], R I as Af and

T as v f in theorem 4, we can state that A, preserves Ay-SN. and so we can conclude that, as shown in [2], A. preserves/~-SN.

We have shown preservation of ~-S N of two different A-calculi with explicit substitutions (Ad and Adn) which have composition of substitutions and are confluent on closed terms. For the proof, an abstract simulation technique was developed to reduce/~-SN of these calculi to that of another one. We applied this technique to show that, not 0nly preservation of/~-SN for Ad and )~dn, but also for Av, reduces to preservation of fl-SN of A], which is a very simple calculus containing no composition and no identity substitution. Thus, A] becomes the minimal calculus of explicit substitutions that one can expect to preserve/~-SN and to be confluent on closed terms, while Ad and Adn become the first A-calculi with explicit substitutions having composition, being confluent on closed terms and preserving ~-SN.

Next challenge concerns the definition of a calculus in the same spirit of Ad (having composition and preserving j3-SN) but being confluent on open terms. We are also interested in a general scheme for substitution calculi as the one defined in [10] to study preservation of ~-SN from a more abstract point of view. Finally, it would be interesting to investigate which are the abstract functional machines that one can encode using Ad or Adn.

Acknowledgments This work was partially done when M. Ferreira visited LRI at the University of Paris-Sud, in January 1996. She was partially supported by NWO, the Dutch Organization for Scientific Research, under grant 612-316-041, the University of Utrech, and by a Human Capital and Mobility project (~ERBCHRXCT940495).

References

[1] M. Abadi, L. Cardelli, P.-L. Curien, and J.-J. L4vy. Explicit substitutions. Journal of Functional Programming, 4(1):375-416, 1991.

[2] Z.-EI-A. Benaissa, D. Briaud, P. Lescanne, and J. Rouyer-Degli. ,h,, a calculus of explicit substitutions which preserves strong normalisation, 1995. Available from http : llwv~, loria. ~rl lescanne/publications .html.

[3] P.-L. Curien, T. Hardin, and J.-J. L4vy. Confluence properties of weak and strong calculi of explicit substitutions. Technical Report 1617, INRIA Rocquencourt, 1992.

[4] P.-L. Curien, T. Hardin, and A. R[os. Strong normalisation of substitutions. In MFC5'92, number 629 in LNCS, pages 209-218, 1992.

Page 15: [Lecture Notes in Computer Science] Algebraic and Logic Programming Volume 1139 || λ-calculi with explicit substitutions and composition which preserve β-strong normalization

298

[5] N. de Bruijn. Lambda-calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indag. Mat., 5(35):381-392, 1972.

[6] N. de Bruijn. Lambda-calculus notation with namefree formulas invoIvingsymbols that represent reference transforming mappings. Indag. Mat., (40):384-356, 1978.

[7] T. Ehrhard. Une s4mantique cat4gorique des types ddpendants. Application au calcuf des constructions. Th~se de doctorat, Universit6 de Paris VII, 1988.

[8] M. C. F. Ferreira, D. Kesner and L. Puel. )~-calculi with explicit substitutions and composition which preserve ~-strong normalization, 1996. Available via ftp at ftp.lri .fr/LRI/articles/kesner/psn .ps.gz.

[9] T. Hardin and J.-J. L6vy. A confluent calculus of substitutions. In France-Japan Artificial Intelligence and Computer Science Symposium, 1989.

[10] D. Kesner. Confluence properties of extensional and non-extensional ,~-calculi with explicit substitutions, in Proc. of the Seventh Int. Conf. RTA, 1996. To appear.

[11] F. Kamareddine and A. Rfos. The confluence of the ~se-calculus via a generalized interpretation method. Technical report TR-1996-19, Dep. of Computing Science, University of Glasgow, 1996.

[12] F. Kamareddine and A. Rios. A h-calculus ~ la de Bruijn with explicit substitutions. In Proc. of the Int. Symposium on Programming Language Implementation and Logic

�9 Programming, number 982 in LNCS. Springer-Vedag, 1995. [13] P. Lescanne. Personal Communication. 1996. [i4] P. Lescanne. From ~r to ~v, a journey through calculi of explicit substitutions. In

Ann. ACM Syrup. POPL, pages 60-69. ACM, 1994. [15] P.-A. Mellies. Four typed-lambda calculi with explicit substitutions may not terminate:

the first examples, 1994. Draft. [16] P.-A. Mellies. Typed ~-calculi with explicit substitutions may not terminate. In M.

Dezani-Ciancaglini and G. Plotkin, editors, Proc. of Int. Conf. TLCA, number 902 in LNCS, April 1995.

[17] C. Mufioz. Confluence and preservation of strong normalisation in an explicit substi- tutions calculus. In Proc. of the Symposium LICS, 1996 To appear.

[18] A. Rfos. Contribution ~ /'~tude des ~-calcu/us avec substitutions explicites. Th~se de doctorat, Universit6 de Paris VII, 1993.