Invariant Generation for Multi-Path Loops with Polynomial Assignments

  • Andreas Humenberger
  • Maximilian Jaroschek
  • Laura Kovács
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10747)


Program analysis requires the generation of program properties expressing conditions to hold at intermediate program locations. When it comes to programs with loops, these properties are typically expressed as loop invariants. In this paper we study a class of multi-path program loops with numeric variables, in particular nested loops with conditionals, where assignments to program variables are polynomial expressions over program variables. We call this class of loops extended P-solvable and introduce an algorithm for generating all polynomial invariants of such loops. By an iterative procedure employing Gröbner basis computation, our approach computes the polynomial ideal of the polynomial invariants of each program path and combines these ideals sequentially until a fixed point is reached. This fixed point represents the polynomial ideal of all polynomial invariants of the given extended P-solvable loop. We prove termination of our method and show that the maximal number of iterations for reaching the fixed point depends linearly on the number of program variables and the number of inner loops. In particular, for a loop with m program variables and r conditional branches we prove an upper bound of \(m\cdot r\) iterations. We implemented our approach in the Aligator software package. Furthermore, we evaluated it on 18 programs with polynomial arithmetic and compared it to existing methods in invariant generation. The results show the efficiency of our approach.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Buchberger, B.: An Algorithm for Finding the Basis Elements of the Residue Class Ring of a Zero Dimensional Polynomial Ideal. J. Symbolic Computation 41(3–4), 475–511 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Cachera, D., Jensen, T., Jobin, A., Kirchner, F.: Inference of polynomial invariants for imperative programs: a farewell to gröbner bases. In: Miné, A., Schmidt, D. (eds.) SAS 2012. LNCS, vol. 7460, pp. 58–74. Springer, Heidelberg (2012). CrossRefGoogle Scholar
  3. 3.
    Farzan, A., Kincaid, Z.: Compositional recurrence analysis. In: Proc. of FMCAD, pp. 57–64. FMCAD Inc, Austin (2015)Google Scholar
  4. 4.
    Humenberger, A., Jaroschek, M., Kovács, L.: Automated generation of non-linear loop invariants utilizing hypergeometric Sequences. In: Proceedings of the 2017 ACM on International Symposium on Symbolic and Algebraic Computation, ISSAC 2017, pp. 221–228. ACM, New York (2017)Google Scholar
  5. 5.
    Kauers, M., Paule, P.: The Concrete Tetrahedron. Text and Monographs in Symbolic Computation, 1st edn. Springer, Wien (2011)CrossRefzbMATHGoogle Scholar
  6. 6.
    Kauers, M., Zimmermann, B.: Computing the algebraic relations of C-finite sequences and multisequences. Journal of Symbolic Computation 43(11), 787–803 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  7. 7.
    Kincaid, Z., Cyphert, J., Breck, J., Reps, T.: Non-linear reasoning for invariant synthesis. In: POPL (2018) (to appear)Google Scholar
  8. 8.
    Kovács, L.: Automated Invariant Generation by Algebraic Techniques for Imperative Program Verification in Theorema. Ph.D. thesis, RISC, Johannes Kepler University Linz, October 2007Google Scholar
  9. 9.
    Kovács, L.: Reasoning algebraically about P-solvable loops. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 249–264. Springer, Heidelberg (2008). CrossRefGoogle Scholar
  10. 10.
    Kovács, L.: A complete invariant generation approach for P-solvable loops. In: Pnueli, A., Virbitskaite, I., Voronkov, A. (eds.) PSI 2009. LNCS, vol. 5947, pp. 242–256. Springer, Heidelberg (2010). CrossRefGoogle Scholar
  11. 11.
    Müller-Olm, M., Seidl, H.: A note on karr’s algorithm. In: Díaz, J., Karhumäki, J., Lepistö, A., Sannella, D. (eds.) ICALP 2004. LNCS, vol. 3142, pp. 1016–1028. Springer, Heidelberg (2004). CrossRefGoogle Scholar
  12. 12.
    de Oliveira, S., Bensalem, S., Prevosto, V.: Polynomial invariants by linear algebra. In: Artho, C., Legay, A., Peled, D. (eds.) ATVA 2016. LNCS, vol. 9938, pp. 479–494. Springer, Cham (2016). CrossRefGoogle Scholar
  13. 13.
    Paule, P., Schorn, M.: A Mathematica Version of Zeilberger’s Algorithm for Proving Binomial Coefficient Identities. Journal of Symbolic Computation 20, 673–698 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Petkovšek, M.: Mathematic package hyper (1998).
  15. 15.
    Research Institute for Symbolic Computation: Mathematic Package ErgoSum (2016).
  16. 16.
    Rodriguez-Carbonell, E., Kapur, D.: Automatic Generation of Polynomial Invariants of Bounded Degree using Abstract Interpretation. J. Science of Computer Programming 64(1), 54–75 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Rodríguez-Carbonell, E., Kapur, D.: Generating all polynomial invariants in simple loops. Journal of Symbolic Computation 42(4), 443–476 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Sankaranarayanan, S., Sipma, H.B., Manna, Z.: Non-linear loop invariant generation using gröbner bases. In: Proc. of POPL, pp. 318–329. ACM, New York (2004)Google Scholar
  19. 19.
    Schneider, C.: Summation theory ii: Characterizations of \(r\pi \sigma \)-extensions and algorithmic aspects. J. Symb. Comput. 80(3), 616–664 (2017). arXiv:1603.04285 [cs.SC]
  20. 20.
    Sharma, R., Gupta, S., Hariharan, B., Aiken, A., Liang, P., Nori, A.V.: A data driven approach for algebraic loop invariants. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 574–592. Springer, Heidelberg (2013). CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG 2018

Authors and Affiliations

  • Andreas Humenberger
    • 1
  • Maximilian Jaroschek
    • 1
  • Laura Kovács
    • 1
  1. 1.Institut für Informationssysteme 184Technische Universität WienViennaAustria

Personalised recommendations