Calculating Polynomial Runtime Properties

  • Hugh Anderson
  • Siau-Cheng Khoo
  • Stefan Andrei
  • Beatrice Luca
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3780)


Affine size-change analysis has been used for termination analysis of eager functional programming languages. The same style of analysis is also capable of compactly recording and calculating other properties of programs, including their runtime, maximum stack depth, and (relative) path time costs. In this paper we show how precise (not just big- \(\mathcal{O}\)) polynomial bounds on such costs may be calculated on programs, by a characterization as a problem in quantifier elimination. The technique is decidable, and complete for a class of size-change terminating programs with limited-degree polynomial costs. An extension to the technique allows the calculation of some classes of exponential-cost programs. We demonstrate the new technique by recording the calculation in numbers-of-function (or procedure) calls for a simple functional definition language, but it can also be applied to imperative languages. The technique is automated within the reduce computer algebra system.


Space Cost Runtime Analysis Cylindrical Algebraic Decomposition Runtime Cost Exponential Cost 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aehlig, K., Schwichtenberg, H.: A Syntactical Analysis of Non-Size-Increasing Polynomial Time Computation. ACM Trans. Comput. Logic 3(3), 383–401 (2002)CrossRefMathSciNetGoogle Scholar
  2. 2.
    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)CrossRefGoogle Scholar
  3. 3.
    Ball, T., Larus, J.R.: Branch Prediction For Free. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 300–313 (1993)Google Scholar
  4. 4.
    Bellantoni, S., Cook, S.: A New Recursion-Theoretic Characterization of the Polytime Functions (Extended Abstract). In: STOC 1992: Proceedings of the twenty-fourth annual ACM symposium on Theory of computing, pp. 283–293. ACM Press, New York (1992)CrossRefGoogle Scholar
  5. 5.
    Caseiro, V.H.: Equations for Defining Poly-Time Functions. PhD thesis, University of Oslo (1997)Google Scholar
  6. 6.
    Caviness, B.F., Johnson, J.R. (eds.): Quantifier Elimination and Cylindrical Algebraic Decomposition. Springer, Heidelberg (1998)zbMATHGoogle Scholar
  7. 7.
    Collins, G.E.: Quantifier Elimination for Real Closed Fields by Cylindrical Algebraic Decomposition. In: Brakhage, H. (ed.) Automata Theory and Formal Languages, Berlin, vol. 33, pp. 134–183 (1975)Google Scholar
  8. 8.
    Dolzmann, A., Sturm, T.: REDLOG: Computer algebra meets computer logic. SIGSAM Bulletin (ACM Special Interest Group on Symbolic and Algebraic Manipulation) 31(2), 2–9 (1997)MathSciNetGoogle Scholar
  9. 9.
  10. 10.
    Gómez, G., Liu, Y.A.: Automatic Time-Bound Analysis for a Higher-Order Language. In: PEPM 2002: Proceedings of the 2002 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation, pp. 75–86. ACM Press, New York (2002)CrossRefGoogle Scholar
  11. 11.
    Grobauer, B.: Cost Recurrences for DML Programs. In: International Conference on Functional Programming, pp. 253–264 (2001)Google Scholar
  12. 12.
    Hofmann, M.: Linear Types and Non-Size-Increasing Polynomial Time Computation. In: Logic in Computer Science, pp. 464–473 (1999)Google Scholar
  13. 13.
    Hong, H.: RISC-CLP(Real): Constraint Logic Programming over Real Numbers. In: Benhamou, F., Colmerauer, A. (eds.) Constraint Logic Programming: Selected Research. MIT Press, Cambridge (1993)Google Scholar
  14. 14.
    Jones, N.: Private communication (June 2003)Google Scholar
  15. 15.
    Kapur, D.: Automatically Generating Loop Invariants Using Quantifier Elimination. In: Proceedings of the 10th International Conference on Applications of Computer Algebra. ACA and Lamar University (July 2004)Google Scholar
  16. 16.
    Kaser, O., Ramakrishnan, C.R., Pawagi, S.: On the Conversion of Indirect to Direct Recursion. LOPLAS 2(1-4), 151–164 (1993)CrossRefGoogle Scholar
  17. 17.
    Khoo, S.C., Anderson, H.: Bounded Size-Change Termination. Technical Report TRB6/05, National University of Singapore (June 2005)Google Scholar
  18. 18.
    Lee, C.S., Jones, N.D., Ben-Amram, A.M.: The Size-Change Principle for Program Termination. In: Conference Record of the 28th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, January 2001, vol. 28, pp. 81–92. ACM Press, New York (2001)Google Scholar
  19. 19.
    Rosendahl, M.: Automatic Complexity Analysis. In: FPCA 1989: Proceedings of the fourth international conference on Functional programming languages and computer architecture, pp. 144–156. ACM Press, New York (1989)CrossRefGoogle Scholar
  20. 20.
    Van Roy, P., Haridi, S.: Concepts, Techniques, and Models of Computer Programming. MIT Press, Cambridge (2004)Google Scholar
  21. 21.
    Sands, D.: Complexity Analysis for a Lazy Higher-Order Language. In: Jones, N.D. (ed.) ESOP 1990. LNCS, vol. 432, pp. 361–376. Springer, Heidelberg (1990)Google Scholar
  22. 22.
    Sankaranarayanan, S., Sipma, H., Manna, Z.: Non-linear loop invariant generation using Gröbner bases. In: Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2004, Venice, Italy, January 14-16, pp. 318–329 (2004)Google Scholar
  23. 23.
    Tarski, A.: A decision method for elementary algebra and geometry. Prepared for publication by J.C.C. Mac Kinsey, Berkeley (1951)Google Scholar
  24. 24.
    Yu, T., Kaser, O.: A Note on “On the Conversion of Indirect to Direct Recursion”. ACM Trans. Program. Lang. Syst. 19(6), 1085–1087 (1997)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Hugh Anderson
    • 1
  • Siau-Cheng Khoo
    • 1
  • Stefan Andrei
    • 1
  • Beatrice Luca
    • 1
  1. 1.Department of Computer ScienceSchool of Computing, National University of Singapore 

Personalised recommendations