Weak Affine Light Typing is complete with respect to Safe Recursion on Notation
Weak affine light typing (WALT) assigns light affine linear formulae as types to a subset of lambda-terms of System F. WALT is poly-time sound: if a lambda-term M has type in WALT, M can be evaluated with a polynomial cost in the dimension of the der…
Authors: ** Luca Roversi (주요 설계자) 외 공동 저자들 (논문에 명시되지 않음) **
W eak A ffi ne Light T yping is complete with r espect to Safe Recu rsion o n Notati on Luca Roversi ∗† Abstract W eak a ffi n e light typing ( W AL T ) assigns light a ffi ne linear formulae as types to a subset of λ -ter m s of 5 System F . W AL T is poly-time sound: if a λ -term M has type in W A L T , M can be evaluated with a polynomial cost in the dimension of the d erivation that gives it a type. The evaluation proceed s under any strategy of a rewriting relation wh ich is a mix of both call-by-name and call-by- value β -reductions. W AL T weakens , namely generalizes , the notion of “ stratification of d eductions ”, common to s o me Lig ht Systems — those logical systems, derived from Linear log ic, to characterize the set of Polynomial functions — . A weaker 10 stratification allows to d efine a comp o sitional embedding of Safe recursion on notation ( SRN ) into W AL T . It turns out that th e expressivity of W AL T is strictly stronger than t he one of the known Ligh t Systems . The embeddi ng passes through the representation of a subsystem of SRN . It is obtained by restr i cting the composition s cheme of SRN to one that can only use its safe variables linearly . On one si de, this sug gests that SRN , in fact, can be redefined in terms of more pr imitive constructs. On the other , the embedding of 15 SRN into W AL T enjoys the two fol l owing remarkable aspects. Ever y datatype, required by the embed d ing, is represented from scratch, showing the strong structural proof-theoretical roots of W AL T . Moreover , the embedding highlights a stratification structure of the normal and safe arguments, normally hidden inside the world of SRN -normal / safe variables: the less an argument is “polyomially impredicative”, the deeper , in a for mal, proof-theoretical sense, it is represented inside W AL T . Finally , since WAL T is SRN -complete it is 20 also polynomial-time compl ete s ince SRN is. ∗ Dipartimento di Informatica, U niversit ` a di T orino, C.so Svizzera n.ro 185 — 1014 9, T ORINO — IT AL Y . † e-mail : roversi@di.unito.it . home page : http:/ /www.di.unito.it/ ˜rover . 1 CONTENTS 2 Contents 1 Introduction 3 2 Overviewing W AL T intuitively 5 3 Overviewing W AL T technically 10 25 3.1 On the rules of W AL T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 The dynamics of W AL T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.3 The combinators of W AL T we nee d to recall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4 Safe Recursion on Notation 17 4.1 Composition-lin ear saf e recursion on notation . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 30 5 The full safe composition of SRN in W AL T 19 5.1 Multiple sharing and rotation of safe names in a square composition . . . . . . . . . . . . . . . 22 6 SRN -complete ness of W A L T 23 7 Conclusions and future work 25 A Some detail ed pro ofs 27 35 A.1 g n ; p \ i m [ M ] is well typed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 A.2 g n ; p \ i m [ M ] well behaves. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1 INTRODUCTION 3 1 Introduction Implicit computational complexity ( ICC ) explor es machine-independent characteriza tions of complexity classes wi thout any explicit reference to resou rce usa ge boun ds, which, instead, result from r estricting 40 suitable comput ational structures. Contributions to ICC can have their r oots in the recursion theory [Cob65, BC92, LM 94, Lei95, Lei99, LM], in the str uctural proof-theory and linear logic [Gir98, Laf04], in the rewriting systems or f unctional programming [Hue80, Der82, Jon99, Lei93, Lei94], in the type systems [Hof97, Hof99a, Hof99b, Hof00, B NS00, BS01]. . . . One specific goal of ICC is to make evident that the known complexity classes are concepts with a n intrin- 45 sic mathematical nature. A way of achieving the goal is to f ormally relate the known ICC characteriza tions. Here, we accomplish the goal relatively to two ICC systems that characteriz e the class FP of Polynomia l functions . Specifica lly , we formally relate the ba sic concept of “predicative recursion” of Safe recursion on notation ( SRN ) [BC92], and the notion of “stratification of the derivations”, basic for Light linear logic ( LLL ) [Gir98] and for va rious proof / type theoretical systems, derive d fro m it. The strategy to formalize the relation 50 is to embed, inductively , SRN i nto W eak a ffi ne light typing ( W AL T ) [Rov07], a type system for pure λ -terms that strictly generalize s Intuitionisti c light a ffi ne logic ( ILAL ) [A sp98, AR02, T er01, T e r07]. Recall that SRN is a recursion theoretical system. It is generate d from a set of basic functions, closed under the safe composition and safe recursion schemes. SRN captures FP by partitioning the set of arguments of each function g ( ~ n , ~ s ) into thos e that a re normal , namely ~ n , and those that are safe , i.e. ~ s . The ba sic functions 55 can only have safe arguments. Th e crucial features of a function f , defined b y an instance of the safe recursive scheme, are: (i) the unfolding of f is driven by a normal argument, and (ii) the recursive call of f may only appear in a safe argument position, as fa r as the unfolding proceeds, ensuring that recursion over the result of a function defined by recursion is not possible. Section 4 formally recalls SRN . In fact, it also recalls Composition-linear safe recursion o n notat ion ( C lSRN ), already introduced in [Rov07] where, however , it was 60 called as Quasi-linear safe recursion on notation . ClSRN restricts SRN ; It is defined on a set of ba sic functions, closed under the full safe recursion scheme of SRN and a linear safe comp osition scheme that uses linearly its safe variables. Namely , ClSRN strictly generalizes BC − [MO04]. Recall that BC − is SRN wher e both the sa fe composition and recursion schemes ca n exclusively use their safe variables linearly . The reason to r ecall ClSRN here is the following one. W e already know that ClSRN can be embe d ded 65 into W AL T [Rov07]. B y using that result, we s how th at, in fact, full SRN can be embedde d in to W AL T , so relating “predicative r ecursion” to “ stratification” without any restriction. Formally , the relation reads as follows. There exists an interpretation map ~ fro m SRN to W AL T , such that, for ever y f ( n 1 , . . . , n k , s 1 , . . . , s l ) ∈ SRN , with k normal and l safe arguments , we can prove th at: (i) if f ( n 1 , . . . , n k , s 1 , . . . , s l ) = n , then ~ f ( n 1 , . . . , n k , s 1 , . . . , s l ) reduces to ~ n , using { w , a rewriting relation which 70 is a mix of both ca ll-by-name and call-by-value β - reductions, and (ii) ~ f ( n 1 , . . . , n k , s 1 , . . . , s l ) has type $ m W , since ~ f has type k z } | { $ W . . . $ W l z }| { $ m W . . . $ m W $ m W , for some m ≥ 1 , the type W being the one for binary words in W AL T . Point (i) shows that W AL T is SRN -complete . Namely , W AL T i s the first system, derived as a restriction of Linear logic to characterize FP , where full SRN can be embedded. 75 Point (ii) links m to the complexity of the de finition of f : m depends on the number o f nested s afe compositions and of safe recursive schemes that define f . The types explicitly show a layered structur e inside the normal and safe arguments of SRN : the type of a safe argument is m ≥ 1 $- modality occurrences deep because a safe argument ca n be used in the course of a recursive unfolding to produce a r esult. Orthogonally , the depth of the type of every normal argument is limited to 1, so giving to every normal 80 argument the nece ssa r y “replication power ”, required to duplica te syntactic str ucture in the course of a n unfolding. On one side, th is means that the Light lin ear logic-like systems say that the weaker is the possibility of a word to replicate structure, behaving it as a n iterator , the deeper is its type. On the other , the recursive systems like SRN are ba sed exactly on the reversed idea, though this cannot be formally sta te d in terms of any typing information inside SRN . 85 A further consequence of embedding SRN into W AL T is that we obtain a second version of such a proo f, 1 INTRODUCTION 4 the first being in [Rov07]. Reca ll that “ polytime completeness” means that every polynom ial T uring machine can be represented as a ter m of W AL T . However , a mor e relevant consequence of look ing for the formal relations between two systems like SRN and W AL T , as we have just done, is the way we prove the SRN -completeness of W AL T . W e shall see that it 90 is obtained by simulating th e full composition scheme of SRN thr ough the linear saf e composition sch eme o f ClSRN and its full r ecursive scheme, which coincides to the one of SRN . This candidates ClSRN to be a linear kernel of SRN , so pointing to the existence of a reformulation of SRN itself in terms of more primitive and linear constructs, as we shall discuss in the conclusions. Finally , we observe that W AL T yields a higher-order characterization of F P in th e li nes of Higher type 95 ramified recursion ( HTRR ) [BNS 00] and Higher or der lin ear ramified r ecursion ( HOLRR ) [ DLM R04], but with a relevant di ff er ence. Both HTRR and HOLRR build their ter ms by a ssuming the existence of constant symbols, like words, successors, etc. . On the co ntrary , n o constant symbol is used inside W AL T where everything is de fined from scratch, exploiting its II-order structural proof-theoretic r oots. Outline. Section 2 intuitively recalls the main intuitions about W AL T , by pointing out how it weakens the 100 design principles of ILAL . Section 3 recalls the technical par ts of W AL T , requir ed to program the combinators that allow to represent the full composition scheme of SRN in W AL T , a s shown in Section 5, so yielding the SRN -completeness. Section 4 formally recalls SRN in the style of [BW96]. Section 7 delineates some possible research directions. 2 OVER VIEWING W AL T INTUITIVEL Y 5 2 Overviewing W AL T intuitively 105 The full technical introduction of W AL T is [Rov07 ]. Here we want to recall the key ideas a b out W AL T at an intuitive level. The main goal is to illustrate the main r easons why W AL T is mo re expressive tha n other ded uctive s ystems, derived from Lin ear logic, to characterize the class of polynomial functions ( FP ). Squaring chains. W AL T contains the main “complex” structur e of Intuitionist ic light a ffi ne logic ( ILAL ) 110 which we call squaring chain . A graph representation of an instance of squaring chain is in Figure 1.(a ) . On a 2 ! a 3 ! $ p r a 1 ! O (max { p , r } ) e (a) $ a 2 ! a 3 ! a 1 ! a 2 ! a 3 ! a 1 ! a 2 ! a 3 ! a 1 ! a 2 ! a 3 ! a 1 ! O (max { p , r } 2 ) p r ( p + 1) e (b) Figure 1: A squaring chain and its reduct top of it ther e is a tree of nodes, a ll the black triangles, that c ontrac t a set of assumptions of the given topmost $-box e . Below the tree of contraction nodes there is a list of !-boxes a 1 , a 2 , a 3 . Every of them depends on at most a single assumption, which is the basic constraint of !- boxes of ILAL . Of course, genera lly , the number of contractions nodes and of !-boxes in a squaring chain is arbitrary and the tree they form need not to be 115 perfectly balance d . The chain is dubbed as “squaring” because its normaliza tion lead s to the configuration in Figure 1.(b), where the size O (max { p , r } ) , essentially , “squares” to a value which is O (max { p , r } 2 ). W eak squaring an d stuck cha ins. However , besides the squaring chains, W AL T contains both weak squaring chains and stuck chains , and its expressive p ower relies on th eir existence. A graph representation of both types of chains is in Figure 2 .(a). The one to the left is a weak squaring chain. The other , to the right, is a 120 stuck chain. The weak squaring chain contains a tree of contraction nodes. However , it is based on a more liberalized form o f !-boxes. They may depend on more than one assumption: one of them must have a !-modal type, the others a $-modal type. The chain under description is “wea k squaring” because only aft er we merge the $-boxes c 1 , c 2 into the !- boxes a 1 , a 2 , r espectively , it tr ansforms to a squaring chain, with !-boxes 125 a 1 ⊲ ⊳ c 1 , a 2 ⊲ ⊳ c 2 , a 3 , th at can be squar ed to the config uration to the left in Figur e 3. W e insist on observing that, before the merging of boxes, no squaring ca n occur . This is why the configuration to the right in Figure 2.(b) is a stuck chain, and not a wea k squaring one. Its “ squaring th rough no rmalization” cannot sta rt, even if we merge b 2 and d 2 , because there is no $-box plugged into the assumption of type $ A of the !-box b 1 . So, the chain to the right in Figure 2.(b) is stuck until 130 the context, eventually , supplies a closed $-box with conclusion $ A that ca n be merged into b 1 , so yielding a squaring chain that we can “square”. W e conclude by remarking that the form of weak squaring and stuck chains is more general than the one in the given e x ample. Indeed , not onl y a single closed $-box can be dangling down the $-modal assumptions 2 OVER VIEWING W AL T INTUITIVEL Y 6 $ p r q O (max { p , q , r , s } ) $ c 1 a 2 ! c 2 $ a 3 ! $ d 2 b 3 ! b 2 ! b 1 ! a 1 ! $ A s (a) $ r p q O (max { p , q , r , s } ) ! ! a 3 ! ! b 1 ! b 3 ! $ A s a 2 ⊲ ⊳ c 2 a 1 ⊲ ⊳ c 1 b 2 ⊲ ⊳ d 2 (b) Figure 2: A weak squaring and a stuck chain a 3 ! a 3 ! a 3 ! a 3 ! $ O (max { p , r } 2 ) p r ( p + 1) q ! b 1 ! b 3 ! $ A ! ! ! ! ! ! ! ! a 1 ⊲ ⊳ c 1 a 2 ⊲ ⊳ c 2 a 1 ⊲ ⊳ c 1 a 2 ⊲ ⊳ c 2 a 1 ⊲ ⊳ c 1 a 2 ⊲ ⊳ c 2 a 1 ⊲ ⊳ c 1 a 2 ⊲ ⊳ c 2 b 2 ⊲ ⊳ d 2 s Figure 3: The reduct of a weak squaring cha in of a !-box, but there can be a whole tree whose nodes can only be $-boxes, which must be closed whenever 135 they constitute the leaves of the tree itself. The la zy nat ure of W AL T . W AL T induces a call-b y- value dynamics on the λ -terms it gives types to as consequence of the more general f orm of its !-boxes, as compared to ILAL . As we have seen, a chain is stuck until the c ontext supplies the $-boxes that close all the assumptions, with $-modal type, of those !-boxes that must be duplicated. A ll such assumption s a re used to represent the parameters in the simulation of the 140 full recursive scheme of SRN inside W AL T , with the right type. W e sh all recall the main idea under some simplifying assumptions, to keep things more readable. Let us a ssume to have a function f , recursively defined as f ( 0 , a ) = g ( a ) , and f ( n , a ) = h ( n − 1 , a , f ( n − 1 , a )), with n ≥ 1. W e want to show how simulating its top-down recursive unfolding: f ( n , a ) = h ( n − 1 , a , f ( n − 1 , a )) = . . . = h ( n − 1 , a , h ( n − 2 , a , . . . h (0 , a , g ( a )) . . . )) by a bottom-up reconstr uction that iterates some transition functions o n suitable config urations and pre- configurations. The reconstruction requi res to assume H , G be the interpretations of h , g , respectively , in W AL T . Mor eover , we assume the unary strings n , a , not words, represent n , a in W AL T . What we are going to say , though, keeps holding with f of ar bitrary a rity a nd with words as its arguments, instead of strings. In W AL T we can develop sequences of computations like the followi ng one, where all the terms can be correctly 2 OVER VIEWING W AL T INTUITIVEL Y 7 typed: h h G a , [0 , . . . , 0 | {z } n + 1 ] , [ a , . . . , a | {z } n + 1 ] i i { ∗ w (1) h h G a , h 0 , [1 , . . . , 1] | {z } n i , h a , [ a , . . . , a ] | {z } n ii i { ∗ w h h H 0 a ( Ga ) , [1 , . . . , 1 ] | {z } n , [ a , . . . , a ] | {z } n i i { ∗ w (2) h h H 0 a ( Ga ) , h 1 , [2 , . . . , 2] | {z } n − 1 i , h a , [ a , . . . , a ] | {z } n − 1 ii i { ∗ w h h H 1 a ( H 0 a ( Ga )) , [1 , . . . , 1] | {z } n − 1 , [ a , . . . , a ] | {z } n − 1 i i { ∗ w . . . (3) The ideal column to the right of { ∗ w contains configurations , the topmost being the initial one. The column to the left of { ∗ w contains pre-configurations . Every pre-configuration comes f rom its preceding configuration by (i) separating head and tail of every list, and storing them as the two compon ents of a same pair , (ii) only 145 on the lef tmost list, simultaneously to the se p a ration, the successor is mapped on the tail. Every configuration, other than th e initial one, is obtained fr om its pr eceding pre-configuration by the application of an instance of H to the first element of every pa ir , and to the first element of the whole pre-configuration, which accumulates the pa rtial result of the bottom-up reconstruction. The main p oint for everything to work correctly in the above simulation is to produce [ a , . . . , a | {z } n + 1 ] with the 150 right type. This is obta ined by using the term in Figure 4 whose definition is substantially b a sed on an instance of the mo re general !-box existing in W AL T , but not in ILAL . The assumption of type $ N in the !- box waits f or a , one $-b ox deep. As soon as this va lue is supplied, the !-box is ready for the duplication by means of the contraction nodes that may be contained in the Church numeral n of type ∀ α. !( α ⊸ α ) ⊸ $( α ⊸ α ), which is the second argument of the whole term. Once both a and n have been given, the result of the whole 155 term is a list of copies of a , wh ose type is the one we can expect: ∀ α. !($ N ⊸ α ⊸ α ) ⊸ $( α ⊸ α ), th at we shorten as LN . The use of the assumptio n with type $ N in the !-box is the key step to obtain a result of type LN which, somewhat, absorbs the $-box initially around the par a meter of a . W ithout this merging we could not obtain a repr esentation of the iterator who se safe arguments are at the same depth as the result, a s required to represent the full recursion scheme of SRN in W AL T . 160 The full SRN -comp osition scheme in W AL T . Once the full recursion scheme of SRN is a t hand in W AL T , we can use it to encode also the full composition scheme of SRN . Figure 5 shows an e xample of functional block diagram that summarizes how the full composition scheme of SRN becomes a term of W AL T . Let us assume F , G , H 1 , H 2 be terms of W AL T that represent the SRN functions f , g , h 1 , h 2 , respectively , and that we need to compose as follows. f takes one normal and two safe arguments which are supplied by g , that depends on a single safe argument, and by h 1 , h 2 . Also, we assume that both h 1 , h 2 require a single normal argument, but h 1 needs th ree safe arguments, while h 2 only one. The first operation to r epresent the full composition scheme of SRN i n W AL T is to genera te the terms F , G , H 1 , H 2 . H 1 will be obtained fro m h 1 as the result of an inductive translation, as we might expect. H 2 will be defined from h 2 with the same inductive process. However , thi s would lead to a term wi th safe arity 1. T o obtain a term H 2 with safe arity 3, we extend the resulting term to era se two of its three safe a rguments: H 2 and the two bullets close to it in Figure 5 represent such a final term. The same holds for F which must erase its third safe argument. Noti ce that the sa fe va lue it erases is supplied by the dummy f unction 0 • • • • , which is constantly equal to 0 , after the erasure of all its arguments: one normal, the others safe. G , supplying it the normal value to F , does not present any problem. The translation process of the functions being composed, a ll with the same safe arity , occurs inside the square compo sition ⊡ 1;3 1 : the topmost parameter 1 is the normal arity of eve ry of the terms being composed, 3 is the maximal sa fe ar ity , namely , the value with respect to which we normalize the terms we generate, a nd the lowermost 1 is the normal arity of F . So, ⊡ 1;3 1 [ F , G , H 1 , H 2 ] has normal arity 1 a nd safe arity 9, since every of the three c omposed terms will have safe arity 3. After the normalized compositio n, the ideal f unctional block χ rearra nges the safe arguments: the first sa f e arguments of H 1 , H 2 • • , and 0 • • • • are put one clo sed to the others, and the same is done for the second and third ones. The goal is to share 2 OVER VIEWING W AL T INTUITIVEL Y 8 $ N N ⊸ LN N ⊸ LN I ⊸ I ∀ I ⊸ I ⊸ E ⊸ E ⊸ E I L N ≡ ∀ α. !( N ⊸ α ⊸ α ) ⊸ $( α ⊸ α ) !( N ⊸ α ⊸ α ) ⊸ $( α ⊸ α ) $((( δ ⊸ δ ) ⊸ α ) ⊸ ( δ ⊸ δ ) ⊸ α ) $( α ⊸ α ) ⊸ I ⊸ I $ ⊸ I ( δ ⊸ δ ) ⊸ α (( δ ⊸ δ ) ⊸ α ) ⊸ ( δ ⊸ δ ) ⊸ α (( δ ⊸ δ ) ⊸ α ) ⊸ ( δ ⊸ δ ) ⊸ α α α δ ⊸ δ ⊸ E ⊸ I ⊸ I ⊸ E ⊸ E !((( δ ⊸ δ ) ⊸ α ) ⊸ ( δ ⊸ δ ) ⊸ α ) ⊸ E I ( δ ⊸ δ ) ⊸ α ∀ E !( N ⊸ α ⊸ α ) $ N ! ( δ ⊸ δ ) ⊸ α α α N ≡ ∀ α. !( α ⊸ α ) ⊸ $( α ⊸ α ) Figure 4: The term that generates the list of constants in a recursive scheme each of the group into a single safe argument. This happens inside the functional block g 1;3 \ 3 m which applies, one a fter the other , three further blocks mY 1;(6 , 3) m , mY 1;(4 , 3) m , mY 1;(2 , 3) m . The b e havior of every of these blocks is to share three safe argumen ts in input into a single safe argument, and to rotate them so tha t a new group of safe arguments gets ready for the sharing of its components by means of the subsequent block. The sharing of the safe arguments is hidden insi de the black triangles. Every of them contains two one-step long iterations that share the same safe va lue in the last two positions of a given term M . The following unfolding illustrates the idea about the behavior of one of such one-step long iterations: Y 1;3 m [ M ] n 1 s 1 s 2 s 3 = M n 1 s 1 s 2 s 3 ( Y 1;3 m [ M ] n 1 s 1 s 2 s 3 ) (4) = M n 1 s 1 s 2 s 3 (( \ x 1 y 1 y 2 y 3 . y 3 ) n 1 s 1 s 2 s 3 ) = M n 1 s 1 s 2 s 3 s 3 W e insist remarking that (4) gives only the idea of what happe ns. The de finition of Y 1;3 m is based on the iteration term, typeable in W AL T , a nd will be f ormally given in Section 5, together with its dynamics. Once the sa fe arguments of ⊡ 1;3 1 [ F , G , H 1 , H 2 ] have b e en shared we are lef t with a term waiting for three safe and one normal arguments. The la tte r is replicated four times by ∇ 1 4 that, sta ndardly , iterates a tuple of successors, starting from a tuple of four instances of 0. Just to remark it again, the above tra nslation mechanism, can be 165 set for a ny normal and safe arities of any number of functions in SRN . 2 OVER VIEWING W AL T INTUITIVEL Y 9 H 1 ∇ 1 4 mY 1;(2 , 3) m mY 1;(6 , 3) m mY 1;(4 , 3) m g 1;3 \ 3 m ⊡ 1;3 1 F H 2 χ 0 G Figure 5: Function al block scheme of SRN -composition in W AL T 3 OVER VIEWING W AL T TECHNICALL Y 10 3 Overviewing W AL T technically Here we recall the ma in aspects of W e a k A ffi ne Light T yping ( W AL T ), as developed in [Rov07 ], and which are requi red to present our results. Recall that W AL T is a type a ssignment for λ -terms. The λ -te rms. The λ -terms are generated by the grammar M :: = x | ( \ x . M ) | ( MM ), where x belongs to a countable set of λ -va riables. An abstraction \ x . M binds the (free) occurrence of x in M . Given a term M , the set of its f ree va riables, those ones which are not bound, is FV( M ). A closed term has no free varia b le s. The cardinality of a free variable in a term is no ( x , M ) and counts the number of free occurr ences of x in M : no( x , x ) = 1 no( x , y ) = 0 ( x . y ) no( x , \ x . M ) = 0 no( x , \ y . M ) = no( x , M ) ( x . y ) no( x , MN ) = no( x , M ) + no ( x , N ) M { N 1 / x 1 · · · N m / x m } denotes the usual capture free simultaneous substitution of every N i for the corresponding 170 x i , with 1 ≤ i ≤ m . Parentheses are left-associative, so (( · · · (( MM ) M ) · · · ) M ) shortens to MMM · · · M . A sequence of abstractions ( \ x 1 . . . . ( \ x m . M ) . . . ) is shortened by \ x 1 . . . x m . M , for any m . Λ V is the set of the λ -terms which are values , generated by V :: = x | ( \ x . M ), where M is any λ -term. The size o f a term | M | gives the dimension of M as expected: | x | = 1 , |\ x . M | = | M | + 1 , | MN | = | M | + | N | + 1. The types o f W AL T . They are formulae that belong to the language, generated by the following grammar: A :: = L | ! A | $ A L :: = α | A ⊸ A | $ A A | ∀ α. L A is the start symbol. A modal formula has form ! A or $ A , and, in particular , ! A is !-modal, while $ A is 175 $-modal. L generates linear , or non modal , f ormulae, wh ich are ranged over b y L , L ′ . Generic formulae by A , B , C , instead. Not ice that the substitution of α in ∀ α. L for a linear type L ′ , p roduces L { L ′ / α } which is still linear . Somewhat conversely , a universal quantification cannot hide a modal type . The rule s of W AL T . Figure 6 gives the deductive rules of W AL T , which de duce judgments Γ ; ∆ ; E ⊢ M : A . Γ and ∆ a re sets of type assignments, namely of pairs x : A . E is a set of pairs ( Θ ; Φ ) such that both Θ and Φ 180 are sets of type a ssignments as well. Dom( { x 1 : A 1 , . . . , x n : A n } ) = { x 1 , . . . , x n } is the dom ain of a ny set { x 1 : A 1 , . . . , x n : A n } of type assignments. Γ will denote a set of linear typ e assignments x : L . Every x ∈ Dom( Γ ) is called linear variable . ∆ will denote a set of linear partially discharged type assignments. Ever y x ∈ Dom( ∆ ) is called linear partially discharged . E will denote a set of partially discharged cont exts . E ca n be either empty o r it contains pairs ( Θ 1 ; Φ 1 ) , . . . , ( Θ n ; Φ n ) 185 where, for every i ∈ { 1 , . . . , n } , the following four points hold: ( i) Θ i is a set of elementary partially d ischarged type assignment. Every x ∈ Dom( Θ i ) is called elementary ; (ii) Φ i is either empty or it is a singleton x : A . W e ca ll x p olynomial ; (iii) only one between Φ 1 , . . . , Φ n can be ∅ ; (iv) the domains of any two Φ i and Φ j are distinct, whenever i , j . For every E = S n i = 1 { ( Θ i ; Φ i ) } , Dom( E ) is ( S n i = 1 Dom( Θ i )) ∪ ( S n i = 1 Dom( Φ i )). In every of the rules of W AL T the domain of two sets of type a ssignments Φ M and Φ N may intersect when Φ M and Φ N are pa rt of two partially discharged con texts E M and E N that belong to two distinct premises of a r ule. This observation justifies the definition of E M ⊔ E N that merges E M and E N , preserving the structure of a partially discharged context: E M ⊔ E N = { ( Θ M , Θ N ; Φ ) | ( Θ M ; Φ ) ∈ E M and ( Θ N ; Φ ) ∈ E N }∪ { ( Θ M ; Φ M ) | ( Θ M ; Φ M ) ∈ E M and th ere is no Θ N such tha t ( Θ N ; Φ M ) in E N }∪ { ( Θ N ; Φ N ) | ( Θ N ; Φ N ) ∈ E N and th ere is no Θ M such tha t ( Θ M ; Φ N ) in E M } The sequence E , ( Θ ; Φ ) denotes that ( Θ ; Φ ) < E . Also, E ⊔ { ( ∅ ; ∅ ) } = E ⊔ ∅ = E . In every other cases, the domain 190 of two sets of type assignments tha t belong to two distinct premises of a rul e of W AL T must be disjoint. Λ T is 3 OVER VIEWING W AL T TECHNICALL Y 11 Γ , x : L ; ∆ ; E ⊢ x : L A Γ ; ∆ ; E , ( Θ x ; { x : A } ) , ( Θ y ; { y : A } ) ⊢ M : B Γ ; ∆ ; E ⊔ { ( Θ x , Θ y ; { z : A } ) } ⊢ M { z / x z / y } : B C Γ , x : L ; ∆ ; E ⊢ M : B Γ ; ∆ ; E ⊢ \ x . M : L ⊸ B ⊸ I Γ ; ∆ , x : A ; E ⊢ M : B Γ ; ∆ ; E ⊢ \ x . M : $ A ⊸ B ⊸ I $ Γ M ; ∆ M ; E M ⊢ M : A ⊸ B Γ N ; ∆ N ; E N ⊢ N : A A . ! C , for any C Γ M , Γ N ; ∆ M , ∆ N ; E M ⊔ E N ⊢ MN : B ⊸ E Γ ; ∆ ; E , ( Θ ; { x : A } ) ⊢ M : B Γ ; ∆ ; E ⊔ { ( Θ ; ∅ ) } ⊢ \ x . M : ! A ⊸ B ⊸ I ! Γ M ; ∆ M ; E M ⊢ M :! A ⊸ B Γ N ; ∆ N ; E N ⊢ N : ! A E M ⊆ { ( ∅ ; Φ 1 ) , . . . , ( ∅ ; Φ n ) } Γ M , Γ N ; ∆ M , ∆ N ; E M ⊔ E N ⊢ MN : B ⊸ E ! Γ ; ∆ ; E , ( Θ , x : A ; ∅ ) ⊢ M : B Γ ; ∆ ; E ⊔ { ( Θ ; ∅ ) } ⊢ \ x . M : $ A B I Γ M ; ∆ ; E M ⊢ M : $ A B ∅ ; ∅ ; E N ⊢ N : $ A E N ⊆ { ( Θ ; ∅ ) } Γ M ; ∆ ; E M ⊔ E N ⊢ MN : B E Γ ; ∆ ′ ; { ( Θ ′ ; ∅ ) } ⊢ M : B Γ ⊆ ∆ ∪ S m i = 1 Θ i ∪ S m i = 1 Φ i Θ i , ∅ i ff Φ i = ∅ Γ ′ ; $ ∆ ′ , ∆ ; { ($ Θ ′ ; ∅ ) } ⊔ { ( Θ 1 ; Φ 1 ) } ⊔ . . . ⊔ { ( Θ m ; Φ m ) } ⊢ M : $ B $ Γ ; ∅ ; { ( Θ ′ ; ∅ ) } ⊢ M : B Γ ⊆ Θ ∪ Φ Θ , ∅ ⇒ Dom( Φ ) ∩ FV( M ) , ∅ Γ ′ ; ∆ ; { ($ Θ ′ ; ∅ ) } ⊔ { ( Θ ; Φ ) } ⊢ M : ! B ! Γ ; ∆ ; E ⊢ M : L α not free in Γ , ∆ and E Γ ; ∆ ; E ⊢ M : ∀ α. L ∀ I Γ ; ∆ ; E ⊢ M : ∀ α. L Γ ; ∆ ; E ⊢ M : L { L ′ /α } ∀ E Figure 6: W eak A ffi ne Light T yping 3 OVER VIEWING W AL T TECHNICALL Y 12 the subset of typeable elements M of Λ , namely , thos e for which a deduction Π with conclusio n Γ ; ∆ ; E ⊢ M : A exists, denoted by Π ⊲ Γ ; ∆ ; E ⊢ M : A . W AL T and System F . W AL T is a subsystem of System F . This means that if Γ ; ∆ ; E ⊢ M : A then M has type t ( A ) from the set of assumptions T ( Γ ; ∆ ; E ) in System F , where: 195 t ( α ) = α t ( ∀ α. A ) = ∀ α. t ( A ) t ( A ⊸ B ) = t ( A ) → t ( B ) t ( A B ) = t ( A ) → t ( B ) t ($ A ) = t ( A ) t (! A ) = t ( A ) and T is the obvious exte nsion of the map t to the types in Γ ; ∆ ; E . 3.1 On the rules of W AL T The bound on the number of normaliza tion steps of any deduction of W AL T is a cons equence of the stratified nature that W AL T inherits from ILAL . “Stratification” mea ns that every deduction Π of W AL T can be thought 200 of as it was organized into levels, so that the logi cal rules of Π may be at di ff erent depths. The normalization preserves the levels: if an instance of a rule R in Π is at de pth d , then it will keep being at depth d af ter any number of normalization steps that, of course, do not er ase it. The onl y duplication a llowed is of deductions Π that have under gone an instance r of the ! rule, namely the conclusion of Π has a !-modal type, introduced by r . Ideally , the ! rule d efines a, so called, !-box a round the deduction that proves its pr emise. Figure 7 205 shows, side by side, a canonical instance of the rule ! and the !-box that would correspond to it if we imagined to associate a proof net notation to the derivations of W AL T . The hypothesis is that Π M , with conclusion of x 1 : C 1 , . . . , x n : C n , x : B ; ∅ ; ∅ ⊢ M : A n > 0 ⇒ x ∈ FV( M ) ∅ ; ∅ ; { ( { x 1 : C 1 , . . . , x n : C n } ; { x : B } ) } ⊢ M : ! A ! . . . ! B ! A A C n B ! C 1 $ C n $ C 1 Π M Figure 7: The canonical instance of !-box / rule in W AL T type A and assumptions C 1 , . . . , C n , B , corresponds to the term M that has type B f rom the set of linea r type assignments x 1 : C 1 , . . . , x n : C n , x : B . The application of the rule ! corresponds to putting the !-box around Π M . The condition n > 0 ⇒ x ∈ FV( M ) a ssures that the substitution of some closed term N , with type ! B , for 210 x in M , cannot yield M { N / x } that on ly depends on a single assumption. Namely , we want to avoid that a sequence of normalization steps, can yield a judgment ∅ ; ∅ ; { ( { x 1 : C 1 } ; ∅ ) } ⊢ M ′ :! A , where ! A says that it can be duplica ted, but whose free assumption says that it ca nnot, since W AL T does not ha v e the contraction on $-modal assumptions. W e remark that the !-box can be put a roun d a d e rivation Π that ma y depend on more than one assum ption, letting W AL T be a strict genera lization of ILAL , whose !-boxes, in the context of W AL T , take the form: Φ ; ∅ ; ∅ ⊢ M : B Φ ⊆ { x : A } ∅ ; ∅ ; { ( ∅ ; Φ ) } ⊢ M : ! B The elementary partially discharged assumptions the genera lized !- boxes may depend on can only be 215 replaced, in the course o f th e n ormalization steps, by the conclusion of $-boxes exc lusively depending on elementary par tially discharged assumptions as well. Figure 8 shows, with the help of a net, that such 3 OVER VIEWING W AL T TECHNICALL Y 13 Γ ; ∆ ; E M ⊢ M : $ C A ∅ ; ∅ ; E N ⊢ N : $ C E N ⊆ { ( Θ ; ∅ ) } Γ ; ∆ ; E M ⊔ E N ⊢ MN : D E I $ $ C ′ $ Θ ′ E I $ C $ E $ Θ $ C ′ $ C A $ C ′ A Π N Π M Figure 8: “Net” meaning of the rule E in W AL T ! A A B ! $ C ⊸ I ! I ! B C Γ ; ∆ ; E , ( Θ ; { x : B } ) ⊢ M : A Γ ; ∆ ; E ⊔ { ( Θ ; ∅ ) } ⊢ \ x . M : ! B ⊸ A ⊸ I ! Γ ; ∆ ; E , ( { Θ , y : C } ; ∅ ) ⊢ M : A Γ ; ∆ ; E , ( Θ ; ∅ ) ⊢ \ x . M : $ C A I Figure 9: “Net” meaning of the rules I , ⊸ I ! in W AL T a behavior is a consequence of restricting E N , in the rule E , to the form { ( Θ ; ∅ ) } . The rule E comes with I that can discharge elementary partially discharged assumptions only when the corresponding polynomial assumption has already been discharged by ⊸ I ! , as in Figure 9. The net in such a figure shows 220 the mandatory discharging order . Finally , Figure 10 shows, with the help of a net, how ⊸ E ! consistently forces the applica tion of some given M of type ! B ⊸ C to an N , of type ! B , according to a n order which reverses the one we must use to apply ⊸ I ! , and I . Summing up, W AL T allows to type λ -terms more liberally than ILAL , while keeping the same normal- ization principles: the stratification is never canceled, a nd only deductions that, eventually , depend on at 225 most one free v a riable may be e ff ectively d uplicated a s e ff ect of the normalization. This is why W AL T does not enjoy a full normalizing procedure, the a nalogous o f th e cut elimination for a corr esponding s equent calculus formulation, as the coming section recalls. 3.2 The dynamics of W AL T . Recall that the call-by-name , or lazy , β -reduction on the λ -terms is the contextual closur e of rewriting relation 230 ( \ x . M ) N → n M { N / x } . The call- by- value , or eager , β -reduction, instead, is the contextual closur e of ( \ x . M ) N → v M { N / x } , where N ∈ Λ V . The subject reduction of the rules in Figure 6 holds only on the f ollowing restriction { w of → n ∪ → v : 3 OVER VIEWING W AL T TECHNICALL Y 14 Γ M ; ∆ M ; E M ⊢ M : ! B ⊸ C Γ N ; ∆ N ; E N ⊢ N : ! B E M ⊆ { ( ∅ ; Φ 1 ) , . . . , ( ∅ ; Φ n ) } Γ M , Γ N ; ∆ M , ∆ N ; E M ⊔ E N ⊢ MN : C ⊸ E ! ! A A B ! $ D C D ⊸ E ! ! B Π M ! B C ⊸ I ! Π N ! B C Figure 10: “Net” meaning of the rule ⊸ E ! in W AL T ( \ x . M ) N { w M if no( x , M ) = 0 ( \ x . M ) N { w M { N / x } if no( x , M ) = 1 , and N ∈ Λ V ( \ x . M ) N { w M { N / x } if no( x , M ) > 1 , and N ∈ Λ V , and FV ( N ) ⊆ { y } { + w is the transitive closure of { w , while { ∗ w is the reflexive and transitive closure of { w . M is in { w -normal form, and we write nf( M ), if { w cannot rewrite M anymore. 235 W e conclude by recalling two main fea tures of W AL T : Theorem 3.1 (Subject reduction ([Rov07]).) Γ ; ∆ ; E ⊢ M : A and M { ∗ w N , imp ly Γ ; ∆ ; E ⊢ N : A. Theorem 3.2 (Polytime soundness ([Rov07]).) Let Π be a derivation of W AL T whose conclusion be Γ ; ∆ ; E ⊢ M : A. Let d( Π ) be th e maximal depth of Π , namely the maxima l number o f instances of the rules $ , ! that we can trav erse moving from the conclusion of Π , to every of its axioms instances. Then, M normalizes to its normal form nf( M ) in a 240 number of steps, hence in a time, wh ich is O ( | Π | k d( Π ) ) , for som e k. 3.3 The combinators of W AL T we need to recall W e recall the main aspects of combinators that can be typed in W AL T , and which are required to show the completeness of W AL T w .r .t. SRN . The details are in [Rov07]. (Binary) W ords. They a re the terms: 0 ≡ \ 0 1 y . y 2 m + 2 m − 1 · ν m − 1 + · · · + 2 0 · ν 0 ≡ \ 01 y .ν 0 ( · · · ( ν m − 1 (1 y ) · · · )) ( m ≥ 1) that allow to encode the natural num bers in binary notation. Every word ha s type W ≡ ∀ α. !( α ⊸ α ) ⊸ !( α ⊸ 245 α ) ⊸ $( α ⊸ α ), where m ≥ 0 and ν 0 ≤ i ≤ m − 1 ∈ { 0 , 1 } . Notice that every word is a Church numeral built using the two successors, identified by the va riable names 0, a nd 1. The c ombinators Ws0 , W s1 , and P , wi th type W ⊸ W , and B , with type W ⊸ W ⊸ W ⊸ W , exist. They a re the two successors, the predecessor a nd the branching, respectively . The branching yields its second a rgument as result, if the first one is the wor d 0. Otherwise, the result is the third argument. 250 3 OVER VIEWING W AL T TECHNICALL Y 15 Eager tensor . W e nee d the ea ger tensor to represent tuples of λ -terms. For every m ≥ 1, the type eager tensor is J m i = 1 A i ≡ ∀ α. ( m i = 1 A i α ) ⊸ α . Its type constructors coincide to the standard tuples in the λ -calculus: h { M 1 . . . M m } i ≡ \ z . z M 1 . . . M m ( m ≥ 1 ) \h { x 1 . . . x m } i . M ≡ \ w . w ( \ x 1 . . . x m . M ) ( m ≥ 1 ) Here, we ca n fairly assume that only to closed terms can be used in h { M 1 . . . M m } i . In [Rov07] the constraint is a little bit more weak. S o, for e very closed M 1 , . . . , M m , we have ( \h { x 1 · · · x m } i . M ) h { M 1 , . . . , M m } i { + w ( \ x 1 . . . x m . M ) M 1 . . . M m . Embeddi ng. W e can embed the a rguments and the result of terms, with a functional type, into a suitable number of boxes. S ince we have two kinds of implications, and we can transform the standard linear 255 implication into a n eager one, we have (a t least) the following three kinds of embedding functors. The basic embedding is Eb n [ M ] ≡ \ x . Mx , for ever y n ≥ 1. It takes a term M , with type L ⊸ $ m A , for any m ≥ 0, and yields one of type $ n L $ m + n A . The linear embedding is El n p [ M ] ≡ \ x 1 . . . x p . M x 1 . . . x p , for every n , p ≥ 0. It takes a ter m M , with type ( ⊸ p i = 1 L i ) ⊸ $ m A , for e very m ≥ 0, and yields one of type ( ⊸ p i = 1 $ n L i ) ⊸ $ m + n A . 260 The eager embedding Ee n p ; q [ M ] is: \ w 1 . . . w p z 1 . . . z q . ( \ w 1 . . . w p . Mw 1 . . . w p z 1 . . . z q )( Eb 1 [ Coerc e n ] w 1 ) . . . ( Eb 1 [ Coerc e n ] w p ) , for every n , p , q ≥ 0. It takes a term M of type ( p i = 1 $ W ) ( q j = 1 $ m L j ) $ m A and yields on e of type ( p i = 1 $ n W ) ( q j = 1 $ m + n L j ) $ m + n A . Coercing. The coerce function takes an instance of a b inar y word and reconstructs it inside a box. It is Coerce ≡ \ n . ( \ z . z 0 )( n Ws0 W s1 ). T o our purposes, Coer ce must be iteratively composed to reconstr uct a word into some given number of boxes: Coerce 0 ≡ \ x . x Coerce 1 ≡ Coe rce Coerce m + 1 ≡ \ x . El 1 1 [ Coerc e m ]( Coer ce 1 x ) ( m ≥ 1 ) For every m ≥ 0, Co erce m has type W ⊸ $ m W . Eager diagonal. T he eager d iagonal ∇ m n is: \ w . ( \ z . z n z }| { h { 0 , . . . , 0 } i )( w ( \h { x 1 . . . x n } i . h { Eb m [ Ws0 ] x 1 , . . . , Eb m [ Ws0 ] x n } i ) ( \h { x 1 . . . x n } i . h { Eb m [ Ws1 ] x 1 , . . . , Eb m [ Ws1 ] x n } i )) for ever y m , n ≥ 1. It combines the copies of the word, given as its input, by mea ns of an elementary tensor constructor . Namely , ∇ m n a { + w n z }| { h { a , . . . , a } i . E very copy is generated from scratc h, by iterating the succe ssors 265 on words. The result is contained into a single box, but every component of the elementary tensor , in the result, is m boxes deep. Namely , ∇ m n has type W ⊸ $( J n i = 1 $ m W ). 3 OVER VIEWING W AL T TECHNICALL Y 16 Iterator . For ev e ry n , s ≥ 0, and m ≥ 1 , and for every closed ter m G 0 , G 1 , and G 2 , all with type $ W ( n i = 1 $ W ) ( s j = 1 $ m W ) $ m W $ m W , the itera tor It 1 + n ; s [ G 0 , G 1 , G 2 ] has type: $ W ( n i = 1 $ W ) ( s i = 1 $ m + 4 W ) $ m + 4 W As expected, the first arg ument of It 1 + n ; s [ G 0 , G 1 , G 2 ] drives the itera tion, G 2 is the base function, whi le G 0 and G 1 are the inductive ones, chosen by the “bits” in the first argument itself of It 1 + n ; s [ G 0 , G 1 , G 2 ]. T o formally recall the behavior of the iterator , we need to assume that: ( i) n , s ≥ 0, a , n , n 1 , . . . , n n , s 1 , . . . , s s 270 be some words, (ii) { ν 0 , ν 1 , . . . } be a denumerable set of metavar iables to ra nge over { 0 , 1 } , (iii) [ x ] i denotes a list with i ∈ N copies of the word x , for any x . Also, we assume that: • G 2 0 n 1 . . . n n s 1 . . . s s 0 rewrites to a word a , and • G 1 0 n 1 . . . n n s 1 . . . s s a rewrites to a word, denoted as r [0 , a , n 1 , . . . , n n , s 1 , . . . , s s ], and 275 • for every m , i , such that m ≥ 0 , m − 1 ≥ i ≥ 0, G ν i m − ( i + 1) X j = 0 2 m − ( i + 1) − j ν m − j n 1 . . . n n s 1 . . . s s r [ m − ( i + 1) , a , n 1 , . . . , n n , s 1 , . . . , s s ] rewrites to a word, denoted as r [ m − i , a , n 1 , . . . , n n , s 1 , . . . , s s ]. Then: It 1 + n ; s [ G 0 , G 1 , G 2 ] 0 n 1 . . . n n s 1 . . . s s { + w a It 1 + n ; s [ G 0 , G 1 , G 2 ] m X j = 0 2 j ν j n 1 . . . n n s 1 . . . s s { + w r [ m , a , n 1 , . . . , n n , s 1 , . . . , s s ] m X j = 0 2 j ν j , 0 The full details about It 1 + n ; s [ G 0 , G 1 , G 2 ] are in [Rov07], whose keypoint is to prove that such a combinator is indeed representable inside W AL T , giving its completeness w .r .t. ClSRN . 4 SAFE RECURSION ON NOT A TION 17 4 Safe Recursion o n Notation W e recall two classes of functions : Safe recursion o n not ation ( SRN ) [BC9 2], and Comp osition-linear safe recursion 280 on notation ( ClSRN ), both in the style of [BW96]. Remark that Composition-linear safe recursion on notation was identified a s Quasi-linear safe recursion on notation in [Rov07]. The reason for the name changing will be given in the conclusions (Section 7). The signature of Safe recursion on notat ion. Let Σ SRN = ∪ k , l ∈ N Σ k , l SRN be the signature of S a fe recursion on notation . Σ SRN contains the base functions and it is closed under the schemes called safe composition a nd safe 285 recurs ion . Fo r every k , l ∈ N , the base functions are the zero z k ; l ∈ Σ k ; l SRN , the successors s 0;1 0 , s 0;1 1 , the predecessor p 0;1 ∈ Σ 0;1 SRN , the p rojection π k ; l i ∈ Σ k ; l SRN , with 1 ≤ i ≤ k + l , a nd the branching c 0 , 3 ∈ Σ 0;3 SRN . The safe composition is ◦ k ; l k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ] ∈ Σ k ; l SRN if f ∈ Σ k ′ ; l ′ SRN , g 1 , . . . , g k ′ ∈ Σ k ;0 SRN , and h i ∈ Σ k ; l SRN , for every k , k ′ , l , l ′ ∈ N . The safe recursion is r k + 1; l [ g , h 0 , h 1 ] ∈ Σ k + 1; l SRN if g ∈ SRN k ; l , and h 0 , h 1 ∈ Σ k + 1; l + 1 SRN . 290 Safe recursion on notation. L et V be a denumerable set of names of variables , disjoint from Σ SRN . The set Safe recursion on notation ( SRN ) contains functions with signature Σ SRN . SRN is de fined as follows. V ⊂ SRN , and for eve ry k , l ∈ N , if f ∈ Σ k ; l SRN , and t 1 , . . . , t k , u 1 , . . . , u l ∈ SRN , then f ( t 1 , . . . , t k , u 1 , . . . , u l ) ∈ SRN . A term is closed if it does not contain var ia bles of V . Notations and te rminology . x , y , z . . . denote elements of V . t , u , v . . . d e note elements of SRN . For every 295 f ∈ Σ k , l SRN , k and l are the normal and safe arity of f , r espectively . For every k , l ∈ N , such that l − k ≥ 1, ~ t [ k ; l ] denotes a non empty sequence t k , . . . , t l of l − k + 1 ter ms in SRN . ~ t [ k ; l ] ( i ), with k ≤ i ≤ l , denotes the element t i of ~ t [ k ; l ] . An equational the ory on SRN . The definition of the equational theory exploits that every natural number n can be written, uniquely , in bin ary no tation, as P m j = 0 2 m − j ν m − j . So, assuming to abbreviate the ba se 300 functions s 0;1 0 , s 0;1 1 as s 0 , s 1 , respectively , we can follow [ M O04] and say that 0 is equivalent to z 0;0 , and n ≥ 1 to s ν 0 ( . . . ( s ν m − 1 ( s 1 z 0;0 )) . . . ). Then, the equational theory is as follows. Zero is constantly e qual to 0: z k ; l ( ~ x [1; k ] , ~ x [ k + 1; k + l ] ) = 0 f or a ny k , l ∈ N . The predecess or erases the least significant bit of any number greater than 0: for every i ∈ { 0 , 1 } , p 0;1 (0) = 0, and p 0;1 ( s i ( y )) = y . W e shall use p as an abbreviation of p 0;1 . The conditional has three arguments. I f the first is zero, then the result is the second argument. Otherwise, it is 305 the third one: for every i ∈ { 0 , 1 } , c 0 , 3 (0 , y 0 , y 1 ) = y 0 , and c 0 , 3 ( s i ( y ) , y 0 , y 1 ) = y 1 . The projection chooses one argument, out of a given tuple, as a result: for every 1 ≤ i ≤ k + l , π k ; l i ( ~ x [1; k ] , ~ x [ k + 1; k + l ] ) = x i . The safe composition uses as arguments of f both the results of the normal functions g 1 , . . . , g k ′ , applied to k normal arguments, and the result of the safe functions h 1 , . . . , h l ′ , ap p lied to k normal and l safe arguments: ◦ k ; l k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ]( ~ x [1; k ] , ~ x [ k + 1; k + l ] ) = f ( g 1 ( ~ x [1; k ] ) , . . . , g k ′ ( ~ x [1; k ] ) , h 1 ( ~ x [1; k ] , ~ x [ k + 1; k + l ] ) , . . . , h l ′ ( ~ x [1; k ] , ~ x [ k + 1; k + l ] )) . The r ecursion iterates either the function h 0 , or h 1 , as many times as the length of its first argument. The choice between h 0 , a nd h 1 depends on the least significant digit of the first a rgument, while the base of the iteration is a function g . The recursion is: r k + 1; l [ g , h 0 , h 1 ](0 , ~ x [1; k ] , ~ x [ k + 1; k + l ] ) = g ( ~ x [1; k ] , ~ x [ k + 1; k + l ] ) r k + 1; l [ g , h 0 , h 1 ]( s i ( x ) , ~ x [1; k ] , ~ x [ k + 1; k + l ] ) = h i ( x , ~ x [1; k ] , ~ x [ k + 1; k + l ] , r k + 1; l [ g , h 0 , h 1 ]( x , ~ x [1; k ] , ~ x [ k + 1; k + l ] )) . 4 SAFE RECURSION ON NOT A TION 18 4.1 Composition-linear safe recursion on notation ClSRN is SRN with a restricted f orm of safe composition, which we call linear (safe) comp osition . Its signature is ⋄ k ; P l ′ i = 1 l i k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ] ∈ Σ k ; P l ′ i = 1 l i ClSRN if f ∈ Σ k ′ ; l ′ ClSRN , g 1 , . . . , g k ′ ∈ Σ k ;0 ClSRN , and h i ∈ Σ k ; l i ClSRN , with i ∈ { 1 , . . . , l ′ } , for every k , l , l ′ , l 1 , . . . , l l ′ ∈ N . Namely , unlike the ge ner a l safe composition scheme of SRN , the safe arguments are used linearly: the list of sa fe arguments is split into a s many sub-sequences as required by the safe arity of every safe function h j , with 1 ≤ j ≤ l ′ : ⋄ k ; P l ′ i = 1 l i k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ] ( ~ x [1; k ] , ~ x [ k + 1; k + l 1 ] , ~ x [ k + 1 + l 1 ; k + l 1 + l 2 ] , . . . , ~ x [ k + 1 + P l ′ − 1 i = 1 l i ; k + 1 + P l ′ i = 1 l i ] ) = f ( g 1 ( ~ x [1; k ] ) , . . . , g k ′ ( ~ x [1; k ] ) , h 1 ( ~ x [1; k ] , ~ x [ k + 1; k + l 1 ] ) , . . . , h l ′ ( ~ x [1; k ] , ~ x [ k + 1 + P l ′ − 1 i = 1 l i ; k + 1 + P l ′ i = 1 l i ] )) . 5 THE FULL SAFE COMPOSITION OF SRN IN W AL T 19 5 The full safe com position of SRN in W AL T W e know that W AL T contains ClSRN as its subsystem. Namely , it holds: 310 Theorem 5.1 ([Rov07].) There is a map ~ , such th at, if f ( n 1 . . . , n k , s 1 . . . , s l ) belongs to ClSRN , and f ( n 1 , . . . , n k , s 1 , . . . , s l ) = n, then ~ f ( n 1 , . . . , n k , s 1 , . . . , s l ) { ∗ w n, for every n 1 , . . . , n k , s 1 , . . . , s l , n ∈ N , in binary notation. Here we go further by defining the combinators that, using the base combinators of Section 3.3, give the full safe composition scheme of SRN a s a term of W AL T . The definitions here below will realize the functional blocks of the example in Figure 5. 315 Sharing safe names. Let n , s ≥ 0, m ≥ 1, a nd a closed term M , with type ( n i = 1 $ W ) ( s + 1 j = 1 $ m W ) $ m W , be given. W e call Y n ; s m the closed ter m that takes M and n + s wor ds as its a rguments. The first n arguments can be viewed as a normal ones, while the s second ones a s safe. Then , Y n ; s m applies M to the normal a nd sa f e arguments, using s s as a value for the two last saf e positions. Namely , the behavior is: Y n ; s m [ M ] n 1 . . . n n s 1 . . . s s { + w M n 1 . . . n n s 1 . . . s s s s Clearly , using the same safe value twice, a fter its d uplication, we are sharing it. The ty p e of Y n ; s m is: (( n i = 1 $ W ) ( s + 1 j = 1 $ m W ) $ m W ) ( n i = 1 $ W ) ( s j = 1 $ m + 4 W ) $ m + 4 W The definition of Y n ; s m is: It 1 + n ; s [ \ w x 1 . . . x n y 1 . . . y s + 1 . 0 , \ w . M , \ w x 1 . . . x n y 1 . . . y s + 1 . y s ] 1 Rotating sa fe names . L e t n , s ≥ 0, m ≥ 1, and a closed term M , with type ( n i = 1 $ W ) ( s j = 1 $ m W ) $ m W , be given. W e call n ; s m the closed term that ta kes M and n + s words as its arguments. The first n arguments can be viewed as a normal ones, while the second s as safe. n ; s m applies M to the normal a rguments in the given order , while using s 1 as va lue at position s , shifting all the others lef tward. Na mely , the behav io r is: n ; s m [ M ] n 1 . . . n n s 1 . . . s s { ∗ w M n 1 . . . n n s 2 . . . s s s 1 The ty p e of n ; s m is: (( n i = 1 $ W ) ( s j = 1 $ m W ) $ m W ) ( n i = 1 $ W ) ( s j = 1 $ m W ) $ m W The definition of n ; s m is \ x 1 . . . x n y s y 1 . . . y s − 1 . M x 1 . . . x n y 1 . . . y s . Multiple sharing of safe names. Let n , p , q ≥ 0, and m ≥ 1. Let M be a closed term with type ( n i = 1 $ W ) ( p + q j = 1 $ m W ) $ m W , when p ≥ 1, a nd ( n i = 1 $ W ) $ m W , when p = 0 . W e c a ll mY n ;( p , q ) m the closed term that takes M and n + p + q words as its arguments. The first n arguments can be viewed as normal ones, while the second p + q as safe. If p > 0, and q ≥ 1 , then mY n ;( p , q ) m applies M to the normal and sa fe arguments, using s p as a value for the last q safe positions. Namely , the behav ior is: mY n ;( p , q ) m [ M ] n 1 . . . n n s 1 . . . s p { ∗ w M n 1 . . . n n s 1 . . . s p q z }| { s p . . . s p ( p > 0 , q ≥ 1) 5 THE FULL SAFE COMPOSITION OF SRN IN W AL T 20 Otherwise, mY n ;( p , q ) m [ M ] coincides to M . The ty p e of mY n ;( p , q ) m is: (( n i = 1 $ W ) ( p + q j = 1 $ m W ) $ m W ) ( n i = 1 $ W ) ( p j = 1 $ m + 4 q W ) $ m + 4 q W ( p ≥ 1) (( n i = 1 $ W ) $ m W ) ( n i = 1 $ W ) $ m W ( p = 0) The definition of mY n ;( p , q ) m is: mY n ;( p , q ) m [ M ] ≡ M ( p = 0 or q = 0) mY n ;( p , 1) m [ M ] ≡ Y n ; p m [ M ] ( p > 0) mY n ;( p , q ) m [ M ] ≡ Y n ; p m + 4( q − 1) [ mY n ;( p , q − 1) m [ M ]] ( p > 0 , q > 1) Multiple sharing and ro tat ion of safe names. L et n , p , q ≥ 0, and m ≥ 1. Let M be a closed term with type ( n i = 1 $ W ) ( p + q j = 1 $ m W ) $ m W , when p ≥ 1, and ( n i = 1 $ W ) $ m W , when p = 0. W e call mY n ;( p , q ) m the closed ter m that ta ke s M and n + p + q words as its arguments. The first n arguments can be v ie wed a s normal ones, while the last p + q as safe ones. If p ≥ 1, then mY n ;( p , q ) m applies M to the normal a rguments in the given order , while using s 1 as value in the last q positions, shifting all the others leftward. Namely , the behavior is: m Y n ;( p , q ) m [ M ] n 1 . . . n n s 1 s 2 . . . s p { ∗ w M n 1 . . . n n s 2 . . . s p q z } | { s 1 . . . s 1 ( p ≥ 1) Otherwise, with p = 0, mY n ;( p , q ) m [ M ] coincides to M , f or any q . The ty p e of mY n ;( p , q ) m is: (( n i = 1 $ W ) ( p + q j = 1 $ m W ) $ m W ) ( n i = 1 $ W ) ( p j = 1 $ m + 4 q W ) $ m + 4 q W ( p ≥ 1) (( n i = 1 $ W ) $ m W ) ( n i = 1 $ W ) $ m W ( p = 0) The definition of mY n ;( p , q ) m is: m Y n ;( p , q ) m [ M ] ≡ M ( p = 0 or q = 0 ) m Y n ;( 1 , q ) m [ M ] ≡ mY n ;( 1 , q ) m [ M ] ( p = 1) m Y n ;( p , q ) m [ M ] ≡ n ; p m + 4 q [ mY n ;( p , q ) m [ M ]] ( p > 1) Square comp osition. T he int uit iv e side first. Let G 1 , . . . , G n ′ be terms that we call normal f or we think of them 320 as functions with only normal arity n . Analogously , let H 1 , . . . , H s ′ be terms that we ca ll safe since we look at them as functions with normal arity n , and safe ar ity s j , f or every 1 ≤ j ≤ s ′ . Let s = max { s 1 , . . . , s s ′ , s ′ } ; notice that s is de te rmined compar ing the safe a rguments of eve r y saf e term and their total number s ′ . The behavior of ⊡ n ; s n ′ [ F , G 1 . . . G n ′ , H 1 . . . H s ′ ] comprises some phases, of which we have a n e xample of result, contained in the innermost dashed box, labeled ⊡ 1;3 1 , of Figure 5. Every normal argum ent of ⊡ n ; s n ′ is replicated 325 as many times as n ′ + s so that ever y copy can be dispatched to normal and safe terms. Then, the term F is used to generate F ′ with n ′ normal and s safe a rities. F ′ behaves like F once erased its s − s ′ arguments. For example, the bullet a side [ f ] ◦ , which plays the role of F in Figure 5, represents the extension of F ′ , with respect to F , that erases its thir d safe a rgument. The generation of H ′ j from H j , with 1 ≤ j ≤ s j , is analogous to the one of F ′ , from F : if necessary , every H ′ j erases s − s j safe arguments. If F ′ has 330 5 THE FULL SAFE COMPOSITION OF SRN IN W AL T 21 to erase s − s ′ safe arguments, we supply them as the r esult of s − s ′ fake f unctions that erase all of their arguments and give a word a s result. In Figure 5 there is a single fake function named 0 • •• , yielding 0. The normal and safe arguments of ⊡ n ; s n ′ are replicated by using two di ff erent processes. The one for normal arguments is the standa rd ea ger diagonal, building every copy from scra tc h. Instead, e v e ry replica of a safe argument is obtained by using the a bove combinator that rotates and shares multiple safe values. Once all 335 the req uired copies of safe a rguments are at hand, they are rearra nged , and a p propriately distributed to H ′ 1 , . . . , H ′ s . Now , the tech nical side . L e t us assume to have a set of closed terms F , G 1 , . . . , G n ′ , H 1 , . . . , H s ′ with the following types, respectively: ( n ′ i = 1 $ W ) ( s ′ j = 1 $ m W ) $ m W ( n i = 1 $ W ) $ m W ( i ∈ { 1 , . . . , n ′ } ) ( n i = 1 $ W ) ( s j k = 1 $ m W ) $ m W ( j ∈ { 1 , . . . , s ′ } ) Let s = max { s 1 , . . . , s s ′ , s ′ } . The ty p e of ⊡ n ; s n ′ is: (( n ′ i = 1 $ W ) ( s ′ j = 1 $ m W ) $ m W ) ( n ′ k = 1 (( n i = 1 $ W ) $ m W )) ( s ′ j = 1 (( n i = 1 $ W ) ( s j k = 1 $ m W ) $ m W )) ( n i = 1 $ W ) ( s 2 k = 1 $ 2 m + 1 W ) $ 2 m + 1 W The definition of ⊡ n ; s n ′ is: ⊡ n ; s n ′ [ F , G 1 , . . . , G n ′ , H 1 , . . . , H s ′ ] ≡ \ n 1 . . . n n . Ee 2 0; n + s [ G ]( El 1 1 [ ∇ 1 n ′ + s ] n 1 ) . . . ( El 1 1 [ ∇ 1 n ′ + s ] n n ) where: G ≡\h { x 11 . . . x n ′ 1 y 11 . . . y s 1 } i . . . \h { x 1 n . . . x n ′ n y 1 n . . . y sn } i . \ w 11 w 12 . . . w 1 s . \ w 21 w 22 . . . w 2 s . . . . . . . . \ w s 1 w s 2 . . . w ss . Ee m − 1 0; n ′ + s [ F ′ ] ( G 1 x 11 . . . x 1 n ) . . . ( G n ′ x n ′ 1 . . . x n ′ n ) ( Ee m − 1 0; n + s [ H ′ 1 ] ( E l 1 1 [ Coerc e m − 1 ] y 11 ) . . . ( El 1 1 [ Coerc e m − 1 ] y 1 n ) w 11 w 21 . . . w s 1 ) ( Ee m − 1 0; n + s [ H ′ 2 ] ( E l 1 1 [ Coerc e m − 1 ] y 11 ) . . . ( El 1 1 [ Coerc e m − 1 ] y 1 n ) w 12 w 22 . . . w s 2 ) . . . . . . ( Ee m − 1 0; n + s [ H ′ s ] ( E l 1 1 [ Coerc e m − 1 ] y s 1 ) . . . ( E l 1 1 [ Coerc e m − 1 ] y sn ) w 1 s w 2 s . . . w ss ) F ′ ≡\ x 1 . . . x n ′ y 1 . . . y s . F x 1 . . . x n ′ y 1 . . . y s ′ H ′ i ≡\ z i 1 . . . z i n w i 1 . . . w i s i w i s i + 1 . . . w i s . H i z i 1 . . . z i n w i 1 . . . w i s i ( i ∈ { 1 , . . . , s ′ } ) H ′ j ≡\ z j 1 . . . z j n w j 1 . . . w j s . 0 ( j ∈ { s ′ , . . . , s − s ′ } ) G takes both n copies of the n ′ + s normal arguments, generated by the n ins tances of El 1 1 [ ∇ 1 n ′ + s ], and s 2 safe arguments. Then, it dispa tches them to the terms G 1 , . . . , G n ′ and H ′ 1 , . . . , H ′ s . As we said, every H ′ i takes s 340 safe arguments and supplies only the first s i to H i . The behavior is: ⊡ n ; s m [ F , G 1 . . . G n ′ , H 1 . . . H s ′ ] n 1 . . . n n s z } | { s 1 . . . s 1 . . . . . . s z } | { s s . . . s s { + w F g 1 . . . g n ′ h 1 . . . h s ′ if G i n 1 . . . n n { ∗ w g i , with 1 ≤ i ≤ n ′ , and H j n 1 . . . n n s 1 . . . s s { ∗ w h j , with 1 ≤ j ≤ s ′ . 5 THE FULL SAFE COMPOSITION OF SRN IN W AL T 22 5.1 Multiple sharing and rotation of safe names in a square compositio n. Let n , p , i ≥ 0, m ≥ 1, and a closed ter m M with type ( n i = 1 $ W ) ( p 2 j = 1 $ m W ) $ m W be given. W e call g n ; p \ i m the closed term that ta kes M and n + i + p i wor ds as its arguments. The first n a rguments can be viewed as normal ones, while the last i + p i as safe ones. Then, g n ; p \ i m [ M ] replicates every of the i safe arguments s p − i + 1 . . . s p as many times as p . Finally the “blocks” s 1 . . . s 1 . . . . . . s p − i . . . s p − i s p − i + 1 . . . s p − i + 1 . . . . . . s p . . . s p , with p elements e ach, are used as the p 2 safe arguments of M . Namely , the behavior is: g n ; p \ i m [ M ] n 1 . . . n n i z }| { s p − i + 1 . . . s p p z } | { s 1 . . . s 1 . . . . . . p z }| { s i . . . s i { ∗ w M n 1 . . . n n p z } | { s 1 . . . s 1 . . . . . . p z }| { s p . . . s p The type of g n ; p \ i m [ M ] is: (( n i = 1 $ W ) ( p 2 j = 1 $ m W ) $ m W ) ( n j = 1 $ W ) ( i + P p − i k = 1 p j = 1 $ m + 4( p − 1) i W ) $ m + 4( p − 1) i W The definition of g n ; p \ i m [ M ] is: g n ; p \ i m [ M ] ≡ M ( p ≤ 1 or i = 0 ) g n ; p \ 1 m [ M ] ≡ mY n ;(1 + P p − 1 k = 1 p , p − 1) m [ M ] g n ; p \ i m [ M ] ≡ mY n ;( i − 1 + P p − ( i − 1) k = 1 p , p ) m + 4( p − 1)( i − 1) [ g n ; p \ i − 1 m [ M ]] ( p ≥ i > 0) 6 SRN -COMPLET E NESS OF W AL T 23 6 SRN -completeness of W AL T W e extend the completeness of W AL T from ClSRN [Rov07] to SRN . The key ingredients are square compo- 345 sition and the multiple sharing of safe names of S e ction 5. Functions of SRN into W AL T . W e start de fining a map [ ] ◦ from the signature Σ SRN to terms of W AL T . Its clauses a re identical to those mapping ClSRN to W AL T [ Rov07], but the one mapping the compositio n. of course. Here they are: 1. [ z 0;0 ] ◦ ≡ El 1 0 [ 0], while [ z k ; l ] ◦ ≡ \ n 1 . . . n k s 1 . . . s l . [ z 0;0 ] ◦ , for e very k , l such that k + l ≥ 1. 350 2. [ s 0;1 0 ] ◦ ≡ Eb 1 [ Ws0 ]. 3. [ s 0;1 1 ] ◦ ≡ Eb 1 [ Ws1 ]. 4. [ p 0;1 ] ◦ ≡ Eb 1 [ P ]. 5. [ π k ; l i ] ◦ ≡ \ x 1 . . . x k + l . x i , with 1 ≤ i ≤ k + l . 6. [ c 0 , 3 ] ◦ ≡ \ x yz . B x y z . 355 7. L e t ⊢ [ f ] ◦ : ( k ′ i = 1 $ W ) ( l ′ i = 1 $ m W ) $ m W , and ⊢ [ g i ] ◦ : ( k i = 1 $ W ) $ m i W , with i ∈ { 1 , . . . , k ′ } , and ⊢ [ h j ] ◦ : ( k i = 1 $ W ) ( l j i = 1 $ n j W ) $ n j W , with j ∈ { 1 , . . . , l ′ } . If p = max { m , m 1 , . . . , m k ′ , n 1 , . . . , n l ′ } , a nd l = ma x { l 1 , . . . , l l ′ , l ′ } , then: [ ◦ k ; l k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ]] ◦ ≡ g k ; l \ l 2 p + 1 [ ⊡ k ; l k ′ [ \ x 1 . . . x k ′ . Ee p − m k ′ ; l ′ [[ f ] ◦ ]( El 1 1 [ Coerce p − m − 1 ] x 1 ) . . . ( El 1 1 [ Coerce p − m − 1 ] x k ′ ) , \ x 1 . . . x k . Ee p − m 1 k ;0 [[ g 1 ] ◦ ]( El 1 1 [ Coerce p − m 1 − 1 ] x 1 ) . . . ( El 1 1 [ Coerce p − m 1 − 1 ] x k ) . . . , \ x 1 . . . x k . Ee p − m k ′ k ;0 [[ g k ′ ] ◦ ]( El 1 1 [ Coerce p − m k ′ − 1 ] x 1 ) . . . ( El 1 1 [ Coerce p − m k ′ − 1 ] x k ) , \ x 1 . . . x k . Ee p − n 1 k ; l 1 [[ h 1 ] ◦ ]( El 1 1 [ Coerce p − n 1 − 1 ] x 1 ) . . . ( El 1 1 [ Coerce p − n 1 − 1 ] x k ) . . . , \ x 1 . . . x k . Ee p − n l ′ k ; l l ′ [[ h l ′ ] ◦ ]( El 1 1 [ Coerce p − n l ′ − 1 ] x 1 ) . . . ( El 1 1 [ Coerce p − n l ′ − 1 ] x k )]] . 8. If ⊢ [ f i ] ◦ : $ W ( k i = 1 $ W ) ( l i = 1 $ m i W ) $ m i W $ m i W , with i ∈ { 0 , 1 } , and ⊢ [ g ] ◦ : ( k i = 1 $ W ) ( l i = 1 $ m W ) $ m W , then: [ r k + 1; l [ g , f 0 , f 1 ]] ◦ ≡ It 1 + k ; l [ F 0 , F 1 , G ] , where G ≡ Ee p − m k + 1; l + 1 [ \ n 0 n 1 . . . n k s 1 . . . s l r . [ g ] ◦ n 1 . . . n k s 1 . . . s l ], F i ≡ Ee p − m i k + 1; l + 1 [[ f i ] ◦ ], with p = max { m 0 , m 1 , m } , and i ∈ { 0 , 1 } . Interpreting SRN to W AL T . Let R be the set of environments, such that, ever y ρ ∈ R is a map from V to N . Then, ~ is a map from a pair in ( SRN ∪ Σ SRN ) × R , to W AL T , inductively defined on its first a rgument: ~ x ρ = ~ ρ ( x ) ρ ( x ∈ V ) ~ 0 ρ = [0] ◦ ~ f ρ = [ f ] ◦ ( f ∈ Σ SRN ) ~ f ( t 1 , . . . , t k , u 1 , . . . , u l ) ρ = Ee v − u + 1 − m 0; l [ Ee u − 1 0; k + l [ ~ f ρ ]( El u − p 1 0 [ ~ t 1 ρ ]) . . . ( El u − p k 0 [ ~ t k ρ ])] ( El v − q 1 0 [ ~ u 1 ρ ]) . . . ( El v − q l 0 [ ~ u l ρ ]) ( f ∈ Σ k , l SRN ) 6 SRN -COMPLET E NESS OF W AL T 24 when u = max { m , p 1 , . . . , p k } , v = max { u − 1 + m , q 1 . . . , q l } , and: ⊢ ~ f ρ : ( k i = 1 $ W ) ( l j = 1 $ m W ) $ m W ⊢ ~ t i ρ : $ p i W i ∈ { 1 , . . . , k } ⊢ ~ u j ρ : $ q j W j ∈ { 1 , . . . , l } . Otherwise, ~ is undefined. W eight of a te rm i n SRN . For proving the statement that formalizes ho w we can embed SRN into W AL T (Theorem 6.1 below) we need a no tion of weight of a closed term in SRN , which, essentially , gives a measure of its impredicativity . For every closed term t ∈ SRN ∪ Σ SRN , wg ( t ) is the weigh t of t , defined by induction on t . If t is one among z ero, predecessor , successor , projection, and br a nching, then wg ( t ) = 0. Otherwise: wg ( ◦ k ; l k ′ ; l ′ [ f , g 1 , . . . , g k ′ , h 1 , . . . , h l ′ ]) = 3 max { wg ( f ) , wg ( g 1 ) , . . . , wg ( g k ) , wg ( h 1 ) , . . . , wg ( h l ) , 1 3 } wg ( r k + 1; l [ g , h 0 , h 1 ]) = 2 max { wg ( g ) , wg ( h 0 ) , wg ( h 1 ) , 1 2 } wg ( f ( t 1 , . . . , t k , u 1 , . . . , u l )) = 2 max { wg ( f ) , wg ( t 1 ) , . . . , wg ( t k ) , wg ( u 1 ) , . . . , wg ( u l ) , 1 2 } Theorem 6.1 ( SRN is a subsystem of W AL T .) Let k , l ∈ N , f ∈ Σ k , l SRN , and t , t 1 , . . . , t k , u 1 , . . . , u l be terms o f SRN . 360 1. T h ere is an m ≥ 1 such th at ⊢ [ f ] ◦ : ( k i = 1 $ W ) ( l j = 1 $ m W ) $ m W . 2. ~ f ( t 1 , . . . , t k , u 1 , . . . , u l ) ρ is defined, for every ρ . 3. ⊢ ~ t : $ m W with m ≤ wg ( t ) . 4. ~ n { + w n, for every n ≥ 0 . 5. If f ( n 1 , . . . , n k , s 1 , . . . , s l ) = n, then ~ f ( n 1 , . . . , n k , s 1 , . . . , s l ) { ∗ w n, for every n 1 , . . . , n k , s 1 , . . . , s l , n ∈ N . 365 Point 1 is a direct consequence of the typing of the com binators of W AL T that we use in the d efinition of [ f ] ◦ . Point 2 follows from point 1 here above and from the definition of ~ . Point 3 holds by induction on t . Point 4 holds by induction on n . Point 5 holds by induction on f . Finally , by structural induction on t , we have: Corollary 6.2 (The embeddi ng of SRN into W AL T is sound.) Let t ∈ SRN , and n ∈ N . If t = n, t hen ~ t ρ { + w 370 n, for every environment ρ . 7 CONCLUS IONS AND FUTU RE WORK 25 7 Co nclusions and fut ure work W AL T is the first higher-order d eductive system, derived from L inear logic, such that: (i) is sound and complete w .r .t. FP , (ii) is complete w .r .t. SRN , ( iii) makes evident the la yered nature of the almost flat normal / safe hiera rchy about the arguments of the terms of SRN , and (iv) no constant symbol is requir ed to 375 obtain the p oint (iii), since e very da tatype can defined f rom scratch. In p a rticular , point (ii) allows to say that the less an a rgument of a ter m of SRN is “polynomially impredicative”, the dee per its representation is inside the stratified structure o f the derivations o f W AL T . This relation between the polynomial impredicativity and the stratification suggests that a relation betwee n W AL T and Higher type ramified recurrence ( HTRR ) [BNS 00, BS01], or Higher linear ramified recursion 380 ( HOLRR ) [DLMR04] should exist. W e think that the most intriguing is the one between HTRR and W AL T . The reason is that HTRR characterize s FP by a ca reful interplay of conditions about its types, b uilt on an almost linear arrow type and !-modal types, and its terms, der ived fro m G ¨ odel System T [G ¨ 58]. The notio ns of complete / incomplete types, linked to their m odality , the possibil ity of duplicating at will only ground types, and the a ffi nability , which expresses linearity constraints on the bound var iables of incomplete types, 385 strongly recall the pro perties we enforce on , on its argu ments and on the $ -modal assumptio ns of !-boxes in W AL T . A further investigation could go in the “ backward” d irection, namely from the structural p roof-theor etical world, represented by W AL T , to the recursive theor etical one, represented by SRN . Let us look at Figure 11. It fixes a hierarchy , based on syntactic restrictions. W e already know what SRN RlSRN + 9 9 r r r r r r ClSRN 3 S e e L L L L L L BC − 3 S e e K K K K K K + 9 9 s s s s s s Figure 11: A simple syntactic hiera rchy 390 SRN , ClSRN , a nd BC − are. Instead, RlSRN , ca lled Recursion-linear SRN , is “new”. It is de fined as the “complement” of ClSRN w .r .t. SRN by restricting t h e recursive sch em e of SRN to one tha t uses its safe variables linearly , while leaving the composition scheme untouched. SRN and ClSRN should be both polytime complete, as consequence of the moral e quivalence “full composition scheme of SRN ≃ recursion scheme + linear composition scheme of ClSRN ”, we have proved 395 in this work. Moreover , we know that BC − is contained into the class of deterministic logarithmic spac e [Nee 04]. W e can ask which is the space complexity of ClSRN , which shoul d not coincide to the one of SRN , because they develop di ff erent computation pro cesses of, very likely , FP . Of c ourse, the same questions may be asked and answered about RlSRN , so inducing a spa ce hierarchy , which originates from a syntactic analysis of SRN , 400 in its turn coming from the structural proof-theor etic roots of W AL T . REFERENCES 26 References [AR02] A. Asperti and L. R oversi. Intuitionistic light a ffi ne logic. ACM T ransactions o n Computat ional Logic , 3(1 ):137 –175, 200 2. [Asp98] A. Asperti. Light a ffi ne logic. In Proceedings of the 13th I EEE Symposium on Logic in Comp ut er 405 Science (LI CS) , pages 300 –308 , 1998. [BC92] S. Bellantoni and S. Cook. A new recursion-theoretic chara cterization of the polytime functions. Computational Comp lexity , 2:97– 110, 1992. [BNS00] S. Bellantoni, K.-H. Niggl, and H. Schwichtenberg. Higher type recursion, ramification and polynomial time. Annals of Pure and Ap plied Logic , 104:17 –30, 2 0 00. 410 [BS01] S. Bellantoni and H. Schwichtenberg. Feasible computation with higher types. Marktoberdorf Summer School Proceedings, 2001. [BW96] A. Beckmann and A. W eiermann. A term rewriting characterization of the polytime functions and related complexity cla sses. Archive for Mathematic a l Logic , 36(1) :11 – 30, Dece mber 1996. [Cob65] A. Cobham. The intrinsic computational di ffi culty of functions. In P roceedings of 1964 International 415 Congress for Logic, Methodology and Ph ilosophy of Sciences , pa ges 24 – 30, 1965. [Der82] D. Dershowitz. Orderings for term-rewriting systems. Theoretical Comp ut er Science , 17(3) :279– 301, 1982. [DLMR04] U. Dal Lago, S . Ma rtini, and L. Roversi. Higher-or der linear r a mified recurrence. In Proceedings of TYPES’04 , volume 3085 of Lecture Notes in Computer Science , pages 17 8 – 193. Springer V erlag, 420 December 2 004. [G ¨ 58] K. G ¨ odel. ¨ Uber e ine bisher noch nicht ben ¨ utzte erweiterung de s finiten standpunktes. Dialectica , 12:28 0–287 , 1958 . [Gir98] J.-Y . Girard. Light linear logic. Informa t ion and Computat ion , 143(2) : 175–2 04, 1998. [Hof97] M. Hofmann. A mixed modal / linear lambda calculus with applications to bellantoni-cook safe 425 recursion. In Proceedings of the 11t h Int ernational Wor kshop on Computer Science Logic , pa ge s 2 7 5– 294, 199 7. [Hof99a] M. Hofmann. Linear types and non-size-increasing polynomial time com putation. In Logic in Computer Science , pages 464 – 473, 1999. [Hof99b] M. Hofmann. T ype systems for p olynomial-time c omputation . Habilitationsschrift, Darmstadt Uni- 430 versity of T echnology , 1999 . [Hof00] M. Hofmann. Safe recursion with higher types and B C K- a lgebra. Annals of Pure and Applied Logic , 104 :113– 166, 2 000. [Hue80] G. Huet. Confluent reductions: Abstract properties and applications to term rewriting systems. Journal of the ACM , 2 7 (4):7 97–82 1, 1980. 435 [Jon99] N. D. Jones. Logspace and ptime characterized by programming languages. Theoretical Computer Science , 228 :151– 174, 1 9 99. [Laf04 ] L. Lafont. Soft linear logic and polynomial time. Theoretical Computer Science , 31 8:163 –180, 20 04. Special issue on Implicit C omputational Complexity . A SOME DET AILED PROOFS 27 [Lei93] D. Leivant. Str a tified functional programs and computational complexity . In Proceedings o f 20t h 440 ACM Sym posium on Principles o f Programming Languages , pages 3 25–33 3, 1 993. [Lei94] D. Leivant. A foundational delineation of poly-time. Informat ion and Computation , 110(2 ):391– 420, 1994. [Lei95] D. Leivant. Ramified recurrence and computation al complexity I: word recurrence and poly-time. In Feasible Mathematics II , pa ges 320– 3 43. Birkh ¨ auser , 1 995. 445 [Lei99] D. Leivant. Ramified recurrence and computational c omplexity III: Higher type recurrence and elementary complexity . Annals of Pure and Applied Logic , 9 6:209 –229, 1 999. [LM] D. Leivant and J. -Y . Marion. Predicative recurrence and computational complexity IV: Predicative functionals a nd poly-space. should b e published ! [LM94] D. Leivant and J.-Y . Marion. Ramified recurrence and computational complexity II: Substitution 450 and poly-space. In Proceedings of 8 th International W orkshop on Com p uter Science Logic (CSL) , pa ges 486–5 00, 1994. [MO04] A. S . Murawski and C.-H. L. Ong. On an in terpretation of safe recursion in ligh t a ffi ne logic. Theor . Comp ut. Sci. , 31 8(1-2 ) :197– 223, 2004. [Nee04] P . M. Neergaard. A functional language for logarithmic space. In Prog. Lang. and Systems: 455 2nd Asian Symp. ( APLAS 2 004) , volume 3302 of LN CS , pages 311–3 26. 2004, Springer-V erlag, November 20 04. [Rov07] L . Roversi. Wea k A ffi ne Light T yping: Intensional expressivity , Polytime soundness and com- pleteness. T echnical Report 103 / 07 , Dipartimento di Informatica, T orino, C.so Svizzera, n.185 — 10149 T orino — Italy , December 2007. 460 [T e r 01] K. T erui. Light a ffi ne lambda calculus and polytime strong normalization. In P roceedings of th e 16th Annual I EEE Conference on Log ic in Comp uter Science (LICS01 ) , pages 209 –220, 2001. [T e r 07] K. T erui. Light a ffi ne lambda calculus and polynomial time str ong no rmalization. Archive for Mathematical Log ic , 46(3 –4):25 3–280, 2007. A So me deta iled proofs 465 A.1 g n ; p \ i m [ M ] is well typed. For every p , this can be proved by cases on the va lue o f p , and by induction on i . When p ≤ 1 or i = 0, g n ; p \ i m [ M ] is M with, at most, a single safe argument. S o, the statement trivially holds. Let us assume p > 1 and p ≥ i ≥ 1. The base case has i = 1. W e start from the type ( n i = 1 $ W ) ( p 2 j = 1 $ m W ) $ m W of M , observing that: p 2 = p X k = 1 p = p + p − 1 X k = 1 p = p − 1 + 1 + p − 1 X k = 1 p = (1 + p − 1 X k = 1 p ) + ( p − 1 ) So, we ca n apply the cla use defining g n ; p \ 1 m [ M ], getting that its type is the one of m Y n ;(1 + P p − 1 k = 1 p , p − 1) m [ M ] , namely ( n j = 1 $ W ) ( 1 + P p − 1 k = 1 p j = 1 $ m + 4( p − 1) W ) $ m + 4( p − 1) W . 470 A SOME DET AILED PROOFS 28 By induction, the type of g n ; p \ i − 1 m [ M ] is ( n j = 1 $ W ) ( ( i − 1) + P p − ( i − 1) k = 1 p j = 1 $ m + 4( p − 1)( i − 1) W ) $ m + 4( p − 1)( i − 1) W . Observing that the following of equivalences hold: ( i − 1) + p − ( i − 1) X k = 1 p = ( i − 1 ) + p − i + 1 X k = 1 p = ( i − 1 ) + p + p − i X k = 1 p = i − 1 + p − 1 + 1 + p − i X k = 1 p = ( i + p − i X k = 1 p ) + ( p − 1 ) we can transform the type of g n ; p \ i − 1 m [ M ] so that we can use it as argument of mY n ;( i + P p − i k = 1 , p − 1) m + 4( p − 1)( i − 1) . By definition, we get a term with the type we need. A.2 g n ; p \ i m [ M ] well behaves. Let p = 0 . Then, g n ; 0 \ i m [ M ] n 1 . . . n n i z } | { s 0 − i + 1 . . . s 0 0 z } | { s 1 . . . s 1 . . . . . . 0 z }| { s i . . . s i ≡ M n 1 . . . n n (5) where the sequences of safe a rguments cannot exist since we a ssume that the indices of the safe arguments start from 1. So, (5) rewrites to M n 1 . . . n n in 0 steps. 475 Let p ≥ 1 and i = 0. Then, g n ; p \ 0 m [ M ] n 1 . . . n n 0 z }| { s p − 0 + 1 . . . s p p z } | { s 1 . . . s 1 . . . . . . p z }| { s p − 0 . . . s p − 0 ≡ M n 1 . . . n n p z } | { s 1 . . . s 1 . . . . . . p z }| { s p . . . s p (6) where the inital sequences of safe a rguments are those req uired directly by M . T his is why g n ; p \ 0 m [ M ] coincides to M a nd the statement holds relatively (6). Let p ≥ 1 and i > 0. By induction, we have: g n ; p \ i − 1 m [ M ] n 1 . . . n n i − 1 z }| { s p − ( i − 1) + 1 . . . s p p z } | { s 1 . . . s 1 . . . . . . p z }| { s i − 1 . . . s i − 1 { ∗ w M n 1 . . . n n p z } | { s 1 . . . s 1 . . . . . . p z }| { s p . . . s p W e a lso know that, for ever y term N with the right type , depe nding on m ′ : m Y n ;( i − 1 + P p − ( i − 1) k = 1 p , p ) m ′ [ N ] n 1 . . . n n i − 1 z }| { s p − ( i − 1) s p − ( i − 1) + 1 . . . s p p z } | { s 1 . . . s 1 . . . . . . p z }| { s p − ( i − 1) − 1 . . . s p − ( i − 1) − 1 { ∗ w N n 1 . . . n n i − 1 z }| { s p − ( i − 1) + 1 . . . s p p z } | { s 1 . . . s 1 . . . . . . p z }| { s p − ( i − 1) − 1 . . . s p − ( i − 1) − 1 p z } | { s p − ( i − 1) . . . s p − ( i − 1) (7) So, in (7), N can be g n ; p \ i − 1 m [ M ] with m ′ = m + 4( p − 1)( i − 1). But, by definition, m Y n ;( i − 1 + P p − ( i − 1) k = 1 p , p ) m + 4( p − 1)( i − 1) [ g n ; p \ i − 1 m [ M ]] is mY n ;( i + P p − i k = 1 p , p ) m [ M ], hence with the behaviour we want.
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment