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

\stackMath

Towards Generalised Half-Duplex Systems111This work has been supported by the French government, through the EUR DS4H Investments in the Future project managed by the National Research Agency (ANR) with the reference number ANR-17-EURE- 0004.

Cinzia Di Giusto   Loïc Germerie Guizouarn   Etienne Lozes Université Nice Côte d’Azur
CNRS, I3S
Sophia Antipolis, France {cinzia.di-giusto,loic.germerie-guizouarn,etienne.lozes}@univ-cotedazur.fr
Abstract

FIFO automata are finite state machines communicating through FIFO queues. They can be used for instance to model distributed protocols. Due to the unboundedness of the FIFO queues, several verification problems are undecidable for these systems. In order to model-check such systems, one may look for decidable subclasses of FIFO systems. Binary half-duplex systems are systems of two FIFO automata exchanging over a half-duplex channel. They were studied by Cece and Finkel who established the decidability in polynomial time of several properties. These authors also identified some problems in generalising half-duplex systems to multi-party communications. We introduce greedy systems, as a candidate to generalise binary half-duplex systems. We show that greedy systems retain the same good properties as binary half-duplex systems, and that, in the setting of mailbox communications, greedy systems are quite closely related to a multiparty generalisation of half-duplex systems.

1 Introduction

FIFO automata, also known as asynchronous communicating automata (i.e., finite state automata that exchange messages via FIFO queues) are an interesting formalism for modeling distributed protocols. In their most general formulation, these automata are Turing powerful, and in order to be able to model check them it is necessary to reduce their expressiveness.

Binary half-duplex systems, introduced by Cece and Finkel [6], are systems with two participants and a bidirectional channel formed of two FIFO queues, such that communication happens only in one direction at a time. The stereotypical half-duplex device is the walkie-talkie (or the CB). In several applications, in particular when FIFO buffers are bounded and sends may be blocking, half-duplex communications are considered a good practice to avoid send-send deadlocks. Language support for enforcing this discipline of communication includes, for instance, binary session types [15, 16] or Sing# channel contracts [11, 21].

In [6], Cece and Finkel show that (1) whether a system is half-duplex is decidable in polynomial time, (2) the set of reachable configurations is regular, and (3) properties like progress and boundedness are decidable in polynomial time. Cece and Finkel also present two possible notions ‘multiparty half-duplex’ systems generalizing their class to systems of any number of machines for p2p communications (one FIFO queue per pair of machine).

The first generalisation involves assuming that at most one queue over all queues is non-empty at any time. This generalisation preserves decidability but is very restrictive. The second generalisation restricts the communications between each pair of participants to half-duplex communications, that is only one buffer per bidirectional channel can be used simultaneously. This generalisation however does not preserve decidability: the systems captured by this definition form a Turing powerful class. In fact, with just three machines it is possible to mimic the tape of a Turing machine.

It could be believed that these results end the discussion about multi-party half-duplex systems. In this work, we claim conversely that there is another natural and relevant notion of multi-party half-duplex communications that allows us to generalise the results of Cece and Finkel. We introduce greedy systems, which are systems for which all executions can be rescheduled in such a way that all receptions are immediately preceded by their corresponding send. This notion is quite natural, and closely related to other notions like synchronisability [4], 11-synchronous systems [5], or existentially 11-bounded system [13] (see Section 6 for a detailed discussion).

In this work, we establish the following results:

  1. 1.

    whether a system is greedy is decidable in polynomial time (when the number of processes is fixed);

  2. 2.

    for greedy systems, all regular safety properties, which includes reachability, absence of unspecified receptions, progress, and boundedness are decidable in polynomial time.

  3. 3.

    we generalize binary half-duplex systems to multiparty mailbox half-duplex systems and we show that (1) mailbox half-duplex systems are greedy, and (2) greedy systems without orphan messages, at least in the binary case, are half-duplex.

The first result follows from techniques developed by Bouajjani et al [5] for kk-synchronous systems. The main challenge here is that we address a more general model of communicating systems that encompasses both mailbox and p2p communications, but also allows any form of sharing of buffers among processes. The second result is based on an approach that, to the best of our knowledge, is new, although it borrows from some general principles from regular model-checking. The challenge is that, unlike for binary half-duplex systems, the reachability set of greedy systems is not regular, which complicates how automata-based techniques can be used to solve regular safety. The third contribution aims at answering, although incompletely, the question we would like to address with this work: what is a relevant notion of multi-party half-duplex systems?

Outline.

The paper is organised as follows: Section 2 introduces communicating automata and systems. Section 3 defines greedy systems and establishes the decidability of the greediness of a system. Section 4 discusses regular safety for greedy systems. Section 5 compares greedy systems and half-duplex systems, first in the binary setting, then in the multi-party setting, by introducing the notion of mailbox half-duplex systems. Finally, Section 6 concludes with some final remarks and discusses related works.

2 Preliminaries

For a finite set SS, SS^{*} denotes the set of finite words over SS, w_1w_2w_{\_}1\cdot w_{\_}2 denotes the concatenation of two words, |w||w| denotes the length of ww, and ϵ\epsilon denotes the empty word. We assume some familiarity with non-deterministic finite state automata, and we write (𝒜)\mathcal{L}(\mathcal{A}) for the language accepted by the automaton 𝒜\mathcal{A}. For two sets SS and II, we write 𝐛\mathbf{b} (in bold) for an element of SIS^{I}, and b_ib_{\_}i for the ii-th component of 𝐛\mathbf{b}, so that 𝐛=(b_i)_iI\mathbf{b}=(b_{\_}i)_{\_}{i\in I}.

A FIFO automaton is basically a finite state machine equipped with FIFO queues where transitions are labelled with either queuing or dequeuing actions. More precisely:

Definition 1 (FIFO automaton).

A FIFO automaton is a tuple222 Note that FIFO automata do not have accepting states, therefore they are not a special case of non-deterministic finite state automaton, and there is not such a thing as ”the language of a FIFO automaton”. 𝒜=(L,𝕍,I,𝖠𝖼𝗍,δ,l_0)\mathcal{A}=(L,\mathbb{V},I,\mathsf{Act},\delta,l_{\_}0) where (1) LL is a finite set of control states, (2) 𝕍\mathbb{V} is a finite set of messages, (3) II is a finite set of buffer identifiers, (4) 𝖠𝖼𝗍I×{!,?}×𝕍\mathsf{Act}\subseteq I\times\{!,?\}\times\mathbb{V} is a finite set of actions, (5) δL×𝖠𝖼𝗍×L\delta\subseteq L\times\mathsf{Act}\times L is the transition relation, and (6) l_0Ll_{\_}0\in L is the initial control state. The size |𝒜||\mathcal{A}| of 𝒜\mathcal{A} is |L|+|δ||L|+|\delta|.

Actions a=(i,,v)a=(i,{\dagger},v), for {!,?}{\dagger}\in\{!,?\} are also denoted by ivi{\dagger}v. Given a FIFO automaton 𝒜=(L,𝕍,I,δ,l_0)\mathcal{A}=(L,\mathbb{V},I,\delta,l_{\_}0), a configuration of 𝒜\mathcal{A} is a tuple γ=(l,𝐛)L×𝕍I\gamma=(l,\mathbf{b})\in L\times\mathbb{V}^{I}. The initial configuration is γ0=(l_0,𝐛)\gamma_{0}=(l_{\_}0,\mathbf{b}^{\emptyset}) where for all iIi\in I, bi=ϵb^{\emptyset}_{i}=\epsilon. A step is a tuple (γ,a,γ)(\gamma,a,\gamma^{\prime}) (often written γ𝒜𝑎γ\gamma\xrightarrow[\tiny\mathcal{A}]{a}\gamma^{\prime}) where γ=(l,𝐛)\gamma=(l,\mathbf{b}) and γ=(l,𝐛)\gamma^{\prime}=(l^{\prime},\mathbf{b}^{\prime}) are configurations and aa is an action, such that the following holds:

  • (l,a,l)δ(l,a,l^{\prime})\in\delta,

  • if a=i!va=i!v, then b_i=b_ivb^{\prime}_{\_}i=b_{\_}i\cdot v and b_j=b_jb_{\_}j^{\prime}=b_{\_}j for all jI{i}j\in I\setminus\{i\}.

  • if a=i?va=i?v, then b_i=vb_ib_{\_}i=v\cdot b_{\_}i^{\prime} and b_j=b_jb_{\_}j^{\prime}=b_{\_}j for all jI{i}j\in I\setminus\{i\}.

Next, we define systems of FIFO automata. We pick a very general definition, where each FIFO queue might be queued (resp. dequeued) by more than one automaton, and where an automaton might ‘send a message to itself’. Most of the theory can be done in this general setting without extra cost, but we merely have in mind either mailbox systems or p2p systems (defined below).

A FIFO system, later called simply a system, is a family 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} of FIFO automata such that all FIFO automata have disjoint sets of actions: for all pqp\neq q\in\mathbb{P}, 𝖠𝖼𝗍_p𝖠𝖼𝗍_q=\mathsf{Act}_{\_}p\cap\mathsf{Act}_{\_}q=\emptyset. Each pp\in\mathbb{P} is referred to as a process. The condition on the disjointness of the sets of actions helps to identify the process that is responsible for a given action: for an action aa, we write 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a)\mathsf{process}(a) to denote the unique pp (when it exists) such that a𝖠𝖼𝗍_pa\in\mathsf{Act}_{\_}p.

