NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Representing Partial Programs with Blended Abstract Semantics

Maxwell Nye, Yewen Pu, Matthew Bowers, Jacob Andreas, Joshua B. Tenenbaum, Armando Solar-Lezama

Overview

Program synthesis—the automated generation of code from input-output examples—is often bottlenecked by the inability to "run" a half-finished program to see if it is on the right track. This paper introduces Blended Abstract Semantics, a hybrid approach that executes finished code blocks concretely while using learned neural modules to "hallucinate" the behavior of unfinished parts (holes). This neuro-symbolic technique allows for much more effective search through the combinatorial space of possible programs.

The Challenge of Incomplete Code

The core challenge in inductive program synthesis is navigating a massive search space. To find a program that matches a set of examples, a synthesizer must explore millions of "sketches" or partial programs.

Recent "execution-guided" approaches have shown that analyzing what a program does (its semantics) is much more powerful than just looking at its code (its syntax). However, you cannot execute a program that has a "hole" in it. For example, if a synthesizer is writing a loop but hasn't yet decided how far the cursor should move in each iteration, the code is unrunnable.

Previous solutions either relied on syntax-only models (which ignore the underlying logic) or hand-designed "abstract interpreters" (which are difficult to build, domain-specific, and often too imprecise). This paper seeks a way to represent the semantic meaning of incomplete code automatically and compositionally.

Methods: Blended Abstract Semantics

To solve this, the authors propose a neuro-symbolic representation called Blended Abstract Semantics.

Overview of the program synthesis search space and how partial programs are evaluated using blended abstract semantics.

The approach is built on three main pillars:

  1. Neural Abstract Semantics: Every primitive function in the programming language (like +, map, or moveHand) is assigned a corresponding Neural Module—a small neural network that approximates the function's behavior in continuous vector space.
  2. Neural Placeholders: Unfinished parts of the code (represented as HOLE) are assigned a learned embedding based on their local context.
  3. The "Blended" Mechanism: When evaluating a program tree, the system intelligently mixes concrete and neural execution:
  4. If a sub-expression is fully written and contains no holes, it is concretely executed to yield a real value (e.g., an image state or a list).
  5. If a sub-expression contains a hole, the system switches to neural execution. It converts any available concrete values into vectors and passes them through the neural modules to approximate the output.
Comparison of RNN, Neural Abstract, and Blended Abstract semantic representations.

Search Guidance: These blended representations are ultimately fed into a Policy network (which predicts the next code token to fill a hole) and a Value function (which predicts if the current sketch will eventually lead to a correct solution).

Datasets and Evaluation

The model was evaluated across three distinct domains to test its versatility:

  • Tower Building: A 2D Tetris-like environment where a hand drops blocks to match a target image. This tests the model's ability to handle loops. (Trained on 480,000 programs).
  • List Processing: A modified version of the DeepCoder dataset that includes a richer, combinatorial set of higher-order functions (lambdas). (Trained on 500,000 programs).
  • String Editing: A domain based on the RobustFill DSL for text manipulation, such as converting "Mariya Sergienko" to "Dr. Mariya". (Trained on 2 million programs).

Key Insights and Results

  • Anchoring in Reality: Purely neural representations can "drift" or become inaccurate for long programs. By using concrete execution whenever possible, the blended model anchors its predictions in ground-truth data, leading to much more robust representations.
  • Compositionality is King: By mirroring the tree structure of the program with neural modules, the model learns the actual "logic" of the programming language rather than just memorizing surface-level syntax patterns.
  • Outperforming Hand-Coded Logic: In the tower domain, the learned value function achieved higher precision than a hand-coded abstract interpreter. The neural model learned to identify subtle failures that a rigid, conservative symbolic system missed.
  • Superior Search Efficiency: In all three domains, the blended approach outperformed syntax-only (RNN) baselines and pure neural semantic baselines. In the tower-building domain, it solved significantly more problems within the same "search budget" compared to previous state-of-the-art methods.
  • Generalization to Complex Constructs: The model successfully synthesized programs with complex nested loops and higher-order functions—constructs that previous execution-guided synthesizers struggled with unless provided with extensive manual DSL modifications.

Limitations and Future Work

While highly effective, the approach has room for refinement. Currently, the model treats loops as fixed feed-forward modules rather than performing an iterative "fixpoint" analysis (the classical computer science method for loop semantics). A more rigorous treatment of loops could improve accuracy for very long-running code. Additionally, while it handles higher-order functions, the internal representation of lambda bodies is still simplified to a single vector.

Future work could apply these blended semantics to more complex tasks, such as synthesizing code directly from natural language instructions or automatically fixing bugs in existing software repositories.

Summary updated

BibTeX
@inproceedings{nye2021representing,
  author = {Maxwell Nye and Yewen Pu and Matthew Bowers and Jacob Andreas and Joshua B. Tenenbaum and Armando Solar-Lezama},
  title = {{Representing Partial Programs with Blended Abstract Semantics}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=mCtadqIxOJ},
}
Figure