Skip to main content

pymwp: A Static Analyzer Determining Polynomial Growth Bounds

  • Conference paper
  • First Online:
Automated Technology for Verification and Analysis (ATVA 2023)

Abstract

We present pymwp, a static analyzer that automatically computes, if they exist, polynomial bounds relating input and output sizes. In case of exponential growth, our tool detects precisely which dependencies between variables induced it. Based on the sound mwp-flow calculus, the analysis captures bounds on large classes of programs by being non-deterministic and not requiring termination. For this reason, implementing this calculus required solving several non-trivial implementation problems, to handle its complexity and non-determinism, but also to provide meaningful feedback to the programmer. The duality of the analysis result and compositionality of the calculus make our approach original in the landscape of complexity analyzers. We conclude by demonstrating experimentally how pymwp is a practical and performant static analyzer to automatically evaluate variable growth bounds of C programs.

This research is supported by the Transatlantic Research Partnership of the Embassy of France in the United States and the FACE Foundation, and has benefited from the research meeting 21453 “Static Analyses of Program Flows: Types and Certificate for Complexity” in Schloss Dagstuhl. Th. Rubiano and Th. Seiller are supported by the Île-de-France region through the DIM RFSI project “CoHOp”.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 59.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 74.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Observe that the bound for X3’ involves X1 and X2: the presence of X1 in the bound of X2’ transitively impacts the bound for X3’, because the analysis is compositional.

  2. 2.

    pymwp actually outputs .

  3. 3.

    Obtaining this feedback requires to specify the --fin argument.

  4. 4.

    List of supported features: https://statycc.github.io/pymwp/features.

  5. 5.

    Full comparison: https://github.com/statycc/pymwp/compare/FSCD22...0.4.2.

  6. 6.

    A complex data structure sounds daunting, but it is in fact one of the highlights of the system, and enables to solve a difficult derivation problem efficiently. For details, see the documentation at https://statycc.github.io/pymwp/relation.

  7. 7.

    Bound of example5_1 does not appear in Table 3 because of this simplification.