Let us now define mailbox and p2p systems. Informally, a p2p system is a system in which each pair of processes has a dedicated buffer for exchanging messages. Instead, for mailbox communication, each process receives messages from all other processes in a single buffer. Let us now formally define these notions. To this aim, it will be useful to identify what are the buffers an automaton queues in (resp. dequeues from). Hence, for a given FIFO automaton 𝒜_p=(L_p,𝕍_p,I_p,𝖠𝖼𝗍_p,δ_p,l_0,p)\mathcal{A}_{\_}p=(L_{\_}p,\mathbb{V}_{\_}p,I_{\_}p,\mathsf{Act}_{\_}p,\delta_{\_}p,l_{\_}{0,p}), and for {!,?}{\dagger}\in\{!,?\}, we write I_pI_{\_}p^{\dagger} for the set of buffer identifiers ii such that there exists v𝕍_pv\in\mathbb{V}_{\_}p such that iv𝖠𝖼𝗍_pi{\dagger}v\in\mathsf{Act}_{\_}p. A system 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} is p2p if for all pp\in\mathbb{P}, I_p2I_{\_}p\subseteq\mathbb{P}^{2}, I_!p={p}×({p})I^{!}_{\_}p=\{p\}\times(\mathbb{P}\setminus\{p\}), and I_?p=({p})×{p}I^{?}_{\_}p=(\mathbb{P}\setminus\{p\})\times\{p\}. A system 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} is a mailbox system if for all pp\in\mathbb{P}, I_pI_{\_}p\subseteq\mathbb{P}, I_p!={p}I_{\_}p^{!}=\mathbb{P}\setminus\{p\} and I_p?={p}I_{\_}p^{?}=\{p\}. Thus in a p2p system with nn processes, there are at most n(n1)n(n-1) buffers, and in a mailbox system with nn processes there are at most nn buffers. A binary system is a system 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} such that ={1,2}\mathbb{P}=\{1,2\} and for all pp\in\mathbb{P}, I_p!={3p}=I_3p?I_{\_}p^{!}=\{3-p\}=I_{\_}{3-p}^{?}; note that a binary system is both p2p and mailbox. We sometimes use a more handy notation for actions of a mailbox (resp. p2p) system: if 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(i!v)=p\mathsf{process}(i!v)=p and 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(i?v)=q\mathsf{process}(i?v)=q, we sometimes write !vpq!v^{\tiny p\to q} instead of i!vi!v and ?vpq?v^{\tiny p\to q} instead of i?vi?v.

ServerServer0112233ClientClient3302211DatabaseDatabase011s?reqs?reqc!resc!ress?ack_ss?ack_{\_}sd!log_sd!log_{\_}ss!reqs!reqc?resc?ress!ack_ss!ack_{\_}sd!log_cd!log_{\_}cc?ack_dc?ack_{\_}dd?log_sd?log_{\_}sd?log_cd?log_{\_}cc!ack_dc!ack_{\_}d
Figure 1: Client/Server/Database protocol
Example 1 (FIFO Automata).

Figure 1 shows a graphical representation of a FIFO system, borrowed from [3]. This system represents a protocol between a client, a server and a database logging requests from the client and the server. In this protocol, a client can log something on the database or send requests to the server, when those requests are satisfied the server logs them in a database. Each automaton is equipped with a buffer in which it receives messages from all other participants: this system is an example of a mailbox system. To improve readability of the graphical representation, we refer to the buffers with the initial of the automaton to which they are associated. For example, ss is the buffer into which the server can receive messages. This simple system will be used as a running example throughout the paper. ∎

The size |𝔖||\mathfrak{S}| of 𝔖\mathfrak{S} is the sum of the |𝒜_p||\mathcal{A}_{\_}p|. Note that |||\mathbb{P}| and |I||I| are independent from the size of 𝔖\mathfrak{S}. In particular, when we say that an algorithm is in polynomial time, we mean in time 𝒪(|𝔖|k)\mathcal{O}(|\mathfrak{S}|^{k}) for some kk that may depend on |||\mathbb{P}| and |I||I|.

The FIFO automaton 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)\mathsf{product}(\mathfrak{S}) associated with 𝔖\mathfrak{S} is the standard asynchronous product automaton: 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)=(Π_pL_p,_p𝕍_p,_pI_p,δ,𝐥_0)\mathsf{product}(\mathfrak{S})=(\Pi_{\_}{p\in\mathbb{P}}L_{\_}p,\bigcup_{\_}{p\in\mathbb{P}}\mathbb{V}_{\_}p,\bigcup_{\_}{p\in\mathbb{P}}I_{\_}p,\delta,\mathbf{l}_{\_}0) where 𝐥_0=(l_0,p)_p\mathbf{l}_{\_}0=(l_{\_}{0,p})_{\_}{p\in\mathbb{P}} and δ\delta is the set of triples (𝐥,a,𝐥)(\mathbf{l},a,\mathbf{l}^{\prime}) for which there exists pp\in\mathbb{P} such that (l_p,a,l_p)δ_p(l_{\_}p,a,l_{\_}p^{\prime})\in\delta_{\_}p and l_q=l_ql_{\_}q=l_{\_}q^{\prime} for all q{p}q\in\mathbb{P}\setminus\{p\}. We often identify 𝔖\mathfrak{S} and 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)\mathsf{product}(\mathfrak{S}) and write for instance 𝔖𝑎\xrightarrow[\tiny\mathfrak{S}]{a} instead of 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)𝑎\xrightarrow[\tiny\mathsf{product}(\mathfrak{S})]{a}. Similarly, we say that γ=(𝐥,𝐛)\gamma=(\mathbf{l},\mathbf{b}) is a configuration of 𝔖\mathfrak{S} while we mean that γ\gamma is a configuration of 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)\mathsf{product}(\mathfrak{S}). An execution e=a_1a_n𝖠𝖼𝗍e=a_{\_}1\cdots a_{\_}n\in\mathsf{Act}^{*} is a sequence of actions. As usual 𝑒\xRightarrow{e} stands for a_1a_n\xrightarrow{a_{\_}1}\cdots\xrightarrow{a_{\_}n}. We write 𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)\mathsf{executions(\mathfrak{S})} for {e𝖠𝖼𝗍γ_0𝔖𝑒γ for some γ}\{e\in\mathsf{Act}^{*}\mid\gamma_{\_}0\xRightarrow[\tiny\mathfrak{S}]{e}\gamma\mbox{ for some }\gamma\}.

Next, we introduce the definition of reachable configuration:

Definition 2 (Reachable configuration).

Let 𝔖\mathfrak{S} be a system. A configuration γ\gamma is reachable if there exists e𝖠𝖼𝗍e\in\mathsf{Act}^{*} such that γ_0𝔖𝑒γ\gamma_{\_}0\xRightarrow[\tiny\mathfrak{S}]{e}\gamma. The set of all reachable configurations of 𝔖\mathfrak{S} is denoted RS(𝔖)RS(\mathfrak{S}).

Given an execution e=a_1a_ne=a_{\_}1\cdots a_{\_}n, we say that {j,j}{1,,n}2\{j,j^{\prime}\}\subseteq\{1,\cdots,n\}^{2} is a matching pair if there exists a buffer identifier ii, a message vv and natural number kk such that (1) a_j=i!va_{\_}j=i!v, (2) a_j=i?va_{\_}{j^{\prime}}=i?v, (3) a_ja_{\_}j is the kk-th send action on ii in ee, and (4) a_ja_{\_}{j^{\prime}} is the kk-th receive action on ii in ee. A communication of ee is either a matching pair {j,j}\{j,j^{\prime}\}, or a singleton {j}\{j\} such that jj does not belong to any matching pair (such a communication is called unmatched). We write 𝖼𝗈𝗆(e)\mathsf{com}(e) to denote the set of communications of ee.

An execution imposes a total order on the actions. Sometimes, however, it is useful to visualise only the causal dependencies between actions. Message sequence charts [18] are usually used to this aim, as they only depict an order between matched pairs of actions and between actions of the same process. However, message sequence charts do not represent graphically the causal dependencies due to shared buffers, like the ones found in mailbox systems. Here we define action graphs that depict all causal dependencies. When considering p2p communications, action graphs and message sequence charts coincide. We say that two actions a_1,a_2a_{\_}1,a_{\_}2 commute if 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_1)𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_2)\mathsf{process}(a_{\_}1)\neq\mathsf{process}(a_{\_}2) and it is not the case that a_1a_{\_}1 and a_2a_{\_}2 are two actions of the same type on a same buffer: there is no {!,?}{\dagger}\in\{!,?\}, iIi\in I and v_1,v_2𝕍v_{\_}1,v_{\_}2\in\mathbb{V} such that a_1=iv_1a_{\_}1=i{\dagger}v_{\_}1 and a_2=iv_2a_{\_}2=i{\dagger}v_{\_}2.

Definition 3 (Action graph).

Given an execution e=a_1a_ne=a_{\_}1\cdots a_{\_}n, the action graph 𝖺𝗀𝗋𝖺𝗉𝗁(e)\mathsf{agraph}(e) is the vertex-labeled directed graph ({1,,n},_e,λ_e)(\{1,\ldots,n\},\prec_{\_}e,\lambda_{\_}e) where λ_e(j)=a_j\lambda_{\_}e(j)=a_{\_}j and j_ejj\prec_{\_}{e}j^{\prime} if (1) j<jj<j^{\prime} and (2) either a_j,a_ja_{\_}j,a_{\_}{j^{\prime}} do not commute, or {j,j}\{j,j^{\prime}\} is a matching pair.

When j_ejj\prec_{\_}{e}j^{\prime}, we say that a_ja_{\_}j happens before a_ja_{\_}{j^{\prime}}. Note that for an execution ee with e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})}, _e\prec_{\_}{e}^{*} is a partial order. Two executions e,ee,e^{\prime} are causally equivalent, denoted by e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}, if their action graphs are isomorphic. Said differently, e,ee,e^{\prime} are causally equivalent if they are two linearisations of a same happens before partial order. Note that if γ0𝔖𝑒γ\gamma_{0}\xRightarrow[\tiny\mathfrak{S}]{e}\gamma and e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}, then γ0𝔖eγ\gamma_{0}\xRightarrow[\tiny\mathfrak{S}]{e^{\prime}}\gamma.

ServerServerClientClientDatabaseDatabases!reqs!reqs?reqs?reqc!resc!resc?resc?ress?ack_ss?ack_{\_}ss!ack_ss!ack_{\_}sd!log_cd!log_{\_}cd?log_cd?log_{\_}cc!ack_dc!ack_{\_}dc?ack_dc?ack_{\_}dd!log_sd!log_{\_}sd?log_sd?log_{\_}ss!reqs!req
(a) The action graph 𝖺𝗀𝗋𝖺𝗉𝗁(e)\mathsf{agraph}(e)
req_{\ req_{\_}{\ }}res_{\ res_{\_}{\ }}ack_s{ack_{\_}s}log_c{log_{\_}c}log_s{log_{\_}s}ack_d{ack_{\_}d}req_2{req_{\_}2}
(b) The conflict graph 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e)
Figure 2: Causal dependencies of an execution of Client/Server/Database protocol

Another graphical tool that we will use to talk about equivalent executions is the conflict graph, which is intuitively obtained from the action graph by merging matching pairs of vertices.

Definition 4 (Conflict graph).

