一句话:提出基于 AARA 类型推导的最坏情况输入生成方法,可证明资源界紧致并生成大规模测试输入。
论文研究函数式程序的资源最坏情况输入生成。给定函数、AARA 资源标注类型推导及描述输入形状与大小的 skeleton,算法通过填充整数、布尔值和数据结构构造具体输入。可靠性定理表明,生成输入在给定形状的所有参数中具有最高开销,且该开销恰为类型推导给出的最坏情况界;相对完备性定理表明,在约束求解可判定的前提下,算法成功当且仅当该界紧致。技术先针对带线性资源界的一阶语言建立,并实现于 Resource Aware ML,支持高阶函数、用户定义数据类型和多项式界。实验对排序、搜索树操作和哈希表插入生成了含数百整数的最坏情况输入。
This paper presents a novel technique for type-guided worst-case input generation for functional programs. The technique builds on automatic amortized resource analysis (AARA), a type-based technique for deriving symbolic bounds on the resource usage of functions. Worst-case input generation is performed by an algorithm that takes as input a function, its resource-annotated type derivation in AARA, and a skeleton that describes the shape and size of the input that is to be generated. If successful, the algorithm fills in integers, booleans, and data structures to produce a value of the shape given by the skeleton. The soundness theorem states that the generated value exhibits the highest cost among all arguments of the functions that have the shape of the skeleton. This cost corresponds exactly to the worst-case bound that is established by the type derivation. In this way, a successful completion of the algorithm proves that the bound is tight for inputs of the given shape. Correspondingly, a relative completeness theorem is proved to show that the algorithm succeeds if and only if the derived worst-case bound is tight. The theorem is relative because it depends on a decision procedure for constraint solving. The technical development is presented for a simple first-order language with linear resource bounds. However, the technique scales to and has been implemented for Resource Aware ML, an implementation of AARA for a fragment of OCaml with higher-order functions, user-defined data types, and types for polynomial bounds. Experiments demonstrate that the technique works effectively and can derive worst-case inputs with hundreds of integers for sorting algorithms, operations on search trees, and insertions into hash tables.