{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/a-cost-aware-logical-framework","title":"A cost-aware logical framework","arxiv_id":"2107.04663","date":"2021-07-09","proceeding":null,"authors":["Yue Niu","Jonathan Sterling","Harrison Grodin","Robert Harper"],"abstract":"We present $\\textbf{calf}$, a $\\textbf{c}$ost-$\\textbf{a}$ware $\\textbf{l}$ogical $\\textbf{f}$ramework for studying quantitative aspects of functional programs. Taking inspiration from recent work that reconstructs traditional aspects of programming languages in terms of a modal account of \\emph{phase distinctions}, we argue that the cost structure of programs motivates a phase distinction between $\\textit{intension}$ and $\\textit{extension}$. Armed with this technology, we contribute a synthetic account of cost structure as a computational effect in which cost-aware programs enjoy an internal noninterference property: input/output behavior cannot depend on cost. As a full-spectrum dependent type theory, $\\textbf{calf}$ presents a unified language for programming and specification of both cost and behavior that can be integrated smoothly with existing mathematical libraries available in type theoretic proof assistants. We evaluate $\\textbf{calf}$ as a general framework for cost analysis by implementing two fundamental techniques for algorithm analysis: the $\\textit{method of recurrence relations}$ and $\\textit{physicist's method for amortized analysis}$. We deploy these techniques on a variety of case studies: we prove a tight, closed bound for Euclid's algorithm, verify the amortized complexity of batched queues, and derive tight, closed bounds for the sequential and $\\textit{parallel}$ complexity of merge sort, all fully mechanized in the Agda proof assistant. Lastly we substantiate the soundness of quantitative reasoning in $\\textbf{calf}$ by means of a model construction.","url_abs":"https://arxiv.org/abs/2107.04663v2","url_pdf":"https://arxiv.org/pdf/2107.04663v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"a-cost-aware-logical-framework","repo_url":"https://github.com/jonsterling/agda-calf","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"none","reach":null}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":null,"mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}