Skip to main content
Log in

Faster algorithms for quantitative verification in bounded treewidth graphs

  • Published:
Formal Methods in System Design Aims and scope Submit manuscript

Abstract

We consider the core algorithmic problems related to verification of systems with respect to three classical quantitative properties, namely, the mean-payoff, the ratio, and the minimum initial credit for energy property. The algorithmic problem given a graph and a quantitative property asks to compute the optimal value (the infimum value over all traces) from every node of the graph. We consider graphs with bounded treewidth—a class that contains the control flow graphs of most programs. Let n denote the number of nodes of a graph, m the number of edges (for bounded treewidth \(m=O(n)\)) and W the largest absolute value of the weights. Our main theoretical results are as follows. First, for the minimum initial credit problem we show that (1) for general graphs the problem can be solved in \(O(n^2\cdot m)\) time and the associated decision problem in \(O(n\cdot m)\) time, improving the previous known \(O(n^3\cdot m\cdot \log (n\cdot W))\) and \(O(n^2 \cdot m)\) bounds, respectively; and (2) for bounded treewidth graphs we present an algorithm that requires \(O(n\cdot \log n)\) time. Second, for bounded treewidth graphs we present an algorithm that approximates the mean-payoff value within a factor of \(1+\epsilon \) in time \(O(n \cdot \log (n/\epsilon ))\) as compared to the classical exact algorithms on general graphs that require quadratic time. Third, for the ratio property we present an algorithm that for bounded treewidth graphs works in time \(O(n \cdot \log (|a\cdot b|))=O(n\cdot \log (n\cdot W))\), when the output is \(\frac{a}{b}\), as compared to the previously best known algorithm on general graphs with running time \(O(n^2 \cdot \log (n\cdot W))\). We have implemented some of our algorithms and show that they present a significant speedup on standard benchmarks.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

Similar content being viewed by others

