On the Send-Synchronizability Problem for Mailbox Communication
Abstract
A system of communicating automata is send-synchronizable if its set of send sequences (i.e., the projection on send actions of its executions) is the same when communications are asynchronous and when they are rendez-vous synchronizations. Send-synchronizability was claimed to be decidable for the mailbox semantics (Basu and Bultan, 2011) and for the peer-to-peer semantics (Basu and Bultan, 2016). Finkel and Lozes showed in 2017 that the proofs of these results are flawed, and they proved that send-synchronizability is in fact undecidable for peer-to-peer systems. The send-synchronizability problem for mailbox systems was left open. A partial solution was recently proposed in (Di Giusto, Laversa and Peters, 2024). In this paper, we revisit the send-synchronizability problem for mailbox systems. Firstly, we show that send-synchronizability is undecidable for mailbox systems, thus closing the question left open in (Finkel and Lozes, 2023) and (Di Giusto, Laversa and Peters, 2024). Secondly, we show that send-synchronizability is decidable for the class of 1-schedulable mailbox systems. A system is 1-schedulable if every execution can be re-scheduled into an equivalent execution where each send is either immediately followed by its matching receive, or is never matched. Despite the apparent similarity between send-synchronizability and 1-schedulability, the proof that send-synchronizability is decidable for 1-schedulable mailbox systems is quite involved. We believe that the techniques that we develop in this proof could be used to address other problems on mailbox systems, such as the realizability problem.
Keywords and phrases:
Concurrent programming, Mailbox communication, Verification, SynchronizabilityCopyright and License:
2012 ACM Subject Classification:
Theory of computation Logic and verificationFunding:
This work was (partially) supported by the grant ANR-23-CE48-0005 of the French National Research Agency ANR (project PaVeDyS).Editors:
Patricia Bouyer and Jaco van de PolSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Message-passing is a key synchronization mechanism for concurrent programming and distributed systems. In this model, processes running asynchronously synchronize by exchanging messages over unbounded channels. Typically, the communication follows a peer-to-peer model, which is particularly useful for reasoning about telecommunication protocols.
Recently, mailbox communication has attracted increased attention due to its role in multi-thread programming, as seen in languages like Rust or Erlang. In mailbox communication each process has a single incoming communication buffer, or mailbox, where messages from other processes are multiplexed.
Asynchronous communication poses significant challenges for formal verification, since it can easily emulate Turing machines. The quest for conditions that ensure decidability for automatic verification has led to various restrictions, such as constraints on channel behavior (e.g. lossiness [1, 12], or properties based on partial-orders [18, 14, 20]). More recently, research has focused on restricting the communication protocols themselves [6, 16, 17, 8].
While synchronous communication offers great simplicity, its relevance extends beyond verification. Many specification formalisms, such as choreography languages [2] and multi-party session types [24, 22, 23], are built upon synchronous communication. This raises a fundamental question, considering the inherent asynchrony of real-world systems: how different is an asynchronous system from its idealized synchronous version, where every sent message is instantaneously received?
Send-synchronizability offers one way to compare synchronous and asynchronous semantics. The work [13] defined a system as (send-)synchronizable if the sequence of sent messages is identical under both asynchronous and synchronous semantics. While [2] claimed decidability for mailbox systems and later extended the claim to peer-to-peer systems [3], the latter claim was refuted by [10, 11], showing undecidability for peer-to-peer systems. The decidability of send-synchronizability for mailbox systems, however, remained an open question (see, e.g., [9]), and this paper addresses it.
Send-synchronizability has been explored in several subsequent works [2, 4, 3, 11, 9] with variations such as final states, or requiring that the same state is reached in both the synchronous and asynchronous execution. For example, in [9], each process has a set of final states. This generalized version was shown to be undecidable in [9], with final states playing a key role in the proof. Our first contribution is to show that send-synchronizability remains undecidable even in the standard setting of communicating systems without final states.
Our second contribution shows the decidability of send-synchronizability for -schedulable systems. These systems, termed 1-synchronizable in [6] but renamed here for clarity, share similarities with the synchronous semantics. However, a key difference is that not all messages need to be received. A system is -schedulable if every execution can be reordered into an equivalent one where each send is either immediately followed by its corresponding receive, or remains unmatched. Being -schedulable is a decidable property, with PSPACE complexity [6, 16]. We show that send-synchronizability is decidable for -schedulable systems, but the proof is surprisingly intricated because of the unreceived messages. Our proof employs partial-order techniques (commutations), with the main challenge being the unmatched send events.
For convenience, technical terms and notations in the electronic version of this manuscript are hyper-linked to their definitions (cf. https://ctan.org/pkg/knowledge).
2 Definitions and Notations
2.1 Mailbox message-passing systems
We let denote a finite non-empty set of processes, and denote a finite non-empty set of message contents. The set of (communication) actions is . An action denotes a send by of message to and an action denotes a receive by of message from . In both cases, the process performing the action is . A communicating finite-state machine [7] is a finite set of processes that exchange messages, each process being given as a finite LTS. Recall that a (finite) labeled transition system, LTS for short, is a quadruple where is a (finite) set of states, is a finite alphabet, is a set of transitions, and is an initial state. In the following definition, denotes the set of actions performed by .
A Communicating Finite-State Machine (CFM for short) is a tuple , where each is a finite LTS . States in are called local states. The size of is defined as .
The usual semantics of communication is peer-to-peer, with (at most one) fifo channel for each pair of distinct processes. In this paper we focus on the mailbox semantics. Here, every process has a receiving fifo queue in which every other process can enqueue messages. We define the semantics by an associated global transition system.
Let be a CFM. The global transition system associated with is the LTS with set of configurations consisting of global states (i.e., products of local states) and queue contents over the alphabet . Let if
-
and for , where is the process performing .
-
Send actions: if then and for .
-
Receive actions: if then and for .
The initial configuration is .
An execution of is a sequence with such that for every . The sequence is the label of the execution. The execution is initial if .
Remark 2.1.
Note that the queue content includes the identity of the sender. This is to exclude executions labelled by with . Without this addition such executions would be allowed in the mailbox semantics, which is clearly not intended.
Definition 2.2 (Trace).
A trace of a CFM is a sequence such that there exists an initial execution of labelled by . The set of all traces of is denoted by .
Definition 2.3 (Viable).
A sequence is called viable if for every :
-
for every prefix of , the number of receives of in is less or equal the number of sends to in ;
-
for every , if the -th receive of in has label then the -th send to in has label .
Definition 2.4 (Rendez-vous).
A sequence from is called a rendez-vous sequence if it is of the form . Note that every send action is matched in a rendez-vous sequence, and that such sequences are viable. We define as the set of traces in that are rendez-vous.
The classical happens-before relation [21], frequently used in reasoning about distributed systems, orders the actions of each process and every (matched) send action before its matching receive. Because of mailbox semantics, an additional order arise between sends to the same process. The happens-before relation together with the mailbox order naturally associates a partial order with every trace, known as message sequence chart:
Definition 2.5 (Message Sequence Chart).
An MSC over is an -labeled partially ordered set of events , with and the least partial order containing the relations , and , which are defined as:
-
1.
For every process , the set of events on is totally ordered by , and is the union of these total orders.
-
2.
is the set of matching send/receive event pairs. In particular, implies and for some and . Moreover, is a partial bijection between sends and receives such that every receive is paired with a (unique) send. A send is called matched if it is in the domain of , and unmatched otherwise.
-
3.
for every process , we order two sends with and if
-
either is matched and is unmatched,
-
or and .
We call the mailbox order.
-
For two events we write if neither nor holds. For a set of events we write and for the causal past and future of , respectively.
If is a viable sequence of actions, then we can associate an MSC with by setting with , , and the orders defined as expected:
-
if and are performed by the same process and .
-
if there exists and a process such that is the -th send to and is the -th receive of .
-
if and are both sends to the same process , is matched to some , and either is unmatched, or is matched to some with .
Remark 2.6.
By definition, for any viable sequence , the associated MSC is well-defined. For the converse, for every MSC , every (labelled) linearization of the partial order of is viable. Indeed, all receives of the same process are totally ordered by , and the corresponding sends are ordered in the same way because of the mailbox order. For example, the sequence shown in Figure 1 is viable, but is not.
The next definition introduces an equivalence relation on sequences of actions. Two viable sequences are equivalent up to commuting adjacent actions that are not ordered by being on the same process, being a matching send/receive pair, or being two sends to the same process that are not both unmatched.
Definition 2.7 (Equivalence ).
Two viable sequences are called equivalent if (up to isomorphism), and we write in this case.
In this paper, we define (as in [2, 10]) the observable behavior of a CFM as the set of projections on sends. We set . For a sequence , we denote by the projection of on . For any , we write .
Definition 2.8 (Send-synchronizability).
Let be a CFM. We say that is send-synchronizable if .
The send-synchronizability problem is the question whether a CFM is send-synchronizable.
3 Undecidability of Send-Synchronizability for Mailbox Systems
We show in this section that the send-synchronizability problem is undecidable. We rely in our undecidability proof on the following decision problem, which is a variant of the well-known Post correspondence problem.
| Pre-MPCP | |
|---|---|
| Input: | A finite sequence of pairs , with , where for some finite alphabet . |
| Output: | Yes if there exists a sequence of indices , with , such that , and for every . |
It is well-known that Pre-MPCP is undecidable [19]. The remainder of this section provides a reduction from Pre-MPCP to send-synchronizability.
Consider an instance of Pre-MPCP over a finite alphabet . We construct a CFM such that is a positive instance of Pre-MPCP if, and only if, is not send-synchronizable. The CFM comprises three processes, namely (the guesser), (the relayer), and (the verifier). So . The set of message contents is , where is disjoint from , and the messages , and denote three distinct symbols that are not in . We choose to introduce a copy of the alphabet in order to easily111In our global transition system , each message content stored in a buffer is decorated with the channel of the corresponding send action. So our construction would also work without the copy of , but we believe that this copy makes our construction easier to read. distinguish in the mailbox of the messages that were sent by from the messages that were sent by . The symbols and are used to mark the end of the sequences and guessed by . It is understood that are the words in that are obtained from by replacing each letter by . The message is sent by when the two guessed sequences are equal. The LTSes , and of the processes , and are defined in Figures 2, 3, and 4. To ease understanding, the resulting communication topology, along with the potential message contents in the channels, is depicted in Figure 5. In the description of the guesser process (see Figure 2), we use the shortcuts and to reduce clutter. Let us explain what we mean by these shortcuts. A transition , where , stands for the contiguous sequence of transitions where are intermediate states. The observant reader will notice that the LTSes and contain silent transitions (from the initial state to the states and ), which are not allowed in our definition of CFM. This is merely a notational convenience to reduce clutter in the figures. We may safely get rid of these silent transitions since send-synchronizability of a CFM is not sensitive to such transitions.
The behavior of the guesser process should be quite clear. It sends the two guessed sequences and then waits for a message from , which it relays to , signaling that the guessed sequences form a solution. The relayer process has two operating modes, a normal mode (right-hand side of Figure 3) and a dummy mode (left-hand side of Figure 3). In the normal mode, simply relays to every message that it receives from . For to process its mailbox properly (see below), the send actions and need to be interleaved in lock-step (but there may be executions in where this does not hold). The purpose of the dummy mode is to make send-synchronizable if is a negative instance of Pre-MPCP. Notice that there is no switch between modes. Analogously, the verifier process has a normal mode and a dummy mode (right-hand and left-hand sides of Figure 4, respectively). In the normal mode, checks that the contents of its mailbox is of the form . It then sends to if that is the case (otherwise it is blocked). The purpose of the dummy mode is the same as for . Observe that the message sent by to is relayed by to , and then relayed by back to , but never receives it.
We first show that if is a positive instance of Pre-MPCP, then is not send-synchronizable.
Lemma 3.1.
If is a positive instance of Pre-MPCP then there is an initial execution in leading to the configuration .
Proof sketch..
guesses a solution , and sends and to and , respectively. relays to with the appropriate delay so that the mailbox of is filled by and in lock-step. This is possible because our variant of PCP requires that for every . We end up with in the mailbox of . Then empties its mailbox by iterating the cycle on .
Corollary 3.2.
If is a positive instance of Pre-MPCP then there is a trace containing the action , hence, is not send-synchronizable.
Now we show that if is a negative instance of Pre-MPCP, then is send-synchronizable. Some additional notations are needed. For every process , we let denote the language recognized by the LTS viewed as a non-deterministic automaton with every state final, and we let denote the projection of a sequence on . We also define as the morphism given by .
Lemma 3.3.
If there is a trace in containing the action then is a positive instance of Pre-MPCP.
Lemma 3.4.
For every trace , if does not contain the action then for every process .
Proof sketch..
Either contains no send action to , or contains a single send action to , which is . In that case, this action is necessarily after and before . In both cases, we get that .
All sends to are from and all sends by are to . The word sent by to in is a prefix of a word in . The word sent by to in is a prefix of a word in , since does not contain the action . It follows that , by letting select the dummy mode.
The word sent to in is in , since does not contain the action . If contains no send action by , then , by letting select the dummy mode. Otherwise, contains a single send action by , which is . The definition of (together with the mailbox semantics) entails that the word sent to in is of the form . Moreover, the action is necessarily after . We derive that coincides with the sequence of actions by in , hence, .
Corollary 3.5.
If is a negative instance of Pre-MPCP then is send-synchronizable.
We then get the next theorem from Corollaries 3.2 and 3.5.
Theorem 3.6.
The send-synchronizability problem is undecidable.
4 Send-synchronizability and -schedulable Systems
In this section we show that we can decide send-synchronizability for a subclass of CFMs that we call -schedulable.222This decidable class of systems originates from [6] and it is the same as 1-synchronizable there. To better distinguish it from send-synchronizability we decided to rename it here into -schedulable. Comparison with other close notions can be found in Appendix A. We start by defining -schedulable systems and a commutation relation over send sequences. Then we show that if all traces of a -schedulable CFM respect a certain property (and we say the CFM is good in this case) then we can check if the CFM is send-synchronizable. Next we show that any -schedulable CFM that is not good, cannot be send-synchronizable. Finally we show that we can check if a -schedulable CFM is good.
Definition 4.1 (-scheduling and -schedulable).
A viable sequence is a -scheduling if every send action in is either directly followed by its receive or it is unmatched. We also say in that case that is -scheduled. A sequence is -schedulable if there exists such that is a -scheduling.
A CFM is -schedulable if every trace is -schedulable.
From [8] (see also [16]) we know that -schedulability is a decidable property (PSPACE-complete). To make the characterization formal, we need some notation first. Given a binary relation over some set , a -cycle is any sequence , with , such that , where . A viable sequence is not -schedulable if, and only if, contains a -cycle with at least two distinct sends [8]. For example, the sequence is not -schedulable, as witnessed by the cycle .
Throughout this section we will assume that the CFM is -schedulable. Our characterization of send-synchronizability will rely on partial commutations applied to the observable behaviors of rendez-vous traces.
Definition 4.2 (Commutations).
We define a commutation relation on the alphabet of sends as follows. Let and be two send actions. Then if , and .
If and then we write , and we consider the reflexive-transitive closure of this relation. We denote the commutative closure of a send sequence as . We define , for , as .
The example in Figure 6 gives a first intuition about the role of commutations for send-synchronizability. As seen there, if a CFM has an execution as depicted on the left, and is send-synchronizable, then it has to include also an execution as depicted on the right. This entails that if is an observable behavior, then so is .
Remark 4.3.
It is readily seen that one can check if a regular language satisfies . For this it is enough to check that entails , for all words and . Such a test can be done in Pspace, if is described by an automaton.
4.1 From -schedulings to arbitrary traces via commutations
In this subsection we start with a sufficient condition that ensures that the send projections of traces of can be obtained via commutations from the send projections of -schedulings of (see Proposition 4.5). The definitions that follow are used in Lemma 4.4, that states the relation between commutations and projections for a single trace.
Consider a viable sequence . We introduce two binary relations and over the set of events of , defined as follows:
-
if there exists such that is an unmatched send to , is a send from , and .
-
if there exists such that and are unmatched sends to , is before in , and .
We say that has a backward arc if there exists two events such that and occurs before in . Consider for example the trace in Figure 7(a) left: we have , so has a backward arc.
The objective of the relation is to enforce the order of unmatched sends to the same process. Given two viable sequences and , we write if and for every process , the order of unmatched sends to is the same in and . Notice that for every viable sequences such that , we have if, and only if, the binary relations and coincide.
Lemma 4.4.
Let be a -scheduling and suppose that has no backward arc. Then .
Proof.
We write .
We first show recursively on the number of commutation steps. Initially . Now we take , and let with , and . Let be the sequence of sends obtained by commuting and . As , there is some such that . We suppose w.l.o.g. that : if there were receives between and , each one could either swap with to the left, or with to the right, since cannot be on the same process, and the sequence obtained would be equivalent to . As we know that they are not on the same process, and they do not send to the same process, so and , hence .
Now we show that by induction on the size of . Initially, . Let be a -scheduling without arc. Consider some such that , with . We have and . We know that so . The case where is dealt with similarly.
By induction, , so . Now, we know that is concurrent with every event of . Moreover, there is no arc. So for every occurring in : if , then is not on , and it is neither a send to (matched or not) nor to (matched or not), so , and .
A viable sequence is called good if there exists a -scheduled sequence such that and has no backward arc. Otherwise is called bad. Note that every good viable sequence is necessarily -schedulable. A CFM is good if every trace in is good, and is called bad otherwise.
Proposition 4.5.
For every good CFM , it holds that is the closure under of .
Proof.
Let and be defined as and , where
Note that . We first show that . Consider a trace . As is good, there exists a trace such that , is a -scheduling and has no backward arc. It holds that according to Lemma 4.4. As and , we get that . The converse inclusion immediately follows from Lemma 4.4. Since and , we derive that , hence, .
The above proposition provides our first ingredient to decide the send-synchronizability problem for -schedulable CFMs. Two additional ingredients are needed to complete our decidability proof. First, we will show that every bad CFM is not -schedulable or not send-synchronizable. Second, badness of a CFM will be shown to be decidable. We start with a characterization of bad viable sequences. For a viable sequence , a -cycle in is called trivial if it is of the form with , or equivalently, if it does not contain two distinct sends.
Lemma 4.6.
For every viable sequence , it holds that is bad if, and only if, there exists a -cycle in that is not trivial.
Proof sketch..
Consider a viable sequence . For short, let us write the condition that every -cycle in is trivial. To prove the lemma, we show that is good if, and only if, holds. We consider the directed graph whose nodes are the events of and whose edges are given by the relations , , , , and . Let denote the directed graph obtained from by, firstly, merging events that are connected by an -arc, and secondly, removing all -arcs. It is readily seen that is equivalent to the condition that is acyclic. If holds, then the partial order induced by admits a linearization . By “unmerging” events in , we get a linearization of such that is -scheduled and has no backward -arc nor backward -arc, hence, is good. Conversely, if is good then the sequence of nodes of that is induced by contains every node of and has no backward edge, so is acyclic, hence, holds.
We now focus our attention to CFMs that are -schedulable. For this class of CFMs, we obtain a characterization of badness of a CFM in terms of cycles that are simpler than those of Lemma 4.6 in the sense that they contain no -arc.
Lemma 4.7.
For every -schedulable CFM , if is bad then there exists a (bad) trace such that contains a -cycle.
Proof.
Consider a bad trace of minimal length. Let denote the set of non-trivial -cycles in . We lexicographically order cycles in first by number of -arcs (accounting for the arc from the last event of to the first event of ), second by length of the cycle. By Lemma 4.6, the set is non-empty. Pick a cycle in of minimal length, and let us show that contains no -arc.
We first observe that every event of is in , where denotes the set of events of . By contradiction, assume that this is not the case. There necessarily exists an event in such that , is maximal for and is a receive or an unmatched send. Consider the sequence corresponding to with removed. It is readily seen that is viable, hence, . Moreover, the cycle is still a non-trivial -cycle in . So by Lemma 4.6, is a bad trace in , which contradicts the minimality of .
By contradiction, assume that contains an -arc. Up to a rotation of the cycle, we may assume that is of the form with . Note that since is non-trivial. For readability, let us write and . We make three observations.
-
1.
The event is maximal for . By contradiction, suppose that for some event . Since , we get that for some . Pick a -path with and . We get that is in and has one less -arc than , which contradicts the minimality of .
-
2.
The event is a send and . Indeed, as is a receive, verifies or . If then , hence, is in , which contradicts the minimality of . So . It remains to show that is a send. Suppose by contradiction that is a receive. We either have or . In the first case, , hence, is in , which is impossible by minimality of . In the second case, , hence, . This entails that is in , which is impossible by minimality of .
-
3.
It holds that . Let us prove this claim. We have and . Note that since and are sends by distinct processes. If then would be a -cycle with at least two distinct sends in , which is impossible since is -schedulable. If then , hence, is in , which contradicts the minimality of .
We now derive a contradiction, which will conclude the proof that contains no -arc. Consider the sequence corresponding to with removed. We have since is a receive and is maximal for , by our first observation above. The event is the matching receive of in , so becomes an unmatched send in . In , the event is a send and is a send to the process performing , by our second observation above. Moreover, as in , by our third observation above, we still have in . It follows that in , hence, . We derive that is a non-trivial -cycle in . This entails, by Lemma 4.6, that is bad, which contradicts the minimality of .
Remark 4.8.
Given a viable sequence , a -cycle in is called genuine if are pairwise-distinct and, for every , we have implies and implies and . Informally, a genuine cycle is a simple cycle such that for every events on the cycle, if then the subpath of the cycle from to is a single -arc. It is routinely checked that if contains a -cycle then it contains a genuine -cycle.
4.2 Bad CFMs
Our goal in this section is to analyze bad, -schedulable CFMs. We will show a necessary condition for badness in terms of patterns (Proposition 4.10), and we will show that the presence of a pattern prevents a CFM to be send-synchronizable (Proposition 4.11).
We focus on -scheduled traces, as they can be effectively constructed from the CFM using automata. The binary relation needs to be relaxed as we might need to re-order unmatched sends of a -scheduling in in order to exhibit a bad -schedulable trace in . Given a viable sequence , we introduce the binary relation over the set of events of , defined by if there exists such that and are unmatched sends to and . Note that is symmetric and contains .
A pattern for a viable sequence is an alternating sequence of send events of satisfying, with the convention that , the following conditions:
-
1.
, for every ,
-
2.
or , for every ,
-
3.
for some ,
-
4.
and and , for every with .
Example 4.9.
Figure 7 shows two examples of patterns. In Figure 7(a) the sequence has the pattern , with , and .
The pattern in Figure 7(b) is , with , , and .
Proposition 4.10.
Let be -schedulable CFM. If is bad then there exists a trace that admits a pattern .
Proof.
By Lemmas 4.7 and 4.8, there exists a trace such that contains a genuine -cycle . Observe that necessarily contains a arc. The reason is that and are both contained in the total order over positions of , hence, there is no -cycle in . In order to transform into a pattern, we insert “identity” arcs of the form as needed to get an alternating sequence satisfying the first three conditions of the definition of patterns (recall that is contained in ). The fourth (and last) condition holds because is genuine.
.
.
Proposition 4.11.
Let be -schedulable. If some -scheduling contains a pattern, then is not send-synchronizable.
For the proof of Proposition 4.11 we first provide two technical lemmas. Recall that patterns are cycles. Proposition 4.11 will show a contradiction to send-synchronizability by listing the cycle in two ways. Lemma 4.12 identifies traces corresponding to different listings of the cycle in a such way that the part before the cycle is the same. Lemma 4.13 relates arcs of two equivalent traces with the same send-projection, one of which is rendez-vous.
Lemma 4.12.
Let contain some pattern . Let also . Then for every there exist with satisfying the following:
-
is a linearization of
-
is a linearization of
-
contains as subsequence.
Proof.
As in Lemma 4.7 we start with a prefix containing all events that are ordered causally before the events of the pattern: is a linearization of .
Consider some , . For readability we write for the infix of , for every .
Let also and . If would hold true then, using and , we would also get , contradicting the definition of pattern. By symmetry, we conclude that for all such .
Therefore, for we can define as linearization of . By definition, contains the subsequence .
Lemma 4.13.
Consider and with . Then for every send events in , with before in :
-
If in , then , where is the matching receive of in : .
-
If in , then in .
-
If in then in by the same causal path.
Proof.
If in , we know that is a send on some process and is an unmatched send to process . Because is a rendez-vous execution, with before , we get .
Now suppose that in . Then and are two unmatched sends to the same process. The two sends are matched in , with , where . Thus in because of .
Finally, if in , then holds also in because every arc of type on the causal path from to is preserved in .
Proof of Proposition 4.11.
We assume that is send-synchronizable, and consider some with pattern . We will assume that the pattern is minimal w.r.t. the following parameter: the size of the pattern is the sum of the lengths of the shortest paths from to , over all .
By Lemma 4.12 we can assume that is a linearization of , with , and occurs as subsequence of . In addition, is linearization of .
We know that is a pattern in , and we can assume w.l.o.g. that . Note that since (by definition of patterns) and (by definition of ). By Lemma 4.12, for every there exists some such that is a subsequence of . Chose for example .
As is send-synchronizable, there exist such that and . From Lemma 4.13, we get that there exists a -path from to in not going through , the receive matching . Indeed, for each , we have in , so we still have it in and it does not go through . We also have or in , for every . If then in . If , then in . In both cases the arcs do not use .
We inspect now . Let be the process of the send (recall that it is also the process of ), because ). Because of pattern minimality, we can show that the only send event on in is . Suppose that some is a send on process with in . By definition of , we have . But then the pattern would be smaller, contradiction. Again by minimality, we can show that the only send to in is . First there is no matched send to in , because such a send would satisfy as is an unmatched send to , hence, if with , then , which is forbidden by the definition of patterns. Now if we had some unmatched send event to , with say and , then the pattern would be smaller. Finally, if , so , then the predecessor of on the causal path from to is an event on , and we can shorten path from to , obtaining a smaller pattern.
Let us construct from by moving at the end of the sequence. Observe that and similarly , where is the morphism defined by . We derive from the previous paragraph that the sequence of actions by is in and in . As is the last receive by in , moving it at the end of the sequence preserves viability, so is viable. Moreover, the sequence of actions by in coincides with that of , and the sequence of actions by in coincides with that of . Since and , we get that .
However, note that now there is a -cycle with at least two distinct sends in . Indeed, we still have in the -path of from to , as this path does not go through , and in , finishing the cycle with . So is not -schedulable because it contains a non-trivial -cycle with at least two sends, which contradicts our assumption that is -schedulable.
4.3 Wrap-Up
In this section, we prove that send-synchronizability is decidable for -schedulable CFMs, by assembling the results from the previous subsections. We start with the following observation, which is an immediate consequence of Propositions 4.5, 4.10, and 4.11.
Proposition 4.14.
For every -schedulable CFM , it holds that is send-synchronizable if, and only if, (1) is good, (2) and (3) is closed under .
Proposition 4.15.
It is decidable to check if a -schedulable CFM is good.
Proof sketch..
Let be a -schedulable CFM. From Proposition 4.10, we know that is bad if there exists a trace with a pattern. The existence of a pattern can be checked on a -scheduling, as by construction two equivalent traces have the same patterns, and is -schedulable. Moreover the set of -scheduling of is regular.
We guess a bad -scheduling on-the-fly, together with the sends that form the pattern. We can assume that the pattern occurs in the order of the sequence. If there exists some bad trace in , then there is one with a pattern of size at most , as otherwise there would be at least three sends of the pattern on the same process, and we would have a shortcut.
Let be the pattern we read. We need to check that
-
for each , and with either or , and at least one -arc.
-
and for each with , and and .
To do so, we will keep for each send of the pattern the set of processes with actions causally ordered after , and we will update these sets while reading the bad -scheduling. So we need a memory of size .
From the two previous propositions, we get the following theorem.
Theorem 4.16.
The question whether a -schedulable CFM is send-synchronizable is Pspace-complete.
Proof.
Let be a -schedulable CFM. From Proposition 4.15, we know that we can check in polynomial space if is good. The two sets and are regular, so we can check in Pspace if they are equal. And from Remark 4.3, we know that we can check if is closed under in Pspace.
For Pspace-hardness, we reduce from the automata intersection problem as in [8], with a send that cannot be received if the intersection of the automata is not empty.
5 Conclusion
We showed that send-synchronizability for mailbox CFMs is undecidable, thus closing the question left open in [11, 9]. We also showed that we can decide in Pspace if a -schedulable CFM (which is a property that can be checked in Pspace) is send-synchronizable. We think that the techniques developed for the proof could be used to answer others problems for mailbox CFMs, like the realizability problem. Moreover, even if the class of -schedulable systems is decidable, it is quite restrictive. It can be interesting to see if our techniques can be used for -schedulable CFMs and the more general class of CFMs studied in [8].
References
- [1] Parosh Aziz Abdulla and Bengt Jonsson. Verifying programs with unreliable channels. Information and Computation, 127(2):91–101, 1996. doi:10.1006/INCO.1996.0053.
- [2] Samik Basu and Tevfik Bultan. Choreography conformance via synchronizability. In Sadagopan Srinivasan, Krithi Ramamritham, Arun Kumar, M. P. Ravindra, Elisa Bertino, and Ravi Kumar, editors, Proceedings of the 20th International Conference on World Wide Web, WWW 2011, Hyderabad, India, March 28 - April 1, 2011, pages 795–804. ACM, 2011. doi:10.1145/1963405.1963516.
- [3] Samik Basu and Tevfik Bultan. On deciding synchronizability for asynchronously communicating systems. Theoretical Computer Science, 656:60–75, 2016. doi:10.1016/J.TCS.2016.09.023.
- [4] Samik Basu, Tevfik Bultan, and Meriem Ouederni. Synchronizability for verification of asynchronously communicating systems. In Viktor Kuncak and Andrey Rybalchenko, editors, Verification, Model Checking, and Abstract Interpretation - 13th International Conference, VMCAI 2012, Philadelphia, PA, USA, January 22-24, 2012. Proceedings, volume 7148 of Lecture Notes in Computer Science, pages 56–71. Springer, 2012. doi:10.1007/978-3-642-27940-9_5.
- [5] Benedikt Bollig, Cinzia Di Giusto, Alain Finkel, Laetitia Laversa, Étienne Lozes, and Amrita Suresh. A unifying framework for deciding synchronizability. In 32nd International Conference on Concurrency Theory, CONCUR 2021, August 24-27, 2021, Virtual Conference, volume 203 of LIPIcs, pages 14:1–14:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPICS.CONCUR.2021.14.
- [6] Ahmed Bouajjani, Constantin Enea, Kailiang Ji, and Shaz Qadeer. On the completeness of verifying message passing programs under bounded asynchrony. In Computer Aided Verification - 30th International Conference, CAV 2018, Held as Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July 14-17, 2018, Proceedings, Part II, volume 10982 of Lecture Notes in Computer Science, pages 372–391. Springer, 2018. doi:10.1007/978-3-319-96142-2_23.
- [7] Daniel Brand and Pitro Zafiropulo. On communicating finite-state machines. Journal of the ACM, 30(2):323–342, 1983. doi:10.1145/322374.322380.
- [8] Romain Delpy, Anca Muscholl, and Grégoire Sutre. An automata-based approach for synchronizable mailbox communication. In 35th International Conference on Concurrency Theory, CONCUR 2024, September 9-13, 2024, Calgary, Canada, volume 311 of LIPIcs, pages 22:1–22:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPICS.CONCUR.2024.22.
- [9] Cinzia Di Giusto, Laetitia Laversa, and Kirstin Peters. Synchronisability in mailbox communication. In Proceedings Combined 31st International Workshop onTheoretical Computer Science Expressiveness in Concurrencyand 21st Workshop on Structural Operational Semantics, Calgary, Canada, 9th September 2024, volume 412 of Electronic Proceedings in Theoretical Computer Science, pages 19–34. Open Publishing Association, 2024. doi:10.4204/EPTCS.412.3.
- [10] Alain Finkel and Étienne Lozes. Synchronizability of communicating finite state machines is not decidable. In Ioannis Chatzigiannakis, Piotr Indyk, Fabian Kuhn, and Anca Muscholl, editors, 44th International Colloquium on Automata, Languages, and Programming, ICALP 2017, July 10-14, 2017, Warsaw, Poland, volume 80 of LIPIcs, pages 122:1–122:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2017. doi:10.4230/LIPICS.ICALP.2017.122.
- [11] Alain Finkel and Étienne Lozes. Synchronizability of communicating finite state machines is not decidable. Logical Methods in Computer Science, 19(4), 2023. doi:10.46298/LMCS-19(4:33)2023.
- [12] Alain Finkel and Philippe Schnoebelen. Well-structured transition systems everywhere! Theoretical Computer Science, 256(1-2):63–92, 2001. doi:10.1016/S0304-3975(00)00102-X.
- [13] Xiang Fu, Tevfik Bultan, and Jianwen Su. Synchronizability of conversations among web services. IEEE Transactions on Software Engineering, 31(12):1042–1055, 2005. doi:10.1109/TSE.2005.141.
- [14] Blaise Genest, Dietrich Kuske, and Anca Muscholl. On communicating automata with bounded channels. Fundamenta Informaticae, 80(1-3):147–167, 2007. URL: http://content.iospress.com/articles/fundamenta-informaticae/fi80-1-3-09.
- [15] Cinzia Di Giusto, Davide Ferré, Laetitia Laversa, and Étienne Lozes. A partial order view of message-passing communication models. Proceedings of the ACM on Programming Languages, 7(POPL):1601–1627, 2023. doi:10.1145/3571248.
- [16] Cinzia Di Giusto, Laetitia Laversa, and Étienne Lozes. On the k-synchronizability of systems. In Foundations of Software Science and Computation Structures - 23rd International Conference, FOSSACS 2020, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2020, Dublin, Ireland, April 25-30, 2020, Proceedings, volume 12077 of Lecture Notes in Computer Science, pages 157–176. Springer, 2020. doi:10.1007/978-3-030-45231-5_9.
- [17] Cinzia Di Giusto, Laetitia Laversa, and Étienne Lozes. Guessing the buffer bound for k-synchronizability. International Journal of Foundations of Computer Science, 34(8):1051–1076, 2023. doi:10.1142/S0129054122430018.
- [18] Jesper G. Henriksen, Madhavan Mukund, K. Narayan Kumar, Milind A. Sohoni, and P. S. Thiagarajan. A theory of regular MSC languages. Information and Computation, 202(1):1–38, 2005. doi:10.1016/J.IC.2004.08.004.
- [19] John E. Hopcroft and Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, 1979.
- [20] Dietrich Kuske and Anca Muscholl. Communicating automata. In Handbook of Automata Theory, pages 1147–1188. European Mathematical Society Publishing House, Zürich, Switzerland, 2021. doi:10.4171/AUTOMATA-2/9.
- [21] Leslie Lamport. Time, clocks, and the ordering of events in a distributed system. Communications of the ACM, 21(7):558–565, 1978. doi:10.1145/359545.359563.
- [22] Elaine Li, Felix Stutz, Thomas Wies, and Damien Zufferey. Complete multiparty session type projection with automata. In Computer Aided Verification - 35th International Conference, CAV 2023, Paris, France, July 17-22, 2023, Proceedings, Part III, volume 13966 of Lecture Notes in Computer Science, pages 350–373. Springer, 2023. doi:10.1007/978-3-031-37709-9_17.
- [23] Rupak Majumdar, Madhavan Mukund, Felix Stutz, and Damien Zufferey. Generalising projection in asynchronous multiparty session types. In 32nd International Conference on Concurrency Theory, CONCUR 2021, August 24-27, 2021, Virtual Conference, volume 203 of LIPIcs, pages 35:1–35:24. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPICS.CONCUR.2021.35.
- [24] Felix Stutz. Asynchronous multiparty session type implementability is decidable - lessons learned from message sequence charts. In 37th European Conference on Object-Oriented Programming, ECOOP 2023, July 17-21, 2023, Seattle, Washington, United States, volume 263 of LIPIcs, pages 32:1–32:31. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023. doi:10.4230/LIPICS.ECOOP.2023.32.
Appendix A -schedulability and related notions
Similar notions to -schedulability can be found in several papers [5, 17]. The way unmatched sends are treated in the literature may differ in a significant way. Our notion of -schedulable is the same as strongly -synchronisable in [5]. The notion of RSC in [15] is more restrictive than -schedulable, as it does not allow to permute two unmatched sends to the same process.
Take as an example the trace 0!2(a) 0!1(b) 2!1(c) 2?0(a). It is -schedulable since it is equivalent to 2!1(c) 0!2(a) 2?0(a) 0!1(b). But it is not RSC according to [15], since RSC disallows permuting 0!1(b), 2!1(c). Note however that every -scheduling is an RSC execution.
Appendix B A necessary and sufficient condition for send-synchronizability
Let be a CFM. Recall that is send-synchronizable if, and only if, for every trace , there exists a trace with . In fact, the trace is unique if it exists. Indeed, the only candidate for is . Recall that is the morphism defined by . Observe that for all . This leads us to the characterization of send-synchronizability in Lemma B.1 below. The following notations are used in this lemma. For every process , is the language of the LTS (viewed as a non-deterministic automaton with every state final) and is the projection of on .
Lemma B.1.
A CFM is send-synchronizable if, and only if, for every trace , the sequence satisfies for every process .
Proof.
Assume that is send-synchronizable. Let and define . Since is send-synchronizable, there exists such that . We have since . It follows that , hence, . This entails that for every process .
Conversely, let and assume that satisfies for every process . The sequence is clearly rendez-vous, according to the definition of . We derive that , since for every process . The observation that entails that , which concludes the proof.
Appendix C Proofs of Section 3
Lemma 3.1. [Restated, see original statement.]
If is a positive instance of Pre-MPCP then there is an initial execution in leading to the configuration .
Proof.
Consider a sequence of indices , with , such that , and for every . Let us write , with , the word (or, equivalently, the word ). Define and , for every . We also put . Our assumptions on entail, firstly, that , and, secondly, that , and , for all .
We show that for every , there is an execution in from the configuration , with and , to the configuration , with and . In the execution , the sequence of actions performed by is , the sequences of receive and send actions performed by are and , respectively, and does not move. These sequences of actions are permitted by the LTSes and (see Figures 2 and 3). To make it clear that such an execution exists, we need to show that these actions can be interleaved in a way that produces an viable sequence (that is, in addition, permitted by the LTS ). To reduce clutter, we define , where . Note that . Formally, the viable sequence labeling the execution is
This sequence is viable because the contents of ’s mailbox after verifies , hence, admits as prefix, since and . It is readily seen that the configuration obtained after verifies and .
We also observe that there is an execution in from the configuration , with , to the configuration . The trace of is the viable sequence . This sequence of actions is permitted by the LTS (see Figure 4).
By concatenating the executions , we get an execution from to . But this execution does not start from the initial configuration of . Along the execution , does , since . So could as well have started from its initial state. Obviously, the same goes for and , since they can move silently from their initial state to the state . Hence, there exists an execution from the initial configuration of to the configuration obtained after . The concatenation provides an initial execution leading to the configuration .
Corollary 3.2. [Restated, see original statement.]
If is a positive instance of Pre-MPCP then there is a trace containing the action , hence, is not send-synchronizable.
Proof.
Starting from the configuration , there is an execution in labelled by
If is a positive instance of Pre-MPCP then, according to Lemma 3.1 and the above observation, there is a trace ending with . Obviously, it holds that . But, as contains no transition, no trace in contains the action . Hence, , which entails that is not send-synchronizable.
Lemma 3.3. [Restated, see original statement.]
If there is a trace in containing the action then is a positive instance of Pre-MPCP.
Proof.
Consider an initial execution in ending with the action . By construction, also necessarily contains , hence, it also contains and , which entails that it contains . Therefore, in the execution , the processes and have each selected the normal mode, since there is no transition nor transition in the dummy modes. Let denote the prefix of that ends just before the action, and let denote the trace labelling . According to the definition of the LTSes , and (see Figures 2, 3, and 4), the projections , and are as follows:
for some with and , some with , some with , and some that is either or a receive action . The word received by is a prefix of a shuffle of the word sent by to and of the word sent by to . So is a prefix of and is a prefix of . Since does not occur in , we get that . Similarly, the word received by is a prefix of the word sent by to . We derive that is a prefix of . Since does not occur in , this entails that . We have shown that . It remains to prove that for all . Before that, we observe that every send action to is matched in . Indeed, the length of the word received by is , and the length of the word sent to is . This means that the sequence of send actions to in is .
We now show that for all . Let and consider a prefix of such that . The projection of on may be written as for some and some that is either or a receive action . The word received by is a prefix of the word sent by to , so . Now, the word sent to in , say , is a shuffle of the word sent by to and of the word sent by to . The word is also a prefix of the word sent to in . This entails that or . It follows that and we conclude that .
Lemma 3.4. [Restated, see original statement.]
For every trace , if does not contain the action then for every process .
Proof.
Let such that does not contain the action . We consider each process in separately. Recall that the LTSes , and of the processes , and are defined in Figures 2, 3, and 4.
Let us start with the guesser process. According to the definition of , there exists a sequence of indices , with and , such that the sequence of send actions performed by in is a prefix of , where . According to the definition of and , the sequence of send actions to in is either empty or the single action . Moreover, if contains then this action is necessarily after and before . This is due to the receive actions and . We derive that is a prefix of and conclude that .
We now proceed to the relayer process. According to the definition of and , the sequence of send actions to in is a prefix of a sequence of the form , with and . So the word sent to in is a prefix of . This entails that the sequence of send actions performed by in is in the language , according to the definition of . Indeed, either selects the normal mode, in which case the word sent by to is a prefix of the word (recall that does not contain the action by assumption), or selects the dummy mode, in which case the word sent by to is in the language . We derive that the projection of on sends by , or to , is in the shuffle of the language and the language . It follows that is in the shuffle of the language and the language . We conclude that , by letting select the dummy mode.
Let us finally address the verifier process. We consider two cases, depending on whether contains the action or not. If does not contain the action , then does not perform any send action in , according to the definition of . The projection of on sends to is in the language , according to the definition of and (recall that does not contain the action by assumption). It follows that is in the language . We conclude that , by letting select the dummy mode.
Assume now that contains the action . According to the definition of , this means that is equal to for some with . The mailbox semantics entails that the word sent to in admits as a prefix. When we dealt about the relayer process, we showed that the word sent by to is in the language . Moreover, according to the definition of , the word sent by to is in the language . So the word sent to in is exactly . We derive that the sequence of send actions to in is . Moreover, the single send action performed by , namely , is necessarily after . This is due to the receive action . It follows that is equal to , hence, . We conclude that .
Corollary 3.5. [Restated, see original statement.]
If is a negative instance of Pre-MPCP then is send-synchronizable.
Proof.
If is a negative instance of Pre-MPCP then we derive from Lemma 3.3 that no trace in contains the action . It follows from Lemma 3.4 that for every trace and every process . We conclude thanks to Lemma B.1 that is send-synchronizable.
