On the k-synchronizability of Systems

We study k-synchronizability: a system is k-synchronizable if any of its executions, up to reordering causally independent actions, can be divided into a succession of k-bounded interaction phases. We show two results (both for mailbox and peer-to-peer automata): first, the reachability problem is decidable for k-synchronizable systems; second, the membership problem (whether a given system is k-synchronizable) is decidable as well. Our proofs fix several important issues in previous attempts to prove these two results for mailbox automata.


Introduction
Asynchronous message-passing is ubiquitous in communication-centric systems; these include high-performance computing, distributed memory management, event-driven programming, or web services orchestration.One of the parameters that play an important role in these systems is whether the number of pending sent messages can be bounded in a predictable fashion, or whether the buffering capacity offered by the communication layer should be unlimited.Clearly, when considering implementation, testing, or verification, bounded asynchrony is preferred over unbounded asynchrony.Indeed, for bounded systems, reachability analysis and invariants inference can be solved by regular model-checking [5].Unfortunately and even if designing a new system in this setting is easier, this is not the case when considering that the buffering capacity is unbounded, or that the bound is not known a priori .Thus, a question that arises naturally is how can we bound the "behaviour" of a system so that it operates as one with unbounded buffers?In a recent work [4], Bouajjani et al. introduced the notion of k-synchronizable system of finite state machines communicating through mailboxes and showed that the reachability problem is decidable for such systems.Intuitively, a system is k-synchronizable if any of its executions, up to reordering causally independent actions, can be chopped into a succession of k-bounded interaction phases.Each of these phases starts with at most k send actions that are followed by at most k receptions.Notice that, a system may be k-synchronizable even if some of its executions require buffers of unbounded capacity.
As explained in the present paper, this result, although valid, is surprisingly non-trivial, mostly due to complications introduced by the mailbox semantics of communications.Some of these complications were missed by Bouajjani et al. and the algorithm for the reachability problem in [4] suffers from false positives.Another problem is the membership problem for the subclass of k-synchronizable systems: for a given k and a given system of communicating finite state machines, is this system k-synchronizable?The main result in [4] is that this problem is decidable.However, again, the proof of this result contains an important flaw at the very first step that breaks all subsequent developments; as a consequence, the algorithm given in [4] produces both false positives and false negatives.
In this work, we present a new proof of the decidability of the reachability problem together with a new proof of the decidability of the membership problem.Quite surprisingly, the reachability problem is more demanding in terms of causality analysis, whereas the membership problem, although rather intricate, builds on a simpler dependency analysis.We also extend both decidability results to the case of peer-to-peer communication.
Outline.Next section recalls the definition of communicating systems and related notions.In Section 3 we introduce k-synchronizability and we give a graphical characterisation of this property.This characterisation corrects Theorem 1 in [4] and highlights the flaw in the proof of the membership problem.Next, in Section 4, we establish the decidability of the reachability problem, which is the core of our contribution and departs considerably from [4].In Section 5, we show the decidability of the membership problem.Section 6 extends previous results to the peer-to-peer setting.Finally Section 7 concludes the paper discussing other related works.Proofs and some additional material are added in a separate Appendix.

Preliminaries
A communicating system is a set of finite state machines that exchange messages: automata have transitions labelled with either send or receive actions.The paper mainly considers as communication architecture, mailboxes: i.e., messages await to be received in FIFO buffers that store all messages sent to a same automaton, regardless of their senders.Section 6, instead, treats peer-to-peer systems, their introduction is therefore delayed to that point.
Let V be a finite set of messages and P a finite set of processes.A send action, denoted send(p, q, v), designates the sending of message v from process p to process q.Similarly a receive action rec(p, q, v) expresses that process q is receiving message v from p.We write a to denote a send or receive action.Let S = {send(p, q, v) | p, q ∈ P, v ∈ V} be the set of send actions and R = {rec(p, q, v) | p, q ∈ P, v ∈ V} the set of receive actions.S p and R p stand for the set of sends and receives of process p respectively.Each process is encoded by an automaton and by abuse of notation we say that a system is the parallel composition of processes.
Definition 1 (System).A system is a tuple S = (L p , δ p , l 0 p ) | p ∈ P where, for each process p, L p is a finite set of local control states, δ p ⊆ (L p × (S p ∪ R p ) × L p ) is the transition relation (also denoted l a − → p l ′ ) and l 0 p is the initial state.
Definition 2 (Configuration).Let S = (L p , δ p , l 0 p ) | p ∈ P , a configuration is a pair ( l, Buf) where l = (l p ) p∈P ∈ Π p∈P L p is a global control state of S (a local control state for each automaton), and Buf = (b p ) p∈P ∈ (V * ) P is a vector of buffers, each b p being a word over V.
We write l 0 to denote the vector of initial states of all processes p ∈ P, and Buf 0 stands for the vector of empty buffers.The semantics of a system is defined by the two rules below. [SEND] A send action adds a message in the buffer b of the receiver, and a receive action pops the message from this buffer.An execution e = a 1 • • • a n is a sequence of actions in S ∪ R such that ( l 0 , Buf 0 ) We write asEx(S) to denote the set of asynchronous executions of a system S.In a sequence of actions e = a 1 • • • a n , a send action a i = send(p, q, v) is matched by a reception a j = rec(p ′ , q ′ , v ′ ) (denoted by a i ⊢ ⊣ a j ) if i < j, p = p ′ , q = q ′ , v = v ′ , and there is ℓ ≥ 1 such that a i and a j are the ℓth actions of e with these properties respectively.A send action a i is unmatched if there is no matching reception in e.A message exchange of a sequence of actions e is a set either of the form v = {a i , a j } with a i ⊢ ⊣ a j or of the form v = {a i } with a i unmatched.For a message v i , we will note v i the corresponding message exchange.When v is either an unmatched send(p, q, v) or a pair of matched actions {send(p, q, v), rec(p, q, v)}, we write proc S (v) for p and proc R (v) for q.Note that proc R (v) is defined even if v is unmatched.Finally, we write procs(v) for {p} in the case of an unmatched send and {p, q} in the case of a matched send.
An execution imposes a total order on the actions.Here, we are interested in stressing the causal dependencies between messages.We thus make use of message sequence charts (MSCs) that only impose an order between matched pairs of actions and between the actions of a same process.Informally, an MSC will be depicted with vertical timelines (one for each process) where time goes from top to bottom, that carry some events (points) representing send and receive actions of this process (see Fig. 1).An arc is drawn between two matched events.We will also draw a dashed arc to depict an unmatched send event.An MSC is, thus, a partially ordered set of events, each corresponding to a send or receive action.

Definition 3 (MSC).
A message sequence chart is a tuple (Ev, λ, ≺), where -Ev is a finite set of events, -λ : Ev → S ∪ R tags each event with an action, -≺= (≺ po ∪ ≺ src ) + is the transitive closure of ≺ po and ≺ src where: • ≺ po is a partial order on Ev such that, for all process p, ≺ po induces a total order on the set of events of process p, i.e., on λ −1 (S p ∪ R p ) • ≺ src is a binary relation that relates each receive event to its preceding send event : * for all event r ∈ λ −1 (R), there is exactly one event s such that s ≺ src r * for all event s ∈ λ −1 (S), there is at most one event r such that s ≺ src r * for any two events s, r such that s ≺ src r, there are p, q, v such that λ(s) = send(p, q, v) and λ(r) = rec(p, q, v).
We identify MSCs up to graph isomorphism (i.e., we view an MSC as a labeled graph).For a given well-formed (i.e., each reception is matched) sequence of actions e = a 1 . . .a n , we let msc(e) be the MSC where Ev = [1.
.n], ≺ po is the set of pairs of indices (i, j) such that i < j and {a i , a j } ⊆ S p ∪ R p for some p ∈ P (i.e., a i and a j are actions of a same process), and ≺ src is the set of pairs of indices (i, j) such that a i ⊢ ⊣ a j .We say that e = a 1 . . .a n is a linearisation of msc(e), and we write asT r(S) to denote {msc(e) | e ∈ asEx(S)} the set of MSCs of system S.
Mailbox communication imposes a number of constraints on what and when messages can be read.The precise definition is given below, we now discuss some of the possible scenarios.For instance: if two messages are sent to a same process, they will be received in the same order as they have been sent.As another example, unmatched messages also impose some constraints: if a process p sends an unmatched message to r, it will not be able to send matched messages to r afterwards (Fig. 1a); or similarly, if a process p sends an unmatched message to r, any process q that receives subsequent messages from p will not be able to send matched messages to r afterwards (Fig. 1b).When an MSC satisfies the constraint imposed by mailbox communication, we say that it satisfies causal delivery.Notice that, by construction, all executions satisfy causal delivery.Definition 4 (Causal delivery).Let (Ev, λ, ≺) be an MSC.We say that it satisfies causal delivery if the MSC has a linearisation e = a 1 . . .a n such that for any two events i ≺ j such that a i = send(p, q, v) and a j = send(p ′ , q, v ′ ), either a j is unmatched, or there are i ′ , j ′ such that a i ⊢ ⊣ a i ′ , a j ⊢ ⊣ a j ′ , and i ′ ≺ j ′ .
Our definition enforces the following intuitive property.Proposition 1.An MSC msc satisfies causal delivery if and only if there is a system S and an execution e ∈ asEx(S) such that msc = msc(e).
We now recall from [4] the definition of conflict graph depicting the causal dependencies between message exchanges.Intuitively, we have a dependency whenever two messages have a process in common.For instance an SS −→ dependency between message exchanges v and v ′ expresses the fact that v ′ has been sent after v, by the same process.
Notice that each linearisation e of an MSC will have the same conflict graph.We can thus talk about an MSC and the associated conflict graph.(As an example cfr.Figs.1c and 1d.)

