Skip to main content

Asymptotically Precise Ranking Functions for Deterministic Size-Change Systems

  • Conference paper
  • First Online:
Computer Science -- Theory and Applications (CSR 2015)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9139))

Included in the following conference series:

Abstract

The size-change abstraction (SCA) is a popular program abstraction for termination analysis, and has been successfully implemented for imperative, functional and logic programs. Recently, it has been shown that SCA is also an attractive domain for the automatic analysis of the computational complexity of programs. In this paper, we provide asymptotically precise ranking functions for the special case of deterministic size-change systems. As a consequence we also obtain the result that the asymptotic complexity of deterministic size-change systems is exactly polynomial and that the exact integer exponent can be computed in PSPACE.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Anderson, H., Khoo, S.-C.: Affine-based size-change termination. In: Ohori, A. (ed.) APLAS 2003. LNCS, vol. 2895, pp. 122–140. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  2. Ben-Amram, A.M.: A complexity tradeoff in ranking-function termination proofs. Acta Inf. 46(1), 57–72 (2009)

    Article  MATH  MathSciNet  Google Scholar 

  3. Ben-Amram, A.M.: Monotonicity constraints for termination in the integer domain. Logical Methods Comput. Sci. 7(3), 1–43 (2011)

    Article  MathSciNet  Google Scholar 

  4. Ben-Amram, A.M., Lee, C.S.: Ranking functions for size-change termination ii. Logical Methods Comput. Sci. 5(2), 1–29 (2009)

    Article  MathSciNet  Google Scholar 

  5. Codish, M., Fuhs, C., Giesl, J., Schneider-Kamp, P.: Lazy abstraction for size-change termination. In: Fermüller, C.G., Voronkov, A. (eds.) LPAR-17. LNCS, vol. 6397, pp. 217–232. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  6. Colcombet, T., Daviaud, L., Zuleger, F.: Size-change abstraction and max-plus automata. In: Csuhaj-Varjú, E., Dietzfelbinger, M., Ésik, Z. (eds.) MFCS 2014, Part I. LNCS, vol. 8634, pp. 208–219. Springer, Heidelberg (2014)

    Google Scholar 

  7. Krauss, A.: Certified size-change termination. In: Pfenning, F. (ed.) CADE 2007. LNCS (LNAI), vol. 4603, pp. 460–475. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  8. Lee, C.S., Jones, N.D., Ben-Amram, A.M.: The size-change principle for program termination. In: POPL, pp. 81–92 (2001)

    Google Scholar 

  9. Manolios, P., Vroon, D.: Termination analysis with calling context graphs. In: Ball, T., Jones, R.B. (eds.) CAV 2006. LNCS, vol. 4144, pp. 401–414. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  10. Vidal, G.: Quasi-terminating logic programs for ensuring the termination of partial evaluation. In: PEPM, pp. 51–60 (2007)

    Google Scholar 

  11. Zuleger, F., Gulwani, S., Sinn, M., Veith, H.: Bound analysis of imperative programs with the size-change abstraction. In: Yahav, E. (ed.) Static Analysis. LNCS, vol. 6887, pp. 280–297. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Florian Zuleger .

Editor information

Editors and Affiliations

Appendices

A Proof of Lemma 5

Proof

Let \(l_1,\ldots ,l_k\) be the length of the cyclic paths \( Loop _1,\ldots , Loop _k\). We set \(z = \max \{l_1,\ldots ,l_k\}\) and \(t = N / (2nz)\). We set \(t = N / (2nz)\). Because we are interested in the asymptotic behavior w.r.t. N we can assume \(N \ge 8nz\).

