skip to main content
research-article

Analysing the complexity of functional programs: higher-order meets first-order

Published: 29 August 2015 Publication History

Abstract

We show how the complexity of higher-order functional programs can be analysed automatically by applying program transformations to a defunctionalised versions of them, and feeding the result to existing tools for the complexity analysis of first-order term rewrite systems. This is done while carefully analysing complexity preservation and reflection of the employed transformations such that the complexity of the obtained term rewrite system reflects on the complexity of the initial program. Further, we describe suitable strategies for the application of the studied transformations and provide ample experimental data for assessing the viability of our method.

References

[1]
B. Accattoli and U. Dal Lago. Beta Reduction is Invariant, Indeed. In Proc. of 23rd CSL, pages 8:1–8:10. ACM, 2014.
[2]
B. Accattoli and C. Sacerdoti Coen. On the Usefulness of Constructors. In Proc. of 30th LICS. IEEE, 2015. To appear.
[3]
E. Albert, S. Genaim, and A. N. Masud. On the Inference of Resource Usage Upper and Lower Bounds. TOCL, 14(3):22(1–35), 2013.
[4]
T. Arts and J. Giesl. Termination of Term Rewriting using Dependency Pairs. TCS, 236(1–2):133–178, 2000.
[5]
D. Aspinall, L. Beringer, M. Hofmann, H.-W. Loidl, and A. Momigliano. A Program Logic for Resources. TCS, 389(3):411–445, 2007.
[6]
M. Avanzini and G. Moser. Closing the Gap Between Runtime Complexity and Polytime Computability. In Proc. of 21st RTA, volume 6 of LIPIcs, pages 33–48, 2010.
[7]
M. Avanzini and G. Moser. Polynomial Path Orders. LMCS, 9(4), 2013.
[8]
M. Avanzini and G. Moser. Tyrolean Complexity Tool: Features and Usage. In Proc. of 24th RTA, volume 21 of LIPIcs, pages 71–80, 2013.
[9]
M. Avanzini and G. Moser. A Combination Framework for Complexity. IC, 2015. To appear.
[10]
M. Avanzini, U. Dal Lago, and G. Moser. Analysing the Complexity of Functional Programs: Higher-Order Meets First-Order (Long Version). CoRR, cs/CC/1506.05043, 2015. Available at http://www.arxiv. org/abs/1506.05043.
[11]
F. Baader and T. Nipkow. Term Rewriting and All That. Cambridge University Press, 1998. ISBN 978-0-521-77920-3.
[12]
P. Baillot and U. Dal Lago. Higher-Order Interpretations and Program Complexity. In Proc. of 26th CSL, volume 16 of LIPIcs, pages 62–76, 2012.
[13]
P. Baillot and K. Terui. Light types for Polynomial Time Computation in Lambda Calculus. IC, 207(1):41–62, 2009.
[14]
R. Benzinger. Automated Higher-order Complexity Analysis. TCS, 318(1-2):79–103, 2004.
[15]
R. Bird. Introduction to Functional Programming using Haskell, Second Edition. Prentice Hall, 1998. ISBN 978-0-134-84346-9.
[16]
G. Bonfante, A. Cichon, J.-Y. Marion, and H. Touzet. Algorithms with Polynomial Interpretation Termination Proof. JFP, 11(1):33–53, 2001.
[17]
G. Bonfante, J.-Y. Marion, and R. Péchoux. Quasi-interpretation Synthesis by Decomposition and an Application to Higher-order Programs. In Proc. of 4th ICTAC, volume 4711 of LNCS, pages 410– 424, 2007.
[18]
U. Dal Lago and M. Gaboardi. Linear Dependent Types and Relative Completeness. LMCS, 8(4), 2012.
[19]
U. Dal Lago and S. Martini. On Constructor Rewrite Systems and the Lambda Calculus. LMCS, 8(3):1–27, 2012.
[20]
U. Dal Lago and B. Petit. The Geometry of Types. In Proc. of 40th POPL, pages 167–178. ACM, 2013.
[21]
N. Danielsson. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In Proc. of 35th POPL, pages 133–144. ACM, 2008.
[22]
O. Danvy and L. R. Nielsen. Defunctionalization at Work. In Proc. of 3rd PPDP, pages 162–174. ACM, 2001.
[23]
G. Feuillade, T. Genet, and V. Viet Triem Tong. Reachability Analysis over Term Rewriting Systems. JAR, 33(3-4):341–383, 2004.
[24]
J. Giesl, R. Thiemann, and P. Schneider-Kamp. Proving and Disproving Termination of Higher-Order Functions. In Proc. of 5th FROCOS, volume 3717 of LNCS, pages 216–231, 2005.
[25]
J. Giesl, M. Raffelsieper, P. Schneider-Kamp, S. Swiderski, and R. Thiemann. Automated Termination Proofs for Haskell by Term Rewriting. TOPLAS, 33(2):7:1–7:39, 2011.
[26]
J. Giesl, M. Brockschmidt, F. Emmes, F. Frohn, C. Fuhs, C. Otto, M. Plücker, P. Schneider-Kamp, T. Ströder, S. Swiderski, and R. Thiemann. Proving Termination of Programs Automatically with AProVE. In Proc. of 7th IJCAR, volume 8562 of LNCS, pages 184–191, 2014.
[27]
G. Gomez and Y. Liu. Automatic Time-bound Analysis for a Higherorder Language. In Proc. of 9th PEPM, pages 75–86. ACM, 2002.
[28]
B. Gramlich. Abstract Relations between Restricted Termination and Confluence Properties of Rewrite Systems. FI, 24:3–23, 1995.
[29]
R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2012. ISBN 978-1-107-02957-6.
[30]
N. Hirokawa and G. Moser. Automated Complexity Analysis Based on the Dependency Pair Method. In Proc. of 4th IJCAR, volume 5195 of LNAI, pages 364–380, 2008.
[31]
N. Hirokawa and G. Moser. Complexity, Graphs, and the Dependency Pair Method. In Proc. of 15th LPAR, volume 5330 of LNCS, pages 652–666, 2008.
[32]
N. Hirokawa, A. Middeldorp, and H. Zankl. Uncurrying for Termination and Complexity. JAR, 50(3):279–315, 2013.
[33]
N. D. Jones. Flow Analysis of Lazy Higher-order Functional Programs. TCS, 375(1-3):120–136, 2007.
[34]
N. D. Jones and N. Bohr. Call-by-Value Termination in the Untyped lambda-Calculus. LMCS, 4(1), 2008.
[35]
S. Jost, K. Hammond, H.-W. Loidl, and M.Hofmann. Static Determination of Quantitative Resource Usage for Higher-order Programs. In Proc. of 37th POPL, pages 223–236. ACM, 2010.
[36]
J. Kochems and L. Ong. Improved Functional Flow and Reachability Analyses Using Indexed Linear Tree Grammars. In Proc. of 22nd RTA, volume 10 of LIPIcs, pages 187–202, 2011.
[37]
M. Korp, C. Sternagel, H. Zankl, and A. Middeldorp. Tyrolean Termination Tool 2. In Proc. of 20th RTA, volume 5595 of LNCS, pages 295–304, 2009.
[38]
J.-Y. Marion. Analysing the Implicit Complexity of Programs. IC, 183: 2–18, 2003.
[39]
J. Midtgaard. Control-flow Analysis of Functional Programs. ACM Comput. Surv., 44(3):10, 2012.
[40]
G. Moser. Proof Theory at Work: Complexity Analysis of Term Rewrite Systems. CoRR, cs.LO/0907.5527, 2009. Habilitation Thesis.
[41]
F. Nielson, H. Nielson, and C. Hankin. Principles of Program Analysis. Springer, 2005. ISBN 978-3-540-65410-0.
[42]
L. Noschinski, F. Emmes, and J. Giesl. A Dependency Pair Framework for Innermost Complexity Analysis of Term Rewrite Systems. In Proc. of 23rd CADE, LNAI, pages 422–438. Springer, 2011.
[43]
C. Okasaki. Functional Pearl: Even Higher-Order Functions for Parsing. JFP, 8(2):195–199, 1998.
[44]
S. E. Panitz and M. Schmidt-Schauß. TEA: Automatically Proving Termination of Programs in a Non-Strict Higher-Order Functional Language. In Proc. of 4th SAS, pages 345–360, 1997.
[45]
B. C. Pierce. Types and programming languages. MIT Press, 2002. ISBN 978-0-262-16209-8.
[46]
G. D. Plotkin. LCF Considered as a Programming Language. TCS, 5 (3):223–255, 1977.
[47]
F. Rabhi and G. Lapalme. Algorithms: A Functional Programming Approach. Addison-Wesley, 1999. ISBN 978-0-201-59604-5.
[48]
J. C. Reynolds. Definitional Interpreters for Higher-Order Programming Languages. Higher-Order and Symbolic Computation, 11(4):363–397, 1998.
[49]
D. Sands. Complexity Analysis for a Lazy Higher-Order Language. In Proc. of 3rd ESOP, volume 432 of LNCS, pages 361–376, 1990.
[50]
M. Sinn, F. Zuleger, and H. Veith. A Simple and Scalable Static Analysis for Bound Analysis and Amortized Complexity Analysis. In Proc. of 26th CAV, volume 8559 of LNCS, pages 745–761, 2014.
[51]
C. Sternagel and R. Thiemann. Generalized and Formalized Uncurrying. In Proc. of 8th FROCOS, volume 6989 of LNCS, pages 243–258, 2011.
[52]
TeReSe. Term Rewriting Systems, volume 55. Cambridge University Press, 2003. ISBN 978-0-521-39115-3.
[53]
P. B. Vasconcelos and K. Hammond. Inferring Cost Equations for Recursive, Polymorphic and Higher-Order Functional Programs. In Revised Papers of 15th Workshop on IFL, pages 86–101, 2003.
[54]
R. Wilhelm, J. Engblom, A. Ermedahl, N. Holsti, S. Thesing, D. Whalley, G. Bernat, C. Ferdinand, R. Heckmann, T. Mitra, F. Mueller, I. Puaut, P. Puschner, J. Staschulat, and P. Stenstrom. The Worst Case Execution Time Problem - Overview of Methods and Survey of Tools. TECS, pages 1–53, 2008.
[55]
H. Zankl and M. Korp. Modular Complexity Analysis for Term Rewriting. LMCS, 10(1:19):1–33, 2014.

Cited By

View all

Index Terms

  1. Analysing the complexity of functional programs: higher-order meets first-order

    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 Tags

    1. Defunctionalisation
    2. term rewriting
    3. termination and resource analysis

    Qualifiers

    • Research-article

    Funding Sources

    • FWF
    • ANR

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)8
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 05 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all

    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