• No se han encontrado resultados

6. CAPÍTULO CONCLUSIONES

6.1 Conclusiones

operation again by its use of the merge operator. Before defining the thread projection, we add a further annotation to each recursion and each recursion variable. GivenrecτXA.A in an annotated

interaction, let{τi}be the set of threads occurring in, butnotinitiated in,

A. Then we further annotate

this recursion asrecτ:{τi}Xand each freeXA

τ in

A

asXτA:{τi}. The added information is used for taking

off unnecessary recursion from endpoint processes.e

CONVENTION7 (annotated interactions). Henceforth

A

, . . .range over extended annotated

DEFINITION22 (Thread Projection). Let

A

be consistently annotated with additional anno- tation as noted above. Then the partial operationTP(

A

, τ)is given as follows, assuming in each lineτ1,τ2andτ0are pairwise distinct and the l.h.s. is undefined iffton the r.h.s. (if any) is undefined.

TP(Aτ1Bτ2:bs˜.A, τ) def=    b(νννs)˜ .TP(

A

, τ1) ifτ=τ1 !b(s)˜ .TP(

A,

τ2) ifτ=τ2 TP(

A

, τ) otherwise TP(Aτ1Bτ2:shop i,ei,xii.A, τ) def =    sCophei.TP(

A,

τ) ifτ=τ1 sBopihxii.TP(

A,

τ) ifτ=τ2 TP(

A,

τ) otherwise TP(

A

1+τ0

A

2, τ) def= TP(

A1

, τ0)⊕TP(

A2

, τ0) ifτ=τ0 TP(

A

1, τ)tTP(

A

2, τ) otherwise TP(ife@Aτ0then

A

1else

A

2, τ) def=

ifethenTP(

A1

, τ0)elseTP(

A2

, τ0) ifτ=τ0 TP(

A

1, τ)tTP(

A

2, τ) otherwise TP(x@Aτ0:=e.A, τ) def= x:=e.TP(

A,

τ0) ifτ=τ0 TP(

A,

τ) otherwise TP(

A

1|τ0

A

2, τ) def= TP(

A

1, τ0)|TP(

A

2, τ0) TP(

E1

|

E2

, τ) def= TP(

E1

, τ0)|TP(

E2

, τ0). TP(recτ0:{τ˜i}XA.

A

, τ) def= rec X.TP(

A

, τ) ifτ∈ {τ˜i} TP(

A

, τ) otherwise TP(XτA:{τ˜i}, τ) def= X ifτ∈ {τ˜i} 0 otherwise TP(0, τ) def= 0 IfTP(

A

, τ)is undefined, we setTP(

A,

τ) =⊥. Some observation:

(1) For each of the initialisation and communication, we have three cases:

(a) When the concerned thread coincides with its active thread, in which case we obtain the corresponding output prefix;

(b) When the concerned thread coincides with its passive thread, in which case we ob- tain the corresponding input prefix; and

(c) three, when neither applies, in which case we simply obtain the projection of the remaining body, which is, by Lemma 6, always in the input/output form.

(2) For assignment, parallel composition, conditional and ifthenelse, each of which is anno- tated with a single thread, we have two cases:

(a) When the projecting thread coincides with the thread of the interaction, we simply carry over these constructors to endpoint processes;

(b) If not, we simply merge these threads (or identity in the case of assignment). (3) Other cases are defined compositionally.

The definition of thread projection already demands that, if we ever wish it to be well-defined, the behaviours inside a thread should be built consistently, i.e. whenever we usetthe operator should

be defined. The notion of coherence includes this well-definedness, and extends it to inter-thread consistency.

The need to consider inter-thread consistency arises because the description of the behaviour of a service (replicated input) can be distributed over more than one places in one global description. In this case, we should combine the result of projecting multiple threads into one code, for which we use the merge operation again.

As an example, recall the projections we have seen in (93), page 83, which we reproduce below with annotations.

(94) A0→B1:ch(νννs).B1→A0:shop,e,xi | A0→B2:ch(νννs0).B2C3:ch0(νννt)...

Call this interaction

A

. Then we have:

TP(

A

, 0) def= ch(νννs)sBophxi.0 | ch(νννs0)... TP(

A

, 1) def= !ch(s).sCophei

TP(

A

, 2) def= !ch(s0).ch0(νννt)... TP(

A

, 3) def= !ch0(t)...

Clearly !ch(s).sCopheiand !ch(s0).ch0(νννt)...are not mergeable. The point of coherence is that, if