Given an execution e=a_1a_ne=a_{\_}1\cdots a_{\_}n, the conflict graph 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e) of the execution ee is the directed graph (𝖼𝗈𝗆(e),e)(\mathsf{com}(e),\rightarrow_{e}) where for all communications c_1,c_2𝖼𝗈𝗆(e)c_{\_}1,c_{\_}2\in\mathsf{com}(e), c_1ec_2c_{\_}1\rightarrow_{e}c_{\_}2 if there is j_1c_1j_{\_}1\in c_{\_}1 and j_2c_2j_{\_}2\in c_{\_}2 such that j_1_ej_2j_{\_}1\prec_{\_}{e}j_{\_}2.

Example 2 (Action and Conflict Graphs).

We go back to the system depicted in Figure 1. One of its executions is

e=s!reqs?reqc!resc?ress!ack_ss?ack_sd!log_cd!log_sd?log_cc!ack_dc?ack_ds!reqd?log_se=s!req\cdot s?req\cdot c!res\cdot c?res\cdot s!ack_{\_}s\cdot s?ack_{\_}s\cdot d!log_{\_}c\cdot d!log_{\_}s\cdot d?log_{\_}c\cdot c!ack_{\_}d\cdot c?ack_{\_}d\cdot s!req\cdot d?log_{\_}s

Figure 2(a) shows 𝖺𝗀𝗋𝖺𝗉𝗁(e)\mathsf{agraph}(e). Actions of the same process are represented vertically between the same dotted lines. As formally explained in Definition 3, an arc from an action aa and another aa^{\prime} means that aa happens before aa^{\prime}. To ease readability, the arcs that follow from transitivity are omitted. For example, in a given column, there should be an arc between every pair of actions.

Figure 2(b) shows 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e). To simplify the graph, instead of marking the matching pairs we simply identify them with the message exchanged. Message req_2req_{\_}2 represent the second send of reqreq in the execution above.

3 Greedy systems

In this section we introduce greedy systems. Those systems aim at mimicking rendez-vous or synchronous communications by checking whether each execution can be rescheduled to an equivalent one where all receptions immediately follow their corresponding send.

Definition 5 (Greedy system).

An execution ee is greedy if all matching pairs are of the form {j,j+1}\{j,j+1\}. A system 𝔖\mathfrak{S} is greedy if for all execution e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})}, there exists a greedy execution ee^{\prime} such that e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}.

Example 3.

The execution s!reqs?reqc!resc?ress!ack_sd!log_cd?log_cs!req\cdot s?req\cdot c!res\cdot c?res\cdot s!ack_{\_}s\cdot d!log_{\_}c\cdot d?log_{\_}c is greedy, but the execution s!reqs?reqc!resc?ress!ack_sd!log_cs?ack_ss!req\cdot s?req\cdot c!res\cdot c?res\cdot s!ack_{\_}s\cdot d!log_{\_}c\cdot s?ack_{\_}s is not greedy, although causally equivalent to a greedy execution. ∎

Example 4 (Greedy system).

The system in Figure 1 is greedy. Take for instance execution ee of the example 2. This execution is not greedy as messages log_clog_{\_}c, log_slog_{\_}s, and ack_dack_{\_}d are not received right after their send. Still since those action can commute and by observing that the conflict graph in Figure 2(b) does not present any cycle (see Lemma 6) below), there exists an equivalent greedy execution ee^{\prime}:

e=s!reqs?reqc!resc?ress!ack_ss?ack_sd!log_cd?log_cc!ack_dc?ack_ds!reqd!log_sd?log_s.e^{\prime}=s!req\cdot s?req\cdot c!res\cdot c?res\cdot s!ack_{\_}s\cdot s?ack_{\_}s\cdot d!log_{\_}c\cdot d?log_{\_}c\cdot c!ack_{\_}d\cdot c?ack_{\_}d\cdot s!req\cdot d!log_{\_}s\cdot d?log_{\_}s.

Example 5.

Consider a system with two processes pp and qq each sending a message to the other, and whose corresponding receptions only happen after the send (see Figure 3). Then the execution e=p!v_1q!v_2p?v_1q?v_2e=p!v_{\_}1\cdot q!v_{\_}2\cdot p?v_{\_}1\cdot q?v_{\_}2 is not causally equivalent to a greedy execution, therefore the whole system is not greedy. ∎

In the remainder of this section, we show that deciding whether a system is greedy is feasible in polynomial time. The proof is in three steps: first, we give a graphical characterisation of the executions that are causally equivalent to greedy executions; second, we show that the non-greediness of a system is revealed by the existence of ‘bad’ executions of a certain shape, called borderline executions. Finally, we show that the graphical characterisation can be exploited to show the regularity of the language of borderline violations, from which we get the decidability of greediness.

ppqqp!v_1p!v_{\_}1q?v_2q?v_{\_}2q!v_2q!v_{\_}2p?v_1p?v_{\_}1
(a) The action graph 𝖺𝗀𝗋𝖺𝗉𝗁(e)\mathsf{agraph}(e) of Example 5
v_1{v_{\_}1}v_2{v_{\_}2}
(b) The conflict graph 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e)
Figure 3: Visual representations of a non-greedy execution ee
Lemma 6.

ee is causally equivalent to a greedy execution if and only if 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e) is acyclic.

Proof.

The left to right implication follows from two observations: first, two causally equivalent executions have isomorphic conflict graphs (because they have isomorphic action graphs), and second, the conflict graph of a greedy execution is acyclic, because for a greedy execution c_1ec_2c_{\_}1\rightarrow_{e}c_{\_}2 induces minc_1<minc_2\min{c_{\_}1}<\min{c_{\_}2}. Conversely, let e=a_1a_ne=a_{\_}1\cdots a_{\_}n, and assume that 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e) is acyclic. Let c_1c_nc_{\_}1\ll\ldots\ll c_{\_}n be a topological order on 𝖼𝗈𝗆(e)\mathsf{com}(e), e=c_1c_ne^{\prime}=c_{\_}1\cdots c_{\_}n be the corresponding greedy execution, and σ\sigma be the permutation such that e=a_σ(1)a_σ(n)e^{\prime}=a_{\_}{\sigma(1)}\cdots a_{\_}{\sigma(n)}. The claim is that e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}. Let j,jj,j^{\prime} be two indices of ee, and let us show that j_ejj\prec_{\_}{e}j^{\prime} iff σ(j)_eσ(j)\sigma(j)\prec_{\_}{e^{\prime}}\sigma(j^{\prime}). First, {j,j}\{j,j^{\prime}\} is a matching pair of ee if and only if {σ(j),σ(j)}\{\sigma(j),\sigma(j^{\prime})\} is a matching pair of ee^{\prime}, which shows the equivalence in that case. Assume now that {j,j}\{j,j^{\prime}\} is not a matching pair of ee, and let c,cc,c^{\prime} be the communications of ee containing jj and jj^{\prime} respectively. Assume also that j_ejj\prec_{\_}ej^{\prime}, we show that σ(j)_eσ(j)\sigma(j)\prec_{\_}{e^{\prime}}\sigma(j^{\prime}) (the other implication, similar, is omitted). First, j_ejj\prec_{\_}ej^{\prime} implies cecc\rightarrow_{e}c^{\prime}, which entails σ(c)eσ(c)\sigma(c)\rightarrow_{e^{\prime}}\sigma(c^{\prime}) because ee and ee^{\prime} have the same conflict graph. Moreover, j_ejj\prec_{\_}ej^{\prime} implies that a_ja_{\_}{j} and a_ja_{\_}{j^{\prime}} do not commute, therefore either σ(j)_eσ(j)\sigma(j)\prec_{\_}{e^{\prime}}\sigma(j^{\prime}) or σ(j)_eσ(j)\sigma(j^{\prime})\prec_{\_}{e^{\prime}}\sigma(j). By contradiction let σ(j)_eσ(j)\sigma(j^{\prime})\prec_{\_}{e^{\prime}}\sigma(j); then σ(c)eσ(c)\sigma(c^{\prime})\rightarrow_{e^{\prime}}\sigma(c), contradicting the acyclicity of the conflict graph of ee^{\prime}, which ends the proof. ∎

Definition 7 (Borderline violations).

An execution e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})} is a borderline violation if (1) ee is not causally equivalent to a greedy execution, (2) e=e_1i?ve=e_{\_}1\cdot i?v for some greedy execution e_1e_{\_}1 and receive action i?vi?v.

Example 6 (Borderline violation).

An example of a borderline violation for the system whose unique maximal execution is the one of Figure 3 is the execution

e=!v_2pq!v_1qp?v_1qp?v_2pq.e=!v_{\_}2^{\tiny p\to q}\cdot!v_{\_}1^{\tiny q\to p}\cdot?v_{\_}1^{\tiny q\to p}\cdot?v_{\_}2^{\tiny p\to q}.

Figure 3 shows its action and conflict graph. The action graph makes it easy to see that any execution ee^{\prime} equivalent to ee will require both the send actions to be done before the first reception, therefore at least one reception will not follow its matching send action. ∎

Lemma 8.

𝔖\mathfrak{S} is greedy if and only if 𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)\mathsf{executions(\mathfrak{S})} contains no borderline violation.

Proof.

Obviously, if 𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)\mathsf{executions(\mathfrak{S})} contains a borderline violation, 𝔖\mathfrak{S} is not greedy. Conversely, assume that 𝔖\mathfrak{S} is not greedy, and let us show that 𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)\mathsf{executions(\mathfrak{S})} contains a borderline violation. Let e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})} be an execution that is not causally equivalent to a greedy execution and of minimal length among all such executions. Then e=e_1ae=e_{\_}1\cdot a with e_1e_{\_}1 causally equivalent to a greedy execution. Let e_1e_{\_}1^{\prime} be a greedy execution causally equivalent to e_1e_{\_}1. Then e=e_1a𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e^{\prime}=e_{\_}1^{\prime}\cdot a\in\mathsf{executions(\mathfrak{S})}. Moreover, if aa is a send action, then ee^{\prime} is greedy, contradicting the fact that ee is not causally equivalent to a greedy execution. Therefore, ee^{\prime} is a borderline violation. ∎

Let Σ=I×{!,!?}×𝕍\Sigma=I\times\{!,!?\}\times\mathbb{V} denote the set of communications, and let Σ_?=I×{?}×𝕍\Sigma_{\_}{?}=I\times\{?\}\times\mathbb{V} be the set of receive actions. Then a greedy execution can be represented by a word in Σ\Sigma^{*} and a borderline violation is represented by a word in ΣΣ_?\Sigma^{*}\cdot\Sigma_{\_}{?}. So now, we define two non-deterministic finite state automata over ΣΣ_?\Sigma\cup\Sigma_{\_}{?}: the first one accepts all greedy executions of a system, and the second one all borderline violations. We later explain how these automata are used to decide greediness.

