TL;DR
NetSyn is a novel framework that automates the creation of fitness functions for genetic algorithms (GAs) in the field of machine programming. By training neural networks to predict how "close" a candidate program is to a target solution based on execution traces, NetSyn significantly outperforms state-of-the-art program synthesis methods, finding more correct programs while exploring a smaller search space.
What Problem Does This Paper Address?
Machine Programming (MP)—the automatic generation of software—often relies on Inductive Program Synthesis (IPS), where a system tries to find a program that matches a set of input-output (I/O) examples. Genetic Algorithms are a natural fit for this search, but they live or die by their fitness function: the metric used to grade how "good" a candidate solution is.
Traditionally, these functions are hand-crafted (e.g., using edit distance between the candidate's output and the target output). However, programs are notoriously brittle; a single character change can result in a completely different output, making simple distance metrics poor guides for evolution. The authors address this by proposing that we should learn the fitness function itself using deep learning.
Methods
The authors introduce NetSyn, which operates in two distinct phases:
- Phase 1: Fitness Function Generation: The system trains a neural network (NN-FF) on a massive corpus of random programs. The network learns to predict an "ideal" fitness score (like the number of common functions or the longest common subsequence) between a candidate and a target program. Crucially, the network takes both I/O examples and execution traces (intermediate values during program run) as inputs.
- Phase 2: Program Generation: A GA uses the trained NN-FF to evolve a population of programs. To further boost performance, NetSyn employs a Restricted Local Neighborhood Search (NS). When the GA's progress plateaus, the system systematically tests small mutations (changing one function at a time) around the top-performing candidates to find the exact solution.
The neural architecture (shown below) uses LSTM encoders to process I/O pairs and execution traces into hidden vectors, which are then fed into fully connected layers to produce a final fitness score.
Datasets
- Training Set: 4,200,000 unique, randomly generated programs of length 5, created using a custom Domain Specific Language (DSL) for list manipulation.
- Evaluation Set: 100 randomly generated programs for each length from 5 to 10.
- Baselines: NetSyn was compared against prominent synthesis tools: DeepCoder, PCCoder, RobustFill, and the genetic programming approach PushGP.
Key Insights and Ideas
- Traces Over Outputs: While final outputs are often "all or nothing," execution traces provide a richer, smoother signal for the neural network to understand if a program is "on the right track."
- Learning the Oracle: Since the actual target program is unknown during synthesis, the NN-FF acts as a proxy for an "oracle" that does know the target, having generalized this knowledge from millions of training examples.
- Hybrid Search Strategy: The GA provides global exploration, while the Local Neighborhood Search (NS) provides efficient local exploitation. This combination helps overcome the "fitness landscape" problems common in program synthesis.
Key Results
NetSyn demonstrated superior synthesis ability across various program lengths:
- Higher Success Rate: For programs of length 5, NetSyn achieved up to a 97% success rate, compared to 40-63% for DeepCoder, PCCoder, and RobustFill.
- Search Efficiency: NetSyn found solutions by searching a much smaller percentage of the total possible program space. For length 5 programs, it synthesized 90% of targets using less than 60% of the maximum search space, whereas competitors often failed to reach 60% success even when exhausting the entire search budget.
- Robustness: As shown in the violin plots below, NetSyn maintains a high synthesis rate (the white dots representing the median are near 100%) for almost every program tested at shorter lengths, while other methods show bimodal distributions with many failures.
Limitations and Future Work
- Implementation Overhead: While NetSyn is algorithmically efficient (searching fewer programs), its current Python/TensorFlow implementation is slower in "wall-clock time" than some highly optimized competitors that leverage parallel hardware more effectively.
- Scaling to Complexity: Like all current synthesis methods, performance degrades as program length and complexity increase.
- DSL Constraints: The current work is limited to a specific list-processing DSL. The authors suggest that future work could extend this to more general-purpose languages with explicit control flow.
Summary updated