NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Neural Logic Reinforcement Learning

Zhengyao Jiang, Shan Luo

Introduction

Neural Logic Reinforcement Learning (NLRL) is a novel framework that represents reinforcement learning (RL) policies using first-order logic. By combining policy gradient methods with a differentiable logic engine, NLRL produces agents that are not only human-readable but also generalize remarkably well to environments much larger or more complex than those seen during training.

The Challenge with Deep Reinforcement Learning

Deep Reinforcement Learning (DRL) has achieved incredible feats, from mastering Atari games to beating world champions at Go. However, DRL faces two major hurdles:

  1. Interpretability: Neural networks act as "black boxes." It is nearly impossible for a human to look at millions of weights and understand why an agent chose a specific action. This lack of transparency is a dealbreaker for safety-critical applications or legal compliance.
  2. Generalization: DRL agents are notoriously brittle. An agent trained to stack three blocks often fails completely when asked to stack five, or even if the starting positions are slightly nudged. They tend to "overfit" to the specific geometry of their training environment rather than learning the underlying abstract rules.

Methods: Differentiable Logic Meets RL

The authors introduce Neural Logic Reinforcement Learning (NLRL), which replaces the standard neural network policy with a Differentiable Recurrent Logic Machine (DRLM).

Key components of this architecture include:

  • Differentiable Inductive Logic Programming (∂ILP): NLRL builds on ∂ILP, a technique that allows logic rules to be learned using gradient descent. Instead of hard "true/false" values, it uses "valuation vectors" that represent the probability of a logical statement being true.
  • The DRLM Architecture: This is an improved version of ∂ILP designed specifically for RL. It performs logical deduction through repeated applications of a step function. Crucially, it is more memory-efficient and allows for longer "chains" of reasoning than previous logic-based models.
  • Logic-Based MDP: The environment is modeled using predicates (e.g., on(block_a, block_b)). A state encoder converts the raw environment into these logical atoms, and an action decoder maps the resulting logical conclusions back into discrete actions.
Blocks manipulation state representation
  • Policy Gradient Training: Because the entire logic engine is differentiable, the authors can use standard "vanilla" policy gradient methods to update the weights of the logical rules based on the rewards the agent receives.

Environments and Generalization Testing

The paper evaluates NLRL on two classic symbolic reasoning domains:

  1. Blocks Manipulation: Three subtasks—STACK (make one tall tower), UNSTACK (spread blocks on the floor), and ON (put a specific block on another).
  2. Cliff-Walking: A grid-world task where an agent must reach a goal while avoiding a "cliff." The authors also tested a Windy Cliff-Walking variant with stochastic movements.

To test generalization, the agents were trained on small versions (e.g., 4 blocks) and tested on much larger versions (up to 7 blocks) or different starting configurations without any additional training.

Key Insights

  • Relational Inductive Bias: By using first-order logic, the model inherently thinks in terms of entities and relationships rather than pixel values or absolute coordinates. This is the "secret sauce" for generalization; the rule "if a block is on the floor, move it to the tower" works regardless of how many blocks are in the room.
  • Differentiable Logic is the Bridge: The paper demonstrates that you don't have to choose between the flexibility of deep learning and the clarity of symbolic logic. By making logic differentiable, you can use the powerful optimization tools of the deep learning era to find symbolic programs.
  • Interpretability by Design: Unlike "post-hoc" explanation methods that try to guess what a neural network is doing, NLRL's policy is the explanation. The output is a set of weighted logical rules that a human can read and verify.

Results

The experiments demonstrate that NLRL vastly outperforms standard Multi-Layer Perceptron (MLP) agents in generalization tasks.

Generalization performance of NLRL vs MLP
  • Superior Generalization: In the UNSTACK task, while a standard MLP agent's performance plummeted to near-failure when the number of blocks increased from 4 to 7, the NLRL agent maintained near-optimal performance.
  • Robustness to Initial States: In Cliff-Walking, moving the agent's starting position caused the MLP agent to fail (as it had essentially memorized a specific path), whereas the NLRL agent, having learned the concept of the goal's relative position, adapted instantly.
  • Human-Readable Policies: The authors successfully extracted the learned rules. For example, in the STACK task, the agent induced a rule that effectively means: "Move a block to the top of a column if that column is at least two blocks high."
Task (Generalization) NLRL Return MLP Return
UNSTACK (7 blocks) 0.868 -0.980 (Failure)
STACK (7 blocks) 0.828 -0.980 (Failure)
Cliff-Walking (7x7) 0.824 -1.122 (Failure)

Limitations and Future Work

While promising, NLRL has a few limitations to address in future research:

  • Hand-crafted Encoders: Currently, the "state encoder" that turns the world into logical predicates is hand-crafted. Future work could use neural networks (like CNNs) to learn these predicates directly from raw sensory data (pixels).
  • Scalability of Deduction: While DRLM is more efficient than ∂ILP, logical deduction over a massive number of possible "atoms" can still be computationally expensive compared to simple matrix multiplications in standard neural networks.
  • Complexity of Rules: The current framework uses relatively simple rule templates. Learning highly complex, multi-step nested logic for more intricate environments remains a significant challenge.

Summary updated

BibTeX
@inproceedings{jiang2019neural,
  author = {Zhengyao Jiang and Shan Luo},
  title = {{Neural Logic Reinforcement Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
}
Figure