Lemma 9.

Let 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} of size nn and 𝕍=_p𝕍_p\mathbb{V}=\bigcup_{\_}{p\in\mathbb{P}}\mathbb{V}_{\_}p, I=_pI_pI=\bigcup_{\_}{p\in\mathbb{P}}I_{\_}p be fixed. There is a non-deterministic finite state automaton 𝒜_gr\mathcal{A}_{\_}{gr} computable in time 𝒪(|𝕍||I|22|I|n||+2)\mathcal{O}(|\mathbb{V}||I|^{2}2^{|I|}n^{|\mathbb{P}|+2}) such that (𝒜_gr)={ei?vΣΣ_?ei?v𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖) and e is greedy}\mathcal{L}(\mathcal{A}_{\_}{gr})=\{e\cdot i?v\in\Sigma^{*}\cdot\Sigma_{\_}{?}\mid e\cdot i?v\in\mathsf{executions(\mathfrak{S})}\mbox{ and $e$ is greedy}\}.

Proof.

Let 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)=(L_𝔖,𝕍,I,𝖠𝖼𝗍,δ_𝔖,𝐥_0)\mathsf{product}(\mathfrak{S})=(L_{\_}{\mathfrak{S}},\mathbb{V},I,\mathsf{Act},\delta_{\_}{\mathfrak{S}},\mathbf{l}_{\_}0) and let 𝒜_gr=(L_gr,δ_gr,l_gr,0,F_gr)\mathcal{A}_{\_}{gr}=(L_{\_}{gr},\delta_{\_}{gr},l_{\_}{gr,0},F_{\_}{gr}) be the non-deterministic finite state automaton over Σ\Sigma with L_gr=L_𝔖×({ϵ}I×v)×2I{l_F}L_{\_}{gr}=L_{\_}{\mathfrak{S}}\times(\{\epsilon\}\cup I\times v)\times 2^{I}\cup\{l_{\_}{F}\}, l_gr,0=(𝐥_0,ϵ,)l_{\_}{gr,0}=(\mathbf{l}_{\_}0,\epsilon,\emptyset), F_gr={l_F}F_{\_}{gr}=\{l_{\_}F\}, and the transitions defined as follows. First, while reading a letter cΣc\in\Sigma, ((𝐥,x,S),c,(𝐥,x,S))δ_gr\big{(}(\mathbf{l},x,S),c,(\mathbf{l}^{\prime},x^{\prime},S^{\prime})\big{)}\in\delta_{\_}{gr} if

  • (𝐥,𝐛)𝔖𝑐(𝐥,𝐛)(\mathbf{l},\mathbf{b})\xRightarrow[\tiny\mathfrak{S}]{c}(\mathbf{l}^{\prime},\mathbf{b^{\prime}}) for some 𝐛,𝐛\mathbf{b},\mathbf{b^{\prime}} such that for all iIi\in I, b_ib_{\_}i\neq\emptyset iff iSi\in S, and b_ib_{\_}i^{\prime}\neq\emptyset iff iSi\in S^{\prime}, and

  • one of the two following holds

    • either x=xx=x^{\prime},

    • or x=ϵx=\epsilon and x=(i,v)x^{\prime}=(i,v) and c=i!vc=i!v and iSi\not\in S.

Second, while reading the letter i?vΣ_?i?v\in\Sigma_{\_}{?}, ((𝐥,x,S),i?v,l_F)δ_gr\big{(}(\mathbf{l},x,S),i?v,l_{\_}F\big{)}\in\delta_{\_}{gr} if x=(i,v)x=(i,v) and (𝐥,i?v,𝐥)δ_𝔖(\mathbf{l},i?v,\mathbf{l}^{\prime})\in\delta_{\_}{\mathfrak{S}} for some 𝐥L_𝔖\mathbf{l}^{\prime}\in L_{\_}{\mathfrak{S}}. Then (𝒜_gr)\mathcal{L}(\mathcal{A}_{\_}{gr}) is as announced. Moreover, each transition of 𝒜_gr\mathcal{A}_{\_}{gr} can be constructed in constant time, so 𝒜_gr\mathcal{A}_{\_}{gr} can be constructed in time as announced. ∎

Lemma 10.

There is a non-deterministic finite state automaton 𝒜_bv\mathcal{A}_{\_}{bv} computable in time 𝒪(|I|3|𝕍|3)\mathcal{O}(|I|^{3}|\mathbb{V}|^{3}) such that (𝒜_bv)={eΣΣ_?𝖼𝗀𝗋𝖺𝗉𝗁(e) contains a cycle}\mathcal{L}(\mathcal{A}_{\_}{bv})=\{e\in\Sigma^{*}\cdot\Sigma_{\_}?\mid\mathsf{cgraph}(e)\mbox{ contains a cycle}\}.

Proof.

Let 𝒜_bv=(L_bv,δ_bv,l_bv,0,{l_bv,1})\mathcal{A}_{\_}{bv}=(L_{\_}{bv},\delta_{\_}{bv},l_{\_}{bv,0},\{l_{\_}{bv,1}\}) be the non-deterministic finite state automaton over ΣΣ_?\Sigma\cup\Sigma_{\_}{?} such that L_bv={l_bv,0,l_bv,1}Σ_?×ΣL_{\_}{bv}=\{l_{\_}{bv,0},l_{\_}{bv,1}\}\cup\Sigma_{\_}{?}\times\Sigma, and for all c,cΣc,c^{\prime}\in\Sigma, for all aΣ_?a\in\Sigma_{\_}{?}, for all iIi\in I, v𝕍v\in\mathbb{V}, (1) (l_bv,0,c,l_bv,0)δ_bv(l_{\_}{bv,0},c,l_{\_}{bv,0})\in\delta_{\_}{bv} (2) (l_bv,0,i!v,(i?v,i!v))δ_bv(l_{\_}{bv,0},i!v,(i?v,i!v))\in\delta_{\_}{bv}, (3) ((a,c),c,(a,c))δ_bv((a,c),c^{\prime},(a,c))\in\delta_{\_}{bv} (4) ((a,c),c,(a,c))δ_bv((a,c),c^{\prime},(a,c^{\prime}))\in\delta_{\_}{bv} if 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(c)𝗉𝗋𝗈𝖼𝖾𝗌𝗌(c)\mathsf{process}(c)\cap\mathsf{process}(c^{\prime})\neq\emptyset, and (5) ((i?v,c),i?v,l_bv,1)δ_bv((i?v,c),i?v,l_{\_}{bv,1})\in\delta_{\_}{bv} if 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(c)𝗉𝗋𝗈𝖼𝖾𝗌𝗌(i?v)\mathsf{process}(c)\cap\mathsf{process}(i?v)\neq\emptyset. Then (𝒜_bv))={eΣΣ_?𝖼𝗀𝗋𝖺𝗉𝗁(e) contains a cycle}\mathcal{L}(\mathcal{A}_{\_}{bv}))=\{e\in\Sigma^{*}\Sigma_{\_}{?}\mid\mathsf{cgraph}(e)\mbox{ contains a cycle}\}. Moreover, each transition of 𝒜_bv\mathcal{A}_{\_}{bv} can be constructed in constant time, so 𝒜_bv\mathcal{A}_{\_}{bv} can be constructed in time as announced. ∎

From the computability of the two previous automata, we deduce the decidability of system greediness.

Theorem 11.

Whether a system 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} of size nn is greedy is decidable in time 𝒪(|I|5|𝕍|42|I|n||+2)\mathcal{O}(|I|^{5}|\mathbb{V}|^{4}2^{|I|}n^{|\mathbb{P}|+2}).

Proof.

Let 𝒜_gr\mathcal{A}_{\_}{gr} and 𝒜_bv\mathcal{A}_{\_}{bv} be the two automata defined in Lemmas 9 and 10. By Lemma 6 and by definition of a borderline violation, the set of borderline violations of 𝔖\mathfrak{S} is (𝒜_gr)Σ_?(𝒜_bv)\mathcal{L}(\mathcal{A}_{\_}{gr})\cdot\Sigma_{\_}{?}\cap\mathcal{L}(\mathcal{A}_{\_}{bv}). So, by Lemma 8, 𝔖\mathfrak{S} is greedy if and only if (𝒜_gr)Σ_?(𝒜_bv)=\mathcal{L}(\mathcal{A}_{\_}{gr})\cdot\Sigma_{\_}{?}\cap\mathcal{L}(\mathcal{A}_{\_}{bv})=\emptyset. The claim then directly follows from the fact that emptiness testing for a non-deterministic finite state automaton of size nn is in time 𝒪(n)\mathcal{O}(n). ∎

4 Model-Checking Greedy Systems

In this section we explore how to verify various safety properties of greedy systems in polynomial time. Since the reachability set of a greedy system is not regular, it is not obvious that regular safety properties are always decidable. We show that this problem actually is decidable, with a polynomial time complexity under mild assumptions. Then, we list a few regular safety properties that were also considered in other works, in particular for approaches based on session types [17, 9, 23].

4.1 Checking Regular Safety Properties

Let 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}} with I=_pI_p={1,,|I|}I=\bigcup_{\_}{p\in\mathbb{P}}I_{\_}p=\{1,\ldots,|I|\} be a system. We identify a word w=𝐥b_1b_|I|L_𝔖(𝕍)|I|w=\mathbf{l}\cdot\sharp\cdot b_{\_}1\cdot\sharp\cdots\sharp\cdot b_{\_}{|I|}\in L_{\_}{\mathfrak{S}}\cdot(\sharp\cdot\mathbb{V}^{*})^{|I|} with the configuration (𝐥,b_1,,b_|I|)(\mathbf{l},b_{\_}1,\ldots,b_{\_}{|I|}). We say that a set of configurations P(𝔖)P(\mathfrak{S}) is regular333also called channel recognizable by Cece and Finkel [6, Definition 10] if the corresponding set of words coding these configurations is regular. A property is a function PP that associates to every system 𝔖\mathfrak{S} a set of configurations P(𝔖)P(\mathfrak{S}). We say that PP is regular if P(𝔖)P(\mathfrak{S}) is regular for all 𝔖\mathfrak{S}, and computable in time 𝒪(f(n))\mathcal{O}(f(n)) if a non-deterministic finite state automaton 𝒜\mathcal{A} accepting P(𝔖)P(\mathfrak{S}) can be computed in time 𝒪(f(|𝔖|))\mathcal{O}(f(|\mathfrak{S}|)). The PP safety problem is whether a system 𝔖\mathfrak{S} is such that RS(𝔖)P(𝔖)=RS(\mathfrak{S})\cap P(\mathfrak{S})=\emptyset. Examples of safety problems are discussed below in Section 4.2.