there are multiple threads which constitute parts of the behaviour of a permanent service, then they should be mergeable.

Since each channelchuniquely defines a service, we can collect all threads contributing to the behaviour of this service by taking the passive thread of each session initialisation interaction viach. Formally we set:

DEFINITION23 (threads-per-channels). The maptpc(

A

,ch)is defined as follows, assuming

ch06=ch. tpc(Aτ1Bτ2:ch(νννs).A0,ch) def= {τ2} ∪tpc(

A

0,ch) tpc(Aτ1Bτ2:ch0(νννs).

A

0,ch) def= tpc(

A

0,ch) tpc(Aτ1Bτ2:shop,x, .i

A

0,ch) def= tpc(

A

0,ch) tpc(x@Aτ:=e. .

A

0,ch) def= tpc(

A

0,ch) tpc(ife@Aτthen

A

0 1else

A

20,ch) def= tpc(

A

10,ch)∪tpc(

A

20,ch) tpc(

A

10+

A

20,ch) def= tpc(

A

10,ch)∪tpc(

A

20,ch) tpc(

A

10|

A

20,ch) def= tpc(

A

10,ch)∪tpc(

A

20,ch) tpc(recXτA.A0,ch) def= tpc(

A

0,ch) tpc(XτA,ch) def= /0 tpc(0,ch) def= /0

That is, ifτ1,τ2∈tpc(

A,

ch), then these two threads are parts of the behaviour of the same service. If two input threads are for the same service channel, then they are equivalent. Belowchannels(

A

)

indicates the set of service channels occurring in

A

.

DEFINITION24. Given a well-threaded annotated interaction

A

, for allτ∈

A

, we define the

equivalence class[τ]A⊆Nas [τ]A=

tpc(

A,

ch) ifchchannels(

A

)such thatτ∈tpc(

A,

ch) {τ} otherwise.

DEFINITION25 (Coherence). Given a well-threaded, consistently annotated interaction

A, we

say that

A

iscoherentif the following two conditions hold:

(1) For each threadτin

A,

TP(

A,

τ)is well-defined.

(2) For each pair of threadsτ1,τ2in

A

withτ1≡Aτ2, we haveTP(

A

, τ1)./TP(

A

, τ2).

We say a well-threaded non-annotated interactionIiscoherentifIhas an annotation which is coherent in the above sense.

EXAMPLE17. (thread projection and coherence)

(1) The interactions (88) in page 83, (91) in page 83 and (92) in page 83 are all coherent, but (93) in page 83 is not.

(2) The following annotated global description already appeared in Section 15.1 (below and henceforth we often writeIetc. for annotated interactions).

I def= 0 + (A1→B2:ch(νννs).B2→A1:shop,e,yi.0)

The descriptionIsays that there are two possible paths in interactions: in one path, noth- ing will happen. On the other, AandB will initiate a session, for which there is one interaction, and the session completes there. Then the projection ofIonto 1 and 2 are, referring to Definition 22:

TP(I, 1) def= 0⊕(c(νννs).s(y).0) TP(I, 2) def= 0t(!c(s).sophei.0)

Note the r.h.s. of the second simply becomes !c(s).sophei.0itself. Since there is a unique thread for a service atch, we concludeIis coherent.

(3) As a slightly more complex example, consider:

I0 def= A1B2:ch(νννs).B2A1:shop

1,“hello00,y1i.0+

A3→B4:ch(νννs).B2→A1:shop2,“goodbye00,y2i.0+ A5→C6:ch0(νννs0).C6A5:s0hop

1,“hi00,xi.0

In this case, the projections become:

TP(I0, 1) def= (ch(νννs).sop 1(y1).0)⊕00 TP(I0, 3) def= 0(ch(νννs).sop 1(y1).0)⊕0 TP(I0, 5) def= 0t0tch0(νννs0).s0op 2(y2).0)

TP(I0, 2) def= (!ch(s).sop

1h“hello00i.0)t0t0 TP(I0, 4) def= 0t(!ch(s).sop

2h“goodbye00i.0)t0 TP(I0, 6) def= 0t(!ch0(s0).s0op

1h“hi00i.0)t0

Immediately each ofTP(I0, i)(1i6) is defined. Since we havetpc(I0,ch) ={2,4}

and tpc(I0,ch0) ={6}, in order for I0 to be coherent, we should haveTP(I0, 2)./ TP(I0, 4)which is possible iffop

16=op2.

A further example can be found in Section 16.7

15.3. Subject Reduction for Coherence. Below

A

A

0is defined precisely following≡on

Documento similar