Abstract
Formal frameworks for cost analysis of programs have been widely studied in the unary setting and, to a limited extent, in the relational setting. However, many of these frameworks focus only on the cost aspect, largely side-lining functional properties that are often a prerequisite for cost analysis, thus leaving many interesting programs out of their purview. In this paper, we show that elegant, simple, expressive proof systems combining cost analysis and functional properties can be built by combining already known ingredients: higher-order refinements and cost monads. Specifically, we derive two syntax-directed proof systems, UC and RC, for unary and relational cost analysis, by adding a cost monad to a (syntax-directed) logic of higher-order programs. We study the metatheory of the systems, show that several nontrivial examples can be verified in them, and prove that existing frameworks for cost analysis (RelCost and RAML) can be embedded in them.
Supplemental Material
- Alejandro Aguirre, Gilles Barthe, Lars Birkedal, Aleš Bizjak, Marco Gaboardi, and Deepak Garg. 2017a. Relational Reasoning for Markov Chains in a Probabilistic Guarded Lambda Calculus. (2017). In preparation.Google Scholar
- Alejandro Aguirre, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Pierre-Yves Strub. 2017b. A Relational Logic for Higher-Order Programs. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP). http://arxiv.org/abs/1703.05042Google Scholar
Digital Library
- Elvira Albert, Puri Arenas, Samir Genaim, German Puebla, and Damiano Zanardini. 2012. Cost analysis of object-oriented bytecode programs. Theor. Comput. Sci. 413, 1 (2012), 142–159. Google Scholar
Digital Library
- Christophe Alias, Alain Darte, Paul Feautrier, and Laure Gonnord. 2010. Multi-dimensional Rankings, Program Termination, and Complexity Bounds of Flowchart Programs. In Static Analysis - 17th International Symposium, SAS 2010, Perpignan, France, September 14-16, 2010. Proceedings. 117–133. Google Scholar
Cross Ref
- Robert Atkey. 2011. Amortised Resource Analysis with Separation Logic. Logical Methods in Computer Science 7, 2 (2011). Google Scholar
Cross Ref
- Martin Avanzini and Ugo Dal Lago. 2017. Automating sized type inference for complexity analysis. In Proceedings of DICE-FOPARA. https://arxiv.org/abs/1704.05585 .Google Scholar
Digital Library
- Martin Avanzini, Ugo Dal Lago, and Georg Moser. 2015. Analysing the complexity of functional programs: higher-order meets first-order. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, Vancouver, BC, Canada, September 1-3, 2015. 152–164. Google Scholar
Digital Library
- 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 41st Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL’14, Suresh Jagannathan and Peter Sewell (Eds.). 193–206. Google Scholar
Digital Library
- Gilles Barthe, Marco Gaboardi, Emilio Jesús Gallego Arias, Justin Hsu, Aaron Roth, and Pierre-Yves Strub. 2015. Higher-order approximate relational refinement types for mechanism design and differential privacy. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015, Sriram K. Rajamani and David Walker (Eds.). 55–68. Google Scholar
Digital Library
- Guillaume Bonfante, Jean-Yves Marion, and Jean-Yves Moyen. 2011. Quasi-interpretations a way to control resources. Theor. Comput. Sci. 412, 25 (2011), 2776–2796. Google Scholar
Digital Library
- Marc Brockschmidt, Fabian Emmes, Stephan Falke, Carsten Fuhs, and Jürgen Giesl. 2016. Analyzing Runtime and Size Complexity of Integer Programs. ACM Trans. Program. Lang. Syst. 38, 4 (2016), 13:1–13:50. http://dl.acm.org/citation. cfm?id=2866575Google Scholar
Digital Library
- Quentin Carbonneaux, Jan Hoffmann, and Zhong Shao. 2015. Compositional certified resource bounds. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2015. 467–478. Google Scholar
Digital Library
- Ezgi Çiçek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2017. Relational Cost Analysis. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL). 316–329. Google Scholar
Digital Library
- Ranald Clouston, Aleš Bizjak, Hans Bugge Grathwohl, and Lars Birkedal. 2016. The Guarded Lambda-Calculus: Programming and Reasoning with Guarded Recursion for Coinductive Types. Logical Methods in Computer Science 12, 3 (2016).Google Scholar
- Karl Crary and Stephanie Weirich. 2000. Resource Bound Certification. In Proceedings of the 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Ugo Dal Lago and Marco Gaboardi. 2011. Linear Dependent Types and Relative Completeness. In Proceedings of the 2011 IEEE 26th Annual Symposium on Logic in Computer Science (LICS ’11). 133–142. Google Scholar
Digital Library
- Ugo Dal Lago and Barbara Petit. 2013. The Geometry of Types. In Proceedings of the 40th Annual Symposium on Principles of Programming Languages (POPL ’13). 167–178. Google Scholar
Digital Library
- Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In Proceedings of the 35th Symposium on Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Norman Danner, Daniel R. Licata, and Ramyaa Ramyaa. 2015. Denotational Cost Semantics for Functional Languages with Inductive Types. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). 140–151. Google Scholar
Digital Library
- S. K. Debray, N.-W. Lin, and M. V. Hermenegildo. 1990. Task Granularity Analysis in Logic Programs. In Proc. ACM Conf. on Programming Language Design and Implementation (PLDI). 174–188. Google Scholar
Digital Library
- Antonio Flores-Montoya and Reiner Hähnle. 2014. Resource Analysis of Complex Programs with Cost Equations. In Programming Languages and Systems - 12th Asian Symposium, APLAS 2014, Singapore, November 17-19, 2014, Proceedings. 275–295. Google Scholar
Cross Ref
- Bernd Grobauer. 2001. Cost recurrences for DML programs. In Proceedings of the 6th International Conference on Functional Programming (ICFP). Google Scholar
Digital Library
- Sumit Gulwani, Krishna K. Mehra, and Trishul Chilimbi. 2009. SPEED: Precise and Efficient Static Estimation of Program Computational Complexity. In Proceedings of the 36th Annual Symposium on Principles of Programming Languages (POPL ’09). 127–139. Google Scholar
Digital Library
- Sumit Gulwani and Florian Zuleger. 2010. The reachability-bound problem. In Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2010, Toronto, Ontario, Canada, June 5-10, 2010. 292–304. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Jan Hoffmann. 2011. Types with Potential: Polynomial Resource Bounds via Automatic Amortized Analysis. Ph.D. Dissertation. Ludwig-Maximilians-Universiät München.Google Scholar
- Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012. Resource Aware ML. In 24rd Int. Conf. on Computer Aided Verification (CAV’12). Google Scholar
Digital Library
- Jan Hoffmann, Ankush Das, and Shu-Chun Weng. 2017. Towards automatic resource bound analysis for OCaml. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Martin Hofmann and Steffen Jost. 2003. Static prediction of heap space usage for first-order functional programs. In Proceedings of the 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Bart Jacobs. 1999. Categorical Logic and Type Theory. Elsevier. Studies in Logic and the Foundations of Mathematics 141.Google Scholar
- Steffen Jost, Kevin Hammond, Hans-Wolfgang Loidl, and Martin Hofmann. 2010. Static determination of quantitative resource usage for higher-order programs. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Steffen Jost, Pedro B. Vasconcelos, Mário Florido, and Kevin Hammond. 2017. Type-Based Cost Analysis for Lazy Functional Languages. Journal of Automated Reasoning 59, 1 (2017), 87–120. Google Scholar
Digital Library
- Ravichandhran Madhavan, Sumith Kulal, and Viktor Kuncak. 2017. Contract-based resource verification for higher-order functions with memoization. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. 330–343. http://dl.acm.org/citation.cfm?id=3009874Google Scholar
Digital Library
- Eugenio Moggi. 1991. Notions of computations and monads. 93, 1 (1991), 55–92.Google Scholar
- 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), 6:1–6:41.Google Scholar
Digital Library
- Aleksandar Nanevski, J. Gregory Morrisett, and Lars Birkedal. 2008. Hoare type theory, polymorphism and separation. J. Funct. Program. 18, 5-6 (2008), 865–911.Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- Frank Pfenning and Rowan Davies. 2001. A judgmental reconstruction of modal logic. Mathematical Structures in Computer Science 11, 4 (2001), 511–540. Google Scholar
Digital Library
- A. Serrano, P. Lopez-Garcia, F. Bueno, and M. V. Hermenegildo. 2013. Sized Type Analysis for Logic Programs. In Theory and Practice of Logic Programming, 29th Int’l. Conference on Logic Programming (ICLP’13) Special Issue, On-line Supplement, Vol. 13. Cambridge U. Press, 1–14.Google Scholar
- Moritz Sinn, Florian Zuleger, and Helmut Veith. 2014. A Simple and Scalable Static Analysis for Bound Analysis and Amortized Complexity Analysis. In Computer Aided Verification - 26th International Conference, CAV 2014, Held as Part of the Vienna Summer of Logic, VSL 2014, Vienna, Austria, July 18-22, 2014. Proceedings. 745–761. Google Scholar
Digital Library
- Moritz Sinn, Florian Zuleger, and Helmut Veith. 2017. Complexity and Resource Bound Analysis of Imperative Programs Using Difference Constraints. J. Autom. Reasoning 59, 1 (2017), 3–45. Google Scholar
Digital Library
- Nikhil Swamy, Catalin Hritcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean Karim Zinzindohoue, and Santiago Zanella Béguelin. 2016. Dependent types and multi-monadic effects in F. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). 256–270. Google Scholar
Digital Library
- Philip Wadler and Peter Thiemann. 2003. The marriage of effects and monads. ACM Trans. Comput. Log. 4, 1 (2003), 1–32. Google Scholar
Digital Library
- Peng Wang, Di Wang, and Adam Chlipala. 2017. TiML: A Functional Language for Practical Complexity Analysis with Invariants. In Proceedings of the 2017 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), part of SPLASH 2017.Google Scholar
Digital Library
- Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In Proceedings of the 26th Symposium on Principles of Programming Languages (POPL ’99). 214–227. Google Scholar
Digital Library
- Florian Zuleger, Sumit Gulwani, Moritz Sinn, and Helmut Veith. 2011. Bound Analysis of Imperative Programs with the Size-Change Abstraction. In Static Analysis - 18th International Symposium, SAS 2011, Venice, Italy, September 14-16, 2011. Proceedings. 280–297. Google Scholar
Cross Ref
Index Terms
Monadic refinements for relational cost analysis
Recommendations
Theorem Proving Modulo
AbstractDeduction modulo is a way to remove computational arguments from proofs by reasoning modulo a congruence on propositions. Such a technique, issued from automated theorem proving, is of general interest because it permits one to separate ...
Extensional Higher-Order Paramodulation in Leo-III
AbstractLeo-III is an automated theorem prover for extensional type theory with Henkin semantics and choice. Reasoning with primitive equality is enabled by adapting paramodulation-based proof search to higher-order logic. The prover may cooperate with ...
Analytic Tableaux for Higher-Order Logic with Choice
While many higher-order interactive theorem provers include a choice operator, higher-order automated theorem provers so far have not. In order to support automated reasoning in the presence of a choice operator, we present a cut-free ground tableau ...






Comments