We define a path \(\pi = (( \cdots ( Loop _k)^t \cdots Loop _2)^t Loop _1)^t\). We note that \(\pi \) has length \(\varOmega (N^k)\). We define a set \(I = [0,t]^k\) and consider the lexicographic order \(> \ \subseteq I \times I\), where \((i_1,\ldots ,i_k) > (j_1,\ldots ,j_k)\), if there is a \(1 \le a \le k\) such that \(i_a > j_a\) and \(i_b = j_b\) for all \(1 \le b < a\). We note that \(>\) is a linear order on I. We define \(I^1 = I \setminus \{(0,\ldots ,0)\}\). We denote the predecessor of an element \(e \in I^1\) w.r.t. to \(>\) by \( pred (e)\). We use \(I^1\) to enumerate the cyclic paths in \(\pi \), i.e., \(\pi = \pi (t,\ldots ,t,t) \pi (t,\ldots ,t,t-1) \cdots \pi (t,\ldots ,t,0)\pi (t,\ldots ,t-1,t) \cdots \pi (0,\ldots ,0,2) \pi (0,\ldots ,0,1)\). We note that by the above definitions \(\pi (i_1,\cdots ,i_k) = Loop _d\), if and only if \(i_d \ne 0\) and \(i_u = 0\) for all \(d < u \le k\).

We define a function \( bw _T: Val _N \rightarrow Val _N\) that takes an SCT \(T\) and a valuation \(\sigma \in Val _N\) and returns a valuation \(\sigma '\) with \(\sigma '(x) = \sigma (y) + 1\), if \(x > y' \in T\), \(\sigma '(x) = \sigma (y)\), if \(x \ge y' \in T\), and \(\sigma '(x) = 0\), otherwise.

We will recursively define valuations \(\sigma (e)\) for \(e \in I\) and traces \(\rho (e)\) for \(e \in I^1\). We define \(\sigma (0,\ldots ,0)(x) = 0\) for all \(x \in Var \). Let \(e \in I^1\). Let \(d \in [1,k]\) be chosen such that \(\pi (e) = Loop _d\). Let \(\ell \xrightarrow {T_{l_d}} \ell _{l_d - 1} \xrightarrow {T_{l_d - 1}} \cdots \ell _1 \xrightarrow {T_1} \ell \) be the path denoted by \( Loop _d\). We define the trace \(\rho (e)\) by \((\ell ,\sigma _{l_d}) \xrightarrow {T_{l_d}} (\ell _{l_d-1},\sigma _{l_d-1}) \cdots (\ell _1,\sigma _1) \xrightarrow {T_1} (\ell ,\sigma _0)\), where \(\sigma _0 := \sigma ( pred (e))\) and \(\sigma _{i+1} := bw _{T_{i+1}}(\sigma _i)\) for all \(0 < i \le l_d\). We set \(\sigma (e) := \sigma _{l_d}\) and \(\sigma ^i(e) := \sigma _i\) for all \(0 < i < l_d\).

Let \(x \in Var \) be some variable. We define \( c (x) = u\), if \(x \in C_u \setminus C_{u-1}\), setting \(C_0 = \emptyset \), or \( c (x) = \bot \), if there is no u with \(x \in C_u\). Let \((i_1,\cdots ,i_k) \in I\). We claim that

$$\begin{aligned} \begin{aligned} \sigma (i_1,\cdots ,i_k)(x)&\le i_u \cdot z + (u-1) \cdot N / n + N / (8n),\\&\text{ if } \text{ there } \text{ is } \text{ a } u = c (x) \ne \bot , \text{ and } \\&\sigma (i_1,\cdots ,i_k)(x) \le 3N / (4n) + (n-1) \cdot N / n, \text{ if } c (x) = \bot . \end{aligned} \end{aligned}$$
(*)

