Comparing Differentiable Logics for Learning Systems: A Research Preview

Thomas Flinkow, Barak A. Pearlmutter, Rosemary Monahan

Abstract

This research preview evaluates "differentiable logics"—mathematical frameworks that translate logical rules into loss functions—to integrate background knowledge directly into neural networks. By comparing the established DL2 system against various fuzzy logics, the study demonstrates that while these methods significantly improve a model's adherence to constraints, they introduce a highly sensitive and non-monotonic hyperparameter ($\lambda$) that complicates stable training.

Introduction

Purely data-driven machine learning often fails to capture "common sense" or domain-specific rules, such as "a car is more similar to a truck than a dog." While formal verifiers can check if a trained model follows these rules post-hoc, they typically treat the model as a "black box" after training is complete.

This research addresses the challenge of correct-by-construction learning. Instead of checking for errors after the fact, the authors explore guiding the learning process itself using logical constraints. The core difficulty lies in making logic "differentiable": standard Boolean logic (True/False) does not provide gradients for optimization. Differentiable logics solve this by mapping logical statements into real-valued loss terms.

Methods

The authors compare two primary approaches to differentiable logic:

  1. DL2 (Deep Learning with Differentiable Logics): A system that maps absolute truth to a loss of 0 and violations to positive values $[0, \infty)$. It handles implications by rewriting them as disjunctions ($x \to y$ becomes $\neg x \vee y$).
  2. Fuzzy Logics: These systems map truth values to the interval $[0, 1]$. The authors test several "flavors" of fuzzy logic, including Gödel, Łukasiewicz, Product, Yager, and Reichenbach. These differ in their mathematical definitions of conjunctions (t-norms) and implications.
Table 1: Definitions of T-norms, T-conorms, and Implications for various fuzzy logic systems.

The training objective combines standard cross-entropy loss ($L_{CE}$) with a weighted logical loss ($L_L$): $$L = L_{CE} + \lambda L_L(\phi)$$ where $\phi$ represents the logical constraint and $\lambda$ is the weight assigned to rule adherence.

Experiments were conducted on three image benchmarks modified for "weakly-supervised" scenarios: Fashion-MNIST (10% data, 10% noise), CIFAR-10 (50% data, 10% noise), and GTSRB (90% data, 10% noise). Constraints included class-similarity (e.g., related classes) and group constraints (confident decisions for similar signs).

Key Results and Insights

The experiments revealed that the weight of the logical loss ($\lambda$) is a "minefield"—it is not monotonic, meaning increasing $\lambda$ does not always improve constraint satisfaction. This makes tuning extremely difficult without expensive grid searches.

For constraints involving implications (if-then statements), fuzzy logics—specifically the Reichenbach implication ($I_{RC}$)—often outperformed DL2. This suggests that the mathematical representation of "if-then" rules significantly impacts gradient flow. The authors also noted the importance of the "shadow-lifting" property in conjunctions, found naturally in the Product t-norm, which ensures that as part of a rule becomes "more true," the overall loss decreases.

Table 2: Performance comparison on Fashion-MNIST and CIFAR-10, showing Prediction Accuracy (P) and Constraint Accuracy (C).

On CIFAR-10, the baseline model satisfied class-similarity constraints only ~48% of the time. Utilizing Reichenbach fuzzy logic boosted this to 90.74%. However, improved "Constraint Accuracy" often came at the cost of a slight decrease in "Prediction Accuracy," reflecting a known trade-off between rule adherence and general classification performance.

Conclusion and Future Work

While differentiable logics drastically improve rule satisfaction, they present challenges in tuning feasibility. Finding the optimal $\lambda$ currently requires computationally expensive experimentation. Furthermore, these constraints act as regularizers during training but are discarded during inference. Future work may explore using these logics at runtime for confidence scoring or bridging the gap between fuzzy logic (vagueness) and probability through systems like DeepProbLog. Finally, unlike formal verification, these methods improve the likelihood of satisfaction but provide no hard guarantees that rules will never be broken.

Summary updated

BibTeX
@inproceedings{flinkow2023comparing,
  author = {Thomas Flinkow and Barak A. Pearlmutter and Rosemary Monahan},
  title = {{Comparing Differentiable Logics for Learning Systems: A Research Preview}},
  booktitle = {FMAS@iFM},
  year = {2023},
  url = {https://openreview.net/forum?id=LoMxeLlHjE},
}
Figure