一句话:将递推提取扩展到摊还分析,引入带信用标注的仿射中间语言,并证明其到递推语言的指称正确性。
函数式程序的时间复杂度分析常通过提取运行时间递推式并求解得到大 O 界。为使递推提取可组合,还需为辅助函数的输出规模提取递推。本文把已有基于逻辑关系的递推提取正确性框架扩展到摊还分析。作者提出一种可按银行家法标注信用额度的中间语言,并用仿射类型系统保证信用不会被重复花费;随后给出到递推语言的提取翻译,递推语言是带 cost 类型的简单类型 lambda 演算。文章定义并证明一个边界逻辑关系以说明翻译正确,并为递推语言给出基于预序的指称语义,用以求解递推,示例包括二进制计数器与伸展树分析。
A typical way of analyzing the time complexity of functional programs is to extract a recurrence expressing the running time of the program in terms of the size of its input, and then to solve the recurrence to obtain a big-O bound. For recurrence extraction to be compositional, it is also necessary to extract recurrences for the size of outputs of helper functions. Previous work has developed techniques for using logical relations to state a formal correctness theorem for a general recurrence extraction translation: a program is bounded by a recurrence when the operational cost is bounded by the extracted cost, and the output value is bounded, according to a value bounding relation defined by induction on types, by the extracted size. This previous work supports higher-order functions by viewing recurrences as programs in a lambda-calculus, or as mathematical entities in a denotational semantics thereof. In this paper, we extend these techniques to support amortized analysis, where costs are rearranged from one portion of a program to another to achieve more precise bounds. We give an intermediate language in which programs can be annotated according to the banker's method of amortized analysis; this language has an affine type system to ensure credits are not spent more than once. We give a recurrence extraction translation of this language into a recurrence language, a simply-typed lambda-calculus with a cost type, and state and prove a bounding logical relation expressing the correctness of this translation. The recurrence language has a denotational semantics in preorders, and we use this semantics to solve recurrences, e.g analyzing binary counters and splay trees.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@article{abs-2006-15036,
title = {Denotational recurrence extraction for amortized analysis},
author = {Joseph W. Cutler and Daniel R. Licata and Norman Danner},
journal = {Proceedings of the ACM on Programming Languages},
volume = {4},
number = {ICFP},
year = {2020},
doi = {10.1145/3408979}
}