A standard informal method for analyzing the asymptotic complexity of a program is to extract a recurrence that describes its cost in terms of the size of its input, and then to compute a closed-form upper bound on that recurrence. We give a formal account of that method for functional programs in a higher-order language with let-polymorphism The method consists of two phases. In the first phase, a monadic translation is performed to extract a cost-annotated version of the original program. In the second phase, the extracted program is interpreted in a model. The key feature of this second phase is that different models describe different notions of size. This plays out specifically for values of inductive type, where different notions of size may be appropriate depending on the analysis, and for polymorphic functions, where we show that the notion of size for a polymorphic function can be described formally as the data that is common to the notions of size of its instances. We give several examples of different models that formally justify various informal cost analyses to show the applicability of our approach.
翻译:分析一个程序无症状复杂性的一个标准非正式方法,是提取一个重现,用输入大小来描述其成本,然后根据重现计算一个封闭式的上层框。我们用高阶语言用一流的一流语言正式说明该方法的功能性程序。方法由两个阶段组成。在第一阶段,进行一个monadic翻译,以提取原始程序的成本附加说明版本。在第二阶段,提取的程序在一个模型中解释。第二阶段的关键特征是不同的模型描述不同的规模概念。这具体表现在进化型的数值上方,根据分析,不同的规模概念可能是合适的,多形态函数的大小概念可以正式描述为与其实例大小概念共同使用的数据。我们举出了不同模型的几个例子,这些不同模型正式证明各种非正式成本分析的可适用性,以显示我们方法的可适用性。