Program Synthesis Guided Reinforcement Learning

Yichen Yang, Jeevana Priya Inala, Osbert Bastani, Yewen Pu, Armando Solar-Lezama, Martin C. Rinard

Introduction

The authors introduce Model Predictive Program Synthesis (MPPS), a framework that automatically generates high-level programs to guide reinforcement learning agents through complex, long-horizon tasks. By combining a generative "hallucinator" to predict unobserved parts of the world with a symbolic synthesizer, MPPS achieves near-human-expert performance in partially observed environments without requiring users to write a new program for every task.

The Challenge of Long-Horizon Tasks

Reinforcement Learning (RL) often struggles with "long-horizon" problems—tasks that require a long, specific sequence of actions to succeed, such as gathering resources to build a tool to cross a river to find a gem. While providing the agent with a "guiding program" (a sequence of subgoals) helps immensely, it creates a massive manual burden: the user has to write a new program for every single task instance.

This challenge is even harder in partially observed environments, where the agent can only see a small area around itself. A pre-written program might fail if the resources it expects aren't where it thought they were. The authors aim to bridge this gap by letting the agent "dream up" the hidden parts of the world and write its own guiding programs on the fly.

Methodology: Model Predictive Program Synthesis

The MPPS framework consists of three main components that operate in a loop:

The MPPS architecture showing the DSL grammar (a) and the interaction between the Hallucinator, Synthesizer, and Executor (b).
  1. The Hallucinator (CVAE): Since the agent can't see the whole map, it uses a Conditional Variational Auto-Encoder to predict multiple possible versions of the unobserved regions based on what it has seen so far. Instead of predicting raw pixels, it predicts high-level features (e.g., "there are likely 2 woods in the dark zone").
  2. The Synthesizer (MaxSAT): The agent takes these "hallucinated" worlds and uses a symbolic solver (Z3) to find a program in a Domain-Specific Language (DSL) that has the highest probability of success across all predicted scenarios. This makes the strategy robust to uncertainty.
  3. The Executor (Modular Neural Network): The agent follows the synthesized program using pre-trained "options"—low-level neural policies that know how to achieve specific subgoals like "get wood" or "use workbench."

The agent executes the program for $N$ steps, observes more of the environment, and then repeats the process (re-planning) until the goal is met.

Key Insights

  • Feature-based Hallucination: The agent doesn't need to imagine every pixel of the hidden world. By predicting abstract state features (like resource counts), the program synthesis step remains computationally tractable.
  • Robustness through Sampling: By synthesizing a program that works across multiple hallucinated worlds, the agent avoids being "blindly optimistic." It plans for the most likely distribution of the world rather than assuming a single outcome.
Illustration of the agent hallucinating unobserved regions to synthesize robust programs based on different predicted world states.
  • Implicit Exploration: The agent doesn't need an explicit "exploration reward." Because it re-plans as it sees more of the map, it is naturally incentivized to move toward unobserved areas to resolve uncertainty and find a valid path to its goal.
  • Hierarchical Transfer: The high-level "program" logic is agnostic to the low-level "physics." This allowed the authors to take a strategy learned in a simple grid world and successfully apply it to a complex MuJoCo robot.

Evaluation and Results

The researchers evaluated MPPS on three challenging benchmarks: 2D-craft (Minecraft-inspired grid world), Box-world (puzzle reasoning), and Ant-craft (continuous control MuJoCo robot).

  • Significant Performance Boost: In 2D-craft, MPPS achieved an average reward of 0.70, dwarfing standard end-to-end RL (0.22) and world-model-based approaches (0.23).
  • Near-Oracle Performance: MPPS performed nearly as well as an "Oracle" agent (0.76 reward) that was given the ground-truth program by a human, proving that the automated synthesis is highly effective.
  • Continuous Control: In the Ant-craft task, MPPS achieved a 0.40 reward, while standard RL methods failed almost entirely (~0.12), showing the framework's utility for robotics.

Limitations

The approach still requires a human to define the Domain-Specific Language (the set of possible subgoals). While you only have to do this once per domain, it still represents a manual bottleneck. Additionally, running a MaxSAT solver and a generative model in a loop introduces computational overhead compared to simple neural network forward passes, which might limit real-time applications in extremely complex environments.

Summary updated

BibTeX
@inproceedings{yang2021program,
  author = {Yichen Yang and Jeevana Priya Inala and Osbert Bastani and Yewen Pu and Armando Solar-Lezama and Martin C. Rinard},
  title = {{Program Synthesis Guided Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=QwNLVId9Df},
}
Figure