skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Relational cost analysis for functional-imperative programs

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

Relational cost analysis aims at formally establishing bounds on the difference in the evaluation costs of two programs. As a particular case, one can also use relational cost analysis to establish bounds on the difference in the evaluation cost of the same program on two different inputs. One way to perform relational cost analysis is to use a relational type-and-effect system that supports reasoning about relations between two executions of two programs.

Building on this basic idea, we present a type-and-effect system, called ARel, for reasoning about the relative cost of array-manipulating, higher-order functional-imperative programs. The key ingredient of our approach is a new lightweight type refinement discipline that we use to track relations (differences) between two mutable arrays. This discipline combined with Hoare-style triples built into the types allows us to express and establish precise relative costs of several interesting programs which imperatively update their data. We have implemented ARel using ideas from bidirectional type checking.

Skip Supplemental Material Section

Supplemental Material

a92-qu.webm

webm

102.7 MB

References

  1. Amal Ahmed. 2006. Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types. In Proceedings of the European Conference on Programming Languages and Systems (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed, Derek Dreyer, and Andreas Rossberg. 2009. State-dependent representation independence. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal G Ahmed. 2004. Semantics of types for mutable state. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Andrew W. Appel and David A. McAllester. 2001. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23, 5 (2001), 657–683. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert Atkey. 2010. Amortised Resource Analysis with Separation Logic. In Proceedings of the European Conference on Programming Languages and Systems (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Martin Avanzini and Ugo Dal Lago. 2017. Automating sized type inference for complexity analysis. In Proceedings of DICE-FOPARA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Gilles Barthe, Cédric Fournet, Benjamin Grégoire, Pierre-Yves Strub, Nikhil Swamy, and Santiago Zanella Béguelin. 2014. Probabilistic relational verification for cryptographic implementations. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Gilles Barthe, Marco Gaboardi, Emilio Jesús Gallego Arias, Justin Hsu, Aaron Roth, and Pierre-Yves Strub. 2015. HigherOrder Approximate Relational Refinement Types for Mechanism Design and Differential Privacy. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Nick Benton. 2004. Simple relational correctness proofs for static analyses and program transformations.. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Nick Benton, Martin Hofmann, and Vivek Nigam. 2014. Abstract effects and proof-relevant logical relations. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Nick Benton, Martin Hofmann, and Vivek Nigam. 2016. Effect-dependent transformations for concurrent programs. In Proceedings of the 18th International Symposium on Principles and Practice of Declarative Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. François Bobot, Sylvain Conchon, E Contejean, Mohamed Iguernelala, Stéphane Lescuyer, and Alain Mebsout. 2013. The Alt-Ergo automated theorem prover, 2008.Google ScholarGoogle Scholar
  13. Marc Brockschmidt, Fabian Emmes, Stephan Falke, Carsten Fuhs, and Jürgen Giesl. 2014. Alternating Runtime and Size Complexity Analysis of Integer Programs. In Tools and Alg. for the Constr. and Anal. of Systems - 20th Int. Conf. (TACAS).Google ScholarGoogle Scholar
  14. Quentin Carbonneaux, Jan Hoffmann, and Zhong Shao. 2015. Compositional Certified Resource Bounds. In Proceedings of the 36th Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Ezgi Çiçek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2017. Relational Cost Analysis. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Arthur Charguéraud and François Pottier. 2015. Machine-Checked Verification of the Correctness and Amortized Complexity of an Efficient Union-Find Implementation. In Interactive Theorem Proving - 6th International Conference, ITP.Google ScholarGoogle Scholar
  17. Ezgi Çiçek, Zoe Paraskevopoulou, and Deepak Garg. 2016. A Type Theory for Incremental Computational Complexity With Control Flow Changes. In Proceedings of the International Conference on Functional Programming(ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Ezgi Çiçek, Weihao Qu, Gilles Barthe, Marco Gaboardi, and Deepak Garg. 2019. Bidirectional type checking for relational properties. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2019, Phoenix, AZ, USA, June 22-26, 2019. 533–547. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. James W. Cooley and John W. Tukey. 1965. An Algorithm for the Machine Calculation of Complex Fourier Series. Math. Comp. (1965).Google ScholarGoogle Scholar
  20. Ugo Dal Lago and Marco Gaboardi. 2011. Linear Dependent Types and Relative Completeness. In Proceedings of the IEEE 26th Annual Symposium on Logic in Computer Science (LICS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jean-Christophe Filliâtre and Andrei Paskevich. 2013. Why3: Where Programs Meet Provers. In Proceedings of the European Conference on Programming Languages and Systems (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Marco Gaboardi, Andreas Haeberlen, Justin Hsu, Arjun Narayan, and Benjamin C. Pierce. 2013. Linear Dependent Types for Differential Privacy. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Bernd Grobauer. 2001. Cost recurrences for DML programs. In Proceedings of the 6th International Conference on Functional Programming (ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. V. Hermenegildo, G. Puebla, F. Bueno, and P. Lopez-Garcia. 2005. Integrated Program Debugging, Verification, and Optimization Using Abstract Interpretation (and The Ciao System Preprocessor). Science of Computer Programming 58, 1–2 (October 2005), 115–140. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012a. Multivariate Amortized Resource Analysis. ACM Trans. Program. Lang. Syst. (2012). Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012b. Resource Aware ML. In Computer Aided Verification - 24th International Conference, CAV. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Shuvendu K. Lahiri, Kapil Vaswani, and C. A. R. Hoare. 2010. Differential static analysis: opportunities, applications, and challenges. In Proceedings of the Workshop on Future of Software Engineering Research, FoSER 2010, at the 18th ACM SIGSOFT International Symposium on Foundations of Software Engineering, Gruia-Catalin Roman and Kevin J. Sullivan (Eds.). Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Benjamin Lichtman and Jan Hoffmann. 2017. Arrays and References in Resource Aware ML. In The 2nd International Conference on Formal Structures for Computation and Deduction, FSCD.Google ScholarGoogle Scholar
  30. Aleksandar Nanevski, Anindya Banerjee, and Deepak Garg. 2013. Dependent Type Theory for Verification of Information Flow and Access Control Policies. ACM Trans. Program. Lang. Syst. 35, 2 (2013). Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Aleksandar Nanevski, J. Gregory Morrisett, and Lars Birkedal. 2008. Hoare type theory, polymorphism and separation. J. Funct. Program. 18, 5-6 (2008). Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Georg Neis, Derek Dreyer, and Andreas Rossberg. 2011. Non-parametric parametricity. J. Funct. Program. 21, 4-5 (2011), 497–562. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Van Chan Ngo, Mario Dehesa-Azuara, Matt Fredrikson, and Jan Hoffmann. 2017. Verifying and Synthesizing ConstantResource Implementations with Types. In 2017 IEEE Symposium on Security & Privacy.Google ScholarGoogle Scholar
  34. Flemming Nielson and HanneRiis Nielson. 1999. Type and Effect Systems. In Correct System Design. Lecture Notes in Computer Science, Vol. 1710. 114–136. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan. 2000), 1–44. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Ivan Radicek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018. Monadic refinements for relational cost analysis. PACMPL 2, POPL (2018). Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Brian Reistad and David K. Gifford. 1994. Static Dependent Costs for Estimating Execution Time. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming (LFP ’94). 65–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Moritz Sinn, Florian Zuleger, and Helmut Veith. 2014. A Simple and Scalable Approach to Bound Analysis and Amortized Complexity Analysis. In Computer Aided Verification - 26th International Conference, CAV. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Aaron Joseph Turon, Jacob Thamsborg, Amal Ahmed, Lars Birkedal, and Derek Dreyer. 2013. Logical relations for finegrained concurrency. In The 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’13, Rome, Italy - January 23 - 25, 2013. 343–356. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Hiroshi Unno, Sho Torii, and Hiroki Sakamoto. 2017. Automating Induction for Solving Horn Clauses. In Computer Aided Verification - 29th International Conference, CAV.Google ScholarGoogle Scholar
  41. Peng Wang, Di Wang, and Adam Chlipala. 2017. TiML: A Functional Language for Practical Complexity Analysis with Invariants. In Proceedings of the International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Danfeng Zhang, Yao Wang, G. Edward Suh, and Andrew C. Myers. 2015. A Hardware Design Language for TimingSensitive Information-Flow Security. In Proceedings of the Twentieth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Relational cost analysis for functional-imperative programs

      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

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader