Hostname: page-component-76fb5796d-2lccl Total loading time: 0 Render date: 2024-04-28T20:50:25.242Z Has data issue: false hasContentIssue false

Relational cost analysis in a functional-imperative setting

Published online by Cambridge University Press:  02 November 2021

WEIHAO QU
Affiliation:
Boston University, Computer Science Department, Boston, MA 02215, USA (e-mail: weihaoqu@bu.edu)
MARCO GABOARDI
Affiliation:
Boston University, Computer Science Department, Boston, MA 02215, USA (e-mail: gaboardi@bu.edu)
DEEPAK GARG
Affiliation:
Max Planck Institute for Software Systems, Saarbrücken, Germany (e-mail: dg@mpi-sws.org)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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 (the difference in the evaluation 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 that imperatively update their data. We have implemented ARel using ideas from bidirectional type checking.

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
Copyright
© The Author(s), 2021. Published by Cambridge University Press

References

Ahmed, A. (2006) Step-indexed syntactic logical relations for recursive and quantified types. In Proceedings of the European Conference on Programming Languages and Systems (ESOP).CrossRefGoogle Scholar
Ahmed, A., Dreyer, D. & Rossberg, A. (2009) State-dependent representation independence. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Ahmed, A. G. (2004) Semantics of types for mutable state, Princeton University.Google Scholar
Appel, A. W. & McAllester, D. A. (2001) An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23(5), 657683.CrossRefGoogle Scholar
Atkey, R. (2010) Amortised resource analysis with separation logic. In Proceedings of the European Conference on Programming Languages and Systems (ESOP).CrossRefGoogle Scholar
Avanzini, M. & Dal Lago, U. (2017) Automating sized type inference for complexity analysis. In Proceedings of DICE-FOPARA.CrossRefGoogle Scholar
Barthe, G., Fournet, C., Grégoire, B., Strub, P.-Y., Swamy, N. & Béguelin, S. Z. (2014) Probabilistic relational verification for cryptographic implementations. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Barthe, G., Gaboardi, M., Arias, E. J. G., Hsu, J., Roth, A. & Strub, P.-Y. (2015) Higher-order approximate relational refinement types for mechanism design and differential privacy. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Benton, N. (2004) Simple relational correctness proofs for static analyses and program transformations. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Benton, N., Hofmann, M. & Nigam, V. (2014) Abstract effects and proof-relevant logical relations. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Benton, N., Hofmann, M. & Nigam, V. (2016) Effect-dependent transformations for concurrent programs. In Proceedings of the 18th International Symposium on Principles and Practice of Declarative Programming.CrossRefGoogle Scholar
Bobot, F., Conchon, S., Contejean, E., Iguernelala, M., Lescuyer, S. & Mebsout, A. (2013) The alt-ergo automated theorem prover, 2008.Google Scholar
Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C. & Giesl, J. (2014) Alternating runtime and size complexity analysis of integer programs. In Tools and Algorithms for the Construction and Analysis of Systems – 26th International Conference (TACAS).CrossRefGoogle Scholar
Carbonneaux, Q., Hoffmann, J. & Shao, Z. (2015) Compositional certified resource bounds. In Proceedings of the 36th Conference on Programming Language Design and Implementation (PLDI).CrossRefGoogle Scholar
Çiçek, E., Barthe, G., Gaboardi, M., Garg, D. & Hoffmann, J. (2017) Relational cost analysis. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Charguéraud, A. & Pottier, F. (2015) Machine-checked verification of the correctness and amortized complexity of an efficient union-find implementation. In Interactive Theorem Proving - 6th International Conference, ITP.CrossRefGoogle Scholar
Çiçek, E., Paraskevopoulou, Z. & Garg, D. (2016) A type theory for incremental computational complexity with control flow changes. In Proceedings of the International Conference on Functional Programming(ICFP).CrossRefGoogle Scholar
Çiçek, E., Qu, W., Barthe, G., Gaboardi, M. & Garg, D. (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, pp. 533–547CrossRefGoogle Scholar
Cooley, J. W. & Tukey, J. W. (1965) An algorithm for the machine calculation of complex fourier series. Math. Comput. 19(90), 297301.CrossRefGoogle Scholar
Cutler, J. W., Licata, D. R. & Danner, N. (2020) Denotational recurrence extraction for amortized analysis. Proc. ACM Program. Lang. 4(ICFP), 129.CrossRefGoogle Scholar
Dal Lago, U. & Gaboardi, M. (2011) Linear dependent types and relative completeness. In Proceedings of the IEEE 26th Annual Symposium on Logic in Computer Science (LICS).CrossRefGoogle Scholar
Danielsson, N. A. (2008) Lightweight semiformal time complexity analysis for purely functional data structures. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Danner, N., Licata, D. R. & Ramyaa, R. (2015) Denotational cost semantics for functional languages with inductive types. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming. ICFP 2015.CrossRefGoogle Scholar
Filliâtre, J.-C. & Paskevich, A. (2013) Why3: Where programs meet provers. In Proceedings of the European Conference on Programming Languages and Systems (ESOP).CrossRefGoogle Scholar
Gaboardi, M., Haeberlen, A., Hsu, J., Narayan, A. & Pierce, B. C. (2013) Linear dependent types for differential privacy. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Grobauer, B. (2001) Cost recurrences for DML programs. In Proceedings of the 6th International Conference on Functional Programming (ICFP).CrossRefGoogle Scholar
Hermenegildo, M. V., Puebla, G., Bueno, F. & López-García, P. (2005) Integrated program debugging, verification, and optimization using abstract interpretation (and the ciao system preprocessor). Sci. Comput. Program. 58(1–2), 115140.CrossRefGoogle Scholar
Hoffmann, J., Aehlig, K. & Hofmann, M. (2012a) Multivariate amortized resource analysis. ACM Trans. Program. Lang. Syst. 34(3), 162.CrossRefGoogle Scholar
Hoffmann, J., Aehlig, K. & Hofmann, M. (2012b) Resource aware ML. In Computer Aided Verification - 24th International Conference, CAV.CrossRefGoogle Scholar
Kavvos, G. A., Morehouse, E., Licata, D. R. & Danner, N. (2019) Recurrence extraction for functional programs through call-by-push-value. Proc. ACM Program. Lang. 4(POPL), 131.CrossRefGoogle Scholar
Lahiri, S. K., Vaswani, K. & Hoare, C. A. R. (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, Roman, G.-C. & Sullivan, K. J. (eds).CrossRefGoogle Scholar
Lichtman, B. & Hoffmann, J. (2017) Arrays and references in resource aware ML. In The 2nd International Conference on Formal Structures for Computation and Deduction, FSCD.Google Scholar
Nanevski, A., Banerjee, A. & Garg, D. (2013) Dependent type theory for verification of information flow and access control policies. ACM Trans. Program. Lang. Syst. 35(2), 141.CrossRefGoogle Scholar
Nanevski, A., Morrisett, J. G. & Birkedal, L. (2008) Hoare type theory, polymorphism and separation. J. Funct. Program. 18(5–6), 865911.CrossRefGoogle Scholar
Neis, G., Dreyer, D. & Rossberg, A. (2011) Non-parametric parametricity. J. Funct. Program. 21(4–5), 497562.CrossRefGoogle Scholar
Ngo, V. C., Dehesa-Azuara, M., Fredrikson, M. & Hoffmann, J. (2017) Verifying and synthesizing constant-resource implementations with types. In 2017 IEEE Symposium on Security & Privacy.CrossRefGoogle Scholar
Nielson, F. & Nielson, H. (1999) Type and effect systems. In Correct System Design. Lecture Notes in Computer Science, vol. 1710, pp. 114–136.Google Scholar
Pierce, B. C. & Turner, D. N. (2000) Local type inference. ACM Trans. Program. Lang. Syst. 22(1), 144.CrossRefGoogle Scholar
Radicek, I., Barthe, G., Gaboardi, M., Garg, D. & Zuleger, F. (2018) Monadic refinements for relational cost analysis. PACMPL 2(POPL), 36–1.Google Scholar
Reistad, B. & Gifford, D. K. (1994) Static dependent costs for estimating execution time. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming. LFP’94, pp. 65–78.CrossRefGoogle Scholar
Sinn, M., Zuleger, F. & Veith, H. (2014) A simple and scalable approach to bound analysis and amortized complexity analysis. In Computer Aided Verification - 26th International Conference, CAV.CrossRefGoogle Scholar
Turon, A. J., Thamsborg, J., Ahmed, A., Birkedal, L. & Dreyer, D. (2013) Logical relations for fine-grained concurrency. In The 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL’13, Rome, Italy - January 23–25, 2013, pp. 343–356.CrossRefGoogle Scholar
Unno, H., Torii, S. & Sakamoto, H. (2017) Automating induction for solving horn clauses. In Computer Aided Verification - 29th International Conference, CAV.CrossRefGoogle Scholar
Wang, P., Wang, D. & Chlipala, A. (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).CrossRefGoogle Scholar
Xi, H. & Pfenning, F. (1999) Dependent types in practical programming. In Proceedings of the Symposium on Principles of Programming Languages (POPL).CrossRefGoogle Scholar
Zhang, D., Wang, Y., Suh, G. E. & Myers, A. C. (2015) A hardware design language for timing-sensitive information-flow security. In Proceedings of the Twentieth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS.CrossRefGoogle Scholar
Supplementary material: PDF

Qu et al. supplementary material

Appendix

Download Qu et al. supplementary material(PDF)
PDF 617.1 KB
Submit a response

Discussions

No Discussions have been published for this article.