References

  1. Almagor S, Boker U, Kupferman O (2013) Formalizing and reasoning about quality. ICALP. LNCS. Springer, New York, pp 15–27

    Google Scholar 

  2. Alur R, D’Antoni L, Deshmukh JV, Raghothaman M, Yuan Y (2013) Regular functions and cost register automata. In: LICS, pp 13–22

  3. Blackburn SM, Garner R, Hoffmann C, Khang AM, McKinley KS, Bentzur R, Diwan A, Feinberg D, Frampton D, Guyer SZ, Hirzel M, Hosking A, Jump M, Lee H, Moss JEB, Phansalkar A, Stefanović D, VanDrunen T, von Dincklage D, Wiedermann B (2006) The DaCapo benchmarks: Java benchmarking development and analysis. In: OOPSLA. ACM, pp 169–190

  4. Bloem R, Chatterjee K, Greimel K, Henzinger TA, Hofferek G, Jobstmann B, Könighofer B, Könighofer R (2014) Synthesizing robust systems. Acta Inf 51(3–4):193–220

    Article  MathSciNet  Google Scholar 

  5. Blumensath A, Colcombet T, Kuperberg D, Parys P, Vanden Boom M (2014) Two-way cost automata and cost logics over infinite trees. In: CSL-LICS, pp 16:1–16:9

  6. Bodlaender HL (1993) A tourist guide through treewidth. Acta Cybern

  7. Bodlaender H (2005) Discovering treewidth. In: SOFSEM: theory and practice of computer science. LNCS. Springer

  8. Bodlaender H, Hagerup T (1995) Parallel algorithms with optimal speedup for bounded treewidth. In: ICALP. LNCS. Springer

  9. Bollig B, Gastin P, Monmege B, Zeitoun M (2014) Pebble weighted automata and weighted logics. ACM Trans Comput Log 15(2):15

    Article  MathSciNet  Google Scholar 

  10. Bouyer P, Fahrenberg U, Larsen KG, Markey N, Srba J (2008) Infinite runs in weighted timed automata with energy constraints. In: FORMATS. LNCS, vol 5215. Springer, pp 33–47

  11. Bouyer P, Markey N, Matteplackel RM (2014) Averaging in LTL. CONCUR. LNCS. Springer, pp 266–280

  12. Brosius D. Java agent for memory measurements. https://github.com/jbellis/jamm

  13. Burns SM (1991) Performance analysis and optimization of asynchronous circuits. Technical report

  14. Cerny P, Henzinger TA, Radhakrishna A (2013) Quantitative abstraction refinement. In: POPL. ACM, pp 115–128

  15. Chatterjee K, Lacki J (2013) Faster algorithms for Markov decision processes with low treewidth. In: CAV. LNCS. Springer

  16. Chatterjee K, Doyen L, Henzinger TA (2010) Quantitative languages. Trans Comput Log

  17. Chatterjee K, Ibsen-Jensen R, Pavlogiannis A (2015) Faster algorithms for quantitative verification in bounded treewidth graphs. In: CAV, pp 140–157

  18. Chatterjee K, Goharshady AK, Ibsen-Jensen R, Pavlogiannis A (2016) Algorithms for algebraic path properties in concurrent systems of constant treewidth components. In: POPL, pp 733–747

  19. Chatterjee K, Henzinger M, Krinninger S, Loitzenbauer V, Raskin MA (2014) Approximating the minimum cycle mean. Theor Comput Sci

  20. Chatterjee K, Ibsen-Jensen R, Pavlogiannis A, Goyal P (2015) Faster algorithms for algebraic path properties in recursive state machines with constant treewidth. In: POPL. ACM

  21. Chatterjee K, Pavlogiannis A, Velner Y (2015) Quantitative interprocedural analysis. In: POPL, pp 539–551

  22. Chaudhuri S, Zaroliagis CD (1995) Shortest paths in digraphs of small treewidth. Sequential algorithms, algorithmica, part I

  23. Colcombet T, Löding C (2010) Regular cost functions over finite trees. In: LICS, pp 70–79

  24. Courcelle B (1990) The monadic second-order logic of graphs. I. Recognizable sets of finite graphs. Inf Comput 85:12–75

    Article  MathSciNet  Google Scholar 

  25. DIMACS implementation challenges. http://dimacs.rutgers.edu/Challenges/

  26. Dasdan A, Gupta R (1998) Faster maximum and minimum mean cycle algorithms for system-performance analysis. IEEE Trans Comput Aided Des Integr Circuits Syst 17:889–899

    Article  Google Scholar 

  27. Dasdan A, Irani SS, Gupta RK (1998) An experimental study of minimum mean cycle algorithms. Technical report

  28. Droste M, Kuich W, Vogler H (2009) Handbook of weighted automata. Springer, New York

    Book  Google Scholar 

  29. Droste M, Meinecke I (2012) Weighted automata and weighted MSO logics for average and long-time behaviors. Inf Comput 220:44–59

    Article  MathSciNet  Google Scholar 

  30. Elberfeld M, Jakoby A, Tantau T (2010) Logspace versions of the theorems of Bodlaender and Courcelle. In: FOCS. IEEE Computer Society

  31. Filiot E, Gentilini R, Raskin JF (2012) Quantitative languages defined by functional automata. In: Koutny M, Ulidowski I (eds) CONCUR 2012-concurrency theory. Springer, Berlin, pp 132–146

    Chapter  Google Scholar 

  32. Forejt V, Kwiatkowska M, Norman G, Parker D, Qu H (2011) Quantitative multi-objective verification for probabilistic systems. In: Abdulla PA, Leino KRM (eds) Tools and algorithms for the construction and analysis of systems. Springer, Berlin, pp 112–127

    Chapter  Google Scholar 

  33. Gustedt J, Mhle O, Telle J (2002) The treewidth of java programs. In: Algorithm engineering and experiments. LNCS. Springer

  34. Halin R (1976) S-functions for graphs. J Geom 8:171–186

    Article  MathSciNet  Google Scholar 

  35. Hartmann M, Orlin JB (1993) Finding minimum cost to time ratio cycles with small integral transit times. Networks 23:567–574

    Article  MathSciNet  Google Scholar 

  36. Henzinger TA, Otop J (2013) From model checking to model measuring. In: CONCUR. LNCS. Springer, pp 273–287

  37. Karp RM (1978) A characterization of the minimum cycle mean in a digraph. Discrete Math 23:309–311

    Article  MathSciNet  Google Scholar 

  38. Kreutzer S, Riveros C (2013) Quantitative monadic second-order logic. In: Proceedings of the 2013 28th annual ACM/IEEE symposium on logic in computer science. LICS ’13. IEEE Computer Society, New York, pp 113–122

  39. Kwek S, Mehlhorn K (2003) Optimal search for rationals. Inf Process Lett 86(1):23–26

    Article  MathSciNet  Google Scholar 

  40. Lawler E (1976) Combinatorial optimization: networks and matroids. Saunders College Publishing, Philadelphia

    MATH  Google Scholar 

  41. Madani O (2002) Polynomial value iteration algorithms for deterministic MDPs. In: UAI. Morgan Kaufmann Publishers

  42. Obdrzálek J (2003) Fast mu-calculus model checking when tree-width is bounded. In: CAV. LNCS. Springer

  43. Orlin JB, Ahuja RK (1992) New scaling algorithms for the assignment and minimum mean cycle problems. Math Program 54:41–56

    Article  MathSciNet  Google Scholar 

  44. Papadimitriou CH (1979) Efficient search for rationals. In: IPL, pp 1–4

  45. Robertson N, Seymour P (1984) Graph minors. III. Planar tree-width. J Combin Theory Ser B 36:49–64

    Article  MathSciNet  Google Scholar 

  46. Robertson N, Seymour P (1986) Graph minors. II. Algorithmic aspects of tree-width. J Algorithms 7:309–322

    Article  MathSciNet  Google Scholar 

  47. Tarjan R (1972) Depth-first search and linear graph algorithms. SIAM J Comput 1:146–160

    Article  MathSciNet  Google Scholar 

  48. Thorup M (1998) All structured programs have small tree width and good register allocation. Inf Comput 142:159–181

    Article  MathSciNet  Google Scholar 

  49. Vallée-Rai R, Co P, Gagnon E, Hendren L, Lam P, Sundaresan V (1999) Soot—a java bytecode optimization framework. In: CASCON ’99. IBM Press

  50. Velner Y (2012) The complexity of mean-payoff automaton expression. In: ICALP. LNCS. Springer

