一句话:为 Hedgehog 生成器建立形式语义,提出受限语言 Hedgehog→ 以获得可组合的分布语义,支持生成器等价证明。
属性测试依赖随机生成器与收缩来寻找反例,但生成器优化难以形式化证明,因为现有语言缺少足够粗粒度、可组合的语义。论文首先形式化 Hedgehog 的语法与语义,证明其分布语义不可组合;并进一步证明任何可靠且完备的组合语义都必等价于过细的采样语义,无法支持常规优化。为此作者基于 arrow calculus 提出受限语言 Hedgehog→,证明其具有组合式分布语义;并通过 Haskell 实现评估,表明其仍能表达实用生成器,为生成器等价证明提供形式基础。
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 → , a restricted version of the language based on the arrow calculus, and prove that Hedgehog → possesses a compositional distribution semantics. We evaluate Hedgehog → 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.
@article{VandikasSC26,
title = {Compositional Generator Equivalence},
author = {Anthony Vandikas and Kiarash Sotoudeh and Marsha Chechik},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {ICFP},
year = {2026},
doi = {10.1145/3828695}
}