skip to main content
research-article

Denotational cost semantics for functional languages with inductive types

Published:29 August 2015Publication History
Skip Abstract Section

Abstract

A central method for analyzing the asymptotic complexity of a functional program is to extract and then solve a recurrence that expresses evaluation cost in terms of input size. The relevant notion of input size is often specific to a datatype, with measures including the length of a list, the maximum element in a list, and the height of a tree. In this work, we give a formal account of the extraction of cost and size recurrences from higher-order functional programs over inductive datatypes. Our approach allows a wide range of programmer-specified notions of size, and ensures that the extracted recurrences correctly predict evaluation cost. To extract a recurrence from a program, we first make costs explicit by applying a monadic translation from the source language to a complexity language, and then abstract datatype values as sizes. Size abstraction can be done semantically, working in models of the complexity language, or syntactically, by adding rules to a preorder judgement. We give several different models of the complexity language, which support different notions of size. Additionally, we prove by a logical relations argument that recurrences extracted by this process are upper bounds for evaluation cost; the proof is entirely syntactic and therefore applies to all of the models we consider.

References

  1. J. Backus. Can programming be liberated from the von Neumann style? A functional style and its algebra of programs. Communications of the Association for Computing Machinery, 21(8):613–641, 1978. doi: 10. 1145/359576.359579. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. R. Benzinger. Automated higher-order complexity analysis. Theoretical Computer Science, 318(1-2):79 – 103, 2004. doi: 10.1016/j.tcs.2003.10. 022. N. A. Danielsson. Lightweight semiformal time complexity analysis for purely functional data structures. In A. Aiken and G. Morrisett, editors, Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 133–144. ACM Press, 2003. doi: 10.1145/1328438.1328457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. N. Danner and J. S. Royer. Two algorithms in search of a type system. Theory of Computing Systems, 45(4):787–821, 2009. doi: 10.1007/ s00224-009-9181-y. N. Danner, J. Paykin, and J. S. Royer. A static cost analysis for a higher-order language. In M. Might and D. V. Horn, editors, Proceedings of the 7th workshop on Programming languages meets program verification, pages 25–34. ACM Press, 2013. doi: 10.1145/2428116.2428123. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. N. Danner, D. R. Licata, and R. Ramyaa. Denotational cost semantics for functional languages with inductive types. arXiv:1506.01949, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. S. K. Debray and N.-W. Lin. Cost analysis of logic programs. ACM Transactions on Programming Languages and Systems, 15(5):826–875, 1993. doi: 10.1145/161468.161472. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. S. Jost, K. Hammond, H.-W. Loidl, and M. Hofmann. Static determination of quantitative resource usage for higher-order programs. In M. Hermenegildo, editor, Proceedings of the 37th Annual ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, pages 223–236. ACM Press, 2010. doi: 10.1145/1706299.1706327. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. D. Le Métayer. ACE: an automatic complexity evaluator. ACM Transactions on Programming Languages and Systems, 10(2):248–266, 1988. doi: 10. 1145/42190.42347. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. X. Leroy and H. Grall. Coinductive big-step operational semantics. Information and Computation, 207(2):284–304, 2009. doi: 10.1016/j.ic.2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 12.004. E. Moggi. Notions of computation and monads. Information And Computation, 93(1):55–92, 1991. doi: 10.1016/0890-5401(91)90052-4. J. Navas, E. Mera, P. López-Garcia, and M. V. Hermenegildo. User-definable resource bounds analysis for logic programs. In V. Dahl and I. Niemelä, editors, Proceedings of Logic Programming: 23rd International Conference, ICLP 2007, volume 4670 of Lecture Notes in Computer Science, pages 348–363, 2007. doi: 10.1007/978-3-540-74610-2_24. C. Okasaki. Purely Functional Data Structures. Cambridge University Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Rosendahl. Automatic complexity analysis. In J. E. Stoy, editor, Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, pages 144–156. ACM Press, 1989. doi: 10.1145/99370.99381. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. Sands. Calculi for Time Analysis of Functional Programs. PhD thesis, University of London, 1990.Google ScholarGoogle Scholar
  13. J. Shultis. On the complexity of higher-order programs. Technical Report CU-CS-288-85, University of Colorado at Boulder, 1985.Google ScholarGoogle Scholar
  14. K. Van Stone. A Denotational Approach to Measuring Complexity in Functional Programs. PhD thesis, School of Computer Science, Carnegie Mellon University, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. P. Wadler. Views: A way for pattern matching to cohabit with data abstraction. In Proceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pages 307–313, 1987. doi: 10. 1145/41625.41653. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. P. Wadler. The essence of functional programming. In R. Sethi, editor, Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 1–14. ACM Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. doi: 10.1145/143165.143169.Google ScholarGoogle Scholar
  18. B. Wegbreit. Mechanical program analysis. Communications of the Association for Computing Machinery, 18(9):528–539, 1975. doi: 10. 1145/361002.361016. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Denotational cost semantics for functional languages with inductive types

        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

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 50, Issue 9
          ICFP '15
          September 2015
          436 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2858949
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
            August 2015
            436 pages
            ISBN:9781450336697
            DOI:10.1145/2784731

          Copyright © 2015 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 29 August 2015

          Check for updates

          Qualifiers

          • research-article

        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!