k-synchronizable systems
In this section, we define k-synchronizable systems.The main contribution of this part is a new characterisation of k-synchronizable executions that corrects the one given in [4].
In the rest of the paper, k denotes a given integer k ≥ 1.A k-exchange denotes a sequence of actions starting with at most k sends and followed by at most k receives matching some of the sends.An MSC is k-synchronous if there exists a linearisation that is breakable into a sequence of k-exchanges, such that a message sent during a k-exchange cannot be received during a subsequent one: either it is received during the same k-exchange, or it remains orphan forever.Definition 6 (k-synchronous).An MSC msc is k-synchronous if: 1. there exists a linearisation of msc e = e 1 • e 2 • • • e n where for all i ∈ [1..n], e i ∈ S ≤k • R ≤k , 2. msc satisfies causal delivery, 3. for all j, j ′ such that a j ⊢ ⊣ a j ′ holds in e, a j ⊢ ⊣ a j ′ holds in some e i .
An execution e is k-synchronizable if msc(e) is k-synchronous.
We write sT r k (S) to denote the set {msc(e) | e ∈ asEx(S) and msc(e) is k-synchronous}.
Example 1 (k-synchronous MSCs and k-synchronizable executions).1.There is no k such that the MSC in Fig. 2a is k-synchronous.All messages must be grouped in the same k-exchange, but it is not possible to schedule all the sends first, because the reception of v 1 happens before the sending of v 3 .Still, this MSC satisfies causal delivery.2. Let e 1 = send(r, q, v 3 )•send(q, p, v 2 )•send(p, q, v 1 )•rec(q, p, v 2 )•rec(r, q, v 3 ) be an execution.Its MSC, msc(e 1 ) depicted in Fig. 2b satisfies causal delivery.Notice that e 1 can not be divided in 1-exchanges.However, if we consider the alternative linearisation of msc(e 1 ): e 2 = send(p, q, v 1 ) • send(q, p, v 2 ) • rec(q, p, v 2 ) • send(r, q, v 3 ) • rec(r, q, v 3 ), we have that e 2 is breakable into 1exchanges in which each matched send is in a 1-exchange with its reception.Therefore, msc(e 1 ) is 1-synchronous and e 1 is 1-synchronizable.Remark that e 2 is not an execution and there exists no execution that can be divided into 1-exchanges.A k-synchronous MSC highlights dependencies between messages but does not impose an order for the execution.
Comparison with [4].In [4], the authors define the set sEx k (S) for a system S as the set of k-synchronous executions of the system in the k-synchronous semantics.Nonetheless as remarked in Example 1.2 not all executions of a system can be divided into k-exchanges even if they are k-synchronizable.Thus, in order not to lose any executions, we have decided to reason only on MSCs (called traces in [4]).
Following standard terminology, we say that a set U ⊆ V of vertices is a strongly connected component (SCC) of a given graph (V, →) if between any two vertices v, v ′ ∈ U , there exist two oriented paths v → * v ′ and v ′ → * v.The statement below fixes some issues with Theorem 1 in [4].

Theorem 1 (Graph-theoretic characterisation of k-synchronous MSCs).
Let msc be a causal delivery MSC.msc is k-synchronous iff every SCC in its conflict graph is of size at most k and if no RS edge occurs on any cyclic path.
Comparison with [4].Bouajjani et al. give a characterisation of k-synchronous executions similar to ours, but they use the word cycle instead of SCC, and the subsequent developments of the paper suggest that they intended to say Hamiltonian cycle (i.e., a cyclic path that does not go twice through the same vertex).It is not the case that a MSC is k-synchronous if and only if every Hamiltonian cycle in its conflict graph is of size at most k and if no RS edge occurs on any cyclic path.Indeed, consider again Example 2. This graph is not Hamiltonian, and the largest Hamiltonian cycle indeed is of size 4 only.But as we already discussed in Example 2, the corresponding MSC is not 4-synchronous.
As a consequence, the algorithm that is presented in [4] for deciding whether a system is k-synchronizable is not correct as well: the MSC of Fig. 2c would be considered 4-synchronous according to this algorithm, but it is not.

Decidability of reachability for k-synchronizable systems
We show that the reachability problem is decidable for k-synchronizable systems.
While proving this result, we have to face several non-trivial aspects of causal delivery that were missed in [4] and that require a completely new approach.
In other words, a system S is k-synchronizable if for every execution e of S, msc(e) may be divided into k-exchanges.
Remark 1.In particular, a system may be k-synchronizable even if some of its executions fill the buffers with more than k messages.For instance, the only linearisation of the 1-synchronous MSC Fig. 2b that is an execution of the system needs buffers of size 2.
For a k-synchronizable system, the reachability problem reduces to the reachability through a k-synchronizable execution.To show that k-synchronous reachability is decidable, we establish that the set of k-synchronous MSCs is regular.More precisely, we want to define a finite state automaton that accepts a sequence e 1 • e 2 • • • e n of k-exchanges if and only if they satisfy causal delivery.
We start by giving a graph-theoretic characterisation of causal delivery.For this, we define the extended edges v XY v ′ of a given conflict graph.The relation XY is defined in Fig. 3 with X, Y ∈ {S, R}.Intuitively, v XY v ′ expresses that event X of v must happen before event Y of v ′ due to either their order on the same machine (Rule 1), or the fact that a send happens before its matching receive (Rule 2), or due to the mailbox semantics (Rules 3 and 4), or because of a chain of such dependencies (Rule 5).We observe that in the extended conflict graph, obtained applying such rules, a cyclic dependency appears whenever causal delivery is not satisfied.
Fig. 3: Deduction rules for extended dependency edges of the conflict graph Example 3. Fig. 5a and 5b depict an MSC and its associated conflict graph with some extended edges.This MSC violates causal delivery and there is a cyclic Theorem 2 (Graph-theoretic characterisation of causal delivery).An MSC satisfies causal delivery iff there is no cyclic causal dependency of the form v SS v for some vertex v of its extended conflict graph.
Let us now come back to our initial problem: we want to recognise with finite memory the sequences e 1 , e 2 . . .e n of k-exchanges that composed give an MSC that satisfies causal delivery.We proceed by reading each k-exchange one by one in sequence.This entails that, at each step, we have only a partial view of the global conflict graph.Still, we want to determine whether the acyclicity condition of Theorem 2 is satisfied in the global conflict graph.The crucial observation is that only the edges generated by Rule 4 may "go back in time".This means that we have to remember enough information from the previously examined kexchanges to determine whether the current k-exchange contains a vertex v that shares an edge with some unmatched vertex v ′ seen in a previous k-exchange and whether this could participate in a cycle.This is achieved by computing two sets of processes C S,p and C R,p that collect the following information: a process q is in C S,p if it performs a send action causally after an unmatched send to p, or it is the sender of the unmatched send; a process q belongs to C R,p if it receives a message that was sent after some unmatched message directed to p.More precisely, we have: These sets abstract and carry from one k-exchange to another the necessary information to detect violations of causal delivery.We want to compute them in any local conflict graph of a k-exchange incrementally, i.e., knowing what they were at the end of the previous k-exchange, we want to compute them at the end of the current one.More precisely, let e CG(e) = (V, E) its conflict graph and B : P → (2 P × 2 P ) the function that associates to each p ∈ P the two sets B(p) = (C S,p , C R,p ).Then, the conflict graph CG(e, B) is the graph (V ′ , E ′ ) with V ′ = V ∪ {ψ p | p ∈ P} and E ′ ⊇ E as defined below.For each process p ∈ P, the "summary node" ψ p shall account for for some Buf for all p ∈ P B(p) = (CS,p, CR,p) and These extra edges summarise/abstract the connections to and from previous k-exchanges.Equation (1) considers connections  checking that for all p ∈ P, p ∈ C ′ R,p meaning that there is no cyclic dependency as stated in Theorem 2. The initial state is ( l 0 , B 0 ), where B 0 : P → (2 P × 2 P ) denotes the function such that B 0 (p) = (∅, ∅) for all p ∈ P.

