Using Intersection Types for Cost-Analysis of Higher-Order Polymorphic Functional Programs

  • Hugo R. Simões
  • Kevin Hammond
  • Mário Florido
  • Pedro Vasconcelos
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4502)

Abstract

This paper presents a system of cost derivation for higher-order and polymorphic functional programs based on a notion of sized types and exploiting a type-and-effect system approach. The paper gives an operational semantics of cost for a simple strict functional language in terms of λ-calculus β-reduction steps and introduces type rules describing cost effects. The type system is based on intersection types. The use of discrete polymorphism (intersection types) instead of the usual parametric polymorphism approach improves the analysis and solves, in many cases, the “size aliasing problem” that has been identified as a limitation on previous type-and-effect approaches. Finally we provide a proof of the soundness of our effect system with respect to the cost semantics.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Amtoft, T., Nielson, F., Nielson, H.R.: Type and Effect Systems: Behaviours for Concurrency. Imperial College Press (1999)Google Scholar
  2. 2.
    Banerjee, A., Jensen, T.: Modular control-flow analysis with rank 2 intersection types. Mathematical. Structures in Comp. Sci. 13(1), 87–124 (2003)MATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Barendregt, H.: The Lambda Calculus. Its Syntax and Semantics. In: Studies in Logic and the Foundations of Mathematics, vol. 103, North-Holland, Amsterdam (1984)Google Scholar
  4. 4.
    Barendregt, H., Coppo, M., Dezani-Ciancaglini, M.: A filter lambda model and the completeness of type assignment. The Journal of Symbolic Logic 48(4), 931–940 (1983)MATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Carlier, S., Polakow, J., Wells, J.B., Kfoury, A.J.: System e: Expansion variables for flexible typing with linear and non-linear types and intersection types. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 294–309. Springer, Heidelberg (2004)Google Scholar
  6. 6.
    Chin, W.-N., Khoo, S.-C.: Calculating Sized Types. Higher-Order and Symbolic Computing 14(2,3) (2001)Google Scholar
  7. 7.
    Coppo, M., Dezani-Ciancaglini, M.: An extension of the basic functionality theory for the λ-calculus. Notre-Dame Journal of Formal Logic 21(4), 685–693 (1980)MATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Coppo, M., Giannini, P.: Principal types and unification for simple intersection type systems. Information and Computation 122(1) (1995)Google Scholar
  9. 9.
    Lago, U.D., Martini, S.: An invariant cost model for the lambda calculus. In: Beckmann, A., Berger, U., Löwe, B., Tucker, J.V. (eds.) CiE 2006. LNCS, vol. 3988, pp. 105–114. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  10. 10.
    Damiani, F.: Rank 2 intersection types for local definitions and conditional expressions. ACM Transactions On Programming Languages and Systems 25(4), 401–451 (2003)CrossRefGoogle Scholar
  11. 11.
    Damiani, F., Giannini, P.: A decidable intersection type system based on relevance. In: Theoretical Aspects of Computer Science. LNCS, Springer, Heidelberg (1994)Google Scholar
  12. 12.
    Damiani, F.: Rank-2 Intersection and Polymorphic Recursion. In: Urzyczyn, P. (ed.) TLCA 2005. LNCS, vol. 3461, pp. 146–161. Springer, Heidelberg (2005)Google Scholar
  13. 13.
    Davies, R., Pfenning, F.: Intersection types and computational effects. In: ICFP, pp. 198–208 (2000)Google Scholar
  14. 14.
    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
  15. 15.
    Felleisen, M., Friedman, D.P.: Control Operators, the SECD-Machine and the λ-Calculus. In: Wirsing, M. (ed.) Formal Description of Programming Concepts III, pp. 193–217. Elsevier, Amsterdam (1986)Google Scholar
  16. 16.
    Grobauer, B.: Cost Recurrences for DML Programs. In: Proc. 2001 ACM Intl. Conf. on Functional Programming – ICFP 2001, Florence, Italy (September 2001)Google Scholar
  17. 17.
    Hofmann, M., Jost, S.: Type-based amortised heap-space analysis (for an object-oriented language). In: Sestoft, P. (ed.) ESOP 2006 and ETAPS 2006. LNCS, vol. 3924, pp. 22–37. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  18. 18.
    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
  19. 19.
    Jim, T.: Rank 2 type systems and recursive definitions. Technical Report MIT/LCS/TM-531, Massachusetts Institute of Technology, Laboratory for Computer Science (November 1995)Google Scholar
  20. 20.
    Kfoury, A.J., Wells, J.B.: Principality and decidable type inference for finite-rank intersection types. In: Assaf, J. (ed.) popl99, pp. 161–174. ACM Press, New York (1999)Google Scholar
  21. 21.
    Launchbury, J.: A Natural Semantics for Lazy Evaluation. In: Proc. 1993 ACM Symp. on Principles of Prog. Langs. – POPL 1993, pp. 144–154 (1993)Google Scholar
  22. 22.
    Milner, A.J.R.G.: A Theory of Type Polymorphism in Programming. J. Computer System Sciences 17(3), 348–375 (1976)CrossRefMathSciNetGoogle Scholar
  23. 23.
    Nielson, F., Nielson, H., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (1999)MATHGoogle Scholar
  24. 24.
    Pottinger, G.: A type assignement for the strongly normalizable terms. In: Hindley, J.R., Seldin, J.P. (eds.) To H.B. Curry, Essays in Combinatory Logic, Lambda-calculus and Formalism, pp. 561–577. Academic Press, San Diego (1980)Google Scholar
  25. 25.
    Portillo, A.J.R., Hammond, K., Loidl, H.-W., Vasconcelos, P.: Cost analysis using automatic size and time inference. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, pp. 232–247. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  26. 26.
    Reistad, B., Gifford, D.K.: Static Dependent Costs for Estimating Execution Time. In: Proc. 1994 ACM Conference on Lisp and Functional Programming – LFP 1994, pp. 65–78, Orlando, FL (June 1994)Google Scholar
  27. 27.
    Simoes, H.R., Hammond, K., Florido, M., Vasconcelos, P.: Using intersection types for cost-analysis of higher-order polymorphic functional programs. Technical report (2006), http://www.dcs.st-and.ac.uk/~kh/papers/itypes_cost.pdf
  28. 28.
    van Bakel, S.: Intersection Type Disciplines in Lambda Calculus and Applicative Term Rewriting Systems. PhD thesis, Department of Computer Science, University of Nijmegen (1993)Google Scholar
  29. 29.
    van Bakel, S.: Rank 2 intersection type assignment in term rewriting systems. Fundam. Inform. 26(2), 141–166 (1996)MATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Hugo R. Simões
    • 1
    • 2
  • Kevin Hammond
    • 1
  • Mário Florido
    • 2
  • Pedro Vasconcelos
    • 2
  1. 1.School of Computer Science, University of St Andrews, St Andrews, KY16 9SSUK
  2. 2.University of Porto, DCC & LIACC, Rua do Campo Alegre, 1021/1055, 4169-007 PortoPortugal

Personalised recommendations