Compositional Reinforcement Learning from Logical Specifications

Kishor Jothimurugan, Suguman Bansal, Osbert Bastani, Rajeev Alur

Overview

This paper introduces DIRL (Dijkstra-style Reinforcement Learning), a framework that combines high-level logical planning with low-level reinforcement learning (RL) to solve complex, long-horizon tasks. By decomposing a logical specification into an abstract graph and interleaving a Dijkstra-style search with neural network policy training, DIRL achieves state-of-the-art performance and scales linearly with task complexity.

The Challenge of Long-Horizon Tasks

Standard Reinforcement Learning excels at low-level motor skills, such as walking or grasping, but struggles significantly with complex, multi-stage goals. Designing "reward functions" for these long-horizon tasks is notoriously difficult. If the reward is too simple, the agent might "reward hack" (finding a shortcut that doesn't actually solve the task); if it's too sparse, the agent may never learn anything at all.

While recent work uses formal logic (like LTL or SPECTRL) to specify tasks precisely, existing methods usually try to solve the entire specification with a single model-free RL algorithm. This approach scales poorly because the agent has to stumble upon a very long sequence of correct actions entirely by chance. The authors identify a critical gap: there is a need to exploit the compositional structure of logical specifications to decouple high-level planning from low-level control.

The DIRL Framework

To address these limitations, the authors propose DIRL, which operates in three main phases:

  1. Graph Construction: The framework converts a task specified in the SPECTRL language into an abstract Directed Acyclic Graph (DAG). In this graph, vertices represent "subgoal regions" in the state space, and edges represent the subtasks needed to move between them.
  2. Interleaved Planning and Learning: Instead of training all possible subtasks upfront, DIRL uses a Dijkstra-style algorithm to find the "shortest" path to the goal. The "cost" of an edge is defined as the negative log-probability of a policy successfully completing that subtask ($c = -\log P_{success}$).
  3. On-the-fly RL: As the Dijkstra search explores the graph, it triggers low-level RL (using algorithms like ARS or TD3) to learn neural network policies for specific edges. Crucially, it uses the distribution of states reached by previous subtasks to set the starting point for the next one. This prevents "distribution shift," a common failure mode where a policy fails because it starts in a state it never saw during training.
The Rooms environment, its corresponding abstract graph for a logical specification, and DIRL's performance compared to baselines.

Evaluation Environments

The approach was evaluated on two main continuous control benchmarks:

  • Rooms Environment: A 2D navigation task (9-rooms and 16-rooms) where an agent must visit specific areas in a specific logical order while avoiding obstacles.
  • Fetch Environment: Based on OpenAI Gym’s robotic arm benchmarks. The tasks involved complex sequences like PickAndPlaceChoice, where the robot must manipulate a block to one of several goal locations based on a logical specification.

Why DIRL Works

Several key insights drive DIRL's success:

  • Model-Based High Level, Model-Free Low Level: High-level planning should be model-based to exploit the known structure of the logical formula, while low-level control should remain model-free to handle the messy, continuous physics of the environment.
  • Linear Scalability: Because DIRL decomposes the task, its sample complexity scales linearly with the size of the specification. In contrast, most baselines degrade exponentially or fail entirely as the task adds more steps.
  • The "Lazy" Advantage: By training policies only when the Dijkstra search requires an edge cost, DIRL avoids wasting computational effort on subtasks that aren't part of an optimal path to the goal.
  • Probabilistic Planning: By setting edge costs to $-\log P(success)$, the shortest path in the graph mathematically corresponds to the sequence of subtasks that maximizes the overall probability of satisfying the entire complex specification.

Performance and Results

DIRL significantly outperformed state-of-the-art methods like SPECTRL, QRM, and HRM.

In the 16-rooms environment, baselines failed to solve tasks with more than one or two segments. DIRL, however, maintained high success rates even as the number of sub-specifications increased to five. Furthermore, DIRL demonstrated exceptional sample efficiency. In the Fetch environment, DIRL reached a ~0.9 success probability on the PickAndPlace task in roughly $1.5 \times 10^6$ steps, whereas most baselines remained near zero success even after $3.5 \times 10^6$ steps.

The system also proved robust to "blocked doors" and complex branching logic, demonstrating that the high-level planner can effectively navigate environmental constraints that aren't explicitly detailed in the logical formula.

Limitations and Future Directions

While powerful, DIRL has a few limitations. The current algorithm assumes the ability to sample or reset the environment to previously observed states to train sub-policies. For real-world scenarios where a hard reset isn't possible, the authors suggest using "path policies" to navigate back to these states.

Additionally, DIRL currently finds a single best "path" of subtasks. An optimal policy might need to follow different high-level plans depending on exactly which state it reaches within a subgoal region. Finally, future work aims to extend the underlying SPECTRL language to support more sophisticated features like conditionals (if-then-else) and loops (repeat until) directly within the compositional framework.

Summary updated

BibTeX
@inproceedings{jothimurugan2021compositional,
  author = {Kishor Jothimurugan and Suguman Bansal and Osbert Bastani and Rajeev Alur},
  title = {{Compositional Reinforcement Learning from Logical Specifications}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=ion6Lo5tKtJ},
}
Figure