skip to main content

Solving Conditional Linear Recurrences for Program Verification: The Periodic Case

Published:06 April 2023Publication History
Skip Abstract Section

Abstract

In program verification, one method for reasoning about loops is to convert them into sets of recurrences, and then try to solve these recurrences by computing their closed-form solutions. While there are solvers for computing closed-form solutions to these recurrences, their capabilities are limited when the recurrences have conditional expressions, which arise when the body of a loop contains conditional statements. In this paper, we take a step towards solving these recurrences. Specifically, we consider what we call conditional linear recurrences and show that given such a recurrence and an initial value, if the index sequence generated by the recurrence on the initial value is what we call ultimately periodic, then it has a closed-form solution. However, checking whether such a sequence is ultimately periodic is undecidable so we propose a heuristic "generate and verify" algorithm for checking the ultimate periodicity of the sequence and computing closed-form solutions at the same time. We implemented a solver based on this algorithm, and our experiments show that a straightforward program verifier based on our solver and using the SMT solver Z3 is effective in verifying properties of many benchmark programs that contain conditional statements in their loops, and compares favorably to other recurrence-based verification tools. Finally, we also consider extending our results to computing closed-form solutions of recurrences with unknown initial values.

References

  1. 2021. COMP 2021 - 10th International Competition on Software Verification. https://sv-comp.sosy-lab.org/2021/index.php Google ScholarGoogle Scholar
  2. Roberto Baldoni, Emilio Coppa, Daniele Cono D’elia, Camil Demetrescu, and Irene Finocchi. 2018. A survey of symbolic execution techniques. ACM Computing Surveys (CSUR), 51, 3 (2018), 1–39. https://doi.org/10.1145/3182657 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Dirk Beyer, Matthias Dangl, and Philipp Wendler. 2015. Boosting k-induction with continuously-refined invariants. In International Conference on Computer Aided Verification. 622–640. https://doi.org/10.1007/978-3-319-21690-4_42 Google ScholarGoogle ScholarCross RefCross Ref
  4. Jason Breck, John Cyphert, Zachary Kincaid, and Thomas Reps. 2020. Templates and recurrences: Better together. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. 688–702. https://doi.org/10.1145/3385412.3386035 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. David C Cooper. 1972. Theorem proving in arithmetic without multiplication. Machine intelligence, 7, 91-99 (1972), 300. Google ScholarGoogle Scholar
  6. John Cyphert, Jason Breck, Zachary Kincaid, and Thomas Reps. 2019. Refinement of path expressions for static analysis. Proceedings of the ACM on Programming Languages, 3, POPL (2019), 1–29. https://doi.org/10.1145/3290358 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Priyanka Darke, Sakshi Agrawal, and R Venkatesh. 2021. VeriAbs: A tool for scalable verification by abstraction (competition contribution). In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. 458–462. https://doi.org/10.1007/978-3-030-72013-1_32 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Leonardo De Moura and Nikolaj Bjørner. 2008. Z3: An efficient SMT solver. In International conference on Tools and Algorithms for the Construction and Analysis of Systems. 337–340. https://doi.org/10.1007/978-3-540-78800-3_24 Google ScholarGoogle ScholarCross RefCross Ref
  9. Isil Dillig, Thomas Dillig, Boyang Li, and Ken McMillan. 2013. Inductive invariant generation via abductive inference. Acm Sigplan Notices, 48, 10 (2013), 443–456. https://doi.org/10.1145/2544173.2509511 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Farzan and Z. Kincaid. 2015. Compositional recurrence analysis. In 2015 Formal Methods in Computer-Aided Design (FMCAD). 57–64. https://doi.org/10.1109/FMCAD.2015.7542253 Google ScholarGoogle ScholarCross RefCross Ref
  11. Sumit Gulwani and Florian Zuleger. 2010. The reachability-bound problem. In Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation. 292–304. https://doi.org/10.1145/1806596.1806630 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Christoph Haase and Simon Halfon. 2014. Integer vector addition systems with states. In International Workshop on Reachability Problems. 112–124. https://doi.org/10.1007/978-3-319-11439-2_9 Google ScholarGoogle ScholarCross RefCross Ref
  13. Roger A Horn and Charles R Johnson. 2012. Matrix analysis. Cambridge university press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Bertrand Jeannet, Peter Schrammel, and Sriram Sankaranarayanan. 2014. Abstract Acceleration of General Linear Loops. SIGPLAN Not., 49, 1 (2014), jan, 529–540. issn:0362-1340 https://doi.org/10.1145/2578855.2535843 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Richard M Karp and Raymond E Miller. 1969. Parallel program schemata. Journal of Computer and system Sciences, 3, 2 (1969), 147–195. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Zachary Kincaid, Jason Breck, Ashkan Forouhi Boroujeni, and Thomas Reps. 2017. Compositional Recurrence Analysis Revisited. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). Association for Computing Machinery, New York, NY, USA. 248–262. isbn:9781450349888 https://doi.org/10.1145/3062341.3062373 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Zachary Kincaid, Jason Breck, John Cyphert, and Thomas Reps. 2019. Closed Forms for Numerical Loops. Proc. ACM Program. Lang., 3, POPL (2019), Article 55, Jan., 29 pages. https://doi.org/10.1145/3290368 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Zachary Kincaid, John Cyphert, Jason Breck, and Thomas Reps. 2017. Non-linear reasoning for invariant synthesis. Proceedings of the ACM on Programming Languages, 2, POPL (2017), 1–33. https://doi.org/10.1145/3158142 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Laura Kovács. 2008. Reasoning algebraically about p-solvable loops. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. 249–264. https://doi.org/10.1007/978-3-540-78800-3_18 Google ScholarGoogle ScholarCross RefCross Ref
  20. Fangzhen Lin. 2016. A formalization of programs in first-order logic with a discrete linear order. Artificial Intelligence, 235 (2016), 1–25. issn:0004-3702 https://doi.org/10.1016/j.artint.2016.01.014 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Zohar Manna. 1979. Mathematical theory of computation. Journal of Symbolic Logic, 44, 1 (1979). Google ScholarGoogle Scholar
  22. Aaron Meurer, Christopher P Smith, Mateusz Paprocki, Ondřej Čertík, Sergey B Kirpichev, Matthew Rocklin, AMiT Kumar, Sergiu Ivanov, Jason K Moore, and Sartaj Singh. 2017. SymPy: symbolic computing in Python. PeerJ Computer Science, 3 (2017), e103. https://doi.org/10.7717/peerj-cs.103 Google ScholarGoogle ScholarCross RefCross Ref
  23. Joël Ouaknine and James Worrell. 2012. Decision problems for linear recurrence sequences. In International Workshop on Reachability Problems. 21–28. https://doi.org/10.1007/978-3-642-33512-9_3 Google ScholarGoogle ScholarCross RefCross Ref
  24. Marko Petkovsek, Herbert S. Wilf, and Doron Zeilberger. 1996. A = B. Wellesley, Mass. : A K Peters. Google ScholarGoogle Scholar
  25. Pritom Rajkhowa. 2019. VIAP : an automated system for verifying integer assignment programs with loops. Ph. D. Dissertation. https://doi.org/10.14711/thesis-991012758169203412 Google ScholarGoogle ScholarCross RefCross Ref
  26. Pritom Rajkhowa and Fangzhen Lin. 2019. VIAP 1.1. In International Conference on Tools and Algorithms for the Construction and Analysis of Systems. 250–255. https://doi.org/10.1007/978-3-030-17502-3_23 Google ScholarGoogle ScholarCross RefCross Ref
  27. Darren Redfern. 2012. The maple handbook: maple V release 4. Springer Science & Business Media. Google ScholarGoogle Scholar
  28. Rahul Sharma, Isil Dillig, Thomas Dillig, and Alex Aiken. 2011. Simplifying loop invariant generation using splitter predicates. In International Conference on Computer Aided Verification. 703–719. https://doi.org/10.1007/978-3-642-22110-1_57 Google ScholarGoogle ScholarCross RefCross Ref
  29. Chenglin Wang and Fangzhen Lin. 2023. OOPSLA 2023 Artifact for “Solving Conditional Linear Recurrences for Program Verification: The Periodic Case”. https://doi.org/10.1145/3554354 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Stephen Wolfram. 1999. The MATHEMATICA® book, version 4. Cambridge university press. Google ScholarGoogle Scholar

Index Terms

  1. Solving Conditional Linear Recurrences for Program Verification: The Periodic Case

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Article Metrics

        • Downloads (Last 12 months)136
        • Downloads (Last 6 weeks)34

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!