paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Tuning Random Generators: Property-Based Testing as Probabilistic Programming

调优随机生成器:将基于属性的测试视为概率编程
OOPSLA 9(OOPSLA2)2025匹配度 3/10 · 论文将概率编程与参数学习用于性质测试中的生成器调优,属于PL与概率编程/测试的交叉,并有一定工程实现与benchmark评估;但未涉及用户核心关注的LLM/Agent、静态分析/形式化验证、浮点程序分析或贝叶斯程序分析,因此整体匹配度较低。引用 1 inbox
Ryan Tjoa, Poorva Garg, Harrison Goldstein, Todd Millstein, Benjamin C. Pierce, Guy Van den Broeck
crossref: 2026-09-10

AI 速览

一句话:把生成器的随机选择权重视为可学习参数,在离散概率编程系统中自动离线优化测试输入分布,显著提升找 bug 效率。

基于属性的测试(PBT)通过在随机生成的输入上执行可执行规约来验证软件。PBT 用户通常用生成器描述如何通过随机选择采样测试输入;为获得理想的输入分布,用户必须手动调优生成器,即决定各个随机选择的权重。然而,从单个权重推断最终分布极为困难,这一过程繁琐且限制了实际可达的分布。本文提出生成器的自动离线调优技术:给定带未定符号权重的生成器和目标函数,方法自动学习使目标最优的权重值。作者给出若干有用目标函数,支持(1)逼近期望分布、(2)提升测试用例的多样性与有效性。该方法实现在新型离散概率编程系统 Loaded Dice 中,该系统支持微分与参数学习,并被用作生成器语言。实验表明,该方法能按指定目标有效优化生成器分布;在 PBT 基准上的全面评估显示,当自动按多样性与有效性调优时,生成器的找 bug 速度提升 3.1–7.4 倍。

问题
PBT 用户难以通过手动设置生成器中各随机选择的权重来获得理想的测试输入分布,这一调优过程繁琐且限制了可达分布。
方法
将生成器建模为带未定符号权重的离散概率程序,给定目标函数后自动离线学习最优权重;目标函数可引导目标分布并提升测试用例的多样性与有效性,方法实现在支持微分和参数学习的 Loaded Dice 系统中。
评估
通过实验验证方法能按指定目标函数有效优化生成器分布,并在 PBT 基准上评估自动按多样性与有效性调优后生成器的找 bug 速度,取得 3.1–7.4 倍加速。
原文摘要(Abstract)

Property-based testing validates software against an executable specification by evaluating it on randomly generated inputs. The standard way that PBT users generate test inputs is via generators that describe how to sample test inputs through random choices. To achieve a good distribution over test inputs, users must tune their generators, i.e., decide on the weights of these individual random choices. Unfortunately, it is very difficult to understand how to choose individual generator weights in order to achieve a desired distribution, so today this process is tedious and limits the distributions that can be practically achieved. In this paper, we develop techniques for the automatic and offline tuning of generators. Given a generator with undetermined symbolic weights and an objective function, our approach automatically learns values for these weights that optimize for the objective. We describe useful objective functions that allow users to (1) target desired distributions and (2) improve the diversity and validity of their test cases. We have implemented our approach in a novel discrete probabilistic programming system, Loaded Dice , that supports differentiation and parameter learning, and use it as a language for generators. We empirically demonstrate that our approach is effective at optimizing generator distributions according to the specified objective functions. We also perform a thorough evaluation on PBT benchmarks, demonstrating that, when automatically tuned for diversity and validity, the generators exhibit a 3.1–7.4× speedup in bug finding.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2948,
  title = {Tuning Random Generators: Property-Based Testing as Probabilistic Programming},
  author = {Ryan Tjoa and Poorva Garg and Harrison Goldstein and Todd Millstein and Benjamin C. Pierce and Guy Van den Broeck},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {OOPSLA2},
  year = {2025},
  doi = {10.1145/3763082}
}