Symbolic Resource Bound Inference for Functional Programs

  • Ravichandhran Madhavan
  • Viktor Kuncak
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8559)


We present an approach for inferring symbolic resource bounds for purely functional programs consisting of recursive functions, algebraic data types and nonlinear arithmetic operations. In our approach, the developer specifies the desired shape of the bound as a program expression containing numerical holes which we refer to as templates. For e.g, time ≤ a ∗ height(tree) + b where a,b are unknowns, is a template that specifies a bound on the execution time. We present a scalable algorithm for computing tight bounds for sequential and parallel execution times by solving for the unknowns in the template. We empirically evaluate our approach on several benchmarks that manipulate complex data structures such as binomial heap, lefitist heap, red-black tree and AVL tree. Our implementation is able to infer hard, nonlinear symbolic time bounds for our benchmarks that are beyond the capability of the existing approaches.


Recursive Function Functional Program Nonlinear Constraint Satisfying Assignment Code Snippet 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of object-oriented bytecode programs. Theor. Comput. Sci. 413(1), 142–159 (2012)CrossRefzbMATHMathSciNetGoogle Scholar
  2. 2.
    Beyene, T.A., Popeea, C., Rybalchenko, A.: Solving existentially quantified horn clauses. In: Sharygina, N., Veith, H. (eds.) CAV 2013. LNCS, vol. 8044, pp. 869–882. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  3. 3.
    Beyer, D., Henzinger, T.A., Majumdar, R., Rybalchenko, A.: Invariant synthesis for combined theories. In: Cook, B., Podelski, A. (eds.) VMCAI 2007. LNCS, vol. 4349, pp. 378–394. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  4. 4.
    Beyer, D., Henzinger, T.A., Majumdar, R., Rybalchenko, A.: Path invariants. In: PLDI (2007)Google Scholar
  5. 5.
    Blanc, R.W., Kneuss, E., Kuncak, V., Suter, P.: An overview of the Leon verification system. In: Scala Workshop (2013)Google Scholar
  6. 6.
    Blelloch, G.E., Maggs, B.M.: Parallel algorithms. Communications of the ACM 39, 85–97 (1996)CrossRefGoogle Scholar
  7. 7.
    Colón, M.A., Sankaranarayanan, S., Sipma, H.B.: Linear invariant generation using non-linear constraint solving. In: Hunt Jr., W.A., Somenzi, F. (eds.) CAV 2003. LNCS, vol. 2725, pp. 420–432. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  8. 8.
    Cook, B., Gupta, A., Magill, S., Rybalchenko, A., Simsa, J., Singh, S., Vafeiadis, V.: Finding heap-bounds for hardware synthesis. In: FMCAD (2009)Google Scholar
  9. 9.
    Cousot, P.: Proving program invariance and termination by parametric abstraction, lagrangian relaxation and semidefinite programming. In: Cousot, R. (ed.) VMCAI 2005. LNCS, vol. 3385, pp. 1–24. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  10. 10.
    de Moura, L., Bjørner, N.S.: Z3: An efficient smt solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  11. 11.
    Grebenshchikov, S., Lopes, N.P., Popeea, C., Rybalchenko, A.: Synthesizing software verifiers from proof rules. In: PLDI (2012)Google Scholar
  12. 12.
    Guerraoui, R., Kuncak, V., Losa, G.: Speculative linearizability. In: PLDI (2012)Google Scholar
  13. 13.
    Gulwani, S., Jha, S., Tiwari, A., Venkatesan, R.: Synthesis of loop-free programs. In: PLDI (2011)Google Scholar
  14. 14.
    Gulwani, S., Mehra, K.K., Chilimbi, T.M.: Speed: Precise and efficient static estimation of program computational complexity. In: POPL (2009)Google Scholar
  15. 15.
    Gulwani, S., Srivastava, S., Venkatesan, R.: Program analysis as constraint solving. In: PLDI (2008)Google Scholar
  16. 16.
    Jacobs, S., Kuncak, V.: Towards complete reasoning about axiomatic specifications. In: Jhala, R., Schmidt, D. (eds.) VMCAI 2011. LNCS, vol. 6538, pp. 278–293. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  17. 17.
    Kaufmann, M., Manolios, P., Moore, J.S. (eds.): Computer-Aided Reasoning: ACL2 Case Studies. Kluwer Academic Publishers (2000)Google Scholar
  18. 18.
    Kneuss, E., Kuraj, I., Kuncak, V., Suter, P.: Synthesis modulo recursive functions. In: OOPSLA (2013)Google Scholar
  19. 19.
    Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)CrossRefGoogle Scholar
  20. 20.
    Madhavan, R., Kuncak, V.: Symbolic resource bound inference. Technical Report EPFL-REPORT-190578, EPFL (2014),
  21. 21.
    Makarios, T.J.M.: The independence of Tarski’s Euclidean axiom. Archive of Formal Proofs, Formal proof development (October 2012),,
  22. 22.
    Odersky, M., Spoon, L., Venners, B.: Programming in Scala: A comprehensive step-by-step guide. Artima Press (2008)Google Scholar
  23. 23.
    Oppen, D.C.: Elementary bounds for presburger arithmetic. In: Proceedings of the Fifth Annual ACM Symposium on Theory of Computing (1973)Google Scholar
  24. 24.
    Rybalchenko, A., Sofronie-Stokkermans, V.: Constraint solving for interpolation. In: Cook, B., Podelski, A. (eds.) VMCAI 2007. LNCS, vol. 4349, pp. 346–362. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  25. 25.
    Sankaranarayanan, S., Sipma, H.B., Manna, Z.: Non-linear loop invariant generation using gröbner bases. In: POPL (2004)Google Scholar
  26. 26.
    Solar-Lezama, A., Tancau, L., Bodík, R., Seshia, S.A., Saraswat, V.A.: Combinatorial sketching for finite programs. In: ASPLOS (2006)Google Scholar
  27. 27.
    Suter, P., Dotta, M., Kuncak, V.: Decision procedures for algebraic data types with abstractions. In: POPL (2010)Google Scholar
  28. 28.
    Suter, P., Köksal, A.S., Kuncak, V.: Satisfiability modulo recursive programs. In: Yahav, E. (ed.) SAS 2011. LNCS, vol. 6887, pp. 298–315. Springer, Heidelberg (2011)Google Scholar
  29. 29.
    Yu, L.: A formal model of IEEE floating point arithmetic. Archive of Formal Proofs, Formal proof development (July 2013),

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Ravichandhran Madhavan
    • 1
  • Viktor Kuncak
    • 1
  1. 1.EPFLSwitzerland

Personalised recommendations