Differentiable Logic Programming for Distant Supervision

Akihiro Takemura, Katsumi Inoue · DOI

Introduction

Neural-Symbolic (NeSy) AI seeks to integrate the perceptual capabilities of deep learning with the structured reasoning of symbolic logic. A primary challenge in this field is distant supervision, where models must learn from indirect labels. In a classic example like "MNIST Addition," a model is presented with images of two digits and their sum, but it is never explicitly told the identity of the individual digits. To solve such tasks, current state-of-the-art methods typically rely on external symbolic solvers (e.g., Prolog or ASP) to determine which labels are logically consistent. However, these solvers are computationally expensive and create a significant bottleneck, preventing NeSy systems from scaling to more complex problems.

The Bottleneck of Symbolic Solvers

Traditional NeSy frameworks like DeepProbLog or NeurASP call external solvers during every training step. These solvers operate outside the neural network's computational graph, making them difficult to parallelize on GPUs. As the complexity of the logical rules or the size of the dataset increases, the time spent waiting for the symbolic solver grows exponentially, often leading to training timeouts in even moderately complex tasks.

Methodology: Logic as Linear Algebra

This research introduces a differentiable logic programming framework that replaces external symbolic solvers with matrix operations. By embedding logical rules directly into the neural network's optimization process, the system can learn logical constraints through standard backpropagation.

1. Matrix Embedding

The framework represents a logic program using two primary binary matrices:

  • Matrix $\mathbf{Q}$ (Program Matrix): Encodes the "bodies" or conditions of the logical rules.
  • Matrix $\mathbf{D}$ (Head Matrix): Encodes the "heads" or the resulting conclusions of those rules.

2. Differentiable Evaluation

Instead of treating logic as a series of discrete true/false steps, the authors utilize a piecewise linear function—a variation of the ReLU (Rectified Linear Unit)—to count "false literals." This approach makes the logical evaluation differentiable, allowing the model to calculate a "logical loss" that can be backpropagated directly through the neural network layers.

3. Unified Loss Function

The model minimizes a dual-component loss function:

  • Implication Loss: Ensures that if the conditions (body) of a rule are satisfied, the model predicts the corresponding conclusion (head).
  • Constraint Loss: Penalizes the model for violating "integrity constraints," such as the physical impossibility of a single digit image representing both a '3' and a '5' simultaneously.

Experimental Results

The authors evaluated the framework against standard NeSy benchmarks, including MNIST Addition, ADD2x2, APPLY2x2, and MEMBER(n) tasks. The results highlight two major advantages: efficiency and accuracy.

Massive Speedups

The most striking result occurred in the Member 5 task. While existing solver-based methods like DeepProbLog and NeurASP timed out after 30 minutes of computation, the proposed differentiable method completed the task in just 11.6 seconds. By leveraging GPU-accelerated linear algebra, the framework avoids the overhead of external symbolic calls.

Competitive Accuracy

In the Apply2x2 task—which involves identifying handwritten mathematical operators—the proposed method achieved 99.5% accuracy. This significantly outperformed DeepProbLog (87.8%) and NeurASP (80.9%), demonstrating that a differentiable approximation of logic can be more effective for training than exact symbolic solvers in certain distant supervision contexts.

Scalability

The method handles larger logic programs with ease. For instance, in a 2-digit addition task involving 10,000 rules, the matrix-based approach remained performant where traditional solvers struggled to manage the rule explosion.

Key Insights

  • Solvers are Optional: The research proves that explicit symbolic reasoning during training is not strictly necessary. If logic is expressed via matrix operations, the neural network can "sense" the logical structure through the gradient.
  • Vectorization is Key: Moving logic into the domain of linear algebra allows NeSy models to benefit from the same hardware acceleration that has fueled the deep learning revolution.
  • Rule Flexibility: The study suggests that engineers may not need exhaustive logical rules; often, using only implications or only constraints is sufficient for the model to converge on the correct solution.

Limitations and Future Work

While the framework shows great promise, it currently focuses on "crisp" (binary) logic. Future research may explore integrating fuzzy logic, where truth values exist on a continuum between 0 and 1. Additionally, while the continuous-valued interpretation vectors are effective for training, they lack the intuitive probabilistic meaning found in some traditional NeSy systems. Finally, further testing is required to determine how well matrix-based logic scales to extremely deep recursive programs or massive knowledge bases where matrix dimensions might become a constraint.

Summary updated

BibTeX
@inproceedings{takemura2024differentiable,
  author = {Akihiro Takemura and Katsumi Inoue},
  title = {{Differentiable Logic Programming for Distant Supervision}},
  booktitle = {ECAI},
  year = {2024},
  doi = {10.3233/faia240628},
}
Figure