Example 4 (An invalid execution)
. Let e = e 1 • e 2 with e 1 and e 2 the two 2-exchanges of this execution.such that e 1 = send(q, r, v 1 ) 5a and 5c show the MSC and corresponding conflict graph of each of the 2-exchanges.Note that two edges of the global graph (in blue) "go across" kexchanges.These edges do not belong to the local conflict graphs and are mimicked by the incoming and outgoing edges of summary nodes.The values of sets C S,r and C R,r at the beginning and at the end of the k-exchange are given on the right.All other sets C S,p and C R,p for p = r are empty, since there is only one unmatched message to process r.Notice how at the end of the second k-exchange, r ∈ C ′ R,r signalling that message v 4 violates causal delivery.
Comparison with [4].In [4] the authors define e,k = = ⇒ cd in a rather different way: they do not explicitly give a graph-theoretic characterisation of causal delivery; instead they compute, for every process p, the set B(p) of processes that either sent an unmatched message to p or received a message from a process in B(p).
They then make sure that any message sent to p by a process q ∈ B(p) is unmatched.According to that definition, the MSC of Fig. 5b would satisfy causal delivery and would be 1-synchronous.However, this is not the case (this MSC does not satisfy causal delivery) as we have shown in Example 3. Due to to the above errors, we had to propose a considerably different approach.The extended edges of the conflict graph, and the graph-theoretic characterisation of causal delivery as well as summary nodes, have no equivalent in [4].
Next lemma proves that Fig. 4 properly characterises causal delivery.
for some global state l ′ and some Note that there are only finitely many abstract configurations of the form ( l, B) with l a tuple of control states and B : P → (2 P × 2 P ).Moreover, since V is finite, the alphabet over the possible k-exchange for a given k is also finite.Therefore e,k = = ⇒ cd is a relation on a finite set, and the set sT r k (S) of k-synchronous MSCs of a system S forms a regular language.It follows that it is decidable whether a given abstract configuration of the form ( l, B) is reachable from the initial configuration following a k-synchronizable execution.
Theorem 3. Let S be a k-synchronizable system and l a global control state of S. The problem whether there exists e ∈ asEx(S) and Buf such that Remark 2. Deadlock-freedom, unspecified receptions, and absence of orphan messages are other properties that become decidable for a k-synchronizable system because of the regularity of the set of k-synchronous MSCs.

Decidability of k-synchronizability for mailbox systems
We establish, here, the decidability of k-synchronizability; our approach is similar to the one of Bouajjani et al. based on the notion of borderline violation, but we adjust it to adapt to the new characterisation of k-synchronizable executions (Theorem 1).

Definition 8 (Borderline violation).
A non k-synchronizable execution e is a borderline violation if e = e ′ • r, r is a reception and e ′ is k-synchronizable.Note that a system S that is not k-synchronizable always admits at least one borderline violation e ′ • r ∈ asEx(S) with r ∈ R: indeed, there is at least one execution e ∈ asEx(S) which contains a unique minimal prefix of the form e ′ • r that is not k-synchronizable; moreover since e ′ is k-synchronizable, r cannot be a k-exchange of just one send action, therefore it must be a receive action.In order to find such a borderline violation, Bouajjani et al. introduced an instrumented system S ′ that behaves like S, except that it contains an extra process π, and such that a non-deterministically chosen message that should have been sent from a process p to a process q may now be sent from p to π, and later forwarded by π to q.In S ′ , each process p has the possibility, instead of sending a message v to q, to deviate this message to π; if it does so, p continues its execution as if it really had sent it to q.Note also that the message sent to π get tagged with the original destination process q.Similarly, for each possible reception, a process has the possibility to receive a given message not from the initial sender but from π.The process π has an initial state from which it can receive any messages from the system.Each reception makes it go into a different state.From this state, it is able to send the message back to the original recipient.Once a message is forwarded, π reaches its final state and remains idle.The precise definition of the instrumented system can be found in Appendix B. The following example illustrates how the instrumented system works.

Example 5 (A deviated message).
Let e 1 , e 2 be two executions of a system S with MSCs respectively msc(e 1 ) and msc(e 2 ).e 1 is not 1synchronizable.It is borderline in S. If we delete the last reception, it becomes indeed 1-synchronizable.msc(e 2 ) is the MSC obtained from the instrumented system S ′ where the message v 1 is first deviated to π and then sent back to q from π.Note that msc(e 2 ) is 1-synchronous.In this case, the instrumented system S ′ in the 1-synchronous semantics "reveals" the existence of a borderline violation of S.
msc(e 1 ) p q For each execution e • r ∈ asEx(S) that ends with a reception, there exists an execution deviate(e • r) ∈ asEx(S ′ ) where the message exchange associated with the reception r has been deviated to π; formally, if e

Example 6 (A non-feasible execution).
Let e ′ be an execution such that msc(e ′ ) is as depicted on the right.Clearly, this MSC satisfies causal delivery and could be the execution of some instrumented system S ′ .However, the sequence e•r such that deviate(e•r) = e ′ does not satisfy causal delivery, therefore it cannot be an execution of the original system S.In other words, the execution e ′ is not feasible.
msc(e ′ ) p q π (q, v 1 ) Lemma 2. A system S is not k-synchronizable iff there is a k-synchronizable execution e ′ of S ′ that is feasible and bad.
As we have already noted, the set of k-synchronous MSCs of S ′ is regular.The decision procedure for k-synchronizability follows from the fact that the set of MSCs that have as linearisation a feasible bad execution as we will see, is regular as well, and that it can be recognised by an (effectively computable) non-deterministic finite state automaton.The decidability of k-synchronizability follows then from Lemma 2 and the decidability of the emptiness problem for non-deterministic finite state automata.
Recognition of feasible executions.We start with the automaton that recognises feasible executions; for this, we revisit the construction we just used for recognising sequences of k-exchanges that satisfy causal delivery.
In the remainder, we assume an execution e ′ ∈ asEx(S ′ ) that contains exactly one send of the form send(p, π, (q, v)) and one reception of the form rec(π, q, v), this reception being the last action of e ′ .Let (V, { XY −→} X,Y ∈{R,S} ) be the conflict graph of e ′ .There are two uniquely determined vertices υ start , υ stop ∈ V such that proc R (υ start ) = π and proc S (υ stop ) = π that correspond, respectively, to the first and last message exchanges of the deviation.The conflict graph of e • r is then obtained by merging these two nodes.

Lemma 3.
The execution e ′ is not feasible iff there is a vertex v in the conflict In order to decide whether an execution e ′ is feasible, we want to forbid that a send action send(p ′ , q, v ′ ) that happens causally after υ start is matched by a receive rec(p ′ , q, v ′ ) that happens causally before the reception υ stop .As a matter of fact, this boils down to deal with the deviated send action as an unmatched send.So we will consider sets of processes C π S and C π R similar to the ones used for e,k = = ⇒ cd , but with the goal of computing which actions happen causally after the send to π.We also introduce a summary node ψ start and the extra edges following the same principles as in the previous section.Formally, let B : P → (2 P × 2 P ), C π S , C π R ⊆ P and e ∈ S ≤k R ≤k be fixed, and let CG(e, B) = (V ′ , E ′ ) be the constraint graph with summary nodes for unmatched sent messages as defined in the previous section.The local constraint graph CG(e, B, C π S , C π R ) is defined as the graph (V ′′ , E ′′ ) where As before, we consider the "closure" XY of these edges by the rules of Fig. 3.

The transition relation e,k
= == ⇒ feas is defined in Fig. 6.It relates abstract configurations of the form ( l, B, C, dest π ) with C = (C S,π , C R,π ) and dest π ∈ P∪{⊥} storing to whom the message deviated to π was supposed to be delivered.Thus, the initial abstract configuration is (l 0 , B 0 , (∅, ∅), ⊥), where ⊥ means that the processus dest π has not been determined yet.It will be set as soon as the send to process π is encountered.
Lemma 4. Let e ′ be an execution of S ′ .Then e ′ is a k-synchronizable feasible execution iff there are , and a tuple of control states l ′ such that msc(e ′ ) = msc(e ′′ ), π ∈ C R,q (with B ′ (q) = (C S,q , C R,q )), and Fig. 6: Definition of the relation Comparison with [4].In [4] the authors verify that an execution is feasible with a monitor which reviews the actions of the execution and adds processes that no longer are allowed to send a message to the receiver of π.Unfortunately, we have here a similar problem that the one mentioned in the previous comparison paragraph.According to their monitor, the following execution e ′ = deviate(e • r) (see its MSC in Fig. 8a in Appendix B) is feasible, i.e., is runnable in S ′ and e • r is runnable in S.
However, this execution is not feasible because there is a causal dependency between v 1 and v 3 .In [4] this execution would then be considered as feasible and therefore would belong to set sT r k (S ′ ).Yet there is no corresponding execution in asT r(S), the comparison and therefore the k-synchronizability, could be distorted and appear as a false negative.
Recognition of bad executions.Finally, we define a non-deterministic finite state automaton that recognizes MSCs of bad executions, i.e., feasible executions e ′ = deviate(e • r) such that e • r is not k-synchronizable.We come back to the "non-extended" conflict graph, without edges of the form Lemma 5.The feasible execution e ′ is bad iff one of the two holds In order to determine whether a given message exchange v of CG(e ′ ) should be counted as reachable (resp.co-reachable), we will compute at the entry and exit of every k-exchange of e ′ which processes are "reachable" or "co-reachable".

