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 \emph{intension} and \emph{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 \emph{method of recurrence relations} and \emph{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 \emph{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.
翻译:我们提出\ textbf{ calf}, compliclebf{ c}\ textbf{ c}\ textbf{c} textbf{ a} a} source communication 用于研究功能程序的数量方面。 我们从最近从重建编程语言的传统方面的工作中得到灵感, 其模式账户是 emph{ 阶段区别 。 我们争辩说, 程序的成本结构促使了 \ emph{ licticle{ text} 和\ emph{ extension} 之间的阶段区别。 有了这种技术, 我们贡献了一个成本结构的合成账户, 作为一种计算结果, 成本意识程序具有内部不干预属性: 输入/ 输出行为不能取决于成本 。 作为完全外观依赖型的理论,\ textbf{ calf} 提供了一种统一的语言, 用于编程和规范成本和行为, 并且可以与现有的精度缩缩缩缩缩缩缩缩缩缩缩图助手 。 我们评估了成本分析的一般框架, 通过两个基础技术进行成本验证分析, 。