Download references

Acknowledgements

The research was partly supported by Austrian Science Fund (FWF) Grant No P23499- N23, FWF NFN Grant No S11407-N23 (RiSE/SHiNE), ERC Start Grant (279307: Graph Games), and Microsoft faculty fellows award.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Andreas Pavlogiannis.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

The bulk of this work was done while R. Ibsen-Jensen and A. Pavlogiannis were at IST Austria.

Appendices

A Minimum cycle

Here we present in full detail the algorithm \(\mathsf {MinCycle}\) and establish its properties as stated in Theorem 2. Recall that \(\mathsf {MinCycle}\) operates on a tree-decomposition \(\mathrm {Tree}(G)\) of an input graph G and behaves as follows.

  1. 1.

    If G has no negative cycles, then \(\mathsf {MinCycle}\) returns the weight \(c^{*}\) of a minimum-weight cycle in G.

  2. 2.

    If G has negative cycles, then \(\mathsf {MinCycle}\) returns a value that is at most a polynomial (in n) factor smaller than \(c^{*}\).

Intuitively, \(\mathsf {MinCycle}\) discovers (not necessarily simple) cycles in G and returns the minimum weight found. For reasons of efficiency, \(\mathsf {MinCycle}\) does not keep track of which examined cycles are simple, hence if G has negative cycles, then \(\mathsf {MinCycle}\) might return a value smaller than \(c^{*}\), which corresponds to an examined non-simple cycle C that traverses some negative cycles multiple times. However, C is guaranteed to have polynomial (in n) length, and thus the weight of C is at most polynomially smaller than \(c^{*}\).

The following lemma follows easily from [20, Lemma 2], and states that \(\mathsf {LD}_{B}(u,v)\) is upper bounded by the smallest weight of a \({\mathsf {U}}\)-shaped simple \(u\rightsquigarrow v\) path in \(B\).

