22email: [email protected]
Shuffling posets on trajectories
(technical report)
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 ConcurrencyTechnical 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 words and a trajectory, which is a word over the alphabet . 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.
Formally, let be finite words over some alphabet and let be a finite word over the alphabet . Let be the empty word. Then:
We note that is only defined if the number of occurrences of in precisely matches the length of for every . We then say that fits .
Example 1
-
•
, since 121332 fits every word.
-
•
is undefined, since 121 does not fit .
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:
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 (events), and a partial order222Recall that a partial order is reflexive, transitive and antisymmetric. 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 to denote that and . We write resp. to denote that resp. . We write to denote that and ; we then say that and are concurrent. We occasionally write , , , and to specify that the set of events or relation belongs to poset , but where this is clear from context we typically omit the subscript.
The behaviour (or language) of a poset , written , is the set of all maximal traces, i.e., maximal sequences of its events, that abide by . 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 by swapping adjacent concurrent events must also be in . In fact, any trace in can be obtained from any other trace in in this fashion.
Example 2
For poset in Figure 2, and the partial order consists of , , , , , and . Its language consists of the traces , , , , and .
We note that the dependencies in a poset can also be observed in its set of traces. For example, if then will precede in every trace, and if then there will both be traces where precedes and traces where precedes . Formally, we can extract the following relation from a set of traces :
We then propose the following:
Proposition 1 ()
Let be a poset. Then .
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.
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:
If the result is an individual poset, by Proposition 1 it must then be:
For example, consider , with , and as in Figure 2. has traces 1121 and 1112, has traces , and , and has a single trace . Shuffling these languages yields . From this we extract , which contains all the dependencies present in and and, additionally, , and . This corresponds to poset in Figure 2, which indeed yields the language .
However, now consider , again as in Figure 2. has traces 1211, 1121 and 1112, which yields . From this we extract , which still contains all the dependencies in and , but otherwise only : the traces and imply that and are concurrent with . However, then the trace should also be in , which it is not. We can then conclude from Proposition 1 that there exists no poset such that . In fact, corresponds to a set of two posets, namely and 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 ) to any third event originating from another operand:
Lemma 1 ()
Let be an lposet and posets such that and . If such that and with , then either , or , or .
We can then group the events in every according to the reflexive and transitive closure of the concurrency relation ; 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 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 . This in turn implies a similar condition on the trajectory lposet: any two -labelled events in that can match two events from the same group of must have the same relation to any -labelled event in (where is not necessarily unequal to ) that can match an event outside of their group.
Figure 4 shows , corresponding to , and (from Figure 2), both restructured to show the groups of and . 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.
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 -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 for some . Then, since is a partial order, either:
-
–
, in which case also since is reflexive; or
-
–
but , in which case will precede in every (maximal) trace of . Furthermore, will not be empty, and then by its first rule.
-
–
-
•
Suppose that for some . Then, by definition of , either:
-
–
, in which case also since is reflexive; or
-
–
(1) and (2) . Suppose, for the sake of contradiction, that . Then either , which contradicts (1), or , which contradicts (2) since there should then also exist some trace in in which precedes . We can thus conclude that .
We note that the transitive rule for 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 refer to and .
We start by making three observations:
-
(1)
As noted in Section 3, if , then there must exist traces in such that occurs before in one, and after 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 and are adjacent to each other, in both orders, e.g., and for some .
-
(2)
The causal relation between two events in remains the same in . The shuffle on trajectories operator does not change the internal order of the traces of its operands, meaning that, for example if occurs before in every trace of , then it will also occur before in every trace of . Similarly, if both contains traces in which occurs before and traces in which occurs after , then so will . In particular, this means that, since , also .
-
(3)
If two events are concurrent in and can thus be swapped in traces of when adjacent, then they can also be swapped in traces of when there are no other events from in between them. The shuffle on trajectories operator does not make any distinction between the corresponding traces from . Additionally, we note that this implies that the two events are concurrent with all events (from other operands) in between.
Consider the relation between , and in . As observed in (2), .
-
•
Suppose that and . It then follows by transitivity (recall that is a partial order) that , which contradicts . Analogously, we can exclude the case where and .
-
•
Suppose that and . Then, there must exist a trace in for some , i.e., a trace where occurs before and where occurs after . If contains no events from , then it follows from and (3) that must also contain , which contradicts . Otherwise, we systematically remove the events from in :
-
–
Let be the leftmost event from in such that . Then, since we must be able to swap adjacent concurrent events in traces of until and are adjacent (as noted in (1)), must be concurrent with all events from to the left of it in (including ). We can thus swap with its left neighbour from until it has been swapped with , thus reducing the number of events from in by 1. We repeat this until there are no events left in the remainder of that fit this description.
-
–
Analogously, let be the rightmost event from in the remainder of such that . Then must be concurrent with all events from to the right of it until at least , so we swap it with its right neighbour from until it has been swapped with . Again, we repeat this until there are no events left that fit this description.
-
–
All events from remaining in must now be concurrent with both and . We can thus keep swapping with its right neighbour (or, alternatively, with its left neighbour) from until there are no events from remaining between and .
If, at some point, has passed and is now to the right of it, then this contradicts . If remains to the left of and to its right, then we can swap and to contradict . Otherwise, if has passed and is now to the left of it, then must be concurrent with all events to the right of it at least until (as noted in (3)). We can then swap it with its right neighbour (from ) until it has been swapped with , after which we can swap it with to contradict .
As all cases lead to a contradiction, we can thus conclude that it is not possible that and . Analogously, we can also exclude the cases where and , where and , and where and .
-
–
As we have excluded all other cases, this proves that either , or , or . ∎