skip to main content
research-article

Denotational cost semantics for functional languages with inductive types

Published: 29 August 2015 Publication History

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. 1145/359576.359579.
[2]
R. Benzinger. Automated higher-order complexity analysis. Theoretical Computer Science, 318(1-2):79 – 103, 2004. 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.
[3]
N. Danner and J. S. Royer. Two algorithms in search of a type system. Theory of Computing Systems, 45(4):787–821, 2009. 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.
[4]
N. Danner, D. R. Licata, and R. Ramyaa. Denotational cost semantics for functional languages with inductive types. arXiv:1506.01949, 2015.
[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.
[6]
R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013.
[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.
[8]
D. Le Métayer. ACE: an automatic complexity evaluator. ACM Transactions on Programming Languages and Systems, 10(2):248–266, 1988. 1145/42190.42347.
[9]
X. Leroy and H. Grall. Coinductive big-step operational semantics. Information and Computation, 207(2):284–304, 2009.
[10]
12.004. E. Moggi. Notions of computation and monads. Information And Computation, 93(1):55–92, 1991. 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. C. Okasaki. Purely Functional Data Structures. Cambridge University Press, 1998.
[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.
[12]
D. Sands. Calculi for Time Analysis of Functional Programs. PhD thesis, University of London, 1990.
[13]
J. Shultis. On the complexity of higher-order programs. Technical Report CU-CS-288-85, University of Colorado at Boulder, 1985.
[14]
K. Van Stone. A Denotational Approach to Measuring Complexity in Functional Programs. PhD thesis, School of Computer Science, Carnegie Mellon University, 2003.
[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. 1145/41625.41653.
[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.
[18]
B. Wegbreit. Mechanical program analysis. Communications of the Association for Computing Machinery, 18(9):528–539, 1975. 1145/361002.361016.

Cited By

View all
  • (2024)Modeling and Analyzing Evaluation Cost of CUDA KernelsACM Transactions on Parallel Computing10.1145/363940311:1(1-53)Online publication date: 12-Jan-2024
  • (2017)Automated Sized-Type Inference and Complexity AnalysisElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.248.5248(7-16)Online publication date: 18-Apr-2017
  • (2023)A Metalanguage for Cost-Aware Denotational Semantics2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS56636.2023.10175777(1-14)Online publication date: 26-Jun-2023
  • Show More Cited By

Index Terms

  1. Denotational cost semantics for functional languages with inductive types

        Recommendations

        Comments

        Information & Contributors

        Information

        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
        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        Published: 29 August 2015
        Published in SIGPLAN Volume 50, Issue 9

        Check for updates

        Author Tag

        1. Semi-automatic complexity analysis

        Qualifiers

        • Research-article

        Funding Sources

        Contributors

        Other Metrics

        Bibliometrics & Citations

        Bibliometrics

        Article Metrics

        • Downloads (Last 12 months)17
        • Downloads (Last 6 weeks)2
        Reflects downloads up to 13 Dec 2024

        Other Metrics

        Citations

        Cited By

        View all
        • (2024)Modeling and Analyzing Evaluation Cost of CUDA KernelsACM Transactions on Parallel Computing10.1145/363940311:1(1-53)Online publication date: 12-Jan-2024
        • (2017)Automated Sized-Type Inference and Complexity AnalysisElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.248.5248(7-16)Online publication date: 18-Apr-2017
        • (2023)A Metalanguage for Cost-Aware Denotational Semantics2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS56636.2023.10175777(1-14)Online publication date: 26-Jun-2023
        • (2023)Automatic Amortized Resource Analysis with Regular Recursive Types2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS56636.2023.10175720(1-14)Online publication date: 26-Jun-2023
        • (2022)A cost-aware logical frameworkProceedings of the ACM on Programming Languages10.1145/34986706:POPL(1-31)Online publication date: 12-Jan-2022
        • (2022)Migrating gradual typesJournal of Functional Programming10.1017/S095679682200008932Online publication date: 6-Oct-2022
        • (2022)Denotational semantics as a foundation for cost recurrence extraction for functional languagesJournal of Functional Programming10.1017/S095679682200003X32Online publication date: 5-Jul-2022
        • (2021)On continuation-passing transformations and expected cost analysisProceedings of the ACM on Programming Languages10.1145/34735925:ICFP(1-30)Online publication date: 19-Aug-2021
        • (2021)Automatic amortized resource analysis with the Quantum physicist’s methodProceedings of the ACM on Programming Languages10.1145/34735815:ICFP(1-29)Online publication date: 19-Aug-2021
        • (2021)A unifying type-theory for higher-order (amortized) cost analysisProceedings of the ACM on Programming Languages10.1145/34343085:POPL(1-28)Online publication date: 4-Jan-2021
        • Show More Cited By

        View Options

        Login options

        View options

        PDF

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        Media

        Figures

        Other

        Tables

        Share

        Share

        Share this Publication link

        Share on social media