Lemma 14

([20, Lemma 2]) For every examined bag \(B\) and nodes \(u,v\in B\), we have

  1. 1.

    \(\mathsf {LD}_{B}(u,v)=\mathsf {wt}(P)\) for some path \(P:u\rightsquigarrow v\) (and \(\mathsf {LD}_{B}(u,v)=\infty \) if no such P exists),

  2. 2.

    \(\mathsf {LD}_{B}(u,v)\le \min _{P:u\rightsquigarrow v}\mathsf {wt}(P)\) where P ranges over \({\mathsf {U}}\)-shaped simple paths and simple cycles in \(B\).

At the end of the computation, the returned value c is the weight of a (generally non-simple) cycle C, captured as a \({\mathsf {U}}\)-shaped path on its smallest-level node. The cycle C can be recovered by tracing backwards the updates of line 10 performed by the algorithm, starting from the node x that performed the last update in line 13. Hence, if C traverses k distinct edges, we can write

$$\begin{aligned} c=\mathsf {wt}(C)=\sum _{i=1}^{k} k_i\cdot \mathsf {wt}(e_i) \end{aligned}$$
(2)

where each \(e_i\) is a distinct edge, and \(k_i\) is the number of times it appears in C.

Lemma 15

Let h be the height of \(\mathrm {Tree}(G)\). For every \(k_i\) in Eq. 2, we have \(k_i\le 2^h\).

Proof

Note that the edge \(e_i=(u_i,v_i)\) is first considered by \(\mathsf {MinCycle}\) in the root bag \(B_i\) of node \(x_i\), where \(x_i=\arg \max _{y_i\in \{u_i,v_i\}}\mathsf {Lv}(y_i)\) (line 10). As \(\mathsf {MinCycle}\) backtracks from \(B_i\) to the root of \(\mathrm {Tree}(G)\), the edge \(e_i\) can be traversed at most twice as many times in each step (because of line 10, once for each term of the sum \(\mathsf {LD}_{B}(u,x)+\mathsf {LD}_{B}(x,v)\)). Hence, this doubling will occur at most h times, and thus \(k_i\le 2^h\). \(\square \)

Lemma 16

Let c be the value returned by \(\mathsf {MinCycle}\), h be the height of \(\mathrm {Tree}(G)\), and \(c^{*}=\min _C \mathsf {wt}(C)\) over all simple cycles C in G. The following assertions hold:

  1. 1.

    If G has no negative cycles, then \(c=c^{*}\).

  2. 2.

    If G has a negative cycle, then

    1. (a)

      \(c\le c^{*}\).

    2. (b)

      \(|c|=O\left( |c^{*}|\cdot n\cdot 2^h\right) \).

Proof

By Remark 1, we have that \(c^{*}=\mathsf {wt}(P)\) for a \({\mathsf {U}}\)-shaped path \(P:x\rightsquigarrow x\). By Lemma 14, after \(\mathsf {MinCycle}\) examines \(B_x\), it will be \(c\le \mathsf {LD}_{B_x}(x,x)\le c^{*}\), with the equalities holding if there are no negative cycles in G (by the definition of \(c^{*}\), as then \(\mathsf {LD}_{B_x}(x,x)\) is witnessed by a simple cycle). By line 10, c can only decrease afterwards, and again by the definition of \(c^{*}\) this can only happen if there are negative cycles in G. This proves items 1 and 2a, and the remaining of the proof focuses on showing that \(|c|=O\left( |c^{*}|\cdot n\cdot 2^h\right) \).

By rearranging the sum of Eq. 2, we can decompose the obtained cycle C into a set of \(k'^{+}\) non-negative simple cycles \(C^{+}_i\), and a set of \(k'^{-}\) negative simple cycles \(C^{-}_i\), and each cycle \(C^{+}_i\) and \(C^{-}_i\) appears with multiplicity \(k^{+}_i\) and \(k^{-}_i\) respectively. Then we have