We proceed by induction on \(e = (i_1,\cdots ,i_k)\). Clearly the claim holds for \(e = (0,\ldots ,0)\). Now consider \(e \in I^1\). Let \(d \in [1,k]\) be chosen such that \(\pi (e) = Loop _d\). Let \((j_1,\ldots ,j_k) = pred (i_1,\cdots ,i_k)\). We have \(i_u = j_u\) for all \(1 \le u < d\) and \(j_d + 1 = i_d\). Let \(x \in Var \) be some variable. Assume there is an \(y \in Var \) with \(x \triangleright y \in Loop _d\). Let \(u = c (x)\) and \(v = c (y)\). By the definition of a for-loop we have \( suc _{ Loop _d}( Var ) = C_d\), and thus \(\bot \ne v \le d\). By induction assumption, we have \(\sigma (j_1,\ldots ,j_k)(y) \le j_v \cdot z + (v-1) \cdot N / n\). If \(1 \le u \le d\), we have \( suc _{ Loop _j}(C_u) = C_u\) and \( suc _{ Loop _j}(C_{u-1}) = C_{u-1}\) by the definition of a for-loop. Because \(\mathcal {A}\) is deterministic and \(\langle C_1,\ldots ,C_k \rangle \) is a proper context, we get \(u = v\). For \(1 \le u < d\) we have \(\triangleright = \ \ge \) by the definition of a for-loop. We get \(\sigma (i_1,\ldots ,i_k)(x) = \sigma (j_1,\ldots ,j_k)(y) \le j_v \cdot z + (v-1) \cdot N / n + N / (8n) = i_u \cdot z + (u-1) \cdot N / n + N / (8n)\). If \(u = d\) we have \(\sigma (i_1,\ldots ,i_k)(x) \le \sigma (j_1,\ldots ,j_k)(y) + z \le j_v \cdot z + (v-1) \cdot N / n + N / (8n) + z = (j_d + 1) \cdot z + (d-1) \cdot N / n + N / (8n) = i_u \cdot z + (u-1) \cdot N / n + N / (8n)\). Assume that \(1 \le u \le d\) does not hold. If \(u \ne \bot \) we have \(d < u \le k\), and thus \(\sigma (i_1,\ldots ,i_k)(x) \le \sigma (j_1,\ldots ,j_k)(y) + z \le j_v \cdot z + (v-1) \cdot N / n + z + N / (8n) \le N / (2n) + (v-1) \cdot N / n + z + N / (8n) \le (u-1) \cdot N / n \le i_u \cdot z + (u-1) \cdot N / n + N / (8n)\). If \(u = \bot \), we have \(\sigma (i_1,\ldots ,i_k)(x) \le \sigma (j_1,\ldots ,j_k)(y) + z \le j_v \cdot z + (v-1) \cdot N / n + z + N / (8n) \le N / (2n) + (v-1) \cdot N / n + z + N / (8n) = (3N / 4n) + (n-1) \cdot N / n\). Otherwise, there is no y with \(x \triangleright y \in Loop _j\). We have \(\sigma (i_1,\ldots ,i_k)(x) \le z \le N / (8n)\). We have established (*).

By (*) we have \(\sigma (e)(x) \le N - N / (4n) \le N\) for all \(e \in I\) and \(x \in Var \). Moreover, we have that \(\sigma ^i(e)(x) \le N - N / (4n) + i \le N\) for all \(e \in I^1\) and \(0 < i < l_d\). Thus,

$$\begin{aligned} \rho (t,\ldots ,t,t) \rho (t,\ldots ,t,t-1) \cdots&\rho (t,\ldots ,t,0)\\&\,\rho (t,\ldots ,t-1,t) \cdots \rho (0,\ldots ,0,2) \rho (0,\ldots ,0,1) \end{aligned}$$

is a trace over [0, N] of length \(\varOmega (N^k)\).

B Proof of Lemma 11

Proof

We assume the exception has been raised in some recursive call \( main (\mathcal {A},i)\). We have that there is a loop \( Loop \) for some location \((\ell ,\mathcal {C})\) of \(\mathcal {A}\) such that (1) \( suc _ Loop ( Var ) = last (\mathcal {C})\) and (2) \(x \triangleright y \in Loop \) and \(x,y \in last (\mathcal {C})\) imply that \(\triangleright = \ \ge \) because \(\mathcal {A}\) is stable.

