This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

11institutetext: Open University of the Netherlands 22institutetext: Centrum Wiskunde & Informatica (CWI)
22email: [email protected]

Shuffling posets on trajectories
(technical report)

Luc Edixhoven 0000-0002-6011-9535
Abstract

Choreographies describe possible sequences of interactions among a set of agents. We aim to join two lines of research on choreographies: the use of the shuffle on trajectories operator to design more expressive choreographic languages, and the use of models featuring partial orders, to compactly represent concurrency between agents. Specifically, in this paper, we explore the application of the shuffle on trajectories operator to individual posets, and we give a characterisation of shuffles of posets which again yield an individual poset.

Keywords:
Posets Shuffle on trajectories Concurrency

Technical report of a paper to be published in the proceedings of iFM 2023.

1 Introduction

Distributed systems are becoming ever more important. However, designing and implementing them is difficult. The complexity resulting from concurrency and dependencies among agents makes the process error-prone and debugging non-trivial. As a consequence, much research has been dedicated to analysing communication patterns, or protocols, among sets of agents in distributed systems. Examples of such research goals are to show the presence or absence of certain safety properties in a given system, to automate such analysis, and to guarantee the presence of desirable properties by construction.

Part of this research deals with choreographies. Choreographies can be used as global specifications for asynchronously communicating agents, and contain certain safety properties by construction. As a drawback, choreographic languages typically have limitations on their expressiveness, since they rely on grammatical constructs for their safety properties, which exclude some communication patterns. We have recently shown that the shuffle on trajectories operator can be used to specify choreographies without compromising expressiveness [2]. Consequently, it could serve as a basis for more expressive choreographic languages.

Other recent work on choreographies includes the use of models featuring partial orders, such as event structures [1] and pomsets [6, 3], to represent and analyse the behaviour of choreographies. By using a partial order to explicitly capture causal dependencies between pairs of actions, these models avoid the exponential blowup from, e.g., parallel composition of finite state machines.

We aim to join these two lines of research by extending the shuffle on trajectories operator from words, i.e., totally ordered traces, and languages to partially ordered traces and sets thereof. In this paper, as a first step, we explore the application of the shuffle on trajectories operator to individual partially ordered sets, or posets. The main challenge is that the resulting behaviour cannot always be represented as one poset and may require a set of them. In particular, we give a characterisation of shuffles of posets which again yield an individual poset.

Outline

We recall the concept and definition of the shuffle on trajectories operator in Section 2. We briefly discuss posets in Section 3. In Section 4 we discuss how to apply the shuffle on trajectories operator to posets, and specifically which shuffles of posets will yield an individual poset as a result. Finally, we briefly discuss future work in Section 5.

The proofs of Proposition 1 and Lemma 1 can be found in the appendix.

2 Shuffle on trajectories

We recall the basic definitions from [2]. The shuffle on trajectories operator is a powerful variation of the traditional shuffle operator111In concurrency theory, the shuffle operator is also known as free interleaving, non-communication merge, or parallel composition., which adds a control trajectory (or a set thereof) to restrict the permitted orders of interleaving. This allows for fine-grained control over orderings when shuffling words or languages. The binary operator was defined — and its properties thoroughly studied — by Mateescu et al. [4]; a multiary variant was introduced slightly later [5].

When defined on words, the shuffle on trajectories takes nn words and a trajectory, which is a word over the alphabet {1,,n}\{1,\ldots,n\}. This trajectory specifies the exact order of interleaving of the shuffled words: in Figure 1, the trajectory 1221112112 specifies that the result should first take a symbol from the first word, then from the second, then again from the second and so on.

12bananapear
Figure 1: The shuffle of ‘banana’ and ‘pear’ over a trajectory 12211121121221112112: ‘bpeanaanar’.

Formally, let w1,,wnw_{1},\ldots,w_{n} be finite words over some alphabet and let tt be a finite word over the alphabet {1,,n}\{1,\ldots,n\}. Let ε\varepsilon be the empty word. Then:

\shuffletn(w1,,wn)={a\shuffletn(w1,,wi,,wn)if t=it and wi=awiεif t=w1==wn=ε\shuffle^{n}_{t}(w_{1},\ldots,w_{n})=\begin{cases}a\shuffle^{n}_{t^{\prime}}(w_{1},\ldots,w_{i}^{\prime},\ldots,w_{n})&\text{if $t=it^{\prime}$ and $w_{i}=aw_{i}^{\prime}$}\\ \varepsilon&\text{if $t=w_{1}=\ldots=w_{n}=\varepsilon$}\end{cases}

We note that \shuffletn(w1,,wn)\shuffle^{n}_{t}(w_{1},\ldots,w_{n}) is only defined if the number of occurrences of ii in tt precisely matches the length of wiw_{i} for every ii. We then say that tt fits wiw_{i}.

Example 1
  • \shuffle1213323(ab,cd,𝑒𝑓)=𝑎𝑐𝑏𝑒𝑓𝑑\shuffle^{3}_{121332}(ab,cd,\mathit{ef})=\mathit{acbefd}, since 121332 fits every word.

  • \shuffle1212(ab,cd)\shuffle^{2}_{121}(ab,cd) is undefined, since 121 does not fit cdcd.

The shuffle on trajectories operator naturally generalises to languages: the shuffle of a number of languages on a set (i.e., a language) of trajectories is defined as the set of all valid shuffles of words in the languages for which the trajectory fits all the words. Formally:

\shuffleTn(L1,,Ln)={\shuffletn(w1,,wn)tT,w1L1,,wnLn}\shuffle^{n}_{T}(L_{1},\ldots,L_{n})=\{\shuffle^{n}_{t}(w_{1},\ldots,w_{n})\mid t\in T,w_{1}\in L_{1},\ldots,w_{n}\in L_{n}\}

As the operator’s arity is clear from its operands, we typically omit it.

3 Posets

Partially ordered sets, or posets for short, consist of a set of nodes EE (events), and a partial order222Recall that a partial order is reflexive, transitive and antisymmetric. \leq defining dependencies between pairs of events — i.e., an event can only fire if all events preceding it in the partial order have already fired. We write a<ba<b to denote that aba\leq b and aba\neq b. We write aba\geq b resp. a>ba>b to denote that bab\leq a resp. b<ab<a. We write a≹ba\not\gtrless b to denote that aba\not\leq b and bab\not\leq a; we then say that aa and bb are concurrent. We occasionally write EP,PE_{P},\leq_{P}, <P<_{P}, P\geq_{P}, >P>_{P} and ≹P\not\gtrless_{P} to specify that the set of events or relation belongs to poset PP, but where this is clear from context we typically omit the subscript.

The behaviour (or language) of a poset PP, written L(P)L(P), is the set of all maximal traces, i.e., maximal sequences of its events, that abide by \leq. In this sense, posets can be considered a generalisation of words with concurrency: they feature a fixed set of symbols (events)333There is a difference between words and posets in the sense that the events in a poset must be unique, whereas a word may contain duplicate symbols. It would be more accurate to say that words generalise to labelled posets, or lposets, and from there to partially ordered multisets, or pomsets. However, in this paper we focus on posets, where all symbols are thus unique., but they can allow multiple orderings of them instead of only a single one. Concurrent events can happen in any order. Consequently, all traces obtained from a trace in L(P)L(P) by swapping adjacent concurrent events must also be in L(P)L(P). In fact, any trace in L(P)L(P) can be obtained from any other trace in L(P)L(P) in this fashion.

Example 2

For poset PexP_{ex} in Figure 2, E={a,b,c,d}E=\{a,b,c,d\} and the partial order consists of aaa\leq a, aca\leq c, ada\leq d, bbb\leq b, bdb\leq d, ccc\leq c and ddd\leq d. Its language L(Pex)L(P_{ex}) consists of the traces abcdabcd, abdcabdc, acbdacbd, bacdbacd, and badcbadc.

Pex=P_{ex}= aabbccddP1=P_{1}= aabbccddP2=P_{2}= eeLPt1=LP_{t_{1}}= 1111111122

LPt2=LP_{t_{2}}= 1111111122Pr1=P_{r_{1}}= aabbccddeePr2a=P_{r_{2a}}= aabbccddeePr2b=P_{r_{2b}}= aabbccddee

Figure 2: Graphical representation of a number of posets and lposets, where an arrow from aa to bb should be read as aba\leq b. The partial order is the reflexive and transitive closure of the dependencies depicted by the arrows. For the lposets, the labels are shown rather than their events.

We note that the dependencies in a poset can also be observed in its set of traces. For example, if a<ba<b then aa will precede bb in every trace, and if a≹ba\not\gtrless b then there will both be traces where aa precedes bb and traces where bb precedes aa. Formally, we can extract the following relation L\leq_{L} from a set of traces LEL\subseteq E^{*}:

x,y,zE:xaybzLx^,y^,z^E:x^by^az^LaLbaLaaLbLcaLc\displaystyle\dfrac{\begin{gathered}\exists x,y,z\in E^{*}:xaybz\in L\\ \forall\hat{x},\hat{y},\hat{z}\in E^{*}:\hat{x}b\hat{y}a\hat{z}\notin L\end{gathered}}{a\leq_{L}b}\qquad\dfrac{}{a\leq_{L}a}\qquad\dfrac{a\leq_{L}b\leq_{L}c}{a\leq_{L}c}

We then propose the following:

Proposition 1 ()

Let P=EP,PP=\langle E_{P},\leq_{P}\rangle be a poset. Then L(P)=P{\leq_{L(P)}}={\leq_{P}}.

To model trajectories, which require duplicate symbols, we must also introduce labelled posets, or lposets. In these, every event is assigned a label, which is not necessarily unique. Its traces then use these labels instead of the events.

4 Shuffling posets

As a first step towards shuffling posets, we first reinterpret shuffles on words as posets. In other words: we consider the case where all posets, including the trajectory, are totally ordered and thus consist of a single trace. This is shown in Figure 3, which features the shuffle from Figure 1 interpreted as a poset. The traces ‘banana’ and ‘pear’ are present as totally ordered parts of the poset, and the trajectory adds additional dependencies between the two, as shown by the vertical (and diagonal) arrows.

bba1a_{1}n1n_{1}a2a_{2}n2n_{2}a3a_{3}ppeea4a_{4}rr
1111112222
Figure 3: The figure on the left shows the shuffle from Figure 1 interpreted as a shuffle of posets. Indices have been added to duplicate symbols to make them unique. Some of the arrows are redundant but are kept to illustrate the general idea. The figure on the right shows the trajectory, 1221112112, as an lposet.

Generalising this to arbitrary posets and lposets is not trivial, but we have some knowledge to assist us. Crucially, since we can determine the language of a poset, it must be so that the result of shuffling posets yields the same language as the shuffle of the languages of these posets, which is defined in Section 2:

L(\shufflePt(P1,,Pn))=\shuffleL(Pt)(L(P1),,L(Pn))L(\shuffle_{P_{t}}(P_{1},\ldots,P_{n}))=\shuffle_{L(P_{t})}(L(P_{1}),\ldots,L(P_{n}))

If the result is an individual poset, by Proposition 1 it must then be:

\shufflePt(P1,,Pn)=EP1EPn,\shuffleL(Pt)(L(P1),,L(Pn))\shuffle_{P_{t}}(P_{1},\ldots,P_{n})=\langle E_{P_{1}}\cup\ldots\cup E_{P_{n}},\leq_{\shuffle_{L(P_{t})}(L(P_{1}),\ldots,L(P_{n}))}\rangle

For example, consider \shuffleLPt1(P1,P2)\shuffle_{LP_{t_{1}}}(P_{1},P_{2}), with LPt1LP_{t_{1}}, P1P_{1} and P2P_{2} as in Figure 2. LPt1LP_{t_{1}} has traces 1121 and 1112, P1P_{1} has traces abcdabcd, acbdacbd and cabdcabd, and P2P_{2} has a single trace ee. Shuffling these languages yields L1={abced,acbed,cabed,abcde,acbde,cabde}L_{1}=\{abced,acbed,cabed,abcde,\allowbreak acbde,\allowbreak cabde\}. From this we extract L1\leq_{L_{1}}, which contains all the dependencies present in P1P_{1} and P2P_{2} and, additionally, aL1ea\leq_{L_{1}}e, bL1eb\leq_{L_{1}}e and cL1ec\leq_{L_{1}}e. This corresponds to poset Pr1P_{r_{1}} in Figure 2, which indeed yields the language L1L_{1}.

However, now consider \shuffleLPt2(P1,P2)\shuffle_{LP_{t_{2}}}(P_{1},P_{2}), again as in Figure 2. LPt2LP_{t_{2}} has traces 1211, 1121 and 1112, which yields L2=L1{abecd,acebd,caebd}L_{2}=L_{1}\cup\{abecd,acebd,caebd\}. From this we extract L2\leq_{L_{2}}, which still contains all the dependencies in P1P_{1} and P2P_{2}, but otherwise only aL2ea\leq_{L_{2}}e: the traces abecdabecd and acebdacebd imply that bb and cc are concurrent with ee. However, then the trace aebcdaebcd should also be in L2L_{2}, which it is not. We can then conclude from Proposition 1 that there exists no poset PP such that L(P)=L2L(P)=L_{2}. In fact, L2L_{2} corresponds to a set of two posets, namely Pr2aP_{r_{2a}} and Pr2bP_{r_{2b}} in Figure 2.

We proceed by giving a characterisation of shuffles of posets for which the result corresponds to an individual poset. A key insight is that, if the result must correspond to an individual poset, then any two events which are concurrent in one of the operands of the shuffle must, in the resulting poset, have the same relation (<<, >> or ≹\not\gtrless) to any third event originating from another operand:

Lemma 1 ()

Let LPtLP_{t} be an lposet and P1,,Pn,PP_{1},\ldots,P_{n},P posets such that L(\shuffleLPt(P1,,Pn))=L(P)L(\shuffle_{LP_{t}}(P_{1},\allowbreak\ldots,P_{n}))=L(P) and L(P)L(P)\neq\emptyset. If a,bEPia,b\in E_{P_{i}} such that a≹Piba\not\gtrless_{P_{i}}b and cEPjc\in E_{P_{j}} with iji\neq j, then either a,b<Pca,b<_{P}c, or a,b>Pca,b>_{P}c, or a,b≹Pca,b\not\gtrless_{P}c.

We can then group the events in every PiP_{i} according to the reflexive and transitive closure of the concurrency relation ≹Pi\not\gtrless_{P_{i}}; two events which are related in this closure then belong to the same group. Note that, while the events in a group are partially ordered, the groups of every PiP_{i} are, by construction, totally ordered. It follows from Lemma 1 that two events in the same group, even when not concurrent, must have the same relation to any event outside of their group in PP. This in turn implies a similar condition on the trajectory lposet: any two ii-labelled events in LPtLP_{t} that can match two events from the same group of PiP_{i} must have the same relation to any jj-labelled event in LPtLP_{t} (where jj is not necessarily unequal to ii) that can match an event outside of their group.

Figure 4 shows Pr1P_{r_{1}}, corresponding to \shuffleLPt1(P1,P2)\shuffle_{LP_{t_{1}}}(P_{1},P_{2}), and LPt1LP_{t_{1}} (from Figure 2), both restructured to show the groups of P1P_{1} and P2P_{2}. This demonstrates an interesting parallel with Figure 3: both feature horizontal traces with additional arrows specifying dependencies between components of these traces. However, in Figure 3 the components consist of individual events, whereas in Figure 4 the components consist of posets. In this sense, shuffles resulting in individual posets generalise shuffles on traces.

aabbccddee
11112
Figure 4: The figure on the left shows Pr1P_{r_{1}}, corresponding to \shuffleLPt1(P1,P2)\shuffle_{LP_{t_{1}}}(P_{1},P_{2}) (see Figure 2), restructured to show the groups of P1P_{1} and P2P_{2}. An arrow from one group of events to another should be read as an arrow from all events in the originating group to all events in the target group. The figure on the right shows the restructured LPt1LP_{t_{1}}; the dependencies within groups in LPt1LP_{t_{1}} are irrelevant for the resulting traces.

Concluding, we can then characterise shuffles on posets which result in individual posets as those where the trajectory lposet is structured along the operand posets’ groups, as in Figure 4, possibly with dependencies between different operands’ groups.

5 Future work

Now that we have studied shuffles of posets resulting in individual posets, there are two evident avenues for future work: (1) shuffles of lposets, where one label may occur multiple times rather than just considering orderings of unique events and (2) shuffles of posets resulting in sets of posets and shuffles of sets of posets, where the main challenge may be to minimise the resulting number of posets.

References

  • [1] Castellani, I., Dezani-Ciancaglini, M., Giannini, P.: Event structure semantics for multiparty sessions. J. Log. Algebraic Methods Program. 131, 100844 (2023)
  • [2] Edixhoven, L., Jongmans, S.: Balanced-by-construction regular and ω\omega-regular languages. Int. J. Found. Comput. Sci. 34(2&3), 117–144 (2023)
  • [3] Edixhoven, L., Jongmans, S., Proença, J., Cledou, G.: Branching pomsets for choreographies. In: ICE. EPTCS, vol. 365, pp. 37–52 (2022)
  • [4] Mateescu, A., Rozenberg, G., Salomaa, A.: Shuffle on trajectories: Syntactic constraints. Theor. Comput. Sci. 197(1-2), 1–56 (1998)
  • [5] Mateescu, A., Salomaa, K., Yu, S.: On fairness of many-dimensional trajectories. J. Autom. Lang. Comb. 5(2), 145–157 (2000)
  • [6] Tuosto, E., Guanciale, R.: Semantics of global view of choreographies. J. Log. Algebraic Methods Program. 95, 17–40 (2018)

Appendix 0.A Proofs from the paper

See 1

Proof
  • Suppose that aPba\leq_{P}b for some a,bEPa,b\in E_{P}. Then, since P\leq_{P} is a partial order, either:

    • a=ba=b, in which case also aL(P)ba\leq_{L(P)}b since L(P)\leq_{L(P)} is reflexive; or

    • aPba\leq_{P}b but aba\neq b, in which case aa will precede bb in every (maximal) trace of PP. Furthermore, L(P)L(P) will not be empty, and then aL(P)ba\leq_{L(P)}b by its first rule.

  • Suppose that aL(P)ba\leq_{L(P)}b for some a,bEPa,b\in E_{P}. Then, by definition of L(P)\leq_{L(P)}, either:

    • a=ba=b, in which case also aPba\leq_{P}b since P\leq_{P} is reflexive; or

    • (1) x,y,zEP:xaybzL(P)\exists x,y,z\in E_{P}^{*}:xaybz\in L(P) and (2) x^,y^,z^EP:x^by^az^L(P)\forall\hat{x},\hat{y},\hat{z}\in E_{P}^{*}:\hat{x}b\hat{y}a\hat{z}\notin L(P). Suppose, for the sake of contradiction, that aPba\not\leq_{P}b. Then either a>Pba>_{P}b, which contradicts (1), or a≹Pba\not\gtrless_{P}b, which contradicts (2) since there should then also exist some trace in L(P)L(P) in which bb precedes aa. We can thus conclude that aPba\leq_{P}b.

    We note that the transitive rule for L(P)\leq_{L(P)} is subsumed by the other two and does not need to be considered separately. Nevertheless, a straightforward inductive argument suffices to cover this.

See 1

Proof

If no subscript is given, in this proof, << and ≹\not\gtrless refer to <P<_{P} and ≹P\not\gtrless_{P}.

We start by making three observations:

  1. (1)

    As noted in Section 3, if a≹Piba\not\gtrless_{P_{i}}b, then there must exist traces in L(Pi)L(P_{i}) such that aa occurs before bb in one, and after bb in another. Furthermore, since all traces of a poset can be obtained from an arbitrary one by swapping adjacent concurrent events, there must also exist traces such that aa and bb are adjacent to each other, in both orders, e.g., vabwvabw and vbawvbaw for some v,wv,w.

  2. (2)

    The causal relation between two events in PiP_{i} remains the same in PP. The shuffle on trajectories operator does not change the internal order of the traces of its operands, meaning that, for example if dd occurs before ee in every trace of PiP_{i}, then it will also occur before ee in every trace of PP. Similarly, if PiP_{i} both contains traces in which dd occurs before ee and traces in which dd occurs after ee, then so will PP. In particular, this means that, since a≹Piba\not\gtrless_{P_{i}}b, also a≹ba\not\gtrless b.

  3. (3)

    If two events are concurrent in PiP_{i} and can thus be swapped in traces of PiP_{i} when adjacent, then they can also be swapped in traces of PP when there are no other events from PiP_{i} in between them. The shuffle on trajectories operator does not make any distinction between the corresponding traces from PiP_{i}. Additionally, we note that this implies that the two events are concurrent with all events (from other operands) in between.

Consider the relation between aa, bb and cc in PP. As observed in (2), a≹ba\not\gtrless b.

  • Suppose that a<ca<c and c<bc<b. It then follows by transitivity (recall that \leq is a partial order) that a<ba<b, which contradicts a≹ba\not\gtrless b. Analogously, we can exclude the case where b<cb<c and c<ac<a.

  • Suppose that a<ca<c and b≹cb\not\gtrless c. Then, there must exist a trace uavcwbxuavcwbx in L(P)L(P) for some u,v,w,xu,v,w,x, i.e., a trace where aa occurs before cc and where bb occurs after cc. If vwvw contains no events from PiP_{i}, then it follows from a≹ba\not\gtrless b and (3) that L(P)L(P) must also contain ubvcwaxubvcwax, which contradicts a<ca<c. Otherwise, we systematically remove the events from PiP_{i} in vwvw:

    • Let dd be the leftmost event from PiP_{i} in vwvw such that d<bd<b. Then, since we must be able to swap adjacent concurrent events in traces of PiP_{i} until aa and bb are adjacent (as noted in (1)), dd must be concurrent with all events from PiP_{i} to the left of it in avwavw (including aa). We can thus swap dd with its left neighbour from PiP_{i} until it has been swapped with aa, thus reducing the number of events from PiP_{i} in vwvw by 1. We repeat this until there are no events left in the remainder of vwvw that fit this description.

    • Analogously, let ee be the rightmost event from PiP_{i} in the remainder of vwvw such that a<ea<e. Then ee must be concurrent with all events from PiP_{i} to the right of it until at least bb, so we swap it with its right neighbour from RPiRPi until it has been swapped with bb. Again, we repeat this until there are no events left that fit this description.

    • All events from PiP_{i} remaining in vwvw must now be concurrent with both aa and bb. We can thus keep swapping aa with its right neighbour (or, alternatively, bb with its left neighbour) from PiP_{i} until there are no events from PiP_{i} remaining between aa and bb.

    If, at some point, aa has passed cc and is now to the right of it, then this contradicts a<ca<c. If aa remains to the left of cc and bb to its right, then we can swap aa and bb to contradict a<ca<c. Otherwise, if bb has passed cc and is now to the left of it, then bb must be concurrent with all events to the right of it at least until cc (as noted in (3)). We can then swap it with its right neighbour (from PP) until it has been swapped with cc, after which we can swap it with aa to contradict a<ca<c.

    As all cases lead to a contradiction, we can thus conclude that it is not possible that a<ca<c and b≹cb\not\gtrless c. Analogously, we can also exclude the cases where c<ac<a and b≹cb\not\gtrless c, where b<cb<c and a≹ca\not\gtrless c, and where c<bc<b and a≹ca\not\gtrless c.

As we have excluded all other cases, this proves that either a,b<ca,b<c, or c<a,bc<a,b, or a,b≹ca,b\not\gtrless c. ∎