$$\begin{aligned} |c|&=|\mathsf {wt}(C)| = \left| \sum _{i=1}^{k'^{+}}k^{+}_i\cdot \mathsf {wt}(C^{+}_i) + \sum _{i=1}^{k'^{-}}k^{-}_i\cdot \mathsf {wt}(C^{-}_i)\right| \le \left| \sum _{i=1}^{k'^{-}}k^{-}_i\cdot \mathsf {wt}(C^{-}_i)\right| \nonumber \\&\le \sum _{i=1}^{k^{-}}k^{-}_i\cdot |\mathsf {wt}(C^{-}_i)|\le |c^{*}|\cdot \sum _{i=1}^{k'^{-}}k^{-}_i \le |c^{*}|\cdot \sum _{i=1}^{k}k_i =O\left( |c^{*}|\cdot n\cdot 2^h\right) \end{aligned}$$
(3)

The first inequality follows from \(c<0\), the third inequality holds by the definition of \(c^{*}\), and the last inequality holds since the total number of (non-positive) simple cycle traversals of C cannot be more than the total number of the edge traversals. Finally, we have \(\sum _{i=1}^{k} k_i=O\left( n\cdot 2^h\right) \), since \(k=O(n)\), and by Lemma 15 we have \(k_i\le 2^h\). \(\square \)

Next we discuss the time and space complexity of \(\mathsf {MinCycle}\).

Lemma 17

Let h be the height of \(\mathrm {Tree}(G)\). \(\mathsf {MinCycle}\) accesses each bag of \(\mathrm {Tree}(G)\) a constant number of times, and uses O(h) additional space.

Proof

\(\mathsf {MinCycle}\) accesses each bag a constant number of times, as it performs a post-order traversal on \(\mathrm {Tree}(G)\) (line 2). Because it computes the local distances in a postorder manner, the number of local distance maps \(\mathsf {LD}_{B}\) it remembers is bounded by the height h of \(\mathrm {Tree}(G)\). Since \(\mathrm {Tree}(G)\) has bounded width, \(\mathsf {LD}_{B}\) requires a constant number of words for storing a constant number of nodes and weights in each \(B\). Hence the total space usage is O(h), and the result follows. \(\square \)

The following theorem summarizes the results of this section.

Theorem 2

Let \(G=(V,E,\mathsf {wt})\) be a weighted graph of n nodes with bounded treewidth, and a balanced, binary tree-decomposition \(\mathrm {Tree}(G)\) of G be given. Let \(c^{*}\), be the smallest weight of a simple cycle in G. Algorithm \(\mathsf {MinCycle}\) uses O(n) time and \(O(\log n)\) additional space, and returns a value c such that:

  1. 1.

    If G has no negative cycles, then \(c=c^{*}\).

  2. 2.

    If G has a negative cycle, then

    1. (a)

      \(c\le c^{*}\).

    2. (b)

      \(|c|=|c^{*}|\cdot n^{O(1)}\).

B The minimum ratio and mean cycle problems

Lemma 18

Let \(\nu ^{*}\ne 0\) be the ratio value of G. The value \(\lfloor \nu ^{*} \rfloor \) can be obtained by evaluating \(O( \log |\nu ^{*}|)\) inequalities of the form \(\nu ^{*}\ge \nu \).

Proof

First determine whether \(\nu ^{*}> 0\), and assume w.l.o.g. that this is the case (the process is similar if \(\nu ^{*}<0\)). Perform an exponential search on the interval \((0,2\cdot \lfloor \nu ^{*}\rfloor )\) by a sequence of evaluations of the inequality \(\nu ^{*}\ge \nu _i=2^i\). After \(\log \lfloor \nu ^{*}\rfloor +1\) steps we either have \(\lfloor \nu ^{*}\rfloor \in (0,1)\), or have determined a \(j>0\) such that \(\nu ^{*}\in [\nu _{j-1}, \nu _j]\). Then, perform a binary search in the interval \([\nu _{j-1}, \nu _j]\), until the running interval \([\ell , r]\) has length at most 1. Since \(\nu _j - \nu _{j-1} = \nu _{j-1} \le \nu ^{*}\), this will happen after at most \(\log \lceil \nu ^{*} \rceil \) steps. Then either \(\lfloor \nu ^{*} \rfloor = \lfloor \ell \rfloor \) or \(\lfloor \nu ^{*} \rfloor = \lfloor r \rfloor \), which can be determined by evaluating the inequality \( \nu ^{*} \ge \lfloor r \rfloor \). A similar process can be carried out when \(\nu ^{*}<0\). \(\square \)

