Abstract
In this work, we propose a novel framework for the logical specification of non-Markovian rewards in Markov Decision Processes (MDPs) with large state spaces. Our approach leverages Linear Temporal Logic Modulo Theories over finite traces (LTLfMT), a more expressive extension of classical temporal logic in which predicates are first-order formulas of arbitrary first-order theories rather than simple Boolean variables. This enhanced expressiveness enables the specification of complex tasks over unstructured and heterogeneous data domains, promoting a unified and reusable framework that eliminates the need for manual predicate encoding. However, the increased expressive power of LTLfMT introduces additional theoretical and computational challenges compared to standard LTLf specifications. We address these challenges from a theoretical standpoint, identifying a fragment of LTLfMT that is tractable but sufficiently expressive for reward specification in an infinite-state-space context. From a practical perspective, we introduce a method based on reward machines and Hindsight Experience Replay (HER) to translate first-order logic specifications and address reward sparsity. We evaluate this approach to a continuous-control setting using Non-Linear Arithmetic Theory, showing that it enables natural specification of complex tasks. Experimental results show how a tailored implementation of HER is fundamental in solving tasks with complex goals.
Introduction
Defining effective reward functions for complex, multi-step tasks in Reinforcement Learning (RL) is a notorious challenge. While temporal logics like Linear Temporal Logic over finite traces (LTLf) offer a way to specify high-level rules (e.g., "pick up the object before delivering it"), they typically rely on simple Boolean predicates. In continuous domains, such as robotics, this requires developers to manually engineer "labeling functions" to map continuous states to Boolean flags. This process is tedious, error-prone, and lacks reusability.
Furthermore, logic-based specifications inherently lead to sparse rewards, as the agent only receives feedback upon satisfying a complex logical condition. This paper introduces a framework that addresses both the specification bottleneck and the optimization challenge by combining First-Order Temporal Logic with advanced data augmentation techniques.
Methodology
LTLfMT for Reward Specification
To eliminate manual reward engineering, we utilize Linear Temporal Logic Modulo Theories (LTLfMT). Unlike standard LTLf, LTLfMT allows predicates to be first-order formulas over specific theories, such as Non-Linear Real Arithmetic. This allows for the direct inclusion of continuous spatial constraints—for instance, specifying a goal as $(x - x_{goal})^2 + (y - y_{goal})^2 < r^2$—within the logic itself. We identify a "lookahead-free" fragment of this logic that remains computationally tractable and use SMT (Satisfiability Modulo Theories) solvers to evaluate these predicates dynamically.
CRM-HER: Bridging Logic and Sample Efficiency
The logical specification is translated into a Deterministic Finite Automaton (DFA), which is then integrated with the environment to form a "product MDP." To overcome the resulting reward sparsity, we propose CRM-HER, a combination of two techniques:
- Counterfactual Experiences for Reward Machines (CRM): This allows the agent to learn from "what if" scenarios, simulating transitions across different states of the logical task.
- Hindsight Experience Replay (HER): This enables the agent to learn from failures by treating reached states as intended goals.
By applying HER to both real and counterfactual trajectories generated by CRM, we create a synergy that significantly improves sample efficiency in continuous control tasks.
Experimental Setup
We evaluated the framework using the Deep Deterministic Policy Gradient (DDPG) algorithm in two continuous-control environments:
- Parking Environment: A 2D simulation where a vehicle must navigate through checkpoints and park with specific orientation constraints.
- Reacher Environment: A robotic arm task requiring the end-effector to reach specific target zones in a defined sequence.
Results and Discussion
The experimental results demonstrate that the integration of CRM and HER is critical for solving complex, multi-step tasks. While CRM helps the agent understand the temporal sequence of a task, HER assists in discovering goals within the continuous state space.
As shown in the figure above, the proposed CRM-HER approach (pink diamonds) consistently outperforms baselines. Notably, in the most challenging scenario (parking_2), which involves multiple checkpoints and strict orientation requirements, standard DDPG and CRM-only approaches fail to achieve any success. CRM-HER, however, successfully learns the policy, reaching high success rates where other methods flatline. This highlights that neither temporal reasoning (CRM) nor goal discovery (HER) is sufficient on its own for these complex logical tasks.
Conclusion
This work demonstrates that LTLfMT provides a powerful, reusable framework for specifying rewards in continuous RL without manual labeling. By combining this logic with CRM-HER, we can effectively solve complex tasks with sparse rewards. Future work will explore integrating this framework with hierarchical RL and extending it to handle safety constraints and formal verification in continuous domains.
Summary updated