寻找受限随机生成器
The Search for Constrained Random Generators
AI总结:
本文提出利用演绎程序合成思想,通过生成器的指称语义设计出自动合成正确生成器的规则,解决属性驱动测试中的受限随机生成问题,提升测试用例的有效性。
摘要:
在属性驱动测试(PBT)中,最大的挑战之一是受限随机生成问题:给定一个程序值的谓词,从所有满足该谓词的值集合中随机采样,并仅生成这些值。高效的解决方案至关重要,因为PBT使用的可执行规范通常有前置条件,要求输入值必须满足才能成为有效测试用例,而满足条件的值往往稀疏分布。我们提出了一种新的方法,利用演绎程序合成的思想。我们提出了一组基于生成器指称语义的合成规则,从而产生一个自动合成正确生成器的自动过程。我们的系统通过将递归谓词重写为猫玛尔法并匹配适当的阿纳玛法来处理递归谓词,这在理论上比其他递归函数合成方法更简单,但仍然非常表达性。我们的实现Palamedes是Lean定理证明器的可扩展库。合成算法本身基于标准的证明搜索战术,减少了实现负担,并允许算法受益于Lean证明自动化进一步的发展。
英文摘要:
Among the biggest challenges in property-based testing (PBT) is the constrained random generation problem: given a predicate on program values, randomly sample from the set of all values satisfying that predicate, and only those values. Efficient solutions to this problem are critical, since the executable specifications used by PBT often have preconditions that input values must satisfy in order to be valid test cases, and satisfying values are often sparsely distributed. We propose a novel approach to this problem using ideas from deductive program synthesis. We present a set of synthesis rules, based on a denotational semantics of generators, that give rise to an automatic procedure for synthesizing correct generators. Our system handles recursive predicates by rewriting them as catamorphisms and then matching with appropriate anamorphisms; this is theoretically simpler than other approaches to synthesis for recursive functions, yet still extremely expressive. Our implementation, Palamedes, is an extensible library for the Lean theorem prover. The synthesis algorithm itself is built on standard proof-search tactics, reducing implementation burden and allowing the algorithm to benefit from further advances in Lean proof automation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。