[Paper Review] Learning Modulo Theories
This paper introduces SMTLayer, a differentiable PyTorch module that integrates Satisfiability Modulo Theories (SMT) solvers into deep neural networks to embed symbolic knowledge directly into learning. By using unsatisfiable cores and weighted MaxSMT for gradient feedback during backpropagation, SMTLayer enables models to learn interpretable, robust representations with significantly less training data, outperforming prior methods like SATNet and Scallop in data-scarce and covariate shift settings.
Recent techniques that integrate \emph{solver layers} into Deep Neural Networks (DNNs) have shown promise in bridging a long-standing gap between inductive learning and symbolic reasoning techniques. In this paper we present a set of techniques for integrating \emph{Satisfiability Modulo Theories} (SMT) solvers into the forward and backward passes of a deep network layer, called SMTLayer. Using this approach, one can encode rich domain knowledge into the network in the form of mathematical formulas. In the forward pass, the solver uses symbols produced by prior layers, along with these formulas, to construct inferences; in the backward pass, the solver informs updates to the network, driving it towards representations that are compatible with the solver's theory. Notably, the solver need not be differentiable. We implement \layername as a Pytorch module, and our empirical results show that it leads to models that \emph{1)} require fewer training samples than conventional models, \emph{2)} that are robust to certain types of covariate shift, and \emph{3)} that ultimately learn representations that are consistent with symbolic knowledge, and thus naturally interpretable.
Motivation & Objective
- To address the challenge of integrating symbolic knowledge into deep learning without requiring expensive, supervision-heavy labeling.
- To enable deep neural networks to learn representations compatible with symbolic theories via non-differentiable SMT solvers.
- To improve data efficiency, robustness to covariate shift, and interpretability in vision and NLP tasks.
- To demonstrate that symbolic knowledge can be leveraged during training without differentiable relaxations of solver behavior.
- To provide a general-purpose framework that supports diverse SMT theories and scales with advances in solver technology.
Proposed method
- SMTLayer embeds an SMT solver as a differentiable layer in a PyTorch model, using propositional variables to interface with neural network outputs.
- During the forward pass, the SMT solver checks consistency of neural network outputs against symbolic constraints encoded as logical formulas.
- During the backward pass, unsatisfiable cores from the solver are used to generate gradient signals for updating the neural network.
- An alternative approach uses weighted MaxSMT to guide learning by assigning penalties to violated constraints.
- The method avoids differentiable relaxations of the solver, enabling use of any efficient SMT solver regardless of theory complexity or decidability.
- The framework is implemented as a PyTorch module using Z3 as the underlying SMT solver, supporting end-to-end training.
Experimental results
Research questions
- RQ1Can symbolic knowledge encoded as SMT constraints be effectively integrated into deep learning without requiring differentiable relaxations?
- RQ2Does integrating SMT solvers into neural networks improve data efficiency in learning perceptual-symbolic tasks?
- RQ3Can SMTLayer enhance robustness to covariate shift in test-time distributions not seen during training?
- RQ4To what extent does SMTLayer produce interpretable representations that align with the symbolic theory?
- RQ5How does SMTLayer compare to prior differentiable solver layers like SATNet and Scallop in terms of performance and sample efficiency?
Key findings
- On MNIST addition with only 10% of training data, SMTLayer achieved near-perfect accuracy, while SATNet and Scallop failed to converge or learned incorrect representations.
- In visual algebra and visual Sudoku tasks, SMTLayer outperformed SATNet and Scallop, especially in low-data regimes, with performance improving steadily with more data.
- SMTLayer learned digit representations that were correct 99% of the time on MNIST addition, matching standard MNIST model accuracy, while Scallop achieved only ~50% accuracy due to poor disentanglement.
- The model trained with SMTLayer was robust to covariate shift, maintaining high performance when test data had different digit pair compositions than training data.
- SMTLayer produced inherently interpretable representations because the network learned to encode inputs in the same bitvector format used in the symbolic constraints.
- The use of unsatisfiable cores and weighted MaxSMT for gradient feedback proved effective, with the simpler unsatisfiable core method outperforming MaxSMT in practice on the tested datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.