Timed Negotiations

Negotiations were introduced in [6] as a model for concurrent systems with multiparty decisions. What is very appealing with negotiations is that it is one of the very few non-trivial concurrent models where several interesting problems, such as soundness, i.e. absence of deadlocks, can be solved in PTIME [3]. In this paper, we introduce the model of timed negotiations and consider the problem of computing the minimum and the maximum execution times of a negotiation. The latter can be solved using the algorithm of [10] computing costs in negotiations, but surprisingly minimum execution time cannot. This paper proposes new algorithms to compute both minimum and maximum execution time, that work in much more general classes of negotiations than [10], that only considered sound and deterministic negotiations. Further, we uncover the precise complexities of these questions, ranging from PTIME to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varDelta _2^P$$\end{document}Δ2P-complete. In particular, we show that computing the minimum execution time is more complex than computing the maximum execution time in most classes of negotiations we consider.


Introduction
Distributed systems are notoriously difficult to analyze, mainly due to the explosion of the number of configurations that have to be considered to answer even simple questions. A challenging task is then to propose models on which analysis can be performed with tractable complexities, preferably within polynomial time. Free choice Petri nets are a classical model of distributed systems that allow for efficient verification, in particular when the nets are 1-safe [4,5].
Recently, [6] introduced a new model called negotiations for workflows and business processes. A negotiation describes how processes interact in a distributed system: a subset of processes in a node of the system take a synchronous decisions among several outcomes. The effect of this outcome sends contributing processes to a new set of nodes. The execution of a negotiation ends when processes reach a final configuration. Negotiations can be deterministic (once an outcome is fixed, each process knows its unique successor node) or not.
Negotiations are an interesting model since several properties can be decided with a reasonable complexity. The question of soundness, i.e., deadlock-freedom: whether from every reachable configuration one can reach a final configuration, is PSPACE-complete. However, for deterministic negotiations, it can be decided in PTIME [7]. The decision procedure uses reduction rules. Reduction techniques were originally proposed for Petri nets [2,8,11,16]. The main idea is to define transformations rules that produce a model of smaller size w.r.t. the original model, while preserving the property under analysis. In the context of negotiations, [7,3] proposed a sound and complete set of soundness-preserving reduction rules and algorithms to apply these rules efficiently. The question of soundness for deterministic negotiations was revisited in [9] and showed NLOGSPACEcomplete using anti patterns instead of reduction rules. Further, they show that the PTIME result holds even when relaxing determinism [9]. Negotiation games have also been considered to decide whether one particular process can force termination of a negotiation. While this question is EXPTIME-complete in general, for sound and deterministic negotiations, it becomes PTIME [12].
While it is natural to consider cost or time in negotiations (e.g. think of the Brexit negotiation where time is of the essence, and which we model as running example in this paper), the original model of negotiations proposed by [6] is only qualitative. Recently, [10] has proposed a framework to associate costs to the executions of negotiations, and adapt a static analysis technique based on reduction rules to compute end-to-end cost functions that are not sensitive to scheduling of concurrent nodes. For sound and deterministic negotiations, the end-to-end cost can be computed in O(n.(C + n)), where n is the size of the negotiation and C the time needed to compute the cost of an execution. Requiring soundness or determinism seems perfectly reasonable, but asking sound and deterministic negotiations is too restrictive: it prevents a process from waiting for decisions of other processes to know how to proceed.
In this paper, we revisit time in negotiations. We attach time intervals to outcomes of nodes. We want to compute maximal and minimal executions times, for negotiations that are not necessarily sound and deterministic. Since we are interested in minimal and maximal execution time, cycles in negotiations can be either bypassed or lead to infinite maximal time. Hence, we restrict this study to acyclic negotiations. Notice that time can be modeled as a cost, following [10], and the maximal execution time of a sound and deterministic negotiation can be computed in PTIME using the algorithm from [10]. Surprisingly however, we give an example (Example 3) for which the minimal execution time cannot be computed in PTIME by this algorithm.
The first contribution of the paper shows that reachability (whether at least one run of a negotiation terminates) is NP-complete, already for (untimed) deterministic acyclic negotiations. This implies that computing minimal or maximal execution time for deterministic (but unsound) acyclic negotiations cannot be done in PTIME (unless NP=PTIME). We characterize precisely the complexities of different decision variants (threshold, equality, etc.), with complexities ranging from (co-)NP-complete to Δ P 2 . We thus turn to negotiations that are sound but not necessarily deterministic. Our second contribution is a new algorithm, not based on reduction rules, to compute the maximal execution time in PTIME for sound negotiations. It is based on computing the maximal execution time of critical paths in the negotiations. However, we show that minimal execution time cannot be computed in PTIME for sound negotiations (unless NP=PTIME): deciding whether the minimal execution time is lower than T is NP-complete, even for T given in unary, using a reduction from a Bin packing problem. This shows that minimal execution time is harder to compute than maximal execution time.
Our third contribution consists in defining a class in which the minimal execution time can be computed in (pseudo) PTIME. To do so, we define the class of k-layered negotiations, for k fixed, that is negotiations where nodes can be organized into layers of at most k nodes at the same depth. These negotiations can be executed without remembering more than k nodes at a time. In this case, we show that computing the maximal execution time is PTIME, even if the negotiation is neither deterministic nor sound. The algorithm, not based on reduction rules, uses the k-layer restriction in order to navigate in the negotiation while considering only a polynomial number of configurations. For minimal execution time, we provide a pseudo PTIME algorithm, that is PTIME if constants are given in unary. Finally, we show that the size of constants do matter: deciding whether the minimal execution time of a k-layered negotiation is less than T is NP-complete, when T is given in binary. We show this by reducing from a Knapsack problem, yet again emphasizing that the minimal execution time of a negotiation is harder to compute than its maximal execution time.
This paper is organized as follows. Section 2 introduces the key ingredients of negotiations, determinism and soundness, known results in the untimed setting, and provides our running example modeling the Brexit negotiation. Section 3 introduces time in negotiations, gives a semantics to this new model, and formalizes several decision problems on maximal and minimal durations of runs in timed negotiations. We recall the main results of the paper in Section 4. Then, Section 5 considers timed execution problems for deterministic negotiations, Section 6 for sound negotiations, and section 7 for layered negotiations. Proof details for the last three sections are given in an extended version of this paper [1].

