Logically-Correct Reinforcement Learning

Mohammadhosein Hasanbeig, Alessandro Abate, Daniel KroeningarXiv 2018

Abstract

We present the first model-free Reinforcement Learning (RL) algorithm designed to synthesize policies for unknown Markov Decision Processes (MDPs) such that a specific linear time property is satisfied. By converting temporal properties into Limit Deterministic Büchi Automata (LDBA), we define a robust reward function over the state-action pairs of the MDP. This reward structure constrains the policy synthesis procedure, guiding exploration toward portions of the MDP relevant to the satisfaction of the Linear Temporal Logic (LTL) property. This approach significantly improves performance and scalability by avoiding exhaustive updates over the entire state space, a common bottleneck in standard dynamic programming methods. Furthermore, we demonstrate that this RL procedure enables local value iteration to calculate the maximum probability of satisfying the property from any given state. Our algorithm is proven to find policies that satisfy the LTL property if they exist and provides reasonable control policies even when satisfaction is impossible. Numerical evaluations show an improvement of one order of magnitude in synthesis iterations compared to existing state-of-the-art approaches.

Introduction

Traditional Reinforcement Learning (RL) excels at maximizing scalar rewards, yet it often struggles with tasks requiring complex, time-dependent constraints. For instance, a robotic agent might be required to "visit a charging station only after picking up a package, while never entering a hazard zone." Expressing such "if-then-eventually" requirements through manual reward engineering is notoriously difficult and prone to "reward hacking," where the agent finds unintended ways to maximize rewards without fulfilling the actual task.

Linear Temporal Logic (LTL) offers a formal mathematical framework to define these complex behaviors. However, previous attempts to integrate LTL with RL faced two primary hurdles: a reliance on pre-existing knowledge of environment transition probabilities (model-dependency) and the "state explosion" problem. The latter is often caused by the use of Deterministic Rabin Automata (DRA), which can grow exponentially relative to the logic formula's complexity, making learning prohibitively slow.

Methodology: The LCRL Framework

Logically-Correct Reinforcement Learning (LCRL) introduces a model-free approach that bridges formal methods and RL through three core innovations:

1. LTL to LDBA Conversion

Instead of the bulky DRAs used in prior research, LCRL converts LTL formulas into Limit Deterministic Büchi Automata (LDBA). LDBAs are significantly more succinct and possess simpler acceptance conditions. This reduction in complexity directly translates to a smaller "Product MDP"—the combined state space of the agent's physical environment and the logical requirements—thereby reducing the computational burden.

2. On-the-Fly Product Construction

LCRL does not require a complete map of the environment or the logic beforehand. Instead, the algorithm tracks the automaton state synchronously as the agent moves. This "on-the-fly" construction allows the agent to ignore vast portions of the environment that are irrelevant to the logical goal, focusing exploration only on paths that contribute to task satisfaction.

3. Automated Reward Shaping

The researchers implemented an "Accepting Frontier Function" to automate reward assignment. This function provides rewards based on the agent's progress through the LDBA’s states. If a policy exists that satisfies the logic, this reward structure guarantees that the RL agent will converge upon it. In parallel, the algorithm utilizes Asynchronous Value Iteration (AVI) to calculate the actual probability of satisfaction at any given state, providing a built-in quality check for the learned policy.

Experimental Evaluation

The LCRL algorithm was evaluated against two primary benchmarks to test its efficiency and robustness:

  • Slippery Grid-World: A stochastic environment where actions (e.g., moving up) only succeed with a specific probability (e.g., 85%). The agent was tasked with complex "safety-plus-reachability" goals.
  • Pacman: A high-dimensional, dynamic environment where the agent must collect specific tokens in a strict order while avoiding moving ghosts.

Key Results and Insights

Efficiency and Scalability

LCRL demonstrated a 10x improvement (one order of magnitude) in the number of iterations required for policy synthesis compared to traditional DRA-based methods. In one specific comparison, LCRL required only 75 states to represent a logic formula that required 150 states under previous methods. This succinctness allows the logic to act as a guide for exploration rather than a computational burden.

Performance in Dynamic Environments

In the Pacman experiment, LCRL successfully identified a stable winning policy within approximately 20,000 episodes. In contrast, classical Q-learning with simple positive rewards failed to find a stable policy, resulting in erratic performance and excessive step counts.

Mathematical Rigor

The built-in probability calculator (AVI) converged to values identical to those produced by PRISM, the gold-standard tool for formal verification. This confirms that the model-free RL approach is as mathematically sound as traditional model-based verification methods.

Graceful Failure

A unique strength of LCRL is its behavior when an LTL property is impossible to satisfy—such as a safety rule that must be violated to reach a mandatory goal. In these scenarios, the algorithm still produces a "reasonable" policy that maximizes the probability of satisfaction, rather than failing entirely.

Conclusion

LCRL represents a significant step forward in making RL agents both efficient and logically reliable. By utilizing LDBAs and on-the-fly product construction, the framework overcomes the state-explosion issues that have long hindered formal RL. Future work will focus on extending these techniques to continuous state and action spaces, partially observable environments (POMDPs), and multi-agent systems where coordinated logical satisfaction is required.

Summary updated

BibTeX
@misc{hasanbeig2018logically,
  author = {Mohammadhosein Hasanbeig and Alessandro Abate and Daniel Kroening},
  title = {{Logically-Correct Reinforcement Learning}},
  year = {2018},
  eprint = {1801.08099},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1801.08099},
}
Figure