Example 7. (Reachable and co-reachable processes)
Consider the MSC on the right composed of five 1exchanges.While sending message (s, v 0 ) that corresponds to υ start , process r becomes "reachable": any subsequent message exchange that involves r corresponds to a vertex of the conflict graph that is reachable from υ start .While sending v 2 , process s becomes "reachable", because process r will be reachable when it will receive message v 2 .Similary, q becomes reachable after receiving v 3 because r was reachable when it sent v 3 , and p becomes reachable after receiving v 4 because q was rea-msc(e) p q r s π chable when it sent it.Co-reachability works similarly, but reasoning backwards on the timelines.For instance, process s stops being "co-reachable" while it receives v 0 , process r stops being co-reachable after it receives v 2 , and process p stops being co-reachable by sending v 1 .The only message that is sent by a process being both reachable and co-reachable at the instant of the sending is v 2 , therefore it is the only message that will be counted as contributing to the SCC.
More formally, let e be sequence of actions, CG(e) its conflict graph and  Comparison with [4].As for the notion of feasibility, to determine if an execution is bad, in [4] the authors use a monitor that builds a path between the send to process π and the send from π.In addition to the problems related to the wrong characterisation of k-synchronizability, this monitor not only can detect an RS edge when there should be none, but also it can miss them when they exist.In general, the problem arises because the path is constructed by considering only an endpoint at the time (see Example 8 in Appendix A for more explanations).
We can finally conclude that: Theorem 4. The k-synchronizability of a system S is decidable for k ≥ 1.

k-synchronizability for peer-to-peer systems
In this section, we will apply k-synchronizability to peer-to-peer systems.A peerto-peer system is a composition of communicating automata where each pair of machines exchange messages via two private FIFO buffers, one per direction of communication.Precise formal definitions, lemmata and theorems can be found in Appendix D.Here we only give a quick insight on what changes w.r.t. the mailbox setting.
Causal delivery reveals the order imposed by FIFO buffers.Definition 4 must then be adapted to account for peer-to-peer communication.For instance, two messages that are sent to a same process p by two different processes can be received by p in any order, regardless of any causal dependency between the two sends.Thus, checking causal delivery in peer-to-peer systems is easier than in the mailbox setting, as we do not have to carry information on causal dependencies.
Within a peer-to-peer architecture, MSCs and conflict graphs are defined as within a mailbox communication.Indeed, they represents dependencies over machines, i.e., the order in which the actions can be done on a given machine, and over the send and the reception of a same message, and they do not depend on the type of communication.The notion of k-exchange remains also unchanged.
Decidability of reachability for k-synchronizable peer-to-peer systems.
To establish the decidability of reachability for k-synchronizable peer-to-peer systems, we define a transition relation for a sequence of action e describing a k-exchange.As for mailbox systems, if a send action is unmatched in the current k-exchange, it will stay orphan forever.Moreover, after a process p sent an orphan message to a process q, p is forbidden to send any matched message to q.Nonetheless, as a consequence of the simpler definition of causal delivery, , we no longer need to work on the conflict graph.Summary nodes and extended edges are not needed and all the necessary information is in function B that solely contains all the forbidden senders for process p.
The characterisation of a k-synchronizable execution is the same as for mailbox systems as the type of communication is not relevant.We can thus conclude, as within mailbox communication, that reachability is decidable.
Theorem 5. Let S be a k-synchronizable system and l a global control state of S. The problem whether there exists e ∈ asEx(S) and Buf such that Decidability of k-synchronizability for peer-to-peer systems.As in mailbox system, the detection of a borderline execution determines whether a system is k-synchronizable.allowing to obtain feasible executions can be found in Fig. 11 in Appendix D. Differently from the mailbox setting, we need to save not only the recipient dest π but also the sender of the delayed message (information stored in variable exp π ).The transition rule then checks that there is no message that is violating causal delivery, i.e., there is no message sent by exp π to dest π after the deviation.Finally the recognition of bad execution, works in the same way as for mailbox systems.The characterisation of a bad execution and the definition of As for mailbox systems, we can, thus, conclude that for a given k, k-synchronizability is decidable.Theorem 6.The k-synchronizability of a system S is decidable for k ≥ 1.

Concluding remarks and related works
In this paper we have studied k-synchronizability for mailbox and peer-to-peer systems.We have corrected the reachability and decidability proofs given in [4].The flaws in [4] concern fundamental points and we had to propose a considerably different approach.The extended edges of the conflict graph, and the graph-theoretic characterisation of causal delivery as well as summary nodes, have no equivalent in [4].Transition relations = == ⇒ bad building on the graph-theoretic characterisations of causal delivery and k-synchronizability, depart considerably from the proposal in [4].
We conclude by commenting on some other related works.The idea of "communication layers" is present in the early works of Elrad and Francez [8] or Chou and Gafni [7].More recently, Chaouch-Saad et al. [6] verified some consensus algorithms using the Heard-Of Model that proceeds by "communication-closed rounds".The concept that an asynchronous system may have an "equivalent" synchronous counterpart has also been widely studied.Lipton's reduction [14] reschedules an execution so as to move the receive actions as close as possible from their corresponding send.Reduction recently received an increasing interest for verification purpose, e.g. by Kragl et al. [12], or Gleissenthal et al. [11].
Existentially bounded communication systems have been studied by Genest et al. [10,15]: a system is existentially k-bounded if any execution can be rescheduled in order to become k-bounded.This approach targets a broader class of systems than k-synchronizability, because it does not require that the execution can be chopped in communication-closed rounds.In the perspective of the current work, an interesting result is the decidability of existential k-boundedness for deadlock-free systems of communicating machines with peer-to-peer channels.Despite the more general definition, these older results are incomparable with the present ones, that deal with systems communicating with mailboxes, and not peer-to-peer channels.
Basu and Bultan studied a notion they also called synchronizability, but it differs from the notion studied in the present work; synchronizability and ksynchronizability define incomparable classes of communicating systems.The proofs of the decidability of synchronizability [3,2] were shown to have flaws by Finkel and Lozes [9].A question left open in their paper is whether synchronizability is decidable for mailbox communications, as originally claimed by Basu and Bultan.Akroun and Salaün defined also a property they called stability [1] and that shares many similarities with the synchronizability notion in [2].
Context-bounded model-checking is yet another approach for the automatic verification of concurrent systems.La Torre et al. studied systems of communicating machines extended with a calling stack, and showed that under some conditions on the interplay between stack actions and communications, contextbounded reachability was decidable [13].A context-switch is found in an execution each time two consecutive actions are performed by a different participant.Thus, while k-synchronizability limits the number of consecutive sendings, bounded context-switch analysis limits the number of times two consecutive actions are performed by two different processes.
As for future work, it would be interesting to explore how both contextboundedness and communication-closed rounds could be composed.Moreover refinements of the definition of k-synchronizability can also be considered.For instance, we conjecture that the current development can be greatly simplified if we forbid linearisation that do not correspond to actual executions.A Comparison with [4] (Examples and additional material) Let po and src be the partial orders on the set of actions obtained respectively from ≺ po and ≺ src by assuming that if i ≺ po j then λ(i) < λ(j) ∈ po and if i ≺ src j then λ(i) < λ(j) ∈ src.
Example 8. [Problems with the development in [4]] Fig. 8b depicts the MSC associated with a feasible execution feasible that does not contain label RS.The monitor in [4] considers the reception of v 2 followed by the send of v 3 .A label RS is thus wrongly detected.Fig. 8c, instead, depicts the MSC associated with an execution feasible but bad.With the monitor in [4], the action seen after the send of v 3 is the send of v 4 and so the existing label RS is ignored at the profit of a non existing label SS.
Other differences with [4].Our definition of causal delivery slightly differs from the one in [4].Indeed our Property 1 does not hold for the definition in [4].
The two examples below stress where the definition of causal delivery in [4] fails.Nonetheless here we have merely fixed a typo, as in the subsequent development in [4], causal delivery is used as intended by our definition.
Example 9. Let e 1 be a sequence of actions such that its msc(e 1 ) is the one depicted in Fig. 9a.According to the definition in [4], causal delivery is satisfied when pairs of message exchanges with identical receivers have sends that are causally related.Thus we have: -send(p, q, v 1 ) < send(p, r, v 2 ) < rec(p, r, v 2 ) < send(r, q, v 3 ) ∈ po ∪ src and rec(r, q, v 3 ) < rec(p, q, v 1 ) / ∈ po -send(r, s, v 4 ) < send(r, t, v 5 ) < rec(r, t, v 5 ) < send(t, s, v) ∈ po ∪ src and rec(t, s, v 6 ) < rec(r, s, v 4 ) / ∈ po This entails that msc(e 1 ) satisfies causal delivery.However, there is no execution corresponding to this MSC as it is impossible to find a linearisation of msc(e 1 ).In our Definition 4, instead, we add the requirement that a linearisation of msc(e 1 ) must exist.Thus msc(e 1 ) does not satisfy causal delivery.
Example 10.Let e 2 be a sequence of actions and msc(e 2 ) as depicted in Fig. 9b.As in the previous example, according to the definition in [4], msc(e 2 ) satisfies causal delivery, indeed we check only messages with identical receiver and whose sends are causally dependent: -send(p, q, v 3 ) < send(p, r, v 4 ) < rec(p, r, v 4 ) < send(r, q, v 5 ) ∈ po ∪ src and rec(r, q, v 5 ) < rec(p, q, v 3 ) / ∈ po However, it ignores the dependency between v 2 and v 3 .Indeed, the mailbox communication implies that if rec(t, q, v 2 ) < rec(p, q, v 3 ) with the same receiver then send(t, q, v 2 ) < send(p, q, v 3 ).With this additional constraint, it is impossible to find a linearisation.We can deduce that the definition of causal delivery in [4] is not complete and should also consider the order imposed by the mailbox communication.In this case, a causally dependency would have been detected between v 1 and v 6 and we would have seen that the receptions do not happen in the correct order.

B Additional material
Definition 10 (Instrumented system S ′ ).Let S = ((L p , δ p , l 0 p ) | p ∈ P) be a system of communicating machines.The instrumented system S ′ associated to S is defined such that S ′ = (L p , δ ′ p , l 0 p ) | p ∈ P ∪ {π} where for all p ∈ P: Process π is the communicating automaton (L π , l 0 π , δ π ) where

C Proofs of Lemmata and Theorems
Proof of Theorem 1 Theorem 1 Let msc be a causal delivery MSC.msc is k-synchronous iff every SCC in its conflict graph is of size at most k and if no RS edge occurs on any cyclic path.
Proof.Let msc be a causal delivery MSC.=⇒ If msc is k-synchronous, then ∃e = e 1 • • • e n such that msc(e) = msc where each e i is a k-exchange.For every vertex v of the conflict graph CG(e) there is exactly one index ι(v) ∈ [1.
.n] such that v ⊆ e ι(v) .Now, observe that if there is an edge from v to v ′ in the conflict graph, some action of v must happen before some action of v ′ , i.e., ι(v) ≤ ι(v ′ ).So if v, v ′ are on a same SCC, ι(v) = ι(v ′ ), they must both occur within the same k-exchange.Since each k-exchange contains at most k message exchanges, this shows that all SCC are of size at most k.Observe also that if v RS −→ v ′ , then ι(v) < ι(v ′ ), since within a k-exchange all the sends precede all the receives.So an RS edge cannot occur on a cyclic path.
⇐= Let e be a linearisation of msc.Assume now that conflict graph CG(e) neither contains a SCC of size greater than k nor a cyclic path with an RS edge.Let V 1 , . . ., V n be the set of maximal SCCs of the conflict graph, listed in some topological order.For a fixed i, let e i = s 1 . . .s m r 1 . . .r m ′ be the enumeration of the actions of the message exchanges of V i defined by taking first all send actions of V i in the order in which they appear in e, and second all the receive actions of V i in the same order as in e.Let e ′ = e 1 . . .e n .Then CG(e ′ ) is the same as CG(e): indeed, the permutation of actions we defined could only postpone a receive after a send of a same SCC, therefore it could only replace some v RS −→ v ′ edge with an v ′ SR −→ v edge between two vertices v, v ′ of a same SCC, but we assumed that the SCCs do not contain RS edges, so it does not happen.Therefore e and e ′ have the same conflict graph, and msc(e ′ ) = msc(e).Moreover, also by hypothesis, |V i | ≤ k for all i, therefore each e i is a k-exchange, and finally msc is k-synchronous.

Proof of Theorem 2
Theorem 2 An MSC satisfies causal delivery iff there is no cyclic causal dependency of the form v SS v for some vertex v of the associated extended conflict graph.
Proof.⇒ Assume that msc satisfies causal delivery.Then there is a total order < < on the events that is a linearisation of ≺= (≺ po ∪ ≺ src ) + (cfr.Definition 3) with the property stated in Definition 4. We claim that if and {a j } = v ′ ∩ Y , then i < < j.The proof of this claim is by induction on the derivation tree of v XY v ′ : -case of Rule 1 : (i, j) ∈≺ po , so i < < j; -case of Rule 2 : (i, j) ∈≺ src , so i < < j; -cases of Rules 3 and 4 : by definition of causal delivery; -case of Rule 5 : there is Let a l be the Z action of v 3 .By inductive hypothesis, i < < l < < j, and by transitivity of < <, i < < j.
So we proved our claim, and < < extends XY .As a consequence, there is no ⇐ Assume that the extended dependency graph does not contain any SS cycle.
Let us first show that it does not contain any RR cycle either.By contradiction assume there is some v such that v RR v. Since there is no SS cycle, there is and we reach a contradiction, as and XY defines a partial order on actions.Let us pick some linearisation of that order, and let < < denote the associated order on indexes, i.e., < < is a total order such that for any X action a i ∈ v i and Y action a j ∈ v j , v i XY v j implies i < < j.
We want to show that < < satisfies the property of Definition 4. Let i < < j with a i , a j ∈ S and proc R (a i ) = proc R (a j ), and let v i , v j be the two vertices such that -Assume that v i SS v j .If v i is unmatched, then v j must be unmatched otherwise by Rule 4 we would have v j SS v i , which would violate the acyclicity hypothesis.On the other hand, if both v i and v j are matched, then v i RR −→ v j , otherwise we would have v j RR −→ v j and by Rule 3 v j SS v j , which would violate the acyclicity hypothesis.So there are i ′ , j ′ such that v i = {a i , a i ′ }, v j = {a j , a j ′ } and i ′ < < j ′ , as required by Definition 4.
-Assume that ¬(v i SS v j ) and ¬(v j SS v i ).Then both sends are unmatched (because of Rules 3 and 4), therefore the property of Definition 4 holds, concluding the proof.⊓ ⊔

Proof of Lemma 1
Lemma 1 An MSC msc is k-synchronous iff there is a linearisation e = e 1 • • • e n such that ( l 0 , B 0 ) ) for some global state l ′ and some B ′ : P → (2 P × 2 P ).
Proof.⇒ Since msc is k-synchronous then ∃e = e 1 • • • e n such that e is a linearisation of msc.The proof proceeds by induction on n.
Base case If n = 1 then e = e 1 .Thus there is only one k-exchange and the local conflict graph CG(e, B ′ ) is the same as the complete global one CG(e).By hypothesis, as msc satisfies causal delivery we have that for some Buf, ( l 0 , B 0 ) e = ⇒ ( l ′ , B ′ ).By contradiction, suppose that ∃p ∈ P such that p ∈ C ′ R,p .Whence there exists v ′ matched, such that p = proc R (v ′ ) and v SS v ′ with v ∈ Unm p .By Rule 4 (Fig. 3), an edge v ′ SS v has been added to the extended conflict graph.Thus, there is a cycle SS from v to v and this violates Theorem 2, which is a contradiction.Inductive step If n > 1, by inductive hypothesis, we have with B = (C S,p , C R,p ) p∈P .Since receptions correspond to sends in the current k-exchange and all sends precede all receptions, we have ( By inductive hypothesis we have that By contradiction, suppose that there is a process p ∈ C ′ R,p .Then by construction there exist two nodes v and v ′ such that v SS v ′ , v ∈ Unm p , v ′ matched and proc R (v ′ ) = p.We can have the following situations: 1. v ∈ V , then both message exchanges v and v ′ with v unmatched and v ′ matched are in the current k-exchange then we can easily reach a contradiction and the proof proceeds as in the base case.2. v = ψ p , then by inductive hypothesis there exists a non-matched message v p ∈ V belonging to a previous k-exchange.We want to show that if this is the case we can reconstruct a cyclic path in the extended conflict graph, which is a contradiction.We assume that by inductive hypothesis CG(e) has been reconstructed from the local conflict graphs considering actions in e 1 . . .e n−1 .We now analyse the last k-exchange and describe to what each edge corresponds in CG(e) .There are four cases: Then in CG(e) there exists an unmatched message v q and this extra edge has been constructed from Equations 1, 2 or 3: q thus by inductive hypothesis there exists v ∈ V in CG(e) such that v q SS v and proc S (v) = proc R (v 1 ).
Whence there exists an edge v SR v 1 in CG(e).If the edge ψ q SS −→ v 1 has been added as proc S (v 1 ) ∈ C S,q then by inductive hypothesis there exists, in CG(e), a node v reachable with an edge SS from v q such that proc S (v) = proc S (v 1 ).Thus an edge v SS v 1 exists in CG(e).
If the edge ψ q SS −→ v 1 has been added as proc R (v 1 ) ∈ C R,q and v 1 is a matched send.Then by inductive hypothesis there exists, in CG(e), a node v reachable with an edge . Whence in CG(e) there exists an edge v If the edge ψ q SS −→ v 1 has been added as proc R (v 1 ) ∈ C R,q and v 1 is an unmatched send.Then by inductive hypothesis there exists, in CG(e), a node v reachable with an edge . Whence in CG(e), because of Rule (4) in Fig. 3 there exists an edge v SS v 1 .
If the edge ψ q SS −→ v 1 has been added as proc S (v 1 ) ∈ C R,q .Then by inductive hypothesis there exists, in CG(e), a node v reachable with an edge SS from v such that proc R (v) = proc S (v 1 ).Whence in CG(e), there exists an edge v

SS
−→ ψ q with v 1 ∈ V and v 1 matched, then we know proc R (v 1 ) = q and because of Rule (4) in Fig. 3 in CG(e) there exists an edge (d) ψ q SS −→ ψ r , thus r ∈ C R,q .This means that there exists a matched message v such that v q SS −→ v and proc R (v) = r.Thus, in CG(e), we can add, because of Rule (4) in Fig. 3, the edge v SS v r .
Then it follows that if there exists an edge ψ p SS v ′ it means that an edge v p SS v ′ exists in the global extended conflict graph and thus by applying Rule (4) in Fig. 3 we can reach a contradiction, as we have a cycle.
where each e i corresponds to a valid k-exchange.Suppose by contradiction that msc(e) violates causal delivery.By Theorem 2 then the global extended conflict graph must contain an edge v SS v.This means that there is an unmatched message v p to process p that is causally followed by a matched message v to the same process p.Since each e i is a valid k-exchange we know that such an edge cannot appear in any of the local conflict graphs.
Indeed, if such an edge existed then there should be an edge SS from v p or ψ p (if the two messages belong to two different k-exchanges) to v.But in this case we would have p ∈ C ′ R,P which is a contradiction.⊓ ⊔

Proof of Theorem 3
Theorem 3 Let S be a k-synchronizable system and l a global control state of S. The problem whether there exists e ∈ asEx(S) and Buf such that ( l 0 , Buf 0 ) e = ⇒ ( l, Buf) is decidable.
Proof.There are only finitely many abstract configurations of the form ( l, B) with l a tuple of control states and B : P → (2 P × 2 P ).Therefore is a relation on a finite set, and the set sT r k (S) of k-synchronous MSCs of a system S forms a regular language.It follows that, it is decidable whether a given abstract configuration of the form ( l, B) is reachable from the initial configuration following a k-synchronizable execution being a linearisation of an MSC contained in sT r k (S).

⊓ ⊔
Proof of Lemma 2 Lemma 2 A system S is not k-synchronizable iff there is a k-synchronizable execution e ′ of S ′ that is feasible and bad.
Proof.⇒ Let S be not k-synchronizable then there exists an execution that is not k-synchronizable which contains a unique minimal prefix of the form e • r with e k-synchronizable and r = rec(p, q, v) a receive action.Thus e is bad and there exists an e ′ = deviate(e • r) ∈ asEx(S ′ ).Since e is k-synchronizable, msc(e) is k-synchronous and there exists a linearisation e ′′ such that e ′′ = e 1 . . .e n and there exists a k-exchange e i containing the send action send(p, q, v).Now if we replace this action with send(p, π, (q, v)) and we add at the end of the same k-exchange the action rec(p, π, (q, v)).The execution in asEx(S ′ ) remains k-synchronizable.Finally if we add to e ′′ a new k-exchange with the actions send(π, q, v) and rec(π, q, v) the execution remains k-synchronizable, hence e ′ is feasible.
⇐ If there is a k-synchronizable execution e ′ of S ′ that is feasible and bad, then by construction e ′ = deviate(e • r) and e • r is not k-synchronizable.Whence S is not k-synchronizable and this concludes the proof.

Proof of Lemma 3 Lemma 3
The execution e ′ is not feasible iff there is a vertex v in the conflict graph of e ′ such that υ this means that a message sent after the deviated message is received before it: hence, it violates causal delivery.
⇒ Assume now e ′ not feasible this entails that e is k-synchronizable and e • r violates causal delivery.Whence there exists an unmatched message that becomes matched and because of Definition 4 there are i ′ , j ′ such that r = a i ′ a i ⊢ ⊣ a i ′ , a j ⊢ ⊣ a j ′ , and i ≺ j and j ′ ≺ i ′ .So the conflict graph CG(e • r) contains Because of the deviation node v d is split in nodes υ start and υ stop in CG(e ′ ), and therefore Lemma 4 Let e ′ an execution of S ′ .Then e ′ is a k-synchronizable feasible execution iff there are , and a tuple of control states l ′ such that msc(e ′ ) = msc(e ′′ ), π ∈ C R,q (with B ′ (q) = (C S,q , C R,q )), and Proof.Let us first state what are the properties of the variables B, C and dest π .Let e ′ a k-synchronizable execution of S ′ and e ′′ = e 1 • • • e n such that msc(e ′ ) = msc(e ′′ ) be fixed, and assume that there are B, C, dest π such that Notice that CG(e ′ ) = CG(e ′′ ).By induction on n, we want to establish that 1. dest π = q if and only if a message of the form (q, v) was sent to π in e ′ ; 2. there is at most one message sent to π in e ′ ; 3. let υ start denote the unique vertex in CG(e ′ ) (if it exists) such that proc R (υ start ) = π; for all X ∈ {S, R}, The first two points easily follow from the definition of -Let X ∈ {S, R} and p ∈ C π X ′ and let us show that there is some v such that p = proc X (v) and either We reason by case analysis on the reason why p ∈ C π X ′ , according to the definition of C π X ′ in Fig. 6.
• p ∈ C π X .Then by induction hypothesis there is v such that p = proc X (v), and ), and therefore also in CG(e 1 • • • e n ), or (v, X) = (υ start , S).
).We reason by case analysis on the construction of the edge By hypothesis, we also have either v so υ start SS v ′ , which closes the case as well.* v = ψ q for some q ∈ C π R .Since ψ q does not have outgoing edges of the form RS, ψ q SS v ′ .From q ∈ C π R , we get by induction hypothesis some node v 1 such that υ start SS v 1 and proc R (v 1 ) = q.As seen in the proof of Lemma 1, ψ q SS v ′ implies that there is a vertex v 2 from a previous k-exchange that is an unmatched send to q such that Since v 1 is a matched send to q and v 2 is an unmatched send to q, by rule 4 in Fig. 3 v 1 SS v 2 .All together, which closes this case.
• p = proc X (v), proc R (v) = π, and X = S. Then v = υ start , which closes this case.-Conversely, let us show that for all X ∈ {S, R} and v such that (the corner case to be proved, (v, X) = (υ start , S), is treated in the last item).Again, we reason by induction on the number n of k-exchanges.If n = 0, it is immediate as there are no such v, X.Let us assume that the property holds for all choices of v 1 , X 1 such that , and v ∩ X = ∅, and let us show that proc X (v) ∈ C π X ′ .We reason by case analysis on the occurrence in e n , or not, of both υ start and v. Then there are v 1 , v 2 , q such that * v 1 is in e n , and either by rule 4 of Fig. 3, i.e., v 1 is a matched send to q and v 2 is an unmatched send to q * either v 2 XS v in CG(e  CG(e n , B).From these two, we get ψ start SS ψ p in CG(e n , B, C).By definition of C π X , we therefore have C X,q ⊆ C π X .From the third item, we get proc • υ start and v in e C π R holds immediately by induction hypothesis.Otherwise, there are v 1 , v 2 , v 3 , v 4 , Y, Z, q such that From the first item, by induction hypothesis, we get proc Y (v 1 ) ∈ C π X .From the second item, we get proc Y (v 1 ) = proc Z (v 2 ), and from the definition of outgoing edges of ψ start , we get ψ start SZ −→ v 2 in CG(e n , B, C).
From the third item and the proof of Lemma 1, we get either v 2 ZS v 3 in CG(e n , B) or (v 2 , Z) = (v 3 , S).From the fourth item, we get v 3 SS ψ q in CG(e n , B).To sum up, we have ψ start SS −→ ψ q in CG(e n , B, C).By definition of C π X , we therefore have C X,q ⊆ C π X .From the fifth item, we get by the proof of Lemma 1 that proc X (v) ∈ C X,q , which ends this case.
-Finally, let us finish the proof of the converse implication, and show the remaining case, i.e., let us show that proc S (υ start ) ∈ C π S .This is immediate from the definition of We are done with proving that C It is now time to conclude with the proof of Lemma 4 itself.Let e ′ and e ′′ = e 1 • • • e n • send(π, q, v) • rec(π, q, v) with e 1 , • • • e n ∈ S ≤k R ≤k be fixed such that msc(e ′ ) = msc(e ′′ ).
⇐ Let us assume that e ′ is a k-synchronizable feasible execution of S ′ and let us show that ( l 0 , B 0 , (∅, ∅), ⊥)  and at least one of the two holds: either sawRS = True, or cnt = k + 2.

Base n=2
Notice that, for a feasible execution, there are at least two k-exchanges as the deviation cannot fit a single k-exchange: the send from process π to the original recipient must follow the reception of the deviated message, thus it has to belong to a subsequent k-exchange.Then e ′′ = e 1 • e 2 and we show ({π}, Q, False, 0) By Lemma 5, we have that either υ start −→ * RS −→−→ * υ stop , or the size of the set Post * (υ start ) ∩ Pre * (υ stop ) is greater or equal to k + 2.
If υ start −→ * RS −→−→ * υ stop , then since a label RS cannot exists in a local conflict graph, there exist two paths υ start −→ * v 1 in CG(e 1 ) and v 2 −→ * υ stop in CG(e 2 ), with proc R (v 1 ) = proc S (v 2 ).We have that v 2 ∈ Pre e2 (π) and lastisRec(proc S (v 2 )) is True, thus sawRS becomes True concluding this part of the proof.Now suppose that the size of the set Post * (υ start ) ∩ Pre * (υ stop ) is greater or equal to k + 2. We show that all nodes in Post * (υ start ) ∩ Pre * (υ stop ) have been counted either in the first or in the second k-exchange.Take v ∈ Post * (υ start ) ∩ Pre * (υ stop ) then there exists a path υ start −→ * v −→ * υ stop and v is an exchange that belongs either to the first or the second k-exchange.If v belongs to the first one then we can divide previous path in two parts such that ) and procs(v 1 ) ∪ procs(v 2 ) = {p} = ∅.From this it follows that process p ∈ Q ′ and thus v ∈ Pre e1 (Q ′ ).Moreover, v ∈ Post e1 (π) and therefore the node v is counted in the first k-exchange.Similarly, if v belongs to the second k-exchange, we can divide the path into two parts such that ) and procs(v 1 ) ∪ procs(v 2 ) = {p} = ∅.From this it follows that process p ∈ P ′ and thus v ∈ Post e2 (P ′ ).Moreover, v ∈ Pre e2 (π) and therefore the node v is counted in the second k-exchange.Thus all nodes in Post * (υ start )∩Pre * (υ stop ) are considered and if Post * (υ start )∩ Pre * (υ stop ) ≥ k + 2 so is variable cnt ′ , concluding this part of the proof.Inductive step It is an easy generalisation of what has been said in the previous part of the proof.By considering that by inductive hypothesis sets Post ei (P ) and Pre ei (Q) contains respectively all the processes that are reachable from the exchange to process π and are co-reachable from the exchange from process π.
1. We suppose that sawRS = True.If sawRS = True then ∃e i where sawRS = False and sawRS ′ = True.In this k-exchange, ∃p ∈ P such that p ∈ P , lastisRec(p) = True and ∃v such that proc S (v) = p and v ∈ Pre e ′ (Q ′ ).Since p ∈ P , then there is a path υ start −→ * RS −→ v in CG(e ′ ).On the other hand, since v ∈ Pre e ′ (Q ′ ) then v ∈ Pre * (υ stop ) and there is a path for some l ′ and Buf for all q ∈ P Bi+1(q) = Bi(q) ∪ {p | si = send(p, q, v) & si is unmatched} for all send action si ∈ e, si ⊢ ⊣ rj =⇒ proc(si) / ∈ Bi(proc(rj)) in a peer-to-peer system Definition 13 (Peer-to-peer causal delivery).Let msc = (Ev, λ, ≺) be an MSC.We say that msc satisfies causal delivery if there is a linearisation e = a 1 . . .a n such that for any two send events i ≺ j such that a i = send(p, q, v) and a j = send(p ′ , q ′ , v ′ ), p = p ′ and q = q ′ , either a j is unmatched, or there are i ′ , j ′ such that a i ⊢ ⊣ a i ′ , a j ⊢ ⊣ a j ′ , and i ′ ≺ j ′ .
Theorem 7. Let e be a sequence of actions such that msc(e) satisfies causal delivery.Then msc(e) is k-synchronous iff every SCC in its conflict graph is of size at most k and if no RS edge occurs on any cycle path.
Proof.Analogous to the proof of Theorem 1. ⊓ ⊔ Lemma 7.An MSC msc is k-synchronous iff there is a linearisation e = e 1 • • • e n such that ( l 0 , B 0 ) ( l ′ , B ′ ) for some global state l ′ and some B ′ : P → (2 P × 2 P ).
Proof.⇒ Since msc is k-synchronous then ∃e = e 1 • • • e n such that e is a linearisation of msc.The proof proceeds by induction on n.
Base case If n = 1 then e = e 1 .Thus there is only one k-exchange.By hypothesis, as msc satisfies causal delivery we have for some l and Buf, ( l, Buf 0 ) e = ⇒ ( l, Buf).By contradiction, suppose that ∃v = {s i , r i ′ } such that s i = send(p, q, v) and p ∈ B i (q).Then ∃v ′ = {s j } such that s j = send(p, q, v ′ ).Since e is a linearisation of msc and proc S (v) = proc S (v ′ ), then j ≺ po i.As proc R (v ′ ) = proc R (v) and v is matched while v ′ is not matched, msc does not satisfy causal delivery which is a contradiction.Inductive step If n > 1, by inductive hypothesis, we have Since all receptions match a corresponding send in the current k-exchange and all sends precede all receptions, we have ( l n−1 , Buf 0 ) e = ⇒ ( l n , Buf) for some Buf.

