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

Neural Logic Machines

Honghua Dong, Jiayuan Mao, Tian Lin, Chong Wang, Lihong Li, Denny Zhou

TL;DR

Neural Logic Machines (NLMs) bridge the gap between deep learning and symbolic reasoning by using neural networks to learn "lifted" logic rules. Unlike standard neural networks that often rely on pattern matching, NLMs can be trained on tiny problems (like sorting 5 numbers) and generalize perfectly to much larger ones (like sorting 50 numbers) because they learn the underlying logic of the task.

The Challenge: Systematicity vs. Scalability

Deep learning excels at perception but often struggles with systematicity—the ability to understand recursive or rule-based systems. For example, a standard sequence model trained to sort arrays of length 10 often fails when presented with an array of length 11.

Conversely, traditional Inductive Logic Programming (ILP) is excellent at learning symbolic rules that generalize perfectly. However, ILP suffers from an exponential search space, making it difficult to scale to complex, large-scale problems.

The authors address this gap by creating a system that is:

  1. Differentiable: Can be trained efficiently using standard gradient descent.
  2. Relational: Can handle complex relationships between multiple objects (e.g., "Is block A on top of block B?").
  3. Generalizable: Recovers "lifted rules"—logic that applies to objects uniformly, regardless of the total number of objects in the environment.

Methods: The NLM Architecture

The NLM is a neural-symbolic architecture that treats logic predicates as tensors and logical operations as neural modules.

Neural Logic Machine Architecture
  • Predicates as Tensors: A property of a single object (unary predicate) is represented as a vector. A relationship between two objects (binary predicate) is represented as a matrix.
  • Neural Logic Operators: Instead of hard-coded logic gates (AND, OR, NOT), NLMs use Multi-Layer Perceptrons (MLPs) to approximate boolean operations. This allows the network to act as a "fuzzy" logic system that learns rules directly from data.
  • Quantification via Wiring: To implement logical quantifiers like "For All" ($\forall$) and "There Exists" ($\exists$), the NLM uses specific tensor operations:
  • Expansion: Adds a new variable to a predicate (increasing tensor rank).
  • Reduction: Eliminates a variable by taking the maximum or minimum across a dimension (decreasing tensor rank), effectively performing existential or universal quantification.
  • Layered Reasoning: The architecture is organized into layers, with each layer performing a step of deduction. As data flows deeper into the network, the model builds increasingly complex predicates (e.g., moving from "is on" to "is moveable" to "should move").

Datasets and Key Results

The authors evaluated NLMs on several symbolic reasoning benchmarks, training the models on small-scale instances and testing them on large-scale instances to measure true generalization.

  • Family Tree & General Graphs: Reasoning about complex relationships (e.g., MaternalGreatUncle) and graph properties (e.g., Connectivity, OutDegree).
  • Algorithmic Tasks: Sorting arrays and finding the shortest path in a graph.
  • Blocks World: A classic AI planning domain where an agent must move blocks to reach a target configuration.
Blocks World Task and Predicates

Perfect Generalization

NLMs achieved 100% accuracy on almost all tasks, significantly outperforming baselines like Memory Networks (MemNN). Because the MLPs in an NLM are shared across all object indices, the learned "rules" are independent of the number of objects.

In the Sorting and Shortest Path tasks, NLMs trained on just 12 objects maintained 100% accuracy when tested on 50 objects. In contrast, baseline models saw their performance plummet as the number of objects increased. Furthermore, NLMs successfully learned policies to solve the Blocks World from sparse rewards—a task where traditional ILP often fails due to the complexity of the required rules.

Key Insights

  • Lifted Rules are the Key to Generalization: By separating the logic from the specific entities, the model generalizes to larger sets without retraining.
  • Breadth vs. Depth: The "Breadth" of an NLM (the maximum arity of relations it considers) and "Depth" (number of layers) define its reasoning capacity. For instance, a breadth of 3 allows the model to reason about relationships between three objects simultaneously, which is necessary for concepts like transitivity (if $a \to b$ and $b \to c$, then $a \to c$).

Limitations and Future Work

While powerful, NLMs have a few limitations:

  • Fixed Hyperparameters: The depth and breadth must be specified upfront. If a problem requires 10 steps of reasoning but the NLM only has 5 layers, it will fail.
  • Symbolic Input Requirement: Currently, NLMs require symbolic inputs (predicates). While the authors show a proof-of-concept using a CNN to extract predicates from MNIST images, full integration with raw, noisy sensory data remains an open challenge.
  • Search Complexity: Tensor operations still grow exponentially with the number of objects ($O(m^B)$), which could limit applications to extremely large-scale graphs or databases.
  • Explainability: While the model learns logic, the rules are hidden within MLP weights. Extracting human-readable Horn clauses from a trained NLM is a promising area for future research.

Summary updated

BibTeX
@inproceedings{dong2019neural,
  author = {Honghua Dong and Jiayuan Mao and Tian Lin and Chong Wang and Lihong Li and Denny Zhou},
  title = {{Neural Logic Machines}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=YvJeMIXGX6},
}
Figure