PRELIMINARY VERSION: DO NOT CITE The AAAI Digital Library will contain the published version some time after the conference
Faster and Better Simple Temporal Problems
Dario Ostuni1, Alice Raffaele2, Romeo Rizzi1, Matteo Zavatteri1* 1University of Verona, Department of Computer Science, Strada Le Grazie 15, 37134 Verona (Italy) 2University of Trento, Department of Mathematics, Via Sommarive 14, 38123 Povo (Italy) {dario.ostuni, romeo.rizzi, matteo.zavatteri}@univr.it, [email protected]
Abstract satisfied? TCSP is NP-complete (Dechter, Meiri, and Pearl 1991). In this paper we give a structural characterization and ex- tend the tractability frontier of the Simple Temporal Problem The Simple Temporal Problem (STP) is the fragment of (STP) by defining the class of the Extended Simple Temporal TCSP whose set of constraints consists of atoms of the form Problem (ESTP), which augments STP with strict inequal- y − x ∈ [`, u] only. Historically, STP allows for two rep- ities and monotone Boolean formulae on inequations (i.e., resentations: the interval based one (as we just discussed formulae involving the operations of conjunction, disjunction above) or a set of inequalities y − x ≤ k where x, y are and parenthesization). A polynomial-time algorithm is pro- variables and k ∈ R. While these are equivalent (y − x ≤ k vided to solve ESTP, faster than previous state-of-the-art al- can be written as y − x ∈ [−∞, k]), the second represen- gorithms for other extensions of STP that had been consid- tation is more elementary as y − x ∈ [`, u] amounts to ered in the literature, all encompassed by ESTP. We show the (y − x ≤ u) ∧ (x − y ≤ −`). STP is in P (Dechter, Meiri, practical competitiveness of our approach through a proof-of- concept implementation and an experimental evaluation in- and Pearl 1991). volving also state-of-the-art SMT solvers. The set of constraints of an STP can also be generalized to include strict inequalities y − x < k and inequations y − x 6= k. Of course, any strict inequality y − x < k can be Introduction and Related Work seen as a non-strict inequality y − x ≤ k plus the inequation The Temporal Constraint Satisfaction Problem (TCSP), y − x 6= k. Inequations are useful to model temporal plans originally introduced by (Dechter, Meiri, and Pearl 1991), in which, for example, we require two events not to happen takes as input a finite set of real variables and a finite set at the same time. Koubarakis augmented STP with disjunc- of constraints. Two kinds of constraints are allowed: unary tions on inequations (y1 − x1 6= k1) ∨ · · · ∨ (yn − xn 6= kn) and binary; both can take a disjunctive form. A unary con- in (Koubarakis 1992). He proved tractability of this exten- 4 straint has the form x ∈ [`1, u1] ∨ · · · ∨ [`n, un], where sion by providing an algorithm that runs in O(||C|| ), where x is a variable and `i, ui ∈ R ∪ {−∞, +∞}, −∞ ≤ C is the set of constraints and ||C|| is the number of atoms `i ≤ ui ≤ ∞. A binary constraint has the form y − x ∈ y − x ./ k, ./∈ {≤, 6=} appearing in C. As far as we know, [`1, u1] ∨ · · · ∨ [`n, un], where x and y are variables and, this was still the bound for this problem. 6= again, `i, ui ∈ R ∪ {−∞, +∞}, −∞ ≤ `i ≤ ui ≤ ∞. Gerevini and Cristani defined STP , which is a restric- Regardless of the type of constraint, the corresponding in- tion of (Koubarakis 1992) allowing only simple inequa- volved intervals are disjoint. Note that each unary constraint tions and not disjunctions of these, resulting in the possi- x ∈ [`1, u1] ∨ · · · ∨ [`n, un] can be seen as a binary one bility of handling both sets of strict-inequalities and inequa- x − z ∈ [`1, u1] ∨ · · · ∨ [`n, un] where z is an extra variable tions (Gerevini and Cristani 1997). They provided an algo- on which we impose the unary constraint z ∈ [0, 0]. As such, rithm to solve STP6= that runs in O(n3 + h), where n is the one single unary constraint suffices. Or, we can even relax number of variables and h is the number of inequations (or that one and then consider the solution obtained by sub- O(n3) if there are only strict and non-strict inequalities). As tracting the value of z from that of every other variable. In- far as we know, the result in (Gerevini and Cristani 1997) deed, the solution space of a TCSP without unary constraints was the state of the art for STP6=, still used by more recent is closed under rigid shifting. We remark that binary con- works (e.g., (Broxvall 2002; Montanari et al. 2012; Cooper, straints are disjunctions over the same pair of variables (this Maris, and Regnier´ 2013; Carbonnel and Cooper 2015)). restriction is overcome in (Stergiou and Koubarakis 2000) For more details about temporal reasoning, the interested with the proposal of disjunctive temporal networks). TCSP reader is referred to (Vila 1994; Gennari 1998; Schwalb and asks the following question: does there exist an assignment Vila 1998; Bartak, Morris, and Venable 2014). of real values to the variables such that all constraints are Satisfiability Modulo Theory (SMT) (Barrett et al. 2009) *Corresponding author can address generalizations of the problems mentioned Copyright © 2021, Association for the Advancement of Artificial above by relying on the quantifier-free fragment of the the- Intelligence (www.aaai.org). All rights reserved. ory of real difference logic (QF RDL). QF RDL allows for arbitrary Boolean combinations of atoms y − x ./ k, where Example 1. Let S = (X,C) be the following instance of x, y are real variables and ./∈ {<, ≤, >, ≥, =, 6=}. STP: X := {x1, x2, x3, x4, x5, x6, x7}, In this logic, strict inequalities y − x < k are usually turned into non-strict inequalities y − x ≤ k − ε, with ε C := {x2 − x1 ≤ −2.2, x3 − x2 ≤ −3.5, x1 − x3 ≤ 5.7, treated either numerically (Armando et al. 2005) or symbol- x4 − x5 ≤ 2, x5 − x7 ≤ 1, x7 − x6 ≤ 6, ically as an infinitesimal parameter (Dutertre and de Moura x6 − x4 ≤ −9, x6 − x3 ≤ −3.3, x2 − x4 ≤ −2}. 2006). As far as we know, the latter is the state of the art on difference arithmetic constraints (Dutertre and de Moura Most of the algorithms that solve instances of STP rely on 2006; de Moura, Dutertre, and Shankar 2007). their corresponding directed weighted graph representation. Note that the core algorithms to solve the problems men- Definition 1 (Directed weighted graph). A directed graph tioned above are typically based on tuned versions of short- is a pair (V,A) where V is a set of nodes and A ⊆ V × V est path algorithms or the simplex method, e.g., (SRI Inter- is a set of arcs (or, equivalently, directed edges). A directed national’s Computer Science Laboratory 2020). It is thus in- weighted graph is a triple (V, A, w) where (V,A) is a di- teresting and reasonable, e.g., when developing a more effi- rected graph and w : A 7→ R is a weight function assigning cient procedure to solve STP with strict inequalities, to also a real value to each arc. make a comparison with SMT solvers supporting QF RDL. We write Px,y := h(x, x1),..., (xn, y)i for the path (se- Organization and Contribution quence of arcs) going from x to y through a sequence of dis- tinct nodes. A cycle is a path P where x = y. In case of We start by giving background on STP. Then, we define x,y directed weighted graphs, we write w(P ) for the weight the Extended Simple Temporal Problem (ESTP), in which x,y of the path (i.e., the sum of the weights of the arcs in the we allow for inequalities, strict inequalities and monotone sequence). A path or a cycle P in a weighted graph is Boolean formulae on inequations. We give a characteriza- x,y negative if w(P ) < 0. tion of ESTP. Specifically, we define verification criteria to x,y detect inconsistency or decide consistency of any instance Definition 2 (Constraint graph). Let S = (X,C) be an in- of ESTP. These allow us to provide a strong polynomial- stance of STP. The corresponding constraint graph of S is time algorithm to solve ESTP, which is faster than current the directed weighted graph GS = (X, A, w) where: state-of-the-art algorithms for previously studied extended • A := {(x, y) | y − x ≤ k ∈ C}, and classes of STP. We discuss a proof-of-concept implementa- • w(x, y) := k for each y − x ≤ k ∈ C. tion by comparing several variants of shortest paths algo- rithms. Moreover, we encode our model as a QF RDL for- Figure 1 shows the constraint graph of Example 1. mula since it is well-known that the satisfiability of conjunc- Theorem 1 ((Dechter, Meiri, and Pearl 1991)). An instance tions of atoms y − x ./ k for ./∈ {≤, <} is tractable. We of STP is consistent iff GS has no negative-weight cycle. evaluate our performance against the state-of-the-art SMT solvers that competed in the 15th International Satisfiabil- Deciding whether an instance of STP S = (X,C) is con- ity Modulo Theories Competition — SMT-COMP 2020 — sistent can be done by computing a potential function for for QF RDL (Model Validation Track and Single Query GS, i.e., a function π : X 7→ R such that π(y) − π(x) ≤ Track), (SMT Steering Committee 2020). Computational re- w(x, y) for each (x, y) ∈ A. This feasible potential is a pos- sults confirm the practical competitiveness of our approach, sible solution δ and can be computed by a run of any SSSP which can solve instances close to 3 million variables within algorithm. Since we deal with temporal problems, it is also 100 seconds. Finally, we draw conclusions and discuss fu- reasonable to seek a non-negative π; a guarantee that, unfor- ture work. tunately, we do not get by just computing a feasible poten- tial. However, this is not an issue because potential functions Background are shift-invariant (Cormen et al. 2009). That is, for any fea- sible potential function π and any σ ∈ R, it holds that the In this section we sum up essential information on STP and function defined as π0(x) := π(x) + σ for each x ∈ X is how to efficiently solve it through a reduction to the Single still a feasible potential function. Indeed, for any (x, y) ∈ A: Source Shortest Paths problem (SSSP) (Cormen et al. 2009). Problem 1 (STP). Given π(y) − π(x) ≤ w(x, y) π(y) − π(x) + σ ≤ w(x, y) + σ ( σ ∈ ) • a finite set X of real variables, and for any R • a finite set C of inequalities of the form y − x ≤ k with (π(y) + σ) − (π(x) + σ) ≤ w(x, y) y, x ∈ X and k ∈ R, π0(y) − π0(x) ≤ w(x, y). does there exist a mapping δ : X 7→ R satisfying all con- Example 1 is consistent. Indeed, a potential function π for straints in C? its constraint graph is shown in Figure 1. Thus, a solution is An instance of STP is consistent if such a solution δ ex- δ(x1) := π(x1) = 0, δ(x2) := π(x2) = −2.2, δ(x3) := ists; inconsistent otherwise. We assume that any instance of π(x3) = −5.7, δ(x4) := π(x4) = 0, δ(x5) := π(x5) = STP appearing in this paper has no dominated inequalities, −2, δ(x6) := π(x6) = −9, and δ(x7): π(x7) = −3. where an inequality y − x ≤ k dominates an inequality In case we desire δ to be non-negative, we define δ(x) := 0 0 y − x ≤ k if k < k . π(x) + σ for each x ∈ X, where σ := | minx∈X π(x)| = 9. 0/9 −2.2/6.8 0/9 −2/7 One could fairly wonder whether C≤ and C6= together −2.2 −2 2 subsume C . It is true; indeed, any strict inequality of the x x x x < 1 2 4 5 form y − x < k can be rewritten as a classic inequality y − x ≤ k plus an inequation y − x 6= k. The reason we also −3.5 −9 1 support strict inequalities is because we want to explore their 5.7 structure without masquerading them as the composition of different parts. −3.3 6 x3 x6 x7 We now discuss three independent conditions to identify inconsistent instances of ESTP. It will later turn out that any −5.7/3.3 −9/0 −3/6 instance of ESTP not affected by any of these conditions is consistent. The notion of relaxation of an ESTP instance Figure 1: Constraint graph of Example 1 (ignoring arc col- helps to state these conditions. ors) and Example 2 (considering red arcs too). Near the Definition 3 (Relaxation of an ESTP instance). Let S = nodes, there are two labels, π/π + 9: π (in gray) is the value (X,C ,C ,C ) be an instance of ESTP. The relaxation of of the feasible potential taking x as a source, whereas π +9 ≤ < 6= 1 S is the following instance of STP R = (X ,C ), where (in green) is the corresponding rigidly shifted value. We do R R C := C ∪ {y − x ≤ k | y − x < k ∈ C }. not draw formulae on inequations to keep the figure clear. R ≤ < In other words, the relaxation of S keeps all non-strict in- equalities and turns each strict inequality into a non-strict Extended Simple Temporal Problem inequality. Note that, by construction, R cannot have dom- In (Koubarakis 1992), STP was extended to also handle dis- inated inequalities either. The relaxation of the instance in junctions on inequations. The definition of Extended STP Example 2 is R = (XR,CR), where XR is the same of Ex- (ESTP) generalizes (Koubarakis 1992) by allowing arbi- ample 2 and CR is exactly the set C of Example 1. trary monotone Boolean formulae on inequations, rather Lemma 1. Let S be an instance of ESTP and let GR be than only disjunctions. the constraint graph of its relaxation. If GR has a negative- Problem 2 (ESTP). Given weight cycle, then S is inconsistent. • a finite set X of real variables, Proof. A solution for S would also be a solution for R. This • a finite set C≤ of inequalities of the form y − x ≤ k with cannot exist if GR has a negative-weight cycle (by Theo- y, x ∈ X and k ∈ R, rem 1). • a finite set C< of strict inequalities of the form y − x < k Figure 1 does not contain any negative-weight cycle. with y, x ∈ X and k ∈ R, and Definition 4 (Arc color). Let S = (X,C≤,C<,C6=) be an • a finite set C6= of monotone Boolean formulae on inequa- instance of ESTP and G = (X, A, w) be the constraint tions generated by the grammar F ::= y−x 6= k | F ∧F | R graph of its relaxation. We say that an arc (x, y) in GR is F ∨ F | (F ) with y, x ∈ X and k ∈ R, red if S contains the strict inequality y − x < w(x, y).A does there exist a mapping δ : X 7→ R satisfying all con- path Px,y is red if it contains a red arc. straints in C≤, C< and C6=? That is, given an instance of ESTP S, the red arcs in the Similarly to STP, an instance of ESTP is consistent if such constraint graph of its relaxation GR identify exactly strict a solution δ exists; inconsistent otherwise. inequalities of S. In Figure 1, (x3, x6) and (x4, x2) are red Let S = (X,C≤,C<,C6=) be any instance of ESTP. We since {x6 − x3 < −3.3, x2 − x4 < −2} ⊆ C< in Ex- write y − x ./ k for a generic atom appearing in some con- ample 2. Red arcs allow for the definition of a condition to straint, where ./ ∈ {≤, <, 6=}. We denote by AS the set discover other inconsistent instances of ESTP. To the best of all atoms appearing in S and, similarly, we denote by of our knowledge, this condition has never been identified AF := {y − x 6= k | y − x 6= k ∈ F } ⊆ AS the set before. of atoms of any F ∈ C6=. Lemma 2. Let S be an instance of ESTP and let G be the Moreover, we just write inequality when we do not care R constraint graph of its relaxation. If GR has a zero-weight if it is strict or not, and we still assume that any instance of cycle containing a red arc, then S is inconsistent. ESTP appearing in this paper has no dominated inequalities, where, this time, an inequality y − x ./ k dominates an Proof. Assume that S admits a solution δ and let c := 0 0 0 0 inequality y − x ./ k if either k < k , or ./ is < and ./ is h(x1, x2),..., (xe, xe+1 = x1)i be a zero-weight cycle in 0 ≤ and k = k . GR where (x1, x2) is a red arc. Then δ(x2) − δ(x1) < w(x1, x2) and δ(xi+1) − δ(xi) ≤ w(xi, xi+1), for every Example 2. Let S = (X,C≤,C<,C6=) be the following i = 2, . . . , e. Summing up these inequalities (one for every instance of ESTP: X := {x1, x2, x3, x4, x5, x6, x7}, arc in c), the valuations of δ on the e nodes simplify away C≤ := {x2 − x1 ≤ −2.2, x3 − x2 ≤ −3.5, x1 − x3 ≤ 5.7, and we end up with the contradiction 0 < 0. x4 − x5 ≤ 2, x5 − x7 ≤ 1, x7 − x6 ≤ 6, x6 − x4 ≤ −9} Figure 1 contains two zero-weight cycles: c1 := C := {x − x < −3.3, x − x < −2} < 6 3 2 4 h(x1, x2), (x2, x3), (x3, x1)i and c2 := h(x4, x6), (x6, x7), C6= := {x6 − x1 6= −9 ∧ (x4 − x7 6= 3 ∨ x6 − x5 6= −7.14)}. (x7, x5), (x5, x4)i. Anyway, none of them contains red arcs. We now provide the third (and last) condition to identify 4. Let P := {X1,...,X|P|} be the partition of X coincid- inconsistent instances of ESTP. ing with the set of strongly connected components (SCCs) of D0. Note that each SCC is a rigid component. That is, Definition 5 (Hopeless formula). Let S = (X,C≤,C<, C ) be an instance of ESTP and G be the constraint graph a set of nodes such that, once the value of one of these 6= R nodes is fixed, so are the values of all the other nodes in of its relaxation. A monotone formula F ∈ C6= is said hope- less if F is false under any Boolean evaluation that assigns the same component. false to all y − x 6= k ∈ AF for which GR contains the two 5. Let DP := (P,AP ) be the DAG of the SCCs of D where non-red weighted paths w(Px,y) = k and w(Py,x) = −k. AP := {(Xi,Xj) | Xi,Xj ∈ P,Xi 6= Xj, ∃(x, y) ∈ A , x ∈ X , y ∈ X }. S S has a hopeless 0 i j Lemma 3. Let be an instance of ESTP. If formula, then S is inconsistent. min 1, min |k + π(x) − π(y)| y−x./k∈AS , Proof. Let S = (X,C≤,C<,C6=) be an instance of ESTP |k+π(x)−π(y)|>0 0 ε := and F be a hopeless formula. Let AF be the set of atoms 6. Let |X| . y − x 6= k of F for which GR contains the two non-red 7. Let T := hX1,..., X|P|i be any topological sort of DP . weighted paths w(Px,y) = k and w(Py,x) = −k. Suppose that S is consistent and let δ be a solution for it. Then, δ 8. Define δ as follows: must satisfy F . However, for each atom in A0 we have F δ(x) := π(x) + 0ε for each x ∈ X that δ(y) − δ(x) = k because both δ(y) − δ(x) ≤ k and |P| δ(x) − δ(y) ≤ −k hold. Therefore, none of these atoms can δ(x) := π(x) + 1ε for each x ∈ X|P|−1 be satisfied by δ. But then, by definition of hopeless, δ does ...... not satisfy F either because, even if δ satisfies all remaining atoms — and that is exactly why this check can be done in δ(x) := π(x) + (|P| − 1)ε for each x ∈ X1. polynomial time — F is still false under such an interpreta- tion (contradiction). We claim that δ is a solution for S. Note that we do not need to check atomic constraints involving variables in the same Consider the unique formula on inequations in Ex- SCC. Indeed, for each y − x ./ k ∈ AS with x, y in the i-th ample 2: x4 − x7 6= 3 is the unique atom for SCC, by letting εi := (|P| − i)ε, it holds that: which Figure 1 contains the two non-red weighted paths π(y) − π(x) ./ k ⇔ π(y) − π(x) + εi ./ k + εi w(h(x7, x5), (x5, x4)i) = 3 and w(h(x4, x6), (x6, x7)i) = −3. Thus, any possible solution δ (if any exists) will not sat- ⇔ (π(y) + εi) − (π(x) + εi) ./ k isfy that atom. Anyway, that formula is not hopeless since ⇔ δ(y) − δ(x) ./ k. its remaining atoms could still make it true. To sum up, an inconsistency certificate for an instance S Notice that, due to Lemma 1 and Lemma 2, if ./ is ≤ or < ./ 6= of ESTP is either a negative-weight cycle in GR or a zero- , then the atom always holds. Instead, if is , then the weight cycle containing a red arc in GR or a hopeless for- atom might also not be satisfied; in such a case it must be- mula in S. We are finally in position to define consistency. long to some formula F which has some other atom satisfied (otherwise Lemma 3 would have applied). Theorem 2. An ESTP instance is consistent iff none of the Therefore, what we are really left to prove is that any atom conditions of Lemma 1, Lemma 2 and Lemma 3 applies. y − x ./ k ∈ AS, with y and x belonging to two different SCCs, is satisfied by δ. Let X and X be two different SCCs Proof. Let S = (X,C ,C ,C ) be an instance of ESTP. i j ≤ < 6= with i < j in the topological sort T . Let ε := (|P| − i)ε (⇒) If S is consistent, then none of the conditions of i and ε := (|P| − j)ε be the distances of δ from π for each Lemma 1, Lemma 2 and Lemma 3 applies. In fact, if any j x ∈ X and for each y ∈ X , respectively. did, S would be inconsistent. i j For each type of atom (i.e., for each ./), we consider its (⇐) If none of the conditions of Lemma 1, Lemma 2 and two possible orientations: the right one from X to X and Lemma 3 applies, then S is consistent. To prove it, we build i j the left one from X to X . We rely on the fact that ε < ε , a mapping δ : X 7→ as follows: j i j i R since i < j. We start by considering the right oriented atoms, i.e., those of the form y − x ./ k. 1. Let π be a feasible potential for the constraint graph GR of the relaxation of S. 0 0 Case y − x ≤ k. We highlight that π(y) − π(x) ≤ k holds. 2. Let GR := (X, A, w ) be the reweighted graph obtained 0 If we substitute δ(y) − π(y) for εj and δ(x) − π(x) for from GR where w (x, y) := w(x, y) + π(x) − π(y) for εi, we obtain δ(y) − π(y) < δ(x) − π(x) and thus δ(y) − each (x, y) ∈ A. δ(x) < π(y) − π(x) ≤ k. 0 3. Let A0 := {(x, y) | (x, y) ∈ A, w (x, y) = 0} be the 0 Case y − x < k. Same of Case y − x ≤ k. subset of zero-weight arcs of GR and let D0 := (X,A0) be the corresponding directed acyclic graph (DAG). Note Case y − x 6= k. We have two cases: that a cycle in D0 is a zero-weight cycle in both GR and • If π(y) − π(x) = k, then, by substituting δ(y) − π(y) 0 GR, since the reweighting operation maintains shortest- for εj and δ(x) − π(x) for εi, we obtain δ(y) − π(y) < paths and cycle weights. δ(x)−π(x), implying δ(y)−δ(x) < π(y)−π(x) = k. 0/0.02/9.02 −2.2/−2.18/6.82 0/0/9 −2/−2/7 Algorithm 1: ESTP solver 0 0.2 0 x1 x2 x4 x5 Input: An instance S = (X,C≤,C<,C6=) of ESTP. Output: A solution δ if S is consistent; inconsistent otherwise. 0 0 0 1 if Lemma 1 applies then return inconsistent; 0 2 if Lemma 2 applies then return inconsistent; 0 0 3 if Lemma 3 applies then return inconsistent; x3 x6 x7 4 Compute δ as discussed in the proof of Theorem 2; 5 return δ; −5.7/−5.68/3.32 −9/−9/0 −3/−3/6 (+1ε) (+0ε)
Figure 2: Graphical construction of the solution δ for the Our ESTP solver is summarized in Algorithm 1. instance in Example 2. Node labels have the form π/δ/δ+9, For the instance S in Example 2, Figure 1 shows a fea- where π (in gray) is the feasible potential, δ (in black) is the sible potential π for its relaxation. Figure 2 represents the solution and δ + 9 (in green) is the rigidly shifted value. reweighted graph of that in Figure 1 (considering all ap- pearing arcs). The same Figure also shows the remaining DAGs (ignoring all weights). Specifically, D0 is the DAG consisting of all snake-pattern edges (with its SCCs high- • Otherwise π(y)−π(x) 6= k; since |k+π(x)−π(y)| > 0 lighted in gray), whereas D is the DAG having as nodes and ε −ε < 0, it holds that ε −ε < |k+π(x)−π(y)|. P j i j i the sets X := {x , x , x } and X := {x , x , x , x } By substituting δ(y) − π(y) for ε and δ(x) − π(x) for 1 1 2 3 2 4 5 6 7 j and as unique arc the snake-pattern red one. We consider ε , we get δ(y)−π(y)−δ(x)+π(x) < |k+π(x)−π(y)|. i the topological sort T := hX ,X i. Regarding all atoms By solving the modulus, we get that: 1 2 of S, the smallest |k + π(x) − π(y)| > 0 is due to the atom – If k + π(x) − π(y) > 0, then δ(y) − δ(x) < k. x6 −x5 6= −7.14 in the formula on inequations and its value – Otherwise k + π(x) − π(y) < 0, and then δ(y) − is 0.14. Therefore, ε := 0.02. We compute the mapping δ as δ(x) < −k + 2(π(y) − π(x)) 6= k. follows: we set δ(x) := π(x) + 0ε for each x ∈ X2 and we set δ(x) := π(x) + 1ε for each x ∈ X1. Then, we consider the left oriented atoms, i.e., x − y ./ k. The reader can check that δ(x1) := π(x1) + 1ε = 0.02, δ(x2) := π(x2) + 1ε = −2.18, δ(x3) := π(x3) + 1ε = x − y ≤ k π(x) − π(y) < k Case . We highlight that . In −5.68, δ(x4) := π(x4) + 0ε = 0, δ(x5) := π(x5) + 0ε = fact, if π(x) − π(y) were equal to k, there would exist −2, δ(x ) := π(x )+0ε = −9, and δ(x ) := π(x )+0ε = 0 6 6 7 7 a zero-weight arc (y, x) in the reweighted graph GR and −3 is a solution. In case, δ can be rigidly shifted by 9 to therefore an arc (Xj,Xi) in the DAG of the SCCs DP , make it non-negative. contradicting the topological sort T . Since k + π(y) − Theorem 3. Let S = (X,C≤,C<,C6=) be an instance π(x) > 0 and εj − εi < 0, it holds that εj − εi < k + of ESTP. Let n := |X|, m := |C≤| + |C<| and h := π(y)−π(x). By substituting δ(x)−π(x) for εi and δ(y)− P |AF |. Then, Algorithm 1 runs in time O(nm + h). π(y) for εj, we get δ(x)−π(x)−δ(y)+π(y) < k+π(y)− F ∈C6= π(x) which implies δ(x) − δ(y) < k. Proof. We analyze the steps needed by Algorithm 1. It takes Case x − y < k. Same of Case x − y ≤ k (once again O(nm) to compute a feasible potential of GR or prove that π(x) − π(y) = k cannot hold, otherwise the topological none exists (i.e., checking Lemma 1). This can be done, for sort T would be contradicted). example, by a run of the Bellman-Ford algorithm. Reweight- 0 Case x − y 6= k. We have two cases: ing GR to obtain GR costs O(m) and the computation of D0 is O(n + m). Finding the SCCs of D , along with comput- • If π(x) − π(y) = k, then by substituting δ(x) − π(x) 0 ing a correspondence allowing each node to retrieve its SCC, for ε and δ(y) − π(y) for ε , we obtain δ(y) − π(y) < i j takes O(n + m) (Gabow 2000). Checking Lemma 2 corre- δ(x) − π(x) implying δ(x) − δ(y) > π(x) − π(y) = k. sponds to verify whether there exists any red arc in some • Otherwise π(x)−π(y) 6= k; since |k+π(y)−π(x)| > 0 SCC. That is, for each y − x < k we just need to check and εj −εi < 0, it holds that εj −εi < |k+π(y)−π(x)|. if the SCCs of y and x are the same (because any cycle in By substituting δ(y) − π(y) for εi and δ(x) − π(x) for that SCC including that arc has weight zero). Thus, this step εj we get δ(y)−π(y)−δ(x)+π(x) < |k+π(y)−π(x)|. takes O(m). Likewise, checking Lemma 3 takes O(h) be- By solving the modulus, we get that: cause we need to evaluate each F ∈ C6= under the interpre- – If k + π(y) − π(x) > 0, then δ(y) − δ(x) < k + tation that sets to false all y − x 6= k ∈ AF if and only if y 2(π(y)−π(x)) and thus δ(x)−δ(y) > −k+2(π(x)− and x are in the same SCC and π(y)−π(x) = k. Computing π(y)) 6= k. DP takes O(n + m). To compute ε, scanning all atoms of S – Otherwise k − π(y) + π(x) < 0, then δ(y) − δ(x) < takes O(m + h). Finding a topological sort takes O(n + m) −k and thus δ(x) − δ(y) > k. and finally computing a solution δ from the potential π takes O(n) (also when we make δ non-negative by rigid shifting). Overall, the complexity is O(nm + h). When dealing with strict inequalities only, then h = 0 and CPU Intel Core i7-6700K @ 4.00GHz the bound boils down to O(nm). Notice that this is the time RAM 64 GB DDR4 @ 2133MHz that Bellman-Ford needs to solve even a simple instance of SSD Samsung SSD 850 EVO 1TB STP. This is faster than (Gerevini and Cristani 1997) as their OS Arch Linux – kernel 5.8.5-zen algorithm is based on Floyd-Warshall, whose complexity is CXXFLAGS -O3 -march=native -std=c++17 O(n3) ≥ O(nm) regardless of the density of the graph. Table 1: Benchmark environment. Experimental Evaluation In this section we provide a proof-of-concept implementa- 2020) and SMTInterpol v2.5 (University of Freiburg 2020). tion of our approach, comparing several variants of shortest To encode an instance S = (X,C≤,C<,C6=) of ESTP, paths algorithms. Then, we encode our model as a QF RDL we simply convert it into the QF RDL formula: formula since it is well-known that satisfiability of conjunc- ^ ^ ^ tions of atoms y −x ./ k for ./∈ {≤, <} is tractable. There- y − x ≤ k y − x < k (F ). fore, this experimental evaluation offers a fair comparison1. y−x≤k∈C≤ y−x
1 1 1 1 ) ) 1 1