Compositionality—the ability to build complex behaviors from simple, pre-trained primitives—is a critical aspect of scalable system design in Reinforcement Learning (RL). Training an agent from scratch for every possible combination of tasks and constraints is computationally prohibitive.
While prior research has established a "Boolean task algebra" for reachability (i.e., combining policies to reach a specific goal using AND, OR, NOT logic), it has historically struggled with safety. In previous frameworks, "NOT A" simply meant the agent shouldn't end its route at state A; it did not prevent the agent from passing through A on its way to another goal. Furthermore, most compositional RL research has been limited to discrete action spaces, leaving a significant gap for real-world robotics and physics simulations.
This paper introduces a framework for combining pre-trained RL tasks using Boolean logic at runtime, with a specific focus on composable safety. By defining new safety semantics and a hierarchical penalty structure, the authors enable agents to achieve complex goals while actively avoiding "bad" states in both discrete and continuous action spaces—all without requiring additional training for the combined tasks.
Methods: Defining Safety Semantics
To govern how an agent behaves when tasks are composed with avoidance constraints, the authors propose two distinct "safety semantics":
- Minimum-Violation (MV) Paths: The agent prioritizes reaching the goal while minimizing the total number of "bad" (non-goal, negated) states it enters. It will cross a forbidden zone if it is the only or significantly fastest way to the goal.
- Prioritized Safety (PS) Paths: A stricter interpretation where the agent will take a much longer, circuitous path to completely avoid specific "negated" regions, only entering them if absolutely no other path to the goal exists.
Key Technical Innovations
- Penalty Hierarchy: To enforce these semantics, the framework uses a reward structure based on a penalty multiplier ($\eta$). By making "bad" behaviors exponentially more expensive than a standard time-step cost, the authors mathematically prove that the optimal policy will naturally choose the safest path.
- Extended Q-Learning: The system utilizes "extended" Q-functions that take the goal as an input. This allows the agent to understand the value of a state relative to any potential goal in the environment, rather than just a single fixed objective.
- Continuous Composition: For continuous action spaces, the authors derive analytical rules to select the best action at runtime by comparing the Q-values of the underlying primitive policies (e.g., using the
minof Q-values for an AND operation).
Environments and Experimental Validation
The methods were evaluated across three increasingly complex environments to validate both theoretical correctness and practical application:
- 2D Static Grid World: A basic environment used for theoretical validation via Value Iteration.
- 2D Item Collection: A grid world where the agent receives image observations (pixels) and uses Deep Q-Networks (DQN) to learn to collect specific items while avoiding others.
- Bullet-Safety-Gym: A 3D physics simulation featuring continuous observations and continuous force-vector actions, solved using the Twin Delayed DDPG (TD3) algorithm.
Key Insights and Results
- Zero-Shot Safety: The most powerful insight is that safety can be "composed" at deployment. You do not need to train a monolithic "go to the target while avoiding obstacles" policy. You simply train a "go to target" policy and an "avoid obstacle" policy, then combine them using a conjunction ($\wedge$) at runtime.
- Linear Training, Exponential Tasks: The framework allows for a "superexponential" number of task combinations. Training time scales linearly with the number of base tasks, but the agent can execute any Boolean combination of those tasks instantly. The authors demonstrate that learning safety-aware composable policies is significantly more efficient than learning every individual task combination from scratch.
- Continuous Action Success: In the Bullet-Safety-Gym, the agent successfully navigated to targets while avoiding specific objects (e.g., "go to sphere AND NOT purple"), marking a first for Boolean composition in continuous action spaces.
- The "Chattering" Problem: The authors identify a failure mode called "chattering" (infinite loops) that can occur when two negated policies disagree on the best way to avoid a region. They provide specific assumptions to circumvent this, suggesting that highly complex safety constraints should sometimes be pre-trained as a single "negated" unit.
Limitations and Future Work
Currently, the theoretical proofs rely on deterministic Markov Decision Processes (MDPs). While the experiments show the framework works well with function approximation (DQN/TD3), extending formal guarantees to stochastic environments remains a future goal. Additionally, the system can struggle with sparse rewards (mitigated here via curriculum learning) and assumes static environments where the "labels" of goals and obstacles are known.
Future directions include integrating Temporal Logic to allow for sequences of tasks (e.g., "Do A, then B, while avoiding C") and exploring reward shaping to improve convergence speed.
Summary updated