LEARNING WITH LOGICAL CONSTRAINTS BUT WITH-OUT SHORTCUT SATISFACTION

Abstract

Recent studies have explored the integration of logical knowledge into deep learning via encoding logical constraints as an additional loss function. However, existing approaches tend to vacuously satisfy logical constraints through shortcuts, failing to fully exploit the knowledge. In this paper, we present a new framework for learning with logical constraints. Specifically, we address the shortcut satisfaction issue by introducing dual variables for logical connectives, encoding how the constraint is satisfied. We further propose a variational framework where the encoded logical constraint is expressed as a distributional loss that is compatible with the model's original training loss. The theoretical analysis shows that the proposed approach bears salient properties, and the experimental evaluations demonstrate its superior performance in both model generalizability and constraint satisfaction.

1. INTRODUCTION

There have been renewed interests in equipping deep neural networks (DNNs) with symbolic knowledge such as logical constraints/formulas (Hu et al., 2016; Xu et al., 2018; Fischer et al., 2019; Nandwani et al., 2019; Li & Srikumar, 2019; Awasthi et al., 2020; Hoernle et al., 2021) . Typically, existing work first translates the given logical constraint into a differentiable loss function, and then incorporates it as a penalty term in the original training loss of the DNN. The benefits of this integration have been well-demonstrated: it not only improves the performance, but also enhances the interpretability via regulating the model behavior to satisfy particular logical constraints. Despite the encouraging progress, existing approaches tend to suffer from the shortcut satisfaction problem, i.e., the model overfits to a particular (easy) satisfying assignment of the given logical constraint. However, not all satisfying assignments are the truth, and different inputs may require different assignments to satisfy the same constraint. An illustrative example is given in Figure 1 . Essentially, the example considers a logical constraint P → Q, which holds when (P, Q) = (T, T) or (P, Q) = (F, F)/(F, T). However, it is observed that existing approaches tend to simply satisfy the constraint via assigning F to P for all inputs, even when the real meaning of the logic constraint is arguably (P, Q) = (T, T) for certain inputs (e.g., class '6' in the example). To escape from the trap of shortcut satisfaction, we propose to consider how a logical constraint is satisfied by distinguishing between different satisfying assignments of the constraint for different inputs. The challenge here is the lack of direct supervision information of how a constraint is satisfied other than its truth value. However, our insight is that, by addressing this "harder" problem, we can make more room for the conciliation between logic information and training data, and achieve better model performance and logic satisfaction at the same time. To this end, when translating a logical constraint into a loss function, we introduce a dual variable for each operand of the logical connectives in the conjunctive normal form (CNF) of the logical constraint. The dual variables, together with the softened truth values for logical variables, provide a working interpretation for the satisfaction of the logical constraint. Take the example in Figure 1 : for the satisfaction of P → Q, we consider its CNF ¬P ∨ Q and introduce two variables τ 1 and τ 2 to indicate the weights of the Based on the dual variables, we then convert logical conjunction and disjunction into convex combinations of individual loss functions, which not only improves the training robustness, but also ensures monotonicity with respect to logical entailment, i.e., the smaller the loss, the higher the satisfaction. Note that most existing logic to loss translations do not enjoy this property but only ensure that the logical constraint is fully satisfied when the loss is zero; however, it is virtually infeasible to make the logical constraint fully satisfied in practice, rendering an unreliable training process towards constraint satisfaction. Another limitation of existing approaches lies in the incompatibility during joint training. That is, existing work mainly treats the translated logic loss as a penalty under a multi-objective learning framework, whose effectiveness strongly relies on the weight selection of each objective, and may suffer when the objectives compete (Kendall et al., 2018; Sener & Koltun, 2018) . In contrast, we introduce an additional random variable for the logical constraint to indicate its satisfaction degree, and formulate it as a distributional loss which is compatible with the neural network's original training loss under a variational framework. We cast the joint optimization of the prediction accuracy and constraint satisfaction as a game and propose a stochastic gradient descent ascent algorithm to solve it. Theoretical results show that the algorithm can successfully converge to a superset of local Nash equilibria, and thus settles the incompatibility problem to a large extent. In summary, this paper makes the following main contributions: 1) a new logic encoding method that translates logical constraints to loss functions, considering how the constraints are satisfied, in particular, to avoid shortcut satisfaction; 2) a variational framework that jointly and compatibly trains both the translated logic loss and the original training loss with theoretically guaranteed convergence; 3) extensive empirical evaluations on various tasks demonstrating the superior performance in both accuracy and constraint satisfaction, confirming the efficacy of the proposed approach. 2 LOGIC TO LOSS FUNCTION TRANSLATION

2.1. LOGICAL CONSTRAINTS

For a given neural network, we denote the data point by (x, y) ∈ X × Y, and use w to represent the model parameters. We use variable v to denote the model's behavior of interest, which is represented



Figure 1: Consider a semi-supervised classification task of handwritten digit recognition. For the illustration purpose, we remove the labels of training images in class '6', but introduce a logical rule P:= (f (R(x)) = 9) → Q := (f (x) = 6) to predict '6', where R(x) stands for rotating the image x by 180 • . The ideal satisfying assignments should be (P, Q) = (T, T) for class '6'. However, existing methods (e.g., DL2(Fischer et al., 2019)) tend to vacuously satisfy the rule by discouraging the satisfaction of P for all inputs, including those actually in class '6'. In contrast, our approach successfully learns to satisfy Q when P holds for class '6', even achieving comparable accuracy (98.8%) to the fully supervised setting.

