This action might not be possible to undo. Are you sure you want to continue?
Thesis: TD3/96
Theoretical and Practical Issues of Optimal Implementations of Functional Languages
Stefano Guerrini
Abstract. The thesis is about sharing graphs, the data structure that was foreseen by L´vy when he deﬁned the family of λcalculus redexes, and that is treated here abe stracting from the calculus to be implemented. The sℓstructures we deﬁne (our sharing graphs, in which s stands for sharing and ℓ for leveled) are deﬁned as hypergraphs whose links correspond to the connectives/operators of the calculus to be implemented. A general notion of box induces a notion of nesting on the structures. Exploiting such a nesting we can avoid the use of an explicit box constructor assigning a level to each vertex of a structure. The sharing is implemented by a unique control node called multiplexer replacing the fan, bracket, and croissant nodes employed in the traditional sharing graphs. The representation obtained in this way is more uniform and ensures a clear distinction between logical and control nodes. Also the dynamics of multiplexers correspond to their naive interpretation as duplicators. The rules obtained in this way, the π interactions, allow to solve a well known problem of the sharing implementations, the socalled coherence problem: that (in the previous implementations) the sharing reduct of a term was not in general the translation of a reduct of the term. The study of the π interactions is developed in a general framework in which, with the help of an algebraic interpretation of structures derived from the geometry of interaction, we are able to give the conditions under which π interactions strongly normalize an sℓstructure to its readback. The results are then applied to two relevant cases: λcalculus and multiplicativeexponential linear logic, for the cases without erasers/weakening. To conclude we show that the restriction of the π interactions to a subsystem which is an interaction net is optimal.
March 1996
ADDR: Corso Italia 40, 56125 Pisa, Italy. TEL: +3950887.111  FAX: +3950887.226 E MAIL: guerrini@di.unipi.it
Supervisor: Reviewers:
Simone Martini Furio Honsell JeanJacques L´vy e Ugo Montanari Laurent Regnier
Acknowledgments
My ﬁrst thank is to Corrado B¨hm. At the second year of my degree in o electronic engineering I met in his course theoretical computer science and lambda calculus. It is because of this lambda calculus imprinting that I wanted to try to become a computer scientist, writing my graduation thesis under his direction. After the degree, when I moved to Pisa, he gave me two suggestions: ﬁrstly, to use my phantasy to formulate a problem which I thought it would be interesting to solve, in a word, to ﬁnd “my research problem”; secondly, even for a restricted or quite detailed problem, to abstract from useless details solving it once and more generally. His work is a good example of what he intended. This dissertation is just an attempt to answer to his suggestions. I thank Simone Martini, who supervised this thesis, especially because he accepted to follow me in a ﬁeld that was not in the mainstream of its research interests. He shared with me the enthusiasm to work on a new subject and carefully guided me through this common trip. Nevertheless, he was more then an advisor. I am particular grateful to him because of his encouragement and support when things seemed to get darker and darker: without them and his patience this thesis have had not been possible. A special thank to Andrea Asperti, who practically was a second advisor of the thesis. He introduced me to the subject of the optimal reductions transmitting me his enthusiasm. His support in my ﬁrst steps into this gripping subject has been invaluable; later, he has always been an invaluable source of insights. I owe a lot to Andrea Masini. I was lucky that, simultaneously to the birth of my interest on optimality, Andrea and Simone were studying leveled calculi for natural deduction. To understand some relations between the two problems was a turning point of the thesis. Most of the ideas presented in the dissertation would have had a diﬀerent formulation (if any) without Andrea’s help and suggestions. I thank Laurent Regnier and JeanJacques L´vy who refereed the thesis, ese pecially since they had to read an awful draft of it, and Furio Honsell and Ugo
Montanari who were members of my thesis committee. Their suggestions and criticisms had been of great help. I wish to thank Giorgio Levi and Andrea MaggioloSchettini. Even if they have no direct connection with the work of the thesis, when I arrived in Pisa they encouraged me to keep working on lambda calculus and logics, and addressed me to Simone. Last but not least, I have to admit that the writing of this thesis has been an hard task to me, because of the lack of time which forced me to write it in a rush. This was due in part to my inexperience in writing (likely, you have to write a Ph.D. dissertation only once in your lifetime!) and in part due to my bad acquaintance with the English language. In spite of this, to share such a hard task with some of my colleagues has been a unique opportunity of friendship.
Contents
Chapter 1. Introduction 1. Overview 2. Graph implementations and sharing 3. Sharing leveled structures 4. An example of sharing reduction 5. Levels 6. Summary Chapter 2. Sharing structures 1. Structures of links 2. Boxes 3. Sharing 4. Sharing morphisms 5. Paths and trees Chapter 3. The π interactions 1. Interactions of muxes 2. Deadlockfree structures 3. Muxes permutation equivalence 4. Simulation lemma Chapter 4. Algebraic semantics 1. Lifting sequences 2. Block diagrams 3. Solutions of an unshared leveled structure Chapter 5. Readback 1. Syntactical readback 2. Semantical readback Chapter 6. Lambda calculus
i
1 1 4 7 8 13 16 19 21 26 31 37 41 43 44 48 50 52 55 55 68 70 77 77 79 93
ii
CONTENTS
1. 2. 3. 4.
Lambda structures Reductions Proper paths Soundness and completeness of sharing reductions
94 109 122 127 135 135 137 148 153 162 165 165 167 169 174 176 177 183 183 184 186 189
Chapter 7. MELL 1. The sequent presentation of MELL 2. IMELL proof nets 3. IMELLℓ 4. IMELLℓ proof nets 5. Sharing proof nets Chapter 8. Optimal reductions 1. Labeled structures 2. Labeled calculi 3. Labeled reductions 4. Labeled readback 5. Labeled reductions of λsℓstructures 6. Optimal reductions Appendix A. Weakening and erasers 1. Weakening 2. Erasers 3. Conclusions Bibliography
CHAPTER 1
Introduction
The subject of this dissertation is the study of the socalled sharing implementations of graph rewriting systems. The study of sharing implementations started in connection with the research of algorithms implementing λcalculus optimal reductions. The ﬁrst who gave a solution to the problem was Lamping [Lam89, Lam90] more than ten years later that L´vy had settled optimal reductions from a theoretical point of view e [L´v78, L´v80]. e e In particular, along this dissertation we will analyze an implementation technique based on sharing graphs derived from the one suggested by Lamping and from its successive variants proposed by Gonthier, Abadi, and L´vy [GAL92b, e GAL92a], and by Asperti and Laneve [AL93c, Asp95b], giving a rewriting system whose steps: 1. correspond to a local and distributed implementation of some global rewritings of the system to be implemented; 2. can be executed in any order (i.e., the rewriting system is conﬂuent); 3. are a superset of the rewriting rules suggested by the theory of optimality. Regarding to the last item, we stress that the additional rules which our work suggests cause in general the loss of optimality. Nevertheless, such rules are semantically correct and useful to obtain a proof of the soundness of the rewriting system internal to itself, solving what in literature is known as the coherence problem. Namely, the use of such nonoptimal rules implies that the term, or more generally the net, represented by a sharing graph becomes an observable of the rewriting system, that is, a normalform for a set of rules whose task is to explicit the sharing present in the graph, propagating the control operators by which it is implemented. 1. Overview The emphasis of the previous studies using sharing graphs (Gonthier et al; Asperti and Laneve) is on the implementation of the optimal reductions deﬁned
1
2
1. INTRODUCTION
by L´vy grouping redexes in families (two redexes obtained along a reduction e are in the same family if residual under βreduction of a same subterm). The corresponding theory relies on the one hand on the deﬁnition of sharing graphs as interactions systems (in the sense of Lafont [Laf90]) designed so that redexes belonging to a same family are shared by a single pair of interacting logical nodes (to distinguish the nodes inserted to implement sharing, from the ones relative to the underlying calculus we call control nodes/operators the ﬁrst ones, and logical nodes the second ones). On the other hand the correctness of the sharing reductions is proved using an invariant which is nothing but the socalled Geometry of Interaction (GOI) of Girard [Gir89, Gir88]. The study developed in the dissertation instead take as central the syntactical correctness of the implementation solving a defect of the sharing implementations known as the coherence problem. Taking for instance the implementation of the λcalculus: it is not true in general that a sharing graph obtained as result of a sharing reduction is the direct translation of a βreduct of the starting term. To get the correspondence, one has to rely on a readback procedure which in some sense performs some equivalence relation on sharing graphs which represent the same term. For this reason Asperti introduced the concept of safe operators in sharing reductions which allows, when some safety conditions are satisﬁed, to perform some non interaction net contractions along the sharing reduction. In the dissertation we propose instead a more homogeneous treatment of sharing graphs giving a new deﬁnition of them that we call sℓstructures (the s stands for sharing and the ℓ for leveled ) in which the logical part is more clearly distinguished from the implementation part. Let us be more precise. In usual sharing graphs there are two kinds of control nodes: the fan nodes for the treatment of sharing; the bracket and croissant nodes to ﬁx the boundaries of the sharing parts. The analysis of the rewriting rules for such nodes leads to recognize that the logical nodes (i.e., the ones coming from the syntax of the calculus to be implemented) have a behavior similar to the one of fans. Therefore, traditionally had been preferred to not distinguish among logical and fan nodes. In the sℓstructures instead, we start from the logical representation of the calculus to be implemented, the socalled ℓstructures formed by nodes labeled by its syntax operators. Hence, we implement sharing adding a unique control node called multiplexer (mux), which from a dynamical point of view is a sort of duplicator.
1. OVERVIEW
3
Actually, the multiplexer node is nothing new w.r.t. the already known control operators. In fact, it is just a way to group suitable sequences of fans, brackets, and croissants. Nevertheless, to join the diﬀerent kinds of control nodes into a unique one is not only a matter of taste: to maintain together coherent informations with the same origin certainly improves the study of the properties of the system. Of greater relevance is also the fact that in the solution presented in the dissertation the logic of the calculus is keep separate from the implementation of the sharing. In this way the safe rules of Asperti ﬁnd a more clear justiﬁcation in the socalled absorption rule, by which a mux disappears once reached the border of its scope (even if, for the sake of precision, we have to say that in this way we loose some cases of applicability of the safe rules). Another relevant point to note is that in the dissertation we assume that the structure of indexes that the sharing implementations traditionally add to nodes, and that we transform into levels assigned to their conclusions, is part of the logic. For instance, let us take linear logic (for which we will present in Chapter 7 the implementation of the multiplicativeexponential fragment). In this case the nodes (called links) are the connectives of the logic and their conclusions (called arrows) are instances of formulae. Consequently, the levels of the arrows of the sℓstructures built in this way correspond to the levels of the logical systems studied by Martini and Masini [Mas92, Mas93a, Mas93b, MM95a]. Before to continue with a more detailed introduction of the previous points we remark that one of the other problems connected with the sharing implementations is their real complexity. For instance, in the λcalculus case the algorithms proposed reach an optimal behavior w.r.t. the number of βreductions (i.e., counting the number of rewritings of nodes which are image of βredexes). Anyhow, nothing is said on the overhead due to the bookkeeping that the control nodes must execute after a shared βcontraction. More precisely, a shared βrule never directly creates new βredexes in the sharing graph. Nevertheless, it would be possible that an instance of an application node could form a βredex with an instance of a lambda node, but at the same time another instance of the same application could be connected with another application node or with a variable. In such a situation the pair of nodes forming the βredex is connected by a sequence of control nodes (in particular at least a fan, or mux, denoting the sharing of the same application between two distinct nodes). To explicit the βredex the sequence of control nodes has to be removed unwinding the sharing they represent, at least for the minimal amount leading the two nodes forming the redex
4
1. INTRODUCTION
to be connected by an edge. A negative result of Asperti [Asp96] shows that in certain cases such an overhead is exponential in the number of βreductions executed, even in the optimal case. The dissertation will not deal with such a problem which we postpone to possible developments of the thesis work, one of which could be to individuate higherorder systems distinct from the λcalculus— possibly restricted to signiﬁcant subsets of computable functions—presenting a polynomial bound to the overhead introduced by the control operators. 2. Graph implementations and sharing One of the ﬁrst sharing graph implementation of functional programming languages was presented by Wadsworth [Wad71] in his thesis. In the Wadsworth’s machine λterms were represented by DAG (Direct and Acyclic Graphs) derived from the abstract syntax trees of the λterms assuming that multiple occurrences of a subterm M could be shared in a unique representation: replacing each occurrence of M by a pointer to the subgraph representing M. In this way any simpliﬁcation of M has eﬀect on all its occurrences (we could equivalently say that such a simpliﬁcation is executed in parallel on all the instances of M). For instance, given T = λf.f(MP)(MQ) with M = λx.(λy.R)S
contracting the redex internal to M, we get in one step T ′ = λf.f(M ′P)(M ′Q) with M ′ = λx.R[S/y]
The previous technique cannot anyhow be directly applied when the shared subterm M is in the functional part of the redex. In fact, referring to the previous example and assuming we want to contract the redex MP, the straight execution of the substitution [P/x] in M would lead to λf.fM ′′ (M ′′ Q) with M ′′ = (λy.R[P/x])(S[P/x])
which is clearly wrong. To ensure the correctness of the evaluation, the Wadsworth’ machine had to split the βreduction in two steps. That is, ﬁrstly it created a new instance of M, let us call it M1; secondly, it performed the substitution [P/x] in M1 (note that this correspond to the technique still used in the traditional implementation of lazy functional languages, see [PJ86]). In this way, however, the sharing between the redexes in M and the corresponding ones in M1 would be deﬁnitely lost.
2. GRAPH IMPLEMENTATIONS AND SHARING
5
At ﬁrst glance it might seem that we could solve the problem executing all the redexes in M before the creation of M1. That is, we could think that following an innermost reduction (i.e., a sort of callbyvalue) we should avoid to duplicate work: a βcontraction would not duplicate any redex in this way. Anyhow, even such a strategy should reduce the socalled needed redexes of M (i.e., provided that the term has a normal form, the redexes a retract of which is contracted in any normalizing reduction), but this is not eﬀective in λcalculus. Furthermore, an innermost strategy is not normalizing in general and even when restricted to needed redexes is not guaranteed to reach the normal form in a minimal number of steps. In fact, the contraction of a redex of M could create new redexes which, again to avoid duplications, should be contracted at their turn, and so on; which in the worst case would lead to an inﬁnite reduction of M, in spite of the fact that MP could have a normalform. Regarding the strategies operating on needed redexes only, the problem is instead related to the higherorder nature of the systems we are going to study, that is, to the presence of function arguments which are at their turn functions (for the recursive schemata of programs in which such cases are not allowed, it is instead possible to ﬁnd a solution based on the choice of a particular order of evaluation [Vui74]). For instance, let us continue the previously given example taking R = fyx, from which M ′ = λx.fSx, and let us assume to apply T ′ to the identity I. In the result of the following reduction T ′I
β (λf.f(fSP)(M ′
Q))I
β (λf.f(fSP)(M
′
Q))I
β β I(ISP)(ISQ)
(λf.f(fSP)(fSQ))I
the two redexes which are underlined are created by the duplication of the same subterm (fS of M ′ ), even though they are not shared (their sharing is lost at the ﬁrst step) and have to be separately contracted. Therefore, to avoid useless work, not only we should not duplicate the redexes of M, but also “potential” redexes of M, that is, subterms that could become redexes after the instantiation of a free variable. As a further example, let us take the λterm M = (λx.xI)(λy.δ(yz)), where I = λx.x and δ = λx.xx (see [L´v78]). Its normalform is zz. In Figure 1 there e are some reduction strategies of M. In particular, the innermost strategy (on the right in the ﬁgure) is not the shortest one. The cause is that its reduction duplicates the expression yz, which after the substitution of y with I becomes a
6
1. INTRODUCTION
redex. Anyhow, a smart sharing reduction system should be able to share the redex Iz, as on the other side is done by the reduction on the left in Figure 1. M (λy.δ(yz))I δ(Iz) δz z(Iz) zz Figure 1. Reductions of M = (λx.xI)(λy.δ(yz)). The problem just discussed is even better shown by the following example [L´v78, p.15] e P = (λx1.x1I x1 . . . x1)(λy.(λx2. x2 . . . x2)(ya))
n1 n2
(λx.xI)(λy.(yz)(yz)) (λy.(yz)(yz))I (Iz)(Iz) (Iz)z
in which a is a constant. The term P contains two redexes and, independently from the order of their contraction, it is impossible to not duplicate work. In fact, contracting as ﬁrst the outer one (outermost strategy) we create n1 copies of the inner redex; otherwise, contracting as ﬁrst the inner redex (innermost strategy), we create n2 copies of ya, which continuing the reduction leads to the creation of n2 redexes (after the replacement of y with I). Hence, reducing P there is not a better strategy independently from the values of n1 and n2. The last result is however even more general, since there are no optimal onestep λterm reduction strategies (see [Bar84]). Nevertheless, the previous examples show that the loss of optimality is caused by the impossibility to avoid the duplication of redexes which conceptually might be kept shared. Therefore, they do not forbid the existence of an optimal (multistep) reduction strategy contracting at each step a set of redexes with the same origin (which are retracts of the same subterm). By the way to have an eﬀective implementation of the latter multistep reduction it is mandatory that the corresponding machine maintain shared the redexes
3. SHARING LEVELED STRUCTURES
7
which has to be contracted in parallel. Anyhow, to recognize which are the parts that have to be shared, or even more to understand what to duplicate work means, is not a trivial question. A theoretical solution to the problem was given by L´vy e [L´v78, L´v80] at the end of the seventies and formalized in his theory of optimal e e reductions. Even if he was not able to give an implementation, concluding that: . . . in order to get an optimal λevaluator, one must share, not only subexpressions, but pairs of subexpressions and substitutions for free variables; i.e. closure in the programming languages terminology. (L´vy [L´v80]) e e The ﬁrst who gave an algorithm implementing the optimal reductions was Lamping [Lam89, Lam90] more that ten years after L´vy’s work. The sharing e implementations we are going to study in the dissertation are a development of the Lamping’s one and, disregarding the previous L´vy’s suggestion they rely on e the possibility to partially share a term, more than on the use of closures. 3. Sharing leveled structures The sℓstructures (the s stands for sharing and the ℓ for leveled ) we use in the dissertation are a reformulation in terms of hypergraphs of the usual sharing graphs. They are directed hypergraphs in which: • Each hyperarc, called a link, is labeled by a constructor (connective) of the calculus to be implemented. Each vertex on which a link is incident, called a door of the link, is associated to a named port of the link. The number and the names of the ports depend on the type of the link (its label). The ports of a link split in two sets, the premises and the conclusions of the link respectively, composed of the doors for which the link is outgoing and of the doors for which the link is incoming. • Each vertex is a premise (conclusion) of no more than one link and for this reason vertices are also called arrows: in practice, they are direct connections from an output port to an input port of two distinct links. The dual of as sℓstructure is a graph whose nodes are the links and whose arcs are the vertices of the sℓstructure (this is another reason because of which the vertices are also called arrows). In particular, for the λcalculus case the graph dual of a λsℓstructure is the syntax tree of the corresponding λterm, in which, to avoid the use of names, each occurrence of a variable x is connected to the node of its corresponding binder λx.
8
1. INTRODUCTION
From the point of view of their dynamics, the sℓstructures are interaction nets in which we relax that two nodes may interact only through their principal ports. Nevertheless, for the λcalculus, we will show in Chapter 8 that a suitable subset of the general rewriting system—the one obtained reintroducing the interaction net restriction—is an implementation of the optimal reductions. The detailed deﬁnition of the sℓstructures will be given in Chapter 2. 4. An example of sharing reduction We present now a simpliﬁed example of sharing reduction of a λterm. We will use it to introduce some of the main ideas used in the sharing implementations1 . In particular, we will introduce the Lamping’s sharing operator, or fan, that to be consistent with the terminology of the dissertation we will instead call multiplexer, or mux. We prefer the latter name because it put in evidence that such a link merges in its output the information ﬂows that it receives as input, preserving the possibility to recover the input splitting back its output into the original ﬂows. To simplify drawings, in the example we will use names instead of back links (see the deﬁnition of λsℓstructure in Chapter 6) to denote the matching between variable occurrences and their corresponding binders.
@
x y
@
x x z
@ @
y z w w
@
z
Figure 2. δ(λy.(δ(yI)) Let us take the λterm δ(λy.(δ(yI)), where δ = λx.xx and I = λx.x. Its corresponding graph is drawn in Figure 2. The λterm normalizes to I and its shortest reduction sequence is (at each step the redex contracted is the one underlined):
1
This example is due to Andrea Asperti.
4. AN EXAMPLE OF SHARING REDUCTION
9
(1) (2) (3) (4) (5) (6) (7) (8)
δ(λy.(δ(yI)))
β (λy.(δ(yI)))(λy.(δ(yI))) β δ((λy.(δ(yI)))I) β δ(δ(II)) β δ(δI) β δ(II) β δI β II βI
By the way the main rewriting rule of the system is the one implementing the shared βcontraction, or βsrule. The graph rewriting corresponding to such a rule has been drawn in Figure 3, in which the dotted line from the variables to the binder explicit the binding link between them. The ﬁgure shows that the βsrule does not perform any duplication (of the subtree of the redex argument part), it inserts instead a sharing control node connecting each occurrence of the redex variable to the root of the argument part.
@
xx x
s
Figure 3. The βsrule. The ﬁrst two steps of the sharing reduction of δ(λy.(δ(yI)) are given in Figure 4, in which the bold arrows correspond to the redexes which are contracted. The ﬁrst reduction correspond to the step (1) of the shortest reduction of δ(λy.(δ(yI))). The graph in Figure 4(2) obtained after the reduction is a shared representation of (λy.(δ(yI)))(λy.(δ(yI))). In it, the pair of redexes δ(hI) have a unique representation. Hence, the successive step corresponds to the parallel contraction of both. The graph in Figure 4(3) is then a sharing representation of (λy.(yI)(yI))(λy.(yI)(yI)).
10
1. INTRODUCTION
@
x y
@ @
s
@
s
@
x x z
y
y
@
y z w w z z
@ @
y z
2
@
w w y
3
@
z
@
@
w w
( )
1
( )
( )
Figure 4. δ(λy.(δ(yI)))
∗ β (λy.(yI)(yI))(λy.(yI)(yI))
The graph in Figure 4(3) does not contain any βsredex, even if the left port of the upper @ node is connected to the up port of a λ node through a mux. In order to continue reducing we need to explicit the redex hidden by the presence of the mux, unwinding the sharing denoted by the mux. The corresponding reduction leads to the graph in Figure 5(4), in which we see that the splitting of λy in two nodes λy ′ and λy ′′ causes at the same time the splitting of the corresponding occurrence of y in two nodes y ′ and y ′′ . Let us note that the mux above y ′ and y ′′ plays the role of a demultiplexer, that is, of a node from which we exit a shared part continuing the construction of the term according to the instance under analysis. To this purpose a crucial role is the one of the mux port names. In fact, as shown by the picture, the variable y ′ accessed crossing the ∗ port of the lower (de)mux is associated to the shared instance accessed through the ∗ port of the upper mux (the port connected to λy ′ ), and analogously for the ◦ port. This implies that there is a notion of matching between positive muxes (downward oriented in this example) and negative ones (upward oriented, to which we also referred as demuxes)2 . Such a correspondence is not a sort of bracketing. For instance, the mux matching with the demux in Figure 5(4) is not the ﬁrst mux
2
For the sake of precision, using the convention we will use in Chapter 6 representing λ
terms, the muxes that here are positive would become negative, and vice versa.
4. AN EXAMPLE OF SHARING REDUCTION
11
met moving upwards. Finally, let us note that in the Wadsworth’s machine the rewriting corresponding to the duplication of λy would have caused the duplication of the whole subterm accessed by λy.
@
y y
0
@
y
00
y
s
00
@ @
y w w
( )
@ @
w y
0
@ @
w y
00
y
00
w
4
w
5
3
( )
( )
Figure 5. (λy.(yI)(yI))(λy.(yI)(yI)) ((λy ′′ .(y ′′ I)(y ′′ I))I)((λy ′′ .(y ′′ I)(y ′′ I))I) After the propagation of the mux through the node λy, the redex previously hidden by the mux can be ﬁnally contracted obtaining the graph of Figure 5(5), which is a representation of ((λy.(yI)(yI))I)((λy.(yI)(yI))I) (note the αconversion). Also the graph of Figure 5(5) contains a redex hidden by a mux. In this case however, the mux is negative and connected to the left port of an @ node. To proceed the computation the mux propagates through the @ node duplicating it. The resulting graph is drawn in Figure 6(6). From it, applying a propagation rule which duplicates the node λw, we get the graph of Figure 6(7). The graph of Figure 6(7) shows in details the consequences of the mux matching problem. In fact, it contains two pairs of complementary muxes which face— circled if the ﬁgure by the dashed lines a and b. The pair a is formed by two muxes that do not match. The pair b is instead formed by a pair of matching muxes. The case b is immediate to treat, since entering from the ∗ (◦) port of the upper mux we have to exit from the corresponding ∗ (◦) port of the lower mux—it
12
1. INTRODUCTION
y
y
y
@ @
w y w
@
@
a
@
y
@
w w
@
y
@
w
0
w
00
b
w
(5) (6) (7)
0
w
00
Figure 6. Facing muxes. is as the ports with the same name was directly connected. In the case a instead, there is no relation between the ways in which the two muxes are accessed. Summarizing, we have two possible rewritings (see Figure 7): • The annihilation rule which causes the disappearance of the facing muxes and the direct connection of the ports with matching names—to be applied in the case of matching muxes (case b). • The swap rule which is the analogous of the already seen propagation rules for the λ and @ nodes—to be applied in the case of nonmatching muxes (case a). We remarked that the swap rule is the natural extension of the already seen propagation rules for logical nodes (redrawn in Figure 8) to the case in which the interacting logical node is replaced by a mux. In fact, we see that thinking at the λ and @ nodes as muxes upward oriented in the case of a λ node and leftward oriented in the case of an @ node, the three propagation rules (λ, @, and swap) coincide. Actually, the case of the λ node is not so direct, since it would require
5. LEVELS
13
an
sw
annihilation
swap
Figure 7. Mux rules. that the occurrences of the variable bound by the λ node was collected by muxes into a unique port connected to the λ. Nevertheless, with such an assumption also the βsrule would become a case of muxes interaction, that is, a case of annihilation.
x x x
0
x
00
x
0
x
00
@
@ @
Figure 8. Mux propagations. The graphs resulting from the annihilation of b and the swap of a are drawn if Figure 9(89). After, the reduction continue till the reaching of the normalform I as depicted in Figure 1011. To conclude this part we remark that, even if it is not shown by the example, the sharing mechanisms that muxes implement (i.e., the sharing of the families of redexes) is so powerful that a redex can be shared even with a redex internal to its function or argument parts. 5. Levels Developing the previous example we have seen that when two muxes face we have to distinguish if they come from the same βreduction—matching muxes and then annihilation—or from distinct βrules—nonmatching muxes and then swap. In the case of the example we implicitly assumed to have a sort of oracle telling us which of the two cases has to be applied. For the real implementations we will instead need a concrete machinery answering to such a question.
14
1. INTRODUCTION
y
an
y
sw
y
@
@
@
@
y
@
w
0
@
w
00
@
w w
0 0
@
w w
00
@
w w
0 0
y
y
w w
00
00
00
w
(7)
0
w
00
(8)
(9)
Figure 9. Annihilation and swap. At ﬁrst glance it might seem suﬃcient to associate a name to each mux at the moment of its creation after a βrule, and to maintain such a name for all the retracts of the muxe that arise along the reduction. This solution would be adequate for the example of this chapter but not in the general case, since Lamping showed that in some cases even muxes with the same origin should be considered nonmatching (see [Lam89]). Because of this Lamping assigned an index to each mux, and let this index change during the reduction according to the way in which the mux propagates. The solution we are going to present in the next chapters follows the mainstream of Lamping and of the following improvements of Gonthier et al, and of Asperti and Laneve, even if our idea is developed in accord with the interpretation of levels studied by Martini e Masini [Mas92, Mas93a, Mas93b, MM95a]. To conclude, we anticipate that such a way to use levels corresponds to solve the problem of to assign “boxes” to a given net (e.g., think at the usual boxes of linear logic) without having any box framing constructor, but associating to each node its box nesting depth. The introduction
5. LEVELS
15
y
@
@
4
@
@
w 00
@
y
9
@
w0 w0
( )
@
w 00 w 00 w0 w0
(
w 00 w 00 w 00
(
10)
14)
Figure 10. ((λy.(yI)(yI))I)((λy.(yI)(yI))I)
(II)(II)
@ @
2
@ @
w0 w 00 w 00
16)
@
w 00 w 00
2
@
w0 w0 w w
w w
w w
(
w0
14)
(
(
17)
(
19)
(
20)
Figure 11. (II)(II)
I
and interpretation of levels in relation with boxes will be the topic of section 2 of Chapter 2.
16
1. INTRODUCTION
6. Summary Chapter 2. The chapter starts with the deﬁnition of the main structures that will be used in the dissertation. Follows a discussion of the key notions of box and sharing. Contents: Formalization of the structures of links as hypergraphs and description of the relevant links used for the multiplicativeexponential linear logic (MELL) and λcalculus structures. Introduction of a general notion of box (intuitively, boxes are arguments in λcalculus or Girard’s boxes in MELL) and box nesting condition. Levels induced on a structure by the box nesting condition. Deﬁnition of leveled structures (ℓstructures). Sharing internal to the calculus or static sharing: the contraction link. Sharing added by the implementation to improve reduction or dynamical sharing: the multiplexer link. Sharing structures (sℓstructures). Unshared structures (uℓstructures). Sharing morphisms (smorphisms) and equivalence classes of identical structures with diﬀerent sharing. Chapter 3. In this chapter we start the study of the properties of the rewriting system (the socalled π interactions) induced by the interpretation of multiplexers as duplicators. Contents: Dynamics of the multiplexer: the π interactions. Behavior of the multiplexer link as a duplicator: propagation and absorption rule. Interactions between pairs of facing muxes: swap and annihilation. Deadlock and deadlockfree structures. Permutation equivalence of muxes. Local conﬂuence and simulation lemma of the deadlockfree structures. Chapter 4. We present in this chapter the algebraic machinery useful for the semantical characterization of the proper structures, that is, of the sℓstructures having an ℓstructure as unique π normalform. Contents: Lifting operators and lifting sequences. Block diagrams. Solutions of a uℓstructure. Internal state. Quiescence solution. Complete unsharing and leastsharedinstance. Proper sℓstructures. Chapter 5. This chapter concludes the study of the properties of the π interactions. We show that the proper sℓstructures are deadlockfree and have a unique π normalform which, because of the deadlockfreeness, is an ℓstructure.
6. SUMMARY
17
Contents: Syntactical readback. Semantical readback. Existence and uniqueness of the π normalform of a uℓstructure. The class of the proper uℓstructures. Box reconstruction in a uℓstructure. Chapter 6. In this chapter we apply the methodology to the λIcalculus. Contents: Lambda structures. Shared and unshared βreductions. Proper paths. Soundness and completeness. Chapter 7. In this chapter we apply the methodology to the multiplicativeexponential fragment of linear logic without weakening (IMELL). Contents: Sequent presentation of MELL. IMELL proof nets. Decoration of IMELL proofs with levels. Standard decorations. Parsing sℓnets. Chapter 8. We show in this chapter that, restricting to the subset of the π interactions obtained introducing the interaction net restriction that links may interact through their principal ports only, we get optimal reductions. Contents: Labeled structures. Labeled λcalculus. Optimality. Appendix. In it we brieﬂy discuss which are the problems which prevent the extension of the general methodology in the presence of weakening or of erasing abstractions.
18
1. INTRODUCTION
CHAPTER 2
Sharing structures
The main purpose of this dissertation is to study in depth the socalled sharing implementations of the λcalculus and of the multiplicative exponential fragment of linear logic (MELL). Anyhow, instead to give and analyze ad hoc solutions for such two relevant cases, our aim is to present a general description of sharing implementations abstracting the essential requisites a calculus must have to be implemented by such sharing techniques. In other words: ﬁrstly, we want to present sharing implementations by an abstract rewriting system separating what is relative to the calculus from what is relative to the implementation; secondly, we want to show how such an abstract point of view instantiates for the implementation of λcalculus and MELL. To start the abstraction process we dedicate this chapter to set the terminology and the main mathematical structures. In particular, we choice to deﬁne the data structures used by the sharing implementations—the socalled “structures of links”—as hypergraphs whose hyperedges—called “links” in accord to the usual proof net terminology—denote the connectives or the syntax operators of the calculi to be implemented. To have a way to treat whole connected parts of a structure as atomic objects we enrich the structure of links by a global constructor framing a whole structure by a box and corresponding in this general setting to the homologous proof net “box” operator. Boxes are the relevant objects manipulated by the computations of the calculi to be implemented. In fact, both linear logic and λcalculus have rewriting rules whose redexes are formed by interacting boxes and whose execution requires to move and duplicate one of the interacting boxes. The aim of the sharing implementations is to perform such displacements and duplications in a distributed way by the introduction of sharing control operators—represented in the graphs by a new kind of link—performing box duplication one link at a time. A lazy reduction strategy delaying the duplication of a link as long as possible will be shown to correspond to the socalled optimal reductions (see Chapter 8).
19
20
2. SHARING STRUCTURES
To obtain a distributed system operating on boxes without explicitly have a framing constructor we need to distribute on the links the informations corresponding to enclosing structures into boxes: provided that the construction rules of the calculus conform with a “box nesting condition” stating that boxes may nest but not partially overlap, we associate to each vertex a level corresponding to its box nesting depth. The interior of a box of level n is then a connected structure of links whose vertices are at a level greater than n. The nesting condition is the basic requirement a calculus must comply with in order to be implementable by our sharing techniques. But, in accord to the reformulation of boxes by levels, we see that an additional mandatory requisite is the connectedness of the boxes of the calculus to be implemented. Which has a computational justiﬁcation in the fact that no distributed algorithm starting from one of the border vertex of a box might completely duplicate a part of the box that is not connected to the starting vertex. The requirement on box connectedness is the cause of the inapplicability of the general methodology to the case of MELL proof nets containing weakenings. A short discussion of this problem is given in the appendix. The sharing links introduced to implement the distributed rewritings are the “multiplexers” that, from another point of view, may be seen at the dynamic counterpart of the static sharing operators of the implementing calculi, e.g., the “contraction” links of MELL. In fact, in a structure we can distinguish: a “static sharing” internal to the calculus (due to operators with a logical interpretation in it); a “dynamic sharing” introduced by the implementation to improve the dynamics of the rewriting system (implemented by multiplexers). The latter classiﬁcation of sharing corresponds to a weaker, but logically clearer, characterization of the “safe” operators of Asperti [Asp95a]. The chapter conclude (before a rather technical section on paths) with the deﬁnition of “sharing morphisms”: the tool by which to recognize when two structures are instances with diﬀerent sharing of the same term. The sharing morphisms are also the key point of the main device we will use in most of the proves in the next chapters: the socalled “simulation lemma.” Namely, demonstrated that a suitable diagram commute (see page 41), the soundness of the implementation is proved showing that any reduction of a sharing structure of links is simulated by a corresponding reduction of an unshared instance of it.
1. STRUCTURES OF LINKS
21
1. Structures of links The graphs we plan to study can be seen as sets of labeled “links” connected by “arrows” in which the cardinality of any link is ﬁxed, or better, constrained to assume a value over a preﬁxed range by the type assigned to the link (i.e., the number of the incoming and outgoing arrows of a link is given by the label of the link). 1.1. Hypergraphs. The arrows incident to a link (incoming or outgoing) are distinct and associated to a link port (input or output, respectively). For these reasons, arrows are better treated as vertices and links as hyperarcs—hyperedges in which we distinguish a tail, the incoming arrows, and a head, the outgoing arrows—of suitable hypergraphs. Definition 1.1 (undirected hypergraph). An undirected hypergraph is a pair def G = (V, E), where V(G) = V = {v1, v2, . . . } is a set of objects, the vertices of G, def and E(G) = E = {e1, e2, . . . } is a set of ﬁnite sequences of distinct vertices of G, the hyperedges of G. Definition 1.2 (hyperarc). A directed hyperedge, or hyperarc, is an ordered pair e = (∂t (e), ∂h(e)) of (possibly empty) disjoint ordered sets of vertices, being ∂t (e) the set of the tail vertices, or the tail of e, and ∂h (e) the set of the head vertices, or the head of e. The undirected hyperedge associated to a hyperarc e is the concatenation of def its tail and head, i.e., ∂(e) = ∂t (e) ∂h(e). Definition 1.3 (directed hypergraph). A hypergraph G is directed when all its hyperedges are hyperarcs, i.e., a directed hypergraph is a pair G = (V, E) of vertices V and hyperarcs E s.t. (V, {∂(e)  e ∈ E}) is an undirected hypergraph. Most of the links we will consider have a natural orientation independent from the one of the hyperarc given by the cardinalities of their head or of their tail: they have a unique head arrow and a tail of arbitrary cardinality, or vice versa. Definition 1.4 (backward/forward hyperarcs). A kary backward hyperarc is a hyperarc e with  ∂t (e) = k and  ∂h (e) = 1. A kary forward hyperarc is a hyperarc e with  ∂t (e) = 1 and  ∂h (e) = k. In the following, directed hypergraphs will be simply called hypergraphs and, when not explicitly speciﬁed the contrary, we will assume that they are ﬁnite, i.e., with a ﬁnite number of hyperarcs and vertices.
22
2. SHARING STRUCTURES
The hyperarc e is an incoming hyperarc of the vertex v when v ∈ ∂h (e), while it is an outgoing hyperarc of v when v ∈ ∂t (e). As for the tail and the head of a link, we assume that the incoming and the outgoing hyperarcs of a vertex v are ordered and we denote by ∂in (v) and ∂out (v) the sequences of the incoming and of the outgoing hyperarcs of it, respectively. Incoming and outgoing hyperarcs of v are both incident to it. Definition 1.5 (source and target roots). A source root is a vertex with no incoming hyperarcs (∂in(v) = ∅). A target root is a vertex with no outgoing hyperarcs (∂out (v) = ∅). An isolated vertex v is a vertex with no incident hyperarcs (∂in (v) = ∂out (v) = ∅). The set ∂V s (G) is the set of the source roots of G; the set ∂V t (G) is the set of the target roots of G. The union ∂V (G) of the source and target roots of G is the set of the roots of G. Definition 1.6 (border). The border of a hypergraph G is the set ∂E (G) of the hyperarcs incident to a root of G. 1.2. Links. A link type is a triple which compose of: 1. a type name; 2. a set of named input ports; 3. a set of named output ports. Definition 1.7 (link). A link of a given type is a hyperarc labeled by the corresponding type name and with a tail/head vertex for each of the input/output ports of the type. The tail vertices ∂t (e) of a link e are also said the premises of e, while the head vertices ∂h (e) are also said the conclusions of e; both premises and conclusions are the doors of e. A link with no premises is a source link. A link with no conclusions is a target link. We assume that isolated links (i.e., with no doors at all) are not allowed. 1.2.1. Notable links. The links we will meet studying the graph implementation of the linear logic are (Figure 1): • The identity links ax and cut: the ﬁrst one is a source link with two conclusions; the second one is a target link with two premises. • The multiplicative links (par) and (tensor) both with two premises and one conclusion (i.e., both are binary backward hyperarcs).
1. STRUCTURES OF LINKS
ax
23
n
A A O AOB
n
A? B
n
A
n
cut
A?
n
A
n n
B
n
n
A B
?
n
A
?
n+p p 0 n
A
?
A
n ?
A
n
A
!
n n
n+1
?
A
?
A
!
A
n
Figure 1. Notable links: linear logic. • The exponential links ? and ! both with one premise and one conclusion. • The (contraction) link (the one represented by a • in Figure 1) with k premises and one conclusion (i.e., it is a kary backward hyperarc). The links we will meet studying the graph implementation of the λcalculus are instead (Figure 2): • The @ (application) link with one conclusion and two premises. • The λ link with one conclusion, one premise, and one binding connection (the dotted one in Figure 2). • The v (variable) link (denoted by a • in pictures, see Figure 2) with one premise and a binding connection (the dotted one in Figure 2). Remark 1.1. In the last description the λ and the v links do not completely conform with the pattern ﬁxed by Deﬁnition 1.7 since both have an additional “binding connection.” The reasons for such a nonstandard representation are that, in order to preserve the tree shape of a λterm, we prefer to separate its binding relation from its topology using a distinct notations for the arrows connecting variable occurrences to their binders. Anyhow, noting that the binding
24
2. SHARING STRUCTURES
tl tr
n n pi 0 n+1
i=1;::: ;k n
x:t
n
@
n+p1
n+pk
n
tl
tr
x
x
t
Figure 2. Notable links: λcalculus. links implement the contraction in the case of the λcalculus, we could get a conforming representation of λterms replacing the binding connections by suitable links. Actually, the set of links we have just presented is not exhaustive. In fact, to implement the sharing we will introduce another kind of link—the multiplexer— in addition to the previous ones. We omit to describe it now since its shape and use will be widely discussed in the following of the chapter. Furthermore, during the study of the linear logic proof nets we will use a special link to parse the correct ℓstructures built by the links of Figure 1. Such a link is not part of the implementation but a sort of nonterminal symbol used to group correct subnets during their parsing. So, we postpone its introduction to the section in which we will study the graph grammar recognizing proof nets. 1.3. Structures. The vertices of our hypergraphs are of particular shape: they may be seen as arrows representing oriented connections between pairs of links. Definition 1.8 (arrow). An arrow is a non isolated vertex v with at most an incoming link and at most an outgoing link, i.e., ∂in(v) ∪ ∂out (v) = ∅, with  ∂in (v) ≤ 1 and  ∂out (v) ≤ 1. Remark 1.2. Let us consider the dual G∗ of a hypergraph G in which all the vertices are arrows. We see that G∗ is a directed graph (not a hypergraph!) since all its edges—the arrows of G—have only one source and one target node. This is the reason why we call arrows the vertices of our hypergraphs and we represent each of them by an “arrow” oriented from its incoming link to its outgoing link (see Figure 1 and Figure 2). Furthermore, when we will later study the λstructures we will see that for the hypergraphs representing λterms is more natural to work on their dual graphs. Hence, in such a case we will use node as a synonym of link
1. STRUCTURES OF LINKS
25
and edge as a synonym of vertex. We hope that in this way, even if not uniform, the terminology should accord with the one more familiar to the reader. Let Σ be a set of link type names (a link signature). A Σnaming for the links of the hypergraph G is a map τG : E(G) → Σ that assigns a link type to each hyperedge of G. Definition 1.9 (structure of links). A structure (of links) G over the link signature Σ is a pair (G, τG) in which 1. the hypergraph G has at least a root; 2. all vertices of G are arrows; 3. the map τG is a Σnaming for the links of G. Notation 1.1. Let G be a structure over Σ and let ⋆ ∈ Σ, the set E ⋆ (G) is the set of the links of G of type ⋆, i.e., E ⋆ (G) = {e ∈ E(G)  τG(e) = ⋆}. The source roots of a structure G are the premises of G , while its target roots are the conclusions of G . Since a structure does not contain isolated vertices it is immediate that no vertex can be both premise and conclusion of G , i.e., ∂V s (G) ∩ ∂V t (G) = ∅. Remark 1.3. The premises of a structure are arrows with no source, while the conclusions are arrows without target. Hence, if we had chosen to work with the dual of our structures we would have got graphs in which the source and target maps of the edges would have been partial, or we should have appended a root node to each dangling edge represented by a root. The latter one is another reason because of which we have preferred to see the structures of links as hypergraphs. 1.3.1. Substructures. A substructure R of a structure G , or G substructure, is a structure s.t. V(R) ⊆ V(G) and E(R) ⊆ E(G), and with τR = τRE(R). Since a structure does not contain isolated vertices, it is readily seen that the G substructures may also be seen as the parts of E(G). In fact, not only any G substructure R is uniquely determined by the set E(S) ⊆ E(G) but, given a set of links E ⊆ E(G), there exists a (unique) G substructure s.t. E(R) = E. With such an interpretation in mind it is immediate to extend the standard inclusion relation and set operations to G substructures: • R0 ⊆ R1 iﬀ E(R0) ⊆ E(R1); • R = R0 ∩ R1 is the G substructure s.t. E(R) = E(R0) ∩ E(R1); • R = R0 ∪ R1 is the G substructure s.t. E(R) = E(R0) ∪ E(R1);
26
2. SHARING STRUCTURES
• R = R0 − R1 is the G substructure s.t. E(R) = E(R0) − E(R1); where R0 and R1 are G substructures. The previous considerations do not apply if we replace links with vertices. In fact, even if a G substructure is uniquely determined by the set of its vertices, it is no more true that for each set of vertices V ⊆ V(G) there exists a G substructure R with V = V(R). Anyhow, to each set of vertices V ∈ V(G) we may associate the G substructure {e ∈ E(G)  ∂(e) ⊆ V} composed of the links whose doors are all contained in V, i.e., the biggest G substructure R s.t. V(R) ⊆ V. The border ∂E (G) of a structure G (see Deﬁnition 1.6) is a G substructure and def its complement ∂E (G ) = G − ∂E (G) is the interior of G . According to this, the interior links/arrows of G are the links/arrows in the interior of G . 2. Boxes The general pattern we shall now introduce is that of a proofbox. Roughly speaking, proof boxes are synchronization marks in the proofnet. They can also be seen as moments where we restore the sequent (i.e., the sequential!) structure. Their use is therefore a bridle to parallelism and, for that reason, one must try to limit their use. [Gir87, p. 43]. The rewritings of the systems we will consider in the next chapters require to treat whole subgraphs of the rewriting structures as atomic objects, the socalled “boxes.” For instance, the elimination of an exponential cut from a linear logic proof net requires the copying and displacement of the box associated to the contracted ! link. Analogously, the βcontraction of a λterm requires to replace each occurrence of the variable of the contracted redex by a copy of the subtree (which plays here the role of a box) of the redex argument. In both the latter examples the box duplicated and moved by the rewriting is a connected substructure in which we distinguish: • A principal door link (pdl): the ! link of the box in the linear logic case; the @ link in the λcalculus case. • A set of auxiliary door links (adls): the auxiliary ? links of the box in the linear logic case; the leaves of the argument tree (the v links of such a tree) in the λcalculus case. Such examples also show that (i ) boxes interactions take place between a pdl and a set of adls of distinct boxes suitably connected by a redex (an @λ pair in
2. BOXES
27
the λcalculus case; a cut the premises of which are (a) the ! link of the redex and (b) a tree of links the leaves of which are the ? links of the redex in the linear logic case) and that (ii ) the result of such an interaction is (cf. Figure 3): 1. the opening of the box of the pdl; 2. the creation of an instance of the interior of the pdl’s box for any adl which is part of the redex; 3. the “nesting” inside the box of its adl of each new instance of the pdl’s box, according to the nesting level of the corresponding doors.
box
box
box
N
!
N
? ? !
?
e
N1
!
Nk
!
N
cut
?
!
cut
!
cut
Figure 3. An example of interacting boxes. Figure 3 shows in details what happens in the linear logic case, in which an ! link is connected by a cut link to a contraction a ? premise of which is an adl of the box N?, and a ? premise of which is not adl of any box (a dereliction). The box around N! evaporates (step 1) and its interior is duplicated in order to create a copy of N! for any premise of the contraction (step 2). Hence, each new instance N! i is nested inside the boxes which enclosed its corresponding adl (step 3). For example, the instance N! 1, corresponding to the dereliction, has to be nested inside nothing and the result is simply the evaporation of the box surrounding N! 1; the instance N! k associated to the adl of N? has instead to be pushed inside N? as deeply as the nesting level of the corresponding erased ? link. In the case of the λcalculus the situation is similar to the just explained one. So, more generally, the method we are going to present applies to systems whose structures of links comply with the following (see [DR95])
28
2. SHARING STRUCTURES
Box nesting condition: Two boxes are either disjoint or included one in the other. In the second case they cannot have the same principal door link. Remark 2.1. Generally, the box nesting condition is not the only box formation rule the implementing calculus induces on the corresponding structures. In fact, as already pointed out for the structures implementing λcalculus or linear logic, the calculus also ﬁxes the type of the principal and auxiliary door links. Anyhow, since the box nesting condition is the only one required to introduce the nesting level indexing, it is the base from which to start the generalization. 2.1. Box nesting level. The box nesting condition gives us a way to associate a nesting level—the number of boxes enclosing it—to any arrow and any link of a structure. In this way, we avoid to introduce special links for box representation additionally asking the connectedness of boxes. Namely (cf. Deﬁnition 2.2), in the case of MELL, the interior of a box whose principal door link e! (an ofcourse link) is at nesting level n is the connected structure containing the premise of e! and s.t.: (1) its internal arrows are at a nesting level greater than n and (2) each of its border links is, with the exception of e!, an auxiliary door link e? (a whynot link) whose conclusion is at a level lower or equal than n (a whynot may close an arbitrary number of boxes so the diﬀerence between its premise and its conclusion may be greater than 1). Hence, to be able to recover boxes without introducing a box constructor it suﬃces to record in any arrow its box nesting level—assuming that the level of a link is recoverable from the ones of its doors. A nesting levels assignment for an hypergraph G is a map ιG : V(G) → N assigning a nonnegative level to each vertex of G. Definition 2.1 (ℓstructure). An ℓstructure G over the link signature Σ is a triple (G, τG, ιG), where (G, τG) is a structure over Σ, and ιG is a nesting levels assignment for G. In spite of the generality of the last deﬁnition, in the practical cases the nesting levels assignment of an ℓstructure is not an arbitrary map. In fact, the type assigned to a link not only constraints the incidence relation of the link, it also gives the positions the link may assume w.r.t. the frame of a box. That reformulated in terms of levels leads to classify links according to the level constraints given by their type (cf. Figure 1 and Figure 2). That is, a link is a:
2. BOXES
29
pdl (principal door link) when all its doors but one that we say internal (w.r.t. the box of which the link is principal door) have the same level n, the level of the internal door being instead n + 1; adl (auxiliary door link) when we can distinguish an external door (w.r.t. the boxes of which the link is auxiliary door) corresponding to the one with the smallest level: such a door is also the one through which the adl may interact with a pdl; intl (interior link) when all its doors have the same level. From which, we can state in more details that: • A pdl (of level n) is the principal door link of the box of level n (i.e., nested inside n boxes) whose interior (nested at level n+1) can be accessed through the internal door of the pdl. The other doors of the pdl are instead outside such a box. • An adl may be auxiliary door link of several possibly disjoint boxes. In fact, moving from its external door to any other one we enter into as many boxes as the diﬀerence between the levels of the two doors. • An intl may not be the door link of any box. 2.1.1. Concrete examples. In the structures for linear logic the ! links are pdls. Such kind of links have in fact a unique premise of level n + 1 and a unique conclusion of level n (see subsection 1.2.1 and Figure 1). Hence, the premise of an ! link is internal to its box, while its conclusion is external. The ? links are instead adls. In fact, such kind of links have a unique premise of level n + p, being p a nonnegative number, and a unique conclusion of level n (see subsection 1.2.1 and Figure 1). Hence, a ? link e? is the border of p boxes and, in the degenerate case in which it is border of no boxes (p = 0), e? is called a dereliction. In the λcalculus case the @ links are pdls: they are the only links with two doors (the left and up arrows) at level n and one (the right arrow) at level n + 1 (see subsection 1.2.1 and Figure 2). In this case the internal door is the right one, the others are instead external. The links playing the role of adls are instead the v links. In fact, we already pointed out that in a more uniform presentation their binding connections should have seen as doors of suitable contractions connected to the corresponding λ link. Moreover, replacing the binding connection by such links, we might see that the v links would have the same shape of the ? links: they would have two doors at level n and n + p, respectively. So, such new v links would be the adls of such structures.
30
2. SHARING STRUCTURES
2.2. Leveled boxes. Let us now see in details how to use the levels assigned to a structure to recover its boxes. Definition 2.2 (box). Let ep be a pdl of level n of an ℓstructure G . The box of ep is the smallest leveled G substructure Boxℓ(ep) s.t.: 1. 2. 3. 4. 5. ep is a door link of Boxℓ(ep); all the door links of Boxℓ(ep) but ep are adls; Boxℓ(ep) is connected; the level of any interior arrow of Boxℓ(ep) is greater than n; the level of any arrow of the border of Boxℓ(ep) is not greater than n.
The G substructure Boxℓ(ep) is also said a box of level n. Remark 2.2. We ask that boxes are connected structures. The reader acquainted with linear logic should have already noted that such a deﬁnition does not allow boxes containing separated subcomponents originated by the use of weakenings. The problem with such conﬁgurations is that, when some parts of Boxℓ(ep) are unreachable from ep, there is no deterministic way to perform a distributed operation that starting from ep involves all the links of Boxℓ(ep). These are the reasons because of which we have to restrict our general study to the cases of the fragment of linear logic without weakening and of the λIcalculus. Remark 2.3. Studying the dynamics of the linear logic we will treat as atomic the conﬁgurations formed by a set of ? links whose conclusions are premises of a link (see Remark 2.2 of Chapter 7) asking at the same time that a ? link is always followed by a contraction, even when it would be useless, i.e., a ? followed by a unary link. Another way to achieve it would have been to replace such conﬁgurations with a generalized contraction in which we admit that the premises might have a level greater than the conclusion also for the study that we are going to perform in the next two chapters. Anyhow, such a choice would have implied a more involved deﬁnition of boxes and it would have complicated the semantical interpretation of links of Chapter 4: an adl has an internal state that summarizes the information it has to know on the contents of the boxes it closes; so, while the nesting of boxes cause a stacking of informations in the state of a common adl, the simultaneous closure of two separate boxes would give independent contributes to the state of a common adl. Summarizing, we could not have assigned a unique state to a ? link.
3. SHARING
31
By the use of levels we have reached the goal to avoid the introduction of a box constructor. Even though, we have not yet given any way to duplicate boxes without to reconstruct them, that is, using Deﬁnition 2.2. So, up to now, boxes are yet needed for the dynamics of the structures of links. The next chapters will be devoted to show how to get rid of boxes also during structure reductions. 3. Sharing 3.1. Static sharing. Analyzing the shape of the notable links presented in subsection 1.2.1 we see that the structures we are going to consider already contain a sort of sharing operator (either explicit or implicit): a link corresponding to the contraction rule of linear logic in proof nets (explicit); a binding function mapping the occurrences of variables to their λabstraction in λnets (implicit). We classify such sharing constructors—also said contraction links—as “static” to distinguish them from their “dynamic” counterpart: the multiplexers. In fact, while the contraction links corresponding to connectives of the calculus under analysis contribute to the static interpretation of a structure, the multiplexers have a meaning in terms of the dynamics of the calculus: they are devices added by the implementation to lazily perform the duplication of boxes. There is also another main diﬀerence between contractions and multiplexers: while the contraction links (being their type) are only “positive”; the multiplexers (see Deﬁnition 3.2) may also be “negative” (see Deﬁnition 3.3). In fact, a link denotes the merging of a set of compatible informations, so it is always built from its premises to its conclusion. A multiplexer instead may denote either the merging of several access pointers to a shared part into a unique wire, or the splitting of a conclusion of a shared part into several exit ways from it. Definition 3.1 (contraction). A contraction link is a backward hyperarc with k > 0 premises in which: 1. all the premise ports have the same name; 2. all the doors have the same level. Remark 3.1. How suggested by the fact that our contraction link is kary, we will use the convention to merge trees of links with k leaves into a unique kary link with the leaves of the tree as premises and its root as conclusion. Nevertheless, we will not care to draw structures containing trees of links: we simply assume that all the links in such a tree are actually the same link.
32
2. SHARING STRUCTURES
n
n
n
n
Figure 4. The contraction link. Remark 3.2 (Degenerate links). For technical reasons it is useful to allow also links with k = 1, that is, useless contractions playing the role of an identity operator. We forbid instead the case k = 0 since such a kind of link would have been a weakening operator. 3.2. Dynamic sharing. Techniques to implement functional calculi based on the use of pointers (and then on graphs) were known from long time (see for instance [Wad71, PJ86, AKP84]). In all such solutions the sharing was implemented at the level of (ﬁnite or inﬁnite) subterms—being a subterm the tree (the inﬁnite unfolding tree when the graph contains cycles) spanned by the paths rooted at a given node—by pointers from the accessing nodes to the corresponding shared part. A relevant drawback of such a naive solution was the possibility of unwanted sideeﬀects (see [Wad71]) during the execution of variable substitutions. In fact, replacing the occurrences of a variable by a term, we cannot directly substitute the nodes representing the variable by pointers to the tree of the term, otherwise the eﬀect of such a substitution would be visible in all the shared parts containing the substituting variable, even in the ones in which the substitution had to not be performed. So, to circumvent such sideeﬀects problems, we had to ensure that the original subterm was leaved unchanged creating a new instance of the shared part before the execution of any substitution. The key point of the sharing implementations is instead the possibility to partially share terms achieved moving the implementation of sharing to the level of the socalled contexts. A “context” is a term (or net) containing placeholders denoting “holes” reﬁllable by any term (net). To “share a context” means then that diﬀerent instances of a context could have their holes ﬁlled in diﬀerent ways or, in terms of graphs, that diﬀerent access pointers to a shared part correspond to diﬀerent exit ways to leave it. The crucial point is then to couple the ways in which the shared parts are accessed to the ways in which they are leaved entering into a hole.
3. SHARING
33
Remark 3.3. The latter behavior of shared contexts is completely diﬀerent from the one of shared variables. Replacing a variable of a shared term the inserted object (term or graph) must be visible in all the instances of the term. Replacing the contents of a hole of a shared context we have instead to take into account which instance of the context we are dealing with. In other words, while the parametricity given by a variable is context independent, a hole denotes a contextual parametricity. The study of paths we are going to develop in particular in the λcalculus case is the formalization of the mentioned matching problem between the instances of a context and the ways in which to ﬁll its holes. Its solution is the rewriting system for the propagation of multiplexers that we will present in the next chapter. 3.3. Multiplexers. The dynamic counterpart of the contraction link is the multiplexer link. Definition 3.2 (multiplexer). A kary multiplexer or kmux is a backward k or forward link of type with: 1. one principal port; 2. a sequence of k secondary or auxiliary ports the names of which a1, . . . , ak are chosen over a denumerable set with the proviso that ai = aj iﬀ i = j; 3. an associated nonnegative integer m, said the threshold of e; 4. an associated sequence of k integers q1, . . . , qk, said the secondary ports oﬀsets, s.t. qi ≥ −1, for i = 1, 2, . . . , k. According to the previous discussion on sharing there are two kinds of muxes: the positive ones collecting the entry pointers to a shared part; the negative ones separating the exit ways from a shared part. Definition 3.3 (positive and negative multiplexers). A kary multiplexer is • a positive kmux (or a mux with type and fanin k) when it is backward, i.e., its auxiliary doors are its tail and its principal door is its head; • a negative kmux (or a mux with type and fanin k) when it is forward, i.e., its auxiliary doors are its head and its principal door is its tail. A multiplexer is an operator conveying multiple ﬂows of informations into a unique wire preserving the reversibility of the process; a demultiplexer is instead the operator performing the inverse task. From this point of view we could then say that a positive mux is a multiplexing operator while a negative mux is a
34
2. SHARING STRUCTURES
demultiplexing one. Such a classiﬁcation would be perfect only if we could always assume that the direction in which informations ﬂow accord with the orientation of links. In fact, the orientation of links, at least in the cases we will present, correspond to the natural one in which the structures are built: in a proof net starting from the axioms; in a λterm starting from the leaves (the variables) of the λterm tree. Nevertheless, the natural way to cross links to readback an already built structure is the inverse one, e.g., starting from the root of the tree in the structures representing λterms. Hence, positive and negative muxes have a dual operational behavior according if we are building or reading the structure: while in the ﬁrst case the positive muxes are multiplexing operators, in the second one they are demultiplexing operators—to readback a structure we need to know which of the subterms multiplexed during its construction we have to choose for each of the instances associated to the principal port of a mux. Thinks are even less clear in the case of linear logic proof nets in which the natural orientation to use crossing nets is not unique as in the λcalculus case (see for instance the work of Bellin on orientation assignments to proof nets [BS94]). Such a duality of a mux explains why we prefer to use a more neutral distinction of them into positive and negative ones rather than into multiplexers and demultiplexers.
n+q1 a1 m
n+qi ai n
n+qk ak m<n qi 1 i=1;:::;k
Figure 5. The multiplexer (mux) link.
Notation 3.1. Henceforth it would be useful to have a common notation for positive and negative muxes denoting by ∂prn (e) the primary door of a mux and by ∂aux (e) its auxiliary doors. Furthermore, when it will not be relevant, we will omit to draw the stems of the arrows in pictures containing muxes. The one drawn in Figure 5 stands then for either a positive or a negative mux depending if the context implies the arrows are downward or upward oriented.
3. SHARING
35
The drawing of a mux in Figure 5 also gives the constraints the levels the doors of a mux must accord to. Namely: • each qi is the oﬀset between the level of the principal door of the mux and its ith auxiliary door; • the threshold m may not be greater or equal than the level of the principal door. 3.4. Sharing structures. The muxes are not part of the calculi we plan to study: they are control operators added to implement sharing. Hence, it is natural to assume that their type names are reserved, i.e., that , ∈ Σ, for any / link signature Σ. Definition 3.4 (sℓstructure). Let Σ be a link signature s.t. , ∈ Σ. A / (leveled) sharing structure (sℓstructure) over Σ is an ℓstructure over Σ ∪ { , }. The mux links do not ﬁt in the classiﬁcation of links related to their relative position into boxes (see page 28). In fact, in the case of a secondary port with an oﬀset equal to −1 a box would be exited and not entered moving from the principal port of the mux to such an auxiliary one. Anyhow, we already pointed out that the interpretation of muxes must be intended in terms of their dynamics, and from this point of view, the task of muxes is to implement the distributed algorithm performing the duplication and the nesting of boxes (cf. the example of Figure 3). So, a mux is not the static border of a box, but (using the names in Figure 3) the dynamical border of a part of N! still shared, the oﬀsets of its ith auxiliary port denoting the number of the new box frames which will enclose the ith instance of N! after the reduction. In particular, when such an oﬀset equals −1 we have the case corresponding to the instance N! 1, in which the box surrounding N! evaporates. 3.5. Unshared structures. The traditional sharing implementations keep separate the two operational aspects of muxes using two distinct kinds of control operators to implement them: the fan nodes for duplication, and the bracket (and croissant) nodes for reindexing. In our approach, we choice instead to unify both the aspects into muxes since we think that the former separation does not simplify signiﬁcantly the study, but on the contrary, that the use of a unique kind of control node allows to give a more compact presentation. Nevertheless, also because of what we will sketch in subsection 4.1 and subsection 4.2, for the sake of the proof of the properties of the sℓstructures it will be useful to separate the
36
2. SHARING STRUCTURES
problem of the assignment to the instances of a structure of their correct nesting levels from the problem of the sharing of such instances (even if the two topics are not completely independent). In particular, for the study of the reindexing, it will be useful to consider structures that do not contain any sharing because all their muxes are unary. Definition 3.5 (lift). A lift is a multiplexer with only one auxiliary port. Definition 3.6 (uℓstructure). An unshared structure (uℓstructure) over the signature Σ is an sℓstructure over Σ in which all the muxes are lifts. 3.6. Erasers. As for the links, in the deﬁnition of muxes we posed no restrictions on their cardinality: we have neither forbidden the case k = 0. The link obtained in this way corresponds however to a dynamic erasing operator and is usually generated by the contraction of an erasing connective of the implementing calculus, e.g., by a rewriting involving a weakening of the linear logic or a K abstraction1 of the λcalculus. So, it would not be used in the following chapters. Here, we just note that the presence of erasers in a structure implies that the structure contains some garbage that the erasers has to collect. Nevertheless, we introduce such links for the sake of completeness and because we will shortly discuss the problems connected with weakening and garbage collection in the appendix of the thesis. Definition 3.7 (eraser). An eraser is a multiplexer with no auxiliary ports. The graph representation of an eraser is similar to the one of a mux: we simply explicit by the ∅ label that its set of auxiliary ports is empty (see Figure 6).
m ?
n
m<n
Figure 6. The eraser link. Definition 3.8 (siℓstructures and skℓstructures). A sharing istructure or siℓstructure is an sℓstructure that does not contain any eraser. A sharing kstructure or skℓstructure is an sℓstructure that may contain erasers.
1
We call a Kabstraction a λ which does not bind any variable.
4. SHARING MORPHISMS
37
Remark 3.4. In the following we will use sℓstructure as a synonym of siℓstructure. So, if we wanted to explicit that a sharing structure might contain erasers we should say that it is an skℓstructure. Note that we use the letter “i” since the sharing structures without erasers are the ones obtainable implementing calculi without weakening or erasing operators, e.g., the λIcalculus. Remark 3.5. To be sure that the result of the reduction of an siℓstructure is still an siℓstructure we should have explicitly asked that the siℓstructures does not contain erasing operators of the calculus (e.g., weakening links in the case of linear logic). We postpone the formal introduction of such a restriction to the chapters in which the general technique is instantiated and the calculus to be implemented completely ﬁxed. Remark 3.6. Since the uℓstructures does not contain erasers they are (modulo the previous remark) uiℓstructures. Their natural extension are the ukℓstructures, in which both lifts and erasers are allowed. 4. Sharing morphisms Given a sharing structure we need a way to unwind the sharing it contains or a way to share compatible parts of it, i.e., we have to deﬁne how a structure may be embedded into another one containing more sharing (the inverse of such operation would immediately give how to get an image of a structure with less sharing). Definition 4.1 (smorphism). A sharing morphism (smorphism) between two sℓstructures G0 and G1, denoted by M : G0 → G1, is a surjective map M between the vertices and the hyperarcs of G0 and G1 that 1. is a bijection between the doors of G0 and the doors of G1, and 2. preserves: (a) the types of the links, (b) the levels of the arrows, (c) the incidence relations, port names included, between the arrows and the links; (d) the thresholds of the muxes, (e) the auxiliary ports oﬀsets of the muxes. The item of the last deﬁnition may be more formally reformulated by:
38
2. SHARING STRUCTURES
1. For any v0 ∈ ∂V (G1) there exists a unique v1 ∈ ∂V (G0) for which Mv(v0) = v1, and vice versa. 2. For any v ∈ V(G0), any e ∈ E(G0), and any e ∈ E (G0): (a) τ(e) = τ(M(e)); (b) ι(v) = ι(M(v)); (c) if v ∈ ∂(e) is connected to the port ⋄ of e, then M(v) ∈ ∂(M(e)) and it is connected to the port ⋄ of M(e); (d) if the threshold of e is equal to m, then also the threshold of M(e ) is equal to m. Remark 4.1. In the relevant cases we will study, the only links with variable cardinality are the contraction link and the mux. Consequently, an smorphism may change the cardinality of those links only, e.g., mapping a lift to a kmux. Remark 4.2. Actually, studying the proof nets of the linear logic we will use another link with a variable number of conclusions: the socalled net link. Anyhow, such a kind of link is only a device to group substructures without muxes for parsing purposes. So, even if the cardinality of such a kind of link is variable, we will require that an smorphism between two structures containing net links preserve the number of the conclusions of any net. The deﬁnition of smorphism allows situations (drawn in Figure 7) in which two distinct lifts e1 and e2 connected by their principal door to the same link e0 have the same shared image (for the sake of simplicity we consider the case of lifts, but similar situations may be constructed using muxes of arbitrary cardinality). By deﬁnition of smorphism such a situation implies that the ports of e0 to which the two lifts are connected have the same name, even if nothing is said about the names ai and aj (and then about the corresponding oﬀsets qi and qj) of the lifts auxiliary ports. We will however see that the intended interpretation of sharing structures leads to consider as not admissible the conﬁgurations in which ai = aj (see section 2 of Chapter 3). The semantics we are going to present in Chapter 4 will give us the invariants helpful to prove that such cases do not arise when the reductions start from a correct structure of the underlying calculus. Remark 4.3. The case of Figure 7 is possible only if the port names of the ⋆ link e0 are equal. Hence, of the notable links presented in subsection 1.2.1, the only possibility is that e0 is a link.
4. SHARING MORPHISMS
39
n+qi
ai
m m
n
?
n+q1 n+qi n+qk
a1 a.i ak m
. . . . .
n
?
n+qj
aj
n
Figure 7. An example of smorphism in which two lifts with the same principal door have the same shared image. 4.1. Instances of a structure. Subsuming that two sℓstructures connected by an smorphism are diﬀerent shared representations of the same structure, we may interpret the arrow of an smorphism as a preorder symbol stating: and deﬁning a class of common instances of an sℓstructure as a maximal set of sℓstructures for which the latter preorder is total. Definition 4.2 (instances of G ). Let G be an sℓstructure. The class of the instances of G is the set of the sℓstructures G1 for which there exists either an smorphism M : G → G1 or an smorphism M ′ : G1 → G , or both. G1 is a less shared instance of G when there exists M : G1 → G ,
The deﬁnition of smorphism explains why we say that muxes are the links where the entry pointers to a shared part are collected, or where the exit ways from it are separated. Furthermore, our interpretation of the source and target of an smorphism as instances of a common structure explains that, even if the lifts of a uℓstructure U have no direct sharing eﬀects, they denote the points where sharing is allowed in a more shared instance of U . Nevertheless, not any method to insert such lifts leads to a “proper” uℓstructure and not any sℓstructure is image of a proper uℓstructure, that is, not any sℓstructure is proper (see Deﬁnition 3.6 in Chapter 4). For instance, let us see the schematic picture of Figure 8 in which a shared part X is the image of two unshared instances X1 and X2. Each unshared instance is delimited by a pair of lifts, that in a proper structure are deﬁnitely complementary. To check the properness of lift names may however not be immediate. In fact, only in very simple cases the lifts may be considered as a sort of standard parenthesis; for instance, when the ones drawn if Figure 8 are the only lifts present in
40
2. SHARING STRUCTURES
m a1
m a2
m
a1 a2
X1
m a1
X2
m a2 m
X
a1 a2
Figure 8. Lifts as parenthesis enclosing unshared parts.
the uℓstructure. The problem is that to deﬁne the properness property capturing the idea of matching lifts the topology of the structures does not suﬃce: it has to be exploited in conjunction with an interpretation of links as constraints between suitable weights assigned to their arrows. Such an algebraic semantics will be the topic of Chapter 4: it will be used to get an algebraic characterization of the proper uℓstructures. A relevant consequence of the restriction given by such an algebraic characterization will be that the proper uℓstructures of our relevant cases (the uℓnets and the λuℓterms) are the least elements (w.r.t. the sharing preorder) of the corresponding sets of instances, i.e., there is no less shared instance of them.2 Hence, each of them may be taken as the representative element of the set of its instances.
4.2. Simulation property. The uniqueness of the unshared representation of the proper sℓstructures (the canonical representatives of their sets of instances) will be exploited to prove the properties of the sℓstructure reductions. In fact,
assume that U1 and U coincide.
For the sake of precision, we had to say: If U is a uℓnet or a λuℓterm and there exists M : U1 → U , then U1 and U are isomorphic. But, since our structures are ﬁnite, we may
2
5. PATHS AND TREES
41
both soundness and correctness will be shown by the “simulation property” established by commuting diagrams with the following shape N0 M0 U0 ρ
+
r
N1 M1 U1
in which Mi : Ui → Ni is an smorphism and the uℓstructure Ui is the (proper) leastshared instance of the proper sℓstructure Ni, for i = 0, 1. 5. Paths and trees We conclude the chapter with some terminology. Notation 5.1. Let e be a link with type ⋆ and let v0, v1 ∈ ∂(e) be two distinct doors of e. We write: 1. v0 e v1 or v0 e v1 when (v0)e(v1) is a twist, i.e., either v0 and v1 are both ⋆ ⋆ premises or both conclusions of e, respectively; 2. v0 e v1 or v1 e v0 when (v0)e(v1) is a straight connection between v0 ∈ ⋆ ⋆ ∂t (e) and v1 ∈ ∂h (e); 3. v0 e v1, when (v0)e(v1) is either a twist or a straight connection. ⋆ Definition 5.1 (paths). A sequence ϕ = (v0)e1 · · · (vi−1)ei(vi) · · · ek(vk) of arrows vi and links ej is: • a direct path when any (vi−1)ei(vi) is a direct straight connection vi−1 ei vi; ⋆ • an inverse path when the sequence ϕ∗ obtained by reversing ϕ is a direct path; • an undirected path when any (vi−1)ei(vi) is either a straight connection or a twist. Notation 5.2. For any path ϕ = (v0)e1 · · · (vi−1)ei(vi) · · · ek(vk) of structure G (denoted by ϕ ⊂ G): 1. ϕ = k is its length, 2. ∂s(ϕ) = v0 is its source vertex, 3. ∂t(ϕ) = vk is its target vertex; and we write: 1. v0
ϕ
vk, when ϕ is direct;
42
2. SHARING STRUCTURES
2. v0 3. v0
ϕ ϕ
vk, when ϕ is inverse; vk, when ϕ is undirected.
Furthermore, let ϕ, ψ be a pair of paths: 1. When ∂t(ϕ) = ∂s(ψ), the path ϕψ is the concatenation of the sequences ϕ and ψ. 2. When ∂t(ϕ) e ∂s(ψ), the path ϕ ′ e ψ ′ is the concatenation of ϕ and ψ ⋆ ⋆ via e (inserting e between ϕ and ψ); according to the type of the connection crossing e, we also write ϕ e ψ, ϕ e ψ, etc. ⋆ ⋆ We admit that the ﬁrst or the last link of a path might be a root: a source root for the ﬁrst link, and a target root for the last one. In such cases, we write ∅ ϕ v or v ϕ ∅, respectively. In particular, when the last link is a target root, the path v ϕ ∅ is said maximal. A structure is said connected when there is a path v0 ϕ v1 between any pair of its vertices (note that we do not ask any orientation of the path). A path whose ﬁrst and last vertices coincide is a cycle. A structure is acyclic if it does not contain any cycle. A connected component of a structure G is a connected G substructure R s.t. R ∩ S = ∅ implies S ⊂ R, for any connected G substructure S . On paths we have the usual preﬁx partial order ψ ≤ ϕ when ψ is an initial sequence of ϕ. Definition 5.2 (direct tree). A set of direct paths Π is a direct tree when it is closed under the preﬁx partial order.
CHAPTER 3
The π interactions
In this chapter we start the study of the dynamics of multiplexers: the socalled π interaction 1 rules. Such rules correspond to a generalization of the usual ones of fans and brackets studied by Gonthier, Abadi, and L´vy [GAL92b, GAL92a] e and are a generalization even of the wider set of rules proposed by Asperti [Asp95b]. The key idea is that multiplexers play the role of duplicators which propagates into nets: something similar to the duplicator interaction combinators of Lafont [Laf90, Laf95b], but in a larger sense. In fact, since we relax the uniqueness of the principal port of the logical links (the ones proper of the calculus to be implemented), a multiplexer interacts with one of such links independently from which of its port it has reached (see Figure 1). Another relevant diﬀerence between the multiplexers and the duplicator of Lafont is that, because of the levels on the arrows, the multiplexers also have to adjust the levels of the new instances of the arrows they create after the duplication of a link, i.e., in terms of box nesting levels, the multiplexers have to lift the nesting levels of such arrows according to their new positions. Summarizing, multiplexers have a twofold task: to duplicate and to reindex the interior of the box on which they have to operate. In the previous literature such two tasks were split and assigned to two diﬀerent kinds of control operators: the fans and the brackets, performing the duplication and the reindexing, respectively. Furthermore, there was no clear distinction between the links relative to the intended interpretation of the structure (to which we just referred as logical links and that Asperti call “safe” [Asp95a]) and the control operators. The uniﬁcation of the control links into the multiplexers and the distinction of them from the logical ones we adopt reveal their strength by the general properties of the π interactions we are able to prove. We remark the generality of our treatment that, according to the classiﬁcation of links of section 2 Chapter 2, allows us to separate three kinds of π interactions:
1
We adopt the terminology of the socalled interaction nets using interaction as a synonym
43
of contraction.
44
3. THE π INTERACTIONS
• the mux propagation rule that corresponds to an interaction internal to the box into which the mux has to perform its task; • the muxes interactions that correspond to the usual rules between facing control operators; • the absorption rule that corresponds to the interaction of a mux with the border—an auxiliary door—of the box it has to operate into. The ﬁrst two kinds of rules are fairly standard. The absorption rule is instead one of the key properties that our approach allows to prove. In fact, even if it may be seen as a subcase of the socalled safe rules of Asperti [Asp95a], in our presentation it assumes a clearer meaning in terms of the behavior of the multiplexers w.r.t. its nesting inside boxes. Deﬁned the π interactions we will start the study of the properties of the corresponding rewriting system (which will be completed in the chapter on the readback after the introduction of the algebraic semantics of structures) and, according to our interpretation, we will deﬁne as deadlocked any conﬁguration in which a multiplexer cannot interact with the link pointed by its principal port. We will then prove that the π reductions of deadlockfree structures are locally conﬂuent up to a permutation equivalence of muxes (which is the only form of propagation given by Asperti in [Asp95b]). The chapter ends with a proof of a simulation lemma which allows to conclude the invariance of deadlockfreeness under smorphisms. 1. Interactions of muxes 1.1. πredexes. A mux interacts trough its principal port with the port of any other kind of link but with the auxiliary port of another mux. Definition 1.1 (π redex). A πredex is a triple e (v)πe⋆ in which: 1. 2. 3. 4. the the the the ﬁrst link e of the redex is a mux; second link e⋆ of the redex is of any type; arrow v is the principal door of e ; arrow v is any door of e⋆ but an auxiliary one when e⋆ too is a mux.
Notation 1.1. For any πredex r = e (v)πe⋆ : 1. the arrow v is the principal door of the redex r; 2. the port of e⋆ to which v is connected is the principal port of e⋆ w.r.t. the redex r; 3. the other ports of e are the auxiliary ports of e⋆ w.r.t. the redex r.
1. INTERACTIONS OF MUXES
45
Remark 1.1. In opposite to what happens in the interaction nets [Laf90], the principal port of a link in not unique. In fact, our notions of principal and auxiliary are relative to the redex and, because of the generality of Deﬁnition 1.1, the principal port may be in turn any port of a link. The only exceptions are multiplexers, for which the principal port is ﬁxed (cf. Deﬁnition 3.2 in Chapter 2 and Notation 1.1 above). The consequence of the loss of such a uniqueness is the presence of critical pairs between πredexes. Anyhow, we will later see that (up to a mux permutation equivalence) such critical pairs are locally conﬂuent, at least for the cases we are interested in. 1.2. Mux propagations. The idea that a mux is an agent traveling through the structure with the task to duplicate and lift a box formalizes into the mux propagation rule. The mux propagation rule corresponds to the interaction of a kmux e with a second link e⋆ having h auxiliary doors (w.r.t. the redex). Its execution (see Figure 1) 1. creates k new instances of e⋆ and h copy of e ; 2. connects the jth auxiliary port of the ith instance ei of the ⋆ link to the ⋆ j ith port of the jth copy e of the mux; 3. lifts the levels of all the doors of ei by the oﬀset qi of the ith auxiliary ⋆ port of e . Remark 1.2. The indexing rules force the threshold of a mux to not be greater than the level of its principal door. Hence, to ensure the soundness of the interaction, the mux propagation has the proviso that the levels ni of the auxiliary doors of e⋆ are greater than the threshold m of e . In section 1.4 we will analyze what to do when the proviso is not veriﬁed. 1.3. Muxes interactions. The muxes interactions are the rewritings corresponding to the case in which also the second link of the πredex is a mux. We already mentioned that in our mind the π interactions represent the steps of distributed duplication processes which propagates into the net. Hence, when two muxes face, we have to recognize if they represent two fronts of the same process which met or if they are agents of two diﬀerent processes. We can then distinguish two cases: 1. the annihilating interaction when the muxes are complementary;
46
3. THE π INTERACTIONS
n+q1 n+qi n+qk
a1 a.i a.k m
. . . .
n ?
:: :: :: nh
n1 :: :: :: n
j
m nj
j = 1; : : :; k
: : . . nh+q1 a.k m : : : : a1 . : . n+qi a.i ? ni +qj . : . a.k m : : : : n1+qk a1 . . : a.i : nj +qknh+qi . . a.k m ? n+qk nh +qk
n+q1
?
n1 +q1 a1 . nj +q1 n1+qi a.i .
n1 : : : : : nj : : : : : nh
Figure 1. The mux propagation rule.
2. the swapping interaction when the two muxes have diﬀerent thresholds. 1.3.1. Muxes annihilation. When the thresholds are equal the two muxes correspond to the same process and their facing indicates the completion of the corresponding tasks. The corresponding annihilating interaction is drawn in Figure 2, in which we see that as a result of the completion of their tasks the two muxes are removed from the structure.
n+q1 n+qi n+qk
a1 ai ak m
. . . . . .
m a1 n+q1 n ai ak
. . . . . .
n+q1 n+qi n+qk
n+q1 n+qi n+qk
n+qi n+qk
Figure 2. Annihilating interaction.
1. INTERACTIONS OF MUXES
47
Remark 1.3. The picture of the annihilating interaction points out that to apply the rule the muxes have to be complementary, i.e., not only the thresholds must be equals, but also their cardinalities and their oﬀsets must coincide. 1.3.2. Muxes swap. The case of two muxes with diﬀerent thresholds correspond to the situation in which the muxes denote the facing of the fronts of two diﬀerent processes propagating in opposite directions. Consequently, the two processes have to continue swapping the muxes. The rewriting corresponding to the swapping interaction is given in Figure 3 (we draw the binary case only), which points out that the thresholds of the new instances of the mux e2 (the one with the higher threshold) are lifted by the oﬀset of the auxiliary ports of the copies of e1 (the mux with the lower threshold) to which they are connected.
m2+q1 n+q1 n+q2 a1 a2 m2 m1 n b1 b2 n+p1 n+p2 m2+q1 n+q2 n+q1
n+q1 +p1 b1 b2 n+q1 +p2
a1 a2
n+p1 m1
m1 < m2
b1 n+q2 +p1 b2 n+q2 +p2
a1 a2
n+p2 m1
Figure 3. Swapping interaction. Remark 1.4. The lifting of the threshold m2 ensures the soundness of the rule. In fact, m1 < m2 < n and pi ≥ −1 implies m1 < n + pi, for i = 1, 2. 1.4. The absorption rule. The intended interpretation of the m parameter of a mux as a threshold applies to the case of the mux propagations too, assuming that the level of the interacting link is the level of its principal door w.r.t. the redex. The constraint that the level of a mux has to be lower than the one of its principal door explains why it is always the second link e⋆ the one which is lifted, but forces the introduction of the proviso on the levels of the auxiliary doors. In fact, when the side condition fails, the corresponding auxiliary door of e⋆ is a door link of the box in which e has to propagate. Then, propagating through this door, the mux would exit its scope. For the sake of simplicity, let us start with the case in which e is a lift (see Figure 4). We see that e crosses the link e⋆ exiting from the ports at which the
48
3. THE π INTERACTIONS
ni n+q a n ? m n+q nj
?
ni +q m nj
a
ni
ni > m nj m
Figure 4. Absorption rule. proviso holds (m < ni), but disappearing “absorbed” by the corresponding port at the doors where the proviso fails (m ≥ nj). When e is a kmux, with k > 1, the absorption creates k new instances of the absorbing ports (one for each of the new instances of e⋆ ) which are not connected to any instance of e . Consequently, since in the initial conﬁguration such ports were all connected to the same door, to avoid the presence of dangling connections we have to contract them into a unique arrow (by a link, or whatever replaces it) as drawn in Figure 5.
n+q1 n+q2
ni a1 a2 m n ? nj
ni +q1 n+q1 n+q2
? ?
a1 a2 ni +q2 nj
ni m
ni > m nj m
nj
nj
Figure 5. Absorption rule: binary case.
2. Deadlockfree structures The task of a mux completes either by an annihilation with a complementary mux, or by an absorption from an auxiliary port. From this point of view, any situation in which a πredex cannot be contracted has to be seen as a deadlock due to an error in the construction of the sharing structure.
2. DEADLOCKFREE STRUCTURES
49
Definition 2.1 (deadlock). A π redex which cannot be contracted is said a deadlock. The primary case of deadlock is a pair of not complementary muxes with the same principal door the threshold of which are equal. In fact, as we already pointed out, such a pair of facing muxes had to correspond to a pair of operators originated by the same box rewriting and then such muxes had to be complementary—not only with the same threshold, but with the same set of port names and oﬀsets too. Another case of deadlock arises when a mux e reaches a pdl ep having a value of the threshold equal to the level of the external doors of ep. In terms of our interpretation, such a conﬁguration would mean that the mux has reached the ¯ border of its scope. Namely, let Bp be the box of the pdl ep whose interaction ¯ ¯ created the mux e . The interaction involving Bp replaced ep with the mux ¯ e whose scope was the interior of Bp. Hence, each mux e originated by the ¯ propagation of e had to complete its task either annihilating with another mux or absorbed by an adl of Bp, that is, it cannot face a pdl ep whose conclusion is ¯ at the same level of its threshold (the pdl of Bp was erased creating e , besides). Consequently, the presence in an sℓstructure of a conﬁguration of the previous kind denotes an error in the construction of the structure. In particular, in our relevant cases, such a deadlock presents when a mux with threshold m reaches: • the right door of an @ link the conclusion of which is at level m, in the case of the λcalculus; • the premise of an ! link the conclusion of which is at level m, in the case of the proof nets. Definition 2.2 (deadlockfree sℓstructure). An sℓstructure G is deadlockfree when: 1. no root of G is the principal door of a mux; 2. G does not contain deadlock; 3. any π contractum of G is deadlockfree. Remark 2.1. The π normalform (if any) of a deadlockfree sℓstructure G does not contain muxes. In fact, Deﬁnition 2.2 not only excludes the presence of deadlocks, but also forbids that a mux might reach a root of a deadlockfree sℓstructure.
50
3. THE π INTERACTIONS
The previous deﬁnition of deadlockfree sℓstructures does not give any insight on their characterization: according with it we had no other way to see if an sℓstructure is deadlockfree that reducing it. The algebraic semantics of Chapter 4 will give us a characterization of deadlockfreeness for the relevant cases in which the π interaction are normalizing. Remark 2.2. By deﬁnition of deadlock, a conﬁguration as the one of Figure 6 may appear in a deadlockfree sℓstructure iﬀ a = b and p = q.
n1+q
a
n1 m m
b
n1+p
?
n+p
b
n1+q
m
n
a
m
n1
?
n2 +p n n1+q
?
n2+p
b
n2 m
m<n
n2+p b n2 m m a
n+q
a
m
n
n2+q
Figure 6. Critical pairs for the π rule (I).
3. Muxes permutation equivalence The lack of a unique principal port of the links leads to the loss of the locally conﬂuence of the system. The problem concern with the critical pairs on the left sides of Figure 6 and Figure 7 (we have drawn the pictures using lifts but the cases generalize in the natural way) that, as shown by the structures on the corresponding right sides, both reduce in two diﬀerent unconvertible ways (unless to choice particular values for the parameters of the lifts). The case of Figure 6 does not require any special treatment. In fact, such a critical pair is locally conﬂuent iﬀ a = b and p = q. But, how seen in the previous section, this is the only case allowed in a deadlockfree structure.
3. MUXES PERMUTATION EQUIVALENCE
51
m2+q b n1+q m1 m1 n1
?
n1+p+q
?
n+q+p
a
n+p m1
b
n1+q
m2
n
a
n2 +p n
a
n2+p+q
n2+p
b
n2 m2
m2+q b n1+q m1 n2 +p
n1+p+q
?
m1 < m2 < n; n1
a
n+q+p
b
n+q n a m1 m2+q
n2+p+q
Figure 7. Critical pairs for the π rule (II). The case of Figure 7 has instead a less direct solution. In fact, in order to ensure its conﬂuence, the system might be extended (KnuthBendix completed) to get a reduction between the pair of structures on the right side of Figure 7, and the shortest way to do it would be orienting the equivalence of Figure 8, e.g., choosing that a sequence of two lifts as the ones on the rightest arrows of Figure 7 permute when the right mux has a threshold greater than the left one.
n+q1 +p1 n+q1 +p2
a1 a2
m1
n+p1 b1 b2 m
n+q1 +p1 n+q1 +p2
2
b1 b2
m2 +q1 n+q1 a1 a2 n
n n+q2 +p1 n+q2 +p2
n+q2 +p1 n+q2 +p2
a1 a2
m1
m1
n+p2
m1 < m2
b1 n+q2 b2 m +q 2 2
Figure 8. Permutation equivalence. To avoid the choice of such an orientation, we prefer instead to solve the problem of the local conﬂuence treating the equivalence of Figure 8 as a permutation rule equating structures modulo permutation of muxes.
52
3. THE π INTERACTIONS
Fact 3.1 (local conﬂuence). The π interactions are locally conﬂuent (up to muxes permutations) on the deadlockfree sℓstructures. Proof. By the latter considerations on critical pairs. 4. Simulation lemma Of particular interest in the next chapters will be the sℓstructures having an instance which we know to be deadlockfree. The relevance of such sℓstructures follows from the fact that for them the simulation lemma holds, i.e., that for any π contraction r and any smorphism M there are a π reduction ρ and an smorphism M1 closing the following commuting diagram: G M U ρ
+
r
G1 M1 U1
Lemma 4.1 (simulation lemma). Let U be a deadlockfree uℓstructure and let M : U → G be an smorphism. For any π contraction r : G π G1 there + exist a corresponding nonempty reduction ρ : U π U1 and an smorphism M1 : U1 → G1.
Proof. We can distinguish two cases depending if the principal doors of any pairs of lifts e ′ , e ′′ s.t. M(e ′ ) = M(e ′′ ) = e are distinct redexes, or not. In the ﬁrst case M−1(r) does not contain critical pairs and the reduction ρ is any of the possible ordered sequences of the set of redexes M−1(r). In the second case, ¯ M−1(r) contains a critical pair for any pair of distinct redexes r ′ = e ′ (v ′ )πe and ′′ ′ ′′ ′′ ′′ ¯ r = e (v )πe s.t. M(v ) = M(v ) = v. The corresponding conﬁguration is the one of Figure 6. Both e ′ and e ′′ have the same threshold (the one of e ), but since U is deadlockfree we also have a = b and p = q. The lifts e ′ and e ′′ ¯ could not be the only ones forming a πredex with e. So, let R be the set of all such redexes, we associate to them a onestep reduction corresponding to moving ¯ the lifts from the principal door of e (w.r.t. to R) to its auxiliary doors (note that such a onestep reduction correspond to a correct π reduction). The redexes R ′ we obtain for the rewriting system using such a onestep reduction are independent. The reduction ρ is one of the possible reduction obtained by reducing the redexes
4. SIMULATION LEMMA
53
R ′ in any order and replacing each redex of R ′ by a correspondent sequence of standard π interactions. In both the cases, the smorphism from U1 to G1 is the natural one deﬁnable stepbystep during the reduction, mapping each image of a lift created by a π interaction to the image of the corresponding mux.
54
3. THE π INTERACTIONS
CHAPTER 4
Algebraic semantics
In this chapter we develop the algebraic material useful for the semantical interpretation of the sℓstructures. The inverse semigroup LSeq∗ which we present follows the line of Danos and Regnier’s study and is tightly correlated to the algebra they propose in [DR93]. Even if, here we are interested in a slightly diﬀerent problem: How to be able to know the level an arrow will get in the readback of a shared structure. The idea is to interpret each link of a uℓstructure as a set of equations between suitable weights assigned to its doors. Weights which are sequences of operators corresponding to the lifts that have to cross the link before the π normalform is reached. A “solution” of a structure is a map that assigns to each arrow a lifting sequence in accord with the constraints given by the links. A model for the lifting sequences is then obtainted interpreting them as oﬀset functions (see subsection 1.5) that, when assigned to an arrow, are able to compute the actual value any level would have in that point at the end of the computation. Such a model is however too poor and it does not suﬃce to prove all the properties of structures that are instead captured using the material introduced in the ﬁrst part of the chapter (section 1). The chapter ends with the explanation of the general method by which to ﬁnd the solution of a structure (section 3). The results developed for the uℓstructures are extended to the sℓstructures exploiting the connection between unshared and shared structures given by the smorphisms. In particular, in Chapter 5 we will show that by the semantics developed here we are able to characterize the deadlockfree sℓstructures and to ﬁnd the readback of them without actually computing it.
1. Lifting sequences Definition 1.1 (lifting operator). A lifting operator over the domain D is an indexed transformation L[m, q, a] of D, with m, q, a ∈ Z, and m ≥ 0, q ≥ −1.
55
56
4. ALGEBRAIC SEMANTICS
The index m is the (lifting) threshold of the operator, the index q is its (lifting) oﬀset, and the index a is its port name. The lifting operators accord to the following axioms: (LO1) (L[m, q1, a1](d1) = L[m, q2, a2](d2)) ⇒ (q1 = q2 ∧ a1 = a2 ∧ d1 = d2) (LO2) L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2] (L[m1, q1, a1](d1) = L[m2, q2, a2](d2)) ⇔ ∃(d)(L[m2 + q1, q2, a2](d) = d1 ∧ L[m1, q1, a1](d) = d2)
(LO3)
provided that m1 < m2.
Remark 1.1 (canonical form). By iterated application of LO2, each product of lifting operators H = 0<i≤k L[mi, qi, ai] (where H = k is the length of the product) is equivalent to a (unique) product in canonical form with the thresholds nondecreasing ordered, i.e., with mi ≤ mj if i < j. Definition 1.2 (lifting sequence). A lifting sequence from n0 to n1, with n0 ≤ n1, is a product of lifting operators H=
0<i≤k
L[mi, qi, ai]
in which n0 ≤ mi < n1 +
0<j<i
qj,
for i = 1, 2, . . . , k. Definition 1.3 (LSeq[n0, n1]). The set LSeq[n0, n1] is the family of the lifting sequences from n0 to n1. Remark 1.2. The notation of Deﬁnition 1.3 extends to the case in which n1 = ω assuming LSeq[n0, ω] = Remark 1.3. By Deﬁnition 1.2, LSeq[n0, n1] ⊆ LSeq[m0, m1] if m0 ≤ n0 and n1 ≤ m1.
def n1 ≥n0
LSeq[n0, n1].
1. LIFTING SEQUENCES
57
Definition 1.4 (global oﬀset). The global oﬀset Q(H) of a lifting sequence H = 0<i≤k L[mi, qi, ai] is the sum of the oﬀsets of its lifting operators, i.e., (Q) Q(H) =
def 0<i≤k
qi.
Fact 1.1. The global oﬀset is s.t. n1 + Q(H) ≥ n0 for any H ∈ LSeq[n0, n1]. Proof. Let H = H ′ L[m, q, a] ∈ LSeq[n0, n1]. In order to have n0 ≤ m < n1 + Q(H ′ ), it is necessary that Q(H ′ ) + n1 > n0 and then, since q ≥ −1, we have Q(H) + n1 ≥ n0. Fact 1.2. For any H0 and H1 in canonical form, H0 H1 ∈ LSeq[n0, n1] iﬀ H0 ∈ LSeq[n0, n1] and H1 ∈ LSeq[n0, n1 + Q(H0)]. Proof. By inspection of Deﬁnition 1.2. Definition 1.5 (LSeq). The set LSeq is the monoid of all the lifting sequences. Namely, of all the ﬁnite products of lifting operators, i.e., LSeq = LSeq[0, ω]. The deﬁnition of the LSeq families is sound w.r.t. the equivalence induced by the axioms. As is proved by the next facts. Fact 1.3. Let m1 < m2. L[m1, q1, a1] L[m2 + q1, q2, a2] ∈ LSeq[n0, n1] iﬀ L[m2, q2, a2] L[m1, q1, a1] ∈ LSeq[n0, n1]. Proof. Let n0 ≤ m1 < n1 and n0 ≤ m2 + q1 < n1 + q1. Since n0 ≤ m1 < m2 < n1, we get n0 ≤ m2 < n1 and n0 ≤ m1 < n1 + q2. Conversely, when n0 ≤ m2 < n1 and n0 ≤ m1 < n1 + q2, we get immediately n0 ≤ m1 < m2 < n1 and n0 ≤ m2 + q1 < n1 + q1.
def
58
4. ALGEBRAIC SEMANTICS
Fact 1.4. Let m1 < m2. H0 L[m2, q2, a2] L[m1, q1, a1] H1 ∈ LSeq[n0, n1] iﬀ H0 L[m1, q1, a1] L[m2 + q1, q2, a2] H1 ∈ LSeq[n0, n1]. Proof. It is an immediate corollary of Fact 1.3 and Fact 1.2. Definition 1.6 (lifting by the oﬀset). Let H = 0<i≤k L[mi, qi, ai] be a lifting sequence and let r be an integer s.t. mi + r ≥ 0, for i = 1, 2, . . . , k. The lifting of H by the oﬀset r is the lifting sequence (H r) H
r def
=
L[mi + r, qi, ai].
0<i≤k
Fact 1.5. Let H0 ∈ LSeq[n0, n1], and H1 ∈ LSeq[n1, n2]. We have that: 1. H1H0 ∈ LSeq[n0, n2]; Q(H ) 2. H1H0 = H0H1 0 . Proof. The ﬁrst item is a consequence of Remark 1.3, Fact 1.1, and Fact 1.2. In fact, by n2 + Q(H1) ≥ n1 ≥ n0, we see that H0 ∈ LSeq[n0, n2 + Q(H1)] and H1 ∈ LSeq[n0, n2]. The second item is instead proved by induction on the length of H0 and H1. ′ In fact, when H0 = L[m1, q1, a1]H0, we see that H1H0 = L[m1, q1, a1] H1q1 H0, where m1 ≤ n1. 1.1. Left inverses of lifting operators. The lifting operators are injective (axiom LO1). Hence, each L[m, q, a] has a left inverse L[m, q, a]. Such an inverse is however not unique in general, since it may assume any value outside of the codomain of L[m, q, a]. Anyhow, if we consider partial functions too, we may deﬁne the left inverse F ∗ of a partial transformation F as the less deﬁned partial transformation s.t. F F ∗ F = F , i.e., s.t. dom(F ∗ ) = codom(F ) and F ∗ (F (d)) = d, for any d ∈ dom(F ). In particular, for the lifting operators the latter assumption gives d when d ∈ codom(L[m, q, a]) and d = L[m, q, a](d) ¯ ¯ def (L) L[m, q, a](d) = ⊥ when d ∈ codom(L[m, q, a]) / where L[m, q, a](d) =⊥ is just a denotation for d ∈ dom(L[m, q, a]). /
1. LIFTING SEQUENCES
59
The previous reasoning generalizes to lifting sequences. In fact, lifting sequences too, as composition of injective functions, are injective transformations, and then lifting sequences too are left invertible. In particular, the left inverse of a product of lifting sequences is (L[m1, q1, a1] · · · L[mk, qk, ak])∗ = L[mk, qk, ak] · · · L[m1, q1, a1] assuming L[m, q, a]∗ = L[m, q, a]. The lifting operators and their left inverses form a monoid LSeq∗ of injective partial transformations of D closed under left inversion. The lifting operator axioms can be reformulated in terms of left inverses properties. For instance, the axiom LO1 becomes: Fact 1.6. For any threshold m, L[m, q, a] L[m, q, a] = 1 L[m, q2, a2] L[m, q1, a1] = 0 when q1 = q2 or a1 = a2. Proof. Let d1 ∈ dom(L[m, q2, a2] L[m, q1, a1]). By the deﬁnition of left inverse there exists d s.t. d = L[m, q2, a2](d) = L[m, q1, a1](d1), which by LO1 implies q1 = q2 and a1 = a2. The axiom LO3 becomes instead: Fact 1.7. For any pair of lifting operators, we have that L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2] when m1 < m2. Proof. Let us use the notations H1 = L[m2, q2, a2] L[m1, q1, a1] for the ﬁrst product and H2 = L[m1, q1, a1] L[m2 + q1, q2, a2] for the second one. We see that d1 ∈ dom(H1) with d2 = H1(d1) iﬀ d2 ∈ dom(L[m2, q2, a2]) and L[m1, q1, a1](d1) = L[m2, q2, a2](d2), which (by LO3) is true iﬀ there exists d s.t. L[m1, q1, a1](d) = d2 and L[m2 + q1, q2, a2](d) = d1, and then iﬀ d1 ∈ dom(H2) with d2 = H2(d1). Remark 1.4. Both the permuting equations of axiom LO3 and Fact 1.7 have a dual obtained applying the involution operator to the left and right sides. The
60
4. ALGEBRAIC SEMANTICS
complete set of the permuting equations is then: L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2] L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2] L[m1, q1, a1] L[m2, q2, a2] = L[m2 + q1, q2, a2] L[m1, q1, a1] L[m1, q1, a1] L[m2, q2, a2] = L[m2 + q1, q2, a2] L[m1, q1, a1] where m1 < m2. 1.2. The inverse semigroup LSeq∗ . An axiomatization of LSeq∗ may be given in terms of the inverse semigroup axioms. Definition 1.7 (inverse semigroup). An inverse semigroup M with 0 is a monoid with a null element (i.e., with an element 0 s.t. for any F , 0F = 0 = F 0) which is closed under an involution operation (·)∗ s.t., for any F , F1, F2 ∈ M , F ∗∗ = F
∗ ∗ (F1F2)∗ = F2 F1
F F =F F1 F2 = F2 F1 where F ≡ F F ∗. The axioms of inverse semigroups allow to immediately prove that: 1. Each F is invariant under involution and is an idempotent of M , i.e., F
∗
= F
F F = F since F F = F F F ∗ = F F ∗ = F . 2. Each idempotent of LSeq∗ may be written as F for some F and is then invariant under involution, i.e., FF =F FF =F ⇒ F =F F∗ = F
since, if F F = F , then F = F F = F F ∗ = F ∗ F = F ∗ F = ( F F )∗ = F ∗ , and then F = F . Which in particular implies 1∗ = 1 and 0∗ = 0.
⇒
1. LIFTING SEQUENCES
61
Definition 1.8 (LSeq∗ ). The inverse semigroup LSeq∗ is the smallest inverse semigroup generated by the family of the indexed symbols L[m, q, a] and of their left inverse symbols L[m, q, a] (being m ≥ 0 and q ≥ −1) according to the axioms (LS0) (LS1) (LS2) (LS3) (LS4) L[m, q, a]∗ = L[m, q, a] L[m, q, a] L[m, q, a] = 1 L[m, q2, a2] L[m, q1, a1] = 0 if q1 = q2 or a1 = a2
L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2] L[m2, q2, a2] L[m1, q1, a1] = L[m1, q1, a1] L[m2 + q1, q2, a2]
when m1 < m2. The monoid LSeq is instead the smallest monoid LSeq ⊂ LSeq∗ containing the indexed symbols L[m, q, a] (for any m ≥ 0 and q ≥ −1) and closed by composition. By the way, because of the properties already shown for the lifting operators, the intended interpretation of LSeq∗ is as the monoid generated by the lifting operators and by their left inverse partial functions. In such a case it is readily seen that: 1. The 0 is the nowhere deﬁned partial transformation of D. 2. Any idempotent F of LSeq∗ is the identity map restricted to the codomain of F , i.e., dom( F ) = codom(F ). 3. For any H ∈ LSeq we have that H∗ H = H∗ = 1, since codom(H∗ ) = dom(H) = D. Fact 1.8 (canonical form). Let F ∈ LSeq∗ . F = 0 implies for some H+, H− ∈ LSeq. Proof. By induction on F . The case F  = 0 and the case F = L[m, q, a] F1 (just apply the induction hypothesis) are direct. So, let us take F = L[m, q, a] F1. ∗ By the induction hypothesis, we get F = L[m, q, a] H+H−, with H+, H− ∈ LSeq. Let H+ = L[m1, q1, a1] · · · L[mk, qk, ak] be in canonical form, and let h be the ﬁrst index for which m+Qi ≥ mh (where Qi = Σi<hqi) or let h = k+1 if such an index does not exist. Let H = H0H1 with H0 = L[m1, q1, a1] · · · L[mh−1, qk−1, ak−1]. If mh = m + Qi, we have either qh = q and ah = a, or not. In the ﬁrst case
∗ F = H+H−
62
4. ALGEBRAIC SEMANTICS
L[m, q, a]H+ ∈ LSeq, in the second L[m, q, a]H+ = 0 and then H = 0. When ∗ mh > m + Qi instead, we see that H = H0H1qL[m + Qi, q, a] H−. Remark 1.5 (canonical form). Also the elements of LSeq∗ can then be written in canonical form assuming that both H+ and H− of Fact 1.8 are canonical. Fact 1.9. Let H+, H− ∈ LSeq. We have that
∗ H+ H− = 1
iﬀ
H+ = H− = 0
for any possible way to write H+ and H− as a product of lifting operators. Proof. Let us assume H+ = L[m, q, a] H ′. For any pair q ′ , a ′ s.t. q = q ′ or ∗ a = a ′ , we would get 1 = L[m, q ′ , a ′] H+ H− L[m, q ′, a ′] = 0. Hence, H+ = 0, etc. Remark 1.6. The latter proof assumes that 1 and 0 have always distinct interpretations. Otherwise, we could reformulate the lemma saying: The only model in which Fact 1.9 does not hold is the trivial one. The same reasoning apply to the uniqueness of the canonical form proved by the next fact. Lemma 1.1. For any pair H1, H2 ∈ LSeq: H1 = H2 iﬀ H1 = H2.
∗ ∗ ∗ Proof. Let H+ H− be a canonical form of H1 H2. We have 1 = H1 H1 H1 = ∗ ∗ ∗ ∗ ∗ ∗ H1 H2 H1 = H1 H2 (H1 H2)∗ = H+ H− H− H+ = H+H+. From which, we see (by Fact 1.9) that H+ = 0. In an analogous way we see that H− = 0 and then that ∗ H1 H2 = 1. Hence, H2 = H2 H2 = H1 H2 = H1.
Proposition 1.1. Two elements of LSeq∗ are equal iﬀ their canonical forms coincide.
∗ ∗ Proof. Let H+H− and H+H− be two canonical forms of F ∈ LSeq∗ . We have H+ = F = H+ . Then, by Lemma 1.1 H+ = H+. From which, H− = H− too. Hence, we may restrict to show the uniqueness of the canonical form of a lifting sequence. The case of 1 is already proved by Fact 1.9. So, let us assume that L[m1, q1, a1] H1 = L[m2, q2, a2] H2 are both in canonical form. Let us assume w.l.o.g. that m1 ≤ m2. If m1 < m2, then H1 = L[m2 + ′ ′ q1, q2, a2] H2q1 L[m1, q1, a1], that leads to the contradiction H1L[m1, q1, a1] = 0 ′ ′ when q1 = q1 or a1 = a1. Hence, the only possibility is m1 = m2, and then also q1 = q2 and a1 = a2. In conclusion, from the initial canonical forms we have got
1. LIFTING SEQUENCES
63
two shorter equivalent ones H1 = H2. So, by induction we see that H1 and H2 coincide, etc. 1.3. LSeq lower semilattice. Definition 1.9 (LSeq partial order). The lifting sequences are partially ordered by the binary relation: (⊑) H1 ⊑ H2 when H2 = H1H,
for some lifting sequence H ∈ LSeq. The partial order is welldeﬁned. In fact, • the reﬂexivity: H = H1; • the transitivity: H0 ⊑ H1 ⊑ H2 implies H1 = H0 H and H2 = H1 H0 H; ∗ • the antisymmetry: H2 = H1 H and H1 = H2 H ′ implies 1 = H1 H1 = ∗ ∗ H1 H2 H ′ = H1 H1 H H ′ = H H ′ and then H = H ′  = 0 (by Fact 1.9). Fact 1.10. Let H1, H2 ∈ LSeq. We have that H1 ⊑ H2 iﬀ
∗ H1H2 ∈ LSeq.
∗ Proof. Let H = H1H2 ∈ LSeq. We have H2 = H2 H∗ H = H2 H1 H2 = H1 H2 H2 = H1 H2 = H1 H, and then that H1 ⊑ H2. The converse is immediate. ∗ Corollary 1.1. Let H1, H2 ∈ LSeq, if H1H2 ∈ LSeq then H2 = H1H for some H ∈ LSeq.
Definition 1.10 (meet). Let H1, H2 be two lifting sequences L[m, q, a](H ′ ⊓ H ′ ) if H = L[m, q, a]H ′, for i = 1, 2 i def 1 2 i H1 ⊓ H2 = 1 otherwise
(⊓)
′ Remark 1.7. The meet is welldeﬁned. In fact, when Hi = L[m1, q1, a1]Hi = ′′ ′ ′′ L[m2, q2, a2]Hi , for some Hi, Hi ∈ LSeq and i = 1, 2:
1. m1 = m2 implies q1 = q2 and a1 = a2;
64
4. ALGEBRAIC SEMANTICS
′′′ 2. m1 < m2 implies (by Corollary 1.1) that there exists Hi ∈ LSeq s.t. ′ ′′′ ′′ ′′′ Hi = L[m2 + q1, q2, a2]Hi and Hi = L[m1, q1, a1]Hi . Hence, ′ ′ L[m1, q1, a1](H1 ⊓ H2) ′′′ ′′′ = L[m1, q1, a1]L[m2 + q1, q2, a2](H1 ⊓ H2 ) ′′′ ′′′ = L[m2, q2, a2]L[m1, q1, a1](H1 ⊓ H2 ) ′′ ′′ = L[m2, q2, a2](H1 ⊓ H2 )
′ ′ Fact 1.11. Let H0, H0 ∈ LSeq[n0, n1] and H1, H1 ∈ LSeq[n1, n2]. We have ′ ′ ′ ′ that H1H0 ⊓ H1H0 = (H1 ⊓ H1)(H0 ⊓ H0).
Proof. By inspection of the deﬁnition of meet. Fact 1.12. The sets LSeq and LSeq[n0, n1] are lower semilattices for the lifting sequence partial order. Proof. The least element of LSeq and of LSeq[n0, n1] is the empty lifting ′ sequence 1, and the meet is the one of Deﬁnition 1.10. To prove that: Hi = HHi, for i = 1, 2, implies H ⊑ H1 ⊓ H2, for any H, H1, H2 ∈ LSeq, let us note that ′ ′ H1 ⊓ H2 = H(H1 ⊓ H2) (by induction on H). 1.4. Lifting sequence sections. Fact 1.13. For any integer n ≥ 0, there is a unique sectioning of H (w.r.t. the level n) in two lifting sequences H<n ∈ LSeq[0, n] and H≥n ∈ LSeq[n, ω] s.t. H = H≥nH<n. Proof. Let H = L[m1, q1, a1] · · · L[mk, qk, ak] ∈ LSeq[n1, n2] be in canonical form. Let h be the ﬁrst index for which n + Qi ≥ mi (where Qi = Σi<hqi), or let h = k + 1 otherwise, i.e., ∀i < k : Let us take H<n = L[m1, q1, a1] · · · L[mh−1, qk−1, ak−1] and H≥n = L[mh − Qh, qh, ah] · · · L[mk − Qh, qk, ak]. By deﬁnition, H<n ∈ LSeq[0, n] and H≤n ∈ LSeq[n, ω]. The deﬁnition of H<n and H≥n also proves their uniqueness.
def def
mi < n + Qi.
1. LIFTING SEQUENCES
65
The H<n factor of H is the lower section of H (w.r.t. to level n), while H≥n is its upper section. Fact 1.14. For any H ∈ LSeq[n1, n2] and any n. 1. The lower section of H w.r.t. n is s.t. H<n = 1 H<n ∈ LSeq[n1, n] H<n = H 2. The upper section of H w.r.t. n is s.t. H≥n = H H≥n ∈ LSeq[n, n2] H≥n = 1 when n ≤ n1 when n1 ≤ n ≤ n2 when n2 ≤ n when n ≤ n1 when n1 ≤ n ≤ n2 when n2 ≤ n
Proof. By inspection of the deﬁnitions of H<n and of H≥n. Lemma 1.2. Let H ∈ LSeq. We have that (H<n1 )<n2 = (H<n2 )<n1 = H<n1 (H≥n1 )≥n2 = (H≥n2 )≥n1 = H≥n2 (H≥n2 H<n2 )≥n1 = H≥n2 (H<n2 )≥n1 (H≥n1 H<n1 )<n2 = (H≥n1 )<n2 H<n1 for any pair of levels n1 ≤ n2. Proof. By inspection of how the sections are constructed in the proof of Fact 1.13. Fact 1.15. Let H ∈ LSeq. We have that (H≥n1 )<n2 = (H<n2 )≥n1 for any pair of levels n1 ≤ n2. Proof. By Lemma 1.2 we get H = H≥n2 H<n2 = H≥n2 (H≥n1 )<n2 H<n1 , with H≥n2 (H≥n1 )<n2 ∈ LSeq[n1, ω]. Hence, by Fact 1.13 H≥n2 (H≥n1 )<n2 = H≥n1 . But applaying again Lemma 1.2, we also see that H≥n1 = (H≥n2 H<n2 )≥n1 = H≥n2 (H<n2 )≥n1 .
66
4. ALGEBRAIC SEMANTICS
Definition 1.11 (section). The section of H between n1 and n2 (where n1 ≤ n2) is the lifting sequence from n1 to n2 H[n1 ,n2 ] = (H≥n1 )<n2 . Remark 1.8. By Fact 1.15 we know that while computing H[n1 ,n2 ] the order in which we take the lower and upper sections is not relevant, i.e., we also have H[n1 ,n2 ] = (H<n2 )≥n1 . Furthermore, by Fact 1.14, we are also sure that H[n1 ,n2 ] ∈ LSeq[n1, n2]. Notation 1.1. For any pair n1 ≤ n2 we use the convention to denote by H the inverse of the section of H between n1 and n2, i.e.,
[n2 ,n1 ] def
H[n2 ,n1 ] = (H[n1 ,n2 ])∗ when n1 ≤ n2. Fact 1.16. Let H ∈ LSeq. We have that H[n1 ,n2 ] = H[n,n2 ] H[n1 ,n] for any level n s.t. min(n1, n2) ≤ n ≤ max(n1, n2). Proof. If n1 ≤ n2, then H[n1 ,n2 ] = ((H≥n1 )<n2 )≥n((H≥n1 )<n2 )<n = ((H<n2 )≥n1 )≥n(H≥n1 )<n = (H<n2 )≥n(H≥n1 )<n = H[n,n2 ] H[n1 ,n]. Otherwise, if n2 ≤ n1, then H[n1 ,n2 ] = (H[n2 ,n1 ])∗ = (H[n,n1 ] H[n2 ,n])∗ = (H[n2 ,n])∗ (H[n,n1 ])∗ = H[n,n2 ] H[n1 ,n].
def
1.5. The oﬀset function. Definition 1.12 (oﬀset function). Let H = 0<i≤k L[mi, qi, ai] be a product of lifting operators. The oﬀset function ∆(H) : Z → Z of H is inductively deﬁned by ∆(1) = id ∆(L[m, q, a] H) = δm,q(∆(H))
def def
1. LIFTING SEQUENCES
67
where
Remark 1.9. From such a deﬁnition it is readily seen that, for any product H = 0<i≤k L[mi, qi, ai], assuming δ(H) = δm1 ,q1 δm2 ,q2 · · · δmk ,qk we have that ∆(H) = δm1 ,q1 δm2 ,q2 · · · δmk ,qk (id ) and then that, for any H1, H2 ∈ LSeq, ∆(H1 H2) = δ(H1)δ(H2)(id ) since by deﬁnition δ(H1 H2) = δ(H1)δ(H2). The integer lifting functionals have a commutative property analogous to the one of lifting operators, which is indeed a proof of the soundness of Deﬁnition 1.12 w.r.t. the equivalence that the axiom LO3 induces on LSeq. Fact 1.17. For any q1, q2 ≥ −1, δm2 ,q2 δm1 ,q1 = δm1 ,q1 δm2 +q1 ,q2 when m1 < m2. Proof. For any integer function f, we have that: • if i ≤ m1 < m2, i ≤ m2 + q1 and δm1 ,q1 δm2 +q1 ,q2 f(i) = δm2 +q1 ,q2 f(i) = f(i) = δm1 ,q1 f(i) = δm2 ,q2 δm1 ,q1 f(i); • if m1 < i ≤ m2, then δm1 ,q1 δm2 +q1 ,q2 f(i) = δm2 +q1 ,q2 f(i +q1) = f(i +q1) = δm1 ,q1 f(i) = δm2 ,q2 δm1 ,q1 f(i); • if i > m2, then δm1 ,q1 δm2 +q1 ,q2 f(i) = δm2 +q1 ,q2 f(i + q1) = f(i + q1 + q2) = δm1 ,q1 f(i + q2) = δm2 ,q2 δm1 ,q1 f(i).
def
is an integer lifting functional δm,q : ZZ → ZZ .
f(i) def δm,q(f)(i) = f(i + q)
when i ≤ m otherwise
Remark 1.10. The oﬀset functions are nondecreasing and s.t. there exists an asymptotic oﬀset Q for which deﬁnitely f(i) = Q + i. In particular, when H ∈ LSeq[0, n], we have that f(i) = ∆(H)(n) + i, for any i > n.
68
4. ALGEBRAIC SEMANTICS
The lifting functionals are the naive interpretation of the lifting operators. In fact, we have seen by Fact 1.17 that they have a permutation equivalence analogous to the one of the lifting operators. Furthermore, they naturally explain the behavior of the lifting operators as operations on the names of the levels used in a certain point of a uℓstructure: we start with the identity map associating to the ith level its natural name i, then each application of a lifting operator L[m, q, a] (interpreted as a δm,q functional) causes the level names above m to be shifted by q positions, i.e., the new name in the ith position, for i > m, is the one that before the application was in position i + q. Anyhow, it is readily seen that in this way we loose any information on the names between m and m + q (when q > 0) and that, because of this, the lifting functionals are not invertible. The last one is the reason because of which the models of LSeq∗ have to record more informations than the simple ones contained in the lifting functionals, that is, to build a model of LSeq∗ we have to use the context introduced by Lamping [Lam89, Lam90] (see also [GAL92b, GAL92a]) or to enrich the L∗ algebra of Danos and Regnier [DR93] (see also [ADLR94]). 2. Block diagrams We now introduce a graphical language of block diagrams corresponding to lifting sequences. Any element of such a language is a transfer block : an object with two ports—its input and its output—to which it is associated a transfer function F mapping the input value d ∈ D to the output value F (d) (see Figure 1). d F F (d)
Figure 1. Transfer block. Transfer blocks may be concatenated to build diagrams according to the ﬂow direction given by the stems of the block ports, i.e., connecting the output of a block to the input of another one. Sometimes, the stem of the arrows will be omitted when the inputoutput ﬂow accords with the usual positive direction: lefttoright and uptodown. A diagram may be seen, at its turn, as a bigger block with a transfer function obtained inverse composing the ones of its components. For instance, the following concatenation F1(d) d F1 F2 F2 F1(d)
2. BLOCK DIAGRAMS
69
is equivalent to the composite block d F2 F1 F2 F1(d)
and the composite transfer function F2 F1 is also said the transfer function of the diagram. Definition 2.1 (closed connection). A block diagram is said an open connection when its transfer function is null, otherwise it is said closed. 2.1. Elementary blocks. The elementary blocks used to build diagrams are the ones whose transfer function is a lifting operator or a left inverse of a lifting operator. Such elementary blocks are the algebraic image of lifts: the positive one is the lifting operator; the negative one is its inverse (see Figure 2).
m,q
d
a
L[m, q, a](d)
d
a m,q
L[m, q, a](d)
Figure 2. Lift blocks: positive and negative. 2.2. The axioms of LSeq∗ . The axioms of LSeq∗ can be reformulated in terms of lift blocks, as draw in Figure 3. By such a ﬁgure, it is readily seen that: 1. an annihilating interaction corresponds to the axiom LS1; 2. a deadlock caused by two noncomplementary lifts with the same threshold is an open connection and models the axiom LS2; 3. a lift permutation equivalence corresponds to the axiom LS3; 4. a swapping interaction corresponds to the axiom LS4. 2.3. Gonthier’s operators. Let us consider a mux with threshold m and let ai and qi be the port and oﬀset of its ith port. In terms of fans, brackets, and croissants of Gonthier (see [GAL92b, GAL92a] and [Asp95b]) any connection between the principal port of the mux and its ith auxiliary port is a sequence of qi + 1 brackets whose indexes go from m to m + q, followed by a croissant with index m + q + 1, and preceded by a path in a tree fans going from the root to the ith leaf of the tree. The sequence of Gonthier’s nodes corresponding to such a mux connection is drawn in Figure 4, in which the tree of fans corresponding to the port with name ai has been represented by a triangle with name ai. Using the usual rewriting rules given by Gonthier1 it is readily seen that each of our mux
1
Actually the way in which we assign the indexes correspond to the one of Asperti, so the
correct comparison would be with the rules given by Asperti in [Asp95b].
70
4. ALGEBRAIC SEMANTICS
a
m;q m;q m;q2 m;q1
a
= = = =
a2 m2 +q1 ;q2 m2+q1 ;q2 a1 m1 ;q1
a1
a2
a1
m1 ;q1
a2 m2 ;q2
m2;q2
a1
m1 ;q1
a2
a2
a1
m1 ;q1
Figure 3. Block equivalences corresponding to the axioms of LSeq∗ . rewriting correspond to a rewriting sequence for the corresponding fans, brackets, and croissants.
m+qi +1

m+qi
qi +1
{z
m+1
}
m
ai
m
Figure 4. A lift in terms of Gonthier’s operators.
3. Solutions of an unshared leveled structure 3.1. Mux transfer function. As suggested by its name, in a multiplexer there is no connection between secondary ports, but only connections from a secondary and a principal port. The transfer function of any of such connections is the lifting operator L[m, qi, ai], where qi and ai are the oﬀset and the name of the auxiliary port and m is the threshold of the mux. In Figure 5 is drawn the transfer function of a mux in terms of a positive lift block. To obtain the corresponding transfer function of a negative mux just invert the orientation of the arrows, the result will obviously be a negative lift block. 3.2. Link internal state. All the links but muxes have no preferential directions, they do not have the same selective behavior as multiplexers. In fact, in such links there is a connection between any pair of ports.
3. SOLUTIONS OF AN UNSHARED LEVELED STRUCTURE
71
n+qi
ai m
n
n+qi
ai
m;qi
n
Figure 5. Transfer function of a mux connection. For any link e that is not a mux, the transfer functions corresponding to its connections depend on an internal parameter: the link internal state Se ∈ LSeq. The levels of the doors of the link ﬁx the amount of such a state observable from the outside. In fact, the transfer function of the connection between a pair of doors with level n1 and n2 is the section of Se between n1 and n2 (see Figure 6).
n
1
?
n
2
n
1
S
n ;n ] e
1
2
n
2
Figure 6. Transfer function of a link. In particular, the latter deﬁnition implies that: • The connections of an intl are identity blocks. So, the internal state of an internal node is not observable at all. • In a pdl, the only connections whose transfer function diﬀers from the identity are the ones involving its principal port. Definition 3.1 (internal state). An internal state S of an sℓstructure G is a map which assigns a lifting sequence Se to any link e of G which is not a mux. Definition 3.2 (quiescence internal state). A quiescence internal state I is an internal state which assigns the empty lifting sequence 1 to any pdl of G . Let us call pdl internal state the restriction of an internal state to the set of the pdls. An internal state is of quiescence when the corresponding pdl internal state is the identity. 3.3. Lifting sequences assignments.
72
4. ALGEBRAIC SEMANTICS
Definition 3.3 (assignment). A lifting sequence assignment H for the internal state S (Sassignment) of the uℓstructure U is a map which associates to each vertex v of U a lifting sequence Hv s.t.: 1. Hv ∈ LSeq[0, ιU(v)]; [n ,n ] 2. Hv2 = Se 1 2 Hv1 , when v1 e v2, with ⋆ = , and ni = ιU(vi), for i = 1, 2; ⋆ 3. Hv = L[m, qi, ai]Hvi , when (vi) ai e (v), m is the threshold of e, and qi = ιU(vi) − ιU(v). An internal state S of U for which there exists an Sassignment is said compatible. Remark 3.1. The second and third constraints of the previous deﬁnition are compatible with the ﬁrst one. In fact, 1. since Se 1 2 ∈ LSeq[n1, n2], we see that Se 1 2 Hv1 ∈ LSeq[0, n2], when Hv1 ∈ LSeq[0, n1] (by Fact 1.5); 2. since L[m, qi, ai] ∈ LSeq[0, ιU(v)] and Hvi ∈ LSeq[0, ιU(v) + qi], we have that L[m, qi, ai]Hvi ∈ LSeq[0, ιU(v)] (by Fact 1.2). Remark 3.2. Let n1 be the minimal level of a door of a link e and let n2 be the maximal level of a door of e. If Se is the internal state of e, the values <n ≥n of Se 1 and Se 2 are not relevant for the computation of any lifting sequences assignment. Hence, internal states may be equated modulo the parts of them which are not observable. Often, in the following, we will implicitly assume that two internal states coincide when their observable parts are equal. Remark 3.3. The internal state S includes the values of both pdls and adls (remind that the state of the intls is not observable). Anyhow, since boxes are connected substructures, the values of the states of the adls of a box depend (functionally) from the state of its internal pdls (not only the one of the box, but also the ones of the boxes nested in it). The partial order relation and the meet operation between lifting sequences extend (pointwise) to assignments of a uℓstructure U deﬁning H′ ⊑ H′ iﬀ
′ ′′ ∀v ∈ V(U) : Hv ⊑ Hv [n ,n ] [n ,n ]
and analogously for the internal states of U replacing the vertices with the links which are not muxes. Notation 3.1. For any uℓstructure U let us denote by:
3. SOLUTIONS OF AN UNSHARED LEVELED STRUCTURE
73
• HS(U ) the set of the Sassignments of U ; • H(U ) the set of all the assignments of U (for any internal state S); • H1(U ) the set of all the quiescence assignments of U (for any quiescence internal state I). Remark 3.4. As a complement of Remark 3.3 note that because of Fact 1.13 and Remark 3.2 an assignment uniquely determines its corresponding internal state, i.e., HS(U ) ∩ HS′ (U ) = ∅ iﬀ S = S ′. Fact 3.1. Let U be a uℓstructure. The sets H(U ), HS(U ), and H1(U ) are lower semilattices. Proof. By the distributivity property of meet proved by Fact 1.11, we see that H ′ ∈ HS′ (U ) and H ′′ ∈ HS′′ (U ) implies (H ′ ⊓ H ′′ ) ∈ HS′ ⊓S′′ (U ). Furthermore, the meet of two quiescence internal states is a quiescence internal state. The latter fact implies that, for any compatible state S, the set HS(U ) has a least element HS(U ): the Ssolution of U . Hence, when there exists a compatible quiescence internal state, then there exists a least quiescence assignment. Definition 3.4 (quiescence solution). The quiescence solution of U is the least quiescence assignment H1(U ). The relevance of the assignments is given by the following lemma. Lemma 3.1. Let H be an Sassignment of the uℓstructure U . 1. ιU(v) + Q(Hv) ≥ 0, for any vertex v of U ; 2. ιU(v0) + Q(Hv0 ) ≤ ιU(v1) + Q(Hv1 ), for any nonmux link e s.t v0 e v1, ⋆ with ιU(v0) ≤ ιU(v1); 3. ιU(vp) + Q(Hvp ) = ιU(va) + Q(Hva ), for any lift e with threshold m in which va is an auxiliary door connected to the port a, and vp the principal door of e, i.e., (va) a e (vp). Proof. The ﬁrst two items derive from Fact 1.1. For the third item, let ιU(va) = ιU(vp)+q. We have that ιU(vp)+Q(Hvp ) = ιU(vp)+Q(L[m, q, a] Hva ) = ιU(vp) + q + Q(Hva ) = ιU(va) + Q(Hva ). 3.4. An example of assignment. An example of sℓstructure with a quiescence solution is the IMELL ℓnet (see Chapter 7) drawn in Figure 7. Near each arrow of the ℓnet we reported (framed) the lifting sequence that the quiescence solution assigns to the arrow. Near each ? link there is instead the value of the
74
4. ALGEBRAIC SEMANTICS
ax
1 2 a2 2
!
ax
0
1
L 0;0;a2] L 0;0;a2]
0
0 1 a2
1 1 a1 2
!
ax
L 0;1;a1 ] L 0;1;a1 ]
1 0
0 a1
L 0;0;a2]
1 1
L 0;1;a1 ]
1 1
1
1 1
?
1
L 0;0;a2 ]
1 0 0 1 1 0
?
L 0;1;a1 ]
O
0 1
2 0
?
1
O
1 0
1
0
Figure 7. An example of quiescence solution. corresponding internal state (we omitted the internal states of the ! links, since in a quiescence assignment they are all equal to 1). The example also shows in detail that, in a quiescence solution, the internal states of the adls are not constrained to be equal to 1. 3.5. Proper structures. Among the uℓstructures having at least a compatible internal state, of particular relevance will be the ones for which all the quiescence internal states are compatible. In the next chapter, we will see a semantical way to associate an ℓstructure to each of them, without performing any reduction. Furthermore, we will show that the previous uℓstructures are the ones for which the π interactions have particurlarly nice properties: deadlockfreeness, strong normalization, and unique normalform. Definition 3.5 (complete unsharing). A complete unsharing M : U → G of an sℓstructure G is an smorphism between a uℓstructure and an sℓstructure
3. SOLUTIONS OF AN UNSHARED LEVELED STRUCTURE
75
in which U has a solution for any pdl internal state. The uℓstructure U is a leastsharedinstance of G . The uℓstructure in Figure 7 is proper and is the (unique) leastsharedinstance of the sℓstructure in Figure 8.
ax ax ax
2 1 a2 a1 0 2
!
1 0 a1 a2 0
1 1
?
1
0
O
0
2 0
?
O
0
0
Figure 8. An example of proper sℓstructure. Definition 3.6 (proper sℓstructure). An sℓstructure is proper when it has a complete unsharing. Hence, the sℓstructure in Figure 8 is proper. Remark 3.5 (proper uℓstructure). Any uℓstructure which has a solution for any pdl internal state is proper (then the uℓstructure in Figure 7 is proper): its complete unsharing is the identity.
76
4. ALGEBRAIC SEMANTICS
CHAPTER 5
Readback
In Chapter 3 we gave a proof (Fact 3.1) of the local conﬂuence of the π interactions up to mux permutation equivalences, but we was not able to say anything about their normalization properties. In fact, we was not able to say when the π interactions are strongly normalizing, or when the sℓstructures have a (unique) π normalform. The simulation lemma gives us a way to restrict the problem to the analysis of the unshared structures (cf. Theorem 1.1). Moreover, according to the discussion on the π interactions and exploiting the algebraic semantics, we see that there are two ways to give them a semantical interpretation: • when the uℓstructure U is deadlockfree, taking its π normalform (if any) w.r.t. the π interactions; • when U is proper, removing the lifts and using the assignments introduced in the previous chapter to compute the new levels of the arrows. The aim of the chapter is to show that the previous two interpretations coincide proving that a uℓstructure is proper iﬀ it is deadlockfree and with no inﬁnite π reduction, i.e., that the π interactions are strongly normalizing and conﬂuent to an ℓstructure (no muxes) over the proper sℓstructures. 1. Syntactical readback We already pointed out that the π normalforms of a deadlockfree sℓstructure G cannot contain muxes. It is then natural to interpret such normalforms as the semantics of G . Definition 1.1 (π readback). Let G be a deadlockfree sℓstructure. Any π normalform G π of G that does not contain muxes is said a π readback of G . Of particular relevance is the case of the uℓstructures. The topology of the readbacks of a uℓstructure U is in fact easily recoverable from the topology of U . Namely, let us denote by · the forgetful map associating to a uℓstructure U the ℓstructure U obtained by:
77
78
5. READBACK
1. Forgetting the levels of the arrows. 2. Removing all the lifts. 3. Merging into a unique arrow the principal and auxiliary doors of any lift. Fact 1.1. The ℓstructure U is invariant under π interactions. Proof. By inspection of the π interactions (remind that a uℓstructure does not contain erasers). Corollary 1.1. The readbacks (if any) of a deadlockfree uℓstructure coincide up to the nesting levels assignment map. Proof. The π normalforms of a deadlockfree uℓstructure do not contain muxes. Hence, the conclusion follows from the invariance stated by Fact 1.1. Remark 1.1 (uniqueness of the readback). The π interaction rules does not change the levels of the roots of a uℓstructure. Besides, for the relevant cases of our study the levels assigned to an ℓstructure of the calculus (a λℓterm of the λcalculus or an ℓnet of linear logic) are uniquely determined by the levels of their roots. Moreover, deﬁning the λℓterms and the ℓnets we will ﬁx the level of their roots to be equal to 0 (since the intended interpretation of the level of an arrow is its box nesting depth, the roots are outside any box). Hence, Fact 1.1 suﬃces to ensure that for the cases of our analysis the readback of an unshared structure is unique. Remark 1.2. The deadlockfreeness property is not suﬃcient to ensure the existence of the readback. An easy example of structure deadlockfree with an inﬁnite π reduction is given in Figure 1, where the cycle formed by the two lifts rewrites to itself giving an inﬁnite reduction sequence.
m1 a n m2 n b n
m1 a m2 n b
Figure 1. A uℓstructure that π contracts to itself. The previous results for the uℓstructures are lifted to the sℓstructures exploiting the correspondence between sharing and unshared reductions stated by the simulation lemma.
2. SEMANTICAL READBACK
79
Theorem 1.1. Let U be a deadlockfree uℓstructure that has a readback. Any sℓstructure G for which there exists an smorphism M : U → G is deadlockfree and the π interactions strongly normalize it to a unique ℓstructure, that is, the readback of G exists and is unique. Proof. In the commuting diagram of the simulation lemma for the π interactions (Lemma 4.1 of Chapter 3) the unshared π reduction ρ corresponding to a single shared contraction r is not empty. Hence, the existence of an inﬁnite π reduction of G would lead to a contradiction: the existence of an inﬁnite π reduction of U . Also the presence of a deadlock in any reduct of G would lead to a contradiction implying the presence of a deadlock in a reduct of U (see the proof of Corollary 2.2). So, the sℓstructure G is deadlockfree and (by Fact 3.1 of Chapter 3) the π interactions are locally conﬂuent on it. The Newman’s Lemma gives then the uniqueness of the π normalform of G . In particular, we will see that the hypothesis of the previous fact hold when the smorphism M : U → G is a complete unsharing (see Deﬁnition 3.5 in Chapter 4).
Remark 1.3. The result of Theorem 1.1 ensures us the uniqueness of the readback G π of an sℓstructure G a lesssharedinstance of which is a uℓstructure U having a readback U π, but does not completely deﬁne the topology of G π. In fact, it only states that there exists an smorphism M : U π → G π between the two π normalforms. In the relevant cases of our study, however, the only smorphisms between ℓstructures are the identity maps (remind that in the linear logic case we restrict to the exponentialmultiplicative case without weakening and that the left and right ports of the and links are distinct). Hence, by what said in Remark 1.1, in the cases we are going to analyze the readback G π is uniquely determined by the ℓstructure U . 2. Semantical readback The algebraic semantics presented in Chapter 4 give us a way to complete the study of the rewriting properties of the π interactions started in the previous section. In fact, the class of the proper uℓstructures deﬁned in that chapter (see Deﬁnition 3.6 and Remark 3.5) is the one composed of the uℓstructures that have a readback (see Theorem 2.3) which, besides, is even unique. 2.1. Invariance of the semantical readback. To prove the existence and the uniqueness of the readback of a proper uℓstructure U we use the solutions
80
5. READBACK
of uℓstructures introduced in section 3 of Chapter 4 to assign the levels to the ℓstructure U . Definition 2.1 (H readback). Let H be a lifting sequence assignment for the uℓstructure U . The H readback of U is the indexed structure U H obtained def by U assigning to any vertex v its Hlevel ιU[H](v) = ιU(v) + Q(Hv). Remark 2.1. We cannot say a priori that U H is a uℓstructure because we are not sure that its levels accord with the constraints of the links. In spite of this, the latter deﬁnition is certainly sound because Lemma 3.1 of Chapter 4 ensures the uniqueness of the levels assigned by H to any arrow of U . In particular, the lemma shows that ιU[H](va) = ιU[H](vp) for the auxiliary door va and the principal door vp of any lift. Notation 2.1. Since the quiescence solution will be the relevant one in the determination of the π normalform of a uℓstructure, we will use: 1. U 1 to denote the readback of the uℓstructure U corresponding to its quiescence solution; 2. ¯U to denote the nesting levels assignment deﬁned by the quiescence solution ι of U , i.e., ¯U(v) is the level of the arrow of U 1 which is image of v. ι Definition 2.2 (actual level). Let U be a proper uℓstructure. For any arrow v of U , the nonnegative index ¯(v) is said the actual level of v. ι The idea hidden behind the algebraic semantics of the previous chapter is to see the π interactions as transformations between equivalent systems of equations. Namely, interpreting a uℓstructure U as a set of constraints whose solutions are the assignments of U , we want to be able to compute the assignments of U from ∗ the ones of U1, and vice versa, for any pair of uℓstructures s.t. r : U π U1. Lemma 2.1. Any π interaction r : U π U1 of a uℓstructure U induces an isomorphism between the lower semilattices (h(U ), ⊓) and (h(U1), ⊓) of their lifting sequence assignments. Proof. Let H be a lifting sequence assignment of U , we show that for any π redex r = e (w)πe⋆ its contraction induces an assignment Hr of U1 s.t. Hv = Hr,v for any arrow1 v = w, and that the map [H → Hr  H ∈ H(U )] is a bijection.
1
∗
More formally, the latter property should have been expressed in terms of residuals: deﬁned the residual of an arrow, we would have had to say that the value assigned by Hr to a residual of v is equal to the one assigned by H to v.
2. SEMANTICAL READBACK
81
Let us start assuming that r is a muxes interaction. The corresponding redex and its transfer function are drawn in the next picture:
n+q1 v1
a1
m1
n m2 a 2 w
] ]
n+q2 v2
Hv1 L m2; q2; a2 L m1; q1; a1
Hv2
When m1 = m = m2 the pair of lifts form a redex iﬀ both q1 = q = q2 and a1 = a = a2. The corresponding transfer function is L[m, q, a] L[m, q, a] = 1, i.e., a direct connection between v1 and v2. Hence, Hv1 = Hv2 and Hw = L[m, q, a] Hv1 , for any assignment H of U . The assignment Hr is then the restriction of H to V(U) − {v1, v2, w} extended by Hv = Hv1 = Hv2 , for the arrow v obtained merging v1 and v2. When m1 < m2 we have instead a case of muxes swap. The result of the interaction r and the corresponding lifting sequences are drawn in the next picture:
m1 a1
+ ; ; ] Hv1 = L m2 m q;1q q;2a a]2HHr;w = Hr;v1 L 1 1 1 w v v
0
1
n+q1
L m2; q2; a2] L m1; q1; a1] Hr;w
m2 a 2 v2 n+q2 w
n
0
L m2 + q1; q2; a2] L m1; q1; a1] Hw
m1 a1 n+q2 v2 w
0
n+q1 +q2
n+q1 m2+q1 a2
1
Hv2
1 1 = LLm1; ;qq; ;aa] ]Hr;w = m2 2 2 Hw
0
Hr;v2
In this case, since for any H ∈ H(U ) we have that Hvi ⊑ Hw, for i = 1, 2, there exists Hr,w′ s.t. Hw = L[m2, q2, a2] L[m1, q1, a1] Hr,w′ , etc. Let us now assume that r is a π propagation, and in particular, as drawn in the next picture, let us see what happens when the proviso of the rule holds, i.e., the level of the auxiliary door vi is s.t. ni > m.
82
5. READBACK
n+q v am
n w
?
ni vi
n+q v
?
ni +q w
0
a
ni m vi
Hv
a
m;q
Sen;n ]
?
i
Hv
i
n Hv Sr;e+q;n +q]
?
i
a
m;q
Hv
i
In this case, we see that Hvi = Se⋆ i L[m, q, a] Hv. Hence, when m < n ≤ ni, [n,n ] [n+q,n +q] we have that Hvi = L[m, q, a] (Se⋆ i ) q Hv, and then Hr,w′ = Sr,e⋆ i Hv, for [n+q,n +q] [n,n ] an internal state of U1 s.t. Sr,e⋆ i = (Se⋆ i ) q. The case m < ni ≤ n is [n +q,n+q] [n ,n] similar, the new internal state of e⋆ is now s.t. Sr,ei⋆ = (Se⋆ i ) q. To conclude the deﬁnition of Hr we have to see what happens when the lift of the redex is absorbed by an auxiliary port of e⋆ .
[n,n ]
n+q v am
n w
?
ni vi
n+q v
?
ni vi
Hv
a
m;q
Sen;n ]
?
i
Hv
i
Hv
?
i
n Sr;e+q;n ]
?
i
Hv
i
i
n Sen ;n] = L m; q; a] Sr;e ;n+q]
?
According to what drawn in the previous picture, and being m ≥ ni, we [n ,n] [n ,n] see that Hv = L[m, q, a] Se⋆ i Hvi , with L[m, q, a] Se⋆ i ∈ LSeq[ni, ω]. Hence, [n ,n+q] [n ,n] [n ,n+q] [n ,n+q] there exists Sr,ei⋆ s.t. Se⋆ i = L[m, q, a] Sr,ei⋆ and Hv = Sr,ei⋆ Hvi . The analysis of the propagation and absorption rule shows that an interaction of such a kind implies also a changement of the internal state of the link e⋆ . In [n ,n ] particular, if Se⋆ 1 2 is the observable part of such a state (i.e., n1 is the minimal level of a door of e⋆ while n2 is the maximal one), we see that the observable part of the new state of e⋆ is:
2 1. Sr,e1⋆ = (Se⋆ 1 2 ) q, when m ≤ n1; [n ,n +q] [n ,n ] 2. Sr,e1⋆ 2 = L[m, q, a] Se⋆ 1 2 , when n1 < m < n2.
[n +q,n +q]
[n ,n ]
2. SEMANTICAL READBACK
83
Which means that if H ∈ HS(U ), then Hr ∈ HSr (U1). By analysis of the deﬁnition of Hr it is not diﬃcult to see that its construction is inversible and then that it gives a bijection. So, to conclude the proof it remains to show that the map induced by r is an homomorphism w.r.t. the meet, i.e., that ′ ′′ Hr = Hr ⊓ Hr , when H = H ′ ⊓ H ′′ . When r is a muxes annihilation there is nothing to prove. When r is instead a muxes swap, it suﬃces to note that ′ ′′ ′ ′′ Hw′ ⊓ Hw′ = L[m2, q2, a2] L[m1, q1, a1](Hr,w′ ⊓ Hr,w′ ). The case in which r is an ′′ ′ absorption is similar to the swap of muxes, i.e., we have that Se⋆ [n,ni ] ⊓ Se⋆ [n,ni ] = ′′ ′ L[m, q, a](Sr,e⋆ [n1 ,n2 +q] ⊓ Sr,e⋆ [n1 ,n2 +q]). While, when r is a mux propagation we ′′ ′ ′′ ′ see that (Se⋆ [n1 ,n2 ] ⊓ Se⋆ [n1 ,n2 ]) q = (Se⋆ [n1 ,n2 ]) q ⊓ (Se⋆ [n1 ,n2 ]) q. Remark 2.2. Since for any π interaction r : U π U1 the bijection [H → Hr  H ∈ hS(U )] between the lifting sequence assignments of U and the ones of U1 is also an isomorphism (·)r : (hS(U ), ⊓) ≃ (hSr (U1), ⊓) between the corresponding ′ ′′ lower semilattices, i.e., (H ′ ⊓ H ′′ )r = (Hr ⊓ Hr ), we see that (·)r preserves the least element. Hence, being I the quiescence solution of U , the assignment Ir is the quiescence solution of U1. Lemma 2.2. For any π interaction r : U π U1 of a uℓstructure U , if [H → Hr  H ∈ hS(U )] is the bijection that r induces between the assignments of U and U1, then U H = U1 Hr . Proof. If vp and va are the principal and auxiliary doors of a lift with threshold m and oﬀset q, we know that ιU[H](vp) = ιU[H](va) (see Lemma 3.1 of Chapter 4), for any H ∈ hS(U ). Hence, using the notations of the proof of Lemma 2.1, when r is a lifts interaction we have that ιU[H](v1) = ιU[H](v2), which is enough to prove the property, that is, to prove ιU[H](vi) = ιU1 [Hr](vi), with i = 1, 2; in addition, when r is a lifts swap let us also note that ιU[H](w) = n + q1 + q2 + Q(Hr,w′ ) = ιU1 [Hr](w ′). The same reasonings apply when r is a lift propagation or a lift absorption. In such cases we have ιU[H](v) = ιU1 [Hr](v) and ιU[H](vi) = ιU1 [Hr](vi). Corollary 2.1. The quiescence readback of a uℓstructure is invariant under π reductions. Proof. By Remark 2.2 we know that if I is the quiescence solution of U and r:U π U1, then Ir is the quiescence solution of U1. Hence, by Lemma 2.2 we can conclude that U 1 = U1 1.
84
5. READBACK
2.2. Uniqueness of the readback. The last subsection ends with the proof of the invariance of the semantical readback of a uℓstructure. In Figure 2 is drawn the semantical readback N (dotted there are the removed lifts too) of the proper uℓstructure U , whose quiescence solution has been given in Figure 7 of Chapter 4. Furthermore, by reducing it, we see that the π normalform of U is the ℓstructure N , that is, does not contain any lift. The fact that a proper ℓstructure does not contain lifts is even more generally true, since to be deadlockfree is implied by properness.
ax
2
ax
?
0
2 a2 2
!
0 0 1 a2
1 a1 1
!
ax
0
0 a1
0 1
?
0
1 0
?
1
0 0
0
O
0
0
O
0
0
Figure 2. Semantical readback. Lemma 2.3. The proper uℓstructures are deadlockfree. Proof. Since in a proper uℓstructure U all the roots have level 0, no root of U can be principal door of a mux: it would force the threshold of such a mux to be negative. Looking at the proof of Lemma 2.1 we also see that a uℓstructure containing two facing lifts with the same threshold, but with either q1 = q2 or a1 = a2, does not admit any lifting sequence assignment. In fact, being v1 and v2 the auxiliary doors of such a pair of lifts, we would have Hv2 =
2. SEMANTICAL READBACK
85
L[m, q2, a2] L[m, q1, a1] Hv1 = 0. Furthermore, a proper uℓstructure cannot contain a lift with threshold n pointing to a pdl with the same level, i.e., whose internal door has level n+1. In fact, comparing with the analysis of the absorption rule in the proof of Lemma 2.1, we see that if such a conﬁguration arises, the [n ,n] [n,n+1] internal state Sepi of the pdl ep might not be arbitrary, but s.t. Sep = L[n, q, a] H, for some H ∈ LSeq. In particular, the ℓstructure might not have any quiescence assignment, that is, it might not be proper. Remark 2.3. In the previous lemma, to prove deadlockfreeness we have only used that any proper uℓstructure has a quiescence solution and not that it has a solution for any pdl internal state. Corollary 2.2. The proper sℓstructures are deadlockfree. Proof. Let M : U → G be the complete unsharing of a proper sℓstructure. By deﬁnition U is proper and it is deadlockfree. So, it is enough to prove that a deadlock in G would induce a deadlock in U too. In the case the deadlock of G is relative to a root or a pdl, by the deﬁnition of smorphism it is readily seen that also U contains a deadlock of the same type. Let then e ′ (v)πe ′′ be a dealock of G formed by a pair of muxes with the same threshold. Let us assume w.l.o.g. ′ that the ith port of e ′ is s.t. there is no port of e ′′ with the same name ai and ′ oﬀset qi. By deﬁnition of smorphism (i.e., since it is surjective), U contains a π redex e ′ (^)πe ′′ s.t. M(^ ′ ) = e ′ and M(^ ′′ ) = e ′′ , and with the port name and ^ v ^ e e ′ ′ ′ the oﬀset of e equal to ai and qi, respectively. But, this implies that e ′ (^)πe ′′ ^ ^ v ^ is a deadlock. Theorem 2.1 (uniqueness of the readback). The readback of a proper sℓstructure G (if it exists) is unique. Proof. Let N be a π normalform of G . By Corollary 2.2 N does contain muxes, that is, it is a readback of G . By Corrollary 2.1 we know that G 1 = N 1. But since N does not contain muxes (and then it is a uℓstructure) its quiescence solution is the identity assignment. Hence, G 1 = N 1 = N . 2.3. Strong normalization of the π interactions. The last subsection ends with a proof of the uniqueness of the readback of any proper sℓstructure. Anyhow, we have not yet given any information on the existence of the readback of an sℓstructure. Lemma 2.4. The length of any π reduction of a proper uℓstructure is ﬁnite.
86
5. READBACK
Proof. Let U be a proper uℓstructure over the signature Σ. Let us consider the following two measures: 1. The sum k⋆ of the length of the lifting sequences assigned by the quiescence solution to the doors of any link of U which is not a lift, i.e., k⋆ = Σe∈E (U)−E (U)Σv∈∂(e)Hv. 2. The sum k analogous to the previous one, but for the lifts of U , i.e., k = Σe∈E (U)(H∂prn (e) + H∂aux (e)). Each lifts interaction decreases k . Each lift propagation or lift absorption decreases k⋆ , but may increase k (since it may increase the number of lifts in the uℓstructure). Hence, each πrule decreases the combined measure (k⋆ , k ) (lexicographically ordered). Remark 2.4. By inspection of the proof of the previous lemma, we see that to prove the strong normalization of the π interactions over the uℓstructure U it suﬃces that U has at least a solution (because of Lemma 2.1). In particular, it suﬃces that U has a quiescence solution. By the simulation lemma, the previous result extends to the sℓstructures too. Corollary 2.3 (strong normaliztion). The length of any π reduction of a proper sℓstructure is ﬁnite. Proof. Let M : G → U be a complete unsharing. If there were an inﬁnite π reduction of G , then there would be an inﬁnite reduction of the proper uℓstructure U too (cf. the proof of Theorem 1.1). To conclude, the existence and uniqueness of the readback of a proper sℓstructure. Theorem 2.2 (readback). Any proper sℓstructure has a unique readback. Proof. Let M : G → U be a complete unsharing. Since U is proper the hypothesis of Theorem 1.1 hold. Since the sℓstructure G in Figure 8 of Chapter 4 its readback is unique. We know indeed that its leastsharedinstance is the proper uℓstructure U in Figure 7 of the same chapter. Hence, the readback of G is the same of U , that is, the ℓstructure N in Figure 2 of this chapter. By reducing G , we see that its normalform is exactly N .
2. SEMANTICAL READBACK
87
2.4. The class of the proper uℓstructures. By the last results, we may state that a uℓstructure is proper only if it strongly normalizes (under π interactions) to a unique readback. By Corollary 2.1 we may see indeed that: Corollary 2.4. The equivalence U structure U .
1
= U
π
holds for any proper uℓ
Hence, given a proper uℓstructure U , we can equivalently deﬁne the ℓstructure its represents either algebraically by U
def
= U
1
or using the π interactions (i.e., syntactically) by U
def
= U
π
since any π reduction of U terminates with its (unique) readback. In the previous reasoning, we have used properness as a tool to prove deadlockfreeness and strong normalization of the proper uℓstructures. In other words, the system of constraints introduced by the semantics is nothing more than an algebraic formulation of the (syntactic) properties of the π interactions. The tightness of such algebraic formulation is proved indeed by the fact that we can invert the reasoning, that is, we may prove that a uℓstructure is proper using the π interactions. Lemma 2.5. If N is an ℓstructure of a calculus whose structures accord with the box nesting condition, then N is proper. Proof. Let e1 , . . . , ek be the pdls of the ℓstructure N increasingly orp p dered according to their levels. We have that either Boxℓ (ei ) ⊃ Boxℓ (ej ) N p N p or Boxℓ (ei ) ∩ Boxℓ (ej ) = ∅, for any pair of indexes i < j. Let S be a pdl interN p N p nal state of N and let us additionally assume w.l.o.g. that Sei ∈ LSeq[n, n + 1], p where n is the level of the pdl ei (we just consider the observable part of the p pdl internal state). Let us consider the sequence of pdl internal states obtained starting with the quiescence internal state and assigning at the ith step the value j j Sei to the pdl ei , i.e., for 0 ≤ j ≤ k, we have Sei = Sei if i ≤ j, and Sei = 1 if p p p
p p
i > j. In the same way let us deﬁne the sequence of assignments Hi by assuming 0 Hv = 1 for any arrow v, and S i+1 Hi i+1 when v ∈ V(∂E (Boxℓ (ep ))) v N ep i+1 Hv = H i otherwise v
88
5. READBACK
with i = 0, 1, . . . , k − 1. Any of such assignment is the solution for the corredef sponding pdl internal state. Hence, H = Hk is the solution for S = Sk. Theorem 2.3. A uℓstructure is proper iﬀ it has a readback. Proof. We have already proved that a proper uℓstructure U has a read∗ back. So, let us assume that ρ : U π N is a normalizing reduction. Because of Lemma 2.1 we know that (h(U ), ⊓) ≃ (h(N ), ⊓). But N is an ℓstructure and then it is proper. Hence, because of the previous isomorphism we see that also U has a solution for any pdl internal state and then that also U is proper. Remark 2.5. In the previous theorem we have implicitly assumed that the box nesting condition holds. Corollary 2.5. A uℓstructure is proper iﬀ it has a quiescence solution. Proof. By Remark 2.3 and Remark 2.4, we see that the existence of the readback of a uℓstructure U still hold if we ask the existence of the quiescence solution of U . By Theorem 2.3 we can then conclude that such a U is proper. Remark 2.6. The last statement suggest that maybe we could have had better deﬁned the proper uℓstructures as the ones with a quiescence solution, proving later that any proper uℓstructure deﬁned in such a way has a solution for any pdl internal state. We followed the inverse direction because the existence of the solution for any pdl internal state naturally arises form the study of the dynamics of the calculi to be implemented. So, at the starting point of our study we chose such a stronger property as the invariant to be preserved. In fact, the internal state of a pdl lifts the interior of its box by the global oﬀset of its internal state (cf. the way in which, given a pdl state, we construct the corresponding solution for an ℓstructure in the proof of Lemma 2.5). The internal state of an adl ea accumulate instead the oﬀsets of the lifting operations that have not been performed yet on the interior of the corresponding boxes and that will end at ea. The interaction between ea and a pdl ep, move the interior of the pdl’s box Boxℓ(ep) inside the ones closed by ea. So, after the interaction, the scope of the lifting operators includes what remains of Boxℓ(ep) too. Algebraically, it means to force the internal state of ep to assume the same value of the internal state of ea. Then, since the states of ep and ea are completely independent, the soundness of the approach may be ensured only by the existence of a solution for any internal state of ep.
2. SEMANTICAL READBACK
89
2.5. Reconstructing boxes. Let us now give how to recover the boxes of a uℓstructures. In fact, because of the presence of lifts the levels of the arrows are not their actual ones. So, we cannot use the deﬁnition given for the ℓstructures in section 2 of Chapter 2. By the way, the extension of the deﬁnition of box to the uℓstructures requires the use of the assignments of levels induced by the solutions of a uℓstructure. Definition 2.3 (uℓbox). Let ep be a pdl of level n of a proper uℓstructure U . The uℓbox of ep is the smallest U substructure Boxℓ (ep) s.t., for each pdl U internal state S of U , if H is the Ssolution of U , then: ep is a door link of Boxℓ (ep); U all the door links of Boxℓ (ep) but ep are adls; U ℓ BoxU(ep) is connected; the Hlevel of any internal arrow of Boxℓ (ep) is not lower than the Hlevel U of ep; 5. the Hlevel of any arrow of the border of Boxℓ (ep) is not greater than the U Hlevel of ep. 1. 2. 3. 4. By the way, the two deﬁnition of boxes that we now have for the ℓstructures coincide. Fact 2.1. For any pdl ep of an ℓstructure U the uℓbox Bℓ(ep) assigned to ep by the Boxℓ map of Deﬁnition 2.3 and the box B1(ep) assigned to it by the U Boxℓ map of Deﬁnition 2.2 of Chapter 2 coincide. U Proof. Let us say that the Hlevel of a box B0(ep) is the Hlevel of ep. By the construction given to get the Ssolution H of an ℓstructure in the proof of Lemma 2.5, we see that in no case the Hlevel of a box contained in the interior of a uℓbox may become lower than the level of a box in which it is contained. Which is enough to state that the Hlevel of any arrow in the interior of B0(ep) is not lower than the Hlevel of B0(ep), that is, of ep. On the contrary, there exists at least a solution H (e.g., the quiescence solution) for which the level of B0(ep) is greater than the Hlevel of each box in which it is contained. Analogous reasonings apply for the adls of a box leading us to conclude that the Hlevel of each adl of B0(ep) cannot be greater than the level of ep. Hence, we conclude that B0(ep) = B1(ep).
90
5. READBACK
Remark 2.7. Since in the proof of the previous fact we referred to Lemma 2.5, also in it we implicitly assumed that for the boxes of the ℓstructure U the box nesting condition holds. Remark 2.8. When U is an ℓstructure. The box Boxℓ (ep) of Deﬁnition 2.2 U of Chapter 2 corresponds to the uℓbox obtainable by Deﬁnition 2.3 when we restrict to consider the quiescence solution only. The previous remark suggests us that, as for the study of properness, the relevant solution of a uℓstructure is the quiescence one. Let U be a proper uℓstructure s.t. r : U Let us denote with π U1. r e ∈ E(U1) the image w.r.t. r of a logical link e ∈ E(U), that is, e ∈ E (U). / The previous map deﬁnes a bijection between the logical links of U and U1. Fur∗ thermore, if ρ : U π U , then ρ gives a bijection between the links of U and the logical links of U (the fact may be seen also reminding that U = U 1 and that, apart for the levels, the ℓstructure U 1 is obtained just erasing the lifts of U , cf. Fact 1.1 too). Fact 2.2. For any pdl ep of a proper uℓstructure U s.t. ρ : U π U1, the border ∂E (Boxℓ 1 (er )) of the uℓbox of the image er (w.r.t. r) of the pdl ep is the U p p image of the border ∂E (Boxℓ (ep)). U Proof. By the invariance of the Hlevels of the doors of any logical link under π reduction (see Lemma 2.2). It is readily seen that the uℓbox of a uℓstructure is determined by its border (remind that boxes are connected). So, in Fact 2.2, let us assume that U1 = U . We have already pointed out by Remark 2.8 that the uℓboxes (i.e., the boxes) of an ℓstructure are deﬁnable in terms of the quiescence solution only (i.e., since in this case the quiescence solution is the identity, in terms of the levels of the ℓstructure). By the correspondence between the solutions of the reduct of a uℓstructure and the solutions of the uℓstructure itself stated by Lemma 2.1, we can then conclude that it is always true that we may deﬁne the uℓboxes of a uℓstructure just considering its quiescence solution. Definition 2.4 (uℓbox). Let ep be a pdl of level n of a proper uℓstructure U . The uℓbox of ep is the smallest U substructure Boxℓ (ep) s.t.: U 1. ep is a door link of Boxℓ (ep); U 2. all the door links of Boxℓ (ep) but ep are adls; U
∗
2. SEMANTICAL READBACK
91
3. Boxℓ (ep) is connected; U 4. the actual level of any internal arrow of Boxℓ (ep) is not lower than the U actual level of ep; 5. the actual level of any arrow of the border of Boxℓ (ep) is not greater than U the actual level of ep. Let us remind that the actual level of an arrow is the level assigned to the arrow by the quiescence solution. Fact 2.3. The two deﬁnitions of uℓbox given in Deﬁnition 2.3 and Deﬁnition 2.4 coincide.
92
5. READBACK
CHAPTER 6
Lambda calculus
We present in this chapter the main case study of the dissertation: the application to the λcalculus of the previously introduced methodologies.1 In the ﬁrst section we ﬁx the structures for the representation of λcalculus. To exploit the tree topology of λterms, such structures are slightly diﬀerent from the general ones. In practice, we maintain separated the topology of a λterm from its binding relation, representing the second one by a map associating each variable node to the corresponding binder. Also the terminology slightly changes. In fact, since the structures used derive from the λterms abstract syntax trees, we adopt the name “node” for the λstructure links, and “edge” for the λstructure vertices. The tree topology of a λterm greatly simplify the recognition of its boxes: they are the subtrees rooted at the right door of an application (the subtrees of the subterms which are argument of an application). Such simplicity of the boxing reﬂects in terms of levels in the existence of a unique correct indexing for a λterm. Hence, there is no practical diﬀerence between standard λterms and leveled ones. Fixed the λstructures we pass to analyze the βrule: the usual one (section 1.4) and its shared implementation (section 1.6). For the sake of the proof of the successive simulation lemma (section 2.9), we also introduce the unshared βrule (βurule) in which the reindexing and the duplication are separated (subsection 1.8). The presentation become then more formal in the successive section 2, where what previously given pictorially is formalized into a notation useful to the proof of the theorems. In particular, we give a tool to control the reduction based on a way to select βredexes suited to the purpose of the proof of the simulation lemma (section 2.9).
1
The results of this chapter are an extended an revised version of the ones presented in
93
[Gue].
94
6. LAMBDA CALCULUS
In the third part (section 3) we adapt the methodologies introduced in Chapter 4 to the present case. In place of give a simple instantiation of such techniques, we prefer to give a diﬀerent but equivalent way to apply them. The method presented here conforms to the usual semantics based on paths started by Girard while formulating the “geometry of interaction” (GOI) [Gir89, Gir88], continued by Asperti, and Laneve [AL93d], and which found its convergence point in the work by Asperti, Danos, Laneve, and Regnier [ADLR94]. We choice to present such a method here, since it is the best way to exploit the tree topology of λterms: it allows to give a way to recover the readback of a shared λterm by an algebraic characterization of the proper paths which rebuild it. We stress that this way to use paths is substantially diﬀerent from the standard one of GOI: our aim is not to use paths to capture the dynamics of the system ﬁnding the paths which would eventually transform into redexes, we want to give a semantical way to reconstruct the readback of a term, in some sense, we use the proper paths to get a static picture of a shared λterm.
1. Lambda structures The usual graph representation of λterms is by their abstract syntax tree: each syntax constructor—application, binder, or variable–is a node; each binding between the occurrence of a variable x and its abstraction λx is a backconnection from the node of x to the one of λx. The representation of λterms we choose is similar to the previous one, even if our λstructures are dual of syntax trees: each edge of the abstract syntax tree of the λterm t is a vertex—an arrow—of the λstructure representing t; each node is an hyperarc—a link. Anyhow, because of the latter duality, henceforth we will use edge in the place of arrow or vertex, and node as a synonym of link. 1.1. λstructures links. To simplify the presentation we restrict w.l.o.g. to the case of closed λterms. In this way any λstructure has a unique conclusion and no premises: all the nodes representing occurrences of variables are backclosed to their binders. The links that compose λstructures are of four types: • application links, or @ nodes, whose unique head edge (the up one) represents the composition tltr of the corresponding pair of tail edges (the left one tl and the right one tr);
1. LAMBDA STRUCTURES
95
tl tr
x:t
@
tl tr x x t
Figure 1. λterm links. • abstraction links, or λ nodes, whose head edge (the up one) represents the abstraction λx.t of the variable name edge x (the side one) from the tail or body edge t (the down one); • variable links, or v nodes (denoted by a • in Figure 1), whose head edge denotes the occurrence of a variable x; • binding links (denoted by a dotted line in Figure 1) that backconnect the v nodes representing the occurrences of a variable x to the variable name edge of their binding λ node. The graphical representation of the previous nodes is given in Figure 1). In the drawings we have omitted the edge stems since the edge orientation denoted by them will be in general clear from the context: we assume the convention to draw λterms topdown starting at the top with their conclusion edge. In this way, all the edges but the head ones of the v nodes are upward oriented. In fact, since we also assume to draw the v nodes at the same height of their binding λ node, the up edge of a v node is a curved line connecting the node to its father (cf. the λterm structure drawn in Figure 5). Remark 1.1. Another and more important reason because we prefer to not draw the edge stems is that, even if the λstructures of the λterms are upward oriented, the natural way to cross them is traveling downward: from the conclusion of a link to its premises. Hence, according to the terminology introduced in section 5 of Chapters 2, the paths we will consider traveling λstructures are inverse. 1.2. λterms. The v nodes backconnections representing variable binding cause the loss of the tree topology that λterms have. Because of this, we prefer to slightly change the representation using a less uniform treatment, adopting a distinct formal representation for the binding links: we split the λstructure of
96
6. LAMBDA CALCULUS
a λterm into a tree and a map representing the binding connections. Such a distinction between links reﬂects in λstructure drawings where the binding links are represented by dotted lines (see Figure 1). Definition 1.1 (λstructure). A (closed) λstructure G = (G, τG, νG) is a pair composed of: 1. A structure of links (G, τG) over the link signature Σλ = {@, λ, v} with only one (conclusion) root. 2. A binding map νG : E v (G) → E λ(G) connecting each v node of G to its binding λ node. Remark 1.2. Let us note that the restriction to closed λterms implies the totality of the binding map and that, because of the separate representation of the binding connections, the λ nodes become links with only two incident edges: the up and the body ones. A λstructure is not always the correct representation of a λterm. Namely, the binding map must respect the usual scoping rules of λcalculus. Definition 1.2 (scoping rules). The binding map νG of a λstructure G respects the scoping rules iﬀ each v node e is in the scope of ν(e), i.e., in the (inverse) subtree rooted at the λ node νG(e). Remark 1.3. As for the paths, in the following we will implicitly assume that the subtrees we consider are inverse. Furthermore, the separation between its topology and its binding relation, and the uniqueness of its root imply that a λstructure is formed by an acyclic main component—the one individuated by its root—and by some other cyclic parts. Nevertheless, all the nodes of a correct λterm should be reachable from the root. The previous requirements summarize in the following deﬁnition of λterm structures. Definition 1.3 (λterm). A (closed) λterm structure is a connected λstructure whose binding map respects the scoping rules. How to convert a λterm t into a λterm structure T is in the description of the λstructures links: we start at the root with t and we go down building T according with the rules implicit in the names used for the edges in Figure 1. The opposite translation, from a λterm structure T to a λterm t, is also direct.
1. LAMBDA STRUCTURES
97
y: x:x(xy)
x:x(xy) x(xy) xy
y x
x
@
@
Figure 2. The λterm representing 2. Let us associate a distinct variable name to each λ node of T . To recover t we proceed bottomup from the v nodes to the root assuming that the name of the variable of a v node e is the one associated to ν(e). For instance, in Figure 2 we have the λterm structure representing the Church’s numeral2 2 = λy.λx.x(xy). The representation used for λterms allows to completely forget the names of the variables and to avoid the problem of variable name clashes. Consequently, the λterm structure representing a given λterm is unique up to αcongruence. Because of such an isomorphism we will also directly use λterm in place of λterm structure. 1.3. λIcalculus. Restrictions to the binding map ν of a λterm may be added to study suitable subclasses of λterms. Namely, the λIcalculus is obtained by forcing ν to be surjective. Definition 1.4 (λIterm). A λIterm is a λterm whose binding map is surjective. Remark 1.4 (Kabstraction). Let us say that a λ node is a Kabstraction when it does not bind any variable, that is, it is not in the image of the binding map. By the previous deﬁnition, a λIterm contains no Kabstraction.
2
The Church’s numeral 2 would actually be λx.λy.x(xy). We prefer to swap the abstractions
λx.λy just for pictorial reasons.
98
6. LAMBDA CALCULUS
(
x:t)s
t s=x]
x:t
t x x x
@
box
s
Tt
s s s
Ts Ts1
Tt
Tsi
Tsk
Figure 3. The βλrule. Since in our analysis we restrict to study the λIcalculus, when not otherwise speciﬁed, in the following we assume that all the λterms are λIterms. 1.4. Boxes and βλrule. The standard λcalculus βrule (β) induces the graph contraction (βλ) T(λx.t)s
βλ
(λx.t)s
β t[s/x]
Tt[s/x]
between the corresponding λterm structures. The main drawback of a direct implementation of the latter contraction rule (cf. Deﬁnition 2.9) is that it involves a global rearrangement of the λterm T(λx.t)s to build its contractum Tt[s/x]. In fact, to replace each occurrence of x with an instance of s requires to displace and (according to the cardinality of x) to duplicate the whole subterm Ts. Hence, such a direct implementation would require the introduction of boxes: one for each right subtree of an @ node, and the corresponding rewriting would be the one depicted in Figure 3 (in which, to simplify the drawing, we have omitted the irrelevant backconnections and the boxes into which the new instances Tsi of the argument tree are nested after the execution of the contraction).
1. LAMBDA STRUCTURES
99
tl tr
n n pi 0 n+1
i=1;::: ;k n
x:t
n
@
n+p1
n+pk
n
tl
tr
x
x
t
Figure 4. Door levels of the λterm links. 1.5. λℓstructures. The tree topology of λterms implies that boxes might be deﬁned even without the introduction of levels: they are the right subtrees of the @ nodes (cf. Figure 3). Anyhow, levels turn to be necessary for the shared implementation of the βλ contraction in which the tree topology is immediately lost. So, the levels of the λℓstructures edges (the leveled λstructure) are set with the goal to put a box around each right subtree of an @ node. The corresponding indexing rules drawn in Figure 4 are formalized in the following deﬁnition of λℓstructure. Definition 1.5 (λℓstructure). A λℓstructure G is a leveled λstructure in which: 1. The root edge has level 0. 2. All the premises of a node have a level equal to the one of the corresponding node’s conclusion, but 3. The right edges of @ nodes whose level is equal to the one of the node’s conclusion incremented by 1. 4. The level of the conclusion of a v node e is greater or equal than the level of the conclusion of its binder νG(e). Definition 1.6 (λℓterm). A λℓterm is the λℓstructure obtained by a λterm assigning the edge levels according to the rules of Deﬁnition 1.5. Remark 1.5. The levels of a λℓterm are uniquely determined by the topology of the λterm. The λℓterm corresponding to the Church’s numeral 2 is drawn in Figure 5. Remark 1.6. According to Deﬁnition 2.2 of Chapter 2 a λℓterm box of level n is a connected component composed of edges at level greater than n whose principal door is the right edge of an @ node. Correspondence that remains valid
100
6. LAMBDA CALCULUS
y: x:x(xy)
0
0
0 2 1 0
@
1
@
Figure 5. A λℓterm. also reintroducing the binding links as contraction nodes of the structures. This is the reason because we preferred to insert the constraints for the v nodes among the indexing rules even if they are superﬂuous in the case of λterms. In fact, such constraints state that the secondary doors of a box are, as usual, the points where the levels become lower or equal than the one of the box. Furthermore, such constraints will not be superﬂuous in the case of λsℓterms. Remark 1.7. The just described level assignment corresponds to give levels according to the (!D ⊸ D) ≃ D translation between linear logic and pure λcalculus, following the work of Asperti [Asp95b]. Also the translation !(D ⊸ D) ≃ D has been used to build structures useful for the sharing implementations (see [GAL92a]), even more, it was the ﬁrst one used to show how the techniques discovered by Lamping should be studied in the framework of linear logic. For a comparison of the two see Asperti and Laneve [AL95] or the thesis of Mackie [Mac94] in which also the (!D ⊸ !D) ≃ D translation is discussed shortly. 1.6. The βsrule. The sharing implementation of the βrule, the βsrule, requires the introduction of multiplexers and then the use of the sharing λℓstructures to represent terms. Definition 1.7 (λsℓstructure). A λsℓstructure pair composed of: G = (G, τG, ιG, νG) is a
1. An sℓstructure (G, τG, ιG) over Σλ with only one (conclusion) root.
1. LAMBDA STRUCTURES
101
n n
n n+1
s
@
n+pi
T
n+pi ai n+pk ak n+1
n n+pk n+p1
T@
n+p1 a1 n
T
T@
Figure 6. βscontraction of a λterm. 2. A surjective binding map νG : E v (G) → E λ(G) connecting each v node of G to its binding λ node. Remark 1.8 (λsiℓstructures). The surjectivity of the binding map of a λsℓstructure implies that the λsℓstructures does not contain Kabstractions. Furthermore, since we assume that the sℓstructures do not contain erasers, they correspond to the structures arising by the sharing computation of λIterms, that is, we should refer to them as λsiℓstructures. In particular, we will use the latter name when we will want to stress the absence of erasers or Kabstractions. In the βsrule the argument subtree of a βredex is no more duplicated: the rule just inserts a mux between the fathers of the v nodes binded by the λ of the redex and the root of the argument. The eﬀect is however the loss of the tree topology. In fact, βscontracting a λterm (see Figure 6) we obtain a direct acyclic graph (DAG). Even more, the successive contractions, either βs or π, cause the loss of the DAG topology too. The graph rewriting picture deﬁning the βscontraction rule (βs) is drawn in Figure 7. G
βs
G1
102
6. LAMBDA CALCULUS
eu
n n
eu
n+1 n+1
s
@
n n a1 n+p1 ai ak n+pi n+pk
n+p1
n+pi
n+pk
er
n
er eb
e1
ei
ek
eb
e1
ei
ek
Figure 7. The shared βrule. Remark 1.9. The correctness of the levels in the βscontractum of a λsℓstructure G are ensured by the constraint on the levels of the v nodes, i.e., ιG(νG(ev )) ≤ ιG(ev ), for any ev ∈ E v (G). According to the formalization of the βsrule that we will give in Deﬁnition 2.16 there are no constraints in the choice of the port names of the mux introduced by a βscontraction. Hence, from this point of view, the βsrule is actually a scheme of nondeterministic rewritings: one for each choice of the port names of the mux. The reasons for such a nondeterminism is that the actual names of the ports do not mind for the computational soundness: it suﬃces the distinction of them inherent into the deﬁnition of mux. Nevertheless, by the introduction of the socalled ports assignments we will further have a way to control the reduction so that the system turns to be deterministic. In fact, a ports assignment is a map activating some v nodes associating to them the name of the port to which they have to be connected when involved in a βscontraction (see subsection 2.6). Only the redexes whose v nodes are active are executable and, since the port names of the mux are now ﬁxed, the corresponding contraction is completely speciﬁed. The control of the reduction achieved by the ports assignment will be a key point to prove the soundness of the βscontraction (see section 4). Remark 1.10. The deﬁnition of βsrule given in Figure 7 applies also to the degenerate case in which k = 0, that is, when the λ node of the redex is a Kabstraction. Let us call it a akredex. The contraction of a bkredex should erase the redex argument subtree. In the sharing implementation of the βkcontraction, however, nothing is removed: an eraser (the mux has not auxiliary ports) is just introduced at the root of the argument subtree. Anyhow, since in the thesis we
1. LAMBDA STRUCTURES
103
0
0
0 2 1 0 a1 a2 0
@
0
1 1 a2 a1
Figure 8. An example of λsℓterm. will study λsiℓstructures only (for a brief description of the problems connected with it see the appendix), the only contractions we will consider are the βsirules, in which k > 0.
1.7. πrules. The internal readback procedure for the sharing implementation of the λcalculus is the general one given by the π rules instantiated to the case of the λsℓstructures. The characterization of the proper sℓstructures and the proof of the properness of the sℓstructures obtainable reducing a λterm are given in the last two sections of the chapter. For the moment, let us simply remark that, since the intended interpretation of a λsℓstructure is a λterm, the π normal forms of the proper λsℓstructures has to be λterms. Hence, the cycle created in the sharing structures during the reduction of a λterm has to be opened by the π rules during the readback. For instance, the sℓstructure in Figure 8 is obtained by βπreducing the λterm II2 (I ≡ λx.x) and it is deﬁnitely not an acyclic structure. Nevertheless, completing the reduction we see that the normal form of such a λsℓstructure is the λterm representing 2 of Figure 5. The only point we have to remark in the instantiation of the π rules in the λℓstructure case is that w.r.t. the π rules the binding connections between v and λ nodes must be considered as normal arrows.
104
6. LAMBDA CALCULUS
e1 u
ei u
ek u
n+q1 n+qi n+qk a1 ai ak m n nj
ej d
n+q1 nj+q1 a1 m nj +qi ai nj
ej d
e1 u
ei u
ek u
n+qi
n+qk
nj +qk ak
n
eb
eu
a1 m
ai n eb
ak
eu
n
@
n m a1 n+q1
e1 l
m a1 n+q1 n+1
n
ai ak n+qi n+qk
@ @ @
e1 l ei l ek l
ai n+qi
ei l
ak n+qk
ek l
er
a1 m
ai
er
ak n+1
Figure 9. Propagation rules: principal rules.
Among the rules obtained in this we also distinguish the principal ones (see Figure 9), in which the mux interact with the up door of a λ node or with the left door of an @ node. The principal rules, plus the βs form an interaction net. In the chapter on optimality we will see that the principal rules suﬃce to get a system ending only if the starting λterm has a normal form with a shared representation of it. The other propagation rules are drawn in Figure 10 the ones in which the interaction is between a mux and a λ node, and in 11 the ones in which the interaction is between a mux and an @ node. Even if, in the case of the rule at the bottom in Figure 10 the interaction is actually between a mux and a v
1. LAMBDA STRUCTURES
105
eu
n
eu n
m a1 nj +qk ak nj
ej d
ai
ak
n nj a1 n+q1
ej d e1 b
ai n+qi
ei b
m ak n+qk
ek b
nj+q1
nj +qi ai
a1 m
n+q1
e1 b
n+qi
ei b
n+qk
ek b
eu
n
n
eu
ai ak
m<n
m a1
nj a1 nj+q1 ai nj +qi m ak n nj +q1 n+qi nj +qk
nj +qk
a1 m
ai n eb
ak
e1 j
eij
ek j
eb
e1 j
eij
ek j
Figure 10. Propagation rules: λ node case. node. Note that the constraint on the level of the threshold of the mux ensures its soundness. In the λsℓstructures, the only case of mux absorption arises when a mux reaches a v node with a threshold greater than the level of the corresponding binder (see Figure 12). The case in which a mux points to the right port of an @ node e and its threshold m is equal to the level of the left and right door of e has instead to be considered as a case of deadlock (cf. section 2 of Chapter 3) since it correspond to a mux with threshold m reaching the principal door of a box of level m.
106
6. LAMBDA CALCULUS
e1 u
ei u
ek u
e1 u
ei u
ek u
n+q1 a1 m n
el
n+qi ai
n+qk ak
n+q1
n+qi
n+qk
@ @ @
a1 m ai n ak a1 m ai ak
@
n n+1
er
el eu
n+1 er n
eu
n
@
n
er
m a1 n+q1 n+1
ai ak n+qi n+qk
@ @ @
m ak n+qk
ek l
a1 n+q1
e1 l
ai n+qi
ei l
a1 m
ai
er
ak n
e1 l
ei l
ek l
Figure 11. Propagation rules: @ node case.
1.8. Unshared reductions. The proof of the soundness of the βs rule will be given showing that a sharing reduction is simulated by a corresponding unshared one, i.e., proving the commutativity of a diagram as the one of page 41 replacing the π reductions by suitable βreductions. To state such a commuting property, ﬁrstly, we have to describe the unshared structures, secondly, we have to deﬁne the unshared counterpart of the βsrule or βu rule. The complete characterization of the proper unshared structures requires the algebraic semantics. Anyhow, the tree topology of λterms implies that for the case of the λcalculus we can restrict the class of the uℓstructures that has to be considered.
1. LAMBDA STRUCTURES
107
eu
n n+pj m a1 n+pj +q1 ai ak n+pj +qk n
eu
n
m n
n+pj +qi n+pj +q1 n+pj +qk n
ej1 eji ejk
eb
ej1 eji ejk
eb
Figure 12. λcalculus absorption rule. Definition 1.8 (λuℓtree). A λuℓtree is a connected λuℓstructure whose binding map is surjective respects the scoping rules. Remark 1.11. Let us remind that the λuℓstructures are λsℓstructures in which all the muxes are lifts. So, not only the λuℓtrees contain no sharing, but they neither contain garbage because erasers are not allowed in it. Furthermore, according to the restriction to the λIcalculus we imposed a λuℓtree is a λsiℓstructure. An example of λuℓtree is drawn in Figure 13. Looking at it let us note that the only diﬀerence between a λuℓtree and a λterm is that in a λuℓtree the pairs of nodes in the signature Σλ are not directly connected by arrows but by sequences of lifts. For instance, the example of Figure 13 is obtained by the λterm representing 2 (see Figure 5) just breaking some arrows of 2 by some lifts. Remark 1.12. The already remarked uniqueness of the levels assigned to the arrows of a λterm implies that to readback the λℓterm U of the λuℓtree U is an immediate task: it is enough to recover the λterm denoted by the λuℓtree, that is, the λterm graphically obtainable replacing each lift by a direct line. Because of this we will use U to denote either the λterm or the λℓterm according to the context. The graph rewriting of Figure 14 deﬁnes the λuℓtree βucontraction rule (βu) U
βu
U1
with k > 0
The βurule is in a middle point between the βs and the βλ rules. In fact, in it the redex boxes (the argument trees) are still duplicated but not nested: the
108
6. LAMBDA CALCULUS
0
0
0 0 a1 0 2 0 0
@
1 0 a 1 1 0 a2 0
@
1 0 a 2
Figure 13. A λuℓtree. reindexing of the new instances of a redex box is demanded to the lifts introduced between them and the corresponding variables they substitute. The βucontraction is welldeﬁned w.r.t. the deﬁnition of λuℓtrees, but it is even sound w.r.t. the previous interpretation of λuℓtrees as λterms. In fact, inspecting the rule, we conclude that U for any λuℓtree U . 1.9. Sharing morphisms between λsℓstructures. The connection between the sharing reductions and the unshared ones are the smorphisms that, because of the non standard representation of λterms, have to be tuned to explicit that also the binding relation has to be preserved.
βu
U1
=⇒
U
βλ
U1
2. REDUCTIONS
109
n n n+pi n n+pk n+p1
n n+1
u
@
T
n+p1 a n 1 n+1 1 T@ n n+pi ai n+1 i T@ n+pk n ak n+1 k T@
T@
T
Figure 14. The unshared βrule. Definition 1.9 (smorphism). An smorphism M : G1 → G2 between two λsℓstructures is an smorphism between the corresponding sℓstructures which is a morphism for the binding map too. In practice, we ask the additional commuting property M(ν(e)) = ν(M(e)), for any v node e of U . 2. Reductions In this section we formally deﬁne and study the βcontractions of the λℓstructures. We start ﬁxing some notation. Notation 2.1. In accord with the deﬁnition of the λstructure links given in subsection 1.1, the direct orientation of λterms is upwards. Anyhow, the natural way to travel a λterm is downwards: from its root toward its v nodes. Because of this in the rest of the chapter we will use path for inverse path, if not otherwise speciﬁed. Moreover, for any λstructure G we will write: • (v0) ϕ(v1) to denote an inverse path v0 ϕ v1 of G but also (⊺) ϕ(v1) when v0 is the root of G and (v0) ϕ(∅) when the last node of ϕ is a v node; e • (vu)e @(vl) to denote the inverse of the connection vl @ vu from the left edge vl to the up edge vu of an @ node e;
110
6. LAMBDA CALCULUS
e • (vu)e @(vr) to denote the inverse of the connection vr @ vu from the right edge vr to the up edge vu of an @ node e; • (vu)e λ(vb) to denote the inverse of the connection vb e vu from the body λ edge vb to the up edge vu of a λ node e; • (vs) a e (vp) to denote the inverse of the connection vp e vs from the principal port to the auxiliary port with name a of a negative mux e; • (vp) e a (vs) to denote the inverse of the connection vs e vp from the auxiliary port with name a to the principal port of a mux e; • (vu)e v(∅) to denote the inverse of the degenerated connection ∅ e vu v starting from a v node e.
2.1. Rooted paths tree. In Chapter 5 we have given a general treatment of the readback problem which is completely adequate also for the case of the λcalculus sharing structures. Nevertheless, the semantical readback has in the λcalculus case a more direct solution exploiting that the least unshared instances of proper λsℓstructures (cf. Deﬁnition 3.6 of Chapter 4) are particular trees—the intended meaning of a proper λsℓstructure is a λterm, so the least unshared instances of λsℓstructures must at least preserve the tree topology of λterms. Then, since any smorphism between a lesssharedinstance G1 of the λsℓstructure G and G itself maps a path of G1 into a path of G , the tree described by the least shared instance of G has to be a suitable restriction of the tree Φ(G ) formed by the inverse rooted paths of G . Definition 2.1 (rooted paths tree). The rooted paths tree of a λsℓstructure G is the set of the rooted paths of G Φ(G ) = {(⊺)
def ϕ(v)
 ϕ ⊂ G}.
Some easy consequences of the previous deﬁnition are: • • • • • each path (⊺) ϕ(∅) is a maximal path of Φ(G ) (w.r.t. the preﬁx ordering); the previous ones are the only ﬁnite maximal paths of Φ(G ); Φ(G ) is ﬁnite iﬀ G is acyclic; Φ(G ) spans over G iﬀ G is connected; the rooted paths tree of a λuℓtree G is isomorphic to G.
Remark 2.1. The rooted paths tree of a λuℓtree G is isomorphic to its λℓstructure G but not to G because, given a generic tree, there is more than one binding map for it that respects the scoping rules.
2. REDUCTIONS
111
2.2. Variable substitutions. We now present two diﬀerent kinds of variable substitutions tailoring the usual λcalculus substitution to the λℓterm case and to the λuℓtree case, respectively. Let us ﬁx the main ingredients of such substitutions. Definition 2.2 (variable occurrence and binder). A variable occurrence is a pair (vv )ev v(∅). A binder is a triple (vu)eλ λ(vb). Notation 2.2. Let G be a λsℓstructure. • We will denote by var(G ) the set of the variable occurrences contained in G. • For any binder (vu)eλ λ(vb) of G , let ν−1(eλ) = {e1, · · · , eh}. We will say v v that: 1. for 1 ≤ i ≤ h, if (vi )ei v(∅), then (vu)eλ λ(vb) binds the variable v v i i v occurrence (vv )ev (∅), or that (vi )ei v(∅) is an occurrence of the v v variable of (vu)eλ λ(vb); 2. k is the cardinality of the binder (vu)eλ λ(vb). Definition 2.3 (U subtree). Let v0 be an edge of a λuℓtree U . The U subtree rooted at v0 is the pair composed of the U substructure U [v0] = {e  ∃ϕ ⊂ U.(v0)
def ϕ(∂h (e))}
isomorphic to the paths tree with root v0, and of the U binding map νU[v0 ] = νUE ν (U[v
def
0 ])
that is the restriction of the binding map of U to the v nodes in the subtree. Remark 2.2. A U subtree U [v0] is not a welldeﬁned λuℓtree since it is not necessarily closed. In fact, the codomain of νU[v0 ] ranges in general over the whole E λ(U), and not over E λ(U[v0]) only, because some of its v nodes might be linked outside it. Definition 2.4 (instance of a U subtree). Let i be a natural number index. The iinstance U i[v0] of a U subtree U [v0] is the copy of U [v0] obtained by: 1. Appending the index i to each vertex and node of U[v0] V(Ui[v0]) = {vi  v ∈ V(U)} E(Ui[v0]) = {ei  (vi)
def ei (w i def
) iﬀ (v)
e(w)}
112
6. LAMBDA CALCULUS
2. Replacing each binding link internal at U[v0] with the correspondent indexed one ν (e)i when ν (e) ∈ E (U[v ]) U U λ 0 def νi 0 ](ei) = U[v νU(e) otherwise 3. Preserving (a) the typing
τi 0 ](ei) = τU(e) U[v (b) the indexing ιi 0 ](vi) = ιU(v) U[v (c) the port names (vi)ei (vi)ei
λ(w @(w i i def
def
) iﬀ . . .
(v)e (v)e
λ(w) @(w)
) iﬀ
of the copied subtree. Definition 2.5 (substitutability). Let U be a λuℓtree. The variable occurrence (vi)ei v(∅) ⊂ U may be substituted with an instance of the U subtree U [v0] when (vi)ei v(∅) is in the scope of any binder not in U [v0] that binds a variable occurrence in U [v0]. Remark 2.3. The last deﬁnition does not forbid that (vi)ei v(∅) might be a variable occurrence of U [v0]. In such a case, the substitution procedures we are going to introduce would recursively copy an instance of the tree inside itself. Anyhow, since we will only study rewritings corresponding to the βrule, it will always be the case that (vi)ei v(∅) ⊂ U [v0]. 2.2.1. Lifted substitution. The lifted substitution is the usual λcalculus variable substitution tailored to λℓterms. In fact, it corresponds to replace the occurrence of a variable with an instance of a λℓterm subtree (substitutable for it) updating at the same time the levels of the subtree instance according to its new position. Definition 2.6 (lifted substitution). Let T be a λℓterm and let (vi)ei be substitutable with an instance of T [v0]. The lifted substitution of (vi)ei with T i[v0] is the λℓterm T [vi := T i[v0]] obtained by:
v(∅) v(∅)
2. REDUCTIONS
113
1. Removing the edge ei from T . 2. Appending to the edge vi the instance T i[v0] by identifying the two edges vi and vi . 0 3. Lifting (incrementing) all the levels of the edges of T i[v0] by the diﬀerence between the levels of vi and v0. Remark 2.4. The lifted substitution process correctly transforms a λℓterm into a new one, the λℓterm T [vi := T i[v0]] • composed of the set of links T [vi := T i[v0]] = ((T − {ei}) ∪ T i[v0])[vi = vi ] 0 where by [vi = vi ] we denote the merging of the two vertices vi and vi into 0 0 i ¯ a new one v s.t. ∂in (¯) = ∂in (v0) and ∂out (¯) = ∂out (vi); v v • whose typing map τT[vi :=Ti (e0 )](e) is the union τT[vi :=Ti [v0 ]] = τT E(T)−{e } ∪ τTi [v0 ]
i
def
def
of the corresponding typing maps of T and T i[v0]; • whose binding map νT[vi :=Ti [v0 ]] = νT E
def
λ (T)−{ei }
∪ νTi [v0 ]
obtained composing the ones of T and of T i[v0], respects the scoping rules because of the deﬁnition of substitutability; • whose indexing function ι (v) when v ∈ V(T ) T def ιT[vi :=Ti [v0 ]](v) = ι i (v) + ιT (vi) − ιT (v0) when v ∈ V(T i[v0])
T [v0 ]
obtained by the union of the one of T and the one of T i[v0] lifted by the the oﬀset ιT (vi) − ιT (v0), is welldeﬁned because of ιT[vi :=Ti [v0 ]](vi ) = 0 ιTi [v0 ](vi ) + ιT (vi) − ιT (v0) = ιT (v0) + ιT (vi) − ιT (v0) = ιT (vi). 0
2.2.2. Unshared substitution. A substitution operation similar to the one for λℓterms may be deﬁned for λuℓtrees too. In fact, since λuℓtrees may contain lifts, we cannot directly extend the previous deﬁnition to them: we would have troubles in correctly lifting the appending subtree because it would not be clear which value we should have to give to the thresholds of the lifts contained in it. The problem is solved inserting a lift between the subtree and the point in which it has to be inserted.
114
6. LAMBDA CALCULUS
Definition 2.7 (uℓsubstitution). Let U be a λuℓtree and let (vi)ei v(∅) be substitutable with U [v0]. The uℓsubstitution of (vi)ei v(∅) with U i[v0], ¯ provided that ιU(vi)+1 ≥ ιU(v0), is the new λuℓtree U [(vi) ai ei (Ui[v0])] obtained by: 1. Applying the lifted substitution of Deﬁnition 2.6 without merging the edges vi and vi . 0 ¯ 2. Connecting vi to vi via a negative lift ei with port name ai and threshold 0 ¯ m < ι(v0), i.e., introducing the connection (vi) ai ei (vi ). 0 Remark 2.5. The uℓsubstitution does not involve any reindexing of the instance of U[v0]. In fact, the correct leveling of the resulting uℓstructure is ¯ achieved by the introduction of the lift node ei whose port oﬀset is correct because of the side condition ιU(vi) − ιU(v0) ≥ −1. 2.3. Unshared βcontractions. Let us now use the two substitution procedures of the previous subsection to deﬁne the unshared contraction rules: the βλrule for the λℓterms and the βurule for the λuℓtrees. Definition 2.8 (βredex). A βredex is a triple (e@ )v β(eλ) composed of an @ node e@ and a λ node vλ connected by an edge v from the left port of e@ to the up port of eλ. Notation 2.3. In a βredex (e@ )v
β(eλ):
• the edge v is the beta edge of the redex; • the triple (v)eλ λ(vb) is the abstraction of the redex, and vb is its body edge; • the triple (vu)e@ @(vr) is the application of the redex, vu is its up edge, vr is its argument edge, and • when the redex occur in a λuℓtree, the subtree rooted at vr is the argument (subtree) of the redex; • the pairs (vi)ei v(∅), with i = 1, . . . , k, and ν−1(eλ) = {e1, . . . , ek}, are the occurrences of the variable of the redex, k is the cardinality of the redex, and ei/vi is the v node/edge of the redex. Definition 2.9 (βλrule). Let r = (e@ )v The βλcontraction of r (βλ) r:T
r βλ β(eλ)
be a βredex of a λℓterm T .
T1
is the rewriting of T into its contractum T1 obtained by: 1. Removing the redex r and the T subtree of its argument.
2. REDUCTIONS
115
2. Merging the body edge and the up edge of r. 3. Replacing each occurrence of the variable of r with a lifted instance of the argument of r. Remark 2.6. Using the symbols introduced in Notation 2.3 the steps of the latter deﬁnition may be more formally written by the following equations (for a graphical description see instead Figure 3): 1. G ′ = T − {e@ , eλ} − T [vr]; 2. G ′′ = G ′ [vu = vb]; 3. T1 = G ′′ [vi := T i[vr]]i=1,...,k. in which G ′ and G ′′ are the intermediate structures obtained by the ﬁrst and the second step of Deﬁnition 2.9, respectively. Definition 2.10 (βurule). Let r = (e@ )v U . The βucontraction of r (βu) r:U
r βu β(eλ)
be a βredex of a λuℓtree
U1
is the rewriting of U into its contractum U1 obtained by: 1. Applying the ﬁrst two steps of the βλcontraction (Deﬁnition 2.9). 2. Using the uℓsubstitution to replace each occurrence of the variable of r with an instance of the argument of r via a lift with threshold ιT (v). Remark 2.7. The formalization of the rule is in this case: 1. G ′ = U − {e@ , eλ} − U [vr]; 2. G ′′ = G ′ [vu = vb]; ¯ 3. Uv = G ′′ [(vi) ai ei (U i[vr])]i=1,...,k. whose corresponding graphical description is given in Figure 14. Remark 2.8. Since the occurrences of the variable of a redex r are substitutable with the argument of r, both the latter βrules are welldeﬁned. Furthermore, the βλcontractum of a λℓterm is a λℓterm, while the βucontractum of a λuℓtree is a λuℓtree. Fact 2.1 (correctness of βu). Any βucontraction r : U βu U1 between two λuℓtrees induces a βλcontraction r : U βλ U1 (of the same redex) between the corresponding λℓterms. Proof. By inspection of the corresponding deﬁnitions.
116
6. LAMBDA CALCULUS
Remark 2.9. The converse of the previous fact in not true: some redexes of the λℓterm U could not be explicit in U because of the presence of lifts between the corresponding @ and λ nodes. 2.4. Ancestors and residuals. Let e1 be a node of the βu or βλ contractum U1 of U . The node e is an ancestor of e1 (w.r.t. the contraction of the redex r) if either 1. e1 = ei, when e1 is a node of the ith instance of the argument of r, or 2. e1 = e, when e1 is not contained in any instance of the argument of r. And analogously for the ancestor of a vertex v1 of U1. Remark 2.10. The only nodes or vertices of a contractum that have no ancestor are: i ) the lifts introduced by a βurule; ii ) the vertices merged during a βλcontraction (cf. the corresponding deﬁnitions, or better Figure 3 and Figure 14). Furthermore, the ancestor of a node, if it exists, is unique; while the ancestors of its doors, if deﬁned, are the doors of its ancestor. Hence, the ancestor relation induces a manytoone map parametric w.r.t. the redex contracted between the nodes (the edges) of U and U1 (the redex is relevant since two diﬀerent redexes might lead to the same contractum) that extends to a relation between any convertible pair U0 and Uk, ρ : U0
r1
U1
r2
···
rk
Uk,
taking its reﬂexive and transitive closure, e.g., in the case of nodes, ek
ρ
e0
iﬀ
ek
rk
ek−1
rk−1
···
r1
e0
for a (possibly empty) sequence of nodes ei ∈ E(Ui). The residual relation is the inverse of the ancestor relation. By this we can ﬁnally say what the residual of a redex is. Definition 2.11 (residual). A redex r1 is a residual of a redex r w.r.t. the reduction ρ when the beta edge of r1 is a residual of r (r is the ancestor of r1) w.r.t. ρ. Namely,
′ (e@ )v′ ′ β(eλ) ρ
(e@ )v
β(eλ)
iﬀ
v′
ρ
v
Remark 2.11. The beta edge of a βredex r is removed by the contraction of r. Consequently, a contracted redex has no residuals.
2. REDUCTIONS
117
Remark 2.12. According to Remark 2.10 our deﬁnition of residual implies that for a redex r, when r ′ r, then even the @ and the λ nodes of r are ancestors of the corresponding nodes of r ′ . The converse is instead true only in the case of the βucontraction. In fact, let r : U βλ U1 be a βλcontraction that substitutes an occurrence (vi)ei v(∅) s.t. (·)e@ @(v) with a subtree T [v0] s.t. (v0)eλ λ(·). The v pair ¯ = (e@ )¯ β(eλ) is a redex created by the contraction of r. Our deﬁnition of r ¯ residual is well suited to model such a case. In fact, since the edge v obtained by equating vi and v0 has no ancestor in U , the redex ¯ is not residual of any edge r of U . Remark 2.13. Let r : U βu U1. Any redex of U1 is a residual of a redex of U . In fact, let us replace βλ by βu in the example of the previous remark. The λ node eλ and the @ node e@ are connected by a lift and not directly by an edge. So, no new redexes may be created by a βureduction even though redexes are created in the corresponding λℓterm. The latter hidden redexes may arise in the λuℓtrees only if the βureduction ρ is followed by a sequence of π interactions propagating the lifts introduced by ρ. 2.5. Developments of βredexes. Let R be a set of redexes of a λℓterm ∗ T . A reduction ρ : T βλ T1, with ρ = r1 · · · rk, is relative to R when any redex ri is the residual of a redex in R. Such a reduction ρ is an Rdevelopment when T1 contains no redex that is residual of a redex in R. Lemma 2.1 (ﬁnite developments). The Rdevelopments of a λterm T are ﬁnite for any set of redexes R. Proof. See [Bar84]. The latter deﬁnitions extend to λuℓtrees just replacing βλ with βu. Anyway, in the case of λuℓtrees we prefer to control the reduction by a diﬀerent device. 2.6. Ports assignments. In the deﬁnition of βucontraction we have not ¯ ﬁxed any rule for the assignment of the port names to the lifts ei introduced by the rewriting—we have not even required that they must be distinct. Hence, the βurule is actually a scheme of rewritings: one for each choice of the set of the port names of the lifts. We now introduce a way to ﬁx such names achieving at the same time a method to control the redexes that may be contracted along a reduction.
118
6. LAMBDA CALCULUS
Definition 2.12 (ports assignment). Let G be λsℓstructure. A ports assignment A for G is a map which activates some variable occurrences x of G associating a port name A(x) to each of them. A ports assignment A is a partial map from var(G) to the set of the port names of the mux auxiliary ports whose domain is the set of the variable occurrences activated by A. By it we enable the contraction of a redex r ﬁxing the port to which each occurrence of the variable of r should be linked by the contraction of r. Hence, given A, the only redexes that may be contracted are the ones whose variable occurrences are active, since the other ones do not know to which ports to connect the occurrences of their variable. Definition 2.13 (Acontraction). A βucontraction r : U βu U1 of a λuℓtree U is relative to the ports assignment A, or it is an Acontraction r, A : U when: 1. The ports assignment A enables the redex r, i.e., all the occurrences of the variable of r are activated by A. ¯ 2. The port name of any lift ei replacing the occurrence xi = (vi)ei v(∅) of the variable of r accords with A, i.e., if A(xi) = ai and vr is the argument ¯ edge of r, then (vi) ai ei (vi ). r 2.7. Developments of ports assignments. Each Aβucontraction r, A : U0 βu U1 of a λuℓtree induces a natural ports assignment Ar of the λuℓtree U1 preserving the port names of the v edges of U0 that have a residual in U1. Ports assignments are then not only a way to mark the redexes which can be reduced in a λuℓtree, but also a natural way to mark redexes that have to be contracted along a reduction, especially because of the invariance of such a marking under βucontraction. Fact 2.2 (invariance of the enabling). Let r, A : U βu U1. A redex of U1 is enabled by the ports assignment Ar induced by the contraction r, A iﬀ its ancestor is enabled by the ports assignment A. Proof. The contraction of the redex r may duplicate variable occurrences but not create new ones. By deﬁnition of Ar any instance of such duplicated variable is active iﬀ its ancestor was.
r A βu
U1
2. REDUCTIONS
119
We say that a reduction ρ = r1 · · · rk is relative to A when r1 is enabled by A and each redex ri+1 is enabled by Ar1 ···ri , for i = 1, . . . , k − 1. Definition 2.14 (Adevelopment). Let A be a ports assignment for the λuℓtree U . An Adevelopment ρ, A : U
ρ ∗ A βu
U1
is a reduction ρ relative to A s.t. the Acontractum U1 does not contain residuals of the redexes enabled by A. The invariance of the enabling stated by Fact 2.2 guarantees not only that any reduction relative to a ports assignment A is a reduction relative to the set of redexes enabled by A, but also the inverse correspondence. Namely, each Rdevelopment is obtainable as Adevelopment of a ports assignment activating the redexes R only, and vice versa. By the way, this implies that the standard properties of Rdevelopments extend to Adevelopments. Lemma 2.2 (ﬁnite developments). Let A be a ports assignment for a λuℓtree U . All the Adevelopments of U are ﬁnite. Proof. Let ρ, A : U βu U1. The βλreduction ρ, R : U βλ U1 induced by ρ (see Fact 2.1) is an Rdevelopment for a suitable set of redexes R of the λℓterm U . Hence, by Lemma 2.1 ρ is ﬁnite, since ρ = ρλ. Remark 2.14. A key point in the previous proof is that ρ is a sequence of βu contractions only and then (see Remark 2.13) that no new redexes are created by ρ: it only duplicates or erases redexes that are residuals of redexes of U . Lemma 2.3 (diamond property). For any pair r1, A1 : U βu U1 and r2, A2 : ∗ U βu U2 of Acontractions there exist two developments ρ2, Ar1 : U1 βu U0 ∗ and ρ1, Ar2 U2 βu U0 reducing U1 and U2 to the same λuℓtree U0. Proof. Standard. Proposition 2.1 (unique Acontractum). All the Adevelopments of a λuℓtree end with the same Acontractum. Proof. Because of Lemma 2.3 the reductions relative to A are locally conﬂuent. Because of Lemma 2.2 they are also strongly normalizing. Hence, by the Newman’s lemma they have a unique normal form.
∗ ∗
120
6. LAMBDA CALCULUS
In particular, the uniqueness of the result of Adevelopments allows to give a parallel reduction strategy considering as a unique step the reduction of a λuℓtree to its Acontractum. Definition 2.15 (parallel Acontraction). Let R be the set of the redexes enabled by a ports assignment A for the λuℓtree U . The Acontraction of U to its Acontractum U1 R, A : U
R A βu
U1
is the rewriting obtained by parallel contracting all the redexes of R. Denoting by r1/r2 the residuals of a redex r1 after the contraction of a redex r2, the diamond property of Lemma 2.3 can be stated by the following commuting diagram:
U r1 A U1 Ar1 Ar2 r2/r1 U0 2.8. Sharing βcontraction. The next deﬁnition is a more formal presentation of the βscontraction rule already depicted in Figure 7. Definition 2.16 (βsrule). Let G be a λsℓstructure. The βscontraction of the βredex r = (e@ )v β(eλ) of G (βs) r:G
r βs
r2 A U2 r1/r2
G1
is the rewriting of G into its contractum G1 obtained by: 1. Removing the redex r and the v nodes e1, . . . , ek of the redex. 2. Introducing a negative kmux e (where k is the cardinality of r) with threshold equal to ιG(v) between the v edges v1, . . . , vk and the argument edge vr of r providing that (a) vi, for i = 1, . . . , k, is the ith door of e ; (b) vr is the principal door of e .
2. REDUCTIONS
121
Using the notations of the previous deﬁnition the λuℓtree G1 is then deﬁned by G1 = (G − {e@ , eλ} − {ei  1 ≤ i ≤ k}) ∪ {e }. v The deﬁnition of ancestor and residual are even easier in this case: we have to consider the case in which the node/edge of G1 was a node/edge of G only. The considerations of section 2.6 on the choice of the port names of the lifts introduced by a βucontraction apply also to the mux introduced by a βscontraction. Anyhow, since the port names of a mux must be distinct, we have to suit Deﬁnition 2.13 to the sharing contractions adding the proviso that “a redex is βsenabled if the port names assigned to its variable occurrences are distinct.” Definition 2.17 (sharing Acontraction). A βscontraction r : G βs G1 of a λsℓstructure G is relative to the ports assignment A, or a sharing Acontraction r, A : U when 1. The ports assignment A βsenables the redex r, i.e., all the occurrences x1, . . . , xk of the variable of r are activated by A and A(xi) = A(xj) iﬀ xi = xj. 2. The port names of the mux e inserted by the redex r accords with A, i.e., if a1, . . . , ak are the port names of e , xi = (vi)ei v(∅) is the ith occurrence of the variable of r, and vr is the argument edge of r, then A(xi) = ai for ¯ any 1 ≤ i ≤ k, or equivalently (vi) A(xi ) e (vr). 2.9. Simulation lemma. The formal deﬁnitions given in the previous subsections allow to ﬁnally state and prove the simulation lemma on which base the proof of the βsrule soundness. Lemma 2.4 (simulation lemma). Let M : U → G be an smorphism from the λuℓtree U to the λsℓstructure G . For any βscontraction r : G βs G1, there + exist a λuℓtree U1 and an smorphism M1 : U1 → G1 s.t. U βu U1.
r A βs
U1
Proof. Let A be a ports assignment for G which βsenables the redex r = ′ ′ (e@ )v β(eλ) only. Let us denote by M−1(r) = {(e@ )v′ β(eλ)  M(v ′ ) = v} the counterimage of the redex r and by M−1(A) the ports assignment for U s.t. M−1(A)(x) = A(M−1(x)), with dom(M−1(A)) = M−1(dom(A)). By deﬁnition ∗ M−1(A) enables the redexes M−1(r). So, let ρ, M−1(A) : U βu U1 be a complete M−1(A)development. Let e be the mux link introduced in G1 by the contraction. Since the only nodes of G1 or U1 which have no ancestor are e and the lifts of U1 introduced
122
6. LAMBDA CALCULUS
is total and welldeﬁned. In the same way we get a map M1 : V(U1) → V(G1). It is immediate to check that such a pair of maps induces an smorphism M1 : U1 → G1. The proof of the simulation lemma shows indeed that the βureductions we use to simulate the βscontraction of r are developments of the counterimage of the redex r. That is, the following diagram commutes: N M U0 M−1(r) M−1(A) r A N1 M1 U1
by the M−1(A)development, the map M1 : E(U1) → E(G1) deﬁned by e ′ ′ when eu M(r) eu and M(eu) M(r) es s eu → e otherwise
3. Proper paths In the case of the λcalculus the algebraic study given at the end of Chapter 4 may be simpliﬁed exploiting the tree topology of λterms. 3.1. Semantics. As usual, we interpret each path of a λsℓstructure G as a block diagram assigning a block to each atomic connection (vu) e(vd) ⊂ ϕ. The corresponding equations are given in Figure 15, in which the lifting sequence S denotes an internal state (an independent parameter) of the corresponding @ node. Remark 3.1. Because of the independence of the node internal states, the transfer function of a path ϕ is parametric w.r.t. the assignment of a suitable lifting sequence to each @ node crossed by the path. In spite of what done in the general case, where such states are relative to the nodes, we prefer here to see the internal states as parameters of the connections (vu)e @(vr) occurring in ϕ. In this way the same node may have diﬀerent internal states for diﬀerent paths. Furthermore we restrict to consider the relevant section (see Deﬁnition 1.11 of Chapter 4) of the internal state only, assuming that if n is the level of the pdl, then S [n,n+1] = S.
3. PROPER PATHS
123
d
n n
d
n n+1 m n
d
n+qi ai n m
d
n ai
@
n+qi
d
S 2 LSeq n; n + 1]
S (d)
d
L m; qi ; ai](d)
L m; qi ; ai](d)
Figure 15. Equations between the doors of λterm nodes. Notation 3.1. Given a path ϕ of a λsℓstructure G . We will denote by: • pdoor(ϕ) the set of the principal doors p = (vu)e @(vr) crossed by ϕ; • ιG(p) the level of the principal door p, i.e., ιG(p) = ιG(vu) = ιG(vr) − 1; • Fϕ[S] the transfer function of a path ϕ relative to the internal state S (see Deﬁnition 3.1), or simply Fϕ when we do not care of the value of the internal state of ϕ. Definition 3.1 (internal state). Let ϕ be a path of a λsℓstructure G . An internal state of ϕ is a map (S) S : pdoor(ϕ) → LSeq
s.t. S(p) ∈ LSeq[ιG(p), ιG(p) + 1], for any p ∈ pdoor(ϕ). Remark 3.2. The internal states of a path correspond to the pdl internal states deﬁned in Section 3.2 of Chapter 4. Definition 3.2 (proper path). A path ϕ is proper if there is no internal state S that opens it, i.e., the transfer function Fϕ[S] is not null for any internal state S of ϕ. Fact 3.1. Let (⊺) ϕ(v) be a proper path of a λsℓstructure G . Its transfer function Fϕ is a lifting sequence from 0 to the level of v, i.e., Fϕ ∈ LSeq[0, ιG(v)]. Proof. By induction on the length of ϕ. 3.2. The proper paths tree. Since a closed path cannot contain subpaths which are open, any preﬁx of a proper path is proper. Consequently, the set of the rooted proper paths of a λsℓstructure spans a tree.
124
6. LAMBDA CALCULUS
Definition 3.3 (proper paths tree). The proper paths tree Π(G ) of a λsℓstructure G is the set of its rooted proper paths Π(G ) = {ϕ ∈ Φ(G )  Fϕ[S] = 0 for any S}. The path tree Φ(G ) of a λsℓstructure is in general inﬁnite: it suﬃces that G is not acyclic to have an inﬁnite path. The proper paths too may be inﬁnite. Nevertheless, we cannot have two distinct proper paths that starting from the root of G reach an edge with the same transfer function. That is, the transfer functions of proper rooted paths allow to distinguish among the ways an edge is reached from the root. Lemma 3.1 (no vicious cycles). Let (⊺) ϕ1 (v) and (⊺) ϕ2 (v) be two rooted proper paths of a λsℓstructure G , the transfer functions of such paths are equal iﬀ the paths coincide, i.e., ∀(⊺)
ϕ1 (v), (⊺) ϕ2 (v) def
∈ Π(G ).
Fϕ1 = Fϕ2
iﬀ
ϕ1 = ϕ2
Proof. By induction on ϕ1 and ϕ2. When ϕ1 = 0 the edge v is the root and then ϕ2 = ϕ1. So, let us assume ϕi = (⊺) ψi (vi) e(v), for i = 1, 2 (note that the last node e of the path is equal for both ϕ1 and ϕ2). We claim that Fϕ1 = Fϕ2 implies v1 = v2 and Fψ1 = Fψ2 . In fact, by case analysis (assuming i = 1, 2): 1. When (v1)e λ(v) or (v1)e @(v), since v is a premise of e we conclude that v1 = v2 and, since Fϕi = Fψi , that Fψ1 = Fψ2 . 2. When (v1)e @(v) (principal door), we have that v1 = v2 and then that p = (vi)e @(v). Let ιG(p) = n and let Si be the internal state of the path ϕi. ≥n ≥n We see that if Fϕi = S i Fψi , with S i = Si(p), then S 1 = Fϕ1 = Fϕ2 = S 2, and Fψ1 = Fψ2 . 3. When (vi) e ai (v), since the edge v is an auxiliary door of e, then a = a1 = a2. From which, v1 = v2 and Fψ1 = L[m, q, a] L[m, q, a] Fψ2 = Fψ2 . 4. When (vi) ai e (v), we have that Fϕi = L[m, qi, ai] Fψi and, since Fψ1 = L[m, q1, a1] L[m, q2, a2] Fψ2 = 0, also that q1 = q2 and a1 = a2. From which, v1 = v2 and Fψ1 = Fψ2 . Hence, in all the cases we have that Fψ1 = Fψ2 and then by the induction hypothesis that ψ1 = ψ2. From which, ϕ1 = (⊺) ψ1 (vi) e(v) = (⊺) ψ2 (v2) e(v) = ϕ2.
3. PROPER PATHS
125
Remark 3.3. The proof of the previous lemma shows not only that the paths ϕ1 and ϕ2 must coincide, but also that if Fϕ1 = Fϕ2 , then the transfer functions Fϕ1 and Fϕ2 must be relative to the same internal state of the path. Remark 3.4 (vicious cycles). We say that Lemma 3.1 states the absence of “vicious cycles” since it proves that if the proper paths tree is inﬁnite, i.e., if there exists a proper path that crosses the same edge an unbound number of times, then the transfer function accumulated by the path is diﬀerent, and in particular it increases, at each of such crossing. Consequently, there is no (vicious) cycle whose transfer function is the empty lifting sequence. 3.3. λuℓterms and λsℓterms. The proper paths tree is the main device for the characterization of the proper λsℓstructures (cf. section 3 of Chapter 4). The absence of vicious cycle described in Remark 3.4 is a key point to prove that the proper paths tree is the correct way in which to unshare a proper λsℓstructure. Definition 3.4 (access path). Let e be a node of a λsℓstructure G . An access path (⊺) ϕ[e] to e is a proper path from the root of G to the conclusion of e, i.e., (⊺) ϕ(∂h (e)) ∈ Π(G ). Remark 3.5. Since proper paths are inverse oriented, no link is contained in its own access path. In particular, when the node e is a v node the access path (⊺) ϕ[e] is also said an access path to the variable occurrence (vu)e v(∅) (in such a case, if x = (vu)e v(∅), then we will also write (⊺) ϕ[x]), while when e is a λ node it is also said an access path to the binder (vu)e λ(vb). Definition 3.5 (correct binding). Let G be a λsℓstructure. The binding map νG is correct when, for any access path (⊺) ϕ[ev ] to a variable occurrence of G , there exists an access path (⊺) ϕλ [νG(ev )] s.t. [ϕ → ϕλ] is a correct binding, i.e., s.t. ϕλ ⊂ ϕ and (Fϕ)<n = Fϕλ . Remark 3.6. A correct binding [ϕ → ϕλ] splits ϕ in two parts: a preﬁx ϕλ (the access path to the binder) and a suﬃx ϕv . The transfer function of ϕ is then Fϕ = Fϕv Fϕλ , with (Fϕ)<n = Fϕλ . This implies indeed that Fϕ = H Fϕλ for a suitable lifting sequence H = (Fϕ)≥n that in general diﬀers from Fϕv . For instance, we can have a case in which Fϕλ = L[m, q, a] H ′ and
126
6. LAMBDA CALCULUS
Fϕv = H ′′ L[m, q, a] L[m, q, a], that is, the path ϕv contains a pair of complementary muxes whose actual level is lower than the actual level of the binder (see Deﬁnition 2.2 of Chapter 5).
d
n n
ni
n
Si (d) Si 2 LSeq n; ni ]
d
Figure 16. Equations corresponding to a binding connection.
Remark 3.7. In terms of equations between the arrows of the corresponding nodes, correct bindings should also be stated saying that (see Figure 16): if d is the value computed by the access path (⊺) ϕλ [eλ] at the up arrow of the λ node eλ, for any access path (⊺) ϕλ [ei ] to the v node ei bound by eλ, there exists v v i Si ∈ LSeq[ι(eλ), ι(ev )], s.t. the value computed at the head of ei is Si(d) (cf. the v constraint that a pdl gives between its arrows). The constraint given in the deﬁnition of correct binding corresponds in our setting to what Lamping [Lam89, Lam90] call “transparency property.” Definition 3.6 (λuℓterm). A λuℓterm is a λuℓtree U in which: 1. All the rooted paths are proper (i.e., Φ(U ) = Π(U )). 2. The binding map νU is correct. Remark 3.8. Since the preﬁxes of a proper path are proper, to ask that Φ(U ) = Π(U ) is equivalent to ask that the access paths to the variable occurrences of the λuℓtree U are proper. Fact 3.2. Each λterm T is a λuℓterm. Proof. Since a λuℓterm does not contain lifts it is immediate that all the rooted paths are proper. By the scoping rules we know that, for any access path
4. SOUNDNESS AND COMPLETENESS OF SHARING REDUCTIONS
127
(⊺) ϕ[e] to a variable occurrence, the access path (⊺) ϕλ [νT (e)] to the corresponding binder is a preﬁx of ϕ, i.e., ϕ = ϕλϕv , for some ϕv . The suﬃx path has the shape ϕv = (v0) ψ0 (v1)e1 @(w1) · · · (vk)ek @(wk) ψk (∅), where v0 is the body door of νT (e). Let n0 = ιT (v0) = n and ni = ιT (wi), for i = 1, . . . , k. We see that ni = n + i and Fψi = 1, for i = 1, . . . , k. Hence, Fϕv = Sk · · · S1 ∈ LSeq[n, n + i], since Si ∈ LSeq[n + i − 1, n + i], for i = 1, . . . , k. Then, since Fϕ ∈ LSeq[0, n] because of Fact 3.1, we conclude that (Fϕ)<n = Fϕλ . Definition 3.7 (λsℓterm). A λsℓstructure N is a λsℓterm for which there exists a complete unsharing M : U → N , i.e., an smorphism in which U is a λuℓterm. The drawing of Figure 17 collects the examples given if Figure 13 and Figure 8. The corresponding structures were a λuℓterm and a λsℓterm between which there exists a complete unsharing. The dashed lines of the ﬁgure show for some nodes the mapping induced by such a complete unsharing. Lemma 3.2. Let G0 and G1 be two λsℓstructures s.t. M : G0 → G1. The rooted proper paths trees of G0 and G1 are isomorphic, i.e., M : G0 → G1 implies M : G0 ≃ G1
Proof. Immediate.
The λuℓterm U of a complete unsharing M : U → N is said the leastsharedinstance of the λsℓterm N (cf. Deﬁnition 3.5 of Chapter 4). Proposition 3.1 (leastsharedinstance). Any λsℓterm has a unique leastsharedinstance. Proof. Easy consequence of Lemma 3.2 and of Lemma 3.1. Definition 3.8 (readback). Let U be the leastsharedinstance of the λsℓdef term N . The λℓterm N = U is the readback of N .
4. Soundness and completeness of sharing reductions In this section we restate for the λcalculus the results given in Chapter 5 for the general case.
128
6. LAMBDA CALCULUS
0
0
0
0
0 0 a1 0 2 0 0 2 0 0
0 a1 a2 0 1 0 a 1 1 0 a2 0
@
@
0
1 1 a2 a1
@
1 0 a 2
Figure 17. A complete unsharing. 4.1. πreductions. We start with the properties of the π reductions of the λuℓterms. Lemma 4.1 (soundness of π). Let r : U π U1 be a πcontraction of a λuℓterm. The contractum U1 is a λuℓterm s.t. U = U1 . Proof. Since in a λuℓterm all the muxes are lifts, the tree topology of U is not lost by the πcontraction r. Hence, the contractum U1 is at least a λuℓtree s.t. U = U1 . To prove that U1 is a λuℓterm it is enough to show that all the πrules but the absorption one do not change the transfer function of the access paths to the variable occurrences (cf. Remark 3.8), i.e., that for any variable occurrence x, if (⊺) ϕ[x] ∈ Π(U ) and (⊺) ψ[x] ∈ Π(U1) are the corresponding access paths, then Fϕ = Fψ. In fact, in the case of the absorption of a lift e by a variable occurrence x = (vx)ex v(∅), let (⊺) ψ[e ]. We have that ψ a e (vx) = (⊺) ϕ[x]. After the
4. SOUNDNESS AND COMPLETENESS OF SHARING REDUCTIONS
129
contraction (with a small abuse of notation) the access path to (the image) of x is (⊺) ψ[x]. Hence, L[m, q, a]Fψ = Fϕ = 0, where m and q are the threshold and the oﬀset of e , and then Fψ = 0. Furthermore, if n = ιU(νU(ex)) is the level <n <n of the binder of x, then m < n and Fψ = Fϕ . That is, the correctness of the binding is preserved. Let us now consider the case in which a positive lift (upwards oriented) e interacts with the righ port of an @ node e@ . Since U is deadlockfree, the threshold m of e (let L[m, q, a] be its transfer function) is lower that the level n of the up edge of e@ . Let ϕu be the path whose last link is the one connected to the up door of e@ , let (⊺) ϕr [er] be the access path to the link connected to the auxiliary door of e (that is, below it), and let (⊺) ϕl [el] be the access path to the link connected to the left door of e@ . After the reduction, such three paths correspond to the path ψu ending at the conclusion of the lift that the reduction insert above e@ , and to the paths (⊺) ψr [er] and (⊺) ψl [el]. The two paths (again, with a small abuse of notation) ϕu and ψu coincide. For the others ′ ′ ′′ we have instead (⊺) ψl [el] = ϕu e′ a (vu)e@ @(vl) a e′′ (vl ) and (⊺) ϕr [er] = ′ ′ ϕu e′ a (vu)e@ @(vr). If S ∈ LSeq[n, n + 1] is the internal state of e@ before the reduction, after the reduction its internal state is S q, and then we see that Fψr = S q L[m, q, a] Fϕu = L[m, q, a] S Fϕu = Fϕr . For the computation of the other transfer function, let us ﬁrst note that, since L[m, q, a] Fϕu ∈ LSeq[0, n+q], we have L[m, q, a] ⊑ Fϕu , then, Fψl = L[m, q, a] Fϕu = Fϕu = Fϕl . In the other cases of π interaction the proof is similar. Lemma 4.2 (strong normalization of π). All the πreductions ρ : U of a λuℓterm U are ﬁnite.
∗ π U1
Proof. Let Fe be the transfer function of the access path (⊺) ϕ[e] to a node e. We can consider the following two measures: i ) the sum k1 of the Fe of the nodes which are not lifts; ii ) the sum k2 of the Fe of the lifts (cf. the proof of the general case, Lemma 2.4 of Chapter 5). The absorption and the lifts rules (annihilation and swap) decrease k2. All the other π interactions decrease k1 (increasing k2 at the same time). Hence, using the lexicographic order, each πrule decreases the combined measure (k1, k2). In accord with what said in section 2 of Chapter 3, apart for the deadlock caused by noncomplementary lifts with the same threshold, in the λcalculus, the only case of deadlock is the one arising when the principal door of a lift with threshold m is the right door of an @ link the conclusion of which is at level m.
130
6. LAMBDA CALCULUS
Lemma 4.3 (no deadlock). A λuℓterm may not contain a deadlock. Proof. Pair of deadlocked lifts may not be present because they would open the correspondent path (remind L[m, q2, a2] L[m, q1, a1]) = 0 iﬀ q1 = q2, and a1 = a2). Analogously, let us assume that there is a path containing a πredex e@ (v)πe , with (vu)e@ @(v) e a (vd), in which ι(v) = n + 1 and n is the threshold of e . The internal state L[n, q, b] opens the path when a = b. Which contradicts the hypothesis (any rooted path of a λuℓterm is proper). Proposition 4.1 (unique π normalform). The πrules are strong normalizing and conﬂuent over the λuℓterms, and the normal form of a λuℓterm U is the λℓterm U . Proof. By Lemma 4.2 we have the strong normalization of U . By Lemma 4.3 we see that any normalformal T of a λuℓterm U does not contain lifts, that is, T = T . By Lemma 4.1 we have then U = T = T . 4.2. Syntactical readback. By Deﬁnition 3.8 we have a semantical way to compute the readback of a λsℓterm. As previously done for the general case (see Chapter 5) we now show that the π interactions give a way to internalize the computation of the readback into the rewriting system. Lemma 4.4 (simulation lemma). Let N be a λsℓterm and let M : U → N be its complete unsharing. For any πcontraction r : N π N1: 1. The contractum N1 of N is a λsℓterm. 2. The contractum of U obtained by M−1(r) : U instance of N1. N r
π + π U1
is the leastshared
N1
M M−1(r) U Proof. See Theorem 4.1 of Chapter 3.
+ π
M1
U1
Theorem 4.1 (syntactical readback). Let N be a λsℓterm with complete unsharing M : U → N . The (unique) πnormal form of N is the λterm U . Proof. By Lemma 4.4, Lemma 4.2, and Proposition 4.1.
4. SOUNDNESS AND COMPLETENESS OF SHARING REDUCTIONS
131
4.3. βreductions. The previous properties are just instantiations of general results. To complete the proof of the soundness of the λcalculus sharing implementation we have to show the correctness of the λcalculus dependent part, that is, the βsrules. Proposition 4.2 (soundness of βu). Let r : U of a λuℓterm. The contractum U1 is a λuℓterm.
βu
U1 be a βucontraction
Proof. Let r = (e@ )v β(eλ). Let (⊺) ϕλ [e@ ] be the access path to the application of the redex, and let vb be its body edge, and vr be its argument edge. Let (vb) ϕi (∅) be a path from the abstraction of r to one of its variable occurrences v and let (vr) ψv (∅) be a path ending at a variable occurrence x in the argument subtree of the redex. With a small abuse of notation, we may say that in U1 the access path to the ith instance of x is ϕλϕi ai ei ψi , where by ψi we mean the v v v copy of ψv in the ith instance of the subtree argument. More important, the corresponding transfer function is Fψi L[n, qi, ai] Fϕi Fϕλ , which coincide with v v the transfer function of the access path to x assuming that the internal state of the pdl (vu)e@ @(vr) is equal to L[n, qi, ai] Fϕi ∈ LSeq[n, n + 1], with ιU(v) = n v and q = ιU(vi ) − n. Hence, after the βucontraction, all the new access paths v are proper. Furthermore, it is not diﬃcult to see that also the correctness of the binding is preserved. Remark 4.1. The latter is a proof of the soundness w.r.t. to the deﬁnition of λuℓterm. The correctness of the βucontractions w.r.t. the usual interpretation of λcalculus has been already proved by Fact 2.1 stating that the following diagram commutes r U1 U · U r U1 ·
Lemma 4.5. Let N be a λsℓterm and let M : U → N be its complete unsharing. For any βscontraction r, A : N βu N1 relative to the ports assignment A: 1. The Acontractum N1 is a λsℓterm. 2. The M(A)contractum of the nonempty βureduction M−1(A), M−1(r) : U βs U1 is the leastsharedinstance of N1.
132
6. LAMBDA CALCULUS
is total and welldeﬁned. In the same way we build a map from V(U1) to V(N1). It is then immediate to check that such maps induce an smorphism M1 between U1 and N1. Theorem 4.2 (soundness of βs). Let N be a λsℓterm. If r : N + then there exists a reduction r : N βλ N1 . Proof. By a direct application of Lemma 4.5. 4.4. Reduction strategies. The completeness of the system is ensured by the existence of a strategy which completely simulates the usual reductions of λcalculus. In fact, the strongly normalization of the π rules for the λuℓterms allows us to deﬁne the λstrategy. Definition 4.1 (λstrategy). The λstrategy is the reduction strategy for π + βs obtained by performing a maximal sequence of π interactions after each execution of a βsrule. Remark 4.2. Let us denote by r : G βλ G1 a step of the λstrategy (i.e., the reduction of the βredex r followed by a maximal sequence of π interactions). If G is a λsℓterm, then G1 is a λℓterm (that is, G1 = G1 ) and, moreover, we see ∗ that G βλ G1 (by Theorem 4.2). Theorem 4.3 (completeness). Let T be a λℓterm. For any βλcontraction ∗ ρλ : T βλ T1, there exists a βs + πreduction ρ : T βs +π T1. Proof. By the previous remark, a reduction ρ is obtainable applying the λstrategy. In the chapter on optimality (Chapter 8) we will see another strategy by which to compute λterm normalforms performing at each step a step of the socalled ∗ ′ complete family reduction. Namely, for any βλreduction ρλ : T βλ T2, such ∗ a strategy ensures that there is a complete family reduction ρ : T βλ N1 s.t. ∗ T2 βλ N1 , which in particular ensures N1 = T2, when T2 is a normalform.
βs
Proof. Let e be the mux introduced in N1 by the contraction. Since the only nodes of U1 and N1 which have no ancestor are e and the lifts introduced in U1 by the M(A)development M(r), the following map from E(U1) to E(N1) e ′ ′ when eu M(r) eu and M(eu) M(r) es s eu → e otherwise
N1,
4. SOUNDNESS AND COMPLETENESS OF SHARING REDUCTIONS
133
The main property of such a reduction strategy will be that for the λIcalculus it is optimal in terms of the number of βsrule executed.3 Theorem 4.4 (conﬂuence of βs + π). The βs + π rewriting system is conﬂuent over the λsℓterms. Proof. Let N be a λsℓterm. If ρ1 : N βs +π N1 and ρ2 : N βs +π N2, ∗ then there exists Ni π Ni , with i = 1, 2. Because of the conﬂuence of the λ∗ ∗ calculus, there exists a λℓterm T0 s.t. Ni βλ T0 (since N βλ Ni ), with i = 1, 2. Hence, because of Theorem 4.3, we conclude that there exists T0 s.t. ∗ Ni βs +π T0.
∗ ∗
In presence of Kabstractions we should have also taken into account the problem of the execution of redexes which are not needed for the computation of the result: an optimal reduction should not execute them.
3
134
6. LAMBDA CALCULUS
CHAPTER 7
MELL
We now apply the methodology to the case of the linear logic without weakening (IMELL). As already done for the λcalculus, also for IMELL we give an alternative way to prove the properties of the π interactions. We introduce a suitable parsing grammar for the leveled proof nets (for a good explanation of such parsing method for the multiplicative case only see [Laf95a]) which has the nice property that if a structure is accepted by a parsing reduction, then the structure is accepted by any parsing reduction, that is, the parsing grammar is conﬂuent over the structures accepted by it. Such a grammar extended by the π rules gives a rewriting system which, interpreted at its turn as a grammar, accepts only the proper structures (see section 3 of Chapter 4) which are shared representation of proof nets. The chapter opens with a presentation of the system (IMELL) and its decoration by nesting levels (IMELLℓ). The correspondence between the two calculi are the analogous of the ones between structures with boxes and ℓstructures in which boxes are implicitly represented by levels (see [MM95a]). We omit to repeat the study of the soundness and completeness of the sharing reductions, since such properties and the corresponding proofs are just adaptations of the λcalculus ones to the present case. 1. The sequent presentation of MELL The standard sequent presentation of the multiplicative and exponential fragment of linear logic (MELL) consists of the derivation rules of Figure 1 (which deﬁnes at the same time the syntax of the linear logic formulae) plus the weakening rule: ⊢Γ ?W ⊢ Γ, ?A The fragment of MELL in Figure 1 is called IMELL. The restriction imposed to obtain it—the absence of weakening—is analogous to the one imposed on λcalculus to obtain the λIcalculus by forbidding the presence of Kabstractions. That explains the reasons of the use of the name IMELL.
135
136
7. MELL
⊢ A, A⊥ ⊢ Γ, A
ax cut
⊢ ∆, A⊥ ⊢ Γ, ∆
⊢ Γ, A, B ⊢ Γ, A B ⊢ Γ, A ⊢ ∆, B ⊢ Γ, A B ⊢ Γ, A ⊢ Γ, ?A ⊢ Γ, ?A, ?A ⊢ Γ, ?A ⊢ ?Γ, A ⊢ ?Γ, !A ! ?D ?C
Figure 1. IMELL Notation 1.1. In the presentation of MELL: 1. The latin letters A and B denote linear logic formulae. Among them we distinguish: (a) the atomic formulae, chosen from a denumerable set of direct X or negated X symbols; (b) the multiplicative formulae, of the shape A B or A B; (c) the exponential formulae, of the shape !A or ?A. 2. The symbol A⊥ denotes the negation of A deﬁned by: ⊥ (a) X⊥ = X and X = X; (b) (A B)⊥ = A⊥ B⊥ and (A B)⊥ = A⊥ B⊥ ; (c) (!A)⊥ = ?A⊥ and (?A)⊥ = !A⊥ . From which we may state that (A⊥ )⊥ = A. 3. The greek letters Γ and ∆ denote possibly empty sets of generic formulae. 4. A greek letter preﬁxed by a ? symbol (e.g., ?Γ ) denotes a possibly empty set of ? formulae ⊢ ?A1, . . . , ?Ak. Remark 1.1. In the presentation of MELL there is no exchange rule since we assume that the sequent ⊢ A1, . . . , Ak is a set of derived formulae {A1, . . . , Ak} and not an ordered sequence.
2. IMELL PROOF NETS
137
Note that, according to Notation 1.1, the ! rule of MELL may be applied only when all the formulae of the premise sequent but one are ? formulae. We call active the formulae relevant to the application of a rule. For instance, referring to the previous presentation, the active formulae of a cut and of an ax rule are A and A⊥ , the active formulae of a rule are A, B, and A B, etc. The principal formula of a rule is the active formula of the conclusion, with the exception of the ax and cut rules in which the principal formula is one of its active formulae (the choice is irrelevant because of their duality). The active formulae of a rule which are not principal are the side formulae of the rules. Notation 1.2. According to the type of the corresponding connective, the rules classify in: 1. identity rules: the ax (axiom) and cut rules; 2. multiplicative rules: the (par) and (tensor) rules; 3. exponential rules: the rules for the ! (whynot) and ? (ofcourse) connectives, for which the standard names are (a) promotion for the ! rule; (b) dereliction for the ?D rule; (c) contraction for the ?C rule; (d) weakening for the ?W rule. 2. IMELL proof nets The proof net Net(Π) associated to a MELL derivation Π is a structure of links in which: 1. There is an arrow for each formula1 of Π. 2. There is a link e for each inference rule of Π connecting the side formulae of the rule to its principal formula—the premises and the conclusion of e, respectively— with the obvious exception of the identity rules—for which both the active formulae become either premises or conclusions. ⊢ ?Γ, A 3. For each link corresponding to a promotion r of Π there is a grouping ⊢ ?Γ, !A constructor called box containing all the links whose corresponding rules precede r in Π. 2.1. IMELL links. In more details, to build proof nets we use:
1
For this reason in the following we will sometimes use formula as a synonym of arrow.
138
7. MELL
• Two kinds of identity links: the ax link with two conclusions and no premises, and the cut link with two premises and no conclusions.
ax
A A? B A
cut
A?
A A
• Two kinds of multiplicative links: the link and the link both with two premises, the left and the right one, and one conclusion.
B
O AOB A B
• Three exponential links: the ? link and the ! link with one premise and one conclusion each, and the (contraction) link (the one in the middle in the next picture) with k premises and one conclusion.
A
?
?
A
?
A
?
A
A
!
?
A
?
A
!
A
• The box constructor. Graphically represented by a square grouping the links contained in it. box
A1
?
N
?
Ak
!
A
?
A1
?
Ak A
!
According to the latter picture (cf. Section 2 of Chapter 2), we can state in more details that a box B of an IMELL proof net N is an N subgraph: 1. with a unique ! door link, the principal door link (pdl), whose conclusion is the principal door of B (the !A formula in the picture);
2. IMELL PROOF NETS
139
2. with a set of ? door links, the auxiliary door links (adls), whose conclusions are the auxiliary doors of B (the ?Ai formulae in the picture); 3. without any other conclusion or premise. Following the deﬁnitions given in Chapter 2, in the graphical representations of nets the vertices are drawn as arrows labeled by the formula they represent: an arrows pointing to the link to denote a premise, and an arrow outgoing from the link to denote a conclusion. We remind again that, even if the chosen terminology might seem misleading, it is justiﬁed by the fact that the dual of a proof net is a graph (and not an hypergraph) with some dangling conclusion arrows closed by suitable root nodes. Nevertheless, we prefer to present nets as hypergraph since in this way we naturally have that a link is a pair composed of the set of its (distinguished) premises and by the set of its (distinguished) conclusions. Remark 2.1. Our deﬁnition of box is more restrictive than the usual one of linear logic. We have the additional provisos that: 1. an auxiliary door of a box may not be one of the conclusions of an axiom; 2. an auxiliary door of a box may not be the conclusion of a contraction. The ﬁrst proviso implies that we cannot directly associate a proof net to the following IMELL derivation: ⊢ ?A, !A⊥ ⊢ ?A, !!A⊥ ax !
To do it we have to transform the previous derivation into the following one which proves the same sequent: ax ⊢ A, A⊥ ?D ⊢ ?A, A⊥ ! ⊢ ?A, !A⊥ ! ⊢ ?A, !!A⊥ The second proviso means that, incrementally building the proof net associated Π to a derivation r ⊢ ?Γ, A , the box B corresponding to the promotion rule r contains ⊢ ?Γ, !A all the links of Net(Π) but the trees of links (if any) ending at a formula in ?Γ . Which in terms of IMELL derivations means that the contractions executed on a formula which is auxiliary door of a box must be delayed till the box is closed. For instance, the left derivation in the following picture must be transformed into the wright one, and so on.
140
7. MELL
Π ⊢ ?Γ, ?B, ?B, A ⊢ ?Γ, ?B, A ⊢ ?Γ, ?B, !A
?C !
Π ⊢ ?Γ, ?B, ?B, A ⊢ ?Γ, ?B, ?B, !A ⊢ ?Γ, ?B, !A
! ?C
The second proviso of Remark 2.1 does not complete the special treatment we deserve to the contraction rule. In fact, in our deﬁnition of proof nets we can contract in one step an arbitrary number of formulae. Therefore, since in MELL the ?C rule is binary, we assume that any tree of links contracting k leafs to a unique root formula is always merged into a unique kary link with the leaves of the tree as premises and the root as conclusion. Nevertheless, we will not care to give proof net pictures containing trees of such kind: we simply assume that all the links in such trees are actually the same one. Remark 2.2. Studying the dynamics of the proof nets it would be useful to have a unique link enclosing the derelictions which introduce the ? connective in front of the formulae A that are eventually contracted into a unique ?A. To this purpose we will treat structures of the following kind
A
?
A
?
A
?
?
A
as an atomic link with k formulae A as premises and the formula ?A as conclusion, unifying them into a unique link. Such a uniﬁcation is however not sound when one of the formulae A is one of the conclusions of an axiom. Consequently, we simply forbid to contract a principal formula of an axiom. The cause of the latter side condition for the contraction rule and of the ﬁrst proviso for the box construction is the presence of axioms with the shape . From the logical point of view, the more elegant solution to avoid ⊢ ?A, !A⊥ them would be to force the principal formulae of the axioms to be atomic. Even if in this way the expressiveness of the calculus does not change, such a restriction would be too strong for our purposes. In fact, to remove composite axioms would
2. IMELL PROOF NETS
141
imply to replace each of them by a tree with a link for each connective of its principal formula. In this way, during proof net reductions we should have to copy and move wide parts of the graph which could have had been very smaller, or not present at all. A less restrictive solution would be to forbid axioms containing exponential formulae. The solution we will give in the next section is instead to recognize the degenerate case transforming them into a permitted conﬁguration modifying the initial proof as less as possible (see the base case of the Inc map at page 150). 2.2. DanosRegnier correctness criterion. Proof nets have been introduced starting from IMELL derivations. Here, we are going to give a characterization of them independent from the logic. Definition 2.1 (proof structure). An IMELL proof structure N is a pair composed of: 1. A structure (N, τN) over the signature ΣMELL = {ax, cut, , , !, ?, }. 2. A boxing map BoxN : E !(N) → 2E(N) associating a box to each ! link of N such that: (a) each ! link is the pdl of its box, i.e., e! ∈ ∂E (BoxN(e!)), for any e! ∈ E !(N); (b) the box nesting condition is satisﬁed, i.e., if e!, e!′ ∈ BoxN(e!) ∩ / ′ ′ BoxN(e! ), then BoxN(e!)∩BoxN(e! ) = ∅, otherwise if e!′ ∈ BoxN(e!), then BoxN(e!′) ⊂ BoxN(e!), for any e!, e!′ ∈ E !(N). Remark 2.3. Not all the IMELL proof structures are IMELL proof nets. In particular, let us note that: 1. Forgetting the orientation of links, the proof nets are connected hypergraphs. 2. A box encloses a wellformed proof net, then its interior is connected. 3. Two distinct boxes of a proof net may share some auxiliary ports. 4. The boxes of a proof net may only nest and not partially overlap (cf. the box nesting condition given in section 2 of Chapter 2). The next one is a correctness criterion characterizing the proof structures that are proof nets. It exploits that certain undirected structures derived from a proof net are trees.
142
7. MELL
Definition 2.2 (switch). Let N be an IMELL proof structure. The undirected hypergraph S is a switch of N (written S ∈ Switch(N )) when it is obtained by: 1. Forgetting the orientation of the links of N. 2. Selecting some boxes and replacing each of them by a single hyperedge connecting its doors. 3. Replacing each and link by an hyperedge connecting the conclusion of the link to only one of its premises. Remark 2.4. The second step of the deﬁnition of switch is sound because of the box nesting condition. Criterion 2.1 (DRcorrectness). An IMELL proof structure N satisﬁes the DanosRegnier correctness criterion, or it is DRcorrect, when each switch of N is connected and acyclic, that is, it is a tree. Theorem 2.1 (sequentialization). An IMELL proof structure N is DRcorrect iﬀ there exists an IMELL derivation Π for which N = Net(Π). Proof. See [Dan90]. The sequentialization theorem ensures that, given a proof structure DRcorrect N , there exists an inductive way to build it mirroring the order of application of the rules of one of the IMELL derivation corresponding to it, and vice versa. Because of this theorem, the IMELL proof nets can be even deﬁned forgetting their connections with linear logic. Definition 2.3 (proof net). An IMELL proof net is an IMELL proof structure DRcorrect. First easy consequences of the characterization of the previous deﬁnition (cf. Remark 2.3) are that an IMELL proof net N is connected (remind that the weakening rule is not allowed) and that each box B of N is at its turn an IMELL proof net (because of the box nesting condition, each switch of N in which B is not collapsed into an hyperedge induces a connected and acyclic switch of B, etc.). Remark 2.5. The boxes of an IMELL proof net are part of the structure and their shape is crucial for the reductions of proof nets that will be presented in subsection 2.4. Furthermore, it is even true that to recover the boxes of a proof net whose box assignment is missing it is not an immediate task. For instance, the
2. IMELL PROOF NETS
143
ax ax
?
?
O
? !
Figure 2. Two examples of box assignment: choosing the box, the structure is an ℓnet; choosing the box, the structure is not an ℓnet. proof structure of Figure 2 obtained assigning to the ! link the box corresponding to the continuous line is correct, while the one obtained assigning to it the dashed box is not a proof net (replacing the box with an hyperedge we get a cyclic switch). The problem is that boxes give a strong constraint on the sequentatialization of a proof net: they state that in all the derivations corresponding to the proof net the content of a box is above what is outside the box. In the example of the ﬁgure, for instance, the wrong box states that in any derivation of the proof net the must be above the , but it is easy to check that a derivation with such a shape cannot exist (cf. Example 4.1 and Example 4.2). 2.3. Parsing. To be more uniform with our graph treatment of proofs, the sequent presentation of IMELL given at the beginning of the chapter will be here reformulated in terms of a graph grammar accepting proof nets. To this purpose we introduce a new kind of link, called net, with no premises and with a nonempty set (of arbitrary cardinality) of conclusions. Definition 2.4 (Proof net grammar). The IMELL proof net grammar is the graph grammar σ which composes of the rules in Figure 3 (multiplicative part) and Figure 4 (exponential part) in which the net link plays the role of a nonterminal symbol. The application of the rules of σ must indeed comply to the following constraints: 1. The two net links in the parsing rule for the cut link must be distinct. link and in the one for the
144
ax
7. MELL
net
A
net
A? A A?
net
A
A?
net
A1
Ak Ai A1
cut
Bh Ai+1 Ak
B1
A1
net
Ak Bh
B1
net
O AiOAi+1
A1
AiOAi+1
Ak
net
Ak Bh Ak Bh
net
net
A1
B1
A1
Ak Bh
B1
Figure 3. The parsing grammar σ: multiplicative part. 2. All the links of the lefthandside of a rule must be contained in the same boxes. Remark 2.6. The second proviso of the previous deﬁnition means that the boxes of a structure are a partial ordering between the links to which any sequence of rules of σ must comply. For instance, the parsing step of Figure 5 is obviously wrong. In fact, starting from the lefthandside of the example the only possibility is to parse the link only after the parsing of the ! link and of its box. Definition 2.5 (parsing structure). A proof structure in which a whole substructure is replaced by a net link is said a parsing structure. The accepting normal forms of σ are the parsing structures composed of a single net link. A sequence of productions of σ is a parsing reduction or σreduction.
2. IMELL PROOF NETS
net
145
net
A Ak
?
net
A1
?
A1
Ak
?
A
net
A
?
A
?
A Ak A1
A1
? box net
Ak
?
A
net
A
?
A1
?
Ak
!
A
!
?
A1
?
Ak
!
A
A
Figure 4. The parsing grammar σ: exponential part.
box net
box net
O
!
!
Figure 5. Parsing order constraint given by a box.
Notation 2.1 (accepting parsing reduction). A parsing reduction of a proof net N is an accepting parsing reduction when it ends with an accepting normal form. An accepting parsing reduction ρ of a proof structure N is denoted by ∗ ρ:N σ net.
146
7. MELL
net
net
net
cut
cut
net
Figure 6. The parsing critical pair between a cut and a
link.
Definition 2.6 (contractibility). A parsing reduction starting from a parsing structure N is contracting reduction of N if it reduces it to an accepting normal form. In such a case, the parsing structure N is said contractible. The proof net grammar is a terminating rewriting system—just note that each rule decreases the size of its lefthandside parsing structure—and, since the conclusions of the parsing normal forms are the conclusions of the starting parsing structures, the accepting normal form (when it exists) is unique. Nevertheless, the parsing system σ is not conﬂuent. For instance, let us take the critical pair of Figure 6. The two parsing structures on the righthandside are not reducible to a common parsing structure. It is however easy to see that both the parsing structures on the righthandside of Figure 6 are not contractible (in the top one there is no way to erase the cut while in the bottom one there is no way to erase the ). So, conﬁgurations as the one of Figure 6 are not reachable parsing a proof net. Proposition 2.1. The σ parsing grammar is strongly normalizing and conﬂuent over the IMELL proof nets. Proof. We already remarked that σ is strongly normalizing. To prove the conﬂuence let us show that σ is locally conﬂuent over any contractible parsing structure. The critical pairs of σ may not involve boxes or ax links. By the analysis of the case of Figure 6 we see that a critical pair between two rules parsing a cut and a may not arise in a contractible parsing structure, and
2. IMELL PROOF NETS
147
analogously for the cut/cut and locally conﬂuent.
/
cases. All the other critical pairs are instead
Theorem 2.2. A proof structure N is contractible iﬀ it is the image of an IMELL derivation Π, i.e., N = Net(Π) for some Π. Proof. By induction of the length of a parsing reduction we see that at any step a net link represents an N substructure which is a proof net.
2.4. Cut elimination for IMELL proof nets. It is well known that each sequent provable by IMELL has a cut free derivation, i.e., a derivation that does not contain any cut rule. Hence, as a deduction system the cut is not necessary. From a computational point of view instead, the wellknown correspondences between natural deduction systems—here the proof nets—and typed calculi give to the cut the meaning of the composition operator of the calculus and to the socalled cut elimination (the Gentzen’s hauptsatz ) reductions the meaning of computations. According to the type of the links connected by a cut, we have three kinds of cut conﬁgurations: 1. The multiplicative cut that connects a and a link. 2. The exponential cut that connects a or a ? link to an ! link. 3. The identity cut in which a premise of the cut link is a conclusion of an ax link. For each of the previous conﬁgurations we have a corresponding β contraction (we use β since such rules play here the same role of the λcalculus βrule): 1. The multiplicative contraction βm:
A O AOB
B A?
cut
B?
m
A
cut
B A?
cut
B?
A? B?
2. The exponential contraction βe:
148
box box
7. MELL
box
N
!
N
? ? !
?
e
N1
!
Nk
!
N
cut
?
!
cut
!
cut
3. The identity contraction βi:
ax
A
i
A A
A
A?
cut
The previous cut elimination rules preserve the correctness of proof nets. Furthermore, the reductions of IMELL proof nets are terminating to a unique normal form, because of the next theorem. Theorem 2.3. The cut elimination for IMELL is strong normalizing and conﬂuent. Proof. See [Gir87].
3. IMELLℓ The calculus IMELLℓ is a leveled version of IMELL in which a nonnegative index (a level) is associated to each formula of a derivation according to its box nesting depth in the corresponding proof net. The corresponding decorated derivations will be denoted by a superscript ℓ. Furthermore, we will say that a decorated derivation Πℓ is an IMELLℓ decoration if it is derived by applying the following decorated rules:
3. IMELLℓ
149
⊢ An, A⊥n
ax cut
⊢ Γ ℓ, An ⊢ ∆ℓ, A⊥n ⊢ Γ ℓ, ∆ℓ ⊢ Γ ℓ, An, Bn ⊢ Γ ℓ, A Bn ⊢ Γ ℓ, An ⊢ ∆ℓ, Bn ⊢ Γ ℓ, A Bn ⊢ Γ ℓ, ?An, ?An ⊢ Γ ℓ, ?An ⊢ ?Γ ℓ≤n, An+1 ⊢ ?Γ ℓ≤n, !An ⊢ Γ ℓ, Am≥n ⊢ Γ ℓ, ?An ?C ! ?D
In which by Γ ℓ we denote a decorated set of formulae. Notation 3.1. The superscript ℓ ≤ n points out that all the indexes of the decoration are not lower than n, i.e., ?Γ ℓ≤n = ?An1 , . . . , ?Ank with ni ≤ n, k 1 for i = 1, . . . , k. The latter notation extends to other operators too, e.g., if n Γ ℓ = ?An1 , . . . , ?Ank , then Γ ℓ+p = ?A1 1 +p, . . . , ?Ank +p. 1 k k It is readily seen that any IMELLℓ decoration is an IMELL derivation but, because of the side condition on the levels of the !rule, not all the IMELL derivations are decorable. An easy example is the already met derivation (see page 139) in which we try to build a box around an exponential axiom. Starting with the active formulae of the axiom at level n + 1, the successive promotion rule would violate the side condition that the levels of the auxiliary doors must be lower or equal than n: ax !
⊢ ?An+1, !A⊥n+1 ⊢ ?An+1, !!A⊥n
Anyhow, we also pointed out that, since we constrained the adls of a box to be conclusions of dereliction rules, such a case is forbidden. The corresponding expansion we suggested to prove the same sequent admits instead a decoration:
150
7. MELL
ax ⊢ A2, A⊥2 ?D ⊢ ?A0, A⊥2 ! ⊢ ?A0, !A⊥1 ! ⊢ ?A0, !!A⊥0 We will see that the latter is the only case that requires a transformation of the IMELL derivation in order to prove that there exists a corresponding IMELLℓ derivation with the same conclusion. It is instead immediate that the decoration of an IMELL derivation is not unique. Just note that if Πℓ is an IMELLℓ decoration, then Πℓ+p is a decoration too, for any p s.t. ℓ + p ≥ 0. 3.1. Standard decorations. To prove that all the IMELL derivations are decorable we ﬁrst introduce an operator Inc taking a decoration Πℓ with the conclusion split in two sets of formulae, ?Γ ℓ=0 and ∆ℓ, transforming Πℓ into a new decoration in which the levels of the formulae of ∆ℓ are incremented by 1. The deﬁnition of Πℓ Inc ⊢ ?Γ ℓ=0; ∆ℓ ⊢ ?Γ ℓ=0, ∆ℓ+1 is by induction on the cardinality of ?Γ ℓ=0 and on the length of Πℓ. We remark the use of the semicolon to denote how the conclusion of the argument of Inc is split. The trivial situation is when ?Γ ℓ=0 is empty: in such a case all the levels of the formulae in Πℓ are simply incremented by 1: Πℓ ⊢; ∆ℓ
Inc
Πℓ+1 ⊢ ∆ℓ+1
When ?Γ ℓ=0 is not empty, we have to proceed by induction on the derivation. The base case is: ax ⊢ A2, A⊥2 ?D ⊢ ?A0, A⊥2 ! ⊢ ?A0, !A⊥1
ax
Inc
⊢
?A0; !A⊥0
which, how previously noted, is the only one that does not preserve the structure of the derivation requiring a slight modiﬁcation of it. The cut, the multiplicative connectives, and the ! cases are straightforward:
3. IMELLℓ
151
cut
Πℓ Θℓ ℓ=0 ℓ=0 ⊢ ?Γ0 ; ∆ℓ , An ⊢ ?Γ1 ; ∆ℓ , A⊥n 0 1 ℓ=0 ℓ=0 ⊢ ?Γ0 , ?Γ1 ; ∆ℓ , ∆ℓ 0 1 Inc
Inc
Πℓ Θℓ Inc ℓ=0 ℓ=0 ⊢ ?Γ0 ; ∆ℓ , An ⊢ ?Γ1 ; ∆ℓ , A⊥n 0 1 ℓ=0 ℓ=0 ⊢ ?Γ0 , ?Γ1 , ∆ℓ+1, ∆ℓ+1 0 1 Πℓ Inc ⊢ ?Γ ℓ=0; ∆ℓ, An, Bn ⊢ ?Γ ℓ=0, ∆ℓ, A Bn+1
cut
Πℓ ⊢ ?Γ ℓ=0; ∆ℓ, An, Bn ⊢ ?Γ ℓ=0; ∆ℓ, A Bn
Inc
Πℓ Θℓ ℓ=0 ℓ=0 ⊢ ?Γ0 ; ∆ℓ , An ⊢ ?Γ1 ; ∆ℓ , Bn 0 1 ℓ=0 ℓ=0 ⊢ ?Γ0 , ?Γ1 , ∆ℓ , ∆ℓ , A Bn 1 0 Inc
Inc
Θℓ Πℓ Inc ℓ=0 ℓ=0 ⊢ ?Γ1 ; ∆ℓ , Bn ⊢ ?Γ0 ; ∆ℓ , An 1 0 ℓ+1 ℓ+1 ℓ=0 ℓ=0 n+1 ⊢ ?Γ0 , ?Γ1 ; ∆0 , ∆1 , A B Πℓ ⊢ ?Γ ℓ=0; ?∆ℓ≤n, An+1 ⊢ ?Γ ℓ=0, ?∆ℓ+1≤n+1, !An+1
!
Πℓ ⊢ ?Γ ℓ=0; ?∆ℓ≤n, An+1 ⊢ ?Γ ℓ=0; ?∆ℓ≤n, !An
Inc
Inc
!
In particular, note that the side condition in the ! rule is deﬁnitely satisﬁed, since all the levels of the formulae on the right of the semicolon are incremented. The ?C case has instead two subcases depending on the position w.r.t. the semicolon of the contracted formula: Πℓ ⊢ ?Γ ℓ=0, ?A0, ?A0; ∆ℓ ⊢ ?Γ ℓ=0, ?A0; ∆ℓ Πℓ ⊢ ?Γ ℓ=0; ∆ℓ, ?An, ?An ⊢ ?Γ ℓ=0; ∆ℓ, ?An Πℓ ⊢ ?Γ ℓ=0, ?A0, ?A0; ∆ℓ ⊢ ?Γ ℓ=0, ?A0, ∆ℓ+1 Πℓ ⊢ ?Γ ℓ=0; ∆ℓ, ?An, ?An ⊢ ?Γ ℓ=0, ∆ℓ+1, ?An+1
Inc
Inc
?C
?C
Inc
Inc
?C
?C
Also in the ?D case we have to take account of the position of its principal formula. In fact, when it is on the right of the semicolon we immediately have:
152
7. MELL
?D
Πℓ ⊢ ?Γ ℓ=0; ∆ℓ, An+p ⊢ ?Γ ℓ=0; ∆ℓ, ?An
Inc
Inc
Πℓ ⊢ ?Γ ℓ=0; ∆ℓ, An+p ⊢ ?Γ ℓ=0, ∆ℓ+1, ?An+1
?D
while when it is on the left of the semicolon, the premise of the principal formula has to be moved to the right of the semicolon in the recursive application of Inc, that is:
?D
Πℓ ⊢ ?Γ ℓ=0, Ap; ∆ℓ ⊢ ?Γ ℓ=0, ?A0; ∆ℓ
Inc
Πℓ Inc ⊢ ?Γ ℓ=0; Ap, ∆ℓ ⊢ ?Γ ℓ=0, ?A0, ∆ℓ+1
?D
Note that the last one is the only case in which the diﬀerence between the levels of the principal formula and of its premises changes. In fact, in the resulting derivation such a ?D inference becomes the dereliction of Ap+1 to ?A0. Remark 3.1. The last case of the deﬁnition of Inc could have been split deserving a special treatment to the case in which the principal formula has the shape ??A0, that is: Πℓ ⊢ ?Γ ℓ=0, ?A0; ∆ℓ ⊢ ?Γ ℓ=0, ??A0; ∆ℓ Inc
Inc
?D
Πℓ ⊢ ?Γ ℓ=0, ?A0; ∆ℓ+1 ⊢ ?Γ ℓ=0, ??A0, ∆ℓ+1
?D
It is easy to check that with such a deﬁnition Fact 3.1 remains true. Anyhow, in this way we would have a box deﬁnition diﬀerent from the standard one. Fact 3.1. Let Πℓ be an IMELLℓ decoration whose conclusion is the sequent Πℓ ⊢ ?Γ ℓ=0, ∆ℓ. The derivation Inc is an IMELLℓ decoration whose ⊢ ?Γ ℓ=0; ∆ℓ conclusion is the sequent ⊢ ?Γ ℓ=0, ∆ℓ+1. Proof. By inspection of the deﬁnition of Inc. The Inc operator can then be used to deﬁne the Dec function which associate to each IMELL derivation a standard decoration by the mapping:
4. IMELLℓ PROOF NETS
153
ax Π ⊢ Γ, A
Dec
⊢ A, A⊥
Dec
⊢ A0, A⊥0
ax
cut
Θ ⊢ ∆, A⊥ ⊢ Γ, ∆ Π ⊢ Γ, A, B ⊢ Γ, A B
Πℓ Θℓ ⊢ Γ ℓ=0, A0 ⊢ ∆ℓ=0, A⊥0 ℓ=0, ∆ℓ=0 ⊢Γ Πℓ ⊢ Γ ℓ=0, A0, B0 ⊢ Γ ℓ=0, A B0 Πℓ Θℓ ⊢ Γ ℓ=0, A0 ⊢ ∆ℓ=0, B0 ⊢ Γ ℓ, A B0 Πℓ ⊢ Γ ℓ=0, A0 ⊢ Γ ℓ=0, ?A0
cut
Dec
Π Θ ⊢ Γ, A ⊢ ∆, B ⊢ Γ, A B Π ⊢ Γ, A ⊢ Γ, ?A
Dec
?D
Dec
?D
?C
Π ⊢ Γ, ?A, ?A ⊢ Γ, ?A Π ⊢ ?Γ, A ⊢ ?Γ, !A
Dec
Πℓ ⊢ Γ ℓ=0, ?A0, ?A0 ⊢ Γ ℓ=0, ?A0 Inc Πℓ ⊢ ?Γ ℓ=0; A0 ⊢ ?Γ ℓ=0, !A0 !
?C
!
Dec
where Πℓ and Θℓ are denotations for Dec(Π) and Dec(Θ). Fact 3.2. Let Π be an IMELL derivation of ⊢ Γ . The decoration Dec(Π) is an IMELLℓ proof of ⊢ Γ ℓ=0. Proof. Just note that the decorated promotion rule obtained applying Dec is sound since the decoration Πℓ with conclusion ⊢ ?Γ ℓ=0, A0 is transformed by Inc into a decoration with conclusion ⊢ ?Γ ℓ=0, A1. Definition 3.1 (standard decoration). An IMELLℓ decoration Πℓ is standard when Dec(Π) = Πℓ. 4. IMELLℓ proof nets An IMELLℓ proof net, or ℓnet for short, is an indexed proof net constructed according to the rules of IMELLℓ. Hence, using the terminology introduced in Chapter 2 it is an ℓstructure over the signature ΣMELL with the following indexing rules:
154
7. MELL
• the doors of an identity
ax
n
A A
A? B O AOB
n
n
A
n
cut
A?
n
or of a multiplicative link
A
n n
B
n
n
A B
n
have all the same level; • the premise of a ? link e has a level greater or equal than the level of the conclusion of e; the doors of a link have all the same level; the level of the premise of an ! link e is equal to the level of the conclusion of e incremented by 1.
A
?
n+p p 0 n
?
A
?
A
n
?
A
n
A
!
n n
n+1
?
A
?
A
!
A
n
Since the purpose of the levels is to avoid the use of boxes, the IMELLℓ proof nets do not contain any box or any other global constructor. Remark 4.1. According to the terminology introduced in section 2 of Chapter 2 and corresponding to what happens in standard proof nets, the identity and multiplicative links are intls (internal links), while the exponential ones are door links: the ! links are pdls (primary door links), the ? links are adls (auxiliary door links). As for the IMELL proof nets, the previous links may be used to build the socalled IMELLℓ proof structures, i.e., generic ℓstructures over the signature ΣMELL according with the indexing rules of the previous pictures. The ℓnets are then the IMELLℓ proof structures to which it is possible to associate an IMELLℓ decoration. Namely, being Net(Πℓ) the ℓnet obtained by replacing each rule of Π by the corresponding IMELLℓ link, an IMELL proof structure N is an ℓnet iﬀ N =
4. IMELLℓ PROOF NETS
155
Net(Πℓ), for some IMELLℓ decoration Πℓ. Even if the deﬁnition of ℓnet we are going to use is more restrictive then the previous one, since it asks indeed that Πℓ is standard. 4.1. Standard IMELLℓ proof nets. For the sake of our study of proof net reductions we do not want to consider all the decorations of IMELLℓ but only the ones that give rise to proof nets in which the level of any arrow corresponds to its box nesting depth and in which a box nested at level n (i.e., whose pdl’s conclusion is at level n) is a connected substructure whose internal arrows are at a level greater than n (cf. Deﬁnition 4.3). Example 4.1. Let us consider the following decoration Πℓ: ax ? ⊢ A1, A⊥1 ⊢ B1, B⊥1 ⊢ ?A0, A⊥1 ⊢ ?B0, B⊥1 0, A⊥1, B⊥1 ⊢ ?A ?B ⊢ ?A ?B0, A⊥ B⊥1 ⊢ ?(?A ?B)0, A⊥ B⊥1 ⊢ ?(?A ?B)0, !(A⊥ B⊥ )0 ax ? ? !
The IMELLℓ proof structure corresponding to Πℓ is the one obtained decorating the structure of Figure 2 by the box nesting levels corresponding to the dashed box (see Figure 7 taking the slashed index when an arrow has two levels). Example 4.2. Let us take the IMELL derivation Π obtained erasing the levels from the previous example. By applying the standard decoration map to Π we get the decoration Dec(Π): ax ? ⊢ A1, A⊥1 ⊢ B1, B⊥1 1, A⊥1 ⊢ ?A ⊢ ?B1, B⊥1 1, A⊥1, B⊥1 ⊢ ?A ?B ⊢ ?A ?B1, A⊥ B⊥1 ⊢ ?(?A ?B)0, A⊥ B⊥1 ⊢ ?(?A ?B)0, !(A⊥ B⊥ )0 ax ? ? !
Whose corresponding IMELLℓ proof structure is drawn in Figure 7 (ignoring the slashed indexes), that is, the proof structure of Figure 2 decorated by the box nesting levels corresponding to the correct box. The previous examples show that to get the right deﬁnition of boxes in terms of levels we have to restrict to standard decorations.
156
7. MELL
ax ax
1
? ?
1
1 0
6
1 0
6
1 0
6
1
O
1
!
1 0
6
?
0
0
Figure 7. The proof ℓstructures for Example 4.1 and Example 4.2. In the case in which two levels are assigned to an arrow: choosing the slashed one we get the level assignment corresponding to the box; choosing the other one we get instead the level corresponding to the box. Definition 4.1 (standard ℓnet). An ℓnet N is standard when there exists a standard IMELLℓ decoration Πℓ s.t. Net(Πℓ) = N . Remark 4.2. In more details, for each standard ℓnet N there exists an IMELL proof net Π s.t. Net(Dec(Π)) = N . 4.2. Parsing. Also for the ℓnets we may give a parsing grammar σℓ accepting a standard ℓnet when it contracts to a unique net link. The rules of σℓ are the ones of σ with the addition of the corresponding levels. Anyhow, since we are interested in the standard ℓnets only, we have to restrict the order in which to apply the rules of the parsing grammar. The key point is to forbid the parsing of a link outside the box associated to an ! link e! before the parsing of e!. In the σ parsing grammar such a requirement corresponds to the proviso that the links of the lefthandside must be in the same boxes. The σℓ grammar has instead no box constructor, so the same result is obtained by appending to each net link a level constraint, i.e., an index n, forbidding to apply a rule for a link whose premises are at a level lower than n. Notation 4.1. Let G be a parsing ℓstructure, that is, an ℓstructure over ΣMELL ∪ {net}. We say that e ∈ E net (G) is a net≥n link to mean that n is the level constraint of e.
4. IMELLℓ PROOF NETS
ax
157
n
net
n
n
A A Ak
n
A? A?
cut
n
`
A
net
A?
`
n
net
n nk
n m1 B1
`
net
n m1 B1
n1
A1
n
n
mh Bh
n1
A1
net
nk
mh Ak Bh
n1
Ai
n
net
n nk
Ai+1
n
A1
n
O
AiOAi+1
net
n
Ak
nk
n1
A1
AiOAi+1
`
n
Ak
Ak Bh
n
net
n m1 B1 n1
net
n m1 B1
n1
A1
Ak Bh
n
n
A1
Ak Bh
n
Figure 8. The parsing grammar σℓ: multiplicative part. The rules of σℓ are drawn in Figure 8 (multiplicative part) and Figure 9 (exponential part). Remark 4.3. We use the superscript ≥ n for the level constraint of a net link to stress that such a link corresponds to a subnet whose links are at a level greater or equal than n (see Fact 4.2). Remark 4.4. The only contraction rule of σℓ that changes the level constraint of a net link is the one for the ! links. In fact, parsing an ! link e! whose conclusion is at level n we complete the parsing of the links at a level greater than n internal to the box of e!. So, after this, the reduction may continue parsing the links outside Boxℓ(e!), that is, at level n (see Fact 4.2).
158
net
7. MELL
n0 nk
A
n0
? ?
`
net
n0 nk
n1
A1
Ak
n1
A
n
A1
Ak
?
A
n
n1
?
A
n
net
n
?
A
`
net
n nk
A1
n
?
Ak
nk
n1
A1
?
A
n
A
n
Ak
net
n+1 nk
A
n+1
!
`
net
n nk
n1
?
A1
ni n
?
Ak
n1
?
!
A
n
A1
?
Ak
!
A
n
Figure 9. The parsing grammar σℓ: exponential part. The restriction on the order in which σℓ parses links implies that the nonstandard ℓnet of Figure 7 is not contractible. In fact, let us start parsing the two ax links and the two ? links. We get a parsing ℓstructure with two net≥1 links which cannot contract any more: we cannot parse the link because of the level constraint of the net links; we cannot parse the link because it is connected to two distinct net links. Fact 4.1. Let enet be a net≥n link of a parsing ℓstructure. For any conclusion Am of enet we have that, 1. m < n only if A is a ? formula; 2. m ≤ n, anyway. Proof. The items of the statement hold for any net link originated by the parsing of an axiom. The statement is invariant under σℓcontractions, besides.
4. IMELLℓ PROOF NETS
159
Remark 4.5. The last fact implies that in the contraction rule for the ! link the requirement that the conclusions of the net link but the premise of the ! are ? formulae is subsumed by the constraint on the levels. The relevant property of the parsing grammar σℓ is that we may associate to each net link of a parsing structure the substructure formed by the links scanned ∗ by such a net link. Namely, let ρ : N σℓ G be a parsing reduction and let enet ∈ V net (G ). We deﬁne by induction on the length of ρ the N substructure ρ(enet ) by: 1. If ρ = r, that is, ρ is composed of the parsing of an ax link eax only, then ρ(enet ) = eax (note that enet is the only net link of G ). 2. If ρ = ρ ′r and r parses a link e, then ′ (a) if enet is introduced by r and enet is the net link connected to e, then ′ ρ(enet ) = ρ ′(enet ) ∪ {e}; (b) otherwise ρ(enet ) = ρ ′(enet ); and analogously when e is a ?, !, or link. 3. If ρ = ρ ′r and r parses a link e, then ′ ′′ (a) if enet is introduced by r and enet , enet are the net links connected to ′ ′′ e, then ρ(enet ) = ρ ′ (enet ) ∪ ρ ′ (enet ) ∪ {e}; (b) otherwise ρ(enet ) = ρ ′(enet ); and analogously when e is a cut link. Fact 4.2. Let ρ : N ture N .
∗ σℓ
G be a parsing reduction of the IMELLℓ proof struc
1. For any net link enet of G the N substructure ρ(enet ) is an ℓnet. 2. If enet is the net link introduced by a σℓ rule parsing an ! link e!, then ρ(enet ) = Boxℓ (e!). N Proof. By induction on the length of ρ. The ﬁrst item is immediate. The second item is proved by noting: (i ) that ρ(enet ) is connected; (ii ) that all the links of ∂E (enet ) but e! are ? links (see Fact 4.1); (iii ) that for any arrow v of ∂E (enet ) we have ιN(v) > n, where n is the level constraint of enet , that is, the level of the conclusion of e!. The standard decorations end with a sequent whose formulae are at level 0. So, if we want to accept standard decorations only, we have to restrict the accepted ℓstructures to the ones that contracts to a single net≥0.
160
7. MELL
∗
Notation 4.2. We write ρ : N ℓ σℓ net≥n to denote a σℓreduction that contracts the IMELLℓ proof structure N to a single net≥n link. In particular, ∗ when n = 0 we simply write ρ : N ℓ σℓ net. Our claim is that ρ : N σℓ net iﬀ N is a standard ℓnet. We do not want to be too formal about this, since the choice we will follow to redeﬁne standard ℓnets using σℓ is adequate to our purposes—it ensures the wright shape of the boxes. Anyhow, let us sketch a proof of the equivalence of the two deﬁnitions (Deﬁnition 4.2 and Deﬁnition 4.1). Exploiting Fact 4.2 we may see that the level of an arrow v conclusion of a link e corresponds to its box nesting depth, that is, to the number of ! link rules that follow the parsing of e in the accepting reduction ρ of N . By an analysis of the Inc map we also see that the level it assigns to a formula of a derivation Π corresponds to the number of ! rules that follow it in Π. By the previous two remarks and by the fact that any σℓreduction ∗ ρ : N ℓ σℓ net corresponds to an IMELLℓ derivation Πℓ, we conclude that Πℓ is indeed standard. For the converse the result is analogously proved, provided that in the IMELLℓ decoration the contractions of the ? formulae closing a box are postponed after the corresponding ! rules. Definition 4.2 (standard ℓnet). A standard ℓnet is a contractible (for σℓ) IMELLℓ proof structure in which the level constraint of the ﬁnal net link is equal to 0. To prove that the standard ℓnets are the right ones, let us show that our deﬁnition of levels allow to correctly reconstruct the boxes of an ℓnet. The deﬁnition of box is the one give in general in Chapter 2 (Deﬁnition 2.2) instantiated to the case of the IMELLℓ proof structures. Definition 4.3 (ℓbox). Let N be an ℓnet and let e! ∈ E !(N) be an ! link whose conclusion is at level n. The ℓbox of e! is the smallest leveled N substructure Boxℓ (e!) s.t.: N 1. 2. 3. 4. 5. e! ∈ ∂E (Boxℓ (e!)); N ∂E (Boxℓ (e!)) − e! ⊂ E ?(N); N ℓ BoxN(e!) is connected; ιN(v) > n, for any arrow v ∈ V(∂E (Boxℓ (ep))); N ιN(v) ≤ n for any conclusion of a link e ∈ ∂E (Boxℓ (e!)). N
∗
The boxing map Boxℓ induced by the previous deﬁnition on a standard ℓnet N N is a correct boxing map for the corresponding proof net.
4. IMELLℓ PROOF NETS
161
Theorem 4.1 (sequentialization). Let N ℓ = (N, τN, ιN) be a standard ℓnet. The proof structure N = (N, τN, Boxℓ ) is an ℓnet. N Proof. Let ρℓ : N ℓ σℓ net. Because of Fact 4.2 we see that any contraction rule r of ρℓ is a correct contraction for the corresponding parsing structure obtained starting from N and applying the rules preceding r. So, the corresponding ∗ ℓ ℓ reduction ρ : N accepts σ net obtained from ρ by forgetting the levels of N N. Proposition 4.1. A proof ℓstructure is contractible iﬀ it is strongly contractible. Proof. See the proof of the corresponding property of σ (Proposition 2.1).
∗
Corollary 4.1. Let G be an IMELLℓ proof structure and let R be a G substructure which contracts to a unique net≥n link. The ℓstructure G is an ℓnet iﬀ the parsing ℓstructure obtained replacing R by a unique net≥n link is contractible. Proof. Let ρ ′ : R σℓ net≥n. The σℓreduction ρ ′ is also a parsing reduction ∗ ′ ′ of G s.t. ρ ′ : G σℓ G , where G is obtained replacing the G substructure R by a net≥n link. So, by Proposition 4.1 G is contractible iﬀ G ′ is. Theorem 4.2. Let N be an IMELL proof net. The IMELLℓ proof structure N ℓ obtained assigning to each arrow of N ℓ its box nesting depth in N and erasing the box links of N is a standard ℓnet. Proof. Each parsing reduction ρ of N induces a corresponding parsing reduction ρℓ of N ℓ. 4.3. Cut elimination for ℓnets. The cut elimination rules deﬁned for the IMELL proof nets extend to the ℓnets too. The βi and βm rules may be redeﬁned for the ℓnets without any additional consideration: just add the correspondent levels to the arrows involved in the rules to obtain the βℓ and βℓ rules. For the βe m i rule we have instead to take into account the fact that the ℓnets does not contain box constructors. Anyhow, Theorem 4.1 gives us a way to circumvent such a problem reformulating the βe contraction rule for the ℓnets, the corresponding βℓ rule is depicted in Figure 10. The boxes drawn in that ﬁgure are not part of e the ℓstructure but the ones we rebuild using the Boxℓ map. In particular, if e! is
∗
162
box box
7. MELL
box
N
0
!
n2
?
n
n+q
?
N
?
` e
N
?
!
0
1
N
?
+ !
0
q
N
cut
?
?
n2 1 n
cut
n2 +q n n+q n+q
!
n+1
! !
n n2 n
cut
n n n1 n2
n1
Figure 10. The βℓ rule. e the ! link above the cut, the substructure N! is the box Boxℓ(e!) without e!, while N? is a box Boxℓ(e!′ ) (of another ! link) an adl of which is contracted by the link above the cut. In terms of such boxes the rewriting is similar to the βerules. For the levels, let us instead note that the new instances of N! created by the rules are lifted by an oﬀset—the level of their arrows is incremented by such an oﬀset— which is the diﬀerence between the level of the premise of the corresponding ? link and the level of the contracted cut. Hence, since the new instance N! −1 is just the old one without its surrounding box, the level of its arrows is decremented by 1. While the levels of the arrows of the new instance N! +q are incremented by the number q of boxes closed by the corresponding ? link. Definition 4.4 (βℓ rule). Let ecut be an exponential cut of the ℓnet N . e The unshared contraction or βℓ contraction of ecut u (βℓ ) e ecut : N
ecut βℓ e
N1
is the rewriting of N obtained applying the βℓ rule of Figure 10. e Proposition 4.2. Any βℓcontractum of an ℓnet is an ℓnet. Proof. Comparing the ℓrules and the standard ones. 5. Sharing proof nets 5.1. The shared βℓ rule. The only cut elimination rule for ℓnets that e involves boxes is the exponential one. So, the only contraction that has to be implemented in a shared way using muxes is the βℓ rule. The corresponding rule e is the βℓ rule drawn in Figure 11 (cf. the βsrule of λcalculus). s
5. SHARING PROOF NETS
163
n1
?
ni
?
nk
?
n+1
!
n n
n
` s
n1 a1 n
ai
ni
nk ak
n
cut
n+1 n
cut
n+1
Figure 11. The βℓ rule. s The sℓstructures obtained introducing muxes in the IMELLℓ proof structures, that is, by using the βℓ rule in place of the βℓ rule, are the IMELLℓ proof sℓs e structures. 5.2. The π rules. The π interactions are just instantiations of the general ones deﬁned in Chapter 3. We only remark that: • In the case of the sℓnets the only absorption rule is given by a mux reaching a ? link whose conclusion is at a level lower or equal than its threshold. • Since the pdl of the sℓnets are the ! links, a situation in which a mux with threshold n points to the premise of an ! link whose conclusion is at level n is a deadlock. 5.3. Parsing sℓnets. The generality of our deﬁnition of the π interactions allows us to extend them even to the parsing sℓstructures, i.e., the sℓstructures obtained replacing a substructure of an IMELLℓ proof sℓstructure with a net≥n link (where n is a suitable level constraint). In this case muxes can also be absorbed by net links, according to the general deﬁnition of absorption given in subsection 1.4 of Chapter 3. Remark 5.1. Since the threshold of a mux is always lower than the level of its principal door, if the principal door of a mux e is conclusion of a net≥n link enet , then the threshold m of e is lower than n. The ith conclusion of enet —let ni be its level—absorbs e only if ni ≤ m < n. Hence, if this is the case, the ith door of enet is a formula ?Ani (because of Fact 4.1), that is, the conclusion of a i ? link parsed by enet which is adl of a box whose pdl has not been yet parsed by enet . Besides, the propagation of e through enet corresponds to the propagation of the mux through the whole net parsed by enet . So, the previous absorption corresponds to a mux reaching the ? link enclosed in enet which is adl of its scope.
164
7. MELL
We now have two sets of rules for the parsing sℓstructures: the σℓ rules and the π interactions. We use them to give a characterization of the proper IMELLℓ sharing proof nets (the sℓnets) which is equivalent to the algebraic one. Definition 5.1 (sℓnet). An sℓnet is a IMELLℓ proof sℓstructure which contracts to a net≥0 link by the σℓ parsing grammar extended by the π rules. The previous deﬁnition is the analogous of the one of ℓnets given in terms of the σℓ rules. The addition of the π interactions is necessary to give a way to remove the muxes that may be present in the sℓstructure that has to be parsed. Lemma 5.1 (σpostponement). For any sℓnet N there exists an accepting ∗ ∗ reduction N π σℓ net which postpones the parsing after the π interactions. Proof. By case analysis of the rules of σℓ and of the π interactions. Reminding that in this case the pdls are the ! links, we get the equivalence between the algebraic characterization of properness and the one given in terms of the parsing grammar. Theorem 5.1. An IMELLℓ proof sℓstructure G is an sℓnet iﬀ the π interactions strongly normalize it to an ℓnet. Proof. By Lemma 5.1 and by the deﬁnition of ℓnet. Theorem 5.2. Any proof sℓnet is a proper proof sℓstructure. Proof. By Lemma 5.1 and by the deﬁnition of ℓnet we know that any sℓnet have a unique π normal form which, besides, is an ℓnet (by Proposition 4.1 of this chapter and Lemma 4.1 of Chapter 3). By Lemma 2.1 of Chapter 5, we have that any structure which reduces to a proper sℓnet is proper. Consequently, since any ℓnet is proper we get the conclusion. 5.4. Soundness and completeness. By the same techniques used for the λcalculus we get the equivalent of Theorem 4.1, Theorem 4.3, Theorem 4.2, and Theorem 4.4 of Chapter 6. Furthermore, in the case of the sℓnets we can also add that βℓ + π is strongly normalizing, since the βreductions of IMELL are s terminating.
CHAPTER 8
Optimal reductions
The staring point of the studies on the sharing implementations is the theory of the optimal λcalculus reductions formulated by L`vy [L´v78, L´v80] and e e e successively generalized to a wider class of systems (the socalled “interaction systems”) by Asperti and Laneve [Lan93, AL93a]. In our dissertation we have approached the problem from another point of view, taking as central the problem of the coherence of the implementation, that is, the internalization into the system of the readback. The crucial testbed of our choice is the possibility to achieve optimality from the the general implementation techniques we addressed, that is, to see if there are suitable reduction strategies which turn the system to be optimal. By the way, the answer is positive (everything has been developed having in mind the problem of the optimal reductions). Namely, there is a subset of the π interactions (the πo rules) which together with the βrule fulﬁll the requirements of the optimality theory. 1. Labeled structures The labeled structures we consider are obtained from the ones introduced in the previous chapters decorating their arrows with suitable strings of unitary labels. A unitary label is either an atomic symbol selected from a denumerable signature, or a symbol obtained by over/underlining a composite label. Namely, let us consider the following label composition rules x ::= si  α  α α ::= x  α0α1 σ ::= ǫ  α in which: • s0, s1, . . . range over a denumerable signature ΣΛ of atomic labels; a • α0α1 denotes the usual concatenation of α0 and α1, and it is then assumed to be an associative operation; • ǫ is the empty label.
165
166
8. OPTIMAL REDUCTIONS
Definition 1.1 (label). The set of the labels over the signature ΣΛ is the a Λ monoid Σǫ generated by σ according to the label composition rules. Remark 1.1. The labels in ΣΛ are said atomic, because we assume that no a Λ symbol s ∈ Σa may be obtained concatenating any pair α0, α1, or over/underlining any α. Notation 1.1. In the following we will use • the latin letters x, x0, x1, . . . to denote unitary labels; • the greek letters α, α0, α1, . . . to denote non empty labels, i.e., the symbol def α and its indexed variants range over ΣΛ = ΣΛ − {ǫ}; ǫ • the greek letters σ, σ0, σ1, . . . to denote generic labels. Definition 1.2 (labeled structure). A labeled structure G Λ is a structure of links G with a labeling map Λ : V(G) → ΣΛ assigning a label to each arrow of G . ǫ
Since an ℓstructure is just a structure plus a level assignment, the previous deﬁnition apply to ℓstructures too. Hence, a labeled ℓstructure G Λ is a structure of links whose arrows have two types of additional informations: a level and a label. Notation 1.2. We denote by Λ(G) the set of the labels of the arrows assigned by the labeling map to the arrows of G Λ.
The superscript of a labeled structure G Λ is the name of the labeling function for the ℓstructure G . So, to denote two distinct labeled structures obtained as′ signing the labeling maps Λ ′ and Λ ′′ to the same structure G we will write G Λ ′′ and G Λ , respectively. Nevertheless, we will not care to overload the symbol Λ using it to name the labeling map in all the cases in which it will not cause confusion. Moreover, henceforth we will assume that the structures with a superscript Λ, Λ ′, Λ ′′ . . . are labeled, omitting sometimes to explicitly restate it. Remark 1.2. According to the deﬁnition of labeled structure, in the general case we do not forbid that an arrow might be labeled with ǫ: the empty label is in fact useful to preserve the correspondence between the labeled sℓstructures and their intended interpretation. Namely, let us take the λcalculus case, an arrow with label α of a λterm corresponds in the shared representation to a path (v0)e1(v1) · · · (vi−1)ei(vi) · · · (vk−1)ek(vk) crossing muxes only s.t. α = σ0·σi · · · σk, where σi is the label of the arrow vi. Hence, even if in λterms we inhibit the case α = ǫ (see Deﬁnition 2.1), to dynamically preserve the correspondence between the sharing structures and the labeled λterm they represent we need to label with
2. LABELED CALCULI
167
ǫ the arrows created by the propagation of muxes (see the deﬁnition of the labeled π interaction rule given by Figure 2). 2. Labeled calculi We restrict our study to the case of the λcalculus. The analogous notions may anyhow be deﬁned for IMELL too. 2.1. Labeled λcalculus. To start the presentation let us come back for a while to the usual representation of λterms. By adding a label to any term we get the labeled λcalculus of L´vy, i.e., a calculus over the set of the labeled terms e deﬁned by the grammar t ::= xα  (λx.t)α  (t0t1)α Remark 2.1 (degree of a term). The deﬁnition of the labeled λterms implies that the empty label may not be used to label any of their arrows. Hence, the label degree(t) of any subterm t of a labeled λterm—also said the degree of t—is s.t. degree(t) = ǫ. In writing terms it will be useful to explicit their corresponding degree. So, assuming that the letter s (and its indexed variants) ranges over the terms generated by s ::= x  λx.t  t0t1 the labeled λterms may be equivalently deﬁned by t ::= sα and consequently degree(sα) = α. To complete notation, let us add the writing (t)α to append a label α to a labeled term t. Anyhow, instead to consider such an operation as part of the syntax, let us see it as a metanotation: the one induced by the syntactical congruence (sα1 )α0 ≡ sα1 α0 or equivalently, the congruence obtained assuming degree((t)α) = degree(t)α. The previous notations allow us to deﬁne the (labeled) βcontraction of a labeled βredex r = (λx.t0)αt1: (β) (λx.t0)αt1
r β ([(t1) α def
/x]t0)α
168
8. OPTIMAL REDUCTIONS
where [(t1)α/x] denotes the natural extension to the labeled case of the substitution metaoperation—in particular, it means that performing [(t1)α/x] we have to take into account the nameclash problem. Remark 2.2. In the deﬁnition of βrule a βredex r = (λx.t0)αt1 is seen as a term with no label. In this way there is no confusion between the degree of the def redex r (degree(r) = α) and the degree of the corresponding labeled term rα0 (degree(rα0 ) = α0). Remark 2.3. To explicit the labels that change after a βcontraction let us analyze the shape of the βrule in more details. Namely, let s0[ , . . . , ]αd denotes the context obtained from the term sαd = s0[xα1 , . . . , xαk ]αd replacing each la0 beled occurrence of the variable x with a hole, and let us additionally assume that no free variable is captured when sαr is inserted in any of such holes. Using such 1 a notation the labeled βrule may be written ((λx.s0[xα1 , . . . , xak ]αd )α(sαr ))αu 1
α1 ααr ,... β s0[s1
, sαk ααr ]αu ααd 1
putting in evidence the new values of the labels changed by the contraction (cf. the deﬁnition of labeled βλrule given in Figure 1). 2.2. Labeled λstructures. The labeled λcalculus presented in the last subsection has an immediate translation into labeled λstructures. In particular, since the degree of any subterm of a labeled term t is not empty, in our hypergraph deﬁnition of labeled λterms we have to add such a constraint. With the reformulation of the labeled calculus into the λstructure setting we end the digression into the usual term representation of λcalculus. In fact, henceforth we come back to the hypergraph implementation introduced in Chapter 6, and then by λterms we intend the ones given in Deﬁnition 1.3 of that chapter. Definition 2.1 (labeled λterms). A labeled λterm T Λ is a λterm T with a labeling map ΛT : V(T ) → ΣΛ assigning a label to any arrow of T . Remark 2.4. Any label of an arrow corresponds to a degree of a subterm and as usual the degree of a redex is the label of its redex arrow.
The labeled βλrule is an immediate translation of the detailed presentation of the labeled βrule given in Remark 2.3. The corresponding rewriting ﬁgure is drawn in Figure 1.
3. LABELED REDUCTIONS
169
u
u
d
@
box
d 1 i k r
Ts 0
1 r i r k r
Ts 1 Ts1 1
Ts0
Tsi1
Tsk 1
Figure 1. The labeled βλrule. 3. Labeled reductions The labeled λcalculus is the main tool for the study of L´vy’s theory of ope timality. The key idea of such a theory is that, starting from terms in which the labels are distinct and atomic, an optimal evaluator should use a shared representation for all the redexes with the same degree. For a detailed presentation and axiomatization of the notion of family of sharable redexes we refer the reader to L´vy’s work [L´v78, L´v80] or to the generalization that Asperti and Laneve e e e gave for the interaction systems [Lan93, AL93a]. Here, we just introduce the relevant deﬁnitions and properties useful to prove that a suitable restriction of the π + βsrules is optimal. 3.1. Conﬂuence. Each reduction of a labeled λterm corresponds to a λcalculus reduction just erasing the labels. Vice versa, given a λcalculus reduction we get an isomorphic labeled reduction just ﬁxing the labeling of its initial λterm. Such a correspondence does not anyhow implies that two λcalculus reductions ρ ′ and ρ ′′ of a λterm T ending with the same λterm T1 would give two labeled reductions ending with the same labeled λterm—we can only say that they end ′ ′′ with T1Λ and T1Λ . Even though, the labeled λcalculus maintains the diamond property stated by the parallel moves lemma and it is then conﬂuent, i.e., the two labeling Λ ′ and Λ ′′ of T1 obtained by the two reductions ρ ′ and ρ ′′ coincide
170
8. OPTIMAL REDUCTIONS
when they are equal w.r.t. the permutation equivalence induced by the diamond property (see also subsection 3.3). Consequently, in the labeled case too, all the developments of a set of redexes end with the same labeled λterm and the usual deﬁnition of parallel reduction R : T Λ β T1Λ contracting in one step a set of redexes R is sound. 3.2. Families of redexes. The labeling of λterms is useful to trace the way in which redexes are created during λterm reductions. In fact, the aim of labels is to identify by the same degree the redexes with the same origin w.r.t. the reduction taken into account. It is then immediate that the labels of the starting term have to be distinct. Definition 3.1 (Init). For any labeled λterm T Λ, the predicate Init(T Λ) is true iﬀ the degrees of the arrows of T Λ are distinct and atomic. The notion of what is sharable depends on the history of the λterm, i.e., on the reduction performed to get it. Definition 3.2 (redex family). Let T Λ be a labeled λterm s.t. Init(T Λ) is ∗ true, and let T1Λ and T2Λ be two reducts of T Λ (i.e., T Λ βλ TiΛ, for i = 1, 2). A βredex r1 of T1Λ is in the same family of a βredex r2 of T2Λ iﬀ degree(r1) = degree(r2). Notation 3.1. Provided that Init(T Λ) is true. We denote by: 1. [α]T Λ the family of the redexes with degree α obtained by reducing T Λ; 2. degree(ρ) the set of the degrees of the redexes contracted in the reduction ∗ ∗ ρ : T Λ βλ T1Λ (or ρ : T Λ βλ T1Λ). Definition 3.3 (development of Ξ). Let Ξ be a set of labels. We say that a ∗ reduction ρ : T Λ βλ TΞΛ is relative to Ξ when degree(ρ) ⊆ Ξ, and that such a ρ is a development of Ξ when degree(r) ∈ Ξ, for any redex r of TΞΛ. / The latter reductions satisfy a generalized version of the ﬁnite development theorem. In fact, let Ξ be ﬁnite. If Init(T Λ) is true, then: 1. There is no inﬁnite reduction relative to Ξ. 2. Two developments of a set of labels Ξ are equivalent w.r.t. the permutation ∗ TΞΛ equivalence established by the diamond property, and then ρ : T Λ for any development ρ of Ξ.
3. LABELED REDUCTIONS
171
In addition to their ﬁniteness the developments of a set of labels Ξ also have the relevant property that no redex whose degree is contained in Ξ can be created continuing the reduction from the end of any development of Ξ. Lemma 3.1. Let T Λ be a λterm and let ρ0 : T Λ of a set of labels Ξ. If Init(T Λ) is true and ρ1 : T1Λ T2Λ does not contain any redex r s.t. degree(r) ∈ Ξ. Proof. See L´vy’s Thesys [L´v78], or [L´v80]. e e e The next step is to characterize the reductions that at each contraction eliminate all the redexes of a given family, and nothing else. Definition 3.4 (complete family reduction). Let ρ = R1R2 · · · Rk · · · be a parallel reduction. We say that ρ is complete iﬀ, for every k ≥ 1, the set Rk = ∅ is a maximum set of redexes s.t. degree(r1) = degree(r2), for all r1, r2 ∈ Rk. Remark 3.1. Assuming to start from a λterm T Λ s.t. Init(T Λ) is true, some consequences of the latter deﬁnition are that: 1. Any complete family reduction ρ is a development of degree(ρ). 2. The length of any complete reduction ρ (in terms of parallel contractions) is equal to the cardinality of degree(ρ), i.e., ρ = ♯ degree(ρ). The previous results allow to prove a rather technical lemma showing that in the result of a complete family reduction ρ of T Λ an over/underlined label α/α may be used for the construction of another label α1 iﬀ the family [α]T Λ has been reduced by ρ. More formally, let us write α ⊂ α1 when α appears in a derivation tree of α1, i.e., let ⊂ be the smallest relation s.t. α⊂α and, when α ⊂ α1, s.t. α ⊂ α1 α ⊂ α1 α ⊂ σ0α1σ1 for any σ0 and σ1. Lemma 3.2. Let ρ : T Λ βλ TkΛ be a complete family reduction and let α1 ∈ Λ(Tk). For any non empty label α, we have that:
∗ ∗ Λ βλ T1 be a development ∗ Λ βλ T2 , then the λterm
172
8. OPTIMAL REDUCTIONS
1. α ⊂ α1 or α ⊂ α1 only if α ∈ degree(ρ); 2. α1 ∈ degree(ρ). / Proof. See L´vy’s Thesis [L´v78]. e e
3.3. Zigzag relation. The deﬁnition of family of redexes is dependent from the history of a given term. In fact, let us consider two unlabeled reductions ∗ ∗ ρ1 : T1 T and ρ2 : T2 T . In general it is not true that there exists a labeling of TiΛ, with i = 1, 2, s.t. Init(TiΛ) is true and s.t., for any pair of redexes r1, r2 of T Λ, then r1, r2 ∈ [α1]T1Λ iﬀ r1, r2 ∈ [α2]T2Λ , for some α1 and α2. The reason is that even if two redexes have the same shape, they are sharable only when they have the same origin in the term from which we assume to start the reduction. Let us be more precise. To take into account the history of a redex let us ∗ denote by ρr a redex of a term T1 s.t. ρ : T βλ T1. The diamond property of the (labeled) λcalculus induces on the reductions of the calculus a congruence ≡ equating for any pair of sets of redexes R1, R2 of a given λterm the two branches of the corresponding diamond, i.e., R1(R2/R1) ≡ R2(R1/R2) (which in particular implies the congruence of any pair of developments of a set of redexes). We say that the redex ρr is a copy of the redex ρ0r0, written ρr ≤ ρ0r0, when there exists a reduction ρ1 s.t. ρ0ρ1 ≡ ρ and r is a residual of r0 (i.e., when r ∈ r0/r1). The ≤ relation is a preorder that may be transformed into an equivalence in the usual way. Definition 3.5 (sharable family). A sharable family of redexes is an equivalence class of the symmetric and transitive closure ≃ of the ≤ relation. The ≃ equivalence is also called zigzag relation since by deﬁnition two redexes ρ1r1 and ρ2r2, even if in the same sharable family, may not have a common ancestor ρ0r0 ≤ ρiri, for i = 1, 2. Nevertheless, a main result of L´vy’s dise sertation is that sharable families may be deﬁned by an extraction relation1 on reductions that also ﬁxes the canonical representative of a sharable family as its unique normalform. For our aim it is however enough to point out that L´vy e
1
Actually the extraction procedure works on standard reductions, i.e., on reductions in
which the redexes contracted are leftmostoutermost ordered. But the standardization theorem of λcalculus proves that any reduction ρ has a congruent standard reduction ρs , i.e., for any reduction ρ there exists a standard reduction ρs s.t. ρ ≡ ρs .
3. LABELED REDUCTIONS
173
proved that sharable families and families of redexes deﬁned by the labeling coincide. Furthermore, any reasonable evaluator based on sharing may be assumed to contract copies of a single redex in a unit of time. Hence, we may more formally say that, given a reduction ρ ending at T Λ, a set of redexes R of T Λ is a set of copies of a single redex iﬀ there is ρ0r0 s.t. ρ0r0 ≤ ρr, for any r ∈ R. Basing on the notion of copies of redexes, we say that a reduction ρ = R1R2 · · · Ri · · · is ccomplete iﬀ, for all i > 0, the nonempty set Ri is a maximum set of copies of a single redex. And, because of the latter assumption on the cost of a reduction on a sharing machine, we obtain by deﬁnition that: cost(ρ) = ρ def for any reduction ccomplete, where R1R2 · · · Rk = k. Furthermore, since all redexes in a set of copies of a single redex are in a same redex family and since in a sharing implementation we do not contract in one unit of time redexes which are not copies of a redex, we have for any reduction that its cost is not lower than the number of families reduced, i.e., cost(ρ) ≥ ♯ degree(ρ). Nevetheless, for any complete family reduction we have cost(ρ) = ♯ degree(ρ) (see the second item of Remark 3.1) and that: Lemma 3.3. A reduction is ccomplete iﬀ it is a complete family reduction. Nence, we may restrict to consider complete family reductions only, ﬁnding the ones taht do not execute work which is not strictly needed. Let Redex(ρ) be the set of redexes of T Λ one of whose residuals is contracted ∗ Λ Tn in ρ. A redex r is needed when r ∈ Redex(ρ) for all the reductions ρ : T Λ Λ in which Tn is a normalform. Theorem 3.1. Any complete and callbyneed family reduction reaches the normalform (if any) in an optimal cost. Proof. See L´vy’s Thesys [L´v78], or [L´v80]. e e e Where by callbyneed we intend a parallel reduction R1R2 · · · Ri · · · s.t. there is at least a needed redex in each Ri. Remark 3.2. The leftmostoutermost redex of a term is always needed. Hence, let us say that a family reduction is leftmostoutermost if it contracts at each step a set of redexes including the leftmostoutermost one. We see that any complete leftmostoutermost complete family reduction is optimal.
174
8. OPTIMAL REDUCTIONS
4. Labeled readback 4.1. Identity paths. In Chapter 5 we have seen that the topology of the readback of a uℓstructure U is obtained just removing its lifts, that is, considering lifts as identity connections. The same idea may be applied to the sℓstructures too, even if not all the paths crossing muxes only may be seen as correct, or proper. Definition 4.1 (identity path). An identity path (v0) ϕ(v1) is a closed direct or inverse path which crosses mux links only. Remark 4.1. By deﬁnition, the transfer function of an identity path is not null. Remark 4.2. A direct identity path (v0) e1 (v1) · · · (vk−1) ek (vk) is a sequence of straight connections (vi−1) ei (vi), with 1 ≤ i ≤ k, s.t.: • when ei is a positive mux, then vi−1 is an auxiliary door and vi the principal door of ei; • when ei is a negative mux, then vi−1 is the principal door and vi an auxiliary door of ei. Notation 4.1. To emphasize the shape of the identity paths pointed out in the last remark (and according to the notations used for the study of proper paths of λcalculus): 1. We write (v0) a e (v1) to denote a direct or inverse connection from the auxiliary door v0 of the mux e (being a the associated port) to its principal door v1. 2. We write (v0) e a (v1) to denote a direct or inverse connection from the principal door v0 of the mux e to its auxiliary door v1 (being a the associated port). 3. We assume that the previous atomic connections may be composed to form an identity path only when they are all direct or all inverse. Remark 4.3. The latter notations allow us to not care about the orientation of identity paths (direct or inverse). The correctness is ensured by the proviso that a direct and an inverse connection of the same link cannot be concatenated, that is, a path (vi) ai e (v) e aj (vj) is not allowed. Let us note that the case vi = vj was already forbidden by the closeness of the path (such a pair of connections would open the path). The case vi = vj instead has been explicitly eliminated by the last item of Notation 4.1.
4. LABELED READBACK
175
Definition 4.2 (label of an identity path). Let G Λ be an sℓstructure and let ϕ = (v0)e1(v1) · · · (vk−1)ek(vk) be an identity path (v0) ϕ(v1) ⊂ G. The label Λ(ϕ) of the identity path ϕ is the concatenation σ0σ1 · · · σk of the labels of its arrows (where σi = Λ(vi)). Remark 4.4. By deﬁnition, the reverse ϕ∗ of an identity path ϕ is an identity path, and Λ(ϕ∗ ) = Λ(ϕ)∗. 4.2. Semantical readback. In a proper uℓstructure U all the direct or inverse paths composed of lifts only are identity paths, since by the results of Section 3 Chapter 4 we see that any path of a uℓstructure is closed. Furthermore, it is readily seen that the readback U = U 1 is obtained substituting any maximal identity path (v0) ϕ(v1) of U with a unique arrow. Namely, each arrow v of U 1 derives from the collapse of a (possibly empty) maximal identity path ϕv into an arrow (let us denote it by ϕv = v). The operator · that removes the lifts from a uℓstructure extends directly to the labeled case. Namely, let us deﬁne U Λ as the structure U with the def labeling induced by the labels of the identity paths, i.e., Λ U (v) = ΛU(ϕv), with ϕv = v. Given a solution H of a uℓstructure, the same reasonings apply to the semantical readback of a uℓstructure obtained removing the lifts and assigning to each arrow its Hlevel (see Deﬁnition 2.1 of Chapter 5), i.e., the ℓstructure U Λ is deﬁned by adding the labels to U H in the previously decribed way. H Finally, the natural extension of the smorphisms to the labeled case allows us to apply the previous considerations to the case of the sℓstructures too. In fact, let us assume that an smorphism between two labeled sℓstructures is a Λ Λ morphism also for their labeling maps. Given an smorphism M : G0 → G1 the Λ Λ labels of G1 are uniquely determined by the ones of G0 , that is, ΛG1 (v1) = ΛG0 (v0) with v0 ∈ M−1(v1)
for any v1 ∈ V(G1) (note that because of the surjectivity of M, we have always Λ Λ M−1(v1) = ∅). Furthermore, the existence of the smorphism M : G0 → G1 Λ forces the labeling of G0 to be consistent with the one of G1 , that is, for any ′ ′ ′ v0, v0 ∈ V(G0), if M(v0) = M(v0), then ΛG0 (v0) = ΛG0 (v0). The deﬁnitions of labeled instance, labeled complete unsharings, etc., follows immediately from the latter extension of the smorphism to the labeled case. We explicitly restate just the deﬁnition of the semantical readback of a labeled sℓstructure.
176
8. OPTIMAL REDUCTIONS
Definition 4.3 (labeled readback). Let G Λ be a proper sℓstructure with complete unsharing M : U Λ → G Λ. The labeled readback of G Λ is the ℓdef structure G Λ = U Λ. 1 5. Labeled reductions of λsℓstructures The labeled π interaction rules for the labeled sharing implementation of λcalculus are obtained instantiating the general rule drawn in Figure 2.
1 2
a1 a2
1 0
m
0
?
3 2 0
? ?
a1 a2
3
m
Figure 2. Labeled π interaction. The labeled βsrule is instead drawn in Figure 3: it corresponds to the shared implementation of the usual labeled βrule drawn in Figure 1.
eu
u
eu
r r s u d
@
1 k
er
i d
n a1
1
ai
i
ak
k
er eb
e1
ei
ek
eb
e1
ei
ek
Figure 3. The labeled βsrule. Also for the labeled calculus the semantical readback of an sℓstructure is invariant under π reductions. Lemma 5.1. Let G Λ be a proper λsℓstructure s.t. G G Λ = G1 Λ.
∗ π G1.
We have that
Proof. By inspection of the labeled rules and by the analogous property for the unlabeled sℓstructures (Corollary 2.1 of Chapter 5).
6. OPTIMAL REDUCTIONS
177
Hence, as in the case without labels the π normalform of a proper sℓstructure is unique and corresponds to its semantical readback. Proposition 5.1 (unique labeled π normalform). Let G Λ be a proper sℓstructure. The labeled readback G Λ is the unique π normalform of G Λ. Proof. Compare with the proof of the analogous property in the unlabeled case (Theorem 2.1 of Chapter 5). 6. Optimal reductions 6.1. βpath. Let N be an λsℓterm and let T = N be the λℓterm its represent. Because of the presence of muxes not all the βredexes of T correspond to βsredexes of N . Anyhow, any βredex r of T is the image of an identity path connecting an @ node to a λ node. Definition 6.1 (βpath). A βpath is an (inverse) identity path connecting the left door of an @ node to the up door of a λ node. Fact 6.1. Let N be a λsℓterm whose complete unsharing is M : U → N . Each βpath of N is the image of a βpath of U . Proof. Let ϕ = (v0)e1(v1) · · · (vk−1)ek(vk) be a βpath. Let r1 : N π N1 be a π interaction involving one of the muxes of ϕ. We see that the βpath ϕ has a unique image ϕ1 ⊂ N1 connecting the residuals of v0 and v1, which is at its turn a βpath. Let us iterate the procedure, we get a reduction ρ : r1 ri rk N N1 · · · Ni−1 Ni · · · Nk−1 Nk and a corresponding sequence of paths ϕ = ϕ1, ϕ2, . . . , ϕi . . . ϕk ending with a path ϕk which is an edge, that is, ρ contracts ϕ into a βredex. In fact, if ri is an interaction between a positive (upward) mux and the @ node of the path, or between a negative (downward) mux and the λ node, then ϕi = ϕi−1 − 1; else if it is a lifts annihilation, then ϕi = ϕi−1 − 2; otherwise if it is a lifts swap, then the swapped positive mux decreases its distance (i.e., the length of the path to it) from the @ node, while the negative one decreases its distance from the λ node. Summarizing, if we take the sum of the distances of the positive muxes from the @ node and of the negative muxes from the λ node, we see that each ri decreases such a measure. Hence, the length k of any of the previous reductions ρ is ﬁnite. Furthermore, we see that if ϕi contains at least a mux, then there is at least a redex ri+1, otherwise the path would contain a deadlock and could not be closed.
178
8. OPTIMAL REDUCTIONS
By the simulation lemma we know that ρ corresponds to an unshared reduction ρu ρu 1 k U1 · · · Uk−1 Uk with M : Ui → Ni, for i = 1, . . . , k. The counterρ :U image of the βredex ϕk is a set of βredexes M−1(ϕk) of Uk. The simulation k −1 property also implies that the redexes Mk (ϕk) are images of the set of βpaths M−1 (ϕk−1), etc. k−1
u
Remark 6.1. In the previous proof the termination of the reduction ρ has been given exploiting that ϕ is a βpath and not that N is proper. So, the fact still holds if we relax the properness of N to the hypothesis that the λsℓstructure N has an unshared instance U which is a λuℓtree. Besides, for the given formulation, the proof should have been simpliﬁed noting that any π reduction of a λsℓterm is ﬁnite. 6.2. Optimal π interactions. In the subsection 4.4 of Chapter 6 we discussed the λstrategy for the βs + πo reductions and we remarked that other strategies should be suggested provided that they do not stop the reduction before a sharing representation of a λterm in normalform has been reached. Namely, let T be a λℓterm. For any βλ reduction ρλ : T
∗ βλ
T2
we want the existence of a βs + π reduction ρ:T
∗ γ N1
obtained applying the reduction strategy γ, s.t.
′ ρλ : T2 ∗ βλ
N1
′ for some βλ reduction ρλ. Let us now consider a subsystem of βs + π, that is, let πo ⊂ π be a subset of the π rules and let opt = βs + πo. According to the previous discussion, for any λsℓterm N , the main requirement that πo must fulﬁll is that if the λℓterm N contains a redex r, then by the application of a sequence of πo ∗ interactions N πo N1 we should be able to explicit the image rs of r, so that the ∗ sharing reduction might continue with rs : N1 βs N2, inducing a corresponding ∗ = N1 ). λcalculus reduction R : N βλ N2 , with r ∈ R (note that N The proof of Fact 6.1 shows that the minimal set πo satisfying the previous requirements is the one which composes of the uplambda π interaction (a mux whose principal door is the up door of a λ node) and of the leftat π interaction
6. OPTIMAL REDUCTIONS
179
(a mux whose principal door is the left door of an @ node), that is, of the ﬁrst two rules in Figure 4. Fact 6.2. The rewriting system βs + πo is an interaction net. Hence, it is locally conﬂuent. Proof. By the deﬁnition of interaction net (see [Laf90]). By the way, because of the previous considerations the system πo is the one which performs as fewer duplications as possible preserving the possibility of the computation to proceed. Because the idea of L´vy in its deﬁnition of optimality e was to capture the maximal sharing allowed in an implementation of λcalculus, it should not be surprising that such a concept of minimal work coincide with the notion of optimal reduction. Definition 6.2 (Opt). Let N Λ be a λsℓterm. The predicate Opt(N Λ) is true when there is no pair of βpaths of N with the same label. Fact 6.3. Let T Λ be a λℓterm s.t. Init(T Λ) holds. We have that Opt(T Λ) ∗ holds for any λsℓterm T1Λ for which there exists ρ : T Λ opt T1Λ. Sketch of proof. The proof is immediate for the πo rules. For the βsrule it requires instead to introduce a wider notion of λterm paths, deﬁned by Lamping and called “prerequisite chains” in [Lam89], for which a suitable extension of the predicate Opt holds in the result of a βreduction if it held in the starting term. Namely, the fact that two of such paths have the same sequence of labels in a λterm iﬀ they have the same sharing representation is preserved under βreduction. Such a property of prerequisite chains holds on the initial term when Init(T Λ) is true. Furthermore, the βredexes are particular cases of prerequisite chains. Hence, because of Fact 6.1, there is no pair of βpaths of T1Λ with the same label, otherwise there would be a pair of βredexes of T1Λ with the same degree but with distinct sharing images. In conclusion, Opt(T1Λ) holds. For a detailed proof see [Lam89]. Theorem 6.1. Let T Λ be a λℓterm s.t. Init(T Λ) holds. Any opt = βs + πo reduction of T Λ is optimal. Proof. By Fact 6.3 we have that Opt(N Λ) holds for any λsℓstructure N Λ ∗ obtained reducing T Λ, that is, T Λ opt N Λ. Hence, each βredex r of N Λ is the representation of all the redexes of N Λ in the family [degree(r)]T Λ . Then, the contraction of r corresponds to a complete family reduction.
180
8. OPTIMAL REDUCTIONS
Remark 6.2. For the λIcalculus any opt reduction is optimal w.r.t. the number of βsrules executed, since all the βredexes of a λIterm are needed. In the case of the λKcalculus instead, to get optimality we should have had to constrain the order in which the βsrule are executed (e.g., in an order corresponding to a leftmostoutermost unshared reduction) in order to ensure that at any step at least a needed redex is eliminated. Any of the other π interactions but the absorption rule causes the loss of the optimality. Hence, the rewriting system π+ which composes of the three rules of o Figure 4 is optimal. The introduction of the absoption rule causes the loss of the locally conﬂuence (the system is no more an interaction net): a counterexample may be built taking a critical pair formed by an absorption and βsrule. Nevertheless, the absorption rule is clearly mandatory in any eﬀective implementation of the system since it erases muxes.
6. OPTIMAL REDUCTIONS
181
e1 u
ei u
ek u
n+q1 n+qi n+qk a1 ai ak m n
o
n+q1 nj+q1 a1 m
e1 u
ei u
ek u
n+qi
n+qk
nj +qi ai nj
ej d
nj +qk ak
nj
ej d
n
eb
eu
a1 m
ai n
eb
ak
eu
n
@
n m a1 n+q1
e1 l
m a1 n+q1 n+1
o
n
ai ak n+qi n+qk
@ @ @
e1 l ei l ek l
ai n+qi
ei l
ak n+qk
ek l
er
a1 m
ai
ak
n+1 er
eu eu
n n+pj m a1 n+pj +q1 ai ak n+pj +qk
eb ej1 eji ejk
+ o
n
n
n+pj +qi n+pj +q1 n+pj +qk
n
eb
ej1 eji ejk
Figure 4. The λcalculus π+ rules. o
182
8. OPTIMAL REDUCTIONS
APPENDIX A
Weakening and erasers
The results presented in the dissertation apply when the calculus to be implemented does not contain erasing or weakening operators. We already pointed out that the reasons for the inapplicability of the general methodologies are that in presence of erasers/weakenings the structures and their boxes are no more connected. In fact, muxes duplicate and reindex the box B on which they have to operate on by performing a visit of the interior of B starting from its pdl. So, if B has a part B1 which is not connected to the pdl of B, there is no possibility that in a reduction involving such a pdl the distributed algorithm implemented by muxes might correctly operate on B1.
1. Weakening The worst case is the one of linear logic. In fact, in presence of weakening we may build boxes containing a socalled weakening component, that is, a tree whose leaves are are ?w (weakening) links. Let us additionally assume that the weakening component ends with an ! link—the easiest case is just a ?w link followed by an ! link. Let B be a box containing a weakening component B0 of such a kind and let ep be its pdl. Let B1 be the complement of B0 w.r.t. the box (i.e., B1 = B −B0). The construction rules of MELL imply that B is a correct proof net iﬀ B1 is, e.g., if B1 is an IMELL proof net. Let us now assume that ep interacts with a binary link. The result of the corresponding rewriting should be a structure Bd composed of two instances B ′ and B ′′ of the whole box B. The only result achievable by ′ the sharing implementations is instead a structure Bd composed of B1 and of ′ ′′ two instances B0 and B0 of the pdl’s component. We already pointed out that by this mismatch between the expected behavior and the eﬀective result achieved we conclude the loss of the coherence of the sharing implementation in presence of weakening. Anyhow, it might seem that in this way we have had deﬁned a ′ new sound reduction rule for proof nets. In fact, we might think that Bd is a ′ correct proof net obtainable ﬁrst building B1, and then the two components B0 ′′ ′ ′′ and B0 (remind that the sequentialization of B0 and B0 is a derivation whose
183
184
A. WEAKENING AND ERASERS
branches start all with a weakening). Such a conjecture is instead false, that is, ′ there are counterexamples in which the structure Bd is not a proof net. The easiest one is obtainable assuming that B0 is the proof net corresponding to a ′ weakening followed by two promotions. The structure Bd has two ! links among its conclusion and there is no way to build two correct boxes for them. It is worth to note that, because of the particular structure of λterms, in the λcalculus the weakening cause less problem. In fact, a λterm is always a connected structure and then pathological conﬁgurations as the ones previously described are not allowed. Hence, the main problem is only to recover all the garbage by propagations of eraser links.
2. Erasers The eraser links has been already presented during the general discussion on structures (subsection 3.6 of Chapter 2). The corresponding rewriting rules are obtainable from the ones given in Chapter 3 assuming that the cardinality of the muxes involved in them is equal to 0. 2.1. Propagation of erasers. In the case of the propagation rule, the assumption that the mux is an eraser has no main consequences in absence of absorption: the second link of the redex is removed and each of its auxiliary door is connected to an eraser. In the case of absorption instead, the second link may not be removed, otherwise the arrow connected to the absorbing port would become dangling. So, after an absorption the second link only looses some of its ports: the ones the eraser may cross according to the usual proviso on levels (see Figure 1).
ni ? n ? m ni >m nj m
!
nj
?
?
ni m
nj
Figure 1. Propagation and absorption of erasers
2. ERASERS
185
2.2. Interactions between an eraser and a mux. The case of interaction erasermux is analogous to the case of propagation. Here, we have to distinguish if only one or both the muxes are erasers. In the ﬁrst case, the mux is removed and an eraser is connected to each of its auxiliary doors. The only possibility is the one of a swap rule. Let e and e◦ be the kmux and the eraser which interact. According to the rules on the thresholds of the swap rule, when the threshold m◦ of e◦ is greater than the one e , the new eraser connected to the ith door vi of e must also be lifted by the oﬀset a i qi of such a port, that is, the eraser e◦ has threshold me + qi. Otherwise, when m◦ < m , all the instances of e◦ maintain the threshold e◦ . In the second case, the one of two facing erasers, the rule cause instead the annihilation of both the links independently form the values of their thresholds. So, the result is an empty structure. 2.3. Loss of the local conﬂuence. The main drawback of the erasers is that in presence of them the π interactions are no more locally conﬂuent. Let us take for instance the critical pair of Figure 2. We see that two structures on the righthandside are inconvertible.
? ? m1 n1
?
m1
n
n
?
n2 m2 m1;m2 <n ? m2 n
Figure 2. Critical pair (I). An analogous example may be obtained replacing one of the two erasers of Figure 2 with a lift. The corresponding reductions are drawn in Figure 3. Such a second example shows that what fails in presence of eraser is the mux permutation equivalence. In fact, the completion the critical pair in Figure 3 induces is the one obtainable adding an equivalence rule like this:
186
A. WEAKENING AND ERASERS
? ? m2 n1
?
m2+q ? n2+q n
m2
n
n2+q
a
n2 m1 m1 <m2<n m2+q ? n2+q
Figure 3. Critical pair (II).
n m2 m1 <m2 <n
?
n+q n a m1 m2 +q
∅
=
n+q ∅ m2 +q a m1
n
Anyhow, it is not diﬃcult to see that such a rule would lead to a wrong system. For instance, assume that the pair composed by the lift e (with threshold m1 and oﬀset q) followed by the eraser e◦ (with threshold m2 +q) is connected to an adl ea whose external door is at level n, with m1 < n < m2. The lift propagates through ^ ^ the adl, while the eraser stops absorbed by ea. Replacing the pair lift/eraser with an eraser (whose threshold is equal to m2) we see that there is any more lift propagating through ea and that the part accessed by the external door of ea is no more lifted by q, but remains at its old level. 3. Conclusions The previous discussion explain that in presence of weakening constructors (Kabstractions in the λcalculus case) the techniques developed in the dissertation are not immediately extendible. As pointed out by the last examples the problem is connected with the shape of the eraser link which causes the loss of the locally conﬂuence. Even if no detailed study on the subject has been published yet, the relevant literature agrees that the problem should not have consequences for the soundness of the λcalculus implementation. In spite of this, we prefer to not get involved in the study of a particular case, but to try to solve the problem more in general
3. CONCLUSIONS
187
changing the shape of the weaning and of the eraser according to the work of Banach [Ban95]. Namely, since the problem connected by the use of weakenings and erasers is the loss of the connectedness of the structure, we add to each weakening link has a port connecting it to a link which precedes it in a correct sequentialization of the net. In this way, in MELL a weakening component would be always connected to the main part of the boxes containing it, that is, to the part of the box which is a proof net by itself. According to this, the eraser should be transformed in a sort of lifts having a particular behavior on the logical nodes (erasing them). We conjecture that suitably adapting the mux rules to such new erasers we should recover the coherence of the implementation, that is, we should ensure that the unique π normalform of a proper structure is its readback. However, the work on this subject is yet at a preliminary stage and would deserve further analysis.
188
A. WEAKENING AND ERASERS
Bibliography
[ADLR94] Andrea Asperti, Vincent Danos, Cosimo Laneve, and Laurent Regnier. Paths in the lambdacalculus: three years of communications without understanding. In Proceedings of 9th Annual Symposium on Logic in Computer Science, pages 426–436, Paris, [AGN95] France, July 1994. IEEE. A. Asperti, C. Giovannetti, and A. Naletto. The bologna optimal higherorder machine. Technical Report UBLCS959, University of Bologna, Department of Computer Science, March 1995. [AKP84] Arvind, Vinod Kathail, and Keshaw Pingali. Sharing of computation in functional language implementations. Technical report, MIT, Laboratory for Computer Science, Cambridge, Massachusetts, July 1984. Andrea Asperti and Cosimo Laneve. Interaction Systems I: The theory of optimal reductions. Technical Report TR1748, INRIARocquencourt, September 1992. Andrea Asperti and Cosimo Laneve. Interaction systems. In Int. Workshop on Higher Order Algebra, Logic and Term Rewriting, 1993. [AL93b] Andrea Asperti and Cosimo Laneve. Interaction Systems II: The practice of optimal reductions. Technical Report UBLCS9312, Laboratory for Computer Science, University of Bologna, May 1993. Andrea Asperti and Cosimo Laneve. Optimal reductions in interaction systems. In M.C. Gaudel and J.P. Jounnaud, editors, Proceedings of TapSoft, number 628 in LNCS, pages 485–500, Orsay, France, April 1993. SpringerVerlag. [AL93d] Andrea Asperti and Cosimo Laneve. Paths, computations and labels in the λcalculus. In C. Kirchner, editor, Rewriting Techniques and Applications, Proceedings of the 5th International Conference, RTA 93, volume 690 of LNCS, pages 152–167, Montreal, Canada, June 1993. SpringerVerlag. [AL95] Andrea Asperti and Cosimo Laneve. Comparing λcalculus translations in sharing graphs. In M. DezaniCiancaglini and Gordon Plotkin, editors, Typed Lambda Calculi and Applications, TLCA ’95, volume 902 of LNCS, pages 1–15. SpringerVerlag, 1995. [Asp95a] Andrea Asperti. δ ◦ !ǫ = 1: Optimizing optimal λcalculus implementations. In Jieh Hsiang, editor, Rewriting Techniques and Applications, 6th International Conference, RTA95, LNCS 914, pages 102–116, Kaiserslautern, Germany, April 5–7, 1995. [Asp95b] SpringerVerlag. Andrea Asperti. Linear logic, comonads and optimal reductions. Fundamenta infomaticae, 22:3–22, 1995.
189
[AL92] [AL93a]
[AL93c]
190
BIBLIOGRAPHY
[Asp96]
Andrea Asperti. On the complexity of betareduction. In Proceedings of Twentythird Annual ACM Symposyum on Principles of Programming Languages, St. Petersburg Beach, Florida, January 1996. ACM. Richard Banach. Sequent reconstruction in LLM—A sweepline proof. Annals of Pure and Applied Logic, 73:277–295, 1995. Henk P. Barendregt. The Lambda Calculus, its Syntax and Semantics, volume 103 of Studies in logic and the foundations of mathematics. NorthHolland, Amsterdam, The Netherlands, 1984.
[Ban95] [Bar84]
[Bel93] [BL79] [BS94]
G. Bellin. Proof nets for multiplicative and additive linear logic. Manuscript, April 1993. G´rard Berry and JeanJacques L´vy. Minimal and optimal computations of recursive e e programs. Journal of the ACM, 26(1):148–175, January 1979. Bellin and Scott. On the πcalculus and linear logic. Theoretical Computer Science,
135, 1994. [BvdW95] G. Bellin and J.. van de Wiele. Empires and kingdoms in MLL. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 249–270. Cambridge University Press, 1995. London Mathematical Society Lecture Note Series [Dan89] 222, Proceedings of the 1993 Workshop on Linear Logic, Cornell Univesity, Ithaca. Vincent Danos. Dynamic graphs, an alternative way to compute λterms (summarised version). In Proc. Third It. Conference on Th. Comp. Science, Mantova, 1989. World Scientiﬁc. Vincent Danos. Une Application de la Logique Lin´aire a l’Etude des Processus de e ` ` Normalisation (principalement du λcalcul). PhD Thesis, Universit´ Paris 7, June e 1990. [DR89] [DR93] V. Danos and L. Regnier. The structure of multiplicatives. Archive for Mathematical Logic, 28:181–203, 1989. Vincent Danos and Laurent Regnier. Local and asyncrhonous betareduction. In Proceedings of 8th Annual Symposium on Logic in Computer Science, pages 296– 306, Montreal, Canada, June 1993. IEEE. V. Danos and L. Regnier. Proofnets and the Hilbert space. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 307–328. Cambridge University Press, 1995. Proceedings of the Workshop on Linear Logic, Ithaca, New [Fie90] York, June 1993. John Field. On laziness and optimality in lambda interpreters: Tools for speciﬁcation
[Dan90]
[DR95]
and analysis. In POPL 1990 [POP90], pages 1–15. [GAL92a] Georges Gonthier, Mart´ Abadi, and JeanJacques L´vy. The geometry of optimal ın e lambda reduction. In Proceedings of Nineteenth Annual ACM Symposyum on Principles of Programming Languages, pages 15–26, Albequerque, New Mexico, January 1992. ACM. [GAL92b] Georges Gonthier, Mart´ Abadi, and JeanJacques L´vy. Linear logic without boxes. ın e In Proceedings of 7th Annual Symposium on Logic in Computer Science, pages 223– 234, Santa Cruz, CA, June 1992. IEEE.
BIBLIOGRAPHY
191
[Gir87] [Gir88] [Gir89]
JeanYves Girard. Linear logic. Theoretical Computer Science, 50(1):1–102, 1987. JeanYves Girard. Geometry of interaction 2: Deadlockfree algorithms. In Proc. of the International Conference on Computer Logic. COLOG 88, SpringerVerlag, 1988. JeanYves Girard. Geometry of interaction 1: Interpretation of system F. In R. Ferro, C. Bonotto, S. Valentini, and A. Zanardo, editors, Logic Colloqium ‘88, pages 221– 260, Amsterdam, The Netherlands, 1989. Elsevier (NorthHolland).
[Gir95a]
J.Y. Girard. Geometry of interaction III: The general case. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 329–389. Cambridge University Press, 1995. Proceedings of the Workshop on Linear Logic, Ithaca, New York, June 1993. J.Y. Girard. Linear logic: Its syntax and semantics. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 1–42. Cambridge University Press, 1995. Proceedings of the Workshop on Linear Logic, Ithaca, New York, June
[Gir95b]
1993. [GMM96] Stefano Guerrini, Simone Martini, and Andrea Masini. Coherence for sharing proof[Gue] [Kat90] [Klo80] [Laf90] [Laf95a] nets. In RTA ’96, New Brunswick, NJ, July 1996. To appear. Stefano Guerrini. Sharingmorphisms and (optimal) λgraph reductions. The Tbilisi Symposyum on Language, Logic and Computation, Tbilisi, Georgia, October ’95. Vinod Kathail. Optimal Interpreters for lambdacalculus based functional languages. PhD Thesis, MIT, 1990. J. W. Klop. Combinatory Reduction Systems. PhD Thesis, Matematisch Centrum, Amsterdam, The Netherlands, 1980. Mathematical Centre Tracts 127. Yves Lafont. Interaction nets. In POPL 1990 [POP90], pages 95–108. Y. Lafont. From proof nets to interaction nets. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 225–247. Cambridge University Press, 1995. Proceedings of the Workshop on Linear Logic, Ithaca, New York, June [Laf95b] [Lam89] [Lam90] [Lan93] [L´v76] e [L´v78] e [L´v80] e 1993. Y. Lafont. Interaction combinators. Manuscript, 1995. John Lamping. An algorithm for optimal lambda calculus evaluation. Technical Report Series SSL8927, Xerox PARC, Palo Alto, May 1989. John Lamping. An algorithm for optimal lambda calculus reduction. In POPL 1990 [POP90], pages 16–30. Cosimo Laneve. Optimality and Concurrency in Interaction Systems. PhD Thesis, TD8/93, Univerit` di Pisa, March 1993. a JeanJacques L´vy. An algebraic interpretation of the λβKcalculus and an applicae tion of labelled λcalculus. Theoretical Computer Science, 2(1):97–114, 1976. JeanJacques L´vy. R´ductions Correctes et Optimales dans le lambdacalcul. PhD e e Thesis, Universit´ Paris VII, 1978. e JeanJacques L´vy. Optimal reductions in the lambdacalculus. In Jonathan P. Seldin e and J. Roger Hindley, editors, To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 159–191. Academic Press, 1980.
192
BIBLIOGRAPHY
[Mac94] [Mac95]
Ian Mackie. The Geometry of Implementation. PhD Thesis, Department of Computing, Imperial College of Science, Technology and Medicine, September 1994. Ian Mackie. The geometry of interaction machine. In Conference Record of POPL ’95: 22nd ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, pages 198–208, San Francisco, California, January 1995. Andrea Masini. 2sequent calculus: A proof theory of modalities. Annals of Pure and Applied Logic, 58:229–246, 1992. Andrea Masini. 2sequent calculus: Intuitionism and natural deduction. Journal of Logic and Computation, 3:533–562, 1993.
[Mas92] [Mas93a]
[Mas93b] Andrea Masini. A Proof Theory of Modalities for Computer Science. PhD Thesis, TD10/93, Univerit` di Pisa, March 1993. a [MM95a] S. Martini and A. Masini. On the ﬁne structure of the exponential rule. In J.Y. Girard, Y. Lafont, and L. Regnier, editors, Advances in Linear Logic, pages 197–210. Cambridge University Press, 1995. Proceedings of the Workshop on Linear Logic, Ithaca, New York, June 1993. [MM95b] Simone Martini and Andrea Masini. A computational interpretation of modal proofs. In H. Wansing, editor, Proof theory of Modal Logics. Kluwer, 1995. To appear. [MR91] Pasquale Malacaria and Laurent Regnier. Some results on the interpretation of λcalculus in operator algebras. In Proceedings of 6th Annual Symposium on Logic in Computer Science, Amsterdam, The Netherlands, July 1991. IEEE. Simon L. Peyton Jones. The Implementation of Functional Programming Languages. Series in Computer Science. PrenticeHall International, Englewood Cliﬀs, NJ, 1986. ACM. Proceedings of Seventeenth Annual ACM Symposyum on Principles of Programming Languages, San Francisco, California, January 1990. [Reg92] [Vui74] [Wad71] Laurent Regnier. LambdaCalcul et Reseaux. Phd Thesis, Universit´ Paris 7, January e 1992. J. Vuillemin. Correct and optimal implementation of recursion in a simple programming language. Journal of Computer and System Sciences, 9(3), 1974. C. P. Wadsworth. Semantics and pragmatics of the lambdacalculus. Phd Thesis, Oxford, England, 1971. Chapter 4.
[PJ86] [POP90]
La sera, come tutte le sere, venne la sera. Non c’` niente da fare: e quella ` una cosa che non guarda in faccia nessuno. e Succede e basta. Non importa che razza di giorno arriva a spegnere. Magari era stato un giorno eccezionale, ma non cambia nulla. Arriva e lo spegne. Amen. Cos` anche quella sera, come tutte le sere, venne la sera. ı Alessandro Baricco, Castelli di Rabbia
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.