Cece and Finkel showed that, for a binary half-duplex system 𝔖\mathfrak{S}, RS(𝔖)RS(\mathfrak{S}) is regular and computable in polynomial time [6, Theorem 26]. Since the emptiness of the intersection of two polynomial time computable regular languages is decidable in polynomial time, for any regular polynomial time property PP, the PP safety problem is decidable in polynomial time for binary half-duplex systems.

For greedy systems, however, the situation is a bit different. Indeed, observe that RS(𝔖)RS(\mathfrak{S}) may be non-regular and even context sensitive (it is easy to define a system with one machine and 3 buffers, such that for some control state ll, RS(𝔖)l(𝕍)3={lanbncnn0}RS(\mathfrak{S})\cap l(\sharp\mathbb{V}^{*})^{3}=\{l\sharp a^{n}\sharp b^{n}\sharp c^{n}\mid n\geq 0\}). So it is not obvious how to decide the emptiness of RS(𝔖)P(𝔖)RS(\mathfrak{S})\cap P(\mathfrak{S}).

Still, the PP safety problem remains decidable for a computable regular property PP.

Theorem 12.

Let PP be a computable regular property. Then, for a given greedy system 𝔖=(𝒜_p)_p\mathfrak{S}=(\mathcal{A}_{\_}p)_{\_}{p\in\mathbb{P}}, the PP safety problem is decidable. Moreover, if PP is computable in time 𝒪(|𝔖|k)\mathcal{O}(|\mathfrak{S}|^{k}) for some k0k\geq 0, then the problem is decidable in time 𝒪(|𝔖|k+||+2)\mathcal{O}(|\mathfrak{S}|^{k+|\mathbb{P}|+2}).

Proof.

Let 𝔖\mathfrak{S} be fixed, with 𝗉𝗋𝗈𝖽𝗎𝖼𝗍(𝔖)=(L_𝔖,𝕍,I,𝖠𝖼𝗍,δ_𝔖,𝐥_𝔖,0)\mathsf{product}(\mathfrak{S})=(L_{\_}{\mathfrak{S}},\mathbb{V},I,\mathsf{Act},\delta_{\_}{\mathfrak{S}},\mathbf{l}_{\_}{\mathfrak{S},0}). Let 𝒜=(L_𝒜,δ_𝒜,l_𝒜,0,F_𝒜)\mathcal{A}=(L_{\_}{\mathcal{A}},\delta_{\_}{\mathcal{A}},l_{\_}{\mathcal{A},0},F_{\_}{\mathcal{A}}) be the polynomial time computable non-deterministic finite state automaton over alphabet L_𝔖{}𝕍L_{\_}{\mathfrak{S}}\cup\{\sharp\}\cup\mathbb{V} such that (𝒜)=P(𝔖)\mathcal{L}(\mathcal{A})=P(\mathfrak{S}). We define an automaton 𝒜_P=(L_P,δ_P,L_P,0,F_P)\mathcal{A}_{\_}P=(L_{\_}P,\delta_{\_}P,L_{\_}{P,0},F_{\_}P) over the alphabet Σ\Sigma of communications such that for all greedy execution e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})}, e(𝒜_P)e\in\mathcal{L}(\mathcal{A}_{\_}P) iff there is γP(𝔖)\gamma\in P(\mathfrak{S}) such that γ0𝔖𝑒γ\gamma_{0}\xRightarrow[\tiny\mathfrak{S}]{e}\gamma.

Before defining 𝒜_p\mathcal{A}_{\_}p formally, let us give some intuitions about how it works on an example. Assume that 𝒜_p\mathcal{A}_{\_}p reads e=1!a2!?b2!c1!de=1!a\cdot 2!?b\cdot 2!c\cdot 1!d, and that the final configuration γ\gamma is 𝐥adc\mathbf{l}\sharp ad\sharp c. While reading ee, 𝒜_p\mathcal{A}_{\_}p should check the existence of an accepting run of 𝒜\mathcal{A} on γ\gamma. When 𝒜_P\mathcal{A}_{\_}P reads a communication, there are two cases. Either the communication is a matched send (like 2!?b2!?b) and therefore it does not contribute to the final configuration, so 𝒜_p\mathcal{A}_{\_}p merely ignores it. Or the communication is an unmatched send, and it contributes to a piece of the accepting run of γ\gamma on 𝒜\mathcal{A}. However, these pieces of the accepting run of 𝒜\mathcal{A} are not necessarily consecutive. For instance, in the above execution, aa and dd are consecutive in the run of 𝒜\mathcal{A}, but 𝒜_p\mathcal{A}_{\_}p reads cc in between, although cc contributes only later to the run of 𝒜\mathcal{A}. To correctly check the existence of a run of 𝒜\mathcal{A} on γ\gamma, 𝒜_p\mathcal{A}_{\_}p uses for each buffer a distinguished ”pebble” placed on a state of 𝒜\mathcal{A}. Every time 𝒜_p\mathcal{A}_{\_}p reads an unmatched send i!vi!v, it moves the ii-th pebble along an vv transition of 𝒜\mathcal{A}. So each pebble checks for a piece of the accepting run of the whole word coding the final configuration. 𝒜_p\mathcal{A}_{\_}p therefore also needs to make sure that all of these pieces of runs can be concatenated to form a run of 𝒜\mathcal{A}. Therefore, at the beginning, 𝒜_p\mathcal{A}_{\_}p guesses an initial control state l_il_{\_}i and a final control state l_il_{\_}i^{\prime} for each pebble, and ensures that (l_i,,l_i+1)δ_𝒜(l_{\_}i^{\prime},\sharp,l_{\_}{i+1})\in\delta_{\_}{\mathcal{A}}. While doing so, going back to our example, 𝒜_p\mathcal{A}_{\_}p ensures that ad#cad\#c can be read by 𝒜\mathcal{A}. It remains also to deal with the control state: indeed, 𝒜\mathcal{A} should accept 𝐥adc\mathbf{l}\sharp ad\sharp c. So 𝒜_P\mathcal{A}_{\_}P guesses before reading ee that the control state will be 𝐥\mathbf{l} after executing ee, and while reading ee, it computes the current control state of 𝔖\mathfrak{S}. In the end, it checks that this control state actually is 𝐥\mathbf{l}.

Now that we presented the intuitions about 𝒜_p\mathcal{A}_{\_}p, let us define it formally. Let us start with the set of control states. Let L_P=L_𝔖×L_𝔖×L_𝒜|I|×L_𝒜|I|L_{\_}P=L_{\_}{\mathfrak{S}}\times L_{\_}{\mathfrak{S}}\times L_{\_}{\mathcal{A}}^{|I|}\times L_{\_}{\mathcal{A}}^{|I|}. Intuitively, the control state (𝐥_𝔖,𝐥_F,𝐥_𝒜,𝐥_I)(\mathbf{l}_{\_}{\mathfrak{S}},\mathbf{l}_{\_}{F},\mathbf{l}_{\_}{\mathcal{A}},\mathbf{l}_{\_}{I}) of 𝒜_p\mathcal{A}_{\_}p corresponds to a situation where: (1) the current control state of 𝔖\mathfrak{S} is 𝐥_𝔖\mathbf{l}_{\_}{\mathfrak{S}}, (2) the guessed final control state of 𝔖\mathfrak{S} is 𝐥_F\mathbf{l}_{\_}{F}, (3) the ii-th pebble currently is on state l_𝒜,il_{\_}{\mathcal{A},i} of 𝒜\mathcal{A}, and (4) 𝐥_I\mathbf{l}_{\_}{I} is a copy of the initial positions of the pebbles and will be checked against their final positions in the end to ensure that all pieces of runs can be concatenated.