Negotiations: Definitions and Brexit example
In this section, we recall the definition of negotiations, of some subclasses (acyclic and deterministic), as well as important problems (soundness and reachability).

Definition 1 (Negotiation [6, 10]).
A negotiation over a finite set of processes P is a tuple N = (N, n 0 , n f , X ), where: -N is a finite set of nodes. Each node is a pair n = (P n , R n ) where P n ⊆ P is a non empty set of processes participating in node n, and R n is a finite set of outcomes of node n (also called results), with R n f = {r f }. We denote by R the union of all outcomes of nodes in N . -n 0 is the first node of the negotiation and n f is the final node. Every process in P participates in both n 0 and n f . -For all n ∈ N , X n : P n × R n → 2 N is a map defining the transition relation from node n, with X n (p, r) Intuitively, at a node n = (P n , R n ) in a negotiation, all processes of P n have to agree on a common outcome r chosen from R n . Once this outcome r is chosen, every process p ∈ P n is ready to move to any node prescribed by X (n, p, r). A new node m can only start when all processes of P m are ready to move to m. Example 1. We illustrate negotiations by considering a simplified model of the Brexit negotiation, see Figure 1. There are 3 processes, P = {EU, P M, P a}. At first EU decides whether or not to enforce a backstop in any deal (outcome backstop) or not (outcome no-backstop). In the meantime, P M decides to proroge P a, and P a can choose or not to appeal to court (outcome court/no court). If it goes to court, then P M and P a will take some time in court (c-meet, defend), before P M can meet EU to agree on a deal. Otherwise, P a goes to recess, and P M can meet EU directly. Once EU and P M agreed on a deal, P M tries to convince P a to vote the deal. The final outcome is whether the deal is voted, or whether Brexit is delayed.