We define a function \( bw _T: Val _N \rightarrow Val _N\) that takes an SCT \(T\) and a valuation \(\sigma \in Val _N\) and returns a valuation \(\sigma '\) with \(\sigma '(x) = \sigma (y) + 1\), if \(x > y' \in T\), \(\sigma '(x) = \sigma (y)\), if \(x \ge y' \in T\), and \(\sigma '(x) = 0\), otherwise.

Let \(\ell _l \xrightarrow {T_{l}} \ell _{l - 1} \xrightarrow {T_{l - 1}} \cdots \ell _1 \xrightarrow {T_1} \ell _0\) with \(\ell = \ell _l = \ell _0\) be the path denoted by \( Loop \). We define a valuation \(\sigma _0(x) = 0\) for all \(x \in Var \). We define a trace \(\rho _0\) by \((\ell ,\sigma _l) \xrightarrow {T_l} (\ell _{l-1},\sigma _{l-1}) \cdots (\ell _1,\sigma _1) \xrightarrow {T_1} (\ell ,\sigma _0)\), where \(\sigma _{i+1} := bw _{T_{i+1}}(\sigma _i)\) for all \(0 < i \le l\). Moreover, we define a trace \(\rho \) by \((\ell ,\sigma _{2l}) \xrightarrow {T_l} (\ell _{2l-1},\sigma _{2l-1}) \cdots (\ell _{l+1},\sigma _{l+1}) \xrightarrow {T_1} (\ell ,\sigma _l)\), where \(\sigma _{i+1} := bw _{T_{i+1}}(\sigma _i)\) for all \(l < i \le 2l\). By induction we get \(\sigma _i \in [0,i]\) for all \(0 \le i \le 2l\).

We will show \(\sigma _{2l} = \sigma _l\). This is sufficient to show that \(\rho ^\omega = \rho \rho \cdots \) is an infinite trace of \(\mathcal {A}\) with valuations over [0, 2l].

We denote by \( Loop |_i = \ell \xrightarrow {T_{l}} \ell _{l - 1} \xrightarrow {T_{l - 1}} \cdots \ell _{i+1} \xrightarrow {T_{i+1}} \ell _i\) the prefix of \( Loop \) until position i. We claim that \(\sigma _{l+i}(x) = \sigma _i(x)\) for all \(x \in suc _{ Loop |_i}( Var )\). The proof proceeds by induction on i. Base case \(i=0\): From (1) and (2) we get that \(\sigma _l(x) = \sigma _0(x) = 0\) for all \(x \in suc _ Loop ( Var ) = last (\mathcal {C})\). Induction step: We consider some \(x \in suc _{ Loop |_i}( Var )\). Assume x does not have a successor in \(T_i\). Then \(\sigma _{l+i}(x) = \sigma _i(x) = 0\). Assume x does have a successor in \(T_i\), i.e., \(x \triangleright y \in T\) for some \(y \in Var \). Then we have \(y \in suc _{ Loop |_{i-1}}( Var )\) and thus \(\sigma _{l+(i-1)}(y) = \sigma _{i-1}(y)\) by induction assumption. By the definition of \( bw _T\) we get \(\sigma _{l+i}(x) = bw _T(\sigma _{l+(i-1)})(x) = bw _T(\sigma _{i-1})(x) = \sigma _i(x)\).

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Springer International Publishing Switzerland

About this paper

Cite this paper

Zuleger, F. (2015). Asymptotically Precise Ranking Functions for Deterministic Size-Change Systems. In: Beklemishev, L., Musatov, D. (eds) Computer Science -- Theory and Applications. CSR 2015. Lecture Notes in Computer Science(), vol 9139. Springer, Cham. https://doi.org/10.1007/978-3-319-20297-6_27

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-20297-6_27

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-20296-9

  • Online ISBN: 978-3-319-20297-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics