Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Decalf: A Directed, Effectful Cost-Aware Logical Framework

Published: 05 January 2024 Publication History
  • Get Citation Alerts
  • Abstract

    We present decalf, a directed, effectful cost-aware logical framework for studying quantitative aspects of functional programs with effects. Like calf, the language is based on a formal phase distinction between the extension and the intension of a program, its pure behavior as distinct from its cost measured by an effectful step-counting primitive. The type theory ensures that the behavior is unaffected by the cost accounting. Unlike calf, the present language takes account of effects, such as probabilistic choice and mutable state. This extension requires a reformulation of calf’s approach to cost accounting: rather than rely on a ”separable” notion of cost, here a cost bound is simply another program. To make this formal, we equip every type with an intrinsic preorder, relaxing the precise cost accounting intrinsic to a program to a looser but nevertheless informative estimate. For example, the cost bound of a probabilistic program is itself a probabilistic program that specifies the distribution of costs. This approach serves as a streamlined alternative to the standard method of isolating a cost recurrence and readily extends to higher-order, effectful programs.
    The development proceeds by first introducing the decalf type system, which is based on an intrinsic ordering among terms that restricts in the extensional phase to extensional equality, but in the intensional phase reflects an approximation of the cost of a program of interest. This formulation is then applied to a number of illustrative examples, including pure and effectful sorting algorithms, simple probabilistic programs, and higher-order functions. Finally, we justify decalf via a model in the topos of augmented simplicial sets.

    References

    [1]
    Danel Ahman, Neil Ghani, and Gordon D. Plotkin. 2016. Dependent Types and Fibred Computational Effects. In Foundations of Software Science and Computation Structures, Bart Jacobs and Christof Löding (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 36–54. isbn:978-3-662-49630-5
    [2]
    Michael Artin, Alexander Grothendieck, and Jean-Louis Verdier. 1972. Théorie des topos et cohomologie étale des schémas (Lecture Notes in Mathematics, Vol. 269, 270, 305). Springer-Verlag, Berlin. Séminaire de Géométrie Algébrique du Bois-Marie 1963–1964 (SGA 4), Dirigé par M. Artin, A. Grothendieck, et J.-L. Verdier. Avec la collaboration de N. Bourbaki, P. Deligne et B. Saint-Donat
    [3]
    Steve Awodey, Nicola Gambino, and Sina Hazratpour. 2021. Kripke-Joyal forcing for type theory and uniform fibrations. arXiv:2110.14576. Unpublished manuscript
    [4]
    Lars Birkedal and Aleš Bizjak. 2022. Lecture Notes on Iris: Higher-Order Concurrent Separation Logic. https://iris-project.org/tutorial-material.html
    [5]
    J. Daniel Christensen, Morgan Opie, Egbert Rijke, and Luis Scoccola. 2020. Localization in Homotopy Type Theory. Higher Structures, 4 (2020), Feb., 1–32. https://higher-structures.math.cas.cz/api/files/issues/Vol4Iss1/ChrOpiRijSco
    [6]
    Eduardo J. Dubuc. 1979. Sur les modèles de la géométrie différentielle synthétique. Cahiers de Topologie et Géométrie Différentielle Catégoriques, 20, 3 (1979), 231–279. http://eudml.org/doc/91216
    [7]
    Marcelo P. Fiore. 1997. An Enrichment Theorem for an Axiomatisation of Categories of Domains and Continuous Functions. Mathematical Structures in Computer Science, 7, 5 (1997), Oct., 591–618. issn:0960-1295 https://doi.org/10.1017/S0960129597002429
    [8]
    Marcelo P. Fiore, Andrew M. Pitts, and S. C. Steenkamp. 2021. Quotients, inductive types, and quotient inductive types. arXiv:2101.02994.
    [9]
    Marcelo P. Fiore and Giuseppe Rosolini. 1997. The category of cpos from a synthetic viewpoint. In Thirteenth Annual Conference on Mathematical Foundations of Progamming Semantics, MFPS 1997, Carnegie Mellon University, Pittsburgh, PA, USA, March 23-26, 1997, Stephen D. Brookes and Michael W. Mislove (Eds.) (Electronic Notes in Theoretical Computer Science, Vol. 6). Elsevier, 133–150. https://doi.org/10.1016/S1571-0661(05)80165-3
    [10]
    Marcelo P. Fiore and Giuseppe Rosolini. 2001. Domains in H. Theoretical Computer Science, 264, 2 (2001), Aug., 171–193. issn:0304-3975 https://doi.org/10.1016/S0304-3975(00)00221-8
    [11]
    Daniel Gratzer and Jonathan Sterling. 2020. Syntactic categories for dependent type theory: sketching and adequacy. arXiv:2012.10783. Unpublished manuscript
    [12]
    Harrison Grodin and Robert Harper. 2023. Amortized Analysis via Coinduction. In 10th Conference on Algebra and Coalgebra in Computer Science (CALCO 2023), Paolo Baldan and Valeria de Paiva (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 270). Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 23:1–23:6. isbn:978-3-95977-287-7 issn:1868-8969 https://doi.org/10.4230/LIPIcs.CALCO.2023.23
    [13]
    Harrison Grodin, Robert Harper, Yue Niu, and Jonathan Sterling. 2023. Decalf: A Directed, Effectful Cost-Aware Logical Framework (Extended Version). https://doi.org/10.48550/arXiv.2307.05938 arxiv:2307.05938.
    [14]
    Harrison Grodin, Yue Niu, Jonathan Sterling, and Robert Harper. 2024. agda-calf v2.0.0. https://doi.org/10.1145/3580425
    [15]
    Robert Harper, John C. Mitchell, and Eugenio Moggi. 1990. Higher-Order Modules and the Phase Distinction. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. Association for Computing Machinery, San Francisco, California, USA. 341–354. isbn:0-89791-343-4 https://doi.org/10.1145/96709.96744
    [16]
    C. A. R. Hoare. 1961. Algorithm 64: Quicksort. Commun. ACM, 4, 7 (1961), July, 321. issn:0001-0782 https://doi.org/10.1145/366622.366644
    [17]
    C. A. R. Hoare. 1962. Quicksort. Comput. J., 5, 1 (1962), Jan., 10–16. issn:0010-4620 https://doi.org/10.1093/comjnl/5.1.10
    [18]
    Martin Hofmann. 1995. Extensional concepts in intensional type theory. Ph. D. Dissertation. University of Edinburgh. Edinburgh.
    [19]
    J. M. E. Hyland. 1991. First steps in synthetic domain theory. In Category Theory, Aurelio Carboni, Maria Cristina Pedicchio, and Guiseppe Rosolini (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 131–156. isbn:978-3-540-46435-8
    [20]
    Ambrus Kaposi, András Kovács, and Thorsten Altenkirch. 2019. Constructing Quotient Inductive-inductive Types. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 2:1–2:24. issn:2475-1421 https://doi.org/10.1145/3290315
    [21]
    G. A. Kavvos, Edward Morehouse, Daniel R. Licata, and Norman Danner. 2019. Recurrence Extraction for Functional Programs through Call-by-Push-Value. Proceedings of the ACM on Programming Languages, 4, POPL (2019), Dec., https://doi.org/10.1145/3371083
    [22]
    Paul Blain Levy. 2003. Call-by-Push-Value: A Functional/Imperative Synthesis. Kluwer, Semantic Structures in Computation, 2. isbn:1-4020-1730-8
    [23]
    Daniel R. Licata and Robert Harper. 2011. 2-Dimensional Directed Type Theory. Electronic Notes in Theoretical Computer Science, 276 (2011), 263–289. issn:1571-0661 https://doi.org/10.1016/j.entcs.2011.09.026 Twenty-seventh Conference on the Mathematical Foundations of Programming Semantics (MFPS XXVII)
    [24]
    Maria Emilia Maietti. 2005. Modular correspondence between dependent type theories and categories including pretopoi and topoi. Mathematical Structures in Computer Science, 15, 6 (2005), 1089–1149. https://doi.org/10.1017/S0960129505004962
    [25]
    Per Martin-Löf. 1984. Intuitionistic type theory (Studies in Proof Theory, Vol. 1). Bibliopolis. isbn:88-7088-105-9
    [26]
    Yue Niu, Jonathan Sterling, Harrison Grodin, and Robert Harper. 2022. A Cost-Aware Logical Framework. Proceedings of the ACM on Programming Languages, 6, POPL (2022), Jan., https://doi.org/10.1145/3498670 arXiv:2107.04663.
    [27]
    Yue Niu, Jonathan Sterling, Harrison Grodin, and Robert Harper. 2022. agda-calf. https://doi.org/10.1145/3462303
    [28]
    Ulf Norell. 2009. Dependently Typed Programming in Agda. In Proceedings of the 4th International Workshop on Types in Language Design and Implementation (TLDI ’09). Association for Computing Machinery, Savannah, GA, USA. 1–2. isbn:978-1-60558-420-1
    [29]
    Pierre-Marie Pédrot and Nicolas Tabareau. 2019. The Fire Triangle: How to Mix Substitution, Dependent Elimination, and Effects. Proceedings of the ACM on Programming Languages, 4, POPL (2019), Dec., https://doi.org/10.1145/3371126
    [30]
    Wesley Phoa. 1991. Domain Theory in Realizability Toposes. Ph. D. Dissertation. University of Edinburgh.
    [31]
    Gordon D. Plotkin and John Power. 2002. Notions of Computation Determine Monads. In Proceedings of the 5th International Conference on Foundations of Software Science and Computation Structures. Springer-Verlag, Berlin, Heidelberg. 342–356. isbn:3-540-43366-X
    [32]
    Ivan Radiček, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2017. Monadic Refinements for Relational Cost Analysis. Proc. ACM Program. Lang., 2, POPL (2017), Article 36, dec, 32 pages. https://doi.org/10.1145/3158124
    [33]
    Vineet Rajani, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2021. A Unifying Type-Theory for Higher-Order (Amortized) Cost Analysis. Proceedings of the ACM on Programming Languages, 5, POPL (2021), Jan., https://doi.org/10.1145/3434308
    [34]
    Emily Riehl and Michael Shulman. 2017. A type theory for synthetic ∞ -categories. Higher Structures, 1 (2017), 147–224. arXiv:1705.07442. https://journals.mq.edu.au/index.php/higher_structures/article/view/36
    [35]
    Egbert Rijke. 2019. Classifying Types. Ph. D. Dissertation. Carnegie Mellon University. arXiv:1906.09435.
    [36]
    Egbert Rijke, Michael Shulman, and Bas Spitters. 2020. Modalities in homotopy type theory. Logical Methods in Computer Science, 16 (2020), Jan., https://doi.org/10.23638/LMCS-16(1:2)2020 arXiv:1706.07526.
    [37]
    Jonathan Sterling. 2021. First Steps in Synthetic Tait Computability: The Objective Metatheory of Cubical Type Theory. Ph. D. Dissertation. Carnegie Mellon University. https://doi.org/10.5281/zenodo.6990769 Version 1.1, revised May 2022
    [38]
    Jonathan Sterling, Carlo Angiuli, and Daniel Gratzer. 2019. Cubical Syntax for Reflection-Free Extensional Equality. In 4th International Conference on Formal Structures for Computation and Deduction (FSCD 2019), Herman Geuvers (Ed.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 131). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 31:1–31:25. isbn:978-3-95977-107-8 issn:1868-8969 https://doi.org/10.4230/LIPIcs.FSCD.2019.31 arXiv:1904.08562.
    [39]
    Jonathan Sterling, Carlo Angiuli, and Daniel Gratzer. 2022. A Cubical Language for Bishop Sets. Logical Methods in Computer Science, 18 (2022), March, https://doi.org/10.46298/lmcs-18(1:43)2022 arXiv:2003.01491.
    [40]
    Jonathan Sterling and Robert Harper. 2021. Logical Relations as Types: Proof-Relevant Parametricity for Program Modules. J. ACM, 68, 6 (2021), Oct., issn:0004-5411 https://doi.org/10.1145/3474834 arXiv:2010.08599.
    [41]
    Taichi Uemura. 2021. Abstract and Concrete Type Theories. Ph. D. Dissertation. Universiteit van Amsterdam. Amsterdam. https://www.illc.uva.nl/cms/Research/Publications/Dissertations/DS-2021-09.text.pdf
    [42]
    Taichi Uemura. 2023. A general framework for the semantics of type theory. Mathematical Structures in Computer Science, 1–46. https://doi.org/10.1017/S0960129523000208
    [43]
    Matthijs Vákár. 2017. In Search of Effectful Dependent Types. Ph. D. Dissertation. University of Oxford. https://doi.org/10.48550/arXiv.1706.07997 arXiv:1706.07997.

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 8, Issue POPL
    January 2024
    2820 pages
    EISSN:2475-1421
    DOI:10.1145/3554315
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution 4.0 International License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 05 January 2024
    Published in PACMPL Volume 8, Issue POPL

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. algorithm analysis
    2. amortized analysis
    3. behavioral verification
    4. cost models
    5. equational reasoning
    6. intensional property
    7. mechanized proof
    8. modal type theory
    9. noninterference
    10. parallel algorithms
    11. phase distinction
    12. proof assistants
    13. recurrence relations

    Qualifiers

    • Research-article

    Funding Sources

    • AFOSR
    • NSF
    • AFRL

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 361
      Total Downloads
    • Downloads (Last 12 months)361
    • Downloads (Last 6 weeks)45
    Reflects downloads up to 11 Aug 2024

    Other Metrics

    Citations

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media