Inductive hypothesis entails that
By contradiction, we suppose that ∃v = {s i , r i ′ } such that s i = send(p, q, v) and p ∈ B i (q).Then there exists a message exchange v ′ in e such that v ′ = {s j }, s j = send(p, q, v ′ ).As v ′ in e, and as in the base case, j ≺ po i with v matched and v ′ unmatched, msc would not satisfy causal delivery which is a contradiction where each e i corresponds to a valid k-exchange.Let show that msc(e) is k-synchronous.
Suppose by contradiction that msc(e) is not k-synchronous.As e is a linearisation of msc(e) and is divisible into valid k-exchange, then msc(e) violates causal delivery.Then there exist s i = send(p, q, v), s j = send(p, q, v ′ ) such that i ≺ j and either: -there exist r i ′ = rec(p, q, v), r j ′ = rec(p, q, v ′ ) such that j ′ ≺ i ′ or, -s i is unmatched and s j is matched Moreover, we have that either s i , s j ∈ e l or s i ∈ e l and s j ∈ e m with l = m.We thus have four cases.
In the first case, s i and s ′ j are matched and belong to the same k-exchange e l .Then there is no valid execution such that ( l, Buf 0 ) e l = ⇒ ( l ′ , Buf) and e l does not describes a valid k-exchange.In the second case, s i and s j are matched but do not belong to the same k-exchange.This case cannot happen as j ′ ≺ i ′ entails that s i and s j must belong to the same k-exchange or the reception of message s i will be separated from its sending.In the third case, s i is unmatched and s j is matched, and they are in the same k-exchange.If s i is unmatched, then p ∈ B i+1 (q).Moreover as i ≺ j , p ∈ B j (q) thus concluding that e l is not a valid k-exchange.In the last case, s i ∈ e l is unmatched and s j ∈ e m is matched.Therefore, since function B is incremental, p ∈ B(q) at the beginning of e m .Then, p ∈ B j (q) and e m is not a valid k-exchange concluding the proof.
⊓ ⊔ Lemma 8.A system S is not k-synchronizable iff there is a k-synchronizable execution e ′ of S ′ that is feasible and bad.
Proof.Analogous to the proof of Lemma 2. ⊓ ⊔

Proof of Theorem 5
Theorem 5 Let S be a k-synchronizable system and l a global control state of S. The problem whether there exists e ∈ asEx(S) and Buf such that ( l 0 , Buf 0 ) e = ⇒ ( l, Buf) is decidable.is a relation on a finite set, and the set sT r k (S) of k-synchronous MSCs of a system S forms a regular language.It follows that, it is decidable whether a given abstract configuration of the form ( l, B) is reachable from the initial configuration following a k-synchronizable execution being a linearisation of an MSC contained in sT r k (S).⊓ ⊔ Lemma 9. Let e ′ be an execution of S ′ .Then e ′ is a k-synchronizable feasible execution iff there are e ′′ = e 1 • • • e n • send(π, q, v) • rec(π, q, v) with e 1 , . . ., e n ∈ S ≤k R ≤k such that msc(e ′ ) = msc(e ′′ ) , B ′ : P → 2 P , a tuple of control states l ′ and processes p and q such that ( l 0 , B 0 , ⊥, ⊥) Proof.⇒ Let e ′ be a k-synchronizable feasible execution of S ′ .We show that there exists e ′′ = e 1 • • • e n • send(π, q, v) • rec(π, q, v) with e 1 , . . ., e n ∈ S ≤k R ≤k , such that msc(e ′ ) = msc(e ′′ ) , B ′ : P → 2 P , a tuple of control states l ′ and processes p and q such that ( l 0 , B 0 , ⊥, ⊥) .Since e ′ is k-synchronizable, msc(e ′ ) is k-synchronous and it exists e ′′ such that msc(e ′′ ) = msc(e ′ ) and e ′′ = e 1 • • • e n where each e i is a valid k-exchange.
⇐ Take a sequence of actions e ′′ such that ( l 0 , B 0 , ⊥, ⊥) and e ′ an execution of S ′ such that msc(e ′′ ) = msc(e ′ ).By contradiction, suppose that e ′ is not feasible.Then e ′ = deviate(e • r) with e • r that is not an execution of S whence it does not satisfy causal delivery.If e • r does not satisfy causal delivery, but e ′ does then ∃v = {s i , r ′ i }, v ′ = {s j , r ′ j } such that s i = send(p, q, v), r i ′ = rec(p, q, v) and s j = send(p, q, v ′ ), r j ′ = rec(p, q, v ′ ) and in msc(e • r): i ≺ j and j ′ ≺ i ′ .In e ′ , there exists an action s l = send(p, π, (q, v)) such that in msc(e ′ ): l ≺ j.Also, the send from π being the last action and let rec(p, q, v ′ ) = r m then j ′ ≺ m.Then, there exist a kexchange after the deviation of message v where the exchange v ′ appears.Thus we have dest ′ π = ⊥, proc S (v ′ ) = p and proc R (v ′ ) = q.Moreover, if s l belongs to the k-exchange under analysis then l < j.This entails that transition Proof.Analogous to the proof of Lemma 6.

