The Search for Constrained Random Generators

Authors:
Harrison Goldstein, Hila Peleg, Cassia Torczon, Daniel Sainati, Leonidas Lampropoulos, Benjamin C. Pierce
Published:
Proceedings of the ACM on Programming Languages, volume 10, issue PLDI, pp. 2060-2084. June 8, 2026.
Abstract:

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, and only values, satisfying that predicate. 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 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 out of standard proof-search tactics, reducing implementation burden and allowing the algorithm to benefit from further advances in Lean proof automation

BibTeX:
@article{goldstein2026,
  title = {{The Search for Constrained Random Generators}},
  author = {Harrison Goldstein and Hila Peleg and Cassia Torczon and Daniel Sainati and Leonidas Lampropoulos and Benjamin C. Pierce},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  issue = {PLDI},
  year = 2026,
  month = 6,
  day = 8,
  doi = {10.1145/3808329},
}