Let us now define the set L_P,0L_{\_}{P,0} of initial control states of 𝒜_P\mathcal{A}_{\_}P. Let us set that (𝐥_𝔖,𝐥_F,𝐥_𝒜,𝐥_IL_P,0(\mathbf{l}_{\_}{\mathfrak{S}},\mathbf{l}_{\_}{F},\mathbf{l}_{\_}{\mathcal{A}},\mathbf{l}_{\_}{I}\in L_{\_}{P,0} if (1) 𝐥_𝒜=𝐥_I\mathbf{l}_{\_}{\mathcal{A}}=\mathbf{l}_{\_}{I}, (2) l_𝒜,1δ_𝒜(l_𝒜,0,𝐥_F)l_{\_}{\mathcal{A},1}\in\delta_{\_}{\mathcal{A}}^{*}(l_{\_}{\mathcal{A},0},\mathbf{l}_{\_}{F}\cdot\sharp), and (3) 𝐥_𝔖=𝐥_𝔖,0\mathbf{l}_{\_}{\mathfrak{S}}=\mathbf{l}_{\_}{\mathfrak{S},0}. Intuitively, a control state is initial if (1) 𝐥_I\mathbf{l}_{\_}{I} is a copy of 𝐥_𝒜\mathbf{l}_{\_}{\mathcal{A}}, (2) the position of the pebble of buffer 11 is on a state that is reachable in 𝒜\mathcal{A} after reading 𝐥_F\mathbf{l}_{\_}{F}\sharp and (3) 𝐥_𝔖\mathbf{l}_{\_}{\mathfrak{S}} is the initial control state of 𝔖\mathfrak{S}.

Similarly, let us now define the set F_PF_{\_}{P} of final control states of 𝒜_P\mathcal{A}_{\_}P. Let us set (𝐥_𝔖,𝐥_F,𝐥_𝒜,𝐥_I)F_P(\mathbf{l}_{\_}{\mathfrak{S}},\mathbf{l}_{\_}{F},\mathbf{l}_{\_}{\mathcal{A}},\mathbf{l}_{\_}{I})\in F_{\_}{P} if (1) 𝐥_𝔖=𝐥_F\mathbf{l}_{\_}{\mathfrak{S}}=\mathbf{l}_{\_}{F}, (2) for all i=1,,|I|1i=1,\ldots,|I|-1, (l_𝒜,i,,l_𝒜,i+1)δ_𝒜(l_{\_}{\mathcal{A},i},\sharp,l_{\_}{\mathcal{A},i+1})\in\delta_{\_}{\mathcal{A}}, and (3) l_𝒜,|I|F_𝒜l_{\_}{\mathcal{A},|I|}\in F_{\_}{\mathcal{A}}. Intuitively, a control state is final if (1) the current control state of 𝔖\mathfrak{S} corresponds to the guessed final one, (2) the ii-th pebble can be moved along a \sharp transition so as to reach the initial position of pebble i+1i+1, and (3) the pebble of the last buffer reached an accepting state of 𝒜\mathcal{A}.

Let us now define the set δ_P\delta_{\_}P of transitions of 𝒜_p\mathcal{A}_{\_}p. Let us set that

((𝐥_𝔖,𝐥_F,𝐥_𝒜,𝐥_I),c,(𝐥_𝔖,𝐥_F,𝐥_𝒜,𝐥_I))δ_P\Big{(}(\mathbf{l}_{\_}{\mathfrak{S}},\mathbf{l}_{\_}{F},\mathbf{l}_{\_}{\mathcal{A}},\mathbf{l}_{\_}{I}),\leavevmode\nobreak\ c,\leavevmode\nobreak\ (\mathbf{l}_{\_}{\mathfrak{S}}^{\prime},\mathbf{l}_{\_}{F}^{\prime},\mathbf{l}_{\_}{\mathcal{A}}^{\prime},\mathbf{l}_{\_}{I}^{\prime})\Big{)}\leavevmode\nobreak\ \in\leavevmode\nobreak\ \delta_{\_}P

if (1) 𝐥_F=𝐥_F\mathbf{l}_{\_}{F}=\mathbf{l}_{\_}{F}^{\prime}, (2) 𝐥_I=𝐥_I\mathbf{l}_{\_}I=\mathbf{l}_{\_}{I}^{\prime}, (3) 𝐥_𝔖δ_𝔖(𝐥_𝔖,c)\mathbf{l}_{\_}{\mathfrak{S}}^{\prime}\in\delta_{\_}{\mathfrak{S}}^{*}(\mathbf{l}_{\_}{\mathfrak{S}},c), (4.1) if c=i!?vc=i!?v, then 𝐥_𝒜=𝐥_𝒜\mathbf{l}_{\_}{\mathcal{A}}=\mathbf{l}_{\_}{\mathcal{A}}^{\prime}, and (4.2) if c=i!vc=i!v, then (l_𝒜,i,v,l_𝒜,i)δ_𝒜(l_{\_}{\mathcal{A},i},v,l_{\_}{\mathcal{A},i}^{\prime})\in\delta_{\_}{\mathcal{A}} and l_𝒜,j=l_𝒜,jl_{\_}{\mathcal{A},j}=l_{\_}{\mathcal{A},j}^{\prime} for all jij\neq i. Intuitively, when it reads a matched send i!?vi!?v, 𝒜_p\mathcal{A}_{\_}p only updates 𝐥_𝔖\mathbf{l}_{\_}{\mathfrak{S}} according to the sequence of actions i!?vi!?v, while when it reads an unmatched send i!vi!v it also updates the position of the ii-th token.

Now that 𝒜_P\mathcal{A}_{\_}P is defined, observe that RS(𝔖)P(𝔖)=RS(\mathfrak{S})\cap P(\mathfrak{S})=\emptyset iff (𝒜_p)(𝒜_gr)=\mathcal{L}(\mathcal{A}_{\_}p)\cap\mathcal{L}(\mathcal{A}_{\_}{gr})=\emptyset, where 𝒜_gr\mathcal{A}_{\_}{gr} is the automaton defined in Lemma 9. The emptiness of this intersection is decidable in time 𝒪(|𝒜_P||𝒜_gr|)\mathcal{O}(|\mathcal{A}_{\_}P|\cdot|\mathcal{A}_{\_}{gr}|), which shows the claim. ∎

4.2 Examples of Regular Safety Problems

In this section we review a few properties of systems that are polynomial-time computable regular properties and showcase some applications of Theorem 12.

Reachability.

The control state reachability problem is to decide, given a system 𝔖\mathfrak{S} and a control state 𝐥L_𝔖\mathbf{l}\in L_{\_}{\mathfrak{S}}, whether there exists 𝐛(𝕍)I\mathbf{b}\in(\mathbb{V}^{*})^{I} and e𝖠𝖼𝗍e\in\mathsf{Act}^{*} such that γ0𝔖𝑒(𝐥,𝐛)\gamma_{0}\xRightarrow[\tiny\mathfrak{S}]{e}(\mathbf{l},\mathbf{b}). The configuration reachability problem, on the other hand, is to decide, given a system 𝔖\mathfrak{S} and a configuration γ\gamma, whether γRS(𝔖)\gamma\in RS(\mathfrak{S}). Both problems are safety problems for a regular property PP computable in polynomial time (and even constant time): P(𝔖)=𝐥(𝕍)|I|P(\mathfrak{S})=\mathbf{l}\cdot(\sharp\cdot\mathbb{V}^{*})^{|I|} for the control state reachability problem, and P(𝔖)={γ}P(\mathfrak{S})=\{\gamma\} for the configuration reachability problem.

Unspecified reception.

Unspecified receptions is one of the errors that session types usually forbid. This error makes more sense for mailbox systems, so let us assume for now that 𝔖\mathfrak{S} is a mailbox system. A configuration is an unspecified reception if one of the participants is in a receiving state, and none of its outgoing transitions can receive the first message in its buffer.

Let us define these notions more formally. A control state l_pl_{\_}p of process pp is a receiving state if for all a,la,l^{\prime} such that (l_p,a,l)δ_p(l_{\_}p,a,l^{\prime})\in\delta_{\_}p, aa is a receive action. The set {v(l_p,p?v,l)δ_p for some l}\{v\mid(l_{\_}p,p?v,l^{\prime})\in\delta_{\_}p\mbox{ for some }l^{\prime}\} is called the ready set of l_pl_{\_}p.

A configuration (𝐥,𝐛)(\mathbf{l},\mathbf{b}) is said an unspecified reception configuration if there is pp\in\mathbb{P} such that (1) l_pl_{\_}p is a receiving state, (2) b_p=vbb_{\_}p=vb^{\prime} for some v𝕍v\in\mathbb{V} and b𝕍b^{\prime}\in\mathbb{V}^{*}, and (3) vv is not in the ready set of l_pl_{\_}p. It can be observed that the set UR(𝔖)UR(\mathfrak{S}) of unspecified receptions of 𝔖\mathfrak{S} defines a regular property that is computable in polynomial time.

Progress.

Another property that is central in session types is progress. A global control state 𝐥\mathbf{l} of 𝔖\mathfrak{S} is final if there is no action aa and global control state 𝐥\mathbf{l}^{\prime} such that (𝐥,a,𝐥)δ_𝔖(\mathbf{l},a,\mathbf{l}^{\prime})\in\delta_{\_}{\mathfrak{S}}. A configuration γ=(𝐥,𝐛)\gamma=(\mathbf{l},\mathbf{b}) of 𝔖\mathfrak{S} satisfies progress if either 𝐥\mathbf{l} is final or there is a configuration γ\gamma^{\prime} and an action aa such that γ𝔖𝑎γ\gamma\xrightarrow[\tiny\mathfrak{S}]{a}\gamma^{\prime}. A system satisfies progress if all reachable configurations satisfy progress. It can be observed that the set NP(𝔖)NP(\mathfrak{S}) of configurations that do not satisfy progress is regular and polynomial time computable.

4.3 Boundedness

There are other examples of properties that are regular and polynomial time, but some interesting ones are not safety properties. To conclude this section, we consider one of these properties.

Definition 13 (Boundedness).

Let 𝔖\mathfrak{S} be a system and k0k\geq 0. A channel iIi\in I is kk-bounded if for all (𝐥,𝐛)RS(𝔖)(\mathbf{l},\mathbf{b})\in RS(\mathfrak{S}) |b_i|k|b_{\_}i|\leq k. 𝔖\mathfrak{S} is kk-bounded if for all iIi\in I, ii is kk-bounded.

Theorem 14.

Whether there exists k0k\geq 0 such that a greedy system 𝔖\mathfrak{S} is kk-bounded is decidable in polynomial time. Moreover, kk is computable in polynomial time.

Proof.

Let Σ_!Σ\Sigma_{\_}{!}\subseteq\Sigma be the set of unmatched communications, and σ:ΣΣ_!\sigma:\Sigma^{*}\to\Sigma^{*}_{\_}{!} the morphism that erase all matched communications. By Lemma 9, and by the closure of regular languages under morphisms, there is a polynomial time computable non-deterministic finite state automaton 𝒜\mathcal{A} such that (𝒜)={σ(e)e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖) is greedy}\mathcal{L}(\mathcal{A})=\{\sigma(e)\mid e\in\mathsf{executions(\mathfrak{S})}\mbox{ is greedy}\}. Then 𝔖\mathfrak{S} is kk-bounded for some kk if and only if (𝒜)\mathcal{L}(\mathcal{A}) is finite, or equivalently if and only if 𝒜\mathcal{A}, once pruned (removing states that are not reachable from the initial state and co-reachable from a final state), is acyclic.This is decidable in time 𝒪(|𝒜|)\mathcal{O}(|\mathcal{A}|), and the maximal length kk of a word of (𝒜)\mathcal{L}(\mathcal{A}) also is computable in time 𝒪(|𝒜|)\mathcal{O}(|\mathcal{A}|). ∎

5 Mailbox Half-Duplex Systems

Binary half-duplex systems, (called simply half-duplex by Cece and Finkel [6]) are binary systems such that all reachable configurations (l_1,l_2,b_1,b_2)(l_{\_}1,l_{\_}2,b_{\_}1,b_{\_}2) are such that either b_1=ϵb_{\_}1=\epsilon or b_2=ϵb_{\_}2=\epsilon. In the previous sections, we established that greedy systems enjoy the same decidability and complexity results as binary half-duplex systems. In this section, we defend the claim that greedy systems could also merit the name of multiparty half-duplex systems.

First, observe that binary half-duplex systems are greedy (see [6, Lemma 20]). The converse does not hold in general: some binary greedy systems are not half-duplex. However, under an extra hypothesis, both are equivalent. A system is called without orphan messages if for all reachable configuration containing a message in a buffer, it is possible to reach a configuration where this message has been received. This property is also enforced by session types and is very natural in communicating systems. Then observe that, for a given a binary system 𝔖\mathfrak{S} without orphan messages, the following two are equivalent: (1) 𝔖\mathfrak{S} is binary half-duplex, and (2) 𝔖\mathfrak{S} is greedy.

Let us now consider multiparty systems. Cece and Finkel proposed two notions of multiparty half-duplex systems, but conclude that they were not well behaved (one being too restrictive, and the other Turing powerful). Both of these generalisations relied on peer-to-peer communication. We propose to consider mailbox communication instead.

Definition 15 (Half-duplex execution).

Fix a mailbox system 𝔖\mathfrak{S}. An execution e=(𝐥_𝟎,𝐛_0)a_1(𝐥_𝟏,𝐛_1)a_n(𝐥_𝐧,𝐛_n)e=(\mathbf{l_{\_}0},\mathbf{b}_{\_}0)\xrightarrow[\tiny]{a_{\_}1}(\mathbf{l_{\_}1},\mathbf{b}_{\_}1)\xrightarrow{}\cdots\xrightarrow{a_{\_}n}(\mathbf{l_{\_}n},\mathbf{b}_{\_}n) is half-duplex if for all j=1,,nj=1,\ldots,n, if a_ja_{\_}j is a send action, then b_pi1=εb_{\_}p^{i-1}=\varepsilon, where p=𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_j)p=\mathsf{process}(a_{\_}j).

Intuitively, an execution is half-duplex if every process empties its queue of messages before sending.

Definition 16 (Mailbox half-duplex system).

A mailbox system 𝔖\mathfrak{S} is mailbox half-duplex if for all execution e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})}, there is a half-duplex execution ee^{\prime} such that e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}.

Example 7.

The system in Figure 1 is half-duplex. Indeed even if execution ee of Example 2 is not half-duplex, by considering one of its greedy equivalents e′′e^{\prime\prime}:

e′′=s!reqs?reqc!resc?ress!ack_ss?ack_sd!log_cd?log_cc!ack_dc?ack_dd!log_sd?log_ss!reqe^{\prime\prime}=s!req\cdot s?req\cdot c!res\cdot c?res\cdot s!ack_{\_}s\cdot s?ack_{\_}s\cdot d!log_{\_}c\cdot d?log_{\_}c\cdot c!ack_{\_}d\cdot c?ack_{\_}d\cdot d!log_{\_}s\cdot d?log_{\_}s\cdot s!req

we obtain a half-duplex execution. Notice that execution ee^{\prime} of Example 4 is greedy but not half-duplex as the send of message log_slog_{\_}s is done when the buffer of the Server is filled with message reqreq. ∎

Note that a binary system is mailbox half-duplex if and only if it is binary half-duplex. In the remainder, we therefore sometimes say simply half-duplex instead of binary half-duplex or mailbox half-duplex.

Theorem 17.

Mailbox half-duplex systems are greedy.

Proof.

We reason by contradiction. Assume that 𝔖\mathfrak{S} is not greedy, we show that 𝔖\mathfrak{S} is not half-duplex. Let e𝖾𝗑𝖾𝖼𝗎𝗍𝗂𝗈𝗇𝗌(𝔖)e\in\mathsf{executions(\mathfrak{S})} be any execution that is not causally equivalent to a greedy execution (for instance, take for ee a borderline violation). We claim that for all ee^{\prime} such that e𝔖ee\stackrel{{\scriptstyle\tiny\mathfrak{S}}}{{\sim}}e^{\prime}, ee^{\prime} is not half-duplex. Since ee^{\prime} is not causally equivalent to a greedy execution, we get, by Lemma 6, that 𝖼𝗀𝗋𝖺𝗉𝗁(e)\mathsf{cgraph}(e^{\prime}) contains a cycle of communications c_1ec_2eec_nec_1c_{\_}1\rightarrow_{e^{\prime}}c_{\_}2\rightarrow_{e^{\prime}}\ldots\rightarrow_{e^{\prime}}c_{\_}n\rightarrow_{e^{\prime}}c_{\_}1 where for all i=1,ni=1,\ldots n, either c_i={j_i,k_i}c_{\_}i=\{j_{\_}i,k_{\_}i\} is a matching pair, or c_i={j_i}c_{\_}i=\{j_{\_}i\} is an unmatched send. We assume that j_i<k_ij_{\_}i<k_{\_}i, i.e. j_ij_{\_}i is the index of the send action and k_ik_{\_}i the index of the receive action. Up to a circular permutation, we can also assume, without loss of generality, that j_1j_{\_}1 is the first send among them in ee^{\prime}, i.e. j_1<j_j_{\_}1<j_{\_}{\ell} for all =2,,n\ell=2,\ldots,n. Now, let us reason by case analysis on the nature of the conflict edge c_nec_1c_{\_}n\rightarrow_{e^{\prime}}c_{\_}1.

  • case “c_nSSc_1c_{\_}n\xrightarrow{SS}c_{\_}1”: j_n_ej_1j_{\_}n\prec_{\_}{e^{\prime}}j_{\_}1. Then j_n<j_1j_{\_}n<j_{\_}1, contradicts the minimality of j_1j_{\_}1. Impossible.

  • case “c_nRSc_1c_{\_}n\xrightarrow{RS}c_{\_}1”: k_n_ek_1k_{\_}n\prec_{\_}{e^{\prime}}k_{\_}1. Then j_n<k_n<j_1j_{\_}n<k_{\_}n<j_{\_}1, impossible.

  • case “c_nRRc_1c_{\_}n\xrightarrow{RR}c_{\_}1”: k_n_ek_1k_{\_}n\prec_{\_}{e^{\prime}}k_{\_}1. Then k_n<k_1k_{\_}n<k_{\_}1 and either (1) 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_k_n)=𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_k_1)\mathsf{process}(a_{\_}{k_{\_}n})=\mathsf{process}(a_{\_}{k_{\_}1}) or (2) there is iIi\in I, v,v𝕍v,v^{\prime}\in\mathbb{V} such that a_k_n=i?va_{\_}{k_{\_}n}=i?v and a_k_1=i?va_{\_}{k_{\_}1}=i?v^{\prime}. Because of the mailbox semantics, (1) and (2) are equivalent, so (2) is granted. But then a_j_n=i!va_{\_}{j_{\_}n}=i!v and a_j_1=i!va_{\_}{j_{\_}1}=i!v^{\prime}. Since ee^{\prime} is a FIFO execution, and k_n<k_1k_{\_}n<k_{\_}1, we get that j_n<j_1j_{\_}n<j_{\_}1, and again the contradiction.

  • case “c_nSRc_1c_{\_}n\xrightarrow{SR}c_{\_}1”: j_n_ek_1j_{\_}n\prec_{\_}{e^{\prime}}k_{\_}1. Then j_n<k_1j_{\_}n<k_{\_}1, and 𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_j_n)=𝗉𝗋𝗈𝖼𝖾𝗌𝗌(a_k_1)\mathsf{process}(a_{\_}{j_{\_}n})=\mathsf{process}(a_{\_}{k_{\_}1}). Moreover, j_1<j_nj_{\_}1<j_{\_}n by the minimality of j_1j_{\_}1. To sum up, let p,q,r,v_1,v_2p,q,r,v_{\_}1,v_{\_}2 be such that a_j_1=!v_1pqa_{\_}{j_{\_}1}=!v_{\_}1^{\tiny p\to q}, a_k_1=?v_1pqa_{\_}{k_{\_}1}=?v_{\_}1^{\tiny p\to q}, and a_j_n=!v_2qra_{\_}{j_{\_}n}=!v_{\_}2^{\tiny q\to r}. Then we just showed that e=!v_1pq!v_2qr?v_1pqe^{\prime}=\ldots!v_{\_}1^{\tiny p\to q}\ldots!v_{\_}2^{\tiny q\to r}\ldots?v_{\_}1^{\tiny p\to q}\ldots, so ee^{\prime} is not a half-duplex execution.

Notice that the converse of Theorem 17 does not hold: being greedy is not a sufficient condition to be half-duplex. Indeed, an unmatched send can fill the buffer of a process willing to send. More precisely, consider the action graph on the right. It depicts a greedy system that is not half-duplex: in fact the buffer for qq is not empty when v_2v_{\_}2 is sent. We conjecture that this is the only pathological situation, and that, like in the binary setting, if a system is greedy and has no orphan messages, then it is half-duplex.

ppqqq!v_1q!v_{\_}1p?v_2p?v_{\_}2q!v_2q!v_{\_}2
02211ClientClient334401122334455SellerSellerBankBank0112233s!ask_prices!ask\_prices!buys!buyc?pricec?pricec?ask_payc?ask\_payb!info_payb!info\_payc?cancelc?cancelc?confc?confs?ask_prices?ask\_prices?buys?buyc!pricec!priceb!transactionb!transactions?auths?auths?refusals?refusalc!confc!confc!cancelc!cancelb?transactionb?transactionc!ask_payc!ask\_payb?info_payb?info\_pays!refusals!refusals!auths!auth
Figure 4: Client/Seller/Bank
Example 8.

To finish this section we present another small example of a half-duplex system: the classic Client/Seller/Bank protocol. This system is shown in Figure 4. In this protocol a client can ask the price of an item to the seller (ask_priceask\_price message), and receive the answer. Whenever the client agrees on a price it can place an order (via the message buybuy). Receiving this message the seller initiates a transaction with the bank. The bank asks the client for its credentials, and when it receives them it either authorizes or refuses the transaction, and notifies the seller accordingly. The seller then confirms or cancels the transaction, sending a message to the client. ∎

6 Conclusion

We have introduced greedy systems, a new class of communicating systems, generalising the notion of half-duplex systems to any number of processes, and to an arbitrary model of FIFO communication (encompassing both p2p and mailbox communications). We have shown that the greediness of a system is decidable in polynomial time, and that for greedy systems regular safety properties, such as reachability, progress, and boundedness are decidable in polynomial time. Finally, we defined mailbox half-duplex systems and showed that greedy systems are intimately related to mailbox half-duplex systems.

Still, the picture is a bit incomplete: we did not address liveness properties nor more general temporal properties, and we also did not propose a notion of p2p half-duplex systems that would enjoy all desirable properties. Also, we did not report on experimental evaluation. We leave these questions for future work.

Pachl gave a general decidability result for systems of communicating finite state machines whose reachability set is regular [22]. Although the algorithm is rather brute-force, the MCSCM tool illustrates that it is amenable to an efficient CEGAR optimization [14]. Beyond regularity, and relying on visibly pushdown languages, La Torre et al [27] established that bounded context-switch reachability is also decidable in time exponential in the number of states and doubly exponential in the number of switch. We conjecture that bounded context-switch reachability is complete for greedy systems with a number of switch polynomial in the size of the system.

Several authors considered communicating systems where queues are not plain FIFO but may over-approximate a FIFO behaviour. A representative example of this approach is lossy channels, introduced independently in [7] and [2]. Another example is the bag semantics of buffers where messages are received without loss but out of order. Examples of uses of bag buffers can be found in [26]. Both for lossy and bag systems the reachability problem is decidable but with a high complexity: non primitive recursive for lossy [24, 25]. The exact complexity seems unknown for bag systems, but by reduction to Petri nets it is non-elementary [8].

Aside bounded context-switch model-checking, another form of bounded model-checking has been promoted by Muscholl et al.: the notions of universally and existentially bounded message sequence charts [20]. This leads to two notions of universally/existentially bounded systems (both having unfortunately the same name), depending whether only the MSCs leading to final stable configurations are considered [13] or all MSCs [19]. For the latter definition, reachability and membership are decidable in PSPACE. Greedy systems are existentially 11-bounded, but the converse does not hold (for instance, the system of Example 5) is existentially 11-bounded). A system is kk-synchronous [5] if the message sequence charts of the system are formed of blocks of kk messages. In particular, a system is 11-synchronous if the message lines never cross. For systems with p2p communications, greediness is the same as 11-synchronizability. However, for mailbox communications, some subtle examples are 11-synchronous but not greedy (see e.g. [10, Example 1.2]). For kk-synchronous systems, reachability is decidable in PSPACE. Finally, greedy system are synchronizable in the sense of Basu and Bultan [4], but synchronizability is not decidable [12]. We believe that greediness is the notion that Basu and Bultan were aiming at with the notion of synchronizability. It might be wondered if greedy systems were not implicit in Cece and Finkel’s work. Actually, some of their arguments rely on the fact that for half-duplex systems, every execution is ‘reachability equivalent’ to a synchronous execution. This is not exactly the notion of greedy systems we introduced, and our notion of greedy systems is closer to Bouajjani et al notion of 11-synchronous systems, although, as we just explained, they are not the same in some corner cases.

Session types are intimately related to half-duplex systems in the binary setting [21]. Several multi-party extensions of session types have been proposed, the last proposal being [23]. It seems there are also some similarities between multiparty session types and greedy systems. For instance, the notion of greedy execution shares some similarities with the notion of alternation in [9]. The study of the exact relationship between greedy systems and multi-party session typed systems is left for future work.

Acknowledgements.

We would like to thank all the ICE reviewers for their comments that greatly improved the present paper.

References

  • [1]
  • [2] Parosh Aziz Abdulla & Bengt Jonsson (1996): Verifying Programs with Unreliable Channels. Inf. Comput. 127(2), pp. 91–101, 10.1006/inco.1996.0053.
  • [3] Lakhdar Akroun & Gwen Salaün (2018): Automated verification of automata communicating via FIFO and bag buffers. Formal Methods Syst. Des. 52(3), pp. 260–276, 10.1007/s10703-017-0285-8.
  • [4] Samik Basu & Tevfik Bultan (2016): On deciding synchronizability for asynchronously communicating systems. Theor. Comput. Sci. 656, pp. 60–75, 10.1016/j.tcs.2016.09.023.
  • [5] Ahmed Bouajjani, Constantin Enea, Kailiang Ji & Shaz Qadeer (2018): On the Completeness of Verifying Message Passing Programs Under Bounded Asynchrony. In Hana Chockler & Georg Weissenbacher, editors: 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, Lecture Notes in Computer Science 10982, Springer, pp. 372–391, 10.1007/978-3-319-96142-2_23.
  • [6] Gérard Cécé & Alain Finkel (2005): Verification of programs with half-duplex communication. Inf. Comput. 202(2), pp. 166–190, 10.1016/j.ic.2005.05.006.
  • [7] Gérard Cécé, Alain Finkel & S. Purushothaman Iyer (1996): Unreliable Channels are Easier to Verify Than Perfect Channels. Inf. Comput. 124(1), pp. 20–31, 10.1006/inco.1996.0003.
  • [8] Wojciech Czerwinski, Slawomir Lasota, Ranko Lazic, Jérôme Leroux & Filip Mazowiecki (2021): The Reachability Problem for Petri Nets Is Not Elementary. J. ACM 68(1), pp. 7:1–7:28, 10.1145/3422822.
  • [9] Pierre-Malo Deniélou & Nobuko Yoshida (2012): Multiparty Session Types Meet Communicating Automata. In Helmut Seidl, editor: Programming Languages and Systems - 21st European Symposium on Programming, ESOP 2012, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2012, Tallinn, Estonia, March 24 - April 1, 2012. Proceedings, Lecture Notes in Computer Science 7211, Springer, pp. 194–213, 10.1007/978-3-642-28869-2_10.
  • [10] Cinzia Di Giusto, Laetitia Laversa & Étienne Lozes (2020): On the k-synchronizability of Systems. In: FOSSACS 2020, LNCS 12077, pp. 157–176, 10.1007/978-3-030-45231-5_9.
  • [11] Manuel Fähndrich, Mark Aiken, Chris Hawblitzel, Orion Hodson, Galen C. Hunt, James R. Larus & Steven Levi (2006): Language support for fast and reliable message-based communication in singularity OS. In Yolande Berbers & Willy Zwaenepoel, editors: Proceedings of the 2006 EuroSys Conference, Leuven, Belgium, April 18-21, 2006, ACM, pp. 177–190, 10.1145/1217935.1217953.
  • [12] Alain Finkel & Étienne Lozes (2017): Synchronizability of Communicating Finite State Machines is not Decidable. In Ioannis Chatzigiannakis, Piotr Indyk, Anca Muscholl & Fabian Kuhn, editors: Proceedings of the 44th International Colloquium on Automata, Languages and Programming (ICALP’17), Leibniz International Proceedings in Informatics 80, Leibniz-Zentrum für Informatik, Warsaw, Poland, pp. 122:1–122:14, 10.4230/LIPIcs.ICALP.2017.122.
  • [13] Blaise Genest, Dietrich Kuske & Anca Muscholl (2007): On Communicating Automata with Bounded Channels. Fundam. Inform. 80(1-3), pp. 147–167. Available at http://content.iospress.com/articles/fundamenta-informaticae/fi80-1-3-09.
  • [14] Alexander Heußner, Tristan Le Gall & Grégoire Sutre (2012): McScM: A General Framework for the Verification of Communicating Machines. In Cormac Flanagan & Barbara König, editors: Tools and Algorithms for the Construction and Analysis of Systems - 18th International Conference, TACAS 2012, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2012, Tallinn, Estonia, March 24 - April 1, 2012. Proceedings, Lecture Notes in Computer Science 7214, Springer, pp. 478–484, 10.1007/978-3-642-28756-5_34.
  • [15] Kohei Honda (1993): Types for Dyadic Interaction. In Eike Best, editor: CONCUR ’93, 4th International Conference on Concurrency Theory, Hildesheim, Germany, August 23-26, 1993, Proceedings, Lecture Notes in Computer Science 715, Springer, pp. 509–523, 10.1007/3-540-57208-2_35.
  • [16] Kohei Honda, Vasco Thudichum Vasconcelos & Makoto Kubo (1998): Language Primitives and Type Discipline for Structured Communication-Based Programming. In Chris Hankin, editor: Programming Languages and Systems - ESOP’98, 7th European Symposium on Programming, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS’98, Lisbon, Portugal, March 28 - April 4, 1998, Proceedings, Lecture Notes in Computer Science 1381, Springer, pp. 122–138, 10.1007/BFb0053567.
  • [17] Kohei Honda, Nobuko Yoshida & Marco Carbone (2016): Multiparty Asynchronous Session Types. J. ACM 63(1), pp. 9:1–9:67, 10.1145/2827695.
  • [18] ITU-TS: ITU-TS Recommendation Z.120: Message Sequence Chart (MSC). ITU-TS (1999).
  • [19] Dietrich Kuske & Anca Muscholl (2019): Communicating Automata. In J.-E. Pin, editor: Handbook of Automata: from Mathematics to Applications (AutoMathA), European Science Foundation. Available at https://eiche.theoinf.tu-ilmenau.de/kuske/Submitted/cfm-final.pdf.
  • [20] Markus Lohrey & Anca Muscholl (2004): Bounded MSC communication. Inf. Comput. 189(2), pp. 160–181, 10.1016/j.ic.2003.10.002.
  • [21] Étienne Lozes & Jules Villard (2011): Reliable Contracts for Unreliable Half-Duplex Communications. In: WS-FM 2011, LNCS 7176, pp. 2–16, 10.1007/978-3-642-29834-9_2.
  • [22] Jan K. Pachl (2003): Reachability problems for communicating finite state machines. CoRR cs.LO/0306121. Available at http://arxiv.org/abs/cs/0306121.
  • [23] Alceste Scalas & Nobuko Yoshida (2019): Less is more: multiparty session types revisited. Proc. ACM Program. Lang. 3(POPL), pp. 30:1–30:29, 10.1145/3290343.
  • [24] Philippe Schnoebelen (2002): Verifying lossy channel systems has nonprimitive recursive complexity. Inf. Process. Lett. 83(5), pp. 251–261, 10.1016/S0020-0190(01)00337-4.
  • [25] Philippe Schnoebelen (2021): On Flat Lossy Channel Machines. In Christel Baier & Jean Goubault-Larrecq, editors: 29th EACSL Annual Conference on Computer Science Logic, CSL 2021, January 25-28, 2021, Ljubljana, Slovenia (Virtual Conference), LIPIcs 183, Schloss Dagstuhl - Leibniz-Zentrum für Informatik, pp. 37:1–37:22, 10.4230/LIPIcs.CSL.2021.37.
  • [26] Koushik Sen & Mahesh Viswanathan (2006): Model Checking Multithreaded Programs with Asynchronous Atomic Methods. In Thomas Ball & Robert B. Jones, editors: Computer Aided Verification, Springer Berlin Heidelberg, Berlin, Heidelberg, pp. 300–314, 10.1007/11817963_29.
  • [27] Salvatore La Torre, P. Madhusudan & Gennaro Parlato (2008): Context-Bounded Analysis of Concurrent Queue Systems. In C. R. Ramakrishnan & Jakob Rehof, editors: Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29-April 6, 2008. Proceedings, Lecture Notes in Computer Science 4963, Springer, pp. 299–314, 10.1007/978-3-540-78800-3_21.