⊓ ⊔
Proof of Theorem 6 Theorem 6 The k-synchronizability of a system S is decidable for k ≥ 1.

Definition 5 (
Conflict graph).The conflict graph CG(e) of a sequence of actions e = a 1 • • • a n is the labeled graph (V, { XY −→} X,Y ∈{R,S} ) where V is the set of message exchanges of e, and for all X, Y ∈ {S, R}, for all

Fig. 2 :
Fig. 2: (a) the MSC of Example 1.1.(b) the MSC of Example 1.2.(c) the MSC of Example 2 and (d) its conflict graph.

Fig. 4 :
Fig. 4: Definition of the relation e,k = = ⇒ cd are due to two sends messages or, respectively, a send and a receive on the same process.Equations (2) and (3) considers connections RR −→ and RS −→ that are due to two received messages or, respectively, a receive and a subsequent send on the same process.Notice how the rules in Fig.3would then imply the existence of a connection SS , in particular Equation (3) abstract the existence of an edge SS built because of Rule 4. Equations in (4) abstract edges that would connect the current k-exchange to previous ones.As before those edges in the global conflict graph would correspond to extended edges added because of Rule 4 in Fig. 3. Once we have this enriched local view of the conflict graph, we take its extended version.Let XY denote the edges of the extended conflict graph as defined from rules in Fig. 3 taking into account the new vertices ψ p and their edges.Finally, let S be a system and e,k = = ⇒ cd be the transition relation given in Fig. 4 among abstract configurations of the form ( l, B). l is a global control state of S and B : P → 2 P × 2 P is the function defined above that associates to each process p a pair of sets of processes B(p) = (C S,p , C R,p ).Transition e,k = = ⇒ cd updates these sets with respect to the current k-exchange e. Causal delivery is verified by

Fig. 5 :
Fig. 5: (a) an MSC (b) its associated global conflict graph, (c) the conflict graphs of its k-exchanges

Lemma 6 .
, Q two sets of processes, Post e (P ) = Post * {v | procs(v) ∩ P = ∅} and Pre e (Q) = Pre * {v | procs(v) ∩ Q = ∅} are introduced to represent the local view through k-exchanges of Post * (υ start ) and Pre * (υ stop ).For instance, for e as in Example 7, we get Post e ({π}) = {(s, v 0 ), v 2 , v 3 , v 4 , v 0 } and Pre e ({π}) = {v 0 , v 2 , v 1 , (s, v 0 )}.In each k-exchange e i the size of the intersection between Post ei (P ) and Pre ei (Q) will give the local contribution of the current k-exchange to the calculation of the size of the global SCC.In the transition relation e,k= == ⇒ bad this value is stored in variable cnt.The last ingredient to consider is to recognise if an edge RS belongs to the SCC.To this aim, we use a function lastisRec : P → {True, False} that for each process stores the information whether the last action in the previous k-exchange was a reception or not.Then depending on the value of this variable and if a node is in the current SCC or not the value of sawRS is set accordingly.The transition relation e,k = == ⇒ bad defined in Fig.7deals with abstract configurations of the form (P, Q, cnt, sawRS, lastisRec ′ ) where P, Q ⊆ P, sawRS is a boolean value, and cnt is a counter bounded by k + 2. We denote by lastisRec 0 the function where all lastisRec(p) = False for all p ∈ P. Let e ′ be a feasible k-synchronizable execution of S ′ .Then e ′ is a bad execution iff there are e ′′ = e 1 • • • e n • send(π, q, v) • rec(π, q, v) with e 1 , . . ., e n ∈ S ≤k R ≤k and msc(e ′ ) = msc(e ′′ ), P ′ , Q ⊆ P, sawRS ∈ {True, False}, cnt ∈ {0, . . ., k + 2}, such that ({π}, Q, 0, False, lastisRec 0 ) , {π}, cnt, sawRS, lastisRec)

.
Let us focus on the last point.The case n = 1 is immediate.Let us assume that

1 RS−
and v unmatched.Again by induction hypothesis, we have v 1 such that υ start SS v → v.If v = v ′ , we have υ start SS v ′ , which closes the case.Otherwise, from v Y S v ′ and v unmatched we deduce v SS −→ v ′ ; finally we

•
υ start and v are in e n .Then from υ start SS v in CG(e 1 • • • e n ) and the proof of Lemma 1, we get that υ start SS v in CG(e n , B).By definition of C π S ′ (first line), it contains proc X (v) • υ start in e n and v in e 1 • • • e n−1 .

with both v 2
and v in e n , or (v 2 , Z) = (v, S) From the first item, by induction hypothesis, we get proc Y (v 1 ) ∈ C π X .From the second item, we get proc Y (v 1 ) = proc Z (v 2 ), and from the definition of outgoing edges of ψ start , we get ψ start SZ −→ v 2 in CG(e n , B, C). the third item and the proof of Lemma 1, we get either v 2 ZS v in CG(e n , B) or (v 2 , Z) = (v, S).All together, we get ψ start SS v in CG(e n , B, C).By definition of C π S ′ (first line), it contains proc X (v) .

(
for some B ′ , C ′ , dest π with π ∈ C R,destπ .By definition of e,k = == ⇒ feas , B ′ , C ′ and dest π are uniquely determined, and it is enough to prove that dest π ∈ C π R .Let us assume by absurd that dest π ∈ C π R .Then, by the property we just proved, there is v such that proc R (v) = dest π , v∩R = ∅, and υ start SS v in CG(e ′ 1 • • • e ′ n ).So we get υ start SS v RR −→ υ stop in CG(e ′ ), and by Lemma 3, e ′ should not be feasible: contradiction.Finally, π ∈ C R,π because e ′ , as an execution of S ′ , msc(e ′ ) satisfies causal delivery.⇒Let us assume that( l 0 , B 0 , (∅, ∅), ⊥) l ′ , B ′ , C ′ , dest π ).for some B ′ , C ′ , dest π with π ∈ C R,destπ , and let us show that e ′ is a ksynchronizable feasible execution of S ′ .From the definition of Fig. 10: Definition of transition e,k = = ⇒ cd
feas ( l ′ , B ′ , C ′ , q) and ({π}, Q, False, 0) , {π}, sawRS, cnt)for some l ′ , B ′ , C ′ , Q, P ′ with π ∈ C R,q .Since both relations the existence of such a sequence of actions is decidable.⊓ ⊔ • • • e n−1 ), or v 2 = v the first item, by the proof of Lemma 1, we get either υ start SS v 1 in CG(e n , B) or v = v 1 .From the second item, we get v 1 SS−→ ψ q in ′) is k-synchronous.Since the last two actions send(π, q, v) • rec(π, q, v) can be placed in a new k-exchange, and since they do not break causal delivery (because π ∈ C R,destπ ), e ′ is a k-synchronizable execution of S ′ .It remains to show that e ′ is feasible.Again, let us reason by contradiction and assume that e ′ is not feasible.By Lemma 3, there is v such that stop in CG(e ′ ).In other words, proc R (v) = dest π , v ∩ R = ∅, andυ start SS v in CG(e ′ ).So, by the property we just proved, dest π ∈ C π The feasible execution e ′ is bad iff one of the two holds 1. υ start −→ * RS −→−→ * υ stop , or 2. the size of the set Post * (υ start ) ∩ Pre * (υ stop ) is greater or equal to k + 2. Proof.Since msc(e ′ ) is k-synchronous and e ′ = deviate(e • r), msc(e) (without the last reception r) is k-synchronous.By Theorem 1, e ′ is bad if and only if CG(e • r) contains either a cyclic path with an RS edge, or a SCC with of size ≥ k + 1.This cyclic path (resp.SCC) must contain the vertex associated with the last receive r of e • r.In CG(e ′ ), this cyclic (resp.SCC) corresponds to a path from υ start to υ stop (resp.the set of vertices that are both reachable from υ start and co-reachable from υ stop ).Since the υ start and υ stop for the same node in the conflict graph of e • r, the size of the SCC is one less than the size of the set Post RR −→ υ * (υ start ) ∩ Pre * (υ stop ).⊓ ⊔ Proof of Lemma 6 Lemma 6 Let e ′ a feasible k-synchronizable execution of S ′ .Then e ′ is a bad execution iff there are e ′′ = e 1 • • • e n • send(π, q, v) • rec(π, q, v) with e 1 , . . ., e n ∈ S ≤k R ≤k and msc(e ′ ) = msc(e ′′ ), P ′ , Q ⊆ P, sawRS ∈ {True, False}, cnt ∈ {0, . . ., k + 2}, such that ({π}, Q, 0, False, lastisRec 0 ) bad . . .bad (P ′ , {π}, cnt, sawRS, lastisRec)