组合生成器等价(扩展版)
Compositional Generator Equivalence (Extended Version)
AI总结:
针对属性测试中生成器优化缺乏组合语义的问题,提出基于箭头演算的限制语言Hedgehog$^\ ightarrow$,证明其具有组合分布语义,为生成器等价证明提供形式基础。
摘要:
基于属性的测试(PBT)是一种强大的软件验证技术,它依赖于随机输入生成器和“收缩”过程来发现并最小化对称为属性的可执行规范的反例。虽然优化这些生成器对于测试效率至关重要,但目前正式证明此类优化是困难的,因为现有语言缺乏足够粗粒度以进行高层推理的组合语义。在本文中,我们首先对流行的PBT框架Hedgehog的语法和语义进行了形式化描述。我们证明了Hedgehog的分布语义——它模拟了用户通常如何推理生成器——是非组合的。此外,我们证明了任何对于Hedgehog而言既健全又完备的组合语义必须等价于其采样语义,而采样语义过于细粒度,无法证明常见的程序优化。为了解决这一困境,我们引入了Hedgehog$^\ ightarrow$,一种基于箭头演算的语言受限版本,并证明了Hedgehog$^\ ightarrow$具有组合分布语义。我们通过Haskell实现评估了Hedgehog$^\ ightarrow$,并表明它在提供组合生成器等价证明所需的形式基础的同时,仍然具有足够的表达能力来捕获实际感兴趣的生成器。
英文摘要:
Property-based testing (PBT) is a powerful technique for software verification that relies on random input generators and "shrinking" processes to find and minimize counterexamples to executable specifications called properties. While optimizing these generators is crucial for testing efficiency, formally justifying such optimizations is currently difficult because existing languages lack a compositional semantics that is coarse-grained enough for high-level reasoning. In this paper, we first provide a formal account of the syntax and semantics of Hedgehog, a popular PBT framework. We demonstrate that Hedgehog's distribution semantics - which models how users typically reason about generators - is non-compositional. Furthermore, we prove that any sound and complete compositional semantics for Hedgehog must necessarily be equivalent to its sampling semantics, which is too fine-grained to justify common program optimizations. To resolve this dilemma, we introduce Hedgehog$^\rightarrow$, a restricted version of the language based on the arrow calculus, and prove that Hedgehog$^\rightarrow$ possesses a compositional distribution semantics. We evaluate Hedgehog$^\rightarrow$ through a Haskell implementation and show that it remains expressive enough to capture generators of practical interest, while providing the formal foundation needed for compositional generator equivalence proofs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。