Let \(T_{\max }=\max _e\mathsf {wt}^{\prime }(e)\) be the largest weight of an edge with respect to \(\mathsf {wt}^{\prime }\). Since \(\nu ^{*}\) is a number with denominator at most \((n-1)\cdot T_{\max }\), it can be determined exactly by carrying the binary search of Lemma 18 until the length of the running interval becomes at most \(\frac{1}{((n-1)\cdot T_{\max })^2}\) (thus containing a unique rational with denominator at most \((n-1)\cdot T_{\max }\)). Then \(\nu ^{*}\) can be obtained by using continued fractions, e.g. as in [39]. We rely in the work of Papadimitriou [44] to obtain a tighter bound.

Lemma 19

Let \(\nu ^{*}\ne 0\) be the ratio value of G, such that \(\nu ^{*}\) is the irreducible fraction \(\frac{a}{b}\in (-1,1)\). Then \(\nu ^{*}\) can be determined by evaluating \(O(\log b)\) inequalities of the form \(\nu ^{*}\ge \nu \).

Proof

Consider that \(\nu ^{*} > 0\) (the proof is similar when \(\nu ^{*} < 0\)). It is shown in [44] that a rational with denominator at most b can be determined by evaluating \(O(\log b)\) inequalities of the form \(\nu ^{*}\ge \nu \). \(\square \)

Theorem 6

Let \(G=(V,E,\mathsf {wt}, \mathsf {wt}^{\prime })\) be a weighted graph of n nodes with bounded treewidth, and \(\lambda =\max _u |a_u\cdot b_u|\) such that \(\nu ^{*}(u)\) is the irreducible fraction \(\frac{a_u}{b_u}\). Let \(\mathcal {T}(G)\) and \(\mathcal {S}(G)\) denote the required time and space for constructing a balanced binary tree-decomposition \(\mathrm {Tree}(G)\) of G with bounded width. The minimum ratio cycle problem for G can be computed in

  1. 1.

    \(O(\mathcal {T}(G)+n\cdot \log (\lambda ))\) time and \(O(\mathcal {S}(G)+n)\) space; and

  2. 2.

    \(O(\mathcal {S}(G)+\log n)\) space.

Proof

In view of Remark 5 the graph G is strongly connected and has a minimum ratio value \(\nu ^{*}\). Let \(\nu ^{*}=\lfloor \nu ^{*} \rfloor + \frac{a'}{b}\) with \(|\frac{a'}{b}|<1\). By Lemma 18, \(\lfloor \nu ^{*} \rfloor \) can be determined by evaluating \(O(\log |\nu ^{*}|)=O(\log |a|)\) inequalities of the form \(\nu ^{*} \ge \nu \), and by Lemma 19, \(\frac{a'}{b}\) can be determined by evaluating O(b) such inequalities. A balanced binary tree-decomposition \(\mathrm {Tree}(G)\) can be constructed once in \(\mathcal {T}(G)\) time and \(\mathcal {S}(G)\) space, and stored in O(n) space. \(\mathrm {Tree}(G)\) is also a tree-decomposition of every \(G_{\nu }\) required by Lemma 11. By Theorem 2 a negative cycle in \(G_{\nu }\) can be detected in O(n) time and using \(O(\log n)\) space. This concludes Item 1. Item 2 is obtained by the same process, but with re-computing \(\mathrm {Tree}(G)\) every time \(\mathsf {MinCycle}\) traverses from a bag to a neighbor (thus not storing \(\mathrm {Tree}(G)\) explicitly). \(\square \)

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Chatterjee, K., Ibsen-Jensen, R. & Pavlogiannis, A. Faster algorithms for quantitative verification in bounded treewidth graphs. Form Methods Syst Des 57, 401–428 (2021). https://doi.org/10.1007/s10703-021-00373-5

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10703-021-00373-5

Keywords

Navigation