References

  1. Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of object-oriented bytecode programs. Theor. Comput. Sci. 413(1), 142–159 (2012). https://doi.org/10.1016/j.tcs.2011.07.009

    Article  MathSciNet  MATH  Google Scholar 

  2. Alias, C., Darte, A., Feautrier, P., Gonnord, L.: Multi-dimensional rankings, program termination, and complexity bounds of flowchart programs. In: Cousot, R., Martel, M. (eds.) SAS 2010. LNCS, vol. 6337, pp. 117–133. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-15769-1_8

    Chapter  Google Scholar 

  3. Aubert, C., Rubiano, T., Rusch, N., Seiller, T.: Certifying complexity analysis (2023). https://hal.science/hal-04083105v1/file/main.pdf. Presented at the Ninth International Workshop on Coq for Programming Languages (CoqPL)

  4. Aubert, C., Rubiano, T., Rusch, N., Seiller, T.: LQICM On C Toy Parser (2021). https://github.com/statycc/LQICM_On_C_Toy_Parser

  5. Aubert, C., Rubiano, T., Rusch, N., Seiller, T.: mwp-analysis improvement and implementation: realizing implicit computational complexity. In: Felty, A.P. (ed.) 7th International Conference on Formal Structures for Computation and Deduction (FSCD 2022). Leibniz International Proceedings in Informatics, vol. 228, pp. 26:1–26:23. Schloss Dagstuhl-Leibniz-Zentrum für Informatik (2022). https://doi.org/10.4230/LIPIcs.FSCD.2022.26

  6. Aubert, C., Rubiano, T., Rusch, N., Seiller, T.: Realizing Implicit Computational Complexity (2022). https://hal.archives-ouvertes.fr/hal-03603510. Presented at the 28th International Conference on Types for Proofs and Programs (TYPES 2022) (Recording)

  7. Aubert, C., Rubiano, T., Rusch, N., Seiller, T.: pymwp: MWP analysis on C code in Python (2023). https://doi.org/10.5281/zenodo.7908484

  8. Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C., Giesl, J.: Analyzing runtime and size complexity of integer programs. ACM Trans. Programm. Lang. Syst. (TOPLAS) 38(4), 1–50 (2016). https://doi.org/10.1145/2866575

    Article  Google Scholar 

  9. Carbonneaux, Q., Hoffmann, J., Shao, Z.: Compositional certified resource bounds. In: Grove, D., Blackburn, S.M. (eds.) Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, Portland, OR, USA, 15–17 June 2015, pp. 467–478. Association for Computing Machinery (2015). https://doi.org/10.1145/2737924.2737955

  10. Dal Lago, U.: A short introduction to implicit computational complexity. In: Bezhanishvili, N., Goranko, V. (eds.) ESSLLI 2010-2011. LNCS, vol. 7388, pp. 89–109. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31485-8_3

    Chapter  Google Scholar 

  11. Flores Montoya, A.: Cost Analysis of Programs Based on the Refinement of Cost Relations. Ph.D. thesis, Technische Universität, Darmstadt (2017). http://tuprints.ulb.tu-darmstadt.de/6746/

  12. Flores-Montoya, A., Hähnle, R.: Resource analysis of complex programs with cost equations. In: Garrigue, J. (ed.) APLAS 2014. LNCS, vol. 8858, pp. 275–295. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-12736-1_15

    Chapter  Google Scholar 

  13. Giesl, J., et al.: Resource analysis of complex programs with cost equations. J. Autom. Reasoning 58(1), 3–31 (2016). https://doi.org/10.1007/s10817-016-9388-y

    Article  MathSciNet  Google Scholar 

  14. Hainry, E., Jeandel, E., Péchoux, R., Zeyen, O.: ComplexityParser: an automatic tool for certifying poly-time complexity of Java programs. In: Cerone, A., Ölveczky, P.C. (eds.) ICTAC 2021. LNCS, vol. 12819, pp. 357–365. Springer, Cham (2021). https://doi.org/10.1007/978-3-030-85315-0_20

    Chapter  MATH  Google Scholar 

  15. Hoffmann, J., Aehlig, K., Hofmann, M.: Resource aware ML. In: Madhusudan, P., Seshia, S.A. (eds.) CAV 2012. LNCS, vol. 7358, pp. 781–786. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31424-7_64

    Chapter  Google Scholar 

  16. Jones, N.D., Kristiansen, L.: A flow calculus of mwp-bounds for complexity analysis. ACM Trans. Comput. Logic 10(4), 28:1-28:41 (2009). https://doi.org/10.1145/1555746.1555752

    Article  MathSciNet  MATH  Google Scholar 

  17. Moser, G., Schneckenreither, M.: Automated amortised resource analysis for term rewrite systems. In: Gallagher, J.P., Sulzmann, M. (eds.) FLOPS 2018. LNCS, vol. 10818, pp. 214–229. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-90686-7_14

    Chapter  Google Scholar 

  18. Moyen, J.: Implicit Complexity in Theory and Practice. Habilitation thesis, University of Copenhagen (2017). https://lipn.univ-paris13.fr/moyen/papiers/Habilitation_JY_Moyen.pdf

  19. Moyen, J.-Y., Rubiano, T., Seiller, T.: Loop quasi-invariant chunk detection. In: D’Souza, D., Narayan Kumar, K. (eds.) ATVA 2017. LNCS, vol. 10482, pp. 91–108. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68167-2_7

    Chapter  Google Scholar 

  20. Moyen, J., Rubiano, T., Seiller, T.: Loop quasi-invariant chunk motion by peeling with statement composition. In: Bonfante, G., Moser, G. (eds.) Proceedings 8th Workshop on Developments in Implicit Computational Complexity and 5th Workshop on Foundational and Practical Aspects of Resource Analysis, DICE-FOPARA@ETAPS 2017, Uppsala, Sweden, 22–23 April 2017. Electronic Proceedings in Theoretical Computer Science, 248, pp. 47–59, 2017. https://doi.org/10.4204/EPTCS.248.9, http://arxiv.org/abs/1704.05169

  21. pycparser - Complete C99 parser in pure Python. https://github.com/eliben/pycparser

  22. pymwp at Python Package Index (2023). https://pypi.org/project/pymwp/

  23. pymwp documentation (2023). https://statycc.github.io/pymwp/

  24. pymwp source code repository (2023). https://github.com/statycc/pymwp

  25. Sinn, M., Zuleger, F., Veith, H.: Complexity and resource bound analysis of imperative programs using difference constraints. J. Autom. Reasoning 59(1), 3–45 (2017). https://doi.org/10.1007/s10817-016-9402-4

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgments

The authors wish to express their gratitude to the reviewers for their thoughtful comments, and to Antonio Flores Montoya, for the preparation and public sharing of his PhD thesis experimental evaluation resources [11].

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Clément Aubert .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Aubert, C., Rubiano, T., Rusch, N., Seiller, T. (2023). pymwp: A Static Analyzer Determining Polynomial Growth Bounds. In: André, É., Sun, J. (eds) Automated Technology for Verification and Analysis. ATVA 2023. Lecture Notes in Computer Science, vol 14216. Springer, Cham. https://doi.org/10.1007/978-3-031-45332-8_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-45332-8_14

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-45331-1

  • Online ISBN: 978-3-031-45332-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics