Abstract
Let $\mathcal{F}$ be a set of boolean functions. We present SPEX (Specifications from Examples), an algorithm for learning $\mathcal{F}_\lor := \{ \bigvee_{f \in S} f \mid S \subseteq \mathcal{F} \}$ from membership queries. Our algorithm asks at most $|\mathcal{F}| \cdot r$ queries, where $r$ is the number of predicates in the target formula. We demonstrate its efficiency for practical classes such as geometric halfspaces and variable inequalities, providing polynomial-time guarantees for constant dimensions.
Introduction
In Programming by Example (PBE), synthesizers generate code from a few input-output pairs. However, these examples often under-specify the desired behavior. To bridge this gap, active learning via membership queries—where the system asks the user "Is this input-output pair correct?"—can be used to refine the specification. This paper focuses on learning disjunctions of predicates, a fundamental structure for complex program requirements.
The SPEX Algorithm
The proposed algorithm, SPEX, efficiently navigates the search space of possible disjunctions by representing them as a Hasse diagram based on logical implication. It employs a top-down pruning strategy, starting from the most general formula and descending through the diagram.
At each step, SPEX identifies a "witness"—an input where a formula and its immediate logical descendant differ. By querying the user on this witness, the algorithm can prune entire branches of the search space. To manage the complexity of finding these descendants, the authors provide subroutines for identifying immediate descendants in the logical structure.
Complexity and Theoretical Guarantees
SPEX achieves near-optimal query complexity. Specifically, the number of queries is bounded by $|\mathcal{F}| \cdot OPT(\mathcal{F}_\lor)$, where $OPT$ is the size of the target formula. This linear scaling with respect to the base predicate set $\mathcal{F}$ makes it highly efficient for practical applications.
The paper establishes that for halfspaces in constant dimensions, the algorithm runs in polynomial time. However, it also proves that the problem is NP-hard in high dimensions, specifically relating it to the dual 3SAT problem.
Practical Applications
The utility of SPEX is demonstrated in two key domains:
- Geometric Halfspaces: Useful for spatial reasoning and boundary detection.
- Variable Inequalities: Crucial for time-series analysis, such as detecting patterns in stock market data.
The authors integrated SPEX into a synthesizer for the AmiBroker DSL. In this context, financial analysts can "teach" the system to recognize specific chart patterns through a series of visual queries. For a pattern of size $k$, the algorithm requires at most $k^2$ queries, making it feasible for human-in-the-loop interaction.
Conclusion
SPEX provides a robust framework for learning logical specifications from examples. By leveraging the structural properties of predicates and using witness-based pruning, it offers a path toward more precise and reliable program synthesis. Future work includes handling "noisy" teachers who may provide incorrect answers and extending the algorithm to handle cyclic variable inequalities.
Summary updated