Inferring Cost Equations for Recursive, Polymorphic and Higher-Order Functional Programs

  • Pedro B. Vasconcelos
  • Kevin Hammond
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3145)


This paper presents a type-based analysis for inferring size- and cost-equations for recursive, higher-order and polymorphic functional programs without requiring user annotations or unusual syntax. Our type reconstruction algorithm is capable of inferring first-order cost equations for a non-trivial subset of higher-order, recursive and polymorphic functions. We illustrate the approach with reference to some standard examples of recursive programs.


Recurrence Equation Recursive Function Inference Algorithm Type Inference Cost Equation 
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.
    Amtoft, T., Nielson, F., Nielson, H.R.: Type and Effect Systems: Behaviours for Concurrency. Imperial College Press, London (1999)Google Scholar
  2. 2.
    Benzinger, R.: Automated Complexity Analysis of Nuprl Extracted Programs. Journal of Functional Programming 11(1), 3–31 (2001)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Chin, W.-N., Khoo, S.-C.: Calculating Sized Types. Higher-Order and Symbolic Computing 14(2,3) (2001)Google Scholar
  4. 4.
    Damas, L., Milner, A.J.R.G.: Principal Type-Schemes for Functional Programs. In: Proc. 1982 ACM Symp. on Principles of Prog. Langs. – POPL 1982, pp. 207–212 (1982)Google Scholar
  5. 5.
    Dornic, V., Jouvelot, P., Gifford, D.K.: Polymorphic Time Systems for Estimating Program Complexity. ACM Letters on Prog. Lang. and Systems 1(1), 33–45 (1992)CrossRefGoogle Scholar
  6. 6.
    Hughes, R.J.M., Pareto, L., Sabry, A.: Proving the Correctness of Reactive Systems using Sized Types. In: Proc 1996 ACM Symposium on Principles of Programming Languages – POPL 1996, St Petersburg, FL (January 1996)Google Scholar
  7. 7.
    Le Métayer, D.: ACE: An Automatic Complexity Evaluator. ACM Transactions on Programming Languages and Systems 10(2) (April 1988)Google Scholar
  8. 8.
    Levy, H., Lessman, F.: Finite Difference Equations. Macmillan, Basingstoke (1961)Google Scholar
  9. 9.
    Loidl, H.-W., Hammond, K.: A Sized Time System for a Parallel Functional Language. In: Glasgow Workshop on Functional Programming, Ullapool (July 1996)Google Scholar
  10. 10.
    Milner, A.J.R.G.: A Theory of Type Polymorphism in Programming. J. Computer System Sciences 17(3), 348–375 (1976)CrossRefMathSciNetGoogle Scholar
  11. 11.
    Nielson, F., Nielson, H., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (1999)zbMATHGoogle Scholar
  12. 12.
    Rebón Portillo, Á., Hammond, K., Loidl, H.-W., Vasconcelos, P.B.: Cost Analysis using Automatic Size and Time Inference. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Reistad, B., Gifford, D.K.: Static Dependent Costs for Estimating Execution Time. In: Proc. 1994 ACM Conference on Lisp and Functional Programming – LFP 1994, June 1994, pp. 65–78, Orlando, FL (1994)Google Scholar
  14. 14.
    Rosendahl, M.: Automatic Complexity Analysis. In: Proc. 1989 Intl. Conf. on Functional Prog. Langs. and Comp. Arch. – FPCA 1989, pp. 144–156 (1989)Google Scholar
  15. 15.
    Turner, D.A.: Elementary Strong Functional Programming. In: Hartel, P.H., Plasmeijer, R. (eds.) FPLE 1995. LNCS, vol. 1022, Springer, Heidelberg (1995)Google Scholar
  16. 16.
    Vasconcelos, P.B., Hammond, K.: A Type and Effect System for Costing Recursive, Higher-Order and Polymorphic Functional Programs (2004) (in preparation)Google Scholar
  17. 17.
    Wegbreit, B.: Mechanical Program Analysis. Comm. of the ACM 18(9) (1975)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Pedro B. Vasconcelos
    • 1
  • Kevin Hammond
    • 1
  1. 1.School of Computer ScienceUniversity of St AndrewsSt AndrewsUK

Personalised recommendations