Comparing differentiable logics for learning with logical constraints
Thomas Flinkow, Barak A. Pearlmutter, Rosemary Monahan
TL;DR
This work investigates learning with background knowledge by comparing differentiable logics (DL2 and fuzzy logics) for enforcing logical constraints during neural network training. It advances the experimental methodology by incorporating counterexample generation via Projected Gradient Descent and adaptive loss balancing with GradNorm, enabling fairer comparisons and stronger constraint satisfaction. The study analyzes theoretical properties (shadow-lifting, Modus Ponens/Tollens, consistency) and empirically assesses how different operators affect learning and subsequent verification outcomes using Vehicle and Marabou. Results show that incorporating logical constraints generally improves constraint satisfaction and verifiable properties, though trade-offs with prediction accuracy and task-specific biases remain; the work highlights practical directions toward verifiable, constraint-guided learning and outlines paths to certified training and probabilistic extensions. Overall, the paper contributes a thorough framework for evaluating differentiable logics in learning with constraints and demonstrates their potential to support safer, corrective learning in autonomous and safety-critical systems.
Abstract
Extensive research on formal verification of machine learning systems indicates that learning from data alone often fails to capture underlying background knowledge, such as specifications implicitly available in the data. Various neural network verifiers have been developed to ensure that a machine-learnt model satisfies correctness and safety properties; however, they typically assume a trained network with fixed weights. A promising approach for creating machine learning models that inherently satisfy constraints after training is to encode background knowledge as explicit logical constraints that guide the learning process via so-called differentiable logics. In this paper, we experimentally compare and evaluate various logics from the literature, present our findings, and highlight open problems for future work. We evaluate differentiable logics with respect to their suitability in training, and use a neural network verifier to check their ability to establish formal guarantees. The complete source code for our experiments is available as an easy-to-use framework for training with differentiable logics at https://github.com/tflinkow/comparing-differentiable-logics.
