Abstract
Traditionally, program synthesis treats the scoring function as a black box, providing limited signal for search algorithms. This paper introduces Glass-Box Program Synthesis (GlassPS), a novel approach where the synthesizer is granted direct access to the source code of the evaluator. By "reading" the evaluator's code, GlassPS extracts features to guide a machine-learning-based search through a grammar-defined program space. Our results demonstrate that GlassPS significantly outperforms brute-force methods, achieving massive speedups on complex algorithmic tasks and showing consistent improvement through iterative self-supervised learning across multiple domains.
Introduction
Program synthesis—the automated generation of code—typically relies on Programming by Example (PBE) or formal specifications. However, PBE is often ambiguous, and black-box scoring provides little guidance for navigating vast search spaces. The authors of this paper argue that in many practical scenarios, such as automated grading or programming contests, the scoring program is already available. GlassPS leverages the internal structure of these scoring functions to learn which programming patterns are likely to succeed for a given problem.
Methods
GlassPS treats program synthesis as a guided search problem within a Context-Free Grammar (CFG). The system follows a structured pipeline to refine its search capabilities:
- Grammar-Based Representation: Programs are represented as trees. The synthesizer must decide which grammar rules to apply at each node.
- Glass-Box Featurization: The system extracts "problem features" from the source code of the scoring program (using a bag-of-rules approach) and combines them with "context features" representing the current state of the program being built.
- Guided Search: A multi-class logistic regression model predicts the probability of each grammar rule being the correct next step based on these features.
- Iterative Learning: To overcome data scarcity, GlassPS generates its own "practice problems." It iteratively solves these problems and uses successful (problem, solution) pairs to refine the model weights $\theta$.
Experimental Setup
The framework was evaluated across four distinct domains: Number Theory (e.g., GCD), Algebraic Roots, Summation Formulas, and String Processing. The training involved 1,000 practice problems generated from grammars, while evaluation was conducted on 100 test problems and 10 high-difficulty "Challenge Problems."
Key Results and Insights
The core finding is that the scoring program acts as a roadmap. For instance, if a scorer contains a mod operator, the solution likely requires one as well. GlassPS successfully captures these correlations, leading to dramatic performance gains:
- Efficiency: On the Greatest Common Divisor (GCD) challenge, brute-force search required 30 hours. GlassPS found the recursive solution in just 10 minutes.
- Learning Progression: The system demonstrated clear iterative gains. In the Number Theory domain, the success rate rose from 10% (no learning) to 70% after four rounds of practice.
- Domain Agnosticism: Even when grammars for different domains were mixed, the system learned to identify the correct "tools" based on the "blueprints" found in the scorer.
Discussion and Limitations
While GlassPS proves the value of introspection, the authors note several areas for future development. The current model uses a simple logistic regression and a "bag-of-rules" feature set that ignores the nesting and order of operations in the scoring code. Moving to Deep Neural Networks could capture more complex relationships. Additionally, the system remains constrained by the expressiveness of the provided CFG; it cannot find solutions that fall outside the predefined grammar rules.
Conclusion
Glass-Box Program Synthesis represents a significant shift from black-box evaluation. By treating the problem specification as a piece of code to be analyzed, synthesizers can learn domain-specific coding patterns without human-labeled data, paving the way for more efficient and intelligent automated programming tools.
Summary updated