arXiv:2610.08207cs.CCOct 2026

Manuscript Offprint

arXiv:2610.08207

A Fast Algorithm for Maltsev Constraints

Victor Lagerkvist

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The constraint satisfaction problem over a set of relations Γ\Gamma (CSP( Γ\Gamma)) is the computational problem of deciding if a set of constraints admits at least one solution. The classical complexity for finite-domain CSP( Γ\Gamma) is settled by the CSP dichotomy theorem: it is tractable if Γ\Gamma satisfies a non-trivial algebraic invariant and is NP-complete otherwise. However, not all these algebraic invariants result in efficient algorithms despite being theoretically tractable. A notable case that generalizes linear equations is that of Maltsev CSPs: an n-variable instance with m constraints is solvable in roughly O(n8⋅m)O(n^8 \cdot m) time by Bulatov & Dalmau (SIAM J. Comput. 2006) or O(n4⋅m)O(n^4 \cdot m) time by Dyer & Richerby (SIAM J. Comput. 2013). At the same time, arguably, most “natural” and efficiently usable polynomial-time algorithms rarely exceed a quadratic or cubic time bound. In this paper we revisit Maltsev constraints with this question in mind and find a O(n2⋅m)O(n^2 \cdot m) algorithm (for finite languages, for infinite languages we in addition need to take the total size of the instance into account). The main novel idea is to not attempt to improve the bottleneck in Bulatov & Dalmau (the FIX-VALUES procedure) but to avoid it altogether with a slightly more refined approach that allows us to search through a smaller space.

1 Introduction

The constraint satisfaction problem over a set of relations Γ\Gamma (CSP( Γ\Gamma)) is the well-known computational problem of deciding if a set of constraints over Γ\Gamma admits at least one satisfying assignment. For finite domains the classical complexity is by now well understood: CSP( Γ\Gamma) is tractable if Γ\Gamma satisfies a non-trivial algebraic condition [28, 12], and is NP-hard otherwise, by a gadget reduction from 3-SAT [10, 3]. There are, roughly speaking, two broad and natural classes of tractable CSPs: those solvable by local consistency methods, and those solvable by (algebraic generalizations of) Gaussian elimination [22]. While the algorithms of Bulatov [12] and Zhuk [28] handle certain involved combinations of local consistency and Gaussian elimination, the algorithms are complicated and are mainly intended as a proof of concept. Whether there is a simpler, unified algorithm is a topic of intense research for both CSP and its promise version [1, 6, 15, 18].

The limits and applications of simple but powerful local consistency algorithms such as (singleton) arc consistency are well understood [2, 22, 26]. The same is true for the reach of the algebraic generalization of linear equations, in the sense that the CSPs it solves are exactly characterized [4, 7, 24]. What is lacking on the latter side is efficiency: the known algorithms are polynomial but far from practical, and, unlike local consistency, are rarely used in practice. Towards defining the algebraic generalization of linear equations, first note that a system of linear equations (mod dd) in nn variables satisfies the following algebraic invariant: for any three solutions s,t,u∈[d]ns, t, u \in [d]^n the tuple s−u+ts - u + t (again, mod dd) satisfies this system, too. This can be generalized to (coset) equations over a group (D,⋅)(D, \cdot) where the corresponding operation guaranteed to preserve the solution space is x⋅y−1⋅zx \cdot y^{-1} \cdot z. If one abstracts this further then the relevant property is a ternary operation φ:D3→D\varphi: D^3 \to D such that

φ(x,x,y)=φ(y,x,x)=y\varphi(x,x,y) = \varphi(y,x,x) = y for any x,y∈Dx,y \in D. Such an operation is called a Maltsev operation and if we require that each relation in Γ\Gamma is “preserved” by φ\varphi (see Section 2 for details) then we get a reasonable algebraic generalization of linear equations (Maltsev CSPs).

