The Search for Constrained Random Generators

📅 2025-11-15
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
In property-based testing (PBT), constraint-aware random generation—efficiently sampling program values satisfying sparse preconditions—is a critical bottleneck. This paper introduces Palamedes, the first system to unify deductive program synthesis with generator denotational semantics: it systematically rewrites recursive predicates into catamorphisms and synthesizes executable generators via anamorphisms; it leverages Lean’s inductive proof search to automatically synthesize generators for arbitrary inductively defined predicates. Unlike traditional rejection sampling or manual generator coding, Palamedes achieves high efficiency and coverage in sparse input spaces. It provides the first generator synthesis framework for PBT that simultaneously ensures expressive power (supporting arbitrary inductive predicates), full automation, and formal correctness guarantees grounded in constructive logic and semantic foundations.

Technology Category

Application Category

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

Research questions and friction points this paper is trying to address.

Constrained random generation for property-based testing
Efficient sampling from sparse valid input distributions
Synthesizing correct generators using deductive program synthesis
Innovation

Methods, ideas, or system contributions that make the work stand out.

Synthesizes generators via deductive program synthesis rules
Handles recursion with catamorphism-anamorphism matching technique
Implements synthesis using Lean theorem prover proof-search tactics
🔎 Similar Papers
No similar papers found.