Introduction
Many structured prediction problems require outputs that are guaranteed to satisfy logical constraints. A clinical decision support system recommending combinations of medications must never prescribe pairs with known contraindications; a hierarchical multi-label classifier must respect that any predicted sub-class implies its parent. In such settings, a single constraint violation invalidates the entire prediction, regardless of how accurate the underlying predictor is on average. Standard neural architectures provide no guarantee that individual predictions satisfy the constraints at inference time.
Neurosymbolic learning addresses this gap by combining neural predictors with symbolic representations of background knowledge, but existing methods exhibit a stark trade-off between guarantee and scalability. Methods that enforce constraints by construction — Semantic Probabilistic Layers [3 ] and CCN+ [25 ] — either compile the constraint into a circuit and renormalize the predictor against it for every input (SPL), or encode each h h h -valued categorical variable as h h h binary indicators (CCN+). Neither approach scales to the structured-prediction regimes our experiments target. Methods that scale—Scallop [30 ] , DeepSoftLog [35 ] , A-NeSI [48 ] , and CTSketch [10 ] —replace exact symbolic inference with approximations such as top-k k k proof enumeration, neural surrogates for weighted model counting, or low-rank tensor sketches, but in doing so forfeit the satisfaction guarantee.
Table 1. Comparison of CASPER against baselines on three properties. Guaranteed Satisfaction (Sat): method provably produces constraint-compliant outputs. Scalable (Scale): method manages to scale over most over the tasks in our experimental analysis, Automatic (Auto): no problem-specific engineering required.
We present CASPER (Categorical Argmax Satisfaction via ProjEction and Resolution)1 , a differentiable neurosymbolic layer that enforces logical constraint satisfaction at scale. Given a neural predictor m θ m_\theta m θ and a set of constraints Π \Pi Π over categorical variables, CASPER composes with m θ m_\theta m θ as m ~ θ = C A S P E R ∘ m θ \tilde{m}_\theta= \mathrm{CASPER} \circ m_\theta m ~ θ = CASPER ∘ m θ , and processes the variables in sequence projecting each unconstrained output onto the constraint-feasible region of the probability simplex. The variable assignments induced by the argmax of m ~ θ \tilde{m}_\theta m ~ θ are guaranteed to satisfy Π \Pi Π by construction. CASPER achieves scalability through two ideas: an offline compilation step that uses the signed resolution rule to reduce multi-variable satisfaction to a sequence of single-variable problems, and a closed-form surrogate of the per-variable projection that requires quadratically fewer sequential steps on a GPU than the exact solution while preserving the satisfaction guarantee. To further exploit GPU parallelism, CASPER parallelizes the computation over different variables whenever possible using the same intuition as in [25 ] , making the fully sequential case the worst-case bound. Table 1 summarises the contrast: CASPER is the only method that simultaneously (i) guarantees constraint satisfaction, (ii) scales at inference time, and (iii) requires no problem-specific engineering beyond the constraint specification.
Our experiments confirm these claims across three benchmarks. On Warcraft pathfinding, CASPER is the only method that produces guaranteed valid paths on the 30 × 30 30 \times30 30 × 30 grid, where exact baselines time out and approximate methods produce invalid predictions. On MNIST-Arithmetic, CASPER is the only exact-satisfaction method that scales to sums over more than a thousand digits, with inference time that closes the gap to approximate methods as the problem grows. On Sudoku solving, CASPER reaches 66% post-layer board accuracy, against 25% for the strongest scalable baseline unconstrained.
Problem Definition
Notation. We denote scalar constants by lower-case letters, e.g., x x x , random variables by upper-case letters, e.g., X X X , and ordered sets of constants and random variables by bold letters, e.g., x \mathbf{x} x and X \mathbf{X} X , respectively. We write [ n ] [n] [ n ] for the set { 1 , … , n } \{1,\ldots,n\} { 1 , … , n } .
Setting. We consider a learning setting with input space X \mathcal{X} X and structured output space Y = [ h 1 ] × [ h 2 ] × ⋯ × [ h n ] \mathcal{Y} = [h_1]\times[h_2]\times\cdots\times[h_n] Y = [ h 1 ] × [ h 2 ] × ⋯ × [ h n ] , i.e., the structured output is given by n n n categorical variables Y = ( Y 1 , … , Y n ) \mathbf{Y} = (Y_1,\ldots,Y_n) Y = ( Y 1 , … , Y n ) , where each Y i Y_i Y i takes values in [ h i ] [h_i] [ h i ] . Let Π \Pi Π be a set of constraints defining the feasible assignments V Π = { a ∈ Y ∣ a ⊨ Π } \mathcal{V}_\Pi= \{a \in\mathcal{Y} \mid a \models\Pi\} V Π = { a ∈ Y ∣ a ⊨ Π } of the problem, a ⊨ Π a \models\Pi a ⊨ Π indicating that the assignment a ∈ Y a \in\mathcal{Y} a ∈ Y satisfies Π \Pi Π . For ease of exposition, we represent background knowledge using signed clauses with empty order [9 ] . A signed clause is an expression of the form:
S 1 : Y 1 ∨ S 2 : Y 2 ∨ … ∨ S m : Y m , (1) S_1 : Y_1 \lor S_2 : Y_2 \lor\ldots\lor S_m : Y_m, \tag*{(1)} S 1 : Y 1 ∨ S 2 : Y 2 ∨ … ∨ S m : Y m , (1)
where, with a slight abuse of notation, Y i Y_i Y i indicates a multiple-valued logic variable (corresponding to the respective random variable), S i ⊆ [ h i ] S_i \subseteq[h_i] S i ⊆ [ h i ] represents a set of truth values, and S i : Y i S_i : Y_i S i : Y i is a signed literal. Without loss of generality, from now on we assume that every variable appears at most once in every clause, as any clause of form S 1 : Y i ∨ … ∨ S k : Y i ∨ φ S_1 : Y_i \lor\ldots\lor S_k : Y_i \lor\varphi S 1 : Y i ∨ … ∨ S k : Y i ∨ φ can always be rewritten as ( S 1 ∪ … ∪ S k ) : Y i ∨ φ (S_1 \cup\ldots\cup S_k) : Y_i \lor\varphi ( S 1 ∪ … ∪ S k ) : Y i ∨ φ . An assignment a a a satisfies the signed clause in Equation (1) iff for some i = 1 , … , m i = 1,\ldots,m i = 1 , … , m it assigns a value in S i S_i S i to Y i Y_i Y i . An assignment a a a satisfies a conjunction (or a set) of signed clauses if it satisfies all of them. Notice that this is purely a presentational choice: in our setting, signed clauses are in one-to-one correspondence with propositional logic formulas [8 ] . We adopt this representation only because it yields cleaner notation and simplifies the theoretical development in the remainder of the paper.
Example 1. Suppose we have an image classification task where we have to decide (i) if the shape shown in the image is a square, circle or triangle, (ii) if it is yellow, red or blue and (iii) if the shape is big (↑ \uparrow ↑ ) or small (↓ \downarrow ↓ ). Suppose also we know that shapes that are either big or yellow are always circles. In this problem, our structured output space will be:
Y = Y 1 × Y 2 × Y 3 Y 1 = { ■ , ■ , ■ } Y 2 = { ∘ , □ , △ } Y 3 = { ↓ , ↑ } \mathcal{Y} = \mathcal{Y}_1 \times\mathcal{Y}_2 \times\mathcal{Y}_3 \qquad\mathcal{Y}_1 = \{\blacksquare, \blacksquare, \blacksquare\} \qquad\mathcal{Y}_2 = \{\mathord{\circ}, \square, \triangle\} \qquad\mathcal{Y}_3 = \{\downarrow, \uparrow\} Y = Y 1 × Y 2 × Y 3 Y 1 = { ■ , ■ , ■ } Y 2 = { ∘ , □ , △ } Y 3 = { ↓ , ↑ } and our knowledge can be expressed using two signed clauses:
{ ∘ } : Y 2 ∨ { ↓ } : Y 3 { ∘ } : Y 2 ∨ { ■ , ■ } : Y 1 \{\mathord{\circ}\}:\mathcal{Y}_2 \lor\{\downarrow\}:\mathcal{Y}_3 \qquad\{\mathord{\circ}\}:\mathcal{Y}_2 \lor\{\blacksquare,\blacksquare\}:\mathcal{Y}_1 { ∘ } : Y 2 ∨ { ↓ } : Y 3 { ∘ } : Y 2 ∨ { ■ , ■ } : Y 1
We study models of the form m θ : X → ∏ i = 1 n Δ ( [ h i ] ) m_\theta: \mathcal{X} \to\prod_{i=1}^{n} \Delta([h_i]) m θ : X → ∏ i = 1 n Δ ([ h i ]) , where Δ ( [ h i ] ) \Delta([h_i]) Δ ([ h i ]) denotes the probability simplex over [ h i ] [h_i] [ h i ] . For any input x ∈ X x \in\mathcal{X} x ∈ X , we write m θ ( x ) = ( m θ 1 ( x ) , … , m θ n ( x ) ) m_\theta(x) = (m_\theta^1(x), \ldots, m_\theta^n(x)) m θ ( x ) = ( m θ 1 ( x ) , … , m θ n ( x )) , where m θ i ( x ) ∈ Δ ( [ h i ] ) m_\theta^i(x) \in\Delta([h_i]) m θ i ( x ) ∈ Δ ([ h i ]) is the predicted categorical distribution for the i i i -th output variable, and we say that a ∈ Y a \in\mathcal{Y} a ∈ Y is the assignment induced by the output m θ ( x ) m_\theta(x) m θ ( x ) if for every i = 1 , … , n i = 1,\ldots,n i = 1 , … , n , a i = argmax j ∈ [ h i ] m θ i ( x ) j a_i = \operatorname*{argmax}_{j \in[h_i]} m_\theta^i(x)_j a i = argmax j ∈ [ h i ] m θ i ( x ) j .2 We say that m θ m_\theta m θ is compliant with Π \Pi Π if, for every x ∈ X x \in\mathcal{X} x ∈ X , the assignment a ∈ Y a \in\mathcal{Y} a ∈ Y induced by m θ ( x ) m_\theta(x) m θ ( x ) satisfies Π \Pi Π .
Goal. Given any network m θ : X → ∏ i = 1 n Δ ( [ h i ] ) m_\theta: \mathcal{X} \to\prod_{i=1}^{n} \Delta([h_i]) m θ : X → ∏ i = 1 n Δ ([ h i ]) and constraints Π \Pi Π , our goal is to design a layer (i) that is guaranteed to be compliant with Π \Pi Π , (ii) that is scalable, and (iii) requires no problem-specific engineering beyond the constraint specification.
Casper
Since CASPER reduces any multi-variable problem to a sequence of single-variable ones via an offline compilation step, we present the single-variable case first and then the general case.
Single Variable Case
Let Y = [ h ] \mathcal{Y} = [h] Y = [ h ] and suppose that background knowledge trivially expresses that, for every input x x x , the assignment a ∈ [ h ] a \in[h] a ∈ [ h ] induced by the output m θ ( x ) m_\theta(x) m θ ( x ) must always belong to the subset S ⊆ [ h ] S \subseteq[h] S ⊆ [ h ] , i.e., Π = { S : Y } \Pi= \{S : \mathcal{Y}\} Π = { S : Y } .
Given a model m θ : X → Δ ( [ h ] ) m_\theta: \mathcal{X} \to\Delta([h]) m θ : X → Δ ([ h ]) and an input x x x , let y ^ = m θ ( x ) \hat{y} = m_\theta(x) y ^ = m θ ( x ) . To ensure that the final predictor m ~ θ = CASPER ∘ m θ \widetilde{m}_\theta= \operatorname{CASPER} \circ m_\theta m θ = CASPER ∘ m θ is compliant with Π \Pi Π , CASPER must map y ^ \hat{y} y ^ to the closest point in the simplex whose argmax lies in S S S . We measure closeness in squared Euclidean distance: as we show in the rest of this section, this choice yields a closed-form fixed-point characterization of the projection (Equation (4)), an exact decomposition of its surrogate error (Theorem 4), and a principled gradient analysis (Proposition 1). Concretely, we would like to solve:
argmin z ∈ Δ ( [ h ] ) ∥ z − y ^ ∥ 2 2 subject to argmax j ∈ [ h ] z j ∈ S . (2) \underset{z \in\Delta([h])}{\operatorname{argmin}}\ \lVert z-\hat{y}\rVert_2^2
\qquad\text{subject to}\qquad\operatorname*{argmax}_{j \in[h]} z_j \in S. \tag*{(2)} z ∈ Δ ([ h ]) argmin ∥ z − y ^ ∥ 2 2 subject to j ∈ [ h ] argmax z j ∈ S . (2)
If ∣ S ∣ = 1 |S| = 1 ∣ S ∣ = 1 , then the optimization problem is convex, while if ∣ S ∣ > 1 |S| > 1 ∣ S ∣ > 1 the feasible region can be decomposed in ∣ S ∣ |S| ∣ S ∣ convex regions, each corresponding to a candidate maximizer t ∈ S t \in S t ∈ S . To ensure the feasible set is closed and the projection is well-defined, we find a ϵ \epsilon ϵ -margin solution to the problem, which for every t ∈ S t \in S t ∈ S , ensures z t ≥ z j + ϵ , ∀ j ∈ [ h ] ∖ t z_t \geq z_j + \epsilon, \forall j \in[h] \setminus t z t ≥ z j + ϵ , ∀ j ∈ [ h ] ∖ t . The ϵ \epsilon ϵ -margin solution for each of the convex problems is characterized by the fixed-point system described in (4) .
Theorem 1 (Fixed point solution). Let y ^ ∈ Δ ( [ h ] ) \hat{y} \in\Delta([h]) y ^ ∈ Δ ([ h ]) and S ⊆ [ h ] S \subseteq[h] S ⊆ [ h ] , the ϵ \epsilon ϵ -margin solution to the optimization problem in (2) is equal to z t ∗ z^{t^*} z t ∗ with t ∗ t^* t ∗ equal to:
t ∗ = argmin t ∈ S ∥ z t − y ^ ∥ 2 2 , (3) t^* = \underset{t \in S}{\operatorname{argmin}}\ \lVert z^t-\hat{y}\rVert_2^2, \tag*{(3)} t ∗ = t ∈ S argmin ∥ z t − y ^ ∥ 2 2 , (3) where for every t ∈ S t \in S t ∈ S , z t z^t z t is the solution of the convex minimization problem obtained by fixing t t t as the unique maximizer and ϵ > 0 \epsilon> 0 ϵ > 0 as an arbitrarily small constant:
z j t = { y ^ j if j ∉ ( M t ∪ { t } ) z j t − ϵ if j ∈ M t y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ 1 + ∣ M t ∣ if j = t M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t t − ϵ } . (4) z_j^t =
\begin{cases}
\hat{y}_j & \text{if } j \notin(\mathcal{M}^t \cup\{t\}) \\
z_j^t-\epsilon& \text{if } j \in\mathcal{M}^t \\
\dfrac{\hat{y}_t+\sum_{j \in\mathcal{M}^t}\hat{y}_j+|\mathcal{M}^t|\epsilon}{1+|\mathcal{M}^t|} & \text{if } j=t
\end{cases}
\qquad
\mathcal{M}^t = \{j \in[h]\setminus\{t\} : \hat{y}_j \geq z_t^t-\epsilon\}. \tag*{(4)} z j t = ⎩ ⎨ ⎧ y ^ j z j t − ϵ 1 + ∣ M t ∣ y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ if j ∈ / ( M t ∪ { t }) if j ∈ M t if j = t M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t t − ϵ } . (4)
The proof can be found in Appendix B. The solution to the fixed-point system (4) can be computed in O ( h log h ) \mathcal{O}(h\log h) O ( h log h ) sequential operations and in O ( log 2 h ) \mathcal{O}(\log^{2}h) O ( log 2 h ) GPU operations via parallel reductions (see bottom of Appendix B). To maximise the scalability of our approach, we work with an over-approximation of M t \mathcal{M}^{t} M t that is available in closed form directly from y ^ \hat{\mathbf{y}} y ^ . We define
A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (5) \mathcal{A}^{t} = \{j \in[h] \setminus\{t\} : \hat{y}_{j} \ge\hat{y}_{t} - \epsilon\}, \tag*{(5)} A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (5)
which is computable in O ( h ) \mathcal{O}(h) O ( h ) time and requires a single thresholding operation on a GPU.
Lemma 1. For every t ∈ [ h ] t \in[h] t ∈ [ h ] and every y ^ ∈ Δ ( [ h ] ) \hat{\mathbf{y}} \in\Delta([h]) y ^ ∈ Δ ([ h ]) , M t ⊆ A t \mathcal{M}^{t} \subseteq\mathcal{A}^{t} M t ⊆ A t .
Proof can be found in Appendix C. Intuitively, this entails that by replacing M t \mathcal{M}^{t} M t with A t \mathcal{A}^{t} A t in Equation (4) we obtain a surrogate projection z ~ t \tilde{\mathbf{z}}^{t} z ~ t in which the t t t th element is guaranteed to be the maximum, but for which we might have over-corrected some other elements.
Theorem 2 (Constraint satisfaction). Let m θ : X → Δ ( [ h ] ) m_{\theta} : \mathcal{X} \to\Delta([h]) m θ : X → Δ ([ h ]) , x ∈ X \mathbf{x} \in\mathcal{X} x ∈ X and y ^ = m θ ( x ) \hat{\mathbf{y}} = m_{\theta}(\mathbf{x}) y ^ = m θ ( x ) . Let Π = { S : Y } \Pi= \{S : Y\} Π = { S : Y } for some ∅ ⊂ S ⊆ [ h ] \varnothing\subset S \subseteq[h] ∅ ⊂ S ⊆ [ h ] . If
CASPER ( y ^ ) = z ~ t ⋆ , t ⋆ = argmin t ∈ S ∥ z ~ t − y ^ ∥ 2 2 , (6) \operatorname{CASPER}(\hat{\mathbf{y}}) = \tilde{\mathbf{z}}^{t^\star}, \qquad t^\star= \underset{t \in S}{\operatorname{argmin}}\ \lVert\tilde{\mathbf{z}}^{t} - \hat{\mathbf{y}}\rVert_{2}^{2}, \tag*{(6)} CASPER ( y ^ ) = z ~ t ⋆ , t ⋆ = t ∈ S argmin ∥ z ~ t − y ^ ∥ 2 2 , (6) where for every t ∈ S t \in S t ∈ S
z ~ j t = { y ^ j if j ∉ ( A t ∪ { t } ) z ~ t t − ϵ if j ∈ A t y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ 1 + ∣ A t ∣ if j = t A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (7) \tilde{z}_{j}^{t} =
\begin{cases}
\hat{y}_{j} & \text{if } j \notin(\mathcal{A}^{t} \cup\{t\}) \\
\tilde{z}_{t}^{t} - \epsilon& \text{if } j \in\mathcal{A}^{t} \\
\dfrac{\hat{y}_{t}+\sum_{j\in\mathcal{A}^{t}}\hat{y}_{j}+|\mathcal{A}^{t}|\epsilon}{1+|\mathcal{A}^{t}|} & \text{if } j=t
\end{cases}
\qquad
\mathcal{A}^{t} = \{j \in[h] \setminus\{t\} : \hat{y}_{j} \ge\hat{y}_{t} - \epsilon\}, \tag*{(7)} z ~ j t = ⎩ ⎨ ⎧ y ^ j z ~ t t − ϵ 1 + ∣ A t ∣ y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ if j ∈ / ( A t ∪ { t }) if j ∈ A t if j = t A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (7) then for ϵ → 0 + \epsilon\to0^{+} ϵ → 0 + , the assignment a a a induced by CASPER ( y ^ ) \operatorname{CASPER}(\hat{\mathbf{y}}) CASPER ( y ^ ) satisfies Π \Pi Π , i.e., a ⊨ Π a \models\Pi a ⊨ Π .
Proof can be found in Appendix D. Thus, for every t ∈ S t \in S t ∈ S , CASPER uses the surrogate projection z ~ t \tilde{\mathbf{z}}^{t} z ~ t instead of the exact fixed-point solution z t \mathbf{z}^{t} z t . The surrogate avoids the sorting step required by the exact solution, reducing the number of sequential GPU operations per candidate from O ( log 2 h ) \mathcal{O}(\log^{2} h) O ( log 2 h ) to O ( log h ) \mathcal{O}(\log h) O ( log h ) . Since candidates are processed in parallel, the full single-variable inference step retains O ( log h ) \mathcal{O}(\log h) O ( log h ) sequential operations. However, replacing z t \mathbf{z}^{t} z t with z ~ t \tilde{\mathbf{z}}^{t} z ~ t does not change which candidate is selected.
Theorem 3 (Candidate selection). Let y ^ ∈ Δ ( [ h ] ) \hat{\mathbf{y}} \in\Delta([h]) y ^ ∈ Δ ([ h ]) and ∅ ⊂ S ⊆ [ h ] \varnothing\subset S \subseteq[h] ∅ ⊂ S ⊆ [ h ] , and let z t \mathbf{z}^{t} z t and z ~ t \tilde{\mathbf{z}}^{t} z ~ t be defined as in Equations (4) and (7) . Then, for ϵ → 0 + \epsilon\to0^{+} ϵ → 0 +
argmin t ∈ S ∥ z t − y ^ ∥ 2 2 = argmin t ∈ S ∥ z ~ t − y ^ ∥ 2 2 = argmax t ∈ S y ^ t . \underset{t\in S}{\operatorname{argmin}}\ \lVert\mathbf{z}^{t} - \hat{\mathbf{y}}\rVert_{2}^{2}
=
\underset{t\in S}{\operatorname{argmin}}\ \lVert\tilde{\mathbf{z}}^{t} - \hat{\mathbf{y}}\rVert_{2}^{2}
=
\underset{t\in S}{\operatorname{argmax}}\ \hat{y}_{t}. t ∈ S argmin ∥ z t − y ^ ∥ 2 2 = t ∈ S argmin ∥ z ~ t − y ^ ∥ 2 2 = t ∈ S argmax y ^ t .
Proof can be found in Appendix E. Hence the surrogate affects only the continuous output of CASPER, not the value it selects; we now characterise the resulting continuous error exactly.
Example 2. (Cont.’ed Ex. 1) Consider the simplified case where Π = { 🟨 } : Y \Pi= \{\ 🟨\ \} : Y Π = { 🟨 } : Y (i.e., we know that the shape is always yellow), and suppose that the network outputs:
m θ ( x ) = ( 🟨 : 0.3 , 🟥 : 0.5 , 🟦 : 0.2 ) , argmax ( m θ ( x ) ) = 🟥 m_{\theta}(\mathbf{x}) = (\ 🟨\ : 0.3,\ 🟥\ : 0.5,\ 🟦\ : 0.2), \qquad\operatorname{argmax}(m_{\theta}(\mathbf{x})) = 🟥 m θ ( x ) = ( 🟨 : 0.3 , 🟥 : 0.5 , 🟦 : 0.2 ) , argmax ( m θ ( x )) = 🟥 Let t = 🟨 t = 🟨 t = 🟨 and (for simplicity) ϵ = 0.01 \epsilon= 0.01 ϵ = 0.01 , then:
A 🟨 = { j ∈ { 🟥 , 🟦 } : y ^ 🟨 < y ^ j + ϵ } = { 🟥 } \mathcal{A}^{🟨} = \{j \in\{🟥, 🟦\} : \hat{y}_{🟨} < \hat{y}_{j} + \epsilon\} = \{🟥\} A 🟨 = { j ∈ { 🟥 , 🟦 } : y ^ 🟨 < y ^ j + ϵ } = { 🟥 } CASPER ( y ^ ) = ( 🟨 : y ^ 🟨 + y ^ 🟥 + ϵ 2 , 🟥 : z ~ 🟨 🟨 − ϵ , 🟦 : y ^ 🟦 ) = ( 🟨 : 0.405 , 🟥 : 0.395 , 🟦 : 0.2 ) \operatorname{CASPER}(\hat{\mathbf{y}}) =
\left(
🟨 : \frac{\hat{y}_{🟨}+\hat{y}_{🟥}+\epsilon}{2},
🟥 : \tilde{z}_{🟨}^{🟨}-\epsilon,
🟦 : \hat{y}_{🟦}
\right)
=
(🟨 : 0.405,\ 🟥 : 0.395,\ 🟦 : 0.2) CASPER ( y ^ ) = ( 🟨 : 2 y ^ 🟨 + y ^ 🟥 + ϵ , 🟥 : z ~ 🟨 🟨 − ϵ , 🟦 : y ^ 🟦 ) = ( 🟨 : 0.405 , 🟥 : 0.395 , 🟦 : 0.2 )
We now give an exact characterization of the distance between z ~ t \tilde{\mathbf{z}}^{t} z ~ t and z t \mathbf{z}^{t} z t . The error decomposes into contributions from each spuriously included index, weighted by its sub-threshold gap g j = z t t − ϵ − y ^ j g_{j} = z_{t}^{t} - \epsilon- \hat{y}_{j} g j = z t t − ϵ − y ^ j .
Theorem 4 (Surrogate fidelity). Let z t \mathbf{z}^{t} z t be the solution of the fixed point system (4) , z ~ t \tilde{\mathbf{z}}^{t} z ~ t defined as in Equation (6) , and W t = A t ∖ M t \mathcal{W}^{t} = \mathcal{A}^{t} \setminus\mathcal{M}^{t} W t = A t ∖ M t . For each j ∈ W t j \in\mathcal{W}^{t} j ∈ W t , let g j = z ~ t t − ϵ − y ^ j g_{j} = \tilde{z}_{t}^{t} - \epsilon- \hat{y}_{j} g j = z ~ t t − ϵ − y ^ j . Then
∥ z ~ t − z t ∥ 2 2 = ∑ j ∈ W t g j 2 − 1 1 + ∣ A t ∣ ( ∑ j ∈ W t g j ) 2 . (8) \lVert\tilde{\mathbf{z}}^{t} - \mathbf{z}^{t}\rVert_{2}^{2}
=
\sum_{j\in\mathcal{W}^{t}} g_{j}^{2}
-
\frac{1}{1+|\mathcal{A}^{t}|}
\left(\sum_{j\in\mathcal{W}^{t}} g_{j}\right)^{2}. \tag*{(8)} ∥ z ~ t − z t ∥ 2 2 = j ∈ W t ∑ g j 2 − 1 + ∣ A t ∣ 1 j ∈ W t ∑ g j 2 . (8)
The proof can be found in Appendix F. The exact identity in Equation (8) can be bounded by an ℓ 2 \ell_2 ℓ 2 regularizer on the distance between y ^ \hat{y} y ^ and z t z^t z t .
Corollary 1. Under the hypotheses of Theorem 4, ∥ z ~ t − z t ∥ 2 ≤ ∥ z ~ t − y ^ ∥ 2 \lVert\tilde{z}^t-z^t\rVert_2 \leq\lVert\tilde{z}^t-\hat{y}\rVert_2 ∥ z ~ t − z t ∥ 2 ≤ ∥ z ~ t − y ^ ∥ 2 .
Corollary 1 motivates adding an ℓ 2 \ell_2 ℓ 2 regularizer ∥ z ~ t − y ^ ∥ 2 2 \lVert\tilde{z}^t-\hat{y}\rVert_2^2 ∥ z ~ t − y ^ ∥ 2 2 to the training objective: driving this quantity to zero drives z ~ t → z t \tilde{z}^t \to z^t z ~ t → z t . Beyond controlling the surrogate fidelity, the ℓ 2 \ell_2 ℓ 2 regularizer serves a complementary role during training: it counteracts the rank deficiency of the layer’s Jacobian. This rank deficiency might cause problems during training as it results in a structurally identifiable subspace of upstream gradients being mapped to zero during back-propagation.
Proposition 1 (Gradient attenuation). Let y ^ ∈ Δ ( [ h ] ) \hat{y} \in\Delta([h]) y ^ ∈ Δ ([ h ]) be such that t ⋆ t^\star t ⋆ and A t ⋆ A^{t^\star} A t ⋆ in (6) are locally constant at y ^ \hat{y} y ^ . Let CASPER ( y ^ ) = z ~ t ⋆ \operatorname{CASPER}(\hat{y})=\tilde{z}^{t^\star} CASPER ( y ^ ) = z ~ t ⋆ and V = { v ∈ R h : v j = v t ⋆ , j ∈ A t ⋆ } V=\{v\in\mathbb{R}^{h}:v_j=v_{t^\star},j\in A^{t^\star}\} V = { v ∈ R h : v j = v t ⋆ , j ∈ A t ⋆ } . Then the Jacobian J = ∂ z ~ t ⋆ / ∂ y ^ J=\partial\tilde{z}^{t^\star}/\partial\hat{y} J = ∂ z ~ t ⋆ / ∂ y ^ equals the orthogonal projector P V P_V P V . Hence, for any differentiable loss L t a s k \mathcal{L}_{\mathrm{task}} L task ,
∇ y ^ [ L t a s k ∘ z ~ t ⋆ ] = P V ∇ z ~ t ⋆ L t a s k ; \nabla_{\hat{y}}\left[\mathcal{L}_{\mathrm{task}}\circ\tilde{z}^{t^\star}\right]=P_V\nabla_{\tilde{z}^{t^\star}}\mathcal{L}_{\mathrm{task}}; ∇ y ^ [ L task ∘ z ~ t ⋆ ] = P V ∇ z ~ t ⋆ L task ; the back-propagated gradient is the orthogonal projection onto V V V of ∇ z ~ t ⋆ L t a s k \nabla_{\tilde{z}^{t^\star}}\mathcal{L}_{\mathrm{task}} ∇ z ~ t ⋆ L task , with the ∣ A t ⋆ ∣ \lvert A^{t^\star}\rvert ∣ A t ⋆ ∣ -dimensional subspace V ⊥ V^\perp V ⊥ mapped to zero by J J J .
The proof can be found in Appendix I. The ℓ 2 \ell_2 ℓ 2 regularizer solves this problem by restoring the gradients along the dimensions that are mapped to zero.
Proposition 2 (Gradient restoration). Under the assumptions of Proposition 1, consider the composite training objective
L t o t a l ( y ^ ) = L t a s k ( z ~ t ( y ^ ) ) + λ 2 ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 , λ > 0. \mathcal{L}_{\mathrm{total}}(\hat{y})=\mathcal{L}_{\mathrm{task}}(\tilde{z}^t(\hat{y}))+\frac{\lambda}{2}\lVert\tilde{z}^t(\hat{y})-\hat{y}\rVert_2^2,\qquad\lambda>0. L total ( y ^ ) = L task ( z ~ t ( y ^ )) + 2 λ ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 , λ > 0. Then
∇ y ^ L t o t a l = P V ∇ z ~ L t a s k ⏟ ∈ V + λ ( y ^ − z ~ t ) ⏟ ∈ V ⊥ . \nabla_{\hat{y}}\mathcal{L}_{\mathrm{total}}= \underbrace{P_V\nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}}}_{\in V}+\lambda\underbrace{(\hat{y}-\tilde{z}^t)}_{\in V^\perp}. ∇ y ^ L total = ∈ V P V ∇ z ~ L task + λ ∈ V ⊥ ( y ^ − z ~ t ) .
The proof can be found in Appendix J. Propositions 1 and 2 together explain why the ℓ 2 \ell_2 ℓ 2 regularizer plays a double role in our framework: it both tightens the approximation bound (Corollary 1) and stabilizes optimization by restoring the gradient along the dimensions originally mapped to zero.
General Case
Extending CASPER to multiple variables requires reasoning about how the assignment of one variable restricts the feasible values of the others. We process variables in a user-specified order Y 1 , … , Y n Y_1,\ldots,Y_n Y 1 , … , Y n and, at each step, derive the set of values for Y i Y_i Y i consistent with the constraints under the assignments already fixed for Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 . The key technical tool is an inference rule over signed clauses, analogous to propositional resolution, that combines two clauses sharing a literal on the same variable into a single entailed clause. Iterating this rule lets us compile Π \Pi Π into a per-variable form that exposes exactly the constraints needed at each step of inference, and reduces multi-variable satisfaction to a sequence of single-variable projections of the kind solved in Section 3.1.
We make use of the signed resolution rule , a standard inference rule from the multiple-valued logic literature [26 , 9 ] . Given two signed clauses both containing a term on variable Y i Y_i Y i : ( S : Y i ) ∨ φ (S:Y_i)\lor\varphi ( S : Y i ) ∨ φ and ( S ′ : Y i ) ∨ φ ′ (S':Y_i)\lor\varphi' ( S ′ : Y i ) ∨ φ ′ , where φ \varphi φ and φ ′ \varphi' φ ′ denote signed clauses over variables other than Y i Y_i Y i , the rule derives a new clause entailed by the premises:
( S : Y i ) ∨ φ ( S ′ : Y i ) ∨ φ ′ ( S ∩ S ′ : Y i ) ∨ φ ∨ φ ′ (9) \frac{(S:Y_i)\lor\varphi\qquad(S':Y_i)\lor\varphi'}{(S\cap S':Y_i)\lor\varphi\lor\varphi'} \tag*{(9)} ( S ∩ S ′ : Y i ) ∨ φ ∨ φ ′ ( S : Y i ) ∨ φ ( S ′ : Y i ) ∨ φ ′ (9)
Soundness of the rule is a classical result [26 ] . Given an user-defined ordering over the variables Y 1 , Y 2 , … , Y n Y_1,Y_2,\ldots,Y_n Y 1 , Y 2 , … , Y n , we can use the intersection rule to compute the set of constraints necessary to determine the feasible assignment for each variable Y i Y_i Y i knowing the initial assignment given by the model θ \theta θ and the final assignments for the variables Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 . The final set of constraints will then be used to build CASPER. We describe the offline compilation below, and we provide the pseudocode for both the compilation and the inference steps in Algorithm 1.
Starting from the end of the ordering:
For every i = n , … , 1 i = n, \ldots, 1 i = n , … , 1 , let Π ˉ i = { ( S j : Y i ) ∨ φ j } j = 1 m ⊆ Π i \bar{\Pi}_i = \{(S_j : Y_i) \lor\varphi_j\}_{j=1}^m \subseteq\Pi_i Π ˉ i = {( S j : Y i ) ∨ φ j } j = 1 m ⊆ Π i be the subset of clauses of Π i \Pi_i Π i where Y i Y_i Y i appears, which allows us to iteratively compute the set Π i − 1 \Pi_{i-1} Π i − 1 as:
Π i − 1 = ( Π i ∖ Π ˉ i ) ∪ Confl i ( Π ˉ i ) , (10) \Pi_{i-1} = (\Pi_i \setminus\bar{\Pi}_i) \cup\operatorname{Confl}_i(\bar{\Pi}_i), \tag*{(10)} Π i − 1 = ( Π i ∖ Π ˉ i ) ∪ Confl i ( Π ˉ i ) , (10)
in which Confl i ( Π ˉ i ) \operatorname{Confl}_i(\bar{\Pi}_i) Confl i ( Π ˉ i ) is the conflict clauses set of Π ˉ i \bar{\Pi}_i Π ˉ i :
Confl i ( Π ˉ i ) = { ⋁ j ∈ J φ j ∣ ⋂ j ∈ J S j = ∅ , ∅ ⊂ J ⊆ [ m ] } . (11) \operatorname{Confl}_i(\bar{\Pi}_i) = \left\{ \bigvee_{j \in\mathcal{J}} \varphi_j \mathrel{\bigg|} \bigcap_{j \in\mathcal{J}} S_j = \varnothing, \varnothing\subset\mathcal{J} \subseteq[m] \right\}. \tag*{(11)} Confl i ( Π ˉ i ) = ⎩ ⎨ ⎧ j ∈ J ⋁ φ j j ∈ J ⋂ S j = ∅ , ∅ ⊂ J ⊆ [ m ] ⎭ ⎬ ⎫ . (11)
The conflict clauses set represents the set of clauses that need to be added to the layer below the i i i th to avoid ending up in an inconsistent state, i.e., avoiding having ( ∅ : Y i ) ∈ Π i (\varnothing: Y_i) \in\Pi_i ( ∅ : Y i ) ∈ Π i . The conflict clauses set can equivalently be characterized as the closure of Π ˉ i \bar{\Pi}_i Π ˉ i under the intersection rule restricted to unsatisfiable combinations of signed terms.
Lemma 2 (Equisatisfiability). Let Π i \Pi_i Π i be a finite and satisfiable set of signed clauses in the variables Y 1 , … , Y i Y_1, \ldots, Y_i Y 1 , … , Y i . Then Π i \Pi_i Π i and Π i − 1 \Pi_{i-1} Π i − 1 are equisatisfiable, and each assignment to Y 1 , … , Y i − 1 Y_1, \ldots, Y_{i-1} Y 1 , … , Y i − 1 satisfying Π i − 1 \Pi_{i-1} Π i − 1 can be extended to satisfy Π i \Pi_i Π i .
The proof is given in Appendix K. We now show that the complexity of the Cᴏᴍᴘɪʟᴇ routine is governed by how many variables a conflict clauses set involves. For a signed clause φ \varphi φ , let scope ( φ ) = { Y ∣ ∃ ℓ = ( S j : Y j ) ∈ φ . Y = Y j } \operatorname{scope}(\varphi) = \{Y \mid\exists\ell= (S_j : Y_j) \in\varphi. \ Y = Y_j\} scope ( φ ) = { Y ∣ ∃ ℓ = ( S j : Y j ) ∈ φ . Y = Y j } , i.e., the scope of φ \varphi φ is the set of variables occurring in some of its literals. We define the interaction graph of a set of signed clauses Π \Pi Π as the undirected graph G Π = ( Y , E Π ) G_\Pi= (\mathcal{Y}, E_\Pi) G Π = ( Y , E Π ) , where E Π = { ( Y j , Y z ) ∣ ∃ φ ∈ Π . { Y j , Y z } ⊆ scope ( φ ) , j ≠ z } E_\Pi= \{(Y_j, Y_z) \mid\exists\varphi\in\Pi. \{Y_j, Y_z\} \subseteq\operatorname{scope}(\varphi), j \ne z\} E Π = {( Y j , Y z ) ∣ ∃ φ ∈ Π. { Y j , Y z } ⊆ scope ( φ ) , j = z } . Intuitively, the interaction graph of Π \Pi Π has an edge between each pair of variables co-occurring in a clause in Π \Pi Π . Given an ordering d = Y 1 ; … ; Y n d = Y_1; \ldots; Y_n d = Y 1 ; … ; Y n , the induced interaction graph G Π ∗ ( d ) G_\Pi^*(d) G Π ∗ ( d ) of Π \Pi Π along d d d connects all the neighbours of a variable Y i Y_i Y i that precede it in d d d , recursively from Y n Y_n Y n to Y 1 Y_1 Y 1 (cf. [14 Def. 3.7] ). Formally, G Π ∗ ( d ) = ( Y , E 0 ) G_\Pi^*(d) = (\mathcal{Y}, E_0) G Π ∗ ( d ) = ( Y , E 0 ) , where E n = E Π E_n = E_\Pi E n = E Π and for i = n , … , 1 i = n, \ldots, 1 i = n , … , 1 we have:
E i − 1 = E i ∪ { ( Y j , Y z ) ∣ { ( Y j , Y i ) , ( Y i , Y z ) } ⊆ E i , j ≠ z , and j , z < i } . (12) E_{i-1} = E_i \cup\{(Y_j, Y_z) \mid\{(Y_j, Y_i), (Y_i, Y_z)\} \subseteq E_i, j \ne z, \text{ and } j, z < i\}. \tag*{(12)} E i − 1 = E i ∪ {( Y j , Y z ) ∣ {( Y j , Y i ) , ( Y i , Y z )} ⊆ E i , j = z , and j , z < i } . (12)
Our bound is controlled by the maximum number of variables preceding some Y i Y_i Y i in d d d that are adjacent to it in G Π ∗ ( d ) G_\Pi^*(d) G Π ∗ ( d ) . We call this number the conflict width . For i ∈ [ n ] i \in[n] i ∈ [ n ] , the set N d ( Y i ) = { Y j ∣ j < i , ( Y j , Y i ) ∈ E 0 } N_d(Y_i) = \{Y_j \mid j < i, (Y_j, Y_i) \in E_0\} N d ( Y i ) = { Y j ∣ j < i , ( Y j , Y i ) ∈ E 0 } denotes the neighbours of Y i Y_i Y i in G Π ∗ ( d ) G_\Pi^*(d) G Π ∗ ( d ) that precede it in d d d ; the conflict width of Π \Pi Π along d d d is w ∗ ( d ) = max i ∈ [ n ] ∣ N d ( Y i ) ∣ w^*(d) = \max_{i \in[n]} |N_d(Y_i)| w ∗ ( d ) = max i ∈ [ n ] ∣ N d ( Y i ) ∣ .
Theorem 5 (Computational Complexity of Cᴏᴍᴘɪʟᴇ). Let Π \Pi Π be a finite set of r r r signed clauses over the variables Y 1 ; … ; Y n Y_1; \ldots; Y_n Y 1 ; … ; Y n , k = max i ∈ [ n ] h i k = \max_{i \in[n]} h_i k = max i ∈ [ n ] h i and w ∗ ( d ) w^*(d) w ∗ ( d ) the conflict width of Π \Pi Π along the ordering d = Y 1 ; … ; Y n d = Y_1; \ldots; Y_n d = Y 1 ; … ; Y n . Cᴏᴍᴘɪʟᴇ( Π , Y 1 ; … ; Y n ) (\Pi, Y_1; \ldots; Y_n) ( Π , Y 1 ; … ; Y n ) in Algorithm 1 can be implemented to run in
time O ( ( r + n ) ⋅ k w ∗ ( d ) + 1 ) and space O ( n ⋅ k w ∗ ( d ) ) . \text{time } O((r+n) \cdot k^{w^*(d)+1}) \qquad\text{and} \qquad\text{space } O(n \cdot k^{w^*(d)}). time O (( r + n ) ⋅ k w ∗ ( d ) + 1 ) and space O ( n ⋅ k w ∗ ( d ) ) .
Proof in Appendix L. Theorem 5 shows that the cost of compilation grows exponentially with the conflict width w ∗ ( d ) w^*(d) w ∗ ( d ) : this is the same worst-case as adaptive consistency and directional resolution [13 ] .
Once the clause sets Π 1 , … , Π n \Pi_1, \ldots, \Pi_n Π 1 , … , Π n have been computed, Cᴀsᴘᴇʀ is evaluated sequentially according to the variable ordering Y 1 , … , Y n Y_1, \ldots, Y_n Y 1 , … , Y n as described below and in the inference step of Algorithm 1 . Let y ^ = m θ ( x ) \hat{y} = m_\theta(x) y ^ = m θ ( x ) . We process the variables in the order Y 1 ; … ; Y n Y_1; \ldots; Y_n Y 1 ; … ; Y n . At step i i i , the assignments a < i = [ a 1 , … , a i − 1 ] a_{<i} = [a_1, \ldots, a_{i-1}] a < i = [ a 1 , … , a i − 1 ] for the preceding variables have already been fixed based on the output by steps 1 , … , i − 1 1, \ldots, i-1 1 , … , i − 1 . These assignments induce a feasible set S i ( a < i ) ⊆ [ h i ] \mathcal{S}_i(a_{<i}) \subseteq[h_i] S i ( a < i ) ⊆ [ h i ] consisting of all values of Y i Y_i Y i consistent with the clauses in Π i \Pi_i Π i under a < i a_{<i} a < i . By construction of the compilation procedure, every clause in Π 1 \Pi_1 Π 1 mentions only Y 1 Y_1 Y 1 , and it can always be reduced to Π 1 = { S 1 : Y 1 } \Pi_1 = \{S_1 : Y_1\} Π 1 = { S 1 : Y 1 } for some S 1 ⊆ [ h 1 ] S_1 \subseteq[h_1] S 1 ⊆ [ h 1 ] . Hence for i = 1 i = 1 i = 1 , S 1 ( a < 1 ) = S 1 \mathcal{S}_1(a_{<1}) = S_1 S 1 ( a < 1 ) = S 1 . Substituting a < i a_{<i} a < i into Π ˉ i \bar{\Pi}_i Π ˉ i yields a set of constraints on Y i Y_i Y i equivalent to the single signed clause ( S i ( a < i ) : Y i ) (\mathcal{S}_i(a_{<i}) : Y_i) ( S i ( a < i ) : Y i ) . If arg max y ^ i ∈ S i ( a < i ) \arg\max\hat{y}_i \in\mathcal{S}_i(a_{<i}) arg max y ^ i ∈ S i ( a < i ) , the prediction already satisfies the constraints and no correction is needed: a i = arg max y ^ i a_i = \arg\max\hat{y}_i a i = arg max y ^ i and z i t ∗ = y ^ i z_i^{t*} = \hat{y}_i z i t ∗ = y ^ i . Otherwise, we compute the refined prediction z i t ∗ z_i^{t*} z i t ∗ for Y i Y_i Y i using the closed-form update of (6) with input y ^ i \hat{y}_i y ^ i and constraints { S i ( a < i ) : Y i } \{\mathcal{S}_i(a_{<i}) : Y_i\} { S i ( a < i ) : Y i } , and set a i = arg max z i t ∗ a_i = \arg\max z_i^{t*} a i = arg max z i t ∗ . Iterating for i = 1 , … , n i = 1, \ldots, n i = 1 , … , n yields the final refined output Cᴀsᴘᴇʀ( y ^ ) = ( z 1 t ∗ , … , z n t ∗ ) (\hat{y}) = (z_1^{t*}, \ldots, z_n^{t*}) ( y ^ ) = ( z 1 t ∗ , … , z n t ∗ ) . Notice that, at step i i i , computing S i ( a < i ) \mathcal{S}_i(a_{<i}) S i ( a < i ) from the precomputed Π ˉ i \bar{\Pi}_i Π ˉ i runs in O ( log ∣ Π ˉ i ∣ ) O(\log|\bar{\Pi}_i|) O ( log ∣ Π ˉ i ∣ ) sequential GPU operations. Hence, each step requires O ( log ( ∣ Π ˉ i ∣ ⋅ h i ) ) O(\log(|\bar{\Pi}_i| \cdot h_i)) O ( log ( ∣ Π ˉ i ∣ ⋅ h i )) sequential GPU operations. The output of Cᴀsᴘᴇʀ satisfies Π \Pi Π as proven in Appendix M.
Algorithm 1 Compilation & Inference Step with CASPER
1: function COMPILE($\Pi$, $Y_1; \ldots ; Y_n$)
2: $\Pi_n \leftarrow \Pi$
3: for $i \leftarrow n$ down to 1 do
4: Compute $\bar{\Pi}_i$, $\operatorname{Conf}_i(\bar{\Pi}_i)$
5: $\Pi_{i-1} \leftarrow (\Pi_i \setminus \bar{\Pi}_i) \cup \operatorname{Conf}_i(\bar{\Pi}_i)$
6: end for
7: if $\Pi_0$ is unsatisfiable then
8: return UNSAT_FLAG
9: else
10: return $\bar{\Pi}_1, \ldots, \bar{\Pi}_n$
11: end if
12: end function
1: function INFER($\hat{\mathbf{y}}, \bar{\Pi}_1, \ldots, \bar{\Pi}_n$)
2: for $i \leftarrow 1$ to $n$ do
3: Compute $S_i(\mathbf{a}_{<i}) \subseteq [h_i]$ from $\bar{\Pi}_i$ under $\mathbf{a}_{<i}$
4: if $\operatorname{argmax} \hat{y}_i \in S_i(\mathbf{a}_{<i})$ then
5: $\tilde{z}_i^{\star} \leftarrow \hat{y}_i$
6: else
7: Compute $\tilde{\mathbf{z}}_i^{\star}$ using Eq. (6) with input $\hat{\mathbf{y}}_i$ and constraint $\{S_i(\mathbf{a}_{<i}) : Y_i\}$
8: end if
9: Compute $a_i = \operatorname{argmax} \tilde{z}_i^{\star}$
10: end for
11: return CASPER($\hat{\mathbf{y}}$) = $(\tilde{\mathbf{z}}_1^{\star}, \ldots, \tilde{\mathbf{z}}_n^{\star})$
12: end function
Theorem 6 (Correctness). Let Π \Pi Π be a finite and satisfiable set of signed clauses. For any datapoint x \mathbf{x} x , model m θ m_\theta m θ and variable ordering, the corresponding output CASPER(m θ ( x ) m_\theta(\mathbf{x}) m θ ( x ) ) satisfies Π \Pi Π for ϵ → 0 + \epsilon\to0^+ ϵ → 0 + .
Notice that the feasible set S i ( a < i ) S_i(\mathbf{a}_{<i}) S i ( a < i ) depends only on the preceding discrete assignments, rather than on the continuous values produced by the preceding projections. Hence, since the surrogate and exact fixed-point projections select the same candidate at every step (Theorem 3), an early continuous over-correction by the surrogate cannot restrict the feasible sets available to later variables:
Corollary 2 (Sequential assignment equivalence). Consider a finite and satisfiable set of signed clauses Π \Pi Π and a variable ordering Y 1 ; … ; Y n Y_1; \ldots; Y_n Y 1 ; … ; Y n . Given y ^ = m θ ( x ) \hat{\mathbf{y}} = m_\theta(\mathbf{x}) y ^ = m θ ( x ) for some x ∈ X \mathbf{x} \in\mathcal{X} x ∈ X , let a ~ \tilde{\mathbf{a}} a ~ be the assignment induced by CASPER(y ^ \hat{\mathbf{y}} y ^ ), a \mathbf{a} a be the assignment induced by the same procedure when each surrogate projection is replaced by the exact fixed-point projection, and let a ⋆ \mathbf{a}^{\star} a ⋆ be the sequential feasible argmax assignment, a i ⋆ = argmax t ∈ S i ( a < i ⋆ ) y ^ i , t a_i^{\star} = \operatorname{argmax}_{t \in S_i(\mathbf{a}_{<i}^{\star})} \hat{y}_{i,t} a i ⋆ = argmax t ∈ S i ( a < i ⋆ ) y ^ i , t . Then, for ϵ → 0 + \epsilon\to0^+ ϵ → 0 + :
(i) a = a ~ = a ⋆ ; and (ii) S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) , ∀ i ∈ [ n ] . \text{(i) }\mathbf{a} = \tilde{\mathbf{a}} = \mathbf{a}^{\star}; \qquad\text{and} \qquad\text{(ii) }S_i(\mathbf{a}_{<i}) = S_i(\tilde{\mathbf{a}}_{<i}) = S_i(\mathbf{a}_{<i}^{\star}),\ \forall i \in[n]. (i) a = a ~ = a ⋆ ; and (ii) S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) , ∀ i ∈ [ n ] .
Proof in Appendix H. Longer sequences therefore only accumulate local continuous discrepancies, characterised at each step by Theorem 4 , which do not compound through the feasible sets.
Experimental Analysis
We conduct our analysis over three tasks: the warcraft pathfinding task [41 ] , 11 variations of the standard MNIST Arithmetic task [36 ] considering different number of digits to sum and different ways of summing them, and sudoku solving [50 ] . For each task we apply a timeout (indicated as T/O) of 5s per training-example (consistent with [10 ] ). The experiments for warcraft and MNIST were run on a workstation equipped with 3 NVIDIA RTX 4500 each with 26GB VRAM, while the sudoku solving task was run on a workstation equipped with 1 NVIDIA H200.
Warcraft Pathfinding
The goal is predicting the minimum-cost path from the top-left to the bottom-right corner of an N × N N \times N N × N grid, given an image rendered from Warcraft II terrain tiles where each tile has an associated traversal cost. We consider grid-sizes N ∈ { 12 , 30 } N \in\{12, 30\} N ∈ { 12 , 30 } where a path is classed as valid if it is connected, contained within the grid, and terminates at the goal. To exemplify the task, we show on qualitative example in Figure 1 . In Table 2 , we report the percentage of test instances for which each method predicts an optimal path, i.e., a path with minimum cost, and a consistent path, i.e., a path satisfying the task constraints. These are denoted by Optimal(%) and Consistent(%), respectively. To complement these metrics, we also report a cumulative cost-optimality analysis: for each tolerance factor α ≥ 1 \alpha\ge1 α ≥ 1 , we measure the fraction of predictions whose cost is
Figure 1. Qualitative example for Warcraft Pathfinding. GT stands for ground truth.
Table 2. Warcraft Pathfinding Task.
within a factor α \alpha α of the optimal path cost in Figure 3 (Appendix § 21 .§ 1 ). This provides a finer-grained view of how close non-optimal predictions are to the optimum. We compare CASPER against both exact (SPL [3 ] , DPL [36 ] , CCN+ [25 ] ) and approximate baselines (DSL [35 ] , Scallop [30 ] , CTSketch [10 ] ). We evaluate different variants of CTSketch and report the best-performing configuration; the full ablation is given in Appendix § 21 .§ 1 . We do not include Dijkstra-based methods such as A-NeSI [48 ] and I-MLE [39 ] , which predict per-tile costs and recover the path with a shortest-path solver. These are complementary approaches that address a different formulation of the task: the solver performs the combinatorial optimization, while the network learns only the tile costs. In our setting, as in SPL [3 ] , the network instead directly predicts the structured output, with no shortest-path solver, and constraints are enforced on this prediction. All models use the standard ResNet-18 [27 ] backbone. CASPER and all baselines except CTSketch work with the step-wise formulation of the path constraint (Appendix § 22 ), which constrains a time-unrolled walk over grid cells and not the path itself. Its feasible set contains every simple path but also walks that revisit a cell, thus for all methods all metrics are computed on the loop-erased path (Appendix § 21 .§ 1 ).
Figure 3. Cumulative path cost-optimality for Warcraft Pathfinding
We further conduct an ablation study by testing the application of CASPER only at inference time (Inference Only), by training CASPER without the ℓ 2 \ell_2 ℓ 2 regularizer (w/o ℓ 2 \ell_2 ℓ 2 ), and by training with CASPER and then removing it at inference time (Train Only). Table 2 shows three findings. First, CASPER is the only method that produces 100% valid paths on both grid sizes. Among exact methods, only CASPER runs to completion on 30 × 30 30 \times30 30 × 30 ; SPL, DPL, and CCN+ all time out, while CTSketch’s optimal-path rate (5.1%) does not exceed the unconstrained ResNet-18 baseline. CASPER reaches 12.1% optimal on 30 × 30 30 \times30 30 × 30 , more than doubling CTSketch. Second, the ablation study isolates the contribution of each component of CASPER. Applying CASPER only at inference time already reaches 78.3% optimal on 12 × 12 12 \times12 12 × 12 and produces valid paths 100% of the times. This demonstrates that CASPER can be deployed as a post-hoc constraint-enforcement step on existing predictors with no retraining. Conversely, training with CASPER but removing it at inference (Train Only) performs similarly to the unconstrained ResNet-18, showing that the gains stem from enforcing the constraints at inference. Third, the ℓ 2 \ell_2 ℓ 2 regularizer provides a consistent improvement on both grid sizes: +1.2 points on 12 × 12 12 \times12 12 × 12 and +1.1 points on 30 × 30 30 \times30 30 × 30 , in line with § 3.1 .
MNIST Arithmetic
We next investigate the scalability of CASPER by considering two arithmetic reasoning tasks where the constraint structure grows with the input size: MNIST-Sum and MNIST-Add. For MNIST-Sum, we consider the problem of computing the sum of n n n handwritten digits sampled from the MNIST dataset [33 ] with n = 2 k n = 2^k n = 2 k for k ∈ { 1 , 4 , 6 , 8 , 10 } k \in\{1, 4, 6, 8, 10\} k ∈ { 1 , 4 , 6 , 8 , 10 } . For MNIST-Add, the objective is to compute the sum of two n n n -digit numbers represented as sequences of handwritten digits. As in [10 ] , we test using n ∈ { 2 , 15 , 100 , 256 } n \in\{2, 15, 100, 256\} n ∈ { 2 , 15 , 100 , 256 } . In both tasks, the constraint requires the final output to follow the sum rules and we train under full supervision. We define a reference accuracy of 0.995 n 0.995^n 0.99 5 n for MNIST-Sum and 0.995 2 n 0.995^{2n} 0.99 5 2 n for MNIST-Add, representing the expected accuracy of a MNIST classifier with 99.5% per-digit accuracy. In addition to the previous task baselines, we include A-NeSI [48 ] , and we evaluate a second variant of CASPER that for every variable solves the optimization problem in Equation (2) using cvxpy [16 , 1 ] with default solver SCS [40 ] . All methods use a Le-Net 5 backbone [33 ] .
We report the results obtained for every dimension in Figure 2 and the time (in seconds) to complete an epoch for each method in Table 3. Figure 2 shows that of the exact methods only CASPER is able to scale from the basic case; DPL, SPL and CCN+ time out for all larger problem sizes. Regarding the approximate methods, on MNIST-Sum we can see that Scallop and DSL fail to scale beyond n = 16 n = 16 n = 16 , with Table 3 showing that Scallop in particular, being CPU bound, incurs a significant increase in training time. Additionally, on MNIST-Sum, for every n ≥ 16 n \ge16 n ≥ 16 , CASPER outperforms both CTSketch and A-NeSI in terms of accuracy. Regarding MNIST-Add, CASPER is competitive with all approximate methods at all scales, with the exception of DSL and A-NeSI at n = 15 n = 15 n = 15 , and DSL leading at n = 100 n = 100 n = 100 (28.0% vs CASPER at 13.8% and CTSketch at 8.5%). However, DSL times out for n = 256 n = 256 n = 256 where CASPER marginally outperforms CTSketch.
Figure 2. Test accuracy as a function of problem size n n n on MNIST (a) Sum and (b) Add. × marks the largest n n n each method completed before timing out or failing.
Regarding the comparison with CASPER using cvxpy , we can see that the cvxpy variant performs comparably to the standard CASPER on both MNIST-Sum and MNIST-Add, but times out at n = 1024 n = 1024 n = 1024 and n = 100 n = 100 n = 100 , respectively. This confirms the need for the closed-form surrogate: solving the fixed-point system exactly is tractable only at small scale.
Sudoku Solving
We consider the SatNet dataset [50 ] composed of 10,000 nine-by-nine Sudoku boards constructed with MNIST digits, whose an average number of hints is equal to 36.22 (min. 31, max. 42). The task is to output the completed final board. The pipeline we adopt is the same as [11 ] : (i) a CNN classifies MNIST hints, (ii) a board solver completes the board and it is followed by (iii) a masking network who blanks out unreliable cells. Finally, (iv) a Prolog solver returns the final board. For (ii) we test two different models: the pretrained neuro-solver from [11 ] and the LLM Qwen2.5-14B-Instruct [43 ] , which we finetuned over the training SatNet boards. We use the same implementation of CASPER interchangeably on top of both solvers, projecting the cells distribution wrt. the 27 groups, over 9 rows, 9 columns, and 9, three-by-three, boxes. CASPER enforces the non-duplicate constraint individually across each. Table 4 , reports the output accuracy of the intermediate solver (NeuroAcc ), the percentage of CNN errors it can recover from (RecRate ) and the final Prolog module (PipeAcc ). On top of improving the final accuracy, CASPER more than doubles the solver performance, while consistently recovering through different solvers almost 95% of the CNN perception errors.
Table 4. Sudoku solving test results.
CASPER belongs to a broader effort in neurosymbolic AI [21 , 38 ] to integrate symbolic background knowledge into neural predictors. The earliest neurosymbolic methods incorporate constraints as differentiable training signals [18 , 6 , 17 , 47 , 44 , 54 , 4 , 42 ] . These methods incur no inference-time overhead but cannot guarantee that test predictions satisfy the constraint. A second family treats the symbolic component as a probabilistic program. DeepProbLog [36 ] and NeurASP [55 ] perform exact weighted model counting (WMC), but inference is #P-hard. Scallop [30 ] retains only the top-k k k proofs, so discarded proofs contribute neither probability mass nor gradient; DeepSoftLog [35 ] adds soft unification and, on multi-digit addition, retains exact inference through a hand-designed digit-wise carry recursion, outperforming CASPER on MNIST-Add at n = 100 n = 100 n = 100 , although this factorisation does not directly apply to MNIST-Sum, where it times out beyond 16 digits; DeepStochLog [53 ] replaces probabilistic with stochastic semantics. A complementary line bypasses logic-programming languages: A-NeSI [48 ] amortises WMC with a learned neural surrogate, introducing approximation and generalisation error; CTSketch [10 ] encodes the program as a tensor compressed via tensor-train decomposition; Softened Symbol Grounding [34 ] uses MCMC to sample symbol assignments consistent with the constraint. Across this family, scalability is bought at the cost of exactness or, in the case of DeepSoftLog, generality, and constraint satisfaction cannot be guaranteed at test time. The closest family to ours injects constraints at the predictive layer, guaranteeing that every output is feasible. C-HMCNN [23 ] , CCN [24 ] and CCN+ [25 ] clamp predictions into coherence intervals; SPL [3 ] multiplies a predictive probabilistic circuit by a compiled constraint circuit and renormalises; MultiplexNet [29 ] parameterises outputs as mixtures over feasible regions. The same principle has recently been applied to controlled language generation, e.g., Ctrl-G [56 ] . CASPER belongs to this final family but breaks its scalability bottleneck. CASPER natively handles categorical variables via a closed-form Euclidean projection, generalising the simplex projection of Duchi et al. [20 ] to argmax constraints, that is compatible in a single forward pass with parallel depth bounded by the number of variables, independent of constraint complexity. Conceptually, CASPER is also close to differentiable convex-optimisation layers [5 , 2 ] , but differently from them it is specialised to categorical structured prediction.
Conclusions
In this paper we presented CASPER, a differentiable neurosymbolic layer that enforces hard logical constraints over categorical variables while scaling to thousands of variables. In the single-variable case, constraint satisfaction reduces to a Euclidean projection onto the argmax-feasible region of the simplex, which we solve via a closed-form surrogate with exactly characterised error and gradient behaviour. The general case is handled by an offline compilation step based on signed resolution that reduces multi-variable satisfaction to a sequence of such single-variable projections, parallel across variables which are independent according to the constraints. Across our benchmarks, CASPER is the only method that simultaneously guarantees satisfaction and scales. Indeed, it predicts valid paths on 100% of 30×30 WarCraft instances, where all exact baselines time out and the strongest approximate baseline falls below 7%. Further, it is the only exact method that scales to MNIST sums of more than a thousand digits. Finally, it more than doubles the post-layer accuracy of the strongest, unconstrained scalable baseline on Sudoku.
Acknowledgements
This work was supported by the AI for Math Fund, which is managed by Renaissance Philanthropy in partnership with founding donor XTX Markets. Lohith Konathala is funded by the Engineering and Physical Sciences Research Council (EPSRC) and IceBrook through an Industrial Doctoral Landscape Award (IDLA) studentship. The authors acknowledge the use of resources provided by the Isambard-AI National AI Research Resource (AIRR). Isambard-AI is operated by the University of Bristol and is funded by the UK Government’s Department for Science, Innovation and Technology (DSIT) via UK Research and Innovation; and the Science and Technology Facilities Council [ST/AIRR/I-A-I/1023]. We thank the anonymous reviewers and area chairs for their helpful comments and feedback.
Limitations
CASPER targets a specific corner of the neurosymbolic problem space — guaranteed satisfaction of hard logical constraints over discrete categorical variables — and the design choices that make this corner tractable at scale carry their own limitations, which we discuss here.
The simplex projection at the heart of CASPER is built for finite-domain categorical variables and signed clauses. Constraints over continuous outputs [46 , 51 , 45 , 19 ] , soft constraints encoding preferences, and constraints mixing discrete and continuous quantities all fall outside its scope: handling them would require redesigning the projection geometry rather than re-instantiating it. Within the categorical setting, our approach also relies on a closed-form over-approximation A t \mathcal{A}^{t} A t of the exact active set M t \mathcal{M}^{t} M t (Lemma 1) in order to retain O ( log h ) O(\log h) O ( log h ) parallel depth. This approximation affects only the continuous output of CASPER: the surrogate selects the same value as the exact projection at every step (Theorem 3 and Corollary 2), and Theorem 4 characterises the resulting gap exactly, with Corollary 1 bounding it for every input. The ℓ 2 \ell_{2} ℓ 2 regulariser (Proposition 2) shrinks this bound during training, but only on average over the training distribution, not on every test input. Inference-only deployments, which never see the regulariser, therefore incur a small but measurable degradation, as the (Inference-Only) ablation in Table 2 shows.
Finally, several active areas of neurosymbolic learning are complementary to ours rather than addressed by it: reasoning shortcuts [37 , 38 ] , modelling dependencies between predicted symbols [49 ] , and concept-based interpretability [32 , 12 , 7 ] . CASPER composes naturally with methods targeting these axes — for instance, the categorical output of a concept bottleneck model can itself serve as the variables on which CASPER enforces constraints — but a thorough empirical study of such combinations is beyond the scope of this paper.
Proof of Theorem 1
Statement. Let y ^ ∈ Δ ( [ h ] ) \hat{y} \in\Delta([h]) y ^ ∈ Δ ([ h ]) and S ⊆ [ h ] \mathcal{S} \subseteq[h] S ⊆ [ h ] , the ϵ \epsilon ϵ -margin solution to the optimization problem in
argmin z ∈ Δ ( [ h ] ) ∥ z − y ^ ∥ 2 2 subject to argmax j ∈ [ h ] z ∈ S . (13) \underset{z \in\Delta([h])}{\operatorname{argmin}}\ \lVert z-\hat{y}\rVert_{2}^{2}
\qquad\text{subject to}\qquad\underset{j \in[h]}{\operatorname{argmax}}\ z \in\mathcal{S}. \tag*{(13)} z ∈ Δ ([ h ]) argmin ∥ z − y ^ ∥ 2 2 subject to j ∈ [ h ] argmax z ∈ S . (13)
is given by z t ⋆ z^{t^\star} z t ⋆ with t ⋆ t^\star t ⋆ equal to
t ⋆ ∈ argmin t ∈ S ∥ z t − y ^ ∥ 2 2 , (14) t^\star\in\underset{t \in\mathcal{S}}{\operatorname{argmin}}\ \lVert z^{t}-\hat{y}\rVert_{2}^{2}, \tag*{(14)} t ⋆ ∈ t ∈ S argmin ∥ z t − y ^ ∥ 2 2 , (14)
where for every t ∈ S t \in\mathcal{S} t ∈ S , z t z^{t} z t is the solution of the convex minimization problem obtained by fixing t t t as the unique maximizer:
z j t = { y ^ j if j ∉ ( M t ∪ { t } ) z t t − ϵ if j ∈ M t y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ 1 + ∣ M t ∣ if j = t (15) z_{j}^{t} =
\begin{cases}
\hat{y}_{j} & \text{if } j \notin(\mathcal{M}^{t} \cup\{t\}) \\
z_{t}^{t}-\epsilon& \text{if } j \in\mathcal{M}^{t} \\
\dfrac{\hat{y}_{t}+\sum_{j\in\mathcal{M}^{t}}\hat{y}_{j}+|\mathcal{M}^{t}|\epsilon}{1+|\mathcal{M}^{t}|} & \text{if } j=t
\end{cases} \tag*{(15)} z j t = ⎩ ⎨ ⎧ y ^ j z t t − ϵ 1 + ∣ M t ∣ y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ if j ∈ / ( M t ∪ { t }) if j ∈ M t if j = t (15)
M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t t − ϵ } \mathcal{M}^{t} = \{j \in[h] \setminus\{t\} : \hat{y}_{j} \ge z_{t}^{t}-\epsilon\} M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t t − ϵ } represents the set of active categories given t t t , and ϵ > 0 \epsilon> 0 ϵ > 0 is an arbitrarily small constant.
Proof. The ϵ \epsilon ϵ -margin feasible space of (13) decomposes as
{ z ∈ Δ ( [ h ] ) : ∃ t ∈ S , z t ≥ z j + ϵ ∀ j ≠ t } = ⋃ t ∈ S C t , C t = { z : z t ≥ z j + ϵ } . \{z \in\Delta([h]) : \exists t \in\mathcal{S},\ z_{t} \ge z_{j}+\epsilon\ \forall j \ne t\} = \bigcup_{t\in\mathcal{S}} C^{t}, \qquad C^{t} = \{z : z_{t} \ge z_{j}+\epsilon\}. { z ∈ Δ ([ h ]) : ∃ t ∈ S , z t ≥ z j + ϵ ∀ j = t } = t ∈ S ⋃ C t , C t = { z : z t ≥ z j + ϵ } .
Since every C t C^{t} C t is an intersection of halfspaces with the simplex, it is closed and convex, and the objective ∥ z − y ^ ∥ 2 2 \lVert z-\hat{y}\rVert_{2}^{2} ∥ z − y ^ ∥ 2 2 is convex and continuous. Hence,
min z ∈ ⋃ t ∈ S C t ∥ z − y ^ ∥ 2 2 = min t ∈ S min z ∈ C t ∥ z − y ^ ∥ 2 2 . \min_{z\in\bigcup_{t\in\mathcal{S}} C^{t}}\lVert z-\hat{y}\rVert_{2}^{2}
= \min_{t\in\mathcal{S}}\min_{z\in C^{t}}\lVert z-\hat{y}\rVert_{2}^{2}. z ∈ ⋃ t ∈ S C t min ∥ z − y ^ ∥ 2 2 = t ∈ S min z ∈ C t min ∥ z − y ^ ∥ 2 2 .
This proves (14) is the ϵ \epsilon ϵ -margin solution of the optimization problem in (13) provided that z t z^{t} z t is equal to (15) .
Consider t ∈ S t \in\mathcal{S} t ∈ S . We solve
min z ∥ z − y ^ ∥ 2 2 \min_{z}\lVert z-\hat{y}\rVert_{2}^{2} z min ∥ z − y ^ ∥ 2 2
subject to
z t ≥ z j + ϵ ∀ j ∈ [ h ] ∖ { t } , ∑ j = 1 h z j = 1 , z j ≥ 0 ∀ j ∈ [ h ] . (16) z_t \ge z_j + \epsilon\quad\forall j \in[h] \setminus\{t\}, \qquad\sum_{j=1}^{h} z_j = 1, \qquad z_j \ge0 \quad\forall j \in[h]. \tag*{(16)} z t ≥ z j + ϵ ∀ j ∈ [ h ] ∖ { t } , j = 1 ∑ h z j = 1 , z j ≥ 0 ∀ j ∈ [ h ] . (16)
This yields a well-posed convex problem enforcing uniqueness of the maximizer with margin ϵ \epsilon ϵ .
The Lagrangian is:
L = ∑ j = 1 h ( z j − y ^ j ) 2 + ν ( ∑ j = 1 h z j − 1 ) − ∑ j ∈ [ h ] ∖ { t } λ j ( z t − z j − ϵ ) − ∑ j = 1 h μ j z j . \mathcal{L} = \sum_{j=1}^{h} (z_j - \hat{y}_j)^2 + \nu\left(\sum_{j=1}^{h} z_j - 1\right) - \sum_{j \in[h]\setminus\{t\}} \lambda_j (z_t - z_j - \epsilon) - \sum_{j=1}^{h} \mu_j z_j. L = j = 1 ∑ h ( z j − y ^ j ) 2 + ν ( j = 1 ∑ h z j − 1 ) − j ∈ [ h ] ∖ { t } ∑ λ j ( z t − z j − ϵ ) − j = 1 ∑ h μ j z j .
The KKT conditions (which include the primal feasibility in Equation (16) ) give us:
∂ L ∂ z j = 2 ( z j − y ^ j ) + ν + λ j − μ j = 0 , ∀ j ∈ [ h ] ∖ t (Stationarity (1)) \frac{\partial\mathcal{L}}{\partial z_j} = 2(z_j-\hat{y}_j) + \nu+ \lambda_j - \mu_j = 0, \qquad\forall j \in[h]\setminus t \qquad\text{(Stationarity (1))} ∂ z j ∂ L = 2 ( z j − y ^ j ) + ν + λ j − μ j = 0 , ∀ j ∈ [ h ] ∖ t (Stationarity (1))
∂ L ∂ z t = 2 ( z t − y ^ t ) + ν − ∑ j ∈ [ h ] ∖ { t } λ j − μ t = 0 (Stationarity (2)) \frac{\partial\mathcal{L}}{\partial z_t} = 2(z_t-\hat{y}_t) + \nu- \sum_{j \in[h]\setminus\{t\}} \lambda_j - \mu_t = 0 \qquad\text{(Stationarity (2))} ∂ z t ∂ L = 2 ( z t − y ^ t ) + ν − j ∈ [ h ] ∖ { t } ∑ λ j − μ t = 0 (Stationarity (2))
λ j ≥ 0 , μ j ≥ 0 ∀ j ∈ [ h ] (Dual Feasibility) \lambda_j \ge0,\qquad\mu_j \ge0 \qquad\forall j \in[h] \qquad\text{(Dual Feasibility)} λ j ≥ 0 , μ j ≥ 0 ∀ j ∈ [ h ] (Dual Feasibility)
λ j ( z t − z j − ϵ ) = 0 ∀ j ∈ [ h ] ∖ { t } μ j z j = 0 ∀ j ∈ [ h ] (Complementary Slackness) \lambda_j(z_t-z_j-\epsilon)=0 \qquad\forall j \in[h]\setminus\{t\} \qquad\mu_j z_j=0 \qquad\forall j \in[h] \qquad\text{(Complementary Slackness)} λ j ( z t − z j − ϵ ) = 0 ∀ j ∈ [ h ] ∖ { t } μ j z j = 0 ∀ j ∈ [ h ] (Complementary Slackness)
Let
Z t = { j ∈ [ h ] : μ j ≠ 0 } Z^t = \{j \in[h] : \mu_j \ne0\} Z t = { j ∈ [ h ] : μ j = 0 } be the set of categories for which the zero constraint is active,
M t = { j ∈ [ h ] ∖ t : λ j ≠ 0 } M^t = \{j \in[h]\setminus t : \lambda_j \ne0\} M t = { j ∈ [ h ] ∖ t : λ j = 0 } be the set of categories for which the margin constraint is active, and
F t = [ h ] ∖ ( M t ∪ Z t ∪ { t } ) F^t = [h]\setminus(M^t \cup Z^t \cup\{t\}) F t = [ h ] ∖ ( M t ∪ Z t ∪ { t }) the free set where neither of the constraints is active.
Notice that these sets, together with { t } \{t\} { t } , form a partition of [ h ] [h] [ h ] .
Indeed, the primal feasibility conditions impose that z ∈ Δ ( [ h ] ) z \in\Delta([h]) z ∈ Δ ([ h ]) and z t − z j ≥ ϵ z_t-z_j \ge\epsilon z t − z j ≥ ϵ for all j ≠ t j \ne t j = t . If z t = ϵ z_t=\epsilon z t = ϵ , then for all j ∈ [ h ] ∖ { t } j \in[h]\setminus\{t\} j ∈ [ h ] ∖ { t } we would have
z j ≤ z t − ϵ = 0. z_j \le z_t-\epsilon=0. z j ≤ z t − ϵ = 0.
Since z j ≥ 0 z_j \ge0 z j ≥ 0 for all j ∈ [ h ] j \in[h] j ∈ [ h ] and ϵ < 1 \epsilon< 1 ϵ < 1 , it follows that z j = 0 z_j=0 z j = 0 for all j ≠ t j \ne t j = t . Therefore,
∑ j = 1 h z j = z t = ϵ ≠ 1 , \sum_{j=1}^{h} z_j = z_t = \epsilon\ne1, j = 1 ∑ h z j = z t = ϵ = 1 ,
which contradicts the simplex constraint z ∈ Δ z \in\Delta z ∈ Δ . Hence z t > ϵ z_t > \epsilon z t > ϵ , and in particular z t − ϵ > 0 z_t-\epsilon> 0 z t − ϵ > 0 .
It follows that no index j ≠ t j \ne t j = t can simultaneously satisfy
z j = 0 and z j = z t − ϵ , z_j=0 \qquad\text{and} \qquad z_j=z_t-\epsilon, z j = 0 and z j = z t − ϵ ,
and hence Z t ∩ M t = ∅ Z^t \cap M^t = \varnothing Z t ∩ M t = ∅ .
Then:
μ j = ν − 2 y ^ j ≥ 0 y ^ j ≤ τ , (17) \mu_j = \nu- 2\hat{y}_j \ge0 \qquad\hat{y}_j \le\tau, \tag*{(17)} μ j = ν − 2 y ^ j ≥ 0 y ^ j ≤ τ , (17)
where τ = ν 2 \tau= \frac{\nu}{2} τ = 2 ν .
λ j = 2 ( y ^ j − z j ) − ν = 2 ( y ^ j − z t + ϵ ) − ν = 2 ( y ^ j − z t + ϵ − τ ) \lambda_j = 2(\hat{y}_j-z_j)-\nu= 2(\hat{y}_j-z_t+\epsilon)-\nu= 2(\hat{y}_j-z_t+\epsilon-\tau) λ j = 2 ( y ^ j − z j ) − ν = 2 ( y ^ j − z t + ϵ ) − ν = 2 ( y ^ j − z t + ϵ − τ )
Since we know that for all j ∈ Z t ∪ F t j \in\mathcal{Z}^t \cup\mathcal{F}^t j ∈ Z t ∪ F t , λ j = 0 \lambda_j = 0 λ j = 0 we can rewrite the first stationarity condition as:
2 ( z t − y ^ t ) + ν − ∑ j ∈ M t λ j = 0 2(z_t-\hat{y}_t)+\nu-\sum_{j\in\mathcal{M}^t}\lambda_j=0 2 ( z t − y ^ t ) + ν − j ∈ M t ∑ λ j = 0
2 ( z t − y ^ t ) + ν − ∑ j ∈ M t 2 ( y ^ j − z t + ϵ − τ ) = 0 2(z_t-\hat{y}_t)+\nu-\sum_{j\in\mathcal{M}^t}2(\hat{y}_j-z_t+\epsilon-\tau)=0 2 ( z t − y ^ t ) + ν − j ∈ M t ∑ 2 ( y ^ j − z t + ϵ − τ ) = 0
Let m = ∣ M t ∣ m=|\mathcal{M}^t| m = ∣ M t ∣ ,
( z t − y ^ t ) + τ − ∑ j ∈ M t y ^ j + m z t − m ϵ + m τ = 0 (z_t-\hat{y}_t)+\tau-\sum_{j\in\mathcal{M}^t}\hat{y}_j+mz_t-m\epsilon+m\tau=0 ( z t − y ^ t ) + τ − j ∈ M t ∑ y ^ j + m z t − m ϵ + m τ = 0
( m + 1 ) z t = y ^ t + ∑ j ∈ M t y ^ j + m ϵ − ( m + 1 ) τ (18) (m+1)z_t=\hat{y}_t+\sum_{j\in\mathcal{M}^t}\hat{y}_j+m\epsilon-(m+1)\tau \tag*{(18)} ( m + 1 ) z t = y ^ t + j ∈ M t ∑ y ^ j + m ϵ − ( m + 1 ) τ (18)
To determine τ \tau τ , we impose the simplex constraint ∑ j = 1 h z j = 1 \sum_{j=1}^h z_j=1 ∑ j = 1 h z j = 1 and decompose the sum according to the partition { Z t , F t , M t } \{\mathcal{Z}^t,\mathcal{F}^t,\mathcal{M}^t\} { Z t , F t , M t } of [ h ] ∖ { t } [h]\setminus\{t\} [ h ] ∖ { t } . By construction,
z j = { 0 , j ∈ Z t , y ^ j − τ , j ∈ F t , z t − ϵ , j ∈ M t , and z t for j = t . z_j=
\begin{cases}
0, & j\in\mathcal{Z}^t,\\
\hat{y}_j-\tau, & j\in\mathcal{F}^t,\\
z_t-\epsilon, & j\in\mathcal{M}^t,
\end{cases}
\qquad\text{and}\qquad z_t\text{ for }j=t. z j = ⎩ ⎨ ⎧ 0 , y ^ j − τ , z t − ϵ , j ∈ Z t , j ∈ F t , j ∈ M t , and z t for j = t .
Hence,
1 = z t + ∑ j ∈ F t ( y ^ j − τ ) + ∑ j ∈ M t ( z t − ϵ ) . 1=z_t+\sum_{j\in\mathcal{F}^t}(\hat{y}_j-\tau)+\sum_{j\in\mathcal{M}^t}(z_t-\epsilon). 1 = z t + j ∈ F t ∑ ( y ^ j − τ ) + j ∈ M t ∑ ( z t − ϵ ) .
Let f = ∣ F t ∣ f=|\mathcal{F}^t| f = ∣ F t ∣ and m = ∣ M t ∣ m=|\mathcal{M}^t| m = ∣ M t ∣ . Then
1 = ( m + 1 ) z t + ∑ j ∈ F t y ^ j − f τ − m ϵ 1=(m+1)z_t+\sum_{j\in\mathcal{F}^t}\hat{y}_j-f\tau-m\epsilon 1 = ( m + 1 ) z t + j ∈ F t ∑ y ^ j − f τ − m ϵ
( m + 1 ) z t = 1 − ∑ j ∈ F t y ^ j + f τ + m ϵ (19) (m+1)z_t=1-\sum_{j\in\mathcal{F}^t}\hat{y}_j+f\tau+m\epsilon \tag*{(19)} ( m + 1 ) z t = 1 − j ∈ F t ∑ y ^ j + f τ + m ϵ (19)
By setting 18 equal to 19 we obtain
y ^ t + ∑ j ∈ M t y ^ j + m ϵ − ( m + 1 ) τ = 1 − ∑ j ∈ F t y ^ j + f τ + m ϵ \hat{y}_t+\sum_{j\in\mathcal{M}^t}\hat{y}_j+m\epsilon-(m+1)\tau=1-\sum_{j\in\mathcal{F}^t}\hat{y}_j+f\tau+m\epsilon y ^ t + j ∈ M t ∑ y ^ j + m ϵ − ( m + 1 ) τ = 1 − j ∈ F t ∑ y ^ j + f τ + m ϵ
∑ j ∈ Z t y ^ j = − ( h − ∣ Z t ∣ ) τ (20) \sum_{j\in\mathcal{Z}^t}\hat{y}_j=-(h-|\mathcal{Z}^t|)\tau \tag*{(20)} j ∈ Z t ∑ y ^ j = − ( h − ∣ Z t ∣ ) τ (20)
Since by definition ∑ j ∈ Z t y ^ j ≥ 0 \sum_{j\in\mathcal{Z}^t}\hat{y}_j\geq0 ∑ j ∈ Z t y ^ j ≥ 0 and h − ∣ Z t ∣ ≥ 1 h-|\mathcal{Z}^t|\geq1 h − ∣ Z t ∣ ≥ 1 (as t ∉ Z t t\notin\mathcal{Z}^t t ∈ / Z t ), Equation (20) gives τ ≤ 0 \tau\leq0 τ ≤ 0 . However, according to Equation (17) , we have that for all j ∈ Z t j\in\mathcal{Z}^t j ∈ Z t , 0 ≤ y ^ j ≤ τ 0\leq\hat{y}_j\leq\tau 0 ≤ y ^ j ≤ τ . Hence, for every j ∈ Z t j\in\mathcal{Z}^t j ∈ Z t , y ^ j = 0 \hat{y}_j=0 y ^ j = 0 , and τ = ν = 0 \tau=\nu=0 τ = ν = 0 .
Since τ = 0 \tau=0 τ = 0 , we have that for all j ∉ M t ∪ { t } j\notin\mathcal{M}^t\cup\{t\} j ∈ / M t ∪ { t } , z j = y ^ j z_j=\hat{y}_j z j = y ^ j , hence the sets F t \mathcal{F}^t F t and Z t \mathcal{Z}^t Z t are indistinguishable. Hence, we have that:
z j = { y ^ j , j ∉ M t ∪ { t } , z t − ϵ , j ∈ M t , y ^ t + ∑ j ∈ M t y ^ j + m ϵ m + 1 , j = t . (21) z_j=
\begin{cases}
\hat{y}_j, & j\notin\mathcal{M}^t\cup\{t\},\\
z_t-\epsilon, & j\in\mathcal{M}^t,\\
\dfrac{\hat{y}_t+\sum_{j\in\mathcal{M}^t}\hat{y}_j+m\epsilon}{m+1}, & j=t.
\end{cases} \tag*{(21)} z j = ⎩ ⎨ ⎧ y ^ j , z t − ϵ , m + 1 y ^ t + ∑ j ∈ M t y ^ j + m ϵ , j ∈ / M t ∪ { t } , j ∈ M t , j = t . (21)
Notice that Equations (22) –(21) define a fixed-point system. Indeed, the set M t \mathcal{M}^t M t :
M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t − ϵ } (22) \mathcal{M}^t=\{j\in[h]\setminus\{t\}:\hat{y}_j\geq z_t-\epsilon\} \tag*{(22)} M t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ z t − ϵ } (22)
is defined through z t z_t z t , which in turn depends on M t \mathcal{M}^t M t . We now show that this system admits a unique solution, which can be found by a one-dimensional sweep over the sorted values of y ^ \hat{y} y ^ .
Let y ^ ( 1 ) ≥ y ^ ( 2 ) ≥ ⋯ ≥ y ^ ( h − 1 ) \hat{y}^{(1)}\geq\hat{y}^{(2)}\geq\cdots\geq\hat{y}^{(h-1)} y ^ ( 1 ) ≥ y ^ ( 2 ) ≥ ⋯ ≥ y ^ ( h − 1 ) denote the values { y ^ j : j ≠ t } \{\hat{y}_j:j\neq t\} { y ^ j : j = t } sorted in decreasing order, with the convention y ^ ( 0 ) : = + ∞ \hat{y}^{(0)}:=+\infty y ^ ( 0 ) := + ∞ and y ^ ( h ) : = − ∞ \hat{y}^{(h)}:=-\infty y ^ ( h ) := − ∞ . For a ∈ { 0 , 1 , … , h − 1 } a\in\{0,1,\ldots,h-1\} a ∈ { 0 , 1 , … , h − 1 } , define the candidate threshold
θ a = y ^ t + ∑ k = 1 a y ^ ( k ) − ϵ 1 + a . (23) \theta_a=\frac{\hat{y}_t+\sum_{k=1}^{a}\hat{y}^{(k)}-\epsilon}{1+a}. \tag*{(23)} θ a = 1 + a y ^ t + ∑ k = 1 a y ^ ( k ) − ϵ . (23)
By construction, θ a = z t t − ϵ \theta_a = z_t^t - \epsilon θ a = z t t − ϵ whenever ∣ M t ∣ = a |\mathcal{M}^t| = a ∣ M t ∣ = a and M t \mathcal{M}^t M t consists of the top-a a a indices.
To prove the uniqueness of the solution, we prove that there exists a unique integer a ⋆ ∈ { 0 , 1 , … , h − 1 } a^\star\in\{0,1,\ldots,h-1\} a ⋆ ∈ { 0 , 1 , … , h − 1 } such that
y ^ ( a ⋆ ) > θ a ⋆ and y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ , (24) \hat{y}^{(a^\star)} > \theta_{a^\star} \qquad\text{and} \qquad\hat{y}^{(a^\star+1)} \leq\theta_{a^\star}, \tag*{(24)} y ^ ( a ⋆ ) > θ a ⋆ and y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ , (24)
and that setting M t \mathcal{M}^t M t to be the top-a a a indices of { y ^ j : j ≠ t } \{\hat{y}_j:j\neq t\} { y ^ j : j = t } and z t t = θ a ⋆ + ϵ z_t^t=\theta_{a^\star}+\epsilon z t t = θ a ⋆ + ϵ yields the unique solution of the fixed-point system (22) –(21) .
Indeed, from (23) :
θ a + 1 − θ a = y ^ ( a + 1 ) − θ a 2 + a , (25) \theta_{a+1}-\theta_a=\frac{\hat{y}^{(a+1)}-\theta_a}{2+a}, \tag*{(25)} θ a + 1 − θ a = 2 + a y ^ ( a + 1 ) − θ a , (25)
which implies the equivalence
θ a + 1 > θ a ⟺ y ^ ( a + 1 ) > θ a , (26) \theta_{a+1}>\theta_a \quad\Longleftrightarrow\quad\hat{y}^{(a+1)}>\theta_a, \tag*{(26)} θ a + 1 > θ a ⟺ y ^ ( a + 1 ) > θ a , (26)
and similarly for the reverse inequality.
Existence. Define
a ⋆ = max { a ∈ { 0 , 1 , … , h − 1 } : y ^ ( a ) > θ a − 1 } , a^\star=\max\{a\in\{0,1,\ldots,h-1\}:\hat{y}^{(a)}>\theta_{a-1}\}, a ⋆ = max { a ∈ { 0 , 1 , … , h − 1 } : y ^ ( a ) > θ a − 1 } ,
where the set is nonempty because y ^ ( 0 ) = + ∞ > θ − 1 \hat{y}^{(0)}=+\infty>\theta_{-1} y ^ ( 0 ) = + ∞ > θ − 1 with the convention θ − 1 = − ∞ \theta_{-1}=-\infty θ − 1 = − ∞ . By definition, y ^ ( a ⋆ ) > θ a ⋆ − 1 \hat{y}^{(a^\star)}>\theta_{a^\star-1} y ^ ( a ⋆ ) > θ a ⋆ − 1 , and applying (26) at index a ⋆ − 1 a^\star-1 a ⋆ − 1 yields θ a ⋆ > θ a ⋆ − 1 \theta_{a^\star}>\theta_{a^\star-1} θ a ⋆ > θ a ⋆ − 1 . Rearranging (25) gives
θ a ⋆ = a ⋆ θ a ⋆ − 1 + y ^ ( a ⋆ ) 1 + a ⋆ , \theta_{a^\star}=\frac{a^\star\theta_{a^\star-1}+\hat{y}^{(a^\star)}}{1+a^\star}, θ a ⋆ = 1 + a ⋆ a ⋆ θ a ⋆ − 1 + y ^ ( a ⋆ ) ,
which is a convex combination of θ a ⋆ − 1 \theta_{a^\star-1} θ a ⋆ − 1 and y ^ ( a ⋆ ) \hat{y}^{(a^\star)} y ^ ( a ⋆ ) ; since θ a ⋆ − 1 < y ^ ( a ⋆ ) \theta_{a^\star-1}<\hat{y}^{(a^\star)} θ a ⋆ − 1 < y ^ ( a ⋆ ) , we obtain y ^ ( a ⋆ ) > θ a ⋆ \hat{y}^{(a^\star)}>\theta_{a^\star} y ^ ( a ⋆ ) > θ a ⋆ , the first part of (24) . If a ⋆ = h − 1 a^\star=h-1 a ⋆ = h − 1 , the second part of (24) holds vacuously via y ^ ( h ) = − ∞ \hat{y}^{(h)}=-\infty y ^ ( h ) = − ∞ ; otherwise, maximality of a ⋆ a^\star a ⋆ gives y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ \hat{y}^{(a^\star+1)}\leq\theta_{a^\star} y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ .
Uniqueness. Suppose a 1 < a 2 a_1<a_2 a 1 < a 2 both satisfy (24) . Hence, y ^ ( a 1 + 1 ) ≤ θ a 1 \hat{y}^{(a_1+1)}\leq\theta_{a_1} y ^ ( a 1 + 1 ) ≤ θ a 1 . We show by induction that
y ^ ( b ) ≤ θ b for every b ≥ a 1 + 1 , (27) \hat{y}^{(b)}\leq\theta_b \qquad\text{for every } b\geq a_1+1, \tag*{(27)} y ^ ( b ) ≤ θ b for every b ≥ a 1 + 1 , (27)
which contradicts the strict inequality y ^ ( a 2 ) > θ a 2 \hat{y}^{(a_2)}>\theta_{a_2} y ^ ( a 2 ) > θ a 2 required by (24) at a 2 a_2 a 2 .
Rearranging (25) yields the identity
θ b + 1 − y ^ ( b + 1 ) = 1 + b 2 + b ( θ b − y ^ ( b + 1 ) ) . (28) \theta_{b+1}-\hat{y}^{(b+1)}=\frac{1+b}{2+b}\left(\theta_b-\hat{y}^{(b+1)}\right). \tag*{(28)} θ b + 1 − y ^ ( b + 1 ) = 2 + b 1 + b ( θ b − y ^ ( b + 1 ) ) . (28)
Base case (b = a 1 + 1 b=a_1+1 b = a 1 + 1 ). Applying (28) at index a 1 a_1 a 1 ,
θ a 1 + 1 − y ^ ( a 1 + 1 ) = 1 + a 1 2 + a 1 ( θ a 1 − y ^ ( a 1 + 1 ) ) ≥ 0 \theta_{a_1+1}-\hat{y}^{(a_1+1)}=\frac{1+a_1}{2+a_1}\left(\theta_{a_1}-\hat{y}^{(a_1+1)}\right)\geq0 θ a 1 + 1 − y ^ ( a 1 + 1 ) = 2 + a 1 1 + a 1 ( θ a 1 − y ^ ( a 1 + 1 ) ) ≥ 0
by the hypothesis y ^ ( a 1 + 1 ) ≤ θ a 1 \hat{y}^{(a_1+1)}\leq\theta_{a_1} y ^ ( a 1 + 1 ) ≤ θ a 1 .
Inductive step. Assume θ b ≥ y ^ ( b ) \theta_b\geq\hat{y}^{(b)} θ b ≥ y ^ ( b ) . Since y ^ ( ⋅ ) \hat{y}^{(\cdot)} y ^ ( ⋅ ) is non-increasing, y ^ ( b + 1 ) ≤ y ^ ( b ) ≤ θ b \hat{y}^{(b+1)}\leq\hat{y}^{(b)}\leq\theta_b y ^ ( b + 1 ) ≤ y ^ ( b ) ≤ θ b , so the right-hand side of (28) is non-negative, giving θ b + 1 ≥ y ^ ( b + 1 ) \theta_{b+1}\geq\hat{y}^{(b+1)} θ b + 1 ≥ y ^ ( b + 1 ) .
Iterating up to b = a 2 b=a_2 b = a 2 gives y ^ ( a 2 ) ≤ θ a 2 \hat{y}^{(a_2)}\leq\theta_{a_2} y ^ ( a 2 ) ≤ θ a 2 , the desired contradiction.
Consistency with the fixed-point system. With a ⋆ a^\star a ⋆ as above, set M t \mathcal{M}^t M t to be the top-a ⋆ a^\star a ⋆ indices and z t t = θ a ⋆ + ϵ z_t^t=\theta_{a^\star}+\epsilon z t t = θ a ⋆ + ϵ . Then (21) holds by construction of θ a ⋆ \theta_{a^\star} θ a ⋆ , and (22) holds by (24) : every index in M t \mathcal{M}^t M t has y ^ j ≥ y ^ ( a ⋆ ) > θ a ⋆ = z t t − ϵ \hat{y}_j\geq\hat{y}^{(a^\star)}>\theta_{a^\star}=z_t^t-\epsilon y ^ j ≥ y ^ ( a ⋆ ) > θ a ⋆ = z t t − ϵ , and every index outside has y ^ j ≤ y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ = z t t − ϵ \hat{y}_j\leq\hat{y}^{(a^\star+1)}\leq\theta_{a^\star}=z_t^t-\epsilon y ^ j ≤ y ^ ( a ⋆ + 1 ) ≤ θ a ⋆ = z t t − ϵ .
Computing z t z^t z t . Given an unconstrained output y ^ \hat{\mathbf{y}} y ^ and a constraint stating that the final assignment must belong to S S S , for every t ∈ S t\in S t ∈ S we can compute z t z^t z t by modifying the sorting method used to project onto the probabilistic simplex [28 , 22 , 20 ] :
Sort { y ^ j : j ≠ t } \{\hat{y}_j:j\neq t\} { y ^ j : j = t } in decreasing order as y ^ 1 ≥ ⋯ ≥ y ^ h − 1 \hat{y}_1\geq\cdots\geq\hat{y}_{h-1} y ^ 1 ≥ ⋯ ≥ y ^ h − 1 .
Compute the cumulative sums and evaluate θ a \theta_a θ a for a = 0 , 1 , … , h − 1 a=0,1,\ldots,h-1 a = 0 , 1 , … , h − 1 via (23) in O ( h ) O(h) O ( h ) time.
Find the unique a ⋆ a^\star a ⋆ satisfying (24) (equivalently, the largest a a a with y ^ ( a ) > θ a − 1 \hat{y}(a) > \theta_{a-1} y ^ ( a ) > θ a − 1 ).
Set M t M^t M t to be the corresponding top-a ⋆ a^\star a ⋆ indices and return z t z^t z t via (4) with z t t = θ a ⋆ + ϵ z^t_t = \theta_{a^\star} + \epsilon z t t = θ a ⋆ + ϵ .
This algorithm needs to perform O ( h log h ) O(h \log h) O ( h log h ) sequential operations, dominated by the sort, while it requires only O ( log 2 h ) O(\log^2 h) O ( log 2 h ) sequential GPU operations thanks to parallelization. Alternatively, the convex problem can be solved with a generic solver (like [16 ] ), applying an iterative interior-point or ADMM method.
Proof of Lemma 1
Statement. For every t ∈ [ h ] t \in[h] t ∈ [ h ] and every y ^ ∈ Δ ( [ h ] ) \hat{\mathbf{y}} \in\Delta([h]) y ^ ∈ Δ ([ h ]) , M t ⊆ A t M^t \subseteq A^t M t ⊆ A t .
Proof. Let j ∈ M t j \in M^t j ∈ M t . From M t M^t M t definition we know that y ^ j ≥ z t t − ϵ \hat{y}_j \geq z^t_t - \epsilon y ^ j ≥ z t t − ϵ . To show that M t ⊆ A t M^t \subseteq A^t M t ⊆ A t we need to demonstrate that z t t ≥ y ^ t z^t_t \geq\hat{y}_t z t t ≥ y ^ t .
Using the closed form (21) and writing m = ∣ M t ∣ m = |M^t| m = ∣ M t ∣ ,
z t t − y ^ t = y ^ t + ∑ k ∈ M t y ^ k + m ϵ 1 + m − y ^ t = ∑ k ∈ M t y ^ k − m y ^ t + m ϵ 1 + m . (29) z^t_t - \hat{y}_t = \frac{\hat{y}_t + \sum_{k \in M^t} \hat{y}_k + m\epsilon}{1+m} - \hat{y}_t = \frac{\sum_{k \in M^t} \hat{y}_k - m\hat{y}_t + m\epsilon}{1+m}. \tag*{(29)} z t t − y ^ t = 1 + m y ^ t + ∑ k ∈ M t y ^ k + m ϵ − y ^ t = 1 + m ∑ k ∈ M t y ^ k − m y ^ t + m ϵ . (29)
If m = 0 m = 0 m = 0 , the right-hand side vanishes and z t t = y ^ t z^t_t = \hat{y}_t z t t = y ^ t .
If m ≥ 1 m \geq1 m ≥ 1 , each k ∈ M t k \in M^t k ∈ M t satisfies y ^ k ≥ z t t − ϵ \hat{y}_k \geq z^t_t - \epsilon y ^ k ≥ z t t − ϵ yielding ∑ k ∈ M t y ^ k ≥ m ( z t t − ϵ ) \sum_{k \in M^t} \hat{y}_k \geq m(z^t_t - \epsilon) ∑ k ∈ M t y ^ k ≥ m ( z t t − ϵ ) . Substituting into (29),
z t t − y ^ t ≥ m ( z t t − ϵ ) − m y ^ t + m ϵ 1 + m ≥ m 1 + m ( z t t − y ^ t ) , z^t_t - \hat{y}_t \geq\frac{m(z^t_t - \epsilon) - m\hat{y}_t + m\epsilon}{1+m} \geq\frac{m}{1+m}(z^t_t - \hat{y}_t), z t t − y ^ t ≥ 1 + m m ( z t t − ϵ ) − m y ^ t + m ϵ ≥ 1 + m m ( z t t − y ^ t ) ,
which rearranges to z t t ≥ y ^ t z^t_t \geq\hat{y}_t z t t ≥ y ^ t .
Proof of Theorem 2
Statement. Let m θ : X → Δ ( [ h ] ) m_\theta: \mathcal{X} \to\Delta([h]) m θ : X → Δ ([ h ]) , x ∈ X \mathbf{x} \in\mathcal{X} x ∈ X and y ^ = m θ ( x ) \hat{\mathbf{y}} = m_\theta(\mathbf{x}) y ^ = m θ ( x ) . Let Π = { S : Y } \Pi= \{S : Y\} Π = { S : Y } for some ∅ ⊂ S ⊆ [ h ] \varnothing\subset S \subseteq[h] ∅ ⊂ S ⊆ [ h ] . If
CASPER ( y ^ ) = z ~ t ⋆ , t ⋆ = arg min t ∈ S ∥ z ~ t − y ^ ∥ 2 , (30) \operatorname{CASPER}(\hat{\mathbf{y}}) = \tilde{\mathbf{z}}^{t^\star}, \qquad t^\star= \underset{t \in S}{\arg\min}\ \lVert\tilde{\mathbf{z}}^t - \hat{\mathbf{y}}\rVert^2, \tag*{(30)} CASPER ( y ^ ) = z ~ t ⋆ , t ⋆ = t ∈ S arg min ∥ z ~ t − y ^ ∥ 2 , (30)
where for every t ∈ S t \in S t ∈ S
z ~ j t = { y ^ j if j ∉ ( A t ∪ { t } ) z ~ t t − ϵ if j ∈ A t y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ 1 + ∣ A t ∣ if j = t A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (31) \tilde{z}^t_j =
\begin{cases}
\hat{y}_j & \text{if } j \notin(A^t \cup\{t\}) \\
\tilde{z}^t_t - \epsilon& \text{if } j \in A^t \\
\frac{\hat{y}_t + \sum_{j \in A^t}\hat{y}_j + |A^t|\epsilon}{1+|A^t|} & \text{if } j=t
\end{cases}
\qquad A^t = \{j \in[h] \setminus\{t\} : \hat{y}_j \geq\hat{y}_t - \epsilon\}, \tag*{(31)} z ~ j t = ⎩ ⎨ ⎧ y ^ j z ~ t t − ϵ 1 + ∣ A t ∣ y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ if j ∈ / ( A t ∪ { t }) if j ∈ A t if j = t A t = { j ∈ [ h ] ∖ { t } : y ^ j ≥ y ^ t − ϵ } , (31)
then for ϵ → 0 + \epsilon\to0^+ ϵ → 0 + , the assignment a \mathbf{a} a induced by CASPER ( y ^ ) \operatorname{CASPER}(\hat{\mathbf{y}}) CASPER ( y ^ ) satisfies Π \Pi Π , i.e., a ⊨ Π \mathbf{a} \models\Pi a ⊨ Π .
Proof. We show that for every t ∈ S t \in S t ∈ S , the surrogate z ~ t \tilde{\mathbf{z}}^t z ~ t defined by (30) lies in the simplex Δ ( [ h ] ) \Delta([h]) Δ ([ h ]) and has t t t as its unique argmax. Applied to t = t ⋆ t = t^\star t = t ⋆ , this gives a = arg max j z ~ j t ⋆ = t ⋆ ∈ S \mathbf{a} = \arg\max_j \tilde{z}^{t^\star}_j = t^\star\in S a = arg max j z ~ j t ⋆ = t ⋆ ∈ S , hence a ⊨ Π \mathbf{a} \models\Pi a ⊨ Π .
Let t ∈ S t \in S t ∈ S . We first show that z ~ t ∈ Δ ( [ h ] ) \tilde{\mathbf{z}}^t \in\Delta([h]) z ~ t ∈ Δ ([ h ]) :
∑ j ∈ [ h ] z ~ j t = ∑ j ∉ A t ∪ { t } y ^ j + ∑ j ∈ A t ( z ~ t t − ϵ ) + z ~ t t = ∑ j ∉ A t ∪ { t } y ^ j + ( ∣ A t ∣ + 1 ) y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ 1 + ∣ A t ∣ − ∣ A t ∣ ϵ = ∑ j ∈ [ h ] y ^ j = 1 , \begin{aligned}
\sum_{j \in[h]} \tilde{z}^t_j
&= \sum_{j \notin A^t \cup\{t\}} \hat{y}_j + \sum_{j \in A^t}(\tilde{z}^t_t - \epsilon) + \tilde{z}^t_t \\
&= \sum_{j \notin A^t \cup\{t\}} \hat{y}_j + (|A^t|+1)\frac{\hat{y}_t + \sum_{j \in A^t}\hat{y}_j + |A^t|\epsilon}{1+|A^t|} - |A^t|\epsilon\\
&= \sum_{j \in[h]} \hat{y}_j = 1,
\end{aligned} j ∈ [ h ] ∑ z ~ j t = j ∈ / A t ∪ { t } ∑ y ^ j + j ∈ A t ∑ ( z ~ t t − ϵ ) + z ~ t t = j ∈ / A t ∪ { t } ∑ y ^ j + ( ∣ A t ∣ + 1 ) 1 + ∣ A t ∣ y ^ t + ∑ j ∈ A t y ^ j + ∣ A t ∣ ϵ − ∣ A t ∣ ϵ = j ∈ [ h ] ∑ y ^ j = 1 ,
Non-negativity of z ~ j t \tilde{z}^{t}_{j} z ~ j t follows from y ^ ∈ Δ ( [ h ] ) \hat{\mathbf{y}} \in\Delta([h]) y ^ ∈ Δ ([ h ]) for the unmodified entries, from z ~ t t \tilde{z}^{t}_{t} z ~ t t being a weighted average of non-negative quantities, and from z ~ t t − ϵ ≥ y ^ t − ϵ ≥ 0 \tilde{z}^{t}_{t} - \epsilon\ge\hat{y}_{t} - \epsilon\ge0 z ~ t t − ϵ ≥ y ^ t − ϵ ≥ 0 on A t A^{t} A t provided ϵ ≤ y ^ t \epsilon\le\hat{y}_{t} ϵ ≤ y ^ t , which holds for ϵ \epsilon ϵ sufficiently small. Hence z ~ t ∈ Δ ( [ h ] ) \tilde{\mathbf{z}}^{t} \in\Delta([h]) z ~ t ∈ Δ ([ h ]) .
To prove t = argmax j z ~ j t t = \operatorname{argmax}_{j} \tilde{z}^{t}_{j} t = argmax j z ~ j t , we compare z ~ t t \tilde{z}^{t}_{t} z ~ t t against the elements in both A t A^{t} A t and [ h ] ∖ ( A t ∪ { t } ) [h] \setminus(A^{t} \cup\{t\}) [ h ] ∖ ( A t ∪ { t }) .
For j ∈ A t j \in A^{t} j ∈ A t : z ~ j t = z ~ t t − ϵ < z ~ t t \tilde{z}^{t}_{j} = \tilde{z}^{t}_{t} - \epsilon< \tilde{z}^{t}_{t} z ~ j t = z ~ t t − ϵ < z ~ t t for any ϵ > 0 \epsilon> 0 ϵ > 0 .
For j ∉ A t ∪ { t } j \notin A^{t} \cup\{t\} j ∈ / A t ∪ { t } : z ~ j t = y ^ j < y ^ t − ϵ \tilde{z}^{t}_{j} = \hat{y}_{j} < \hat{y}_{t} - \epsilon z ~ j t = y ^ j < y ^ t − ϵ by definition of A t A^{t} A t . Since every k ∈ A t k \in A^{t} k ∈ A t satisfies y ^ k ≥ y ^ t − ϵ \hat{y}_{k} \ge\hat{y}_{t} - \epsilon y ^ k ≥ y ^ t − ϵ , ∑ k ∈ A t y ^ k ≥ ∣ A t ∣ ( y ^ t − ϵ ) \sum_{k \in A^{t}} \hat{y}_{k} \ge|A^{t}|(\hat{y}_{t} - \epsilon) ∑ k ∈ A t y ^ k ≥ ∣ A t ∣ ( y ^ t − ϵ ) , and substituting into the closed form for z ~ t t \tilde{z}^{t}_{t} z ~ t t yields z ~ t t ≥ y ^ t \tilde{z}^{t}_{t} \ge\hat{y}_{t} z ~ t t ≥ y ^ t . Combining, z ~ t t ≥ y ^ t > y ^ t − ϵ > y ^ j = z ~ j t \tilde{z}^{t}_{t} \ge\hat{y}_{t} > \hat{y}_{t} - \epsilon> \hat{y}_{j} = \tilde{z}^{t}_{j} z ~ t t ≥ y ^ t > y ^ t − ϵ > y ^ j = z ~ j t .
Proof of Theorem 3
Statement. Let y ^ ∈ Δ ( [ h ] ) \hat{\mathbf{y}} \in\Delta([h]) y ^ ∈ Δ ([ h ]) , z t \mathbf{z}^{t} z t be the solution of the fixed point system (4) and z ˉ t \bar{\mathbf{z}}^{t} z ˉ t its surrogate solution as defined in (6) . Then, for ϵ → 0 + \epsilon\to0^{+} ϵ → 0 + ,
argmin t ∈ S ∥ z t − y ^ ∥ 2 2 = argmin t ∈ S ∥ z ˉ t − y ^ ∥ 2 2 = argmax t ∈ S y ^ t . \underset{t \in S}{\operatorname{argmin}}\left\|\mathbf{z}^{t}-\hat{\mathbf{y}}\right\|_{2}^{2}=\underset{t \in S}{\operatorname{argmin}}\left\|\bar{\mathbf{z}}^{t}-\hat{\mathbf{y}}\right\|_{2}^{2}=\underset{t \in S}{\operatorname{argmax}}\hat{y}_{t}. t ∈ S argmin z t − y ^ 2 2 = t ∈ S argmin z ˉ t − y ^ 2 2 = t ∈ S argmax y ^ t .
Proof. Notice that if ∣ S ∣ = 1 |S| = 1 ∣ S ∣ = 1 the thesis is trivially satisfied. We hence assume ∣ S ∣ > 1 |S| > 1 ∣ S ∣ > 1 . We prove separately that the surrogate and exact projection criteria are strictly improved whenever a candidate t t t is replaced by a candidate t ′ t' t ′ satisfying y ^ t ′ > y ^ t \hat{y}_{t'} > \hat{y}_{t} y ^ t ′ > y ^ t ; the case y ^ t ′ = y ^ t \hat{y}_{t'} = \hat{y}_{t} y ^ t ′ = y ^ t is treated at the end of the proof.
Exact fixed-point solution. Suppose by contradiction that t = argmin s ∈ S ∥ z s − y ^ ∥ 2 2 t = \underset{s \in S}{\operatorname{argmin}}\left\|\mathbf{z}^{s}-\hat{\mathbf{y}}\right\|_{2}^{2} t = s ∈ S argmin ∥ z s − y ^ ∥ 2 2 satisfies y ^ t < max s ∈ S y ^ s \hat{y}_{t} < \max_{s \in S}\hat{y}_{s} y ^ t < max s ∈ S y ^ s . Then there exists t ′ ∈ S t' \in S t ′ ∈ S such that y ^ t ′ > y ^ t \hat{y}_{t'} > \hat{y}_{t} y ^ t ′ > y ^ t .
Given s ∈ S s \in S s ∈ S , let C s = { z ∈ Δ ( [ h ] ) : z s ≥ z j + ϵ , ∀ j ≠ s } C^{s} = \{\mathbf{z} \in\Delta([h]) : z_{s} \ge z_{j} + \epsilon,\ \forall j \ne s\} C s = { z ∈ Δ ([ h ]) : z s ≥ z j + ϵ , ∀ j = s } , be the s s s -selection region, i.e., the subset of Δ ( [ h ] ) \Delta([h]) Δ ([ h ]) in which coordinate s s s is maximal with margin at least ϵ \epsilon ϵ .
Consider an alternative candidate solution to the fixed point system z ˉ t ′ ∈ C t ′ \bar{\mathbf{z}}^{t'} \in C^{t'} z ˉ t ′ ∈ C t ′ constructed from z t \mathbf{z}^{t} z t by swapping the values at the coordinates t t t and t ′ t' t ′ :
z ˉ j t ′ = { z t ′ t , j = t , z t t , j = t ′ , z j t , j ∉ { t , t ′ } . \bar{z}^{t'}_{j} =
\begin{cases}
z^{t}_{t'}, & j=t,\\
z^{t}_{t}, & j=t',\\
z^{t}_{j}, & j \notin\{t,t'\}.
\end{cases} z ˉ j t ′ = ⎩ ⎨ ⎧ z t ′ t , z t t , z j t , j = t , j = t ′ , j ∈ / { t , t ′ } .
We know that z ˉ t ′ ∈ C t ′ \bar{\mathbf{z}}^{t'} \in C^{t'} z ˉ t ′ ∈ C t ′ because by definition of z t \mathbf{z}^{t} z t , z t t ≥ z j t + ϵ z^{t}_{t} \ge z^{t}_{j} + \epsilon z t t ≥ z j t + ϵ , for every j ≠ t j \ne t j = t . For every j ∉ { t ′ , t } j \notin\{t',t\} j ∈ / { t ′ , t } , this implies
z ˉ t ′ t ′ = z t t ≥ z j t + ϵ = z ˉ j t ′ + ϵ , and z ˉ t ′ t ′ = z t t ≥ z t ′ t + ϵ = z ˉ t t ′ + ϵ . \bar{z}^{t'}_{t'} = z^{t}_{t} \ge z^{t}_{j} + \epsilon= \bar{z}^{t'}_{j} + \epsilon,\qquad\text{and}\qquad\bar{z}^{t'}_{t'} = z^{t}_{t} \ge z^{t}_{t'} + \epsilon= \bar{z}^{t'}_{t} + \epsilon. z ˉ t ′ t ′ = z t t ≥ z j t + ϵ = z ˉ j t ′ + ϵ , and z ˉ t ′ t ′ = z t t ≥ z t ′ t + ϵ = z ˉ t t ′ + ϵ .
Since only coordinates t t t and t ′ t' t ′ differ between z ˉ t ′ \bar{\mathbf{z}}^{t'} z ˉ t ′ and z t \mathbf{z}^{t} z t :
∥ z ˉ t ′ − y ^ ∥ 2 2 − ∥ z t − y ^ ∥ 2 2 = ( z t ′ t − y ^ t ) 2 + ( z t t − y ^ t ′ ) 2 − ( z t t − y ^ t ) 2 − ( z t ′ t − y ^ t ′ ) 2 = 2 ( z t t − z t ′ t ) ( y ^ t − y ^ t ′ ) . (32) \begin{aligned}
\left\|\bar{\mathbf{z}}^{t'}-\hat{\mathbf{y}}\right\|_{2}^{2}-\left\|\mathbf{z}^{t}-\hat{\mathbf{y}}\right\|_{2}^{2}
&=(z^{t}_{t'}-\hat{y}_{t})^{2}+(z^{t}_{t}-\hat{y}_{t'})^{2}-(z^{t}_{t}-\hat{y}_{t})^{2}-(z^{t}_{t'}-\hat{y}_{t'})^{2}\\
&=2(z^{t}_{t}-z^{t}_{t'})(\hat{y}_{t}-\hat{y}_{t'}). \tag*{(32)}
\end{aligned} z ˉ t ′ − y ^ 2 2 − z t − y ^ 2 2 = ( z t ′ t − y ^ t ) 2 + ( z t t − y ^ t ′ ) 2 − ( z t t − y ^ t ) 2 − ( z t ′ t − y ^ t ′ ) 2 = 2 ( z t t − z t ′ t ) ( y ^ t − y ^ t ′ ) . (32)
Because
z t t − z t ′ t ≥ ϵ > 0 z^{t}_{t}-z^{t}_{t'} \ge\epsilon> 0 z t t − z t ′ t ≥ ϵ > 0
and
y ^ t − y ^ t ′ < 0 , \hat{y}_{t}-\hat{y}_{t'} < 0, y ^ t − y ^ t ′ < 0 ,
(32) implies
∥ z ˉ t ′ − y ^ ∥ 2 2 < ∥ z t − y ^ ∥ 2 2 . \left\|\bar{\mathbf{z}}^{t'}-\hat{\mathbf{y}}\right\|_{2}^{2}<\left\|\mathbf{z}^{t}-\hat{\mathbf{y}}\right\|_{2}^{2}. z ˉ t ′ − y ^ 2 2 < z t − y ^ 2 2 .
Let z t ′ \mathbf{z}^{t'} z t ′ be the minimizer over C t ′ C^{t'} C t ′ , since z ˉ t ′ ∈ C t ′ \bar{\mathbf{z}}^{t'} \in C^{t'} z ˉ t ′ ∈ C t ′ ,
∥ z t ′ − y ^ ∥ 2 2 ≤ ∥ z ˉ t ′ − y ^ ∥ 2 2 < ∥ z t − y ^ ∥ 2 2 , \left\|\mathbf{z}^{t'}-\hat{\mathbf{y}}\right\|_{2}^{2}\le\left\|\bar{\mathbf{z}}^{t'}-\hat{\mathbf{y}}\right\|_{2}^{2}<\left\|\mathbf{z}^{t}-\hat{\mathbf{y}}\right\|_{2}^{2}, z t ′ − y ^ 2 2 ≤ z ˉ t ′ − y ^ 2 2 < z t − y ^ 2 2 ,
contradicting the assumed optimality of t t t .
Thus, no index with a strictly sub-maximal value of y ^ t \hat{y}_{t} y ^ t can minimize the exact projection distance.
Surrogate solution. For every t ∈ S t \in S t ∈ S and j ∈ A t j \in A^t j ∈ A t , let
r j t = y ^ j − y ^ t + ϵ and α t = z ~ t t − y ^ t = 1 1 + ∣ A t ∣ ∑ j ∈ A t r j t . r_j^t = \hat{y}_j - \hat{y}_t + \epsilon\qquad\text{and}\qquad\alpha_t = \tilde{z}_t^t - \hat{y}_t = \frac{1}{1 + |A^t|}\sum_{j \in A^t} r_j^t. r j t = y ^ j − y ^ t + ϵ and α t = z ~ t t − y ^ t = 1 + ∣ A t ∣ 1 j ∈ A t ∑ r j t .
r j t r_j^t r j t representing the ϵ \epsilon ϵ -margin violation for coordinate j j j . For j ∈ A t j \in A^t j ∈ A t , we have
z ~ j t − y ^ j = z ~ t t − ϵ − y ^ j = α t − r j t , \tilde{z}_j^t - \hat{y}_j = \tilde{z}_t^t - \epsilon- \hat{y}_j = \alpha_t - r_j^t, z ~ j t − y ^ j = z ~ t t − ϵ − y ^ j = α t − r j t ,
while the remaining coordinates are unchanged. Hence,
∥ z ~ t − y ^ ∥ 2 2 = α t 2 + ∑ j ∈ A t ( α t − r j t ) 2 = α t 2 + ∣ A t ∣ α t 2 − ∑ j ∈ A t 2 α t r j t + ∑ j ∈ A t ( r j t ) 2 = 1 1 + ∣ A t ∣ ( ∑ j ∈ A t r j t ) 2 − 2 1 + ∣ A t ∣ ( ∑ j ∈ A t r j t ) 2 + ∑ j ∈ A t ( r j t ) 2 = ∑ j ∈ A t ( r j t ) 2 − 1 1 + ∣ A t ∣ ( ∑ j ∈ A t r j t ) 2 . \begin{aligned}
\lVert\tilde{\mathbf{z}}^t - \hat{\mathbf{y}}\rVert_2^2 = \alpha_t^2 + \sum_{j \in A^t}(\alpha_t-r_j^t)^2 \\
&= \alpha_t^2 + |A^t|\alpha_t^2 - \sum_{j \in A^t}2\alpha_t r_j^t + \sum_{j \in A^t}(r_j^t)^2 \\
&= \frac{1}{1+|A^t|}\left(\sum_{j \in A^t}r_j^t\right)^2 - \frac{2}{1+|A^t|}\left(\sum_{j \in A^t}r_j^t\right)^2 + \sum_{j \in A^t}(r_j^t)^2 \\
&= \sum_{j \in A^t}(r_j^t)^2 - \frac{1}{1+|A^t|}\left(\sum_{j \in A^t}r_j^t\right)^2.
\end{aligned} ∥ z ~ t − y ^ ∥ 2 2 = α t 2 + j ∈ A t ∑ ( α t − r j t ) 2 = α t 2 + ∣ A t ∣ α t 2 − j ∈ A t ∑ 2 α t r j t + j ∈ A t ∑ ( r j t ) 2 = 1 + ∣ A t ∣ 1 j ∈ A t ∑ r j t 2 − 1 + ∣ A t ∣ 2 j ∈ A t ∑ r j t 2 + j ∈ A t ∑ ( r j t ) 2 = j ∈ A t ∑ ( r j t ) 2 − 1 + ∣ A t ∣ 1 j ∈ A t ∑ r j t 2 .
The above equation is equivalent to the computational formula of the sum of squares over the multiset Q t = { r j t : j ∈ A t } ⊎ { r t t } Q^t = \{r_j^t : j \in A^t\} \uplus\{r_t^t\} Q t = { r j t : j ∈ A t } ⊎ { r t t } with r t t = 0 r_t^t = 0 r t t = 0 , defined as:
SS ( Q t ) = ∑ q ∈ Q t ( q − q ˉ ) 2 . \operatorname{SS}(Q^t) = \sum_{q \in Q^t}(q-\bar{q})^2. SS ( Q t ) = q ∈ Q t ∑ ( q − q ˉ ) 2 .
Q t Q^t Q t can be interpreted as the multiset of displacement terms associated with the coordinates modified by the surrogate (i.e., those in A t A^t A t and t t t ) when removing the shared displacement z ~ t t − y ^ t \tilde{z}_t^t-\hat{y}_t z ~ t t − y ^ t .
Consider t , t ′ ∈ S t,t' \in S t , t ′ ∈ S such that
y ^ t ′ > y ^ t , d = y ^ t ′ − y ^ t > 0. \hat{y}_{t'} > \hat{y}_t,\qquad d=\hat{y}_{t'}-\hat{y}_t>0. y ^ t ′ > y ^ t , d = y ^ t ′ − y ^ t > 0.
Since ϵ → 0 + \epsilon\to0^+ ϵ → 0 + , we may assume that ϵ < d \epsilon<d ϵ < d . The corresponding active sets satisfy
A t ′ ⊆ A t , t ∉ A t ′ , t ′ ∈ A t . A^{t'} \subseteq A^t,\qquad t \notin A^{t'},\qquad t' \in A^t. A t ′ ⊆ A t , t ∈ / A t ′ , t ′ ∈ A t .
Additionally, for every j ∈ A t ′ j \in A^{t'} j ∈ A t ′ ,
r j t = y ^ j − y ^ t + ϵ = r j t ′ + d , r_j^t=\hat{y}_j-\hat{y}_t+\epsilon=r_j^{t'}+d, r j t = y ^ j − y ^ t + ϵ = r j t ′ + d ,
while
r t ′ t = d + ϵ . r_{t'}^t=d+\epsilon. r t ′ t = d + ϵ .
Let
P = Q t ′ + d = { r j t ′ + d : j ∈ A t ′ } ⊎ { d } , \mathcal{P}=Q^{t'}+d=\{r_j^{t'}+d:j\in A^{t'}\}\uplus\{d\}, P = Q t ′ + d = { r j t ′ + d : j ∈ A t ′ } ⊎ { d } ,
where Q t ′ + d Q^{t'}+d Q t ′ + d denotes the multiset obtained by adding d d d to each element of Q t ′ Q^{t'} Q t ′ . Since the sum of squared deviations is translation invariant,
SS ( P ) = SS ( Q t ′ ) . \operatorname{SS}(\mathcal{P})=\operatorname{SS}(Q^{t'}). SS ( P ) = SS ( Q t ′ ) .
We next relate P \mathcal{P} P to Q t Q^t Q t by introducing a new multiset R \mathcal{R} R obtained by removing the element d ∈ P d\in\mathcal{P} d ∈ P and adding the two elements 0 0 0 and d + ϵ d+\epsilon d + ϵ :
R = ( P ∖ { d } ) ⊎ { 0 , d + ϵ } . \mathcal{R}=(\mathcal{P}\setminus\{d\})\uplus\{0,d+\epsilon\}. R = ( P ∖ { d }) ⊎ { 0 , d + ϵ } .
The element 0 0 0 is the residual associated with the candidate coordinate t t t , whereas d + ϵ = r t ′ t d+\epsilon=r_{t'}^t d + ϵ = r t ′ t . The goal is to show that
SS ( Q t ) ≥ SS ( R ) > SS ( P ) = SS ( Q t ′ ) . \operatorname{SS}(Q^t)\geq\operatorname{SS}(\mathcal{R})>\operatorname{SS}(\mathcal{P})=\operatorname{SS}(Q^{t'}). SS ( Q t ) ≥ SS ( R ) > SS ( P ) = SS ( Q t ′ ) .
Let n = ∣ P ∣ n = |\mathcal{P}| n = ∣ P ∣ and s = ∑ q ∈ P q s = \sum_{q\in\mathcal{P}} q s = ∑ q ∈ P q . Since d ∈ P d \in\mathcal{P} d ∈ P and all its other elements are at least d d d , we have s ≥ n d s \ge nd s ≥ n d . Using the computational formula of the sum of squares we obtain
SS ( R ) − SS ( P ) = ( d + ϵ ) 2 − d 2 − ( s + ϵ ) 2 n + 1 + s 2 n = s 2 − 2 n ϵ s + 2 n ( n + 1 ) d ϵ + n 2 ϵ 2 n ( n + 1 ) . \begin{aligned}
\operatorname{SS}(\mathcal{R})-\operatorname{SS}(\mathcal{P}) &= (d+\epsilon)^2-d^2-\frac{(s+\epsilon)^2}{n+1}+\frac{s^2}{n}\\
&=\frac{s^2-2n\epsilon s+2n(n+1)d\epsilon+n^2\epsilon^2}{n(n+1)}.
\end{aligned} SS ( R ) − SS ( P ) = ( d + ϵ ) 2 − d 2 − n + 1 ( s + ϵ ) 2 + n s 2 = n ( n + 1 ) s 2 − 2 n ϵs + 2 n ( n + 1 ) d ϵ + n 2 ϵ 2 .
The numerator is increasing in s s s for s ≥ n ϵ s \ge n\epsilon s ≥ n ϵ , and s ≥ n d > n ϵ s \ge nd > n\epsilon s ≥ n d > n ϵ since d > ϵ d > \epsilon d > ϵ ; hence it is minimised at s = n d s=nd s = n d , giving
SS ( R ) − SS ( P ) ≥ n d 2 + 2 d ϵ + n ϵ 2 n + 1 > 0. \operatorname{SS}(\mathcal{R})-\operatorname{SS}(\mathcal{P}) \ge\frac{nd^2+2d\epsilon+n\epsilon^2}{n+1}>0. SS ( R ) − SS ( P ) ≥ n + 1 n d 2 + 2 d ϵ + n ϵ 2 > 0.
Finally, Q t Q^t Q t is obtained from R \mathcal{R} R by adding the residuals
{ r j t : j ∈ A t ∖ ( A t ′ ∪ { t ′ } ) } . \{r_j^t:j\in\mathcal{A}^t\setminus(\mathcal{A}^{t'}\cup\{t'\})\}. { r j t : j ∈ A t ∖ ( A t ′ ∪ { t ′ })} .
Adding an element to a multiset cannot decrease its sum of squared deviations: if Q Q Q has cardinality m m m and mean q ‾ \overline{q} q , then
SS ( Q ⊎ { x } ) = SS ( Q ) + m m + 1 ( x − q ‾ ) 2 ≥ SS ( Q ) . \operatorname{SS}(Q\uplus\{x\})=\operatorname{SS}(Q)+\frac{m}{m+1}(x-\overline{q})^2\ge\operatorname{SS}(Q). SS ( Q ⊎ { x }) = SS ( Q ) + m + 1 m ( x − q ) 2 ≥ SS ( Q ) .
Consequently,
SS ( Q t ) ≥ SS ( R ) > SS ( P ) = SS ( Q t ′ ) . \operatorname{SS}(Q^t)\ge\operatorname{SS}(\mathcal{R})>\operatorname{SS}(\mathcal{P})=\operatorname{SS}(Q^{t'}). SS ( Q t ) ≥ SS ( R ) > SS ( P ) = SS ( Q t ′ ) .
Equivalently,
∥ z ~ t ′ − y ^ ∥ 2 2 < ∥ z ~ t − y ^ ∥ 2 2 . \lVert\widetilde{z}^{t'}-\widehat{y}\rVert_2^2<\lVert\widetilde{z}^{t}-\widehat{y}\rVert_2^2. ∥ z t ′ − y ∥ 2 2 < ∥ z t − y ∥ 2 2 .
Thus, no candidate t t t with a strictly sub-maximal value y ^ t \widehat{y}_t y t can minimise the surrogate projection distance.
Notice that if y ^ t = y ^ t ′ \widehat{y}_t=\widehat{y}_{t'} y t = y t ′ , exchanging the coordinates t t t and t ′ t' t ′ leaves both projection distances unchanged. Hence,
∥ z t − y ^ ∥ 2 2 = ∥ z t ′ − y ^ ∥ 2 2 \lVert z^t-\widehat{y}\rVert_2^2=\lVert z^{t'}-\widehat{y}\rVert_2^2 ∥ z t − y ∥ 2 2 = ∥ z t ′ − y ∥ 2 2
and
∥ z ~ t − y ^ ∥ 2 2 = ∥ z ~ t ′ − y ^ ∥ 2 2 . \lVert\widetilde{z}^{t}-\widehat{y}\rVert_2^2=\lVert\widetilde{z}^{t'}-\widehat{y}\rVert_2^2. ∥ z t − y ∥ 2 2 = ∥ z t ′ − y ∥ 2 2 .
The same candidate is therefore selected by all three operators according to the common deterministic tie-breaking policy specified in Footnote 1.
Putting our results together we obtain that:
argmin t ∈ S ∥ z t − y ^ ∥ 2 2 = argmin t ∈ S ∥ z ~ t − y ^ ∥ 2 2 = argmax t ∈ S y ^ t . \underset{t\in\mathcal{S}}{\operatorname{argmin}}\ \lVert z^t-\widehat{y}\rVert_2^2
=
\underset{t\in\mathcal{S}}{\operatorname{argmin}}\ \lVert\widetilde{z}^{t}-\widehat{y}\rVert_2^2
=
\underset{t\in\mathcal{S}}{\operatorname{argmax}}\ \widehat{y}_t. t ∈ S argmin ∥ z t − y ∥ 2 2 = t ∈ S argmin ∥ z t − y ∥ 2 2 = t ∈ S argmax y t .
Proof of Theorem 4
Statement. Let z t z^t z t be the solution of the fixed point system (4), z ~ t \widetilde{z}^t z t defined as in (6) , and W t = A t ∖ M t \mathcal{W}^t=\mathcal{A}^t\setminus\mathcal{M}^t W t = A t ∖ M t . For each j ∈ W t j\in\mathcal{W}^t j ∈ W t , let g j = z t − ϵ − y ^ j g_j=z^t-\epsilon-\widehat{y}_j g j = z t − ϵ − y j . Then
∥ z ~ t − z t ∥ 2 2 = ∑ j ∈ W t g j 2 − 1 1 + ∣ A t ∣ ( ∑ j ∈ W t g j ) 2 . (33) \lVert\widetilde{z}^t-z^t\rVert_2^2=\sum_{j\in\mathcal{W}^t}g_j^2-\frac{1}{1+|\mathcal{A}^t|}\left(\sum_{j\in\mathcal{W}^t}g_j\right)^2. \tag*{(33)} ∥ z t − z t ∥ 2 2 = j ∈ W t ∑ g j 2 − 1 + ∣ A t ∣ 1 j ∈ W t ∑ g j 2 . (33)
Proof. Let W t = A t ∖ M t \mathcal{W}^t=\mathcal{A}^t\setminus\mathcal{M}^t W t = A t ∖ M t denote the spuriously included indices, with cardinality w = ∣ W t ∣ w=|\mathcal{W}^t| w = ∣ W t ∣ . Let m = ∣ M t ∣ m=|\mathcal{M}^t| m = ∣ M t ∣ , a = ∣ A t ∣ = m + w a=|\mathcal{A}^t|=m+w a = ∣ A t ∣ = m + w . Write M = ∑ k ∈ M t y ^ k M=\sum_{k\in\mathcal{M}^t}\widehat{y}_k M = ∑ k ∈ M t y k and G = ∑ j ∈ W t g j G=\sum_{j\in\mathcal{W}^t}g_j G = ∑ j ∈ W t g j , where g j = z t − ϵ − y ^ j g_j=z^t-\epsilon-\widehat{y}_j g j = z t − ϵ − y j for j ∈ W t j\in\mathcal{W}^t j ∈ W t .
The two solutions read
z t t = y ^ t + M + m ϵ 1 + m , z ~ t t = y ^ t + M + ∑ k ∈ W t y ^ k + a ϵ 1 + a , z_t^t=\frac{\widehat{y}_t+M+m\epsilon}{1+m},\qquad
\widetilde{z}_t^t=\frac{\widehat{y}_t+M+\sum_{k\in\mathcal{W}^t}\widehat{y}_k+a\epsilon}{1+a}, z t t = 1 + m y t + M + m ϵ , z t t = 1 + a y t + M + ∑ k ∈ W t y k + a ϵ ,
z j t = z ~ j t = y ^ j for j ∉ A t ∪ { t } , z_j^t=\widetilde{z}_j^t=\widehat{y}_j\qquad\text{for }j\notin\mathcal{A}^t\cup\{t\}, z j t = z j t = y j for j ∈ / A t ∪ { t } ,
z j t = z t t − ϵ z ~ j = z ~ t − ϵ for j ∈ M t z_j^t = z_t^t-\epsilon\qquad\widetilde{z}_j=\widetilde{z}_t-\epsilon\qquad\text{for }j\in\mathcal{M}^t z j t = z t t − ϵ z j = z t − ϵ for j ∈ M t
z j t = y ^ j z ~ j = z ~ t − ϵ for j ∈ W t z_j^t=\widehat{y}_j \qquad\widetilde{z}_j=\widetilde{z}_t-\epsilon\qquad\text{for }j\in\mathcal{W}^t z j t = y j z j = z t − ϵ for j ∈ W t
We now proceed in calculating the difference for each coordinate.
Let us consider the difference at j = t j=t j = t . Since y ^ t + M = ( 1 + m ) z t t − m ϵ \widehat{y}_t+M=(1+m)z_t^t-m\epsilon y t + M = ( 1 + m ) z t t − m ϵ we can simplify the expression for z ~ t t \widetilde{z}_t^t z t t as
z ~ t t − z t t = ( 1 + m ) z t t − m ϵ + ∑ k ∈ W t y ^ k + a ϵ 1 + a − z t t = ( 1 + m ) z t t − z t t ( 1 + a ) + ∑ k ∈ W t y ^ k + w ϵ 1 + a = − w z t t + ∑ k ∈ W t y ^ k + w ϵ 1 + a = − ∑ k ∈ W t ( z t t − ϵ − y ^ k ) 1 + a = − G 1 + a . \begin{aligned}
\widetilde{z}_t^t-z_t^t=\frac{(1+m)z_t^t-m\epsilon+\sum_{k\in\mathcal{W}^t}\widehat{y}_k+a\epsilon}{1+a}-z_t^t \\
&=\frac{(1+m)z_t^t-z_t^t(1+a)+\sum_{k\in\mathcal{W}^t}\widehat{y}_k+w\epsilon}{1+a} \\
&=\frac{-wz_t^t+\sum_{k\in\mathcal{W}^t}\widehat{y}_k+w\epsilon}{1+a} \\
&=-\frac{\sum_{k\in\mathcal{W}^t}(z_t^t-\epsilon-\widehat{y}_k)}{1+a}=-\frac{G}{1+a}.
\end{aligned} z t t − z t t = 1 + a ( 1 + m ) z t t − m ϵ + ∑ k ∈ W t y k + a ϵ − z t t = 1 + a ( 1 + m ) z t t − z t t ( 1 + a ) + ∑ k ∈ W t y k + w ϵ = 1 + a − w z t t + ∑ k ∈ W t y k + w ϵ = − 1 + a ∑ k ∈ W t ( z t t − ϵ − y k ) = − 1 + a G .
For j ∉ A t ∪ { t } j\notin\mathcal{A}^t\cup\{t\} j ∈ / A t ∪ { t } the difference is zero.
For j ∈ M t j\in\mathcal{M}^t j ∈ M t ,
z ~ j t − z j t = [ z ~ t t − ϵ ] − [ z t t − ϵ ] = z ~ t t − z t t = − G 1 + a . \widetilde{z}_j^t-z_j^t=[\widetilde{z}_t^t-\epsilon]-[z_t^t-\epsilon]=\widetilde{z}_t^t-z_t^t=-\frac{G}{1+a}. z j t − z j t = [ z t t − ϵ ] − [ z t t − ϵ ] = z t t − z t t = − 1 + a G .
For j ∈ W t j\in\mathcal{W}^t j ∈ W t ,
z ~ j t − z j t = z ~ t t − ϵ − y ^ j = [ z ~ t t − z t t ] + [ z t t − ϵ − y ^ j ] = g j − G 1 + a . \widetilde{z}_j^t-z_j^t=\widetilde{z}_t^t-\epsilon-\widehat{y}_j=[\widetilde{z}_t^t-z_t^t]+[z_t^t-\epsilon-\widehat{y}_j]=g_j-\frac{G}{1+a}. z j t − z j t = z t t − ϵ − y j = [ z t t − z t t ] + [ z t t − ϵ − y j ] = g j − 1 + a G .
Summing squared differences (over { t } \{t\} { t } , M t \mathcal{M}^t M t , and W t \mathcal{W}^t W t ):
∥ z ~ t − z t ∥ 2 2 = G 2 ( 1 + a ) 2 + m ⋅ G 2 ( 1 + a ) 2 + ∑ j ∈ W t ( g j − G 1 + a ) 2 = ( 1 + m ) G 2 ( 1 + a ) 2 + ∑ j ∈ W t g j 2 − 2 G 1 + a ∑ j ∈ W t g j + w G 2 ( 1 + a ) 2 . \begin{aligned}
\lVert\widetilde{z}^t-z^t\rVert_2^2=\frac{G^2}{(1+a)^2}+m\cdot\frac{G^2}{(1+a)^2}+\sum_{j\in\mathcal{W}^t}\left(g_j-\frac{G}{1+a}\right)^2 \\
&=\frac{(1+m)G^2}{(1+a)^2}+\sum_{j\in\mathcal{W}^t}g_j^2-\frac{2G}{1+a}\sum_{j\in\mathcal{W}^t}g_j+\frac{wG^2}{(1+a)^2}.
\end{aligned} ∥ z t − z t ∥ 2 2 = ( 1 + a ) 2 G 2 + m ⋅ ( 1 + a ) 2 G 2 + j ∈ W t ∑ ( g j − 1 + a G ) 2 = ( 1 + a ) 2 ( 1 + m ) G 2 + j ∈ W t ∑ g j 2 − 1 + a 2 G j ∈ W t ∑ g j + ( 1 + a ) 2 w G 2 .
Using ∑ j ∈ W t g j = G \sum_{j\in\mathcal{W}^t}g_j=G ∑ j ∈ W t g j = G and m + w = a m+w=a m + w = a . The total simplifies to
∥ z ~ t − z t ∥ 2 2 = ∑ j ∈ W t g j 2 − 2 G 2 1 + a + G 2 1 + a = ∑ j ∈ W t g j 2 − G 2 1 + a , \lVert\widetilde{z}^t-z^t\rVert_2^2=\sum_{j\in\mathcal{W}^t}g_j^2-\frac{2G^2}{1+a}+\frac{G^2}{1+a}=\sum_{j\in\mathcal{W}^t}g_j^2-\frac{G^2}{1+a}, ∥ z t − z t ∥ 2 2 = j ∈ W t ∑ g j 2 − 1 + a 2 G 2 + 1 + a G 2 = j ∈ W t ∑ g j 2 − 1 + a G 2 ,
which is Equation (8) .
Proof of Corollary 1
Statement. Under the hypotheses of Theorem 4,
∥ z ~ t − z t ∥ 2 ≤ ∥ z ~ t − y ^ ∥ 2 . (34) \lVert\widetilde{z}^t-z^t\rVert_2\leq\lVert\widetilde{z}^t-\widehat{y}\rVert_2. \tag*{(34)} ∥ z t − z t ∥ 2 ≤ ∥ z t − y ∥ 2 . (34)
Proof. We first show that z t z^t z t is the orthogonal projection of y ^ \widehat{y} y onto the affine subspace
V M t = { z ∈ R h : z j = z t − ϵ , j ∈ M t } . V_{\mathcal{M}^t}=\{z\in\mathbb{R}^h:z_j=z_t-\epsilon,\ j\in\mathcal{M}^t\}. V M t = { z ∈ R h : z j = z t − ϵ , j ∈ M t } .
Substituting the defining constraint into the objective, the projection problem min z ∈ V M t 1 2 ∥ z − y ^ ∥ 2 2 \min_{z\in V_{\mathcal{M}^t}}\frac{1}{2}\lVert z-\widehat{y}\rVert_2^2 min z ∈ V M t 2 1 ∥ z − y ∥ 2 2 reduces to
min z t , { z j } j ∉ M t ∪ { t } 1 2 ( z t − y ^ t ) 2 + 1 2 ∑ j ∈ M t ( z t − ϵ − y ^ j ) 2 + 1 2 ∑ j ∉ M t ∪ { t } ( z j − y ^ j ) 2 \min_{z_t,\{z_j\}_{j\notin\mathcal{M}^t\cup\{t\}}}
\frac{1}{2}(z_t-\widehat{y}_t)^2+\frac{1}{2}\sum_{j\in\mathcal{M}^t}(z_t-\epsilon-\widehat{y}_j)^2+\frac{1}{2}\sum_{j\notin\mathcal{M}^t\cup\{t\}}(z_j-\widehat{y}_j)^2 z t , { z j } j ∈ / M t ∪ { t } min 2 1 ( z t − y t ) 2 + 2 1 j ∈ M t ∑ ( z t − ϵ − y j ) 2 + 2 1 j ∈ / M t ∪ { t } ∑ ( z j − y j ) 2
The free coordinates decouple: z j = y ^ j z_j=\hat{y}_j z j = y ^ j for j ∉ M t ∪ { t } j\notin\mathcal{M}^t\cup\{t\} j ∈ / M t ∪ { t } , and the first-order condition in z t z_t z t yields
z ~ t = y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ 1 + ∣ M t ∣ . \tilde{z}_t=\frac{\hat{y}_t+\sum_{j\in\mathcal{M}^t}\hat{y}_j+|\mathcal{M}^t|\epsilon}{1+|\mathcal{M}^t|}. z ~ t = 1 + ∣ M t ∣ y ^ t + ∑ j ∈ M t y ^ j + ∣ M t ∣ ϵ .
Together with z j = z t − ϵ z_j=z_t-\epsilon z j = z t − ϵ for j ∈ M t j\in\mathcal{M}^t j ∈ M t , this is exactly (15), hence z t \mathbf{z}^t z t is the orthogonal projection of y ^ \hat{\mathbf{y}} y ^ onto V M t V_{\mathcal{M}^t} V M t .
Since M t ⊆ A t \mathcal{M}^t\subseteq\mathcal{A}^t M t ⊆ A t , the approximate solution z ~ t \tilde{\mathbf{z}}^t z ~ t satisfies z ~ j t = z ~ t t − ϵ \tilde{z}^t_j=\tilde{z}^t_t-\epsilon z ~ j t = z ~ t t − ϵ for every j ∈ M t j\in\mathcal{M}^t j ∈ M t , hence z ~ t ∈ V M t \tilde{\mathbf{z}}^t\in V_{\mathcal{M}^t} z ~ t ∈ V M t . The Pythagorean identity for orthogonal projection onto an affine subspace then yields
∥ z ~ t − y ^ ∥ 2 2 = ∥ z ~ t − z t ∥ 2 2 + ∥ z t − y ^ ∥ 2 2 ≥ ∥ z ~ t − z t ∥ 2 2 , \lVert\tilde{\mathbf{z}}^t-\hat{\mathbf{y}}\rVert_2^2=\lVert\tilde{\mathbf{z}}^t-\mathbf{z}^t\rVert_2^2+\lVert\mathbf{z}^t-\hat{\mathbf{y}}\rVert_2^2\geq\lVert\tilde{\mathbf{z}}^t-\mathbf{z}^t\rVert_2^2, ∥ z ~ t − y ^ ∥ 2 2 = ∥ z ~ t − z t ∥ 2 2 + ∥ z t − y ^ ∥ 2 2 ≥ ∥ z ~ t − z t ∥ 2 2 ,
and taking square roots gives (34).
Proof of Corollary 2
Statement. Consider a finite and satisfiable set of signed clauses Π \Pi Π and a variable ordering Y 1 ; … ; Y n Y_1;\ldots;Y_n Y 1 ; … ; Y n . Given y ^ = m θ ( x ) \hat{\mathbf{y}}=m_\theta(\mathbf{x}) y ^ = m θ ( x ) for some x ∈ X \mathbf{x}\in\mathcal{X} x ∈ X , let a ~ ∗ b e t h e a s s i g n m e n t i n d u c e d b y ∗ \tilde{\mathbf{a}} *be the assignment induced by* a ~ ∗ b e t h e a ss i g nm e n t in d u ce d b y ∗ \operatorname{CASPER}(\hat{\mathbf{y}})$, a \mathbf{a} a be the assignment induced by the same procedure when each surrogate projection is replaced by the exact fixed-point projection, and let a ⋆ \mathbf{a}^{\star} a ⋆ be the sequential feasible argmax assignment, a i ⋆ = arg max t ∈ S i ( a < i ⋆ ) y ^ i , t a_i^\star=\arg\max_{t\in S_i(\mathbf{a}_{<i}^\star)}\hat{y}_{i,t} a i ⋆ = arg max t ∈ S i ( a < i ⋆ ) y ^ i , t . Then, for ϵ → 0 + \epsilon\to0^+ ϵ → 0 + : (i) a = a ~ = a ⋆ \mathbf{a}=\tilde{\mathbf{a}}=\mathbf{a}^\star a = a ~ = a ⋆ ; (ii) S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) S_i(\mathbf{a}_{<i})=S_i(\tilde{\mathbf{a}}_{<i})=S_i(\mathbf{a}_{<i}^\star) S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) , ∀ i ∈ [ n ] \forall i\in[n] ∀ i ∈ [ n ] .
Proof. We prove (i) separately for the exact and the surrogate procedures, showing in each case that the assignment produced coincides with a ⋆ \mathbf{a}^\star a ⋆ .
Exact fixed-point solution. For k ∈ [ n ] k\in[n] k ∈ [ n ] , let
P ( k ) : a i = a i ⋆ for all i ≤ k . P(k):\quad a_i=a_i^\star\quad\text{for all }i\leq k. P ( k ) : a i = a i ⋆ for all i ≤ k .
We prove P ( k ) P(k) P ( k ) by induction on k k k , using the following claim.
Claim. Let i ∈ [ n ] i\in[n] i ∈ [ n ] . If a < i = a < i ⋆ \mathbf{a}_{<i}=\mathbf{a}_{<i}^\star a < i = a < i ⋆ , then S i ( a < i ) = S i ( a < i ⋆ ) S_i(\mathbf{a}_{<i})=S_i(\mathbf{a}_{<i}^\star) S i ( a < i ) = S i ( a < i ⋆ ) and a i = a i ⋆ a_i=a_i^\star a i = a i ⋆ .
Proof of the claim. The feasible set S i ( a < i ) S_i(\mathbf{a}_{<i}) S i ( a < i ) is obtained by substituting the preceding assignments a < i \mathbf{a}_{<i} a < i into Π ˉ i \bar{\Pi}_i Π ˉ i (Section 3.2); it depends only on these discrete values and not on the projected vectors computed for Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 . Since a < i = a < i ⋆ \mathbf{a}_{<i}=\mathbf{a}_{<i}^\star a < i = a < i ⋆ , it follows that S i ( a < i ) = S i ( a < i ⋆ ) = : S i S_i(\mathbf{a}_{<i})=S_i(\mathbf{a}_{<i}^\star)=:S_i S i ( a < i ) = S i ( a < i ⋆ ) =: S i , which is non-empty by Lemma 2 (cf. the proof of Theorem 6). Moreover, the projection for Y i Y_i Y i receives the unmodified input y ^ i \hat{\mathbf{y}}_i y ^ i , since the projections for earlier variables do not alter it. Two cases arise.
If arg max j ∈ [ h i ] y ^ i , j ∈ S i \arg\max_{j\in[h_i]}\hat{y}_{i,j}\in S_i arg max j ∈ [ h i ] y ^ i , j ∈ S i , no correction is applied (Section 3.2), so a i = arg max j ∈ [ h i ] y ^ i , j = arg max t ∈ S i y ^ i , t = a i ⋆ a_i=\arg\max_{j\in[h_i]}\hat{y}_{i,j}=\arg\max_{t\in S_i}\hat{y}_{i,t}=a_i^\star a i = arg max j ∈ [ h i ] y ^ i , j = arg max t ∈ S i y ^ i , t = a i ⋆ .
Otherwise, by Theorem 3 applied to input y ^ i \hat{\mathbf{y}}_i y ^ i and constraint { S i : Y i } \{S_i:Y_i\} { S i : Y i } , the candidate selected in (3) is t i ⋆ = arg max t ∈ S i y ^ i , t t_i^\star=\arg\max_{t\in S_i}\hat{y}_{i,t} t i ⋆ = arg max t ∈ S i y ^ i , t . By Theorem 1, t i ⋆ t_i^\star t i ⋆ is the unique maximiser of z t i ⋆ z^{t_i^\star} z t i ⋆ , so a i = t i ⋆ = a i ⋆ a_i=t_i^\star=a_i^\star a i = t i ⋆ = a i ⋆ .
This proves the claim.
Base case (k = 1 k=1 k = 1 ). No variables precede Y 1 Y_1 Y 1 , so a < 1 = a < 1 ⋆ \mathbf{a}_{<1}=\mathbf{a}_{<1}^\star a < 1 = a < 1 ⋆ holds trivially. By the claim with i = 1 i=1 i = 1 , a 1 = a 1 ⋆ a_1=a_1^\star a 1 = a 1 ⋆ . Hence P ( 1 ) P(1) P ( 1 ) holds.
Inductive step. Assume P ( k ) P(k) P ( k ) holds for some k ∈ [ n − 1 ] k\in[n-1] k ∈ [ n − 1 ] , i.e., a < k + 1 = a < k + 1 ⋆ \mathbf{a}_{<k+1}=\mathbf{a}_{<k+1}^\star a < k + 1 = a < k + 1 ⋆ . By the claim with i = k + 1 i=k+1 i = k + 1 , a k + 1 = a k + 1 ⋆ a_{k+1}=a_{k+1}^\star a k + 1 = a k + 1 ⋆ . Together with P ( k ) P(k) P ( k ) , this gives P ( k + 1 ) P(k+1) P ( k + 1 ) .
Conclusion. By induction, P ( n ) P(n) P ( n ) holds, i.e., a = a ⋆ \mathbf{a}=\mathbf{a}^\star a = a ⋆ .
Surrogate solution. Let P ~ ( k ) \tilde{P}(k) P ~ ( k ) be defined as P ( k ) P(k) P ( k ) with a ~ i \tilde{a}_i a ~ i in place of a i a_i a i . The argument above applies verbatim with a ~ \tilde{\mathbf{a}} a ~ in place of a \mathbf{a} a , (6) in place of (3) , z ~ t i ⋆ \tilde{z}^{t_i^\star} z ~ t i ⋆ in place of z t i ⋆ z^{t_i^\star} z t i ⋆ , and Theorem 2 in place of Theorem 1. Theorem 3 again gives t i ⋆ = arg max t ∈ S i y ^ i , t t_i^\star=\arg\max_{t\in S_i}\hat{y}_{i,t} t i ⋆ = arg max t ∈ S i y ^ i , t , now for ϵ → 0 + \epsilon\to0^+ ϵ → 0 + , and Theorem 2 guarantees that t i ⋆ t_i^\star t i ⋆ is the unique maximiser of z ~ t i ⋆ \tilde{z}^{t_i^\star} z ~ t i ⋆ . Hence a ~ = a ⋆ \tilde{\mathbf{a}}=\mathbf{a}^\star a ~ = a ⋆ .
Combining the two cases gives a = a ⋆ = a ~ \mathbf{a}=\mathbf{a}^\star=\tilde{\mathbf{a}} a = a ⋆ = a ~ , which is (i). For (ii), fix i ∈ [ n ] i\in[n] i ∈ [ n ] . By (i), a < i = a ~ < i = a < i ⋆ \mathbf{a}_{<i}=\tilde{\mathbf{a}}_{<i}=\mathbf{a}_{<i}^\star a < i = a ~ < i = a < i ⋆ , and since S i ( ⋅ ) S_i(\cdot) S i ( ⋅ ) depends only on the preceding assignments, S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) S_i(\mathbf{a}_{<i})=S_i(\tilde{\mathbf{a}}_{<i})=S_i(\mathbf{a}_{<i}^\star) S i ( a < i ) = S i ( a ~ < i ) = S i ( a < i ⋆ ) .
Proof of Proposition 1
Statement. Let y ^ ∈ Δ ( [ h ] ) \hat{y} \in\Delta([h]) y ^ ∈ Δ ([ h ]) be such that t ∗ t^* t ∗ and A t ∗ A^{t^*} A t ∗ in (6) are locally constant in a neighbourhood of y ^ \hat{y} y ^ . Let CASPER ( y ^ ) = z ~ t \operatorname{CASPER}(\hat{y}) = \tilde{z}^{t} CASPER ( y ^ ) = z ~ t and V = { v ∈ R h : v j = v t , j ∈ A t } V = \{v \in\mathbb{R}^{h}: v_j = v_t,\ j \in A^{t}\} V = { v ∈ R h : v j = v t , j ∈ A t } . Then the Jacobian J = ∂ z ~ t / ∂ y ^ J = \partial\tilde{z}^{t}/\partial\hat{y} J = ∂ z ~ t / ∂ y ^ is the orthogonal projector P V P_V P V onto V V V . Consequently, for any differentiable downstream loss L t a s k \mathcal{L}_{\mathrm{task}} L task ,
∇ y ^ [ L t a s k ∘ z ~ t ] = P V ∇ z ~ L t a s k , ∥ P V ∇ z ~ L t a s k ∥ 2 ≤ ∥ ∇ z ~ L t a s k ∥ 2 , \nabla_{\hat{y}}[\mathcal{L}_{\mathrm{task}} \circ\tilde{z}^{t}] = P_V \nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}}, \qquad\lVert P_V \nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}}\rVert_2 \le\lVert\nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}}\rVert_2, ∇ y ^ [ L task ∘ z ~ t ] = P V ∇ z ~ L task , ∥ P V ∇ z ~ L task ∥ 2 ≤ ∥ ∇ z ~ L task ∥ 2 ,
with the a a a -dimensional subspace V ⊥ V^\perp V ⊥ annihilated entirely.
Proof. We can follow the same steps as in the proof of Corollary 1 to show that z ~ t \tilde{z}^{t} z ~ t is the orthogonal projection of y ^ \hat{y} y ^ onto the affine subspace V A t = p 0 + V V_{A^t} = p_0 + V V A t = p 0 + V for any p 0 ∈ V A t p_0 \in V_{A^t} p 0 ∈ V A t . Hence z ~ t ( y ^ ) = p 0 + P V ( y ^ − p 0 ) \tilde{z}^{t}(\hat{y}) = p_0 + P_V(\hat{y} - p_0) z ~ t ( y ^ ) = p 0 + P V ( y ^ − p 0 ) , and differentiating gives J = P V J = P_V J = P V .
The chain-rule expression ∇ y ^ [ L t a s k ∘ z ~ t ] = J ⊤ ∇ z ~ t L t a s k = P V ∇ z ~ t L t a s k \nabla_{\hat{y}}[\mathcal{L}_{\mathrm{task}} \circ\tilde{z}^{t}] = J^\top\nabla_{\tilde{z}^{t}}\mathcal{L}_{\mathrm{task}} = P_V\nabla_{\tilde{z}^{t}}\mathcal{L}_{\mathrm{task}} ∇ y ^ [ L task ∘ z ~ t ] = J ⊤ ∇ z ~ t L task = P V ∇ z ~ t L task follows since P V P_V P V is symmetric, and the contraction ∥ P V g ∥ 2 ≤ ∥ g ∥ 2 \lVert P_Vg\rVert_2 \le\lVert g\rVert_2 ∥ P V g ∥ 2 ≤ ∥ g ∥ 2 holds for any g ∈ R h g \in\mathbb{R}^{h} g ∈ R h and orthogonal projector.
The coordinate-wise formula comes from the explicit form ( P V ) j k = 1 1 + a 1 { j , k ∈ A t ∪ { t } } + δ j k 1 { j ∉ A t ∪ { t } } (P_V)_{jk} = \frac{1}{1+a}\mathbf{1}_{\{j,k\in A^t\cup\{t\}\}} + \delta_{jk}\mathbf{1}_{\{j\notin A^t\cup\{t\}\}} ( P V ) j k = 1 + a 1 1 { j , k ∈ A t ∪ { t }} + δ j k 1 { j ∈ / A t ∪ { t }} :
∂ L t a s k ∂ y ^ k = { ∂ L t a s k ∂ z ~ k t k ∉ A t ∪ { t } , 1 1 + ∣ A t ∣ ( ∂ L t a s k ∂ z ~ t t + ∑ j ∈ A t ∂ L t a s k ∂ z ~ j t ) k ∈ A t ∪ { t } . \frac{\partial\mathcal{L}_{\mathrm{task}}}{\partial\hat{y}_k} =
\begin{cases}
\frac{\partial\mathcal{L}_{\mathrm{task}}}{\partial\tilde{z}^{t}_k} & k \notin A^t \cup\{t\},\\
\frac{1}{1+\lvert A^t\rvert}\left(\frac{\partial\mathcal{L}_{\mathrm{task}}}{\partial\tilde{z}^{t}_t}+\sum_{j\in A^t}\frac{\partial\mathcal{L}_{\mathrm{task}}}{\partial\tilde{z}^{t}_j}\right) & k \in A^t \cup\{t\}.
\end{cases} ∂ y ^ k ∂ L task = ⎩ ⎨ ⎧ ∂ z ~ k t ∂ L task 1 + ∣ A t ∣ 1 ( ∂ z ~ t t ∂ L task + ∑ j ∈ A t ∂ z ~ j t ∂ L task ) k ∈ / A t ∪ { t } , k ∈ A t ∪ { t } .
Proof of Proposition 2
Statement. Under the assumptions of Proposition 1, consider the composite training objective
L t o t a l ( y ^ ) = L t a s k ( z ~ t ( y ^ ) ) + λ 2 ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 , λ > 0. \mathcal{L}_{\mathrm{total}}(\hat{y}) = \mathcal{L}_{\mathrm{task}}(\tilde{z}^{t}(\hat{y})) + \frac{\lambda}{2}\lVert\tilde{z}^{t}(\hat{y})-\hat{y}\rVert_2^2,\qquad\lambda>0. L total ( y ^ ) = L task ( z ~ t ( y ^ )) + 2 λ ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 , λ > 0.
Then
∇ y ^ L t o t a l = P V ∇ z ~ L t a s k ⏟ ∈ V + λ ( y ^ − z ~ t ) ⏟ ∈ V ⊥ . \nabla_{\hat{y}}\mathcal{L}_{\mathrm{total}} =
\underbrace{P_V\nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}}}_{\in V}
+
\underbrace{\lambda(\hat{y}-\tilde{z}^{t})}_{\in V^\perp}. ∇ y ^ L total = ∈ V P V ∇ z ~ L task + ∈ V ⊥ λ ( y ^ − z ~ t ) .
Proof. The task contribution is P V ∇ z ~ L t a s k P_V\nabla_{\tilde{z}}\mathcal{L}_{\mathrm{task}} P V ∇ z ~ L task by Proposition 1. Let ϕ ( y ^ ) = 1 2 ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 \phi(\hat{y})=\frac{1}{2}\lVert\tilde{z}^{t}(\hat{y})-\hat{y}\rVert_2^2 ϕ ( y ^ ) = 2 1 ∥ z ~ t ( y ^ ) − y ^ ∥ 2 2 and apply the chain rule:
∇ y ^ ϕ = ∂ ϕ ∂ z ~ t ∂ z ~ t ∂ y ^ + ∂ ϕ ∂ y ^ = ( J − I ) ⊤ ( z ~ t − y ^ ) = ( P V − I ) ( z ~ t − y ^ ) = y ^ − z ~ t , \nabla_{\hat{y}}\phi=
\frac{\partial\phi}{\partial\tilde{z}^{t}}\frac{\partial\tilde{z}^{t}}{\partial\hat{y}}+\frac{\partial\phi}{\partial\hat{y}}
=(J-I)^\top(\tilde{z}^{t}-\hat{y})
=(P_V-I)(\tilde{z}^{t}-\hat{y})
=\hat{y}-\tilde{z}^{t}, ∇ y ^ ϕ = ∂ z ~ t ∂ ϕ ∂ y ^ ∂ z ~ t + ∂ y ^ ∂ ϕ = ( J − I ) ⊤ ( z ~ t − y ^ ) = ( P V − I ) ( z ~ t − y ^ ) = y ^ − z ~ t ,
where the last equality uses y ^ − z ~ t ∈ V ⊥ \hat{y}-\tilde{z}^{t}\in V^\perp y ^ − z ~ t ∈ V ⊥ (residual orthogonality of the projection in Proposition 1), so P V ( y ^ − z ~ t ) = 0 P_V(\hat{y}-\tilde{z}^{t})=0 P V ( y ^ − z ~ t ) = 0 .
Proof of Lemma 2
Statement. Let Π i \Pi_i Π i be a finite and satisfiable set of signed clauses in the variables Y 1 , … , Y i Y_1,\ldots,Y_i Y 1 , … , Y i . Then Π i \Pi_i Π i and Π i − 1 \Pi_{i-1} Π i − 1 are equisatisfiable, and each assignment to Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 satisfying Π i − 1 \Pi_{i-1} Π i − 1 can be extended to satisfy Π i \Pi_i Π i .
Proof. Forward direction. If Π i \Pi_i Π i is satisfiable then Π i − 1 \Pi_{i-1} Π i − 1 is satisfiable. Indeed, every clause in Confli ( Π ‾ i ) \operatorname{Confli}(\overline{\Pi}_i) Confli ( Π i ) is derived from Π ‾ i ⊆ Π i \overline{\Pi}_i\subseteq\Pi_i Π i ⊆ Π i via the intersection rule ((9) ), hence it is entailed by Π i \Pi_i Π i . Combined with Π i ∖ Π ‾ i ⊆ Π i \Pi_i\setminus\overline{\Pi}_i\subseteq\Pi_i Π i ∖ Π i ⊆ Π i , (10) yields Π i ⊨ Π i − 1 \Pi_i\models\Pi_{i-1} Π i ⊨ Π i − 1 ; in particular, if a ⊨ Π i a\models\Pi_i a ⊨ Π i then its restriction a < i a_{<i} a < i (i.e., the assignment a a a restricted over the variables Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 ) satisfies Π i − 1 \Pi_{i-1} Π i − 1 , since the latter is over Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 .
Backward direction. Let Π ‾ i = { ( S j : Y i ) ∨ φ j } j = 1 m \overline{\Pi}_i=\{(S_j:Y_i)\lor\varphi_j\}_{j=1}^{m} Π i = {( S j : Y i ) ∨ φ j } j = 1 m collect the clauses of Π i \Pi_i Π i mentioning Y i Y_i Y i , with each φ j \varphi_j φ j a signed clause over Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 . Let a < i ⊨ Π i − 1 a_{<i}\models\Pi_{i-1} a < i ⊨ Π i − 1 , and assume for contradiction that no a i ∈ [ h i ] a_i\in[h_i] a i ∈ [ h i ] satisfies ( a < i , a i ) ⊨ Π i (a_{<i},a_i)\models\Pi_i ( a < i , a i ) ⊨ Π i . Substituting a < i a_{<i} a < i into the clauses of Π i \Pi_i Π i : clauses in Π i ∖ Π ‾ i \Pi_i \setminus\overline{\Pi}_i Π i ∖ Π i are over Y 1 , … , Y i − 1 Y_1,\ldots,Y_{i-1} Y 1 , … , Y i − 1 and lie in Π i − 1 \Pi_{i-1} Π i − 1 , hence are satisfied by a < i a_{<i} a < i ; each clause ( S j : Y i ) ∨ φ j ∈ Π ‾ i (S_j:Y_i)\lor\varphi_j\in\overline{\Pi}_i ( S j : Y i ) ∨ φ j ∈ Π i reduces to ( S j : Y i ) (S_j:Y_i) ( S j : Y i ) if a < i ⊭ φ j a_{<i}\not\models\varphi_j a < i ⊨ φ j , and to a tautology otherwise. Define
K = { j ∈ [ m ] : a < i ⊭ φ j } , Π ‾ i ( a < i ) = { ( S k : Y i ) : k ∈ K } . \mathcal{K}=\{j\in[m]:a_{<i}\not\models\varphi_j\},\qquad\overline{\Pi}_i(a_{<i})=\{(S_k:Y_i):k\in\mathcal{K}\}. K = { j ∈ [ m ] : a < i ⊨ φ j } , Π i ( a < i ) = {( S k : Y i ) : k ∈ K } .
By assumption, no a i a_i a i satisfies Π ‾ i ( a < i ) \overline{\Pi}_i(a_{<i}) Π i ( a < i ) . If K = ∅ \mathcal{K}=\emptyset K = ∅ , any a i ∈ [ h i ] a_i\in[h_i] a i ∈ [ h i ] would do, contradicting the assumption; hence K ≠ ∅ \mathcal{K}\ne\emptyset K = ∅ and ⋂ k ∈ K S k = ∅ \bigcap_{k\in\mathcal{K}}S_k=\emptyset ⋂ k ∈ K S k = ∅ .
By Equation (11) , K \mathcal{K} K witnesses a clause
ψ = ⋁ k ∈ K φ k ∈ Confl i ( Π ‾ i ) ⊆ Π i − 1 . \psi=\bigvee_{k\in\mathcal{K}}\varphi_k\in\operatorname{Confl}_i(\overline{\Pi}_i)\subseteq\Pi_{i-1}. ψ = k ∈ K ⋁ φ k ∈ Confl i ( Π i ) ⊆ Π i − 1 .
Every k ∈ K k\in\mathcal{K} k ∈ K has a < i ⊭ φ k a_{<i}\not\models\varphi_k a < i ⊨ φ k by definition of K \mathcal{K} K , so a < i ⊭ ψ a_{<i}\not\models\psi a < i ⊨ ψ , contradicting a < i ⊨ Π i − 1 a_{<i}\models\Pi_{i-1} a < i ⊨ Π i − 1 . Hence some a i ∈ [ h i ] a_i\in[h_i] a i ∈ [ h i ] satisfies ( a < i , a i ) ⊨ Π i (a_{<i},a_i)\models\Pi_i ( a < i , a i ) ⊨ Π i , which proves the extension claim. Equisatisfiability follows.
Proof of Theorem 5
Statement. Let Π \Pi Π be a finite set of r r r signed clauses over the variables Y 1 , … , Y n Y_1,\ldots,Y_n Y 1 , … , Y n , k = max i ∈ [ n ] h i k=\max_{i\in[n]}h_i k = max i ∈ [ n ] h i and w ( d ) w^{(d)} w ( d ) the conflict width of Π \Pi Π along the ordering d = Y 1 ; … ; Y n d=Y_1;\ldots;Y_n d = Y 1 ; … ; Y n . COMPILE( Π , Y 1 ; … ; Y n ) (\Pi,Y_1;\ldots;Y_n) ( Π , Y 1 ; … ; Y n ) in Algorithm 1 can be implemented to run in time O ( ( r + n ) ⋅ k w ( d ) + 1 ) O((r+n)\cdot k^{w^{(d)}+1}) O (( r + n ) ⋅ k w ( d ) + 1 ) and space O ( n ⋅ k w ( d ) ) O(n\cdot k^{w^{(d)}}) O ( n ⋅ k w ( d ) ) .
Proof. The proof proceeds by reducing COMPILE to bucket elimination [13 ] . This suffices to prove the claim, as the latter has worst case time complexity linear in r + n r+n r + n and space linear in n n n , while both grow exponentially — with base k k k — in the induced width w ∗ ( d ) w^{*}(d) w ∗ ( d ) of the variable interaction graph associated to a signed-CNF constraint set Π \Pi Π , along an ordering d d d . Since in our case G Π ∗ ( d ) G_{\Pi}^{*}(d) G Π ∗ ( d ) is defined as the induced graph of G Π G_{\Pi} G Π along d d d in the same way as [14 ] , then our conflict width coincides with the induced width.
In particular, we reduce the compilation step of CASPER in Equations (10) and (11) to the bucket elimination algorithm for belief updating over Bayesian networks in [14 ] , Fig. 4.5. The proof comprises three parts:
the encoding of the COMPILE routine in the bucket elimination framework of [13 ] ;
the reduction; and
the transfer of the time and space bounds from bucket elimination to COMPILE.
Together these show that COMPILE admits the same worst-case time and space complexity bounds as classical problems solvable through bucket elimination, like adaptive consistency and directional resolution [13 ] .
Relational Encoding. Consider a set of variables U = { Y j 1 , … , Y j m } ⊆ Y U=\{Y_{j_1},\ldots,Y_{j_m}\}\subseteq Y U = { Y j 1 , … , Y j m } ⊆ Y with j 1 < ⋯ < j m j_1<\cdots<j_m j 1 < ⋯ < j m ordered along the chosen d d d ; let Y U = [ h j 1 ] × ⋯ × [ h j m ] \mathcal{Y}_U=[h_{j_1}]\times\cdots\times[h_{j_m}] Y U = [ h j 1 ] × ⋯ × [ h j m ] and let u = ( u j 1 , … , u j m ) ∈ Y U \mathbf{u}=(u_{j_1},\ldots,u_{j_m})\in\mathcal{Y}_U u = ( u j 1 , … , u j m ) ∈ Y U be an assignment of the values in Y U \mathcal{Y}_U Y U to variables in U U U . For a signed clause φ \varphi φ so that scope ( φ ) ⊆ U \operatorname{scope}(\varphi)\subseteq U scope ( φ ) ⊆ U , we say that u \mathbf{u} u satisfies it, written as u ⊨ φ \mathbf{u}\models\varphi u ⊨ φ , if it exists a literal ℓ = ( S j : Y j ) ∈ φ \ell=(S_j:Y_j)\in\varphi ℓ = ( S j : Y j ) ∈ φ for which it holds that u j ∈ S j u_j\in S_j u j ∈ S j . We can now encode each signed clause φ \varphi φ by the relation R φ = { u ∈ Y scope ( φ ) ∣ u ⊨ φ } R_\varphi=\{\mathbf{u}\in\mathcal{Y}_{\operatorname{scope}(\varphi)}\mid\mathbf{u}\models\varphi\} R φ = { u ∈ Y scope ( φ ) ∣ u ⊨ φ } . For any two relations R ⊆ Y U R\subseteq\mathcal{Y}_U R ⊆ Y U and R ′ ⊆ Y U ′ R'\subseteq\mathcal{Y}_{U'} R ′ ⊆ Y U ′ , their natural join is the relation R ⋈ R ′ = { u ∈ Y U ∪ U ′ ∣ u U ∈ R , u U ′ ∈ R ′ } R\bowtie R'=\{\mathbf{u}\in\mathcal{Y}_{U\cup U'}\mid\mathbf{u}_U\in R,\mathbf{u}_{U'}\in R'\} R ⋈ R ′ = { u ∈ Y U ∪ U ′ ∣ u U ∈ R , u U ′ ∈ R ′ } , where u U \mathbf{u}_U u U and u U ′ \mathbf{u}_{U'} u U ′ denote the restriction of u \mathbf{u} u to the variables in U U U and U ′ U' U ′ respectively. On the other hand, for V ⊆ U V\subseteq U V ⊆ U , the projection of R R R onto V V V is π V ( R ) = { u V ∣ u ∈ R } \pi_V(R)=\{\mathbf{u}_V\mid\mathbf{u}\in R\} π V ( R ) = { u V ∣ u ∈ R } .
Reduction. Under the relational encoding defined in the previous step, the signed resolution in Equation (9) corresponds to the belief-updating algorithm BE-BEL [14 ] , Fig. 4.5, instantiated over the Boolean relational semiring rather than the sum-product one: indeed, bucket combination can be expressed through the natural join ⋈ \bowtie ⋈ (taking the role of the product), while bucket marginalisation is carried out through the projection operator π \pi π (instead of the sum). These operations still define a commutative semiring, so the general bucket-elimination scheme of [13 ] applies. Table 5 summarizes
Table 5. Correspondence between BE-BEL [14 Fig. 4.5] and COMPILE (Algorithm 1) under the relational encoding at step 1 of the proof.
the correspondence between BE-BEL [14 Fig. 4.5] and COMPILE under the relational encoding we build: the message λ p \lambda_p λ p computed in a bucket corresponds to the conflict clauses set Confl i ( Π ‾ i ) \operatorname{Confl}_i(\overline{\Pi}_i) Confl i ( Π i ) , while the messages λ S 1 , … , λ S j \lambda_{S_1},\ldots,\lambda_{S_j} λ S 1 , … , λ S j it receives correspond to the conflict clauses produced at earlier elimination steps and re-filed into Π ‾ i \overline{\Pi}_i Π i by (10) .
Along the ordering d d d , the bucket of Y i Y_i Y i is the set B i = Π ‾ i ⊆ Π i B_i=\overline{\Pi}_i\subseteq\Pi_i B i = Π i ⊆ Π i of the clauses of Π i \Pi_i Π i in which the variable Y i Y_i Y i appears. Since by (10) the variables Y i + 1 , … , Y n Y_{i+1},\ldots,Y_n Y i + 1 , … , Y n have already been eliminated, then Y i Y_i Y i is the variable occurring in every clause of Π ‾ i \overline{\Pi}_i Π i that comes last along d d d . We call the scope of a bucket B i B_i B i the set of the variables — other than the last one — occurring in it, namely:
scope ( B i ) = ( ⋃ φ ∈ Π ‾ i scope ( φ ) ) ∖ { Y i } . \operatorname{scope}(B_i)=\left(\bigcup_{\varphi\in\overline{\Pi}_i}\operatorname{scope}(\varphi)\right)\setminus\{Y_i\}. scope ( B i ) = φ ∈ Π i ⋃ scope ( φ ) ∖ { Y i } .
Then the per-bucket message computed by BE-BEL in the bucket of Y i Y_i Y i — namely λ i = ∑ Y i ψ i ∏ l λ S l \lambda_i=\sum_{Y_i}\psi_i\prod_l\lambda_{S_l} λ i = ∑ Y i ψ i ∏ l λ S l with ψ i \psi_i ψ i being the product of input functions in the corresponding bucket and — over the Boolean semiring — λ i ( u ) = 1 \lambda_i(u)=1 λ i ( u ) = 1 when some value of Y i Y_i Y i makes every function in the bucket true — becomes the relation π scope ( B i ) ( ⋈ φ ∈ Π ‾ i R φ ) ⊆ Y scope ( B i ) \pi_{\operatorname{scope}(B_i)}(\bowtie_{\varphi\in\overline{\Pi}_i}R_\varphi)\subseteq\mathcal{Y}_{\operatorname{scope}(B_i)} π scope ( B i ) ( ⋈ φ ∈ Π i R φ ) ⊆ Y scope ( B i ) . We remark that joining the bucket for Π ‾ i \overline{\Pi}_i Π i and projecting over its scope rules out the tuples with no consistent value for Y i Y_i Y i : by (11) , these are exactly the tuples falsifying some clause of Confl i ( Π ‾ i ) \operatorname{Confl}_i(\overline{\Pi}_i) Confl i ( Π i ) (cf. the proof of Lemma 2). Therefore, the conflict set Confl i ( Π ‾ i ) \operatorname{Confl}_i(\overline{\Pi}_i) Confl i ( Π i ) from (11) can be equivalently expressed as the set of signed clauses:
{ ⋁ Y j ∈ scope ( B i ) ( [ h j ] ∖ { u j } ) : Y j ∣ u ∈ Y scope ( B i ) ∖ π scope ( B i ) ( ⋈ φ ∈ Π ‾ i R φ ) } . (35) \left\{\bigvee_{Y_j\in\operatorname{scope}(B_i)}([h_j]\setminus\{u_j\}):Y_j\mid u\in\mathcal{Y}_{\operatorname{scope}(B_i)}\setminus\pi_{\operatorname{scope}(B_i)}(\bowtie_{\varphi\in\overline{\Pi}_i}R_\varphi)\right\}. \tag*{(35)} ⎩ ⎨ ⎧ Y j ∈ scope ( B i ) ⋁ ([ h j ] ∖ { u j }) : Y j ∣ u ∈ Y scope ( B i ) ∖ π scope ( B i ) ( ⋈ φ ∈ Π i R φ ) ⎭ ⎬ ⎫ . (35)
containing a maximum of k ∣ scope ( B i ) ∣ k^{|\operatorname{scope}(B_i)|} k ∣ scope ( B i ) ∣ clauses. It follows that BE-BEL can compute through its bucket-elimination procedure the conflict set in (11) . The result is then the same computed by COMPILE in virtue of (10) . BE-BEL carries out the same operation as COMPILE across the buckets: indeed, (i) its buckets partition the clauses by the variable coming last in d d d , (ii) the elimination proceeds backwards from Y n Y_n Y n to Y 1 Y_1 Y 1 , and (iii) the derived constraints are re-filed into lower bucket.
Since Lemma 2 — and therefore the correctness of CASPER — depends on Π i − 1 \Pi_{i-1} Π i − 1 only through the assignments who satisfy it, then COMPILE can compute the set in (35) in place of Confl i ( Π ‾ i ) \operatorname{Confl}_i(\overline{\Pi}_i) Confl i ( Π i ) .
3. Cost transfer. Eliminating variable Y i Y_i Y i requires computing the combined bucket ⋈ φ ∈ Π ‾ i R φ \bowtie_{\varphi\in\overline{\Pi}_i}R_\varphi ⋈ φ ∈ Π i R φ . This is a relation over ∣ scope ( B i ) ∣ + 1 |\operatorname{scope}(B_i)|+1 ∣ scope ( B i ) ∣ + 1 variables, hence it contains at most k ∣ scope ( B i ) ∣ + 1 k^{|\operatorname{scope}(B_i)|+1} k ∣ scope ( B i ) ∣ + 1 tuples, where k = max i ∈ [ n ] h i k=\max_{i\in[n]}h_i k = max i ∈ [ n ] h i is the maximum size of the domain of each variable. Since the complexity of BE-BEL depends only on the number of functions combined in each bucket and on the size of the combined bucket, regardless of the particular semiring of choice, the complexity bound transfers. To conclude the proof we need to show that ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) |\operatorname{scope}(\mathcal{B}_i)| \le w^{*}(d) ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) for every i ∈ [ n ] i \in[n] i ∈ [ n ] . To this end, we show that, for every i = n , … , 1 i = n,\ldots,1 i = n , … , 1 it holds that,
P ( i ) : G Π i is a subgraph of ( Y , E i ) , P(i):\qquad\mathcal{G}_{\Pi_i}\text{ is a subgraph of }(\mathbf{Y},E_i), P ( i ) : G Π i is a subgraph of ( Y , E i ) ,
with E i E_i E i defined as in Equation (12) , i.e., any two variables appearing together in a clause of Π i \Pi_i Π i are adjacent in E i E_i E i . Notice that P ( i ) P(i) P ( i ) implies ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) |\operatorname{scope}(\mathcal{B}_i)| \le w^{*}(d) ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) . Indeed, for every Y j ∈ scope ( B i ) Y_j \in\operatorname{scope}(\mathcal{B}_i) Y j ∈ scope ( B i ) that appears in a clause of Π ‾ i ⊆ Π i \overline{\Pi}_i \subseteq\Pi_i Π i ⊆ Π i together with Y i Y_i Y i , it holds that ( Y i , Y j ) ∈ E i (Y_i,Y_j) \in E_i ( Y i , Y j ) ∈ E i by P ( i ) P(i) P ( i ) . Observe that j < i j < i j < i , since Y i + 1 , … , Y n Y_{i+1},\ldots,Y_n Y i + 1 , … , Y n do not appear in Π i \Pi_i Π i . As E i ⊆ E 0 E_i \subseteq E_0 E i ⊆ E 0 , we get that Y j ∈ N d ( Y i ) Y_j \in N_d(Y_i) Y j ∈ N d ( Y i ) , so scope ( B i ) ⊆ N d ( Y i ) \operatorname{scope}(\mathcal{B}_i) \subseteq N_d(Y_i) scope ( B i ) ⊆ N d ( Y i ) and therefore we obtain the desired bound ∣ scope ( B i ) ∣ ≤ ∣ N d ( Y i ) ∣ ≤ w ∗ ( d ) |\operatorname{scope}(\mathcal{B}_i)| \le|N_d(Y_i)| \le w^{*}(d) ∣ scope ( B i ) ∣ ≤ ∣ N d ( Y i ) ∣ ≤ w ∗ ( d ) .
We now prove P ( i ) P(i) P ( i ) by induction on i = n , … , 1 i = n,\ldots,1 i = n , … , 1 . We follow the same argument used in [15 Lemma 2] , showing that directional resolution never couples variables that are not adjacent in the induced graph.
Base case (i = n i=n i = n ). For i = n i=n i = n , we have Π n = Π \Pi_n=\Pi Π n = Π and E n = E Π E_n=E_{\Pi} E n = E Π . So G Π n = G Π \mathcal{G}_{\Pi_n}=\mathcal{G}_{\Pi} G Π n = G Π and P ( n ) P(n) P ( n ) holds as G Π \mathcal{G}_{\Pi} G Π is the graph ( Y , E n ) (\mathbf{Y},E_n) ( Y , E n ) .
Inductive step (i → i − 1 i \to i-1 i → i − 1 ). Assume P ( i ) P(i) P ( i ) holds. By Equation (10) every clause φ ∈ Π i − 1 \varphi\in\Pi_{i-1} φ ∈ Π i − 1 falls in one of two cases:
φ \varphi φ is a conflict clause in Equation (35) , hence so that scope ( φ ) ⊆ scope ( B i ) \operatorname{scope}(\varphi) \subseteq\operatorname{scope}(\mathcal{B}_i) scope ( φ ) ⊆ scope ( B i ) . Any two distinct Y j , Y l ∈ scope ( B i ) Y_j,Y_l \in\operatorname{scope}(\mathcal{B}_i) Y j , Y l ∈ scope ( B i ) satisfy j , l < i j,l < i j , l < i and { ( Y j , Y i ) , ( Y l , Y i ) } ⊆ E i \{(Y_j,Y_i),(Y_l,Y_i)\} \subseteq E_i {( Y j , Y i ) , ( Y l , Y i )} ⊆ E i , as shown above. Therefore, Equation (12) adds the edge ( Y j , Y l ) (Y_j,Y_l) ( Y j , Y l ) to E i − 1 E_{i-1} E i − 1 and any two variables in scope ( φ ) \operatorname{scope}(\varphi) scope ( φ ) are adjacent in E i − 1 E_{i-1} E i − 1 .
It follows that G Π i − 1 \mathcal{G}_{\Pi_{i-1}} G Π i − 1 is a subgraph of ( Y , E i − 1 ) (\mathbf{Y},E_{i-1}) ( Y , E i − 1 ) which proves P ( i − 1 ) P(i-1) P ( i − 1 ) . Since we showed that under the relational encoding we provided in step 1. COMPILE reduces to the BE-BEL algorithm, and that ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) |\operatorname{scope}(\mathcal{B}_i)| \le w^{*}(d) ∣ scope ( B i ) ∣ ≤ w ∗ ( d ) for every i ∈ [ n ] i \in[n] i ∈ [ n ] , then the proof of [14 Thm. 4.5, Sec. 4.8] yields the bounds:
time O ( ( r + n ) ⋅ k w ∗ ( d ) + 1 ) and space O ( n ⋅ k w ∗ ( d ) ) . \operatorname{time} O\left((r+n)\cdot k^{w^{*}(d)+1}\right)
\qquad\text{and}\qquad
\operatorname{space} O\left(n\cdot k^{w^{*}(d)}\right). time O ( ( r + n ) ⋅ k w ∗ ( d ) + 1 ) and space O ( n ⋅ k w ∗ ( d ) ) .
We remark that [14 ] states the bound as O ( r ⋅ k w ∗ ( d ) + 1 ) O(r\cdot k^{w^{*}(d)+1}) O ( r ⋅ k w ∗ ( d ) + 1 ) under the assumption r > n r>n r > n , which holds for Bayesian networks but not necessarily for Π \Pi Π . Also, our result highlights a (somewhat expected) super-polynomial dependence: since COMPILE decides the satisfiability of Π \Pi Π (Algorithm 1), and satisfiability of signed-CNF formulae is NP-complete [9 ] , no implementation of COMPILE runs in time polynomial in r r r , n n n and k k k unless P = N P \mathrm{P}=\mathrm{NP} P = NP .
Proof of Theorem 6
Statement. Let Π \Pi Π be a finite and satisfiable set of signed clauses. For any datapoint x x x , model m θ m_{\theta} m θ and variable ordering, the corresponding output CASPER(m θ ( x ) m_{\theta}(x) m θ ( x ) ) satisfies Π \Pi Π .
Proof. By induction on the number n n n of variables appearing in Π \Pi Π .
Base case (n = 0 n=0 n = 0 ): Π \Pi Π contains no variables and is trivially satisfied by any assignment.
Inductive step (n > 0 n>0 n > 0 ): Let Y n Y_n Y n be the variable in Π \Pi Π with the highest index in the ordering, so Π n = Π \Pi_n=\Pi Π n = Π . Since Π n − 1 \Pi_{n-1} Π n − 1 involves n − 1 n-1 n − 1 variables and is satisfiable, the inductive hypothesis gives that the partial assignment a < n \mathbf{a}_{<n} a < n induced by CASPER(m θ ( x ) m_{\theta}(x) m θ ( x ) ) satisfies Π n − 1 \Pi_{n-1} Π n − 1 . Substituting a < n \mathbf{a}_{<n} a < n into Π \Pi Π leaves clauses involving only Y n Y_n Y n ; by Lemma 2, this residual is satisfiable and reduces to a single signed clause ( S ∗ : Y n ) (S^{*}:Y_n) ( S ∗ : Y n ) by replacing each variable in Y 1 , … , Y n − 1 Y_1,\ldots,Y_{n-1} Y 1 , … , Y n − 1 with the value given by the assignment a < n \mathbf{a}_{<n} a < n induced by CASPER(m θ ( x ) m_{\theta}(x) m θ ( x ) ). Then, Theorem 2 ensures that arg max j ∈ [ h n ] CASPER ( m θ ( x ) ) n ∈ S ∗ \arg\max_{j \in[h_n]} \operatorname{CASPER}(m_{\theta}(x))_n \in S^{*} arg max j ∈ [ h n ] CASPER ( m θ ( x ) ) n ∈ S ∗ , and hence CASPER(m θ ( x ) m_{\theta}(x) m θ ( x ) ) satisfies Π n = Π \Pi_n=\Pi Π n = Π .
Additional Experimental Results
Warcraft Pathfinding.
Task Details. We consider a shortest-path finding task on Warcraft II terrain tiles as proposed by [41 ] , with the dataset generated using the MIT-licensed war2edit toolset3 ; the underlying tile assets remain the property of Blizzard Entertainment and are used here for research purposes. The full rendered terrain image is 96 × 96 pixels at the N = 12 N=12 N = 12 version and 240 × 240 at N = 30 N=30 N = 30 one. Given a N × N N \times N N × N grid rendered from Warcraft II terrain tiles, the goal of the task is to predict the minimum-cost paths from the top-left to the bottom-right corner. We test grid sizes, N ∈ { 12 , 30 } N \in\{12,30\} N ∈ { 12 , 30 } and each tile has a traversal cost outlined in Table 6 with higher costs corresponding to harder-to-traverse terrain. The constraint is that the predicted path forms a valid route: connected, contained within the grid, starting at the source ( 0 , 0 ) (0,0) ( 0 , 0 ) and ending at ( N − 1 , N − 1 ) (N-1,N-1) ( N − 1 , N − 1 ) .
Table 6. Warcraft II Tile Cost Mapping
Dijkstra-based methods. We do not include A-NeSI [48 ] or I-MLE [39 ] among the baselines. These approaches predict a tile-cost map c θ ( x ) c_\theta(\mathbf{x}) c θ ( x ) and then use a task-specific shortest-path solver to return
arg min P ∈ P ∑ v ∈ P c θ , v ( x ) , \underset{P \in\mathcal{P}}{\arg\min}\ \sum_{v \in P} c_{\theta,v}(\mathbf{x}), P ∈ P arg min v ∈ P ∑ c θ , v ( x ) ,
where P \mathcal{P} P is the set of valid paths. The solver therefore performs not only feasibility enforcement but also the combinatorial optimization that selects the path, while the network learns the costs rather than directly predicting the structured output. In our formulation, as in SPL [3 ] , the network directly predicts the path, and hence must learn from the image which of the feasible paths is optimal. The two formulations thus differ in their neural output space, optimization objective, and division of labour between the neural and symbolic components. Dijkstra-based decoding is a strong, task-specific alternative that is complementary to our approach; however, it does not address the setting studied here, in which the network must directly predict the structured output and constraints are enforced on those predictions.
Experimental Setup. For both grid sizes, N ∈ { 12 , 30 } N \in\{12,30\} N ∈ { 12 , 30 } , we use a fixed split of 10k training, 1k validation, and 1k test examples. The neural backbone is a ResNet-18 [27 ] trained from scratch. We train with Adam at learning rate 5 e − 4 5\mathrm{e}{-4} 5 e − 4 under a cosine schedule (η min = 5 e − 6 \eta_{\min}=5\mathrm{e}{-6} η m i n = 5 e − 6 ), batch size 128, and 300 epochs with early stopping. In addition to the metrics reported in the main text, and for coherence with previous work [3 ] , we additionally report Hamming accuracy and Exact match. Hamming accuracy is the per-edge accuracy averaged over the grid, and Exact match is the percentage of predicted paths that match the ground-truth shortest path edge-for-edge. We further report Optimality (%), the percentage of predicted paths whose total cost equals the ground-truth cost, along with the fractions within 1%, 5%, and 10% of the ground-truth cost. For methods that do not always produce consistent paths, these fractions are computed over the full test set (not solely on consistent paths): since inconsistent predictions count as failures regardless of the cost of any partial path they may induce. These metrics are reported in Table 8 and Table 9 for the 12 × 12 12 \times12 12 × 12 and 30 × 30 30 \times30 30 × 30 grids, respectively. To complement the exact-optimality metric, Figure 3 (Appendix § 21 ) reports a cumulative cost-optimality analysis: for each tolerance factor α ≥ 1 \alpha\ge1 α ≥ 1 , we measure the fraction of predictions whose cost is within a factor α \alpha α of the optimal path cost, providing a finer-grained view of how close non-optimal predictions are to the optimum. Consistency is the percentage of predicted paths that form a valid route: connected, contained within the grid, with correct degree at all nodes. For methods that predict a walk, all metrics are computed on the loop-erased path. All metrics are reported as mean ± \pm ± std over 5 seeds.
Table 8. Warcraft Pathfinding Task (12×12). Each metric is presented as a percentage (%). EM stands for Exact-Match.
Table 9. Warcraft Pathfinding Task (30× \times × 30). Each metric is presented as a percentage (%). EM stands for Exact-Match.
Path encoding. CASPER and all structured baselines except CTSketch share a single step-wise encoding of the path constraint (\xref}Appendix O), compiled once into an artifact from which every method reads its domains and transitions. For an N × N N \times N N × N grid with cells numbered in row-major order, source s = 0 s = 0 s = 0 and target t = N 2 − 1 t = N^2 - 1 t = N 2 − 1 , the variables X 0 , … , X L X_0, \ldots, X_L X 0 , … , X L with L = N 2 − 1 L = N^2 - 1 L = N 2 − 1 denote the cell occupied at each tick. A cell v v v belongs to the domain D i D_i D i of X i X_i X i only if it is reachable from s s s by tick i i i (d ( s , v ) ≤ i d(s,v) \le i d ( s , v ) ≤ i ), has matching parity (i ≡ d ( s , v ) m o d 2 i \equiv d(s,v) \bmod2 i ≡ d ( s , v ) mod 2 ), and can still reach t t t in time (d ( v , t ) ≤ L − i d(v,t) \le L-i d ( v , t ) ≤ L − i ); X 0 = s X_0 = s X 0 = s and X L = t X_L = t X L = t are fixed. Transitions require X i + 1 ∈ succ ( X i ) ∩ D i + 1 X_{i+1} \in\operatorname{succ}(X_i) \cap D_{i+1} X i + 1 ∈ succ ( X i ) ∩ D i + 1 , where succ ( u ) \operatorname{succ}(u) succ ( u ) is the set of grid neighbours of u u u , except that t t t can only move to itself. No all-different constraint is imposed, so walks may revisit cells; loop erasure turns a predicted walk into a simple path.
Implementation Details. We compare CASPER against the remaining six neurosymbolic baselines once again spanning exact and approximate methods: DeepProbLog (DPL) [36 ] , Semantic Probabilistic Layers (SPL) [3 ] , CCN+ [25 ] , CTSketch [10 ] , Scallop [30 ] , and DeepSoftLog (DSL) [35 ] . Both CASPER and CCN+ enforce path connectivity through a differentiable layer built on the steps encoding. For CASPER, the per-cell probabilities P ( v on path ) P(v\text{ on path}) P ( v on path ) are read on the domains D i D_i D i ; a walk selects the highest-scoring allowed successor at each step, and loop erasure turns it into a path. This path sets a target category for each cell, and each cell’s distribution is projected with the smallest ℓ 2 \ell_2 ℓ 2 edit that makes its target the argmax. CCN+ instead encodes the steps constraint as propositional clauses over one Boolean atom per step and cell in D i D_i D i , requiring at least one cell per step and that X i = u X_i = u X i = u implies one of its allowed successors (the at-most-one constraint is omitted); the clauses are compiled into a PiShield shield fed with the same scores as CASPER, and prediction is a greedy walk over the shielded scores followed by loop erasure. Scallop and DSL incorporate path validity through their respective probabilistic logic backends during training. Scallop encodes the steps constraint as a differentiable Datalog program over the relations at ( i , v ) \operatorname{at}(i,v) at ( i , v ) , dom ( i , v ) \operatorname{dom}(i,v) dom ( i , v ) and nxt ( i , j ) \operatorname{nxt}(i,j) nxt ( i , j ) read from the compiled artifact, with grid edges as probabilistic input facts given by the network’s per-node outputs: a walk at cell u u u at tick i i i can move along an edge to v v v if v ∈ D i + 1 v \in D_{i+1} v ∈ D i + 1 , remains at t t t once reached, and valid_path holds when at ( L , t ) \operatorname{at}(L,t) at ( L , t ) holds. Training minimizes − log P ( valid_path ) -\log P(\text{valid\_path}) − log P ( valid_path ) alongside the supervised loss. Each proof is one valid walk, whose probability is the product of its edge probabilities; following the default settings, we retain only the top-3 highest-probability walks per fact. This signal is a soft, approximate penalty applied during training rather than a hard constraint. At inference, the prediction is the raw per-cell argmax, without the encoding, so nothing couples these choices into a connected route. The constraint therefore acts on the probability of a valid walk during training, not on this independent decoding, and does not transfer to inference, hence Scallop’s low consistency.
SPL compiles the steps constraint into an SDD with one Boolean variable per legal (tick, from, to) move, each taking the probability of the grid edge it crosses, with sink-to-sink moves neutral; prediction uses SPL’s greedy decoding through the circuit. CTSketch approximates the per-node path-connectivity constraint via a Tensor-Train (TT) decomposition of a symbolic one-hot tensor ϕ c o n n ∈ { 0 , 1 } 2 × 2 × 2 × 2 3 \phi_{\mathrm{conn}} \in\{0,1\}^{2 \times2 \times2 \times2^3} ϕ conn ∈ { 0 , 1 } 2 × 2 × 2 × 2 3 . The four binary modes of ϕ c o n n \phi_{\mathrm{conn}} ϕ conn encode the occupancy of the four incident edges of a node (left, right, up, down in canonical order), and the final mode indexes three admissible routing classes: degree-zero (off-path node), degree-one (path endpoint), and degree-two (interior through-node); edge-degree configurations of three or higher receive zero weight in every class, producing a large penalty in log-space. We deploy CTSketch in two variants that differ in how the terrain image is presented to the backbone and how path-consistency is enforced.
For CASPER, we set the surrogate threshold ϵ = 1 e − 3 \epsilon= 1\mathrm{e}{-3} ϵ = 1 e − 3 and add an auxiliary L 2 L_2 L 2 loss between the unprojected and projected per-cell distributions weighted by λ = 1.0 \lambda= 1.0 λ = 1.0 , as motivated by Proposition 2. The step variables are processed in order, X 0 , … , X L X_0,\ldots,X_L X 0 , … , X L . For DSL, we embed the steps constraint in a symbolic functor [35 ] that runs max-product propagation over the steps encoding, one pass per tick (L = N 2 − 1 L = N^2 - 1 L = N 2 − 1 passes: 143 at N = 12 N = 12 N = 12 and 899 at N = 30 N = 30 N = 30 ): after each pass, cells outside D i D_i D i are set to zero and t t t may remain at itself, giving P ( v a l i d ) = r e a c h L ( t ) P(\mathrm{valid}) = \mathrm{reach}_L(t) P ( valid ) = reach L ( t ) . As for Scallop, this term enters only the training loss, and prediction is the raw per-cell argmax. CCN+ and Scallop are run at N = 12 N = 12 N = 12 only: CCN+’s clause encoding does not scale to N = 30 N = 30 N = 30 , and Scallop exceeds the time-out limit at N = 30 N = 30 N = 30 . For SPL, we run with a configuration consistent with [3 ] . Lastly, for CTSketch we run two distinct modalities: CTSketch and CTSketch Grid (cf. Table 8 , Table 9 ).
Single modality (CTSketch). The full rendered terrain image is forwarded through the ResNet-18 backbone, yielding independent per-edge logits for all 2 N ( N − 1 ) 2N(N - 1) 2 N ( N − 1 ) grid edges. The symbolic tensor ϕ c o n n \phi_{\mathrm{conn}} ϕ conn is factorised offline into a chain of TT cores via TT-SVD. At each of the N 2 N^2 N 2 grid nodes, the predicted probability p e p_e p e of each incident edge is assembled into a 2-state distribution [ 1 − p e , p e ] [1 - p_e, p_e] [ 1 − p e , p e ] (boundary edges absent from the grid are clamped to [ 0 , 1 ] [0, 1] [ 0 , 1 ] ). These distributions are contracted with the shared TT-core chain to produce a per-node log-score vector over the three routing classes. The symbolic connectivity loss L C T S \mathcal{L}_{\mathrm{CTS}} L CTS is defined as the mean negative log-likelihood of the ground-truth routing class, determined by the node’s degree in the ground-truth shortest path (zero, one, or two). The full training objective is given by L = L B C E + λ C T S L C T S \mathcal{L} = \mathcal{L}_{\mathrm{BCE}} + \lambda_{\mathrm{CTS}}\mathcal{L}_{\mathrm{CTS}} L = L BCE + λ CTS L CTS , with λ C T S = 1.0 \lambda_{\mathrm{CTS}} = 1.0 λ CTS = 1.0 . No post-processing is applied at inference time; predicted paths are obtained by thresholding the per-edge sigmoid outputs.
Grid modality (CTSketch Grid). The terrain image is partitioned into a 3 × 3 3 \times3 3 × 3 grid of non-overlapping tiles, each covering ⌊ N / 3 ⌋ × ⌊ N / 3 ⌋ \lfloor N/3 \rfloor\times\lfloor N/3 \rfloor ⌊ N /3 ⌋ × ⌊ N /3 ⌋ terrain nodes (4 × 4 nodes per tile at N = 12 N = 12 N = 12 ). The ResNet-18 backbone is applied independently to each tile and predicts only the edges whose both endpoints lie within that tile. The binary cross-entropy loss and the CTS loss L C T S \mathcal{L}_{\mathrm{CTS}} L CTS are correspondingly restricted to within-tile edges. An additional global regulariser R g l o b a l \mathcal{R}_{\mathrm{global}} R global , weighted by λ g l o b a l = 1.0 \lambda_{\mathrm{global}} = 1.0 λ global = 1.0 , penalises cross-tile inconsistencies at evaluation time by scoring boundary-node degree compatibility between adjacent tiles. At inference time, within-tile edge predictions are thresholded, and a deterministic stitching procedure fills the missing cross-tile edges: starting from the top-left tile, the algorithm greedily identifies pairs of adjacent tiles with degree-one boundary nodes and connects them.
CTSketch Ablation. We study the sensitivity of both CTSketch modalities introduced above to the TT approximation rank on the 12 × 12 12 \times12 12 × 12 grid, evaluating ranks r ∈ { 3 , 10 , 30 } r \in\{3, 10, 30\} r ∈ { 3 , 10 , 30 } with TT-SVD decomposition across 5 random seeds per configuration.
Single modality. The connectivity tensor ϕ c o n n \phi_{\mathrm{conn}} ϕ conn is a sparse binary array of shape ( 2 , 2 , 2 , 2 , 3 ) (2, 2, 2, 2, 3) ( 2 , 2 , 2 , 2 , 3 ) whose intrinsic TT-rank is 3: a TT-SVD at r = 3 r = 3 r = 3 already achieves a reconstruction error below 5 × 10 − 7 5 \times10^{-7} 5 × 1 0 − 7 in the ℓ ∞ \ell_\infty ℓ ∞ norm, making the factorisation effectively lossless. As a direct consequence, all three rank settings yield nearly indistinguishable training dynamics and final performance. We adopt r = 30 r = 30 r = 30 as the final configuration reported in the main results, as it achieves the best aggregate performance and provides a large margin above the minimum admissible rank, ensuring numerical stability of the TT contraction throughout training.
Grid modality. Across all three ranks, CTSketch (Grid) yields consistently degenerate path-level outcomes: exact-match and consistency figures remain near 0.2% irrespective of r r r (cf. Table 8 , Table 9 ). Within-tile edge quality is comparatively higher, as reflected by Hamming accuracies of ≈ 91.5 % \approx91.5\% ≈ 91.5% , indicating that the backbone learns meaningful per-tile edge distributions under the tile-local CTS supervision. The failure to produce valid global paths is therefore attributable not to the quality of the TT approximation—which is exact at every tested rank—but to the structural limitation the method exhibits during global reconciliation: tile-local policies are optimised independently, with no training signal governing the entry and exit points at tile boundaries, so the greedy cross-tile connector cannot reliably assemble a globally consistent shortest path.
Table 7. Computational efficiency on Warcraft Shortest Path across grid-sizes.
Computational Efficiency Table 7 reports peak GPU memory and per-epoch training time for each method on both grid sizes N ∈ { 12 , 30 } N \in\{12, 30\} N ∈ { 12 , 30 } . CASPER’s memory usage and epoch-time grow gracefully with increasing grid-size. All other exact methods, which guarantee path consistency, are unable to run at N = 30 N = 30 N = 30 without breaching the 5s per-sample time-out limit. Of the approximate methods, CTSketch is the most memory and time efficient at N = 30 N = 30 N = 30 ; however, as outlined in Table 9 , this comes at the cost of both optimality (5.1% cost-optimal paths vs 12.1% for CASPER) and consistency (6.1% consistency vs 100% for CASPER).
MNIST-Arithmetic
Task Details We consider two fully supervised tasks based on the MNIST Dataset [33 ] which is distributed under the CC BY-SA 3.0 license. For MNIST-Sum, we consider the problem of computing the sum of n n n handwritten digits sampled from the dataset, and test using sums of size n = 2 k n = 2^k n = 2 k for k ∈ { 1 , 4 , 6 , 8 , 10 } k \in\{1, 4, 6, 8, 10\} k ∈ { 1 , 4 , 6 , 8 , 10 } . Each sample consists of n n n single-digit images ( x 1 , … , x n ) (x_1, \ldots, x_n) ( x 1 , … , x n ) with labels
( Y 1 , … , Y n ) ∈ { 0 , … , 9 } n (Y_1,\ldots,Y_n) \in\{0,\ldots,9\}^n ( Y 1 , … , Y n ) ∈ { 0 , … , 9 } n and sum T ∈ { 0 , … , 9 n } T \in\{0,\ldots,9n\} T ∈ { 0 , … , 9 n } . The enforced constraint is:
∑ i = 1 n Y i = T . \sum_{i=1}^{n} Y_i = T. i = 1 ∑ n Y i = T .
For MNIST-Add, we consider the problem of computing the sum of two n n n -digit numbers represented as sequences of handwritten digits. We test using n ∈ { 2 , 15 , 100 , 256 } n \in\{2, 15, 100, 256\} n ∈ { 2 , 15 , 100 , 256 } . Each sample consists of 2 n 2n 2 n single-digit images ( x 1 , … , x 2 n ) (x_1,\ldots,x_{2n}) ( x 1 , … , x 2 n ) encoding two operands, with labels ( A 1 , … , A n ) ∈ { 0 , … , 9 } n (A_1,\ldots,A_n) \in\{0,\ldots,9\}^n ( A 1 , … , A n ) ∈ { 0 , … , 9 } n and ( B 1 , … , B n ) ∈ { 0 , … , 9 } n (B_1,\ldots,B_n) \in\{0,\ldots,9\}^n ( B 1 , … , B n ) ∈ { 0 , … , 9 } n , and an ( n + 1 ) (n+1) ( n + 1 ) -digit sum with labels ( S 0 , S 1 , … , S n ) ∈ { 0 , … , 9 } n + 1 (S_0,S_1,\ldots,S_n) \in\{0,\ldots,9\}^{n+1} ( S 0 , S 1 , … , S n ) ∈ { 0 , … , 9 } n + 1 , where A 1 A_1 A 1 , B 1 B_1 B 1 , and S 0 S_0 S 0 denote the most significant digits. The constraint requires the predicted ( n + 1 ) (n+1) ( n + 1 ) -digit output to equal the sum of the two input numbers:
∑ i = 1 n A i ⋅ 10 n − i + ∑ i = 1 n B i ⋅ 10 n − i = ∑ i = 0 n S i ⋅ 10 n − i . \sum_{i=1}^{n} A_i \cdot10^{n-i} + \sum_{i=1}^{n} B_i \cdot10^{n-i} = \sum_{i=0}^{n} S_i \cdot10^{n-i}. i = 1 ∑ n A i ⋅ 1 0 n − i + i = 1 ∑ n B i ⋅ 1 0 n − i = i = 0 ∑ n S i ⋅ 1 0 n − i .
Experimental Setup To ensure a fair comparison with existing baselines we follow the dataset construction of [10 ] : 5k training and 1k test examples for every n n n on MNIST-Sum, and ⌊ 60000 / 2 n ⌋ \lfloor60000/2n \rfloor ⌊ 60000/2 n ⌋ training and ⌊ 10000 / 2 n ⌋ \lfloor10000/2n \rfloor ⌊ 10000/2 n ⌋ test examples on MNIST-Add. To test scalability we sweep n ∈ { 2 , 16 , 64 , 256 , 1024 } n \in\{2, 16, 64, 256, 1024\} n ∈ { 2 , 16 , 64 , 256 , 1024 } for MNIST-Sum and N ∈ { 2 , 15 , 100 , 256 } N \in\{2, 15, 100, 256\} N ∈ { 2 , 15 , 100 , 256 } for MNIST-Add. The neural backbone is shared across both tasks: a LeNet-5 digit encoder which we train with Adam [31 ] at a learning rate of 1 e − 3 1\mathrm{e}{-3} 1 e − 3 (reduced to 3 e − 4 3\mathrm{e}{-4} 3 e − 4 for MNIST-Add at n ∈ { 100 , 256 } n \in\{100, 256\} n ∈ { 100 , 256 } ) under a cosine schedule (η min = 1 e − 5 \eta_{\min} = 1\mathrm{e}{-5} η m i n = 1 e − 5 ). We set batch size 16 for MNIST-Sum and 64 for MNIST-Add, and for each task size n n n we record mean ± \pm ± std over 5 seeds for task accuracy (predicted output exactly matches ground truth) and consistency (predicted digits sum to the predicted output). We present the full set of results for MNIST-Sum in Table 10 and for MNIST-Add in Table 12 ; these results are visualised in Figure 2 . Table 13 further breaks down MNIST-Add accuracy into operand and sum accuracy, reporting both exact-match and per-digit (macro) accuracy.
Table 10. Test accuracy (%) on the MNISTSum task (s u m n \mathrm{sum}_n sum n ) for n ∈ { 2 , 16 , 64 , 256 , 1024 } n \in\{2, 16, 64, 256, 1024\} n ∈ { 2 , 16 , 64 , 256 , 1024 } . T/O = timeout. The reference approximates the accuracy of a neural predictor for MNIST images with 0.995 accuracy, computed as 0.995 n 0.995^n 0.99 5 n .
Table 12. Test accuracy (%) on the MNISTAdd task (a d d n \mathrm{add}_n add n ). Accuracy is the exact-match accuracy of the predicted sum: all n + 1 n+1 n + 1 digits must be correct. T/O = timeout; ERR = numerical error. The reference approximates the accuracy of a neural predictor with 0.995 accuracy per digit, computed as 0.995 2 n 0.995^{2n} 0.99 5 2 n .
Implementation Details We compare CASPER against seven neurosymbolic baselines covering both exact and approximate methods: DeepProbLog (DPL) [36 ] , Semantic Probabilistic Layers (SPL) [3 ] , CCN+ [25 ] , CTSketch [10 ] , A-NeSI [48 ] , Scallop [30 ] , and DeepSoftLog (DSL) [35 ] . All methods are trained and evaluated in a fully-supervised setting but differ in how the per-digit predictions are aggregated to give the final output. For MNIST-Sum, CASPER, A-NeSI, and CCN+ use a learned MLP sum-head, while SPL reads the sum directly from the joint distribution over digits and sum encoded in its compiled SDD. CTSketch, Scallop, DSL, and DPL take a per-digit argmax at inference and compute the sum deterministically, so their predictions are consistent by construction. For MNIST-Add, CASPER and CTSketch use a carry-chain decomposition, processing digit positions sequentially and propagating the carry from each position into the next. Consistent with [48 ] , A-NeSI uses an autoregressive MLP head over the multi-digit output. CCN+ uses a MLP head, as its binary one-hot representation does not support carry-chain decomposition. Scallop, DPL, and DSL evaluate the addition relation as a logic program, while SPL compiles it into a SDD over the joint distribution of digits and sum.
For MNIST-Sum, Scallop uses top-3 proofs with learning rate 1 e − 3 1\mathrm{e}{-3} 1 e − 3 ; CTSketch uses tensor-train decomposition with rank 2 and tree depth 1, 4, 6, 8, 10 for n = 2 , 16 , 64 , 256 , 1024 n = 2, 16, 64, 256, 1024 n = 2 , 16 , 64 , 256 , 1024 respectively; DSL uses neural embeddings for n = 16 n = 16 n = 16 with learning rate 1 e − 3 1\mathrm{e}{-3} 1 e − 3 and weight decay 1 e − 5 1\mathrm{e}{-5} 1 e − 5 ; and A-NeSI uses parameters consistent with [48 ] . For MNIST-Add, Scallop again uses top-3 proofs with learning rate 1 e − 3 1\mathrm{e}{-3} 1 e − 3 ; CTSketch uses tensor-train decomposition with rank 2; and A-NeSI and DSL use the hyperparameters from their respective papers. The original CTSketch implementation reconstructs predicted digits via base-10 expansion over int64, we observe overflow for n ≥ 19 n \ge19 n ≥ 19 and report results using a fixed arbitrary-precision implementation. A-NeSI’s symbolic function overflows int64 for n ≥ 19 n \ge19 n ≥ 19 ; we therefore report A-NeSI only up to n = 15 n = 15 n = 15 .
Table 11 reports an ablation conducted on the MNIST-Sum task to isolate the contribution of training with CASPER versus applying it only at inference: digit accuracy is essentially unchanged across configurations, confirming that CASPER does not degrade the perception backbone, while inference-only application already recovers most of the sum-accuracy gain.
Table 11. MNIST-Sum Ablation Study.
Computational Efficiency Table 14 reports peak GPU memory and per-epoch training time on MNIST-Sum across all scales. Among exact methods, only CASPER scales beyond n = 2 n = 2 n = 2 , and it reaches n = 1024 n = 1024 n = 1024 while remaining competitive with the approximate methods on both memory and time, using substantially less memory than A-NeSI and running considerably faster at the largest scale. CTSketch is the most resource-efficient baseline, but at the cost of accuracy (Table 10). The cvxpy variant times out at n = 1024 n = 1024 n = 1024 , confirming that the closed-form surrogate is necessary for scaling while retaining the constraint satisfaction guarantee.
Sudoku solving.
Task Details We consider the sudoku dataset from SatNet [50 ] , consisting of 10,000 nine-by-nine Sudoku boards whose hint cells are rendered as 28 × 28 28 \times28 28 × 28 grayscale MNIST digits and whose blank cells are represented as uniformly grey images. The average number of given hints per board is 36.22 (with a minimum of 31, and maximum 42). The task is to predict the complete 9 × 9 9 \times9 9 × 9 solution, inserting one digit from { 1 , … , 9 } \{1, \ldots, 9\} { 1 , … , 9 } per cell—from the 81-cell image grid, while abiding by the standard Sudoku rules: a board is accepted as correct only when every row, every column, and every 3 × 3 3 \times3 3 × 3 sub-grid contains each digit exactly once. The dataset can be downloaded from the official repository. No explicit license for the dataset was provided.
Experimental Setup The 10,000 boards are split into 9,000 training, 500 validation, and 500 test examples following the standard SatNet partition. All hyperparameter and checkpoint selection is performed on the validation split; final results are reported on the fixed test split. Every method is run with 10 random seeds and we report mean and standard deviation across seeds for each metric we consider. The primary metric is PipeAcc : the fraction of test boards for which the complete pipeline output exactly matches the ground-truth solution. We additionally report the NeuroAcc : board accuracy of the argmax of the soft board distribution P ∈ R 81 × 9 P \in\mathbb{R}^{81 \times9} P ∈ R 81 × 9 produced by component (ii) before masking and symbolic completion, isolating the contribution of the learned upstream components from that of the Prolog solver. Finally, we report the percentage of CNN errors, that the board solver is able to detect and recover from, out of the total number of CNN errors across the test set (RecRate ). Results are shown in Table 4 .
Table 13. Operand and sum accuracy (%) on MNISTAdd. Exact : no digit errors; Macro : per-digit accuracy. Exact, approximate methods; unlisted methods time out (A-NeSI: ERR for n ≥ 100 n \ge100 n ≥ 100 ).
At evaluation time, methods that produce a scalar mask-logit bias (CASPER and its LLM variant) select the bias from the grid { − 2.0 , − 1.0 , 0.0 , 1.0 , 2.0 } \{-2.0, -1.0, 0.0, 1.0, 2.0\} { − 2.0 , − 1.0 , 0.0 , 1.0 , 2.0 } that maximises board accuracy on the validation set; for the remaining methods (CTSketch and A-NeSI) the bias is swept over { − 1.0 , 0.0 , 1.0 } \{-1.0, 0.0, 1.0\} { − 1.0 , 0.0 , 1.0 } and the results for the best performing evaluation run is reported.
Implementation Details
Shared backbones. All six methods share the same three-component backbone, initialised from the publicly released NASR checkpoint [11 ] . Specifically these are as follows:
The perception module is a convolutional network that processes each of the 81 cell images independently and outputs per-cell log-posteriors over the ten classes { 0 , 1 , … , 9 } \{0,1,\ldots,9\} { 0 , 1 , … , 9 } (class 0 denotes a blank cell).
Table 14. Computational efficiency on MNIST-Sum across methods and scales. † Scallop runs on CPU. ‡ The cvxpy projection runs on CPU.
The board-solver is a Vision Transformer with embedding dimension 192, depth 4, 3 attention heads, and MLP expansion ratio 4; it maps the 81 per-cell ten-dimensional inputs to a soft board distribution P ∈ R 81 × 9 P \in\mathbb{R}^{81 \times9} P ∈ R 81 × 9 over { 1 , … , 9 } \{1, \ldots, 9\} { 1 , … , 9 } .
The masking network shares the same Transformer configuration with a scalar output per cell; sigmoid-activating those logits yields the per-cell keep probability used to gate Prolog.
LLM fine-tuning. For the LLM-backed variants, we fine-tune Qwen2.5-14B-Instruct on the 9,000 SatNet training boards using LoRA [52 ] with rank r = 16 r = 16 r = 16 , scaling α = 16 \alpha= 16 α = 16 , no dropout, applied to all attention and MLP layers. The base model is loaded in 4-bit NormalFloat quantisation with bfloat16 activations (via Unsloth). We train for 3 epochs with AdamW-8bit, learning rate 2 × 10 − 4 2 \times10^{-4} 2 × 1 0 − 4 , cosine decay schedule, warmup ratio 0.05, weight decay 0.01, and an effective batch size of 16 (providing two examples per device with eight gradient-accumulation steps). Each board is formatted under the Qwen2.5 chat template: the system message states the ’ALLDIFFERENT’ rules and specifies a structured output format; the user message provides the full 9 × 9 9 \times9 9 × 9 grid with zeros marking blank cells. The model is trained to output a <WORKING>/<SOLUTION> block containing exactly nine lines of nine space-separated digits. At inference time, outputs that violate the format, contain out-of-range digits, or alter any given cell are treated as failures.
The fine-tuned LLM produces one-hot-like logits—high confidence on the predicted digit and zero elsewhere—carrying no per-cell uncertainty. To recover calibrated soft probabilities compatible with downstream masking, the frozen neuro-solver from [11 ] is used as an auxiliary uncertainty prior for CASPER. Concretely, we introduce a new fusion head , implemented as a residual MLP (with a total of ≈21,700 parameters) operating on the individual cells receiving both the LLM-solved boards and the frozen standard neuro-solver soft probabilities, modelling prior prediction uncertainty. Across all LLM-backed methods the CNN and neuro-solver are frozen throughout; only the fusion head (and, where applicable, the masking network) receive gradient updates.
CASPER. Neuro-board solver from [11 ] . Only the masking network is trained; the CNN and board solver remain at their pre-trained weights throughout. At each training step, the solver distribution is projected through CASPER constraint layer. The masking network is trained with a per-cell weighted binary cross-entropy loss: the target for cell j j j is 1 if and only if the projected digit equals the ground-truth, and 0 otherwise. Incorrectly projected cells (the minority class, typically < 10 % <10\% < 10% ) receive loss weight 20 to compensate for the severe class imbalance. We use AdamW with learning rate 10 − 4 10^{-4} 1 0 − 4 , weight decay 0.3, cosine LR schedule, gradient clipping at norm 1.0, batch size 200, up to 10 epochs, and early stopping on validation board accuracy at patience 5.
LLM board solver. The fusion head and masking network are trained jointly. Training is cache-only: a full-data generation pass is run once to populate an on-disk cache of LLM outputs. The loss combines the same weighted BCE mask term (λ m a s k = 1.0 \lambda_{\mathrm{mask}} = 1.0 λ mask = 1.0 ) and a label-smoothed NLL calibration loss on the fused distribution (λ t e m p = 0.5 \lambda_{\mathrm{temp}} = 0.5 λ temp = 0.5 , smoothing α = 0.3 \alpha= 0.3 α = 0.3 ). Label smoothing is necessary because the LLM is already highly accurate: without it, the NLL drives the fusion temperature toward zero, collapsing the soft distribution. With α = 0.3 \alpha= 0.3 α = 0.3 the analytical optimum lies at a finite temperature, preserving uncertainty. All other hyperparameters match the previous variant, with the training budget extended to 20 epochs and early stopping patience 7. The mask logit bias is tuned at evaluation on the grid { − 2.0 , − 1.0 , 0.0 , 1.0 , 2.0 } \{-2.0, -1.0, 0.0, 1.0, 2.0\} { − 2.0 , − 1.0 , 0.0 , 1.0 , 2.0 } .
CTSketch. Neuro-board solver from [11 ] . The full model (CNN, board-solver, masking network) is trained end-to-end. The training objective is the CTS tensor-sketch loss, following the code from [10 ] : a differentiable rank-2 Tucker approximation of the nine-ary ALLDIFFERENT constraint-satisfaction probability, summed over all 27 groups (rows, columns, and boxes) and combined with a Prolog-based per-board reward signal. We use AdamW with learning rate 5 × 10 − 6 5 \times10^{-6} 5 × 1 0 − 6 , weight decay 0.3, a linear learning-rate ramp over all 9 training epochs (warmup covering the full training duration), and batch size 200.
LLM board solver. Only the fusion head and masking network are trained; the CNN, board-solver, The CTS sketch loss and Prolog reward are applied directly to the fused distribution output by the fusion head. We use AdamW with learning rate 10 − 4 10^{-4} 1 0 − 4 , weight decay 0.3, cosine LR schedule, gradient clipping (norm 1.0), batch size 200, 20 epochs, and early stopping on validation reward at patience 7.
A-NesI. Neuro-board solver from [11 ] . We apply the A-NesI framework [48 ] with pairwise encoding of the ALLDIFFERENT constraints. The inference model q q q is a two-layer MLP with hidden size 128 that predicts binary constraint satisfaction for each cell pair; it is optimised with Adam at learning rate 10 − 3 10^{-3} 1 0 − 3 (MSE loss). The perception backbone (CNN and board-solver) is updated via the log-q q q perception loss with Adam at learning rate 5 × 10 − 5 5 \times10^{-5} 5 × 1 0 − 5 . Each training step draws 100 samples from the board distribution P P P . The masking network is frozen during A-NesI training and is used solely at evaluation time. We train for 3 epochs with batch size 50.
LLM board solver. The fusion head takes the role of the perception backbone in the A-NesI training loop: it is updated via the log-q q q perception loss with Adam at learning rate 5 × 10 − 5 5 \times10^{-5} 5 × 1 0 − 5 , while q q q is trained identically to the neuro counterpart (Adam, lr 10 − 3 10^{-3} 1 0 − 3 , MSE). The masking network is trained jointly from epoch 1 via a separate AdamW optimizer (learning rate 10 − 4 10^{-4} 1 0 − 4 , weight decay 0.3, gradient clipping at norm 1.0). The checkpoint selection uses A-NesI inference success (fraction of validation batches for which q q q predicts all pairwise constraints satisfied) as the criterion. Training runs for 20 epochs with early stopping patience 7.
Choice of the Encoding
Theorem 5 bounds the cost of COMPILE by
time O ( ( r + n ) ⋅ k w ∗ ( d ) + 1 ) , space O ( n ⋅ k w ∗ ( d ) ) . \text{time } \mathcal{O}\left((r+n) \cdot k^{w^*(d)+1}\right), \qquad\text{space } \mathcal{O}\left(n \cdot k^{w^*(d)}\right). time O ( ( r + n ) ⋅ k w ∗ ( d ) + 1 ) , space O ( n ⋅ k w ∗ ( d ) ) .
with r r r the number of clauses, n n n the number of variables, k = max i h i k = \max_i h_i k = max i h i the largest domain, and w ∗ ( d ) w^*(d) w ∗ ( d ) the conflict width of Π \Pi Π along the ordering d d d , which coincides with the induced width of the interaction graph of Π \Pi Π along d d d [14 ] . For highly interconnected problems, w ∗ ( d ) w^*(d) w ∗ ( d ) grows with the problem size N N N , which is intractable for compilation, so we instead consider alternative problem settings that keep w ∗ ( d ) w^*(d) w ∗ ( d ) bounded.
In Sudoku solving, compiling the joint constraint set over the whole board is intractable, because every cell shares a group with many others, so the interaction graph is highly interconnected. We instead enforce the all-different constraint on each of the 27 groups (9 rows, 9 columns and 9 boxes) individually, so that each constraint set involves only the 9 cells of one group.
In Warcraft, specifying the task as path-finding with local constraints between neighbouring cells gives an interaction graph where w ∗ ( d ) ∝ N w^*(d) \propto N w ∗ ( d ) ∝ N , making it intractable to compile. We instead formulate it as walk-finding, describing the task as a sequence of cells, which gives w ∗ ( d ) = 1 w^*(d) = 1 w ∗ ( d ) = 1 for every N N N . This is a different problem-setting since walks may revisit a cell, so a simple path is recovered by loop erasure. All baselines are run in the same walk-finding setting (excl. CTSketch), with loop erasure applied to every method’s output before computing the metrics.
Warcraft: walk-finding formulation. Let G = ( V , E ) G = (V, E) G = ( V , E ) be the four-neighbour grid graph on a g × g g \times g g × g board, n = g 2 = ∣ V ∣ n = g^2 = |V| n = g 2 = ∣ V ∣ , with source s s s (top-left) and target t t t (bottom-right). Write d ( u , v ) d(u,v) d ( u , v ) for the graph (Manhattan) distance. Recall that G G G is bipartite under the checkerboard two-colouring: every edge joins cells of different colours, hence a walk of length ℓ \ell ℓ from s s s can only end on a cell v v v whose distance d ( s , v ) d(s,v) d ( s , v ) has the same parity as ℓ \ell ℓ (ℓ ≡ d ( s , v ) ( m o d 2 ) \ell\equiv d(s,v) \pmod{2} ℓ ≡ d ( s , v ) ( mod 2 ) ); e.g. a cell at even distance is reachable only in an even number of moves).
Variables and transitions. Fix the horizon L = n − 1 L=n-1 L = n − 1 , the maximum number of edges of any simple path. Introduce multi-valued variables X 0 , … , X L X_0,\ldots,X_L X 0 , … , X L with intended reading “X i = X_i= X i = the cell occupied at time i i i ”. The absorbing transition relation is
T ( u , v ) ⟺ ( u ≠ t ∧ { u , v } ∈ E ) ∨ u = v = t . T(u,v) \Longleftrightarrow(u \ne t \land\{u,v\}\in E)\lor u=v=t. T ( u , v ) ⟺ ( u = t ∧ { u , v } ∈ E ) ∨ u = v = t .
i.e. every step is a real move, except that the target, once reached, repeats forever (and can never be left). (There is no general waiting move; this is what makes the parity argument below available.) The formula is the chain
Φ = ⋀ i = 0 L − 1 T ( X i , X i + 1 ) , \Phi=\bigwedge_{i=0}^{L-1}T(X_i,X_{i+1}), Φ = i = 0 ⋀ L − 1 T ( X i , X i + 1 ) ,
endpoint pinning being absorbed into the domains below.
From the relation to signed clauses. T T T is not a primitive of the constraint language; it is unrolled value by value. Writing [ S ] : X [S]\!:\!X [ S ] : X for the signed literal “X ∈ S X\in S X ∈ S ”, each conjunct T ( X i , X i + 1 ) T(X_i,X_{i+1}) T ( X i , X i + 1 ) becomes one clause per value u ∈ D i u\in D_i u ∈ D i ,
[ D i ∖ { u } ] : X i ∨ [ succ ( u ) ∩ D i + 1 ] : X i + 1 , succ ( u ) = { N ( u ) u ≠ t , { t } u = t , [D_i\setminus\{u\}]\!:\!X_i\lor[\operatorname{succ}(u)\cap D_{i+1}]\!:\!X_{i+1},\qquad
\operatorname{succ}(u)=
\begin{cases}
N(u) & u\ne t,\\
\{t\} & u=t,
\end{cases} [ D i ∖ { u }] : X i ∨ [ succ ( u ) ∩ D i + 1 ] : X i + 1 , succ ( u ) = { N ( u ) { t } u = t , u = t ,
i.e. the implication X i = u ⇒ X i + 1 ∈ succ ( u ) X_i=u\Rightarrow X_{i+1}\in\operatorname{succ}(u) X i = u ⇒ X i + 1 ∈ succ ( u ) written as a disjunction. The edge set E E E never appears as an object: adjacency (N ( u ) = N(u)= N ( u ) = the up/down/left/right cells of u u u ) is materialized inside the enumerated successor lists. A guard [ ∅ ] : X i [\emptyset]\!:\!X_i [ ∅ ] : X i (empty when D i = { u } D_i=\{u\} D i = { u } is a singleton) is dropped, leaving a unary clause. For the trimmed 2 × 2 2\times2 2 × 2 instance the whole formula is four clauses:
[ 1 , 2 ] : X 1 , [ 2 ] : X 1 ∨ [ 3 ] : X 2 , [ 1 ] : X 1 ∨ [ 3 ] : X 2 , [ 3 ] : X 3 , [1,2]\!:\!X_1,\qquad[2]\!:\!X_1\lor[3]\!:\!X_2,\qquad[1]\!:\!X_1\lor[3]\!:\!X_2,\qquad[3]\!:\!X_3, [ 1 , 2 ] : X 1 , [ 2 ] : X 1 ∨ [ 3 ] : X 2 , [ 1 ] : X 1 ∨ [ 3 ] : X 2 , [ 3 ] : X 3 ,
(step 0: D 0 = { 0 } D_0=\{0\} D 0 = { 0 } forces X 1 ∈ N ( 0 ) ∩ D 1 = { 1 , 2 } X_1\in N(0)\cap D_1=\{1,2\} X 1 ∈ N ( 0 ) ∩ D 1 = { 1 , 2 } ; step 1: from u = 1 u=1 u = 1 or u = 2 u=2 u = 2 the only admissible successor in D 2 = { 3 } D_2=\{3\} D 2 = { 3 } is the target; step 2: absorption). Optionally, ALLDIFFERENT clauses over the non-target positions restrict the models to simple paths; we omit them (allow_cycles) because they connect every pair of step variables and destroy the chain structure — simplicity is instead recovered downstream (loop erasure) or left to the learner.
Domain trimming. The untrimmed encoding gives every X i X_i X i the full domain V V V . The trimmed encoding declares instead
D i = { v ∈ V ∖ { t } : d ( s , v ) ≤ i , i ≡ d ( s , v ) ( m o d 2 ) , d ( v , t ) ≤ L − i } ∪ { t : i ≥ d ( s , t ) } . D_i=\left\{v\in V\setminus\{t\}:d(s,v)\le i,\ i\equiv d(s,v)\pmod{2},\ d(v,t)\le L-i\right\}\cup\{t:i\ge d(s,t)\}. D i = { v ∈ V ∖ { t } : d ( s , v ) ≤ i , i ≡ d ( s , v ) ( mod 2 ) , d ( v , t ) ≤ L − i } ∪ { t : i ≥ d ( s , t )} .
In particular D 0 = { s } D_0=\{s\} D 0 = { s } and D L = { t } D_L=\{t\} D L = { t } : the endpoint constraints are domain facts, not clauses.
Reading the three tests. Since D L = { t } D_L=\{t\} D L = { t } , the walk must have arrived by the deadline L L L ; at time i i i it therefore has exactly L − i L-i L − i transitions left. The three tests bound where it can possibly stand at that moment:
Forward (d ( s , v ) ≤ i d(s,v)\le i d ( s , v ) ≤ i ): the past constrains the present — in i i i moves from s s s no walk outruns the graph distance, so cells farther than i i i from the source are unoccupiable.
Backward (d ( v , t ) ≤ L − i d(v,t)\le L-i d ( v , t ) ≤ L − i ): the future constrains the present — from v v v even the most direct route to costs d ( v , t ) d(v,t) d ( v , t ) moves, so a cell with d ( v , t ) > L − i d(v,t)>L-i d ( v , t ) > L − i admits no completion by the deadline, whatever the walk does afterwards. (At i = L i=L i = L this test alone yields D L = { t } D_L=\{t\} D L = { t } ; one step earlier only t t t and its neighbours survive.)
Parity (i ≡ d ( s , v ) ( m o d 2 ) i\equiv d(s,v)\pmod{2} i ≡ d ( s , v ) ( mod 2 ) ): within reach is not enough — every move flips the checkerboard colour, so the step count and the distance must also agree modulo 2.
The forward and backward tests are the two cones of a discrete space–time “light cone” — reachable-from-s s s and can-still-reach-t t t — and D i D_i D i is their intersection restricted to the correct colour class. Domains are accordingly narrow near both ends of the horizon and widest in the middle. Deleting a cell that fails any test removes no walk, since every walk satisfies all three by the prefix/suffix argument of Proposition 3; the backward family is also precisely what bucket elimination would otherwise have to derive as resolvents (see below), while the forward and parity families are stronger facts that the target-first elimination would never produce.
Proposition 3 (Exactness of the trimming). An assignment ( x 0 , … , x L ) ∈ D 0 × ⋯ × D L (x_0,\ldots,x_L) \in D_0 \times\cdots\times D_L ( x 0 , … , x L ) ∈ D 0 × ⋯ × D L satisfies Φ \Phi Φ if and only if it is an absorbing s s s –t t t walk: a four-neighbour walk that starts at s s s , first reaches t t t at some time ℓ ≤ L \ell\le L ℓ ≤ L , and repeats t t t thereafter. Moreover the trimming deletes no such walk: the models of the trimmed formula and of the untrimmed formula (with absorbing transitions and pinned endpoints) coincide. Consequently every simple s s s –t t t path — of every length, the maximum being L = n − 1 L=n-1 L = n − 1 — is a model, obtained by padding it with repetitions of t t t ; the remaining models are exactly the walks that revisit a cell before reaching t t t .
Proof sketch. ( ⇐ ) (\Leftarrow) ( ⇐ ) Let ( x i ) (x_i) ( x i ) be an absorbing walk with arrival time ℓ \ell ℓ . For i < ℓ i<\ell i < ℓ the prefix x 0 ⋯ x i x_0\cdots x_i x 0 ⋯ x i is a genuine walk of length i i i from s s s , so d ( s , x i ) ≤ i d(s,x_i)\le i d ( s , x i ) ≤ i , and, by bipartiteness, i ≡ d ( s , x i ) ( m o d 2 ) i\equiv d(s,x_i)\pmod2 i ≡ d ( s , x i ) ( mod 2 ) ; the suffix x i ⋯ x ℓ x_i\cdots x_\ell x i ⋯ x ℓ reaches t t t in ℓ − i ≤ L − i \ell-i\le L-i ℓ − i ≤ L − i moves, so d ( x i , t ) ≤ L − i d(x_i,t)\le L-i d ( x i , t ) ≤ L − i . For i ≥ ℓ i\ge\ell i ≥ ℓ , x i = t x_i=t x i = t and i ≥ ℓ ≥ d ( s , t ) i\ge\ell\ge d(s,t) i ≥ ℓ ≥ d ( s , t ) . Hence every position lies in its trimmed domain, and consecutive positions satisfy T T T by definition of a walk. ( ⇒ ) (\Rightarrow) ( ⇒ ) Conversely, a satisfying assignment moves along edges until its first visit to t t t (self-repetition is licensed only at t t t ), and x L = t x_L=t x L = t because D L = { t } D_L=\{t\} D L = { t } ; it is therefore an absorbing s s s –t t t walk. Both directions never invoke the trimming tests negatively, which proves the coincidence of model sets. Finally, a simple path padded at t t t is an absorbing walk, and an absorbing walk with pairwise-distinct non-target positions is a padded simple path.
Why this compiles with zero resolvents. The primal graph of Φ \Phi Φ is the chain X 0 − X 1 − ⋯ − X L X_0-X_1-\cdots-X_L X 0 − X 1 − ⋯ − X L (induced width 1), so bucket elimination never couples more than two step variables. Its only derivations would be the backward-reachability constraints “X i X_i X i must lie within distance L − i L-i L − i of t t t ” propagated from the pinned endpoint — precisely the backward trimming test, which the domains already encode; the forward and parity tests are stronger facts that resolution would not derive at all. The trimmed input is therefore its own compilation fixpoint. Measured compilation costs (single worker, AMD EPYC 9335):
Table 1 (PDF p. 41).
Worked example: 2 × 2 2 \times2 2 × 2 . Cells row-major: s = 0 = ( 0 , 0 ) s=0=(0,0) s = 0 = ( 0 , 0 ) , 1 = ( 0 , 1 ) 1=(0,1) 1 = ( 0 , 1 ) , 2 = ( 1 , 0 ) 2=(1,0) 2 = ( 1 , 0 ) , t = 3 = ( 1 , 1 ) t=3=(1,1) t = 3 = ( 1 , 1 ) ; d ( s , t ) = 2 d(s,t)=2 d ( s , t ) = 2 , L = 3 L=3 L = 3 . The trimmed domains are
D 0 = { 0 } , D 1 = { 1 , 2 } , D 2 = { 3 } , D 3 = { 3 } . D_0=\{0\}, \qquad D_1=\{1,2\}, \qquad D_2=\{3\}, \qquad D_3=\{3\}. D 0 = { 0 } , D 1 = { 1 , 2 } , D 2 = { 3 } , D 3 = { 3 } .
(E.g. 0 ∉ D 1 0\notin D_1 0 ∈ / D 1 by parity; 0 ∉ D 2 0\notin D_2 0 ∈ / D 2 because d ( 0 , t ) = 2 > L − 2 = 1 d(0,t)=2>L-2=1 d ( 0 , t ) = 2 > L − 2 = 1 ; t ∉ D 1 t\notin D_1 t ∈ / D 1 because 1 < d ( s , t ) 1<d(s,t) 1 < d ( s , t ) .) The formula has exactly two models,
( 0 , 1 , 3 , 3 ) and ( 0 , 2 , 3 , 3 ) , (0,1,3,3) \qquad\text{and} \qquad(0,2,3,3), ( 0 , 1 , 3 , 3 ) and ( 0 , 2 , 3 , 3 ) ,
i.e. precisely the two simple s s s –t t t paths — at this size the walk relaxation is already exact, and the model count equals the path count.
Worked example: 3 × 3 3 \times3 3 × 3 . Cells 0..8 0..8 0..8 row-major, s = 0 s = 0 s = 0 , t = 8 t = 8 t = 8 , d ( s , t ) = 4 d(s,t) = 4 d ( s , t ) = 4 , L = 8 L = 8 L = 8 . Distances from s s s are ( 0 , 1 , 2 , 1 , 2 , 3 , 2 , 3 , 4 ) (0,1,2,1,2,3,2,3,4) ( 0 , 1 , 2 , 1 , 2 , 3 , 2 , 3 , 4 ) and to t t t are ( 4 , 3 , 2 , 3 , 2 , 1 , 2 , 1 , 0 ) (4,3,2,3,2,1,2,1,0) ( 4 , 3 , 2 , 3 , 2 , 1 , 2 , 1 , 0 ) . The trimmed domains are
D 0 = { 0 } D 1 = { 1 , 3 } D 2 = { 0 , 2 , 4 , 6 } D 3 = { 1 , 3 , 5 , 7 } D 4 = { 0 , 2 , 4 , 6 , 8 } D 5 = { 1 , 3 , 5 , 7 , 8 } D 6 = { 2 , 4 , 6 , 8 } D 7 = { 5 , 7 , 8 } D 8 = { 8 } \begin{aligned}
D_0 &= \{0\} & D_1 &= \{1,3\}\\
D_2 &= \{0,2,4,6\} & D_3 &= \{1,3,5,7\}\\
D_4 &= \{0,2,4,6,8\} & D_5 &= \{1,3,5,7,8\}\\
D_6 &= \{2,4,6,8\} & D_7 &= \{5,7,8\}\\
D_8 &= \{8\}
\end{aligned} D 0 D 2 D 4 D 6 D 8 = { 0 } = { 0 , 2 , 4 , 6 } = { 0 , 2 , 4 , 6 , 8 } = { 2 , 4 , 6 , 8 } = { 8 } D 1 D 3 D 5 D 7 = { 1 , 3 } = { 1 , 3 , 5 , 7 } = { 1 , 3 , 5 , 7 , 8 } = { 5 , 7 , 8 }
— 29 values in total against 81 untrimmed (the parity test alone halves each interior domain; the backward test additionally removes 0 from D 6 D_6 D 6 and 1, 3 from D 7 D_7 D 7 ; t t t enters only from step d ( s , t ) = 4 d(s,t) = 4 d ( s , t ) = 4 on). Sample models:
a geodesic simple path, padded at the target: ( 0 , 1 , 2 , 5 , 8 , 8 , 8 , 8 , 8 ) (0,1,2,5,8,8,8,8,8) ( 0 , 1 , 2 , 5 , 8 , 8 , 8 , 8 , 8 ) ;
a maximal simple path using the full horizon (no padding): ( 0 , 1 , 2 , 5 , 4 , 3 , 6 , 7 , 8 ) (0,1,2,5,4,3,6,7,8) ( 0 , 1 , 2 , 5 , 4 , 3 , 6 , 7 , 8 ) ;
a cyclic walk retained by allow_cycles — it revisits 0 and 3 before arriving: ( 0 , 1 , 4 , 3 , 0 , 3 , 6 , 7 , 8 ) (0,1,4,3,0,3,6,7,8) ( 0 , 1 , 4 , 3 , 0 , 3 , 6 , 7 , 8 ) ; loop erasure maps it to ( 0 , 3 , 6 , 7 , 8 ) (0,3,6,7,8) ( 0 , 3 , 6 , 7 , 8 ) .
All three satisfy every domain membership and transition. Excluded by construction are: assignments that leave the target after reaching it (absorption), assignments placing any cell off its parity class (e.g. x 2 = 1 x_2 = 1 x 2 = 1 ), jumps between non-adjacent cells, and prefixes that stray too far to return (e.g. x 6 = 0 x_6 = 0 x 6 = 0 : d ( 0 , t ) = 4 > L − 6 d(0,t) = 4 > L - 6 d ( 0 , t ) = 4 > L − 6 ).
Sequence-level supervision and head design. Feeding every step variable the same network tile distribution leaves the sequence dimension unsupervised: the greedy walk then has no reason to progress, and empirically it oscillates inside the predicted corridor and reaches t t t only when the backward cone forces it (arrival at the last admissible step for 100% of test samples), leaving path quality intact but the raw sequence degenerate. The remedy is to let the network output one categorical distribution per step variable and to supervise it with the ground-truth optimal path as a sequence , the absorbing target repeated after arrival; the training loss applies the cross-entropy after the projection (on the layer-adjusted distributions), plus the mean-normalized ℓ 2 \ell_2 ℓ 2 projection regularizer. This has one structural cost: a dense head needs one logit per (step, admissible cell) pair, i.e. ∑ i ∣ D i ∣ \sum_i |D_i| ∑ i ∣ D i ∣ outputs — benign at 12 × 12 12 \times12 12 × 12 (6,234 logits at the provable horizon L = 106 L=106 L = 106 ) but O ( L n ) O(Ln) O ( L n ) in general (379k logits, a 194M-parameter final layer, at 30 × 30 30 \times30 30 × 30 with L = 899 L=899 L = 899 ). Two mitigations: (i) shrink the horizon — either to the provable chordless bound of Section O or, more aggressively, to the longest optimal path observed in the dataset (at 12 × 12 12 \times12 12 × 12 : L = 32 L = 32 L = 32 versus the provable 106; the artifact shrinks to 869 logits and 864 clauses); (ii) factorize the head as logit ( i , v ) = ⟨ u i , e v ( x ) ⟩ \operatorname{logit}(i,v) = \langle u_i,e_v(x)\rangle logit ( i , v ) = ⟨ u i , e v ( x )⟩ with per-cell embeddings e v ( x ) e_v(x) e v ( x ) taken from the stride-8 feature map (one feature per grid tile) plus broadcast global context, and learned per-step queries u i u_i u i — O ( ( L + n ) d ) O((L+n)d) O (( L + n ) d ) parameters in place of O ( L n ) O(Ln) O ( L n ) . Empirically, sequence supervision removes the procrastination outright (mean arrival drops from the horizon to the geodesic within two epochs). Measured at 12 × 12 12 \times12 12 × 12 (CE after projection, λ = 1 \lambda= 1 λ = 1 mean-normalized, paper recipe). The report the walk-cost metric — every emitted tile is paid at every visit, so wandering is penalized directly and a walk counts as optimal only if it is a wander-free optimal simple path — alongside the loop-erased strict metrics. “simple” = fraction of emitted sequences with no revisit. Dense-head rows are mean ± \pm ± std over six seeds; factorized rows are single-seed:
Table 1 (PDF p. 42).
Sequence supervision removes the procrastination outright: 97–99% of emitted sequences are already simple, median arrival equals the geodesic, and the wandering-penalized and loop-erased metrics coincide to within one point — the layer outputs clean optimal paths with no post-processing credit. Across horizons the differences are within seed noise (single-seed comparisons at this task overstate contrasts by up to 7 points), so the dataset horizon is preferred purely on cost: the smallest head and the cheapest projection at equal accuracy. The factorized head trades roughly 10 points for its O ( ( L + n ) d ) O((L+n)d) O (( L + n ) d ) parameter budget — the price of input-independent step queries — making it the scalable but not yet accuracy-matched option for larger grids.
Table 1 (PDF p. 43). Sequence supervision at 30 × 30. The same protocol at 30 × 30 (three seeds per configuration; horizons: dataset maximum L = 80 L=80 L = 80 , dataset maximum plus slack L = 100 L=100 L = 100 , provable chordless bound L = 674 L=674 L = 674 ):
Three conclusions. First , the dense head scales: even the 154M-parameter output layer at the chordless bound trains stably (48 s/epoch, 2 ms projections), and accuracy is horizon-invariant — the dataset horizon again wins on cost alone. Second , the factorized head fails outright at this scale (0% wander-free optimal, no simple sequences): input-independent step queries cannot drive 900-way step decisions, so the affordable head is the one that does not work, while the “expensive” dense head is entirely affordable. Third , the ≈ 7% walk-opt plateau, shared by the greedy oracle walks and every horizon, is a perception ceiling , not a decoding one: an exact dynamic-programming decode over the down/right-monotone DAG on the same network’s probabilities attains only 6.3% (median ratio 1.23), despite searching its restricted space optimally, while the masks contain a true-weight optimal path 38% of the time. The network’s coarse corridor is right; its fine cost ranking between neighbouring corridors is not, and no decoder over the same probabilities — restricted or not — can recover information the scores do not carry. Improving the 30 × 30 operating point is therefore a backbone problem (e.g. cost regression in place of membership probabilities), orthogonal to the layer’s guarantees.
Broader Impacts
The guarantees provided by CASPER are highly relevant in safety-critical domains, such as clinical decision support tools. However, while CASPER guarantees that its outputs satisfy the given constraints, it does not guarantee that they are correct. First, the constraints themselves may contain errors, which CASPER would enforce just as reliably as correct knowledge. Second, a prediction can satisfy every constraint and still be wrong; since all outputs appear valid, such constraint-compliant errors may go unnoticed.
NeurIPS Paper Checklist
Claims
Question: Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
Answer: [Yes]
Justification: The abstract and introduction claim CASPER (i) guarantees constraint satisfaction by construction, (ii) scales at inference time, (iii) requires no problem-specific decomposition and (iv) is fully differentiable. These properties are substantiated by Theorem 6 (correctness) and verified by the experimental analysis detailed in Section 4.
Guidelines:
The answer [N/A] means that the abstract and introduction do not include the claims made in the paper.
The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A [No] or [N/A] answer to this question will not be perceived well by the reviewers.
The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings.
It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper.
Limitations
Question: Does the paper discuss the limitations of the work performed by the authors?
Answer: [Yes]
Justification: In Appendix § 8 we discuss the limitations of CASPER namely we consider the problem of enforcing hard constraints over categorical variables. We do not address several orthogonal problems to ours: constraint satisfaction over continuous variables, reasoning shortcuts, modelling dependencies between predicted symbols and concept base interpretability.
Guidelines:
The answer [N/A] means that the paper has no limitation while the answer [No] means that the paper has limitations, but those are not discussed in the paper.
The authors are encouraged to create a separate “Limitations” section in their paper.
The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be.
The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated.
The authors should reflect on the factors that influence the performance of the approach. For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon.
The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size.
If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness.
While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren’t acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations.
Theory assumptions and proofs
Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?
Answer: [Yes]
Justification: All theoretical results are stated with explicit assumptions in Section 3 and proven in Appendices B–M. Theorems 1–2 and Lemma 1 establish the single-variable projection and its satisfaction guarantee; Theorem 3 shows that the surrogate and exact projections select the same value; Theorem 4, Corollary 1, and Propositions 1–2 characterise the surrogate error and gradient behaviour; Lemma 2 and Theorem 6 extend correctness to the multi-variable case via the compilation step, whose cost is bounded by Theorem 5; and Corollary 2 shows that the surrogate does not alter the sequence of assignments. Each result is numbered and cross-referenced from the main text.
Guidelines:
The answer [N/A] means that the paper does not include theoretical results.
All the theorems, formulas, and proofs in the paper should be numbered and cross-referenced.
All assumptions should be clearly stated or referenced in the statement of any theorems.
The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition.
Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material.
Theorems and Lemmas that the proof relies upon should be properly referenced.
Experimental result reproducibility
Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)?
Answer: [Yes]
Justification: We provide a detailed description of our method in Section 3, our key experimental results in Section 4 and all remaining details (task-formulation, experimental setup and implementation details) specific to each task in Appendix N.
Guidelines:
The answer [N/A] means that the paper does not include experiments.
If the paper includes experiments, a [No] answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not.
If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable.
Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general, releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed.
While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. For example (a) If the contribution is primarily a new algorithm, the paper should make it clear how to reproduce that algorithm. (b) If the contribution is primarily a new model architecture, the paper should describe the architecture clearly and fully.
(c) If the contribution is a new model (e.g., a large language model), then there should either be a way to access this model for reproducing the results or a way to reproduce the model (e.g., with an open-source dataset or instructions for how to construct the dataset).
(d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results.
Open access to data and code
Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material?
Answer: [Yes]
Justification: Code and instructions to reproduce all experimental results are publicly available at https://github.com/lkonathala25/casper.
Guidelines:
The answer [N/A] means that paper does not include experiments requiring code.
Please see the NeurIPS code and data submission guidelines (https://neurips.cc/public/guides/CodeSubmissionPolicy) for more details.
While we encourage the release of code and data, we understand that this might not be possible, so [No] is an acceptable answer. Papers cannot be rejected simply for not including code, unless this is central to the contribution (e.g., for a new open-source benchmark).
The instructions should contain the exact command and environment needed to run to reproduce the results. See the NeurIPS code and data submission guidelines (https://neurips.cc/public/guides/CodeSubmissionPolicy) for more details.
The authors should provide instructions on data access and preparation, including how to access the raw data, preprocessed data, intermediate data, and generated data, etc.
The authors should provide scripts to reproduce all experimental results for the new proposed method and baselines. If only a subset of experiments are reproducible, they should state which ones are omitted from the script and why.
At submission time, to preserve anonymity, the authors should release anonymized versions (if applicable).
Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted.
Experimental setting/details
Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer) necessary to understand the results?
Answer: [Yes]
Justification: All relevant details for our experimental analysis are covered, for each task, in Section 4.
Guidelines:
The answer [N/A] means that the paper does not include experiments.
The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them.
The full details can be provided either with the code, in appendix, or as supplemental material.
Experiment statistical significance
Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?
Answer: [Yes] Justification: We report the error bars in all the tables and charts present in our paper.
Guidelines:
The answer [N/A] means that the paper does not include experiments.
The authors should answer [Yes] if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper.
The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions).
The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.)
The assumptions made should be given (e.g., Normally distributed errors).
It should be clear whether the error bar is the standard deviation or the standard error of the mean.
It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified.
For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g., negative error rates).
If error bars are reported in tables or plots, the authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text.
Experiments compute resources
Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments?
Answer: [Yes]
Justification: We cover the compute resources used in our experiment analysis in Section 4.
Guidelines:
The answer [N/A] means that the paper does not include experiments.
The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage.
The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute.
The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn’t make it into the paper).
Code of ethics
Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines?
Answer: [Yes]
Justification: We confirm we have read the NeurIPS code of ethic and we comply with it.
Guidelines:
The answer [N/A] means that the authors have not reviewed the NeurIPS Code of Ethics.
If the authors answer [No], they should explain the special circumstances that require a deviation from the Code of Ethics.
The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction).
Broader impacts
Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed? Answer: [Yes]
Justification: We discuss the potential positive and negative societal impacts of CASPER, particularly in safety-critical domains such as clinical decision support, in Appendix § 23 .
Guidelines:
The answer [N/A] means that there is no societal impact of the work performed.
If the authors answer [N/A] or [No], they should explain why their work has no societal impact or why the paper does not address societal impact.
Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations.
The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate Deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster.
The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology.
If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML).
Safeguards
Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pre-trained language models, image generators, or scraped datasets)?
Answer: [N/A]
Justification: This paper proposes a method that does not present any particular risk of misuse.
Guidelines:
The answer [N/A] means that the paper poses no such risks.
Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters.
Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images.
We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.
Licenses for existing assets
Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?
Answer: [Yes]
Justification: All datasets used in the experimental analysis are cited: MNIST-Arithmetic [32 ] , Warcraft Pathfinding [40 ] and SatNet (Sudoku Solving) [49 ] where the associated licenses are outlined in Appendix § 21 .
Guidelines:
The answer [N/A] means that the paper does not use existing assets.
The authors should cite the original paper that produced the code package or dataset.
The authors should state which version of the asset is used and, if possible, include a URL.
The name of the license (e.g., CC-BY 4.0) should be included for each asset.
For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided.
If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset.
For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided.
If this information is not available online, the authors are encouraged to reach out to the asset’s creators.
13. New assets
Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets?
Answer: [N/A]
Justification: This paper does not release any new assets.
Guidelines:
The answer [N/A] means that the paper does not release new assets.
Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc.
The paper should discuss whether and how consent was obtained from people whose asset is used.
At submission time, remember to anonymize your assets (if applicable). You can either create an anonymized URL or include an anonymized zip file.
14. Crowdsourcing and research with human subjects
Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)?
Answer: [N/A]
Justification: This paper does not involve crowdsourcing nor research with human subjects
Guidelines:
The answer [N/A] means that the paper does not involve crowdsourcing nor research with human subjects.
Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper.
According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector.
15. Institutional review board (IRB) approvals or equivalent for research with human subjects
Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained?
Answer: [N/A]
Justification: This paper does not involve crowdsourcing nor research with human subjects. Guidelines:
The answer [N/A] means that the paper does not involve crowdsourcing nor research with human subjects.
Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper.
We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution.
For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review.
Declaration of LLM usage
Question: Does the paper describe the usage of LLMs if it is an important, original, or non-standard component of the core methods in this research? Note that if the LLM is used only for writing, editing, or formatting purposes and does not impact the core methodology, scientific rigor, or originality of the research, declaration is not required.
Answer: [N/A]
Justification: The development of the core methodology of this paper does not involve LLMs as any important, original, or non-standard component.
Guidelines:
The answer [N/A] means that the core method development in this research does not involve LLMs as any important, original, or non-standard components.
Please refer to our LLM policy in the NeurIPS handbook for what should or should not be described.