The celebrated result by Bulatov & Dalmau [7], the simple algorithm for Maltsev constraints, then solves every Maltsev CSP in polynomial time. In the sequel, let us abbreviate this algorithm by BD. It is conceptually simple and is built upon the idea that every relation preserved by a Maltsev operation has a small generating set (a compact representation). We then go through the constraints C1,…,CmC_1, \ldots, C_m in the instance and for each ClC_l, 1≤l≤m1 \leq l \leq m, assess its impact upon the solution space by constructing a compact representation of the solution space of (C1,…,Cl)(C_1, \ldots, C_l). We then either detect an inconsistency (no solution can be represented) or output a compact representation of the solution space of C1,…,CmC_1, \ldots, C_m. The main complication is to compute these compact representations efficiently. To see exactly where the complexity bottleneck in BD lies we thus need to define a few technical notions. For R⊆DnR \subseteq D^n, a pair of tuples t,t′∈Rt, t' \in R witnesses a triple (i,a,b)(i, a, b) if tt and t′t' agree on the first i−1i - 1 coordinates and ti=at_i = a, ti′=bt_i' = b. The pair (a,b)(a, b) is sometimes called a fork of RR at coordinate ii [11]. The signature Sig(R)\text{Sig}(R) is the set of witnessed triples, so ∣Sig(R)∣≤n∣D∣2|\text{Sig}(R)| \leq n|D|^2 however large RR is. A representation of RR is a subset R′⊆RR' \subseteq R with Sig(R′)=Sig(R)\text{Sig}(R') = \text{Sig}(R), and it is compact if ∣R′∣≤2∣Sig(R)∣|R'| \leq 2|\text{Sig}(R)|. The key fact is that a representation of a relation preserved by φ\varphi generates it under φ\varphi [7, Lemma 3.1]. BD then uses a procedure SOLVE that maintains a compact representation of the solution space RlR_l of the first ll constraints C1,…,ClC_1, \ldots, C_l. To update the current compact representation BD uses the procedure NEXT, which adds the constraint scope one coordinate at a time by calling the procedure NEXT-BETA. NEXT-BETA must find, for every (i,a,b)(i, a, b) in the signature of the new relation, two witnesses with a common prefix, and accomplishes this with two subroutines: NONEMPTY finds a tuple of RR whose projection onto given coordinates lies in a given relation, by closing the representation under φ\varphi, and FIX-VALUES takes a representation of RR and values a1,…,ai−1a_1, \ldots, a_{i-1} and returns a compact representation of the tuples of RR whose first i−1i - 1 coordinates are a1,…,ai−1a_1, \ldots, a_{i-1}. The second witness is found by NONEMPTY inside that representation. Thus, FIX-VALUES is called once for each of the n∣D∣2n|D|^2 triples (i,a,b)(i, a, b) (once per (i,a)(i, a) if its result is saved), and each call fixes up to nn coordinates, calling NONEMPTY n∣D∣2n|D|^2 times per coordinate. Bulatov and Dalmau do not make the polynomial explicit but Dalmau's technical report [16] bounds one coordinate step (with respect to a relation SS) by O(n8+(n+∣S∣)4∣S∣n2)O(n^8 + (n + |S|)^4|S|n^2) and the algorithm by O(mn8+m(n+∣S∗∣)4∣S∗∣n2)O(mn^8 + m(n + |S^*|)^4|S^*|n^2) for a finite language with largest (in the sense of cardinality) relation S∗S^*.

The BD algorithm and various questions concerning Maltsev CSPs (and the related subpower membership problem) have been revisited several times in the literature in different contexts [17, 24, 4, 5, 27, 11, 25, 23, 8, 9, 19, 20, 13, 14]. Notably, Dyer and Richerby [21], in the context of simplifying the dichotomy for finite-domain counting CSPs, report an improvement of BD. They replace compact representations by (small) frames that describe (at most n(∣D∣−1)+1n(|D|-1)+1 entries) tuples with a common prefix. Similar to a compact representation a frame generates R through applications of the Maltsev operation [21, Lemma 15]. Their update step avoids the worst redundancies of NONEMPTY (a closure procedure that considers each triple once, [21, Lemma 13]) and fixes a prefix in O(n3)O(n^3) time [21, Corollary 17]. However, it still computes, for every prefix class at every coordinate, a frame of the tuples with that prefix, and then intersects with the constraint in question. For a fixed language and constant ∣D∣|D| this gives O(n4)O(n^4) per constraint and O(mn4)O(mn^4) in total [21, Lemmas 19–20]. To the best of our knowledge this is still the best explicit bound for Maltsev CSPs. Furthermore, it runs into the exact same wall as BD: for each of about n∣D∣n|D| pairs (coordinate, value or class), one build a representation of the tuples of R with the corresponding prefix, and search inside it. A representation of a prefix class has up to n(∣D∣−1)+1n(|D|-1)+1 (for a frame) or 2n∣D∣22n|D|^2 (for a compact representation) tuples of length n, so merely writing it down can cost Θ(n2)\Theta(n^2). The cheapest known way of computing it costs O(n3)O(n^3) [21, 25], which over n∣D∣n|D| classes gives

O(n4)O(n^{4}) per constraint.

Our paper. In this paper we break the O(n4⋅m)O(n^4 \cdot m) barrier with an obvious (in hindsight) but novel approach. Rather than attempting to speed up FIX-VALUES we avoid calling it in the first place. We first investigate what NEXT-BETA actually extracts from the tuples of RR with a given prefix, i.e., which values occur at the one position ii under consideration, and which of these tuples are compatible with the new constraint. Both questions depend only on the coordinates in position ii and in the scope QQ of the constraint. So all that is needed is the projection of the prefix class onto these ∣Q∣+1|Q| + 1 coordinates. This is a set of at most ∣D∣2∣S∣|D|^2|S| tuples (thanks to the coordinate-at-a-time idea of BD).

The question is how to get at this projection without going through the entire class. This turn out to be straightforward. The first property is a localised form of the generating lemma (i.e., that a relation can be generated from its compact representation with the Maltsev operation). Fix a tuple uu of RR with respect to some prefix, pick (a,a′)(a, a') from the current compact representation (witnessing a fork at some position ≥i\geq i), and consider moves of the form x↦φ(x,a,a′)x \mapsto \varphi(x, a, a'). There are roughly n∣D∣2n|D|^2 such maps. Because aa and a′a' agree before their position, a move never changes the first i−1i-1 coordinates of xx, and we do not leave the prefix class. Because of the two identities defining a Maltsev operation, the moves reach every tuple of the class from uu. Thus the class is the set of tuples reachable from uu along n∣D∣2n|D|^2 specific applications of the Maltsev operation (that, importantly, follows immediately from the compact representation). Second, we apply these “moves” to projections (with respect to the current constraint and a fixed index). Hence, the reachability search can be done with breadth-first search on at most ∣D∣2∣S∣|D|^2|S| vertices with n∣D∣2n|D|^2 moves each. Whenever the search discovers a new projected tuple, we, as output, also store a full tuple of the class projecting to it, since this later is necessary to build the new representation. The same search, started from any tuple of RR and using all the moves, then yields the projection of all of RR.

One coordinate step therefore costs nn positions times a search that spends O(n∣D∣2)O(n|D|^2) per object, i.e. O(n2∣D∣5∣S∣)O(n^2|D|^5|S|). Summing over the constraints gives O(∣D∣5n2∥I∥)O(|D|^5 n^2 \|\mathcal{I}\|) where ∥I∥\|\mathcal{I}\| is the size of the input. For a fixed, finite constraint language we obtain O(mn2)O(mn^2) which matches Gaussian elimination.

This work naturally opens up corresponding questions for k-edge terms (of which Maltsev is the special case k=2k = 2) where the induced CSP is known to be solvable in O(m(n∣D∣∣S∗)(k+2)2)O(m(n|D||S^*)^{(k+2)^2}) time [24]. Several steps in our algorithm carries over and the exponent can plausibly be lowered. However, whether the exponent can actually reach O(k)O(k) is an intriguing open question.