paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Reflecting on Random Generation

反思随机生成
ICFP 7(ICFP)2023匹配度 1/10 · 该论文属于程序语言与软件测试中的随机生成器、property-based testing 与双向编程方向,虽涉及形式化抽象和工程实现,但未涉及用户画像核心关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。引用 10 inbox
Harrison Goldstein, Samantha Frohlich, Meng Wang, Benjamin C. Pierce
crossref: 2026-09-10

AI 速览

一句话:提出反射生成器,统一随机生成器在收缩、变异等测试数据生产中的多种用途。

基于属性的测试中,专家常需精心构造随机生成器来编码合法且有趣的输入空间。该文提出“反射生成器”(reflective generators),其核心能力是能对给定输入值进行反射,计算出可能产生该值的随机选择。该方法融合两种已有抽象:自由生成器(free generators)与部分单子 profunctor(partial monadic profunctors)。作者用其实现并增强收缩与变异算法,且可推广到没有生成器执行轨迹的值。除收缩和变异外,反射生成器还推广了基于示例的生成算法,并可用作检查器、部分值补全器及其他测试数据生产者。

问题
基于属性的测试中,随机生成器需要编码输入合法性与有趣性知识,且这些知识难以复用于收缩、变异、检查等不同任务。
方法
提出反射生成器,结合自由生成器与部分单子 profunctor,使生成器能对已生成值反射并计算其可能的随机选择。
评估
通过实现并增强收缩与变异算法,并推广基于示例的生成、检查器和部分值补全等用途来展示其通用性。
原文摘要(Abstract)

Expert users of property-based testing often labor to craft random generators that encode detailed knowledge about what it means for a test input to be valid and interesting. Fortunately, the fruits of this labor can also be put to other uses. In the bidirectional programming literature, for example, generators have been repurposed as validity checkers, while Python's Hypothesis library uses the same structures for shrinking and mutating test inputs. To unify and generalize these uses and many others, we propose reflective generators, a new foundation for random data generators that can "reflect" on an input value to calculate the random choices that could have been made to produce it. Reflective generators combine ideas from two existing abstractions: free generators and partial monadic profunctors. They can be used to implement and enhance the aforementioned shrinking and mutation algorithms, generalizing them to work for any values that can be produced by the generator, not just ones for which a trace of the generator's execution is available. Beyond shrinking and mutation, reflective generators generalize a published algorithm for example-based generation, and they can also be used as checkers, partial value completers, and other kinds of test data producers.

链接与引用

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

BibTeX
@article{paperbot1904,
  title = {Reflecting on Random Generation},
  author = {Harrison Goldstein and Samantha Frohlich and Meng Wang and Benjamin C. Pierce},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {ICFP},
  year = {2023},
  doi = {10.1145/3607842}
}