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.
Supplemental Material
Available for Download
Technical appendix for the paper "Relational Cost Analysis for Functional-Imperative Programs" by Weihao Qu, Marco Gaboardi, and Deepak Garg
- 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 ScholarDigital Library
- Amal Ahmed, Derek Dreyer, and Andreas Rossberg. 2009. State-dependent representation independence. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarDigital Library
- Amal G Ahmed. 2004. Semantics of types for mutable state. Google ScholarDigital Library
- 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 ScholarDigital Library
- Robert Atkey. 2010. Amortised Resource Analysis with Separation Logic. In Proceedings of the European Conference on Programming Languages and Systems (ESOP). Google ScholarDigital Library
- Martin Avanzini and Ugo Dal Lago. 2017. Automating sized type inference for complexity analysis. In Proceedings of DICE-FOPARA.Google ScholarDigital 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 Symposium on Principles of Programming Languages (POPL). Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- François Bobot, Sylvain Conchon, E Contejean, Mohamed Iguernelala, Stéphane Lescuyer, and Alain Mebsout. 2013. The Alt-Ergo automated theorem prover, 2008.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- James W. Cooley and John W. Tukey. 1965. An Algorithm for the Machine Calculation of Complex Fourier Series. Math. Comp. (1965).Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Bernd Grobauer. 2001. Cost recurrences for DML programs. In Proceedings of the 6th International Conference on Functional Programming (ICFP). Google ScholarDigital 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 ScholarDigital Library
- Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012a. Multivariate Amortized Resource Analysis. ACM Trans. Program. Lang. Syst. (2012). Google ScholarDigital Library
- Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012b. Resource Aware ML. In Computer Aided Verification - 24th International Conference, CAV. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 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). Google ScholarDigital Library
- Aleksandar Nanevski, J. Gregory Morrisett, and Lars Birkedal. 2008. Hoare type theory, polymorphism and separation. J. Funct. Program. 18, 5-6 (2008). Google ScholarDigital Library
- Georg Neis, Derek Dreyer, and Andreas Rossberg. 2011. Non-parametric parametricity. J. Funct. Program. 21, 4-5 (2011), 497–562. Google ScholarDigital 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
- Flemming Nielson and HanneRiis Nielson. 1999. Type and Effect Systems. In Correct System Design. Lecture Notes in Computer Science, Vol. 1710. 114–136. Google ScholarDigital Library
- Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan. 2000), 1–44. Google ScholarDigital Library
- Ivan Radicek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018. Monadic refinements for relational cost analysis. PACMPL 2, POPL (2018). Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Hiroshi Unno, Sho Torii, and Hiroki Sakamoto. 2017. Automating Induction for Solving Horn Clauses. In Computer Aided Verification - 29th International Conference, CAV.Google Scholar
- 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 ScholarDigital Library
- Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Relational cost analysis for functional-imperative programs
Recommendations
Relational cost analysis
POPL '17Establishing quantitative bounds on the execution cost of programs is essential in many areas of computer science such as complexity analysis, compiler optimizations, security and privacy. Techniques based on program analysis, type systems and abstract ...
Monadic refinements for relational cost analysis
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 ...
Bidirectional type checking for relational properties
PLDI 2019: Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and ImplementationRelational type systems have been designed for several applications including information flow, differential privacy, and cost analysis. In order to achieve the best results, these systems often use relational refinements and relational effects to ...
Comments