Definition 2 (Deterministic negotiations).
A process p ∈ P is deterministic iff, for every n ∈ N and every outcome r of n, X (n, p, r) is a singleton. A negotiation is deterministic iff all its processes are deterministic. It is weakly nondeterministic [9] (called weakly deterministic in [3]) iff, for every node n, one of the processes in P n is deterministic. Last, it is very weakly non-deterministic [9] (called weakly deterministic in [6]) iff, for every n, every p ∈ P n and every outcome r of n, there exists a deterministic process q such that q ∈ P n for every n ∈ X (n, p, r). In deterministic negotiations, once an outcome is chosen, each process knows the next node it will be involved in. In (very-)weakly non-deterministic negotiations, the next node might depend upon the outcome chosen in other nodes by other processes. However, once the outcomes have been chosen for all current nodes, there is only one next node possible for each process. Observe that the class of deterministic negotiations is isomorphic to the class of free choice workflow nets [10]. In Example 1, the Brexit negotiation is non-deterministic, because process P M is non-deterministic. Indeed, consider outcomes c-meet: it allows two nodes, according to whether the backstop is enforced or not, which is a decision taken by process EU .
Semantics: A configuration [3] of a negotiation is a mapping M : P → 2 N . Intuitively, it tells for each process p the set M (p) of nodes p is ready to engage in. The semantics of a negotiation is defined in terms of moves from a configuration to the next one. The initial M 0 and final M f configurations, are given by M 0 (p) = {n 0 } and M f (p) = ∅ respectively for every process p ∈ P . A configuration M enables node n if n ∈ M (p) for every p ∈ P n . When n is enabled, a decision at node n can occur, and the participants at this node choose an outcome r ∈ R n . The occurrence of (n, r) produces the configuration M given by M (p) = X (n, p, r) for every p ∈ P n and M (p) = M (p) for remaining processes in P \ P n . Moving from M to M after choosing (n, r) is called a step, denoted M n,r − − → M . A run of N is a sequence (n 1 , r 1 ), (n 2 , r 2 )...(n k , r k ) such that there is a sequence of configurations M 0 , M 1 , . . . , M k and every (n i , r i ) is a step between M i−1 and M i . A run starting from the initial configuration and ending in the final configuration is called a final run. By definition, its last step is (n f , r f ).
An important class of negotiations in the context of timed negotiations is acyclic negotiations, where infinite sequence of steps is impossible: Definition 3 (Acyclic negotiations). The graph of a negotiation N is the labeled graph G N = (V, E) where V = N , and E = {((n, (p, r), n ) | n ∈ X (n, p, r)}, with pairs of the form (p, r) being the labels. A negotiation is acyclic iff its graph is acyclic. We denote by P aths(G N ) the set of paths in the graph of a negotiation. These paths are of form π = (n 0 , The Brexit negotiation of Fig.1 is an example of acyclic negotiation. Despite their apparent simplicity, negotiations may express involved behaviors as shown with the Brexit example. Indeed two important questions in this setting are whether there is some way to reach a final node in the negotiation from (i) the initial node and (ii) any reachable node in the negotiation.

A negotiation is sound iff every run from the initial configuration can be extended to a final run. The problem of soundness is to check if a given negotiation is sound. 2. The problem of reachability asks if a given negotiation has a final run.
Notice that the Brexit negotiation of Fig.1 is sound (but not deterministic). It seems hard to preserve the important features of this negotiation while being both sound and deterministic. The problem of soundness has received considerable attention. We summarize the results about soudness in the next theorem: Determining whether a negotiation is sound is PSPACE-Complete. For (very-)weakly non-deterministic negotiations, it is co-NP-complete [9]. For acyclic negotiations, it is in DP and co-NP-Hard [6]. Determining whether an acyclic weakly non-deterministic negotiation is sound is in PTIME [3,9]. Finally, deciding soundness for deterministic negotiations is NLOGSPACE-complete [9].
Checking reachability is NP-complete, even for deterministic acyclic negotiations (surprisingly, we did not find this result stated before in the literature):

Proposition 1. Reachability is NP-complete for acyclic negotiations, even if the negotiation is deterministic.
Proof (sketch). One can guess a run of size ≤ |N | in polynomial time, and verify if it reaches n f , which gives the inclusion in NP. The hardness part comes from a reduction from 3-CNF-SAT that can be found in the proof of Theorem 3.

k-Layered Acyclic Negotiations
We introduce a new class of negotiations which has good algorithmic properties, namely k-layered acyclic negotiations, for k fixed. Roughly speaking, nodes of a k-layered acyclic negotiations can be arranged in layers, and these layers contain at most k nodes. Before giving a formal definition, we need to define the depth of nodes in N .
First, a path in a negotiation is a sequence of nodes n 0 . . . n such that for all i ∈ {1, . . . , − 1}, there exists p i , r i with n i+1 ∈ X (n i , p i , r i ). The length of a path n 0 , . . . , n is . The depth depth(n) of a node n is the maximal length of a path from n 0 to n (recall that N is acyclic, so this number is always finite).

Definition 5.
An acyclic negotiation is layered if for all node n, every path reaching n has length depth(n). An acyclic negotiation is k-layered if it is layered, and for all ∈ N, there are at most k nodes at depth .
The Brexit example of Fig. 1 is 6-layered. Notice that a layered negotiation is necessarily k-layered for some k ≤ |N | − 2. Note also that we can always transform an acyclic negotiation N into a layered acyclic negotiation N , by adding dummy nodes: for every node m ∈ X (n, p, r) with depth(m) > depth(n)+ 1, we can add several nodes n 1 , . . . n with = depth(m) − (depth(n) + 1), and processes P ni = {p}. We compute a new relation X such that X (n, p, r) = {n 1 }, X (n , p, r) = {m} and for every i ∈ 1.. − 1, X (n i , p, r) = n i+1 . This transformation is polynomial: the resulting negotiation is of size up to |N | × |X | × |P |. The proof of the following Theorem can be found in [1].

Theorem 2.
Let k ∈ N + . Checking reachability or soundness for a k-layered acyclic negotiation N can be done in PTIME.

Timed Negotiations
In many negotiations, time is an important feature to take into account. For instance, in the Brexit example, with an initial node starting at the begining of September 2019, there are 9 weeks to pass a deal till the 31 st October deadline.
We extend negotiations by introducing timing constraints on outcomes of nodes, inspired by timed Petri nets [14] and by the notion of negotiations with costs [10]. We use time intervals to specify lower and upper bounds for the duration of negotiations. More precisely, we attach time intervals to pairs (n, r) where n is a node and r an outcome. In the rest of the paper, we denote by I the set of intervals with endpoints that are non-negative integers or ∞. For convenience we only use closed intervals in this paper (except for ∞), but the results we show can also be extended to open intervals with some notational overhead. Intuitively, outcome r can be taken at a node n with associated time interval [a, b] only after a time units have elapsed from the time all processes contributing to n are ready to engage in n, and at most b time units later.

Definition 6.
A timed negotiation is a pair (N , γ) where N is a negotiation, and γ : N ×R → I associates an interval to each pair (n, r) of node and outcome such that r ∈ R n . For a given node n and outcome r, we denote by γ − (n, r) (resp. γ + (n, r)) the lower bound (resp. the upper bound) of γ(n, r).

Semantics:
A timed valuation is a map μ : P → R ≥0 that associates a nonnegative real value to every process. A timed configuration is a pair (M, μ) where M is a configuration and μ a timed valuation. There is a timed step from (M, μ) Intuitively a timed step (M, μ) (n,r) − −− → (M , μ ) depicts a decision taken at node n, and how long each process of P n waited in that node before taking decision (n, r). The last process engaged in n must wait for a duration contained in γ(n, r). However, other processes may spend a time greater than γ + (n, r).
where M 0 is the initial configuration, μ 0 (p) = 0 for every p ∈ P , and each Notice that we only attached timing to processes, not to individual steps. With our definition of runs, timing on steps may not be monotonous (i.e., nondecreasing) along the run, while timing on processes is. Viewed by the lens of concurrent systems, the timing is monotonous on the partial orders of the system rather than the linearization. It is not hard to restrict paths, if necessary, to have a monotonous timing on steps as well. In this paper, we are only interested in execution time, which does not depend on the linearization considered.
Given a timed negotiation N , we can now define the minimum and maximum execution time, which correspond to optimistic or pessimistic views: Given T ∈ N, the main problems we consider in this paper are the following: -The mintime problem, i.e., do we have mintime(N ) ≤ T ?.
In other words, does there exist a final timed run ρ with δ(ρ) ≤ T ? -The maxtime problem, i.e., do we have maxtime(N ) ≤ T ?.
In other words, does δ(ρ) ≤ T for every final timed run ρ?
These questions have a practical interest : in the Brexit example, the question "is there a way to have a vote on a deal within 9 weeks ?" is indeed a minimum execution time problem. We also address the equality variant of these decision problems, i.e., mintime(N ) = T : is there a final run of N that terminates in exactly T time units and no other final run takes less than T time units? Similarly for maxtime(N ) = T . Example 3. We use Fig. 1 to show that it is not easy to compute the minimal execution time, and in particular one cannot use the algorithm from [10] to compute it. Consider the node n with P n = {P M, P a} and R n = {court, no court}. If the outcome is court, then P M needs 2 weeks before (s)he can talk to EU and P a needs at least 3 weeks before he can debate. However, if the outcome is no court, then P M need not wait before (s)he can talk to EU , but P a wastes 5 weeks in recess. This means that one needs to remember different alternatives which could be faster in the end, depending on the future. On the other hand, the algorithm from [10] attaches one minimal time to process P a, and one minimal time to process P M. No matter the choices (0 or 2 for P M and 3 or 5 for P a), there will be futures in which the chosen number will over or underapproximate the real minimal execution time (this choice is not explicit in [10]) 4 . For maximum execution time, it is not an issue to attach to each node a unique maximal execution time. The reason for the asymmetry between minimal and maximal execution times of a negotiation is that the execution time of a path is max p∈P μ k (p), for μ k the last timed valuation, which breaks the symmetry between min and max.

High level view of the main results
In this section, we give a high-level description of our main results. Formal statements can be found in the sections where they are proved. We gather in Fig. 2 the precise complexities for the minimal and the maximal execution time problems for 3 classes of negotiations that we describe in the following. Since we are interested in minimum and maximum execution time, cycles in negotiations can be either bypassed or lead to infinite maximal time. Hence, while we define timed negotiations in general, we always restrict to acyclic negotiations (such as Brexit) while stating and proving results.
In [10], a PTIME algorithm is given to compute different costs for negotiations that are both sound and deterministic. One limitation of this result is that it cannot compute the minimum execution time, as explained in Example 3. A second limitation is that the class of sound and deterministic negotiations is quite restrictive: it cannot model situations where the next node a process participates in depends on the outcome from another process, as in the Brexit example. We thus consider classes where one of these restrictions is dropped.
We first consider (Section 5) negotiations that are deterministic, but without the soundness restriction. We show that for this class, no timed problem we consider can be solved in PTIME (unless NP=PTIME). Further, we show that the equality problems (maxtime/mintime(N ) = T ), are complete for the complexity class DP, i.e., at the second level of the Boolean Hierarchy [15].
We then consider (Section 6) the class of negotiations that are sound, but not necessarily deterministic. We show that maximum execution time can be solved in PTIME, and propose a new algorithm. However, the minimum execution time cannot be computed in PTIME (unless NP=PTIME). Again for the mintime equality problem we have a matching DP-completeness result. Finally, in order to obtain a polytime algorithm to compute the minimum execution time, we consider the class of k-layered negotiations (see Section 7): Given k ∈ N, we can show that maxtime(N ) can be computed in PTIME for k-layered negotiations. We also show that while the mintime(N ) ≤ T ? problem is weakly NP-complete for k-layered negotiations, we can compute mintime(N ) in pseudo-PTIME, i.e. in PTIME if constants are given in unary.

Deterministic Negotiations
We start by considering the class of deterministic acyclic negotiations. We show that both maximal and minimal execution times cannot be computed in PTIME (unless NP=PTIME), as the threshold problems are (co-)NP-complete.

Theorem 3. The mintime(N ) ≤ T decision problem is NP complete, and the maxtime(N ) ≤ T decision problem is co-NP-complete for acyclic deterministic timed negotiations.
Proof. For mintime(N ) ≤ T , containment in NP is easy: we just need to guess a run ρ (of polynomial size as N is acyclic), consider the associated timed run ρ − where all decisions are taken at their earliest possible dates, and check whether δ(ρ − ) ≤ T , which can be done in time O (|N |+log T ).
For the hardness, we give the proof in two steps. First, we start with a proof of Proposition 1 that reachability problem is NP-hard using reduction of 3-CNF SAT, i.e., given a formula φ, we build a deterministic negotiation N φ s.t. φ is satisfiable iff N φ has a final run. In a second step, we introduce timings on this negotiation and show that mintime(N φ ) ≤ T iff φ is satisfiable.
Step 1: Reducing 3-CNF-SAT to Reachability problem. Given a Boolean formula φ with variables v i , 1 ≤ i ≤ n and clauses c j , 1 ≤ j ≤ m, for each variable v i we define the sets of clauses S i,t = {c j | v i is present in c j } and S i,f = {c j | ¬v i is present in c j }. Clauses in S i,t and S i,f are naturally ordered: c i < c j iff i < j. We denote these elements S i,t (1) < S i,t (2) < . . .. Similarly for set S i,f . Now, we construct a negotiation N φ (as depicted in Figure 3) with a process V i for each variable v i and a process C j for each clause c j : -Initial node n 0 has a single outcome r taking each process C j to node Lone cj , and each process V i to node Lone vi . -Lone cj has three outcomes: if literal v i ∈ c j , then t i is an outcome, taking C j to P air cj ,vi , and if literal ¬v i ∈ c j , then f i is an outcome, taking C j to P air cj ,¬vi . -The outcomes of Lone vi are true and false. Outcome true brings V i to node T lone vi,1 and outcome false brings V i to node F lone vi,1 . -We have a node T lone vi,j for each j ≤ |S i,t | and F lone vi,j for each j ≤ |S i,f |, with V i as only process. Let c r = S i,t (j). Node T lone vi,j has two outcomes vton bringing V i to T lone vi,j+1 (or n f if j = |S i,t |), and vtoc i,r bringing V i to P air cr,vi . The two outcomes from F lone vi,j are similar.
Timing is [0, 0] whereever not mentioned -Node P air cr,vi has V i and C r as its processes and one outcome ctof which takes process C r to final node n f and process V i to T lone vi,j+1 (with c r = S i,t (j)), or to n f if j = |S i,t |. Node P air cr,¬vi is defined in the same way from F lone vi,j .
With this we claim that N φ has a final run iff φ is satisfiable which completes the first step of the proof. We give a formal proof of this claim in Appendix A of [1]. Observe that the negotiation N φ constructed is deterministic and acyclic (but it is not sound).
Step 2 : Before we introduce timing on N φ , we introduce a new outcome r at n 0 which takes all processes to n f . Now, the timing function γ associated with N φ is: γ(n 0 , r) = [2,2] and γ(n 0 , r ) = [3,3] and γ(n, r) = [0, 0], for all node n = n 0 and all r ∈ R n . Then, mintime(N φ ) ≤ 2 iff φ has a satisfiable assignment: if mintime(N φ ) ≤ 2, there is a run with decision r taken at n 0 which is final. But existence of any such final run implies satisfiability of φ. For reverse implication, if φ is satisfiable, then the corresponding run for satisfying assignment takes 2 time units, which means that mintime(N φ ) ≤ 2.
Similarly, we can prove that the MaxTime problem is co-NP complete by changing γ(n 0 , r ) = [1,1] and asking if maxtime(N φ ) > 1 for the new N φ . The answer will be yes iff φ is satisfiable.
We now consider the related problem of checking if mintime(N ) = T (or if maxtime(N ) = T ). These problems are harder than their threshold variant under usual complexity assumptions: they are DP-complete (Difference Polynomial time class, i.e., second level of the Boolean Hierarchy, defined as intersection of a problem in NP and one in co-NP [15]). Proof. We only give the proof for mintime (the proof for maxtime is given in Appendix A of [1]). Indeed, it is easy to see that this problem is in DP, as it can be written as mintime(N ) ≤ T which is in NP and ¬(mintime(N ) ≤ T − 1)), which is in co-NP. To show hardness, we use the negotiation constructed in the above proof as a gadget, and show a reduction from the SAT-UNSAT problem (a standard DP-complete problem).
The SAT-UNSAT Problem asks given two Boolean expressions φ and φ , both in CNF forms with three literals per clause, is it true that φ is satisfiable and φ is unsatisfiable? SAT-UNSAT is known to be DP-complete [15]. We reduce this problem to mintime(N ) = T .
Given φ, φ , we first make the corresponding negotiations N φ and N φ as in the previous proof. Let n 0 and n f be the initial and final nodes of N φ and n 0 and n f be the initial and final nodes of N φ . (Similarly, for other nodes we write above the nodes to signify they belong to N φ .) In the negotiation N φ , we introduce a new node n all , in which all the processes participate (see Figure 4). The node n all has a single outcome r all which sends all the processes to n f . Also, for node n 0 , apart from the outcome r which sends all processes to different nodes, there is another outcome r all which sends all the processes to n all . Now we merge the nodes n f and n 0 and call the merged node n sep . Also nodes n 0 and n f now have all the processes of N φ and N φ participating in them. This merged process gives us a new negotiation N φ,φ in which the structure above n sep is same as N φ while below it is same as N φ . Node n sep now has all the processes of N φ and N φ participating in it. The outcomes of n sep will be same as that of n 0 (r all , r). For both the outcomes of n sep the processes corresponding to N φ directly go to n f of the N φ,φ . Similarly n 0 of N φ,φ which is same n 0 of N φ, sends processes corresponding to N φ directly to n sep for all its outcomes. We now define timing function γ for N φ,φ which is as follows: γ(Lone vi , r) = [1, 1] for all v i ∈ φ and r ∈ {true, false}, γ(n all , r all ) = [2,2] and γ(n, r) = [0, 0] for all other outcomes of nodes. With this construction, one can conclude that mintime(N φ,φ ) = 2 iff φ is satisfiable and φ is unsatisfiable (see [1] for details). This completes the reduction and hence proves DP-hardness.  Finally, we consider a related problem of computing the min and max time. To consider the decision variant, we rephrase this problem as checking whether an arbitrary bit of the minimum execution time is 1. Perhaps surprisingly, we obtain that this problem goes even beyond DP, the second level of the Boolean Hierarchy and is in fact hard for Δ P 2 (second level of the polynomial hierarchy), which contains the entire Boolean Hierarchy. Formally, Theorem 4. Given an acyclic deterministic timed negotiation and a positive integer k,computing the k th bit of the maximum/minimum execution time is Finally, we remark that if we were interested in the optimization variant and not the decision variant of the problem, the above proof can be adapted to show that these variants are OptP-complete (as defined in [13]). But as optimization is not the focus of this paper, we avoid formal details of this proof.

Sound Negotiations
Sound negotiations are negotiations in which every run can be extended to a final run, as in Fig. 1. In this section, we show that maxtime(N ) can be computed in PTIME for sound negotiations, hence giving PTIME complexities for the maxtime(N ) ≤ T ? and maxtime(N ) = T ? questions. However, we show that mintime(N ) ≤ T is NP-complete for sound negotiations, and that mintime(N ) = T is DP-complete, even if T is given in unary.
Lemma 1 gives a way to evaluate the maximal execution time. This amounts to finding a path of maximal weight in an acyclic graph, which is a standard PTIME problem that can be solved using standard max-cost calculation. A direct consequence is that maxtime(N ) ≤ T and maxtime(N ) = T problems can be solved in polynomial time when N is sound. Notice that if N is deterministic but not sound, then Lemma 1 does not hold: we only have an inequality.
We now turn to mintime(N ). We show that it is strictly harder to compute for sound negotiations than maxtime(N ).

Theorem 5. mintime(N ) ≤ T is NP-complete in the strong sense for sound acyclic negotiations, even if N is very weakly non-deterministic.
Proof (sketch). First, we can decide mintime(N ) ≤ T in NP. Indeed, one can guess a final (untimed) run ρ of size ≤ |N |, consider ρ − the timed run corresponding to ρ where all outcomes are taken at the earliest possible dates, and compute in linear time δ(ρ − ), and check that δ(ρ − ) ≤ T .
The hardness part is obtained by reduction from the Bin Packing problem. The reduction is similar to Knapsack, that we will present in Thm. 7. The difference is that we use bins in parallel, rather than 2 processes, one for the weight and one for the value. The hardness is thus strong, but the negotiation is not k-layered for a bounded k (it is 2 + 1 bounded, with depending on the input). A detailed proof is given in Appendix B of [1].
We show that mintime(N ) = T is harder to decide than mintime(N ) ≤ T , with a proof similar to Prop. 2.

Proposition 4. The mintime(N ) = T ? decision problem is DP-complete for sound acyclic negotiations, even if it is very weakly non-deterministic.
An open question is whether the minimal execution time can be computed in PTIME if the negotiation is both sound and deterministic. The reduction from Bin Packing does not work with deterministic (and sound) negotiations.

k-Layered Negotiations
In this section, we consider k-layeredness, a syntactic property that can be efficiently verified (see Section 2).

Algorithmic properties
Let k be a fixed integer. We first show that the maximum execution time can be computed in PTIME for k-layered negotiations. Let N i be the set of nodes at layer i. We define for every layer i the set S i of subsets of nodes X ⊆ N i which can be jointly enabled and such that for every process p, there is exactly one node n(X, p) in X with p ∈ n(X, p). An element X in S i is a subset of nodes that can be selected by solving all non-determnism with an appropriate choice of outcomes. Formally, we define S i inductively. We start with S 0 = {n 0 }. We then define S i+1 from the contents of layer S i : we have Y ∈ S i+1 iff n∈Y P n = P and there exist X ∈ S i and an outcome r m ∈ R m for every m ∈ X, such that n ∈ X (n(X, p), p, r m ) for each n ∈ Y and p ∈ P n . Theorem 6. Let k ∈ N + . Computing the maximum execution time for a klayered acyclic negotiation N can be done in PTIME. More precisely, the worstcase time complexity is O(|P | · |N | k+1 ).
Proof (Sketch). The first step is to compute S i layer by layer, by following its inductive definition. The set S i is of size at most 2 k , as |N i | < k by definition of k-layeredness. Knowing S i , it is easy to build S i+1 by induction. This takes time in O(|P ||N | k+1 ) : We need to consider all k-uples of outcomes for each layer. There can be |N | k such tuples. We need to do that for all processes (|P |), and for all layers (at most |N |).
We then keep for each subset X ∈ S i and each node n ∈ X, the maximal time f i (n, X) ∈ N associated with n and X. From S i+1 and f i , we inductively compute f i+1 in the following way: for all X ∈ S i with successor Y ∈ S i+1 for outcomes (r p ) p∈P , we denote f i+1 (Y, n, X) = max p∈P (n) f i (X, n(X, p)) + γ + (n(X, p), r p ). If there are several choices of (r p ) p∈P leading to the same Y , we take r p with the maximal f i (X, n(X, p)) + γ + (n(X, p), r p ). We then define f i+1 (Y, n) = max X∈Si f i+1 (Y, n, X). Again, the initialization is trivial, with We can bound the complexity precisely by O(d(N ) · C(N ) · ||R|| k * ), with: d(N ) ≤ |N | the depth of n f , that is the number of layers of N , and ||R|| is the maximum number of outcomes of a node, -C(N ) = max i |S i | ≤ 2 k , which we will call the number of contexts of N , and which is often much smaller than 2 k . -k * = max X∈ i Si |X| ≤ k. We say that N is k * -thread bounded, meaning that there cannot be more that k * nodes in the same context X of any layer. Usually, k * is strictly smaller than k = max i |N i |, as N i = X∈Si X.
Consider again the Brexit example Figure 1. We have (k + 1) = 7, while we have the depth d(N ) = 6, the negotiation is k * = 3-thread bounded (k * is bounded by the number of processes), ||R|| = 2, and the number of contexts is at most C(N ) = 4 (EU chooses to enforce backstop or not, and Pa chooses to go to court or not).

Minimal Execution Time
As with sound negotiations, computing minimal time is much harder than computing the maximal time for k-layered negotiations: Theorem 7. Let k ≥ 6. The Min ≤ T problem is NP-Complete for k-layered acyclic negotiations, even if the negotiation is sound and very weakly non-deterministic.
Proof. One can guess in polynomial time a final run of size ≤ |N |. If the execution time of this final run is smaller than T then we have found a final run witnessing mintime(N ) ≤ T . Hence the problem is in NP.
Let us now show that the problem is NP-hard. We proceed by reduction from the Knapsack decision problem. Let us consider a set of items U = {u 1 , . . . u n } of respective values v 1 , . . . v n and weight w 1 , . . . , w n and a knapsack of maximal capacity W . The knapsack problem asks, given a value V whether there exists a subset of items U ⊆ U such that ui∈U v i ≥ V and such that ui∈U w i ≤ W . We build a negotiation with 2n processes P = {p 1 , . . . p 2n }, as shown in Fig. 5. Intuitively, p i , i ≤ n will serve to encode the value of selected items as timing, while p i , i > n will serve to encode the weight of selected items as timing.
Concerning timing constraints for outcomes we do the following: Outcomes 0, yes and no are associated with [0, 0]. Outcome c i is associated with [w i , w i ], the weight of u i . Last, outcome b i is associated with a more complex function, where v max is the largest value of an item, and V is the total value we want to reach at least. Also, we set [ (vmax)W n·vmax−V , vmaxW n·vmax−vi ] for outcome a i . We set T = W , the maximal weight of the knapsack. Now, consider a final run ρ in N . The only choices in ρ are outcomes yes or no from C 1 , . . . , C n . Let I be the set of indices such that yes is the outcome from all C i in this path. We obtain δ(ρ) = max( i / ∈I a i + i∈I b i , i∈I c i ). We have δ(ρ) ≤ T = W iff i∈I w i ≤ W , that is the sum of the weights is lower than W , and i / Hence, there exists a path ρ with δ(ρ) ≤ T = W iff there exists a set of items of weight less than W and of value more than V .
It is well known that Knapsack is weakly NP-hard, that is, it is NP-hard only when weights/values are given in binary. This means that Thm. 7 shows that minimum execution time ≤ T is NP-hard only when T is given in binary. We can actually show that for k-layered negotiations, the mintime(N ) ≤ T problem can be decided in PTIME if T is given in unary (i.e. if T is not too large): Theorem 8. Let k ∈ N. Given a k-layered negotiation N and T written in unary, one can decide in PTIME whether the minimum execution time of N is ≤ T . The worst-case time complexity is O(|N | · |P | · (T · |N |) k ).
Proof. We will remember for each layer i a set T i of functions τ from nodes N i of layer i to a value in {1, . . . , T, ⊥}. Basically, we have τ ∈ T i if there exists a path ρ reaching X = {n ∈ N i | τ (n) = ⊥}, and this path reaches node n ∈ X after τ (n) time units. As for S i , for all p, we should have a unique node n(τ, p) such that p ∈ n(τ, p) and τ (n(τ, p)) = ⊥. Again, it is easy to initialize T 0 = {τ 0 }, with τ 0 (n 0 ) = 0, and τ 0 (n) = ⊥ for all n = n 0 .
Inductively, we build T i+1 in the following way: τ i+1 ∈ T i+1 iff there exists a τ i ∈ T i and r p ∈ R n(τi,p) for all p ∈ P such that for all n with τ i+1 (n) = ⊥, we have τ i+1 (n) = max p τ − i (n(τ i , p)) + γ(n(τ i , p), r p ). We have that the minimum execution time for N is min τ ∈Tn τ (n τ ), for n the depth of n f . There are at most T k functions τ in any T i , and there are at most |N | layers to consider, giving the complexity.
As with Thm. 6, we can more accurately state the complexity as O(d(N ) · C(N ) · ||R|| k * · T k * −1 ). The k * − 1 is because we only need to remember minimal functions τ ∈ T i : if τ (n) ≥ τ (n) for all n, then we do not need to keep τ in T i . In particular, for the knapsack encoding in the proof of Thm. 7, we have k * = 3, ||R|| = 2 and C(N ) = 4. Notice that if k is part of the input, then the problem is strongly NP-hard, even if T is given in unary, as e.g. encoding bin packing with bins result to a 2 + 1-layered negotiations.

Conclusion
In this paper, we considered timed negotiations. We believe that time is of the essence in negotiations, as examplified by the Brexit negotiation. It is thus important to be able to compute in a tractable way the minimal and maximal execution time of negotiations. We showed that we can compute in PTIME the maximal execution time for acyclic negotiations that are either sound or k-layered, for k fixed. We showed that we cannot compute in PTIME the maximal execution time for negotiations that are not sound nor k-layered, even if they are deterministic and acyclic (unless NP=PTIME). We also showed that surprisingly, computing the minimal execution time is much harder, with strong NP-hardness results in most of the classes of negotiations, contradicting a claim in [10]. We came up with a new reasonable class of negotiations, namely k-layered negotiations, which enjoys a pseudo PTIME algorithm to compute the minimal execution time. That is, the algorithm is PTIME when the timing constants are given in unary. We showed that this restriction is necessary, as the problem becomes NP-hard for constants given in binary, even when the negotiation is sound and very weakly non-deterministic. The problem to know whether the minimal execution time can be computed in PTIME for deterministic and sound negotiation remains open.