Symmetric Linear Arc Monadic Datalog and Gadget Reductions
Abstract
A Datalog program solves a constraint satisfaction problem (CSP) if and only if it derives the goal predicate precisely on the unsatisfiable instances of the CSP. There are three Datalog fragments that are particularly important for finite-domain constraint satisfaction: arc monadic Datalog, linear Datalog, and symmetric linear Datalog, each having good computational properties. We consider the fragment of Datalog where we impose all of these restrictions simultaneously, i.e., we study symmetric linear arc monadic (slam) Datalog. We characterise the CSPs that can be solved by a slam Datalog program as those that have a gadget reduction to a particular Boolean constraint satisfaction problem. We also present exact characterisations in terms of a homomorphism duality (which we call unfolded caterpillar duality), and in universal-algebraic terms (using known minor conditions, namely the existence of quasi Maltsev operations and -absorptive operations of arity , for all ). Our characterisations also imply that the question whether a given finite-domain CSP can be expressed by a slam Datalog program is decidable.
Keywords and phrases:
Datalog, Gadget Reductions, Homomorphism Dualities, Minor ConditionsCopyright and License:
![[Uncaptioned image]](x1.png)
2012 ACM Subject Classification:
Theory of computation Finite Model TheoryFunding:
Both authors have been funded by the European Research Council (Project POCOCOP, ERC Synergy Grant 101071674). Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them.Editors:
Sudeepa Roy and Ahmet KaraSeries and Publisher:

1 Introduction
Datalog is an important concept linking database theory with the theory of constraint satisfaction. It is by far the most intensively studied formalism for polynomial-time tractability in constraint satisfaction. Datalog allows to formulate algorithms that are based on iterating local inferences, aka constraint propagation or establishing local consistency; this has been made explicit by Feder and Vardi in their groundbreaking work where they also formulate the finite-domain CSP dichotomy conjecture [25]. Following their convention, we say that a Datalog program solves a CSP if derives the goal predicate on an instance of the CSP if and only if the instance is unsatisfiable.
The class of CSPs that can be solved by Datalog is closed under so-called “gadget reductions” (a result due to Larose and Zádori [33]). In such a reduction, the variables in an instance of a constraint satisfaction problem are replaced by tuples of variables of some fixed finite length, and the constraints are replaced by gadgets (implemented by conjunctive queries; a formal definition can be found in Section 2.3); many of the well-known reductions between computational problems can be phrased as gadget reductions. Datalog is sufficiently powerful to simulate such gadget reductions; this has been formalised by Atserias, Bulatov, and Dawar in [2] and the connection has been sharpened recently by Dalmau and Opršal [21].
Feder and Vardi showed that Datalog cannot solve systems of linear equations over finite fields, even though such systems can be solved in polynomial time [25]. They suggest that the ability to simulate systems of linear equations should essentially be the only reason for a CSP to not be in Datalog. This conjecture was formalised by Larose and Zádori [33]: they observed that if systems of linear equations admit a gadget reduction to a CSP, then the CSP is not in Datalog, and they conjectured that otherwise the CSP can be solved by Datalog. This conjecture was proved by Barto and Kozik in 2009 [4], long before the resolution of the finite-domain CSP dichotomy conjecture by Bulatov [12] and by Zhuk [41, 40].
Datalog programs can be evaluated in polynomial time; but even a running time in on a sequential computer can be prohibitively expensive in practise. This is one of the reasons why syntactic fragments of Datalog have been studied, which often come with better computational properties.
1.1 Arc Monadic Datalog
In monadic Datalog, we restrict the arity of the inferred predicates of the Datalog program to one (i.e., all the IDBs are monadic). In arc Datalog we restrict each rule to a single input relation symbol (i.e., the body contains a single EDB; for formal definitions, see Section 2.4).
An important Datalog fragment is arc monadic Datalog, which is still powerful enough to express the famous arc consistency procedure in constraint satisfaction. The arc consistency procedure has already been studied by Feder and Vardi [25], and has many favorable properties: it can be evaluated in linear time and linear space. It is used as an important pre-processing step in the algorithms for both of the mentioned CSP dichotomy proofs, and it is also used in many practical implementations of algorithms in constraint satisfaction. The arc consistency procedure is still extremely powerful, and can for instance solve the P-complete HornSat Problem.
Feder and Vardi characterised the power of the arc consistency procedure in terms of tree duality (see Section 2.6), a natural combinatorial property which has been studied intensively in the graph homomorphism literature in the 90s (see, e.g., [26, 27]). Their characterisation has several remarkable consequences: one is that also the class of CSPs that can be solved by an arc monadic Datalog program is closed under gadget reductions. Another one is a collapse result for Datalog when it comes to finite-domain CSPs, namely that monadic Datalog collapses to arc monadic Datalog: in fact, if a finite-domain CSP can be solved by a monadic Datalog program, then it can already be solved by the arc consistency procedure (i.e., by a program in arc monadic Datalog). This statement is false without the restriction to finite-domain CSPs; in fact, there are infinite-domain CSPs that can be solved by a monadic Datalog program, but not by a program in arc monadic Datalog (Bodirsky and Dalmau [8]).
1.2 Linear Datalog
Besides arc monadic Datalog, there are other natural fragments of Datalog. The most notable one is linear Datalog [29]. Linear Datalog programs can be evaluated in non-deterministic logarithmic space (NL), and hence cannot express P-hard problems (unless P=NL). Dalmau [19] asked whether the converse is true as well, i.e., whether every finite-domain CSP which is in NL can be solved by a linear Datalog program [19]. This is widely treated as a conjecture, to which we refer as the linear Datalog conjecture; it is one of the biggest open problems in finite-domain constraint satisfaction.
There are some sufficient conditions for solvability by linear Datalog (see Bulatov, Kozik, and Willard [3] and Carvalho, Dalmau, and Krokhin [15]) and some necessary conditions (Larose and Tesson [32]) but the results still leave a large gap. For examples of CSPs of orientations of trees that fall into this gap, see Bodirsky, Bulín, Starke, and Wernthaler [7]. Again, linear Datalog is closed under gadget reductions [38]. And indeed, if HornSat has a gadget-reduction in a finite-domain CSP, then the finite-domain CSP cannot be solved by a linear Datalog program [1].
1.3 Symmetric Linear Datalog
A further restriction is symmetric linear Datalog, introduced by Egri, Larose, and Tesson [23]. Symmetric linear Datalog programs can be evaluated in deterministic logspace (L). Egri, Larose, and Tesson conjecture that every finite-domain CSP which is in L can be be solved by a symmetric linear Datalog program [23]; we refer to this conjecture as the symmetric linear Datalog conjecture.
Symmetric linear Datalog is closed under gadget reductions [38]. Since directed reachability is not in symmetric linear Datalog [24], it follows that every CSP that admits a gadget reduction from directed reachability cannot be solved by a symmetric linear Datalog program. Egri, Larose, and Tesson also suggest that this might be the only additional condition for containment in symmetric linear Datalog, besides the known necessary conditions to be in linear Datalog. Kazda [30] confirms the symmetric linear Datalog conjecture conditionally on the truth of the linear Datalog conjecture, i.e., he shows that if a finite-domain CSP is in linear Datalog and does not admit a gadget reduction from a CSP that corresponds to the directed reachability problem, then it is in symmetric linear Datalog (generalizing an earlier result of Dalmau and Larose [20]).
1.4 Our Contributions
In this paper, we study the Datalog fragment that can be obtained by combining all the previously considered restrictions, namely symmetric linear arc monadic (slam) Datalog. Before stating our result we illustrate this fragment with some examples. For , let be the directed path with vertices and edges. An example of a slam Datalog program which solves CSP is
goal |
(in this case, the program is even recursion-free). An example of a slam Datalog program which solves CSP, this time with recursion and IDBs and , is
goal |
The idea why this program is correct is that a finite digraph has a homomorphism to if and only if certain orientations of paths (those of net length three; for a formal description, see Example 8) do not have a homomorphism to ; and the program derives the goal predicate on precisely if there is a homomorphism from such a path to .
It follows from our results that the class of CSPs that can be solved by slam Datalog programs is closed under gadget reductions, despite the many restrictions that we imposed.
We provide a full description of the power of a Datalog fragment in terms of gadget reductions: we show that a CSP can be solved by a slam Datalog program if and only if it has a gadget reduction to CSP.111The statement even holds for infinite-domain CSPs, since being solved by an arc monadic Datalog program implies the existence of a finite template [8] and admitting a gadget reduction to a finite-domain CSP implies the existence of a finite template as well [21]. The particular role of the structure is explained by the fact that it is a representative of the unique class of CSPs which is non-trivial and weakest with respect to gadget reductions – a formalisation of this can be found in Section 2.3.222We mention that is a Boolean structure which simultaneously satisfies the Schaefer conditions of being Horn, dual Horn, affine, and bijunctive [37]. This shows that slam Datalog is the smallest non-trivial fragment of Datalog that is closed under gadget reductions.
Our main result (Theorem 18) establishes a tight connection between the power of slam Datalog and various central themes in structural combinatorics and universal algebra. Specifically, the power of slam Datalog can be characterised by a combinatorial duality which we call unfolded caterpillar duality (restricting the concept of caterpillar duality of Carvalho, Dalmau, and Krokhin [16], and using ideas that appear implicitly in the literature on symmetric Datalog [20, 23, 30]), and by the existence of a quasi Maltsev polymorphism (a central concept in universal algebra) in combination with -ary -absorbing polymorphisms for every (introduced in [16] as well). Our result also implies that the following meta-problem can be decided algorithmically: given a finite structure , can be solved by a slam Datalog program?
1.5 Related Results
Solvability of finite-domain CSPs by (unrestricted) Datalog was first studied by Feder and Vardi; they proved that can be solved by Datalog if and only if has bounded treewidth duality, and they showed that CSPs for systems of linear equations over finite Abelian groups cannot be solved by Datalog. Larose and Zadori [33] showed that solvability by Datalog is preserved by gadget reductions and they asked whether having a gadget reduction from CSPs for systems of linear equations is not only a sufficient, but also a necessary condition for not being solvable by Datalog. This questions was answered positive by Barto and Kozik [4]. Kozik, Krokhin, and Willard [31] gave a characterisation of Datalog in terms of minor conditions.
Linear (but not necessarily symmetric) monadic arc Datalog has been studied by Carvalho, Dalmau, and Krokhin [16]; our proof builds on their result. In their survey on Datalog fragments and dualities in constraint satisfaction [13] Bulatov, Krokhin, and Larose write “it would be interesting to find (…) an appropriate notion of duality for symmetric (Linear) Datalog (…)”. We do find such a notion for symmetric linear arc monadic Datalog, namely unfolded caterpillar duality (Theorem 18).
Another fragment of Datalog consists of the set of conjunctive queries; the CSPs that can be solved by such Datalog programs are precisely the CSPs that are first-order expressible, by Rossman’s theorem [36]. This is also known to be equivalent to CSPs having finite duality. However, note that first-order definability is not preserved under gadget reductions (as we will see in Section 2.6).
2 Preliminaries
We write for the set and for the set . We say that a tuple , for , is injective if is injective when viewed as a function from to .
2.1 Structures and Graphs
We assume familiarity with the concepts of relational structures and first-order formulas from mathematical logic, as introduced for instance in [28]. The arity of a relation symbol is denoted by . If is a -structure, then we sometimes use the same symbol for and the respective relation of . We write for the substructure of induced on .
A (directed) graph is a relational structure with a single binary relation . For instance the clique with vertices is the graph with domain and edges . Let be a graph. An (undirected) path from to in is a tuple such that are pairwise distinct, , , and for all there is an edge between and (from to or from to ). If , then we say that passes through . A graph is called connected if for any two elements there exists a path from to in . A cycle is a path from to of length at least three such that there is an edge between and . A graph is called acyclic if it does not contain any cycle. A graph is called a tree if it is connected and acyclic. A graph has girth if the length of the shortest cycle is .
2.2 Homomorphisms and CSPs
Let be a relational signature and let and be -structures. Then a homomorphism from to is a map such that for , say of arity , we have whenever . An embedding of into is an injective map such that if and only if . We write if there exists a homomorphism from to and if there exists no homomorphism from to .
If is a finite relational signature and is a -structure, then denotes the class of all finite -structures such that . It can be viewed as a computational problem. For example, consists of the set of all finite -colourable graphs, and can therefore be viewed as the -colorability problem. Clearly, for finite structures , this problem is always in NP. Note that from the database perspective, by the work of Chandra and Merlin [17], can be viewed as the expression complexity of conjunctive queries over .
A -structure is homomorphically equivalent to a -structure if there are homomorphisms from to and vice versa. Clearly, homomorphically equivalent structures have the same CSP. A relational -structure is called a core if all endomorphisms of are embeddings. It is well-known and easy to see that every finite structure is homomorphically equivalent to a core , and that all core structures that are homomorphically equivalent to are isomorphic; therefore, we refer to as the core of .
2.3 Primitive Positive Constructions
A -formula is called a conjunctive query (in constraint satisfaction and model theory such formulas are called primitive positive, or short pp) if it is built from atomic formulas (including atomic formulas of the form ) using only conjunction and existential quantification. If is a -structure, and is a conjunctive query over the signature , then the relation is called the relation defined by .
Definition 1.
The canonical database of a conjunctive query over the signature is the -structure that can be constructed as follows: Let be obtained from be renaming all existentially quantified variables such that no two quantified variables have the same name. Let be obtained from by removing all conjuncts of the form in and by identifying variables and if there is a conjunct in . Then is the -structure whose domain is the set of variables of such that for every we have
The canonical conjunctive query of a structure with signature is the primitve positive -formula with variables that contains for every and every the conjunct .
Observe that the canonical database of the canonical conjunctive query of a structure equals . The following concepts have been introduced by Barto, Opršal, and Pinsker [5].
Definition 2.
A (-th) pp-power of a -structure is a structure with domain such that every relation of of arity is definable by a conjunctive query in as a relation of arity . A structure has a primitive positive (pp) construction from if it is homomorphically equivalent to a pp-power of .
Primitive positive constructions turned out to the the essential tool for classifying the complexity of finite-domain CSPs, because if has a pp-construction from , then there is a so-called gadget reduction from to ; in fact, the converse is true as well, see Dalmau and Opršal [21].
Definition 3.
Let be a class of finite -structures and let be a class of finite -structures. Then a (-dimensional) gadget reduction from to consists of a conjunctive query of arity over the signature for every of arity . This defines the following map from finite -structures to finite -structures:
-
replace each element of by the -tuple ;
-
for every of arity and every tuple , introduce a new element for every existentially quantified variable in and define relations for the relation symbols from such that the substructure induced by the new elements and induce a copy of the canonical database of in the natural way, where is obtained from by removing all conjuncts of the form . Let be the resulting structure.
-
let be the smallest equivalence relation that contains all ordered pairs of elements such that there exists and with , such that contains the conjunct . Then .
For instance, the solution to the Feder-Vardi conjecture mentioned in the introduction states that , for a finite structure , is NP-hard if and only if has a pp-construction from (unless ); by what we have stated above, this is true if and only if the 3-coloring problem has a gadget reduction to .
Example 4.
Let be the signature that consists of a single binary relation symbol whose elements we call edges. Let be the -structure with the domain and edges . Then pp-constructs [9], so has a gadget reduction to .
Remark 5.
Given the fundamental importance of conjunctive queries and homomorphisms in database theory, we believe that pp-constructions and gadget reductions are an interesting concept for database theory as well.
2.4 Datalog
Let and be finite relational signatures such that . A Datalog program is a finite set of rules of the form where each is an atomic -formula. The formula is called the head of the rule, and the sequence is called the body of the rule. The symbols in are called EDBs (extensional database predicates) and the other symbols from are called IDBs (intensional database predicates). In the rule heads, only IDBs are allowed. There is one special IDB of arity 0, which is called the goal predicate. IDBs might also appear in the rule bodies. We view the set of rules as a recursive specification of the IDBs in terms of the EDBs – for a detailed introduction, see, e.g., [8]. A Datalog program is called
-
linear if in each rule, at most one IDB appears in the body (we then assume without loss of generality that in every rule whose body contains an IDB, the IDB is listed first).
-
arc if each rule involves at most one EDB.
-
symmetric if it is linear and for every rule where and are build from IDBs, the Datalog program also contains the reversed rule .333Note that we do not have to exclude that is the goal predicate, because we may always add its symmetric version without changing the set of structures on which the goal predicate is derived.
If is a -structure, then we say that is solved by a Datalog program with EDBs if the following holds: the goal predicate is derived by on a finite -structure if and only if there is no homomorphism from to . We say that a Datalog program has width if all IDBs have arity at most , and if every rule has at most variables. For given and a structure , there exists a Datalog program of width with the remarkable property that if some Datalog program of width solves , then solves . This Datalog program is referred to as the canonical Datalog program for of width , and is constructed as follows [25]: For every relation over of arity at most , we introduce a new IDB. The empty relation of arity 0 is the goal predicate. Then contains all rules with at most variables such that the formula holds in the expansion of by all IDBs. If the canonical Datalog program for derives the goal predicate on a finite structure , then there is no homomorphism from to (see, e.g., [8]).
If is the maximal arity of the EDBs, we may restrict the canonical Datalog program of width to those rules with only unary IDBs and at most one EDB; in this case, we obtain the canonical arc monadic Datalog program, which is also known as the arc consistency procedure. Analogously, we may define the canonical linear, and the canonical symmetric Datalog program. We may also combine these restrictions, and in particular obtain a definition the canonical slam Datalog program, i.e., the canonical symmetric linear arc monadic Datalog program, which has not yet been studied in the literature before. The following lemma can be shown analogously to the well-known fact for unrestricted canonical Datalog programs of width (see, e.g., [8]).
Lemma 6.
Let be a finite structure with a finite relational signature, and let be the canonical slam Datalog program for . If is a finite structure with a homomorphism to , then does not derive the goal predicate on .
2.5 The Incidence Graph
Several results from graph theory concerning acyclicity and high girth can be generalised to general structures. To formulate these generalisations, we need the following notion. The incidence graph of a structure with the relational signature is the bipartite graph where one color class is , and the other consists of all pairs of the form such that and . We put an edge between and if for some . The girth of an (undirected) graph is the length of the shortest cycle in . We say that a relational structure is a generalised tree if its incidence graph is a tree. A leaf of a generalised tree is an element of which has degree one in the incidence graph of . A structure is called injective if all tuples that are in some relation in are injective (i.e., have no repeated entries). A structure is called an (injective) tree if it is injective and its incidence graph is a tree.
Theorem 7 (Sparse incomparability lemma for structures [25]).
Let be a finite relational signature. Let and be -structure with finite domains such that . Then for every there exists an injective finite structure whose incidence graph has girth at least , such that and .
2.6 Dualities
For a -structure and a class of -structures the pair is called a duality pair if a finite structure has a homomorphism to if and only if no structure has a homomorphism to . Several forms of duality pairs will be relevant here, depending on the class of structures . A -structure has finite duality if there exists a finite set of -structures such that is a duality pair. The property of having finite duality is among the very few notions studied in the context of constraint satisfaction which is not preserved under gadget reductions, as illustrated in the following example.
Example 8.
Example 9.
Let be the signature that consists of a binary relation symbol and a unary relation symbol . Let be the structure with domain where
and |
Let be the -expansion of where . Then is a duality pair.
A more robust form of duality is tree duality, which plays a central role in constraint satisfaction, and is studied in the graph homomorphism literature in the 90s. A structure has tree duality if there exists a (not necessarily finite) set of trees such that is a duality pair. The following is well known; see Theorem 7.4 in [14]. The equivalence of 1. and 3. is from [25]; also see [6].
Theorem 10.
Let be a finite -structure. Then the following are equivalent:
-
1.
has tree duality;
-
2.
has a pp-construction from ;
-
3.
can be solved by arc consistency.
There are finite structures with tree duality that have a P-complete CSP, such as the structure , which is essentially the Boolean HornSAT problem. In the following, we therefore introduce more restrictive forms of dualities.
Definition 11.
A relational structure is called a generalised caterpillar if it is a generalised tree and its incidence graph contains a path such that every vertex in of the form is connected (in ) to a vertex in .
See Figure 1 (left) for an example. A relational structure is called an (injective) caterpillar if it is injective and a generalised caterpillar (this definition of a caterpillar is equivalent to the one given in [16]). A structure has caterpillar duality if there exists a set of caterpillars such that is a duality pair. The structures with caterpillar duality have been characterised by [16] (Theorem 17) in terms of linear arc Datalog.
To capture the power of symmetric linear arc Datalog, we present a more restrictive form of duality. Let be an (injective) tree and let and be distinct elements of . Write the canonical query of as where contains all conjuncts of the form such that in the incidence graph, all paths from the vertex to the vertex pass though . Similarly, we define , switching the roles of and . Note that and do not share any conjuncts. All the remaining conjuncts of the canonical query form . Let be obtained from () by existentially quantifying all variables except for (, and let be obtained from by existentially quantifying all variables except for and . We introduce the following concept; see Figure 2 for an example.
Definition 12.
Let be an (injective) tree and let and be distinct elements of that are not leaves. The -unfolding of is the canonical database of the formula
where , , and are defined as above. A unfolding of is a structure that is obtained by a sequence such that is an -unfolding of , for all .
Note that an unfolding of a tree is again a tree and has a homomorphism to . It can also be shown that the unfolding of a caterpillar is a caterpillar as well (Lemma 24). We say that a structure has unfolded caterpillar duality if there exists a set of caterpillars such that is a duality pair, and contains every unfolding of a caterpillar in . Clearly, unfolded caterpillar duality implies caterpillar duality. Unfolded generalised caterpillar duality is defined analogously.
2.7 Minor Conditions
If is a structure and , then a polymorphism of of arity is a homomorphism from to . The set of all polymorphisms of is denoted by . An (operation) clone is a set of operations which contains the projections and is closed under composition. Note that is a clone. An operation is called idempotent if for all . A clone is called idempotent if all of its operations are idempotent.
If and are a structures and , then a polymorphism of of arity is a homomorphism from to . The set of all polymorphisms of is denoted by . Let be a function and let , then the map
is called a minor of . A minion is a set or functions from to that is closed under taking minors. Note that is a minion. Let and be minions. A map is called a minion homomorphism if preserves arity and for every of arity and every map we have .
Let be a function signature, i.e., a set of function symbols, each equipped with an arity. A minor condition is a finite set of minor identities, i.e., expressions of the form
where is an -ary function symbol from , is an -ary function symbol from , and are (not necessarily distinct) variables. If is a minion, then a map satisfies a minor condition if for every minor identity and for every assignment we have
We say that a minion satisfies if there exists a map that satisfies .444It is convenient and standard practise to notationally drop the distinction between and . If and are minor conditions, then we say that implies if every clone that satisfies also satisfies . We present some concrete minor conditions that are relevant in the following.
Definition 13.
An operation is called a quasi Maltsev operation if it satisfies the minor condition
A Maltsev operation is an idempotent quasi Maltsev operation. A quasi minority operation is a quasi Maltsev operation that additionally satisfies
and a minority operation is an idempotent quasi minority operation.
Definition 14.
Let . An operation is called -block symmetric if it satisfies the following condition
(1) |
whenever where and . If or then is called totally symmetric.
If is -block symmetric and are subsets of of size at most , then we also write instead of where . We say that is -absorptive if it satisfies
Remark 15.
Note that every structure with a -absorptive polymorphism of arity also has the quasi majority polymorphism given by because and hence
and similarly .
The list of equivalent statements from Theorem 10 can now be extended as follows.
Theorem 16 ([22, 25]).
Let be a finite -structure. Then has tree duality if and only if has totally symmetric polymorphisms of all arities.
We will make crucial use of the following theorem.
Theorem 17 (Theorem 16 in [16]).
Let be a finite relational -structure. Then the following are equivalent.
-
1.
has caterpillar duality.
-
2.
can be solved by a linear arc monadic Datalog program.
-
3.
contains for every an -absorbing operation of arity .
-
4.
is homomorphically equivalent to a structure with binary polymorphisms and such that is a (distributive) lattice.
3 Results
In this section we state and prove our main result (Theorem 18), which characterises the power of slam Datalog in many different ways, including descriptions in terms of pp-constructability in , minor conditions, unfolded caterpillar duality, and homomorphic equivalence to a structure with both lattice and quasi Maltsev polymorphisms.
Theorem 18.
Let be a structure with a finite domain and a finite relational signature . Then the following are equivalent.
-
1.
contains a quasi Maltsev operation and -absorptive operations of arity , for all .
-
2.
The canonical slam Datalog program for solves .
-
3.
Some slam Datalog program solves .
-
4.
has unfolded caterpillar duality.
-
5.
If does not satisfy a minor condition , then implies .
-
6.
Every minor condition that holds in also holds in .
-
7.
There is a minion homomorphism from to .
-
8.
There is a pp-construction of from .
-
9.
is homomorphically equivalent to a structure such that contains a quasi Maltsev operation and operations and such that forms a (distributive) lattice.
We first prove the equivalence of (1)-(6) in cyclic order. We then explain how the equivalence of (6)-(8) follows from general results in the literature, and show the equivalence of (1) and (9). The proof of the theorem stretches over the following subsections.
Remark 19.
If one of the items of Theorem 18 holds for a structure , then there exists a structure with a binary relational signature such that , and all the statements hold for in place of as well.
Example 20.
The structure is the transitive tournament with vertices, i.e., it has the domain and the binary relation . Note that equals . It is easy to see that is a duality pair. Since is a caterpillar Theorem 17 implies that can be solved by a linear arc monadic Datalog program. However, does not have a quasi Maltsev polymorphism for , and hence Theorem 18 implies that cannot be solved by slam Datalog.
3.1 Symmetrizing Linear Arc Monadic Datalog
The following lemma is used for the implication from (1) to (2) in the proof of Theorem 18. Note that in the canonical linear arc monadic Datalog program we can use the “strongest possible rules”555These comments are intended to illustrate the challenges in the proof of next lemma; it will not be necessary to formalise what we mean by strongest possible rules. when deriving the goal predicate. However, the canonical slam Datalog program might need to use weaker rules in order to be able to apply symmetric rules later on in the derivation. See Example 22.
Lemma 21.
Let be a finite structure with relational signature such that contains a quasi Maltsev operation. Let be the canonical linear arc monadic Datalog program for and be the canonical slam Datalog program for . Then can derive the goal predicate on a finite -structure if and only if can derive the goal predicate on .
A proof of the lemma can be found in the long version of the article which is available on ArXiv [10].
Example 22.
Consider the structure with domain , binary relation , and all constants. Let be the structure with domain , , and all constants. Clearly, . The canonical linear arc monadic Datalog program for can derive the goal predicate using the derivation
The canonical slam Datalog program for can also derive the goal predicate on . Since the rule is not symmetric it cannot use . However, it may use a different rule :
Note that is also a rule of but in order to apply the program needs to use the rule which is weaker than the rule (in the sense that the derived IDB is a strict superset).
3.2 Unfolded Caterpillar Duality
This section is devoted to the implication (3) to (4) in Theorem 18; the full proofs can be found in the long version of the article which is available on ArXiv [10]. We first present a general result about obstruction sets for finite-domain CSPs that closes a gap in the presentation of the proof of Lemma 21 in [16] and essentially follows from the sparse incomparability lemma (Theorem 7); we thank Víctor Dalmau for clarification.
Lemma 23.
Let be a finite structure and a class of finite structures such that is a duality pair. Define . Then is a duality pair.
Note that Theorem 17 implies that if is solved by a linear arc monadic Datalog program, then has caterpillar duality; the proof given in [16] only shows generalised caterpillar duality. However, Lemma 23 implies that in this case also has (injective) caterpillar duality.
In order to prove the implication (3) to (4) in Theorem 18, it only remains to prove that also has unfolded caterpillar duality (Lemma 25). We need the following lemma, which has already been mentioned in Section 2.6.
Lemma 24.
An unfolding of a caterpillar is a caterpillar as well.
Lemma 25.
If is solved by a slam Datalog program , then has unfolded caterpillar duality.
Lemma 26.
Let be a relational structure with unfolded caterpillar duality. If does not satisfy a minor condition , then implies .
3.3 Proof of the Main Result
We finally prove Theorem 18.
Proof of Theorem 18.
For the implication let be the canonical slam Datalog program for and let be the canonical linear arc monadic Datalog program for . Since has -absorptive operations of arity for all we can apply Theorem 17 to conclude that solves . Furthermore, has a quasi Maltsev polymorphism. Hence, Lemma 21 implies that and can derive the goal predicate on the same instances of . Therefore, solves .
The implication is trivial, is Lemma 25, and is Lemma 26. For the implication from (5) to (6), suppose that is a minor condition that holds in . Since all polymorphisms of are idempotent, does not imply . Hence, the contraposition of (5) implies that does not satisfy .
The implication from (6) to (1) is clear since is preserved by the Boolean minority operation and by the -absorptive -ary Boolean operation
The equivalence of (1) and (9) follows the equivalence of items (3) and (4) in Theorem 17 and from the fact that the existence of a quasi Maltsev polymorphism is preserved by homomorphic equivalence.
Remark 27.
Consider the poset of all finite structures ordered by primitive positive constructability. It is well known that the structure is a representative of the top element of this poset and that it has exactly one lower cover with representative . We claim that is a representative of a lower cover of in the poset of all finite structures ordered by primitive positive constructability. The structure satisfies all conditions that do not imply the quasi Maltsev condition (see, e.g., [9]). Clearly, does not have a primitive positive construction from , because does not have a quasi Maltsev polymorphism. Since and are polymorphisms of , Theorem 17 implies that has -ary -absorbing polymorphisms for all . Let be a structure with a primitive positive construction from such that does not have a pp-construction from . Then must have a quasi Maltsev polymorphism and -ary -absorbing polymorphisms for all . By Theorem 18, has a primitive positive construction from , which proves the claim. It is still open what other lower covers has.
Remark 28.
Another condition on finite structures that is equivalent to the conditions in Theorem 18 has been found by Vucaj and Zhuk [39]: they prove that there is a minion homomorphism from to (item 7) if and only if contains totally symmetric polymorphisms of all arities and generalised quasi minority polymorphisms of all odd arities . A operation , for odd , is called a generalised quasi minority if it satisfies
However, it is not clear to us whether this characterisation can be used to prove the consequence of our main result from Remark 27.
Remark 29.
Yet another remarkable equivalent condition for solvability by slam Datalog was very recently discovered by Meyer and Starke [34]: the conditions from Theorem 18 hold if and only if can neither pp-construct nor any structure from a list of structures that correspond to the finite simple groups with a particular action; for details, we refer to [34].
4 Decidability of Meta-Problem
There are many interesting results and open problems about algorithmic meta-problems in constraint satisfaction; we refer to [18]. The natural algorithmic meta-problem in the context of our work is the one addressed in the following proposition.
Proposition 30.
There is an algorithm which decides in deterministic doubly-exponential time whether the CSP of a given finite structure can be solved by a slam Datalog program, and if so, computes such a program.
Proof.
The following algorithm can be used to test whether has -absorptive operations of arity , for all . It is well-known that the existence of a quasi Maltsev polymorphism can be decided in non-deterministic polynomial time (see, e.g., [18]). Hence, the statement then follows from Theorem 18.
Let be the maximal arity of the relations of . Let and . Note that has -absorptive polymorphisms of arity , for all , if and only if it has -absorptive polymorphisms of arity (similarly as the well-known fact that has totally symmetric polymorphisms of all arities if and only if it has totally symmetric polymorphisms of arity ; the term bounds the size of antichains in the set of all subsets of . Also see [15] for the case of -absorptive polymorphisms). Let be the minor condition for the existence of -absorptive operations of arity . Let be the indicator structure of with respect to as defined in Section A.1; clearly, this structure can be computed in doubly exponential time. We may then find a non-deterministic algorithm with the same time bound that tests whether there exists a homomorphism from to . The non-determinism for checking whether can be eliminated by standard self-reduction techniques (again see, e.g., [18]). For the second part of the statement, note that there are for a given only finitely many potential rules of a slam Datalog program, and one can compute for a given rule whether it is part of the canonical slam Datalog program of .
5 Conclusion and Open Problems
We characterised the unique submaximal element in the primitive positive constructability poset on finite structures, linking concepts from homomorphism dualities, Datalog fragments, minor conditions, and minion homomorphisms. It is now tempting to further descend in the pp-constructability poset of finite structures in order to obtain a more systematic understanding. Particularly attractive are other dividing lines in the poset that are relevant for the complexity of the constraint satisfaction problem. We propose the following problems for future research.
-
Characterise all finite structures that are primitively positively constructible in a finite structure that has finite duality. Are these exactly the finite structures whose polymorphism clones have Hagemann-Mitschke chains of some length and extended -absorptive polymorphisms of arity , for all , as defined in [16]? Is there a Datalog fragment that corresponds to this class?
-
What is the precise computational complexity the Meta-Problem of deciding whether the CSP of a given finite structure can be solved by a slam Datalog program? Proposition 30 only provides a deterministic doubly exponential time algorithm.
References
- [1] Foto N. Afrati and Stavros S. Cosmadakis. Expressiveness of restricted recursive queries (extended abstract). In David S. Johnson, editor, Proceedings of the 21st Annual ACM Symposium on Theory of Computing, May 14-17, 1989, Seattle, Washigton, USA, pages 113–126. ACM, 1989. doi:10.1145/73007.73018.
- [2] Albert Atserias, Andrei A. Bulatov, and Anuj Dawar. Affine systems of equations and counting infinitary logic. Theoretical Computer Science, 410(18):1666–1683, 2009. doi:10.1016/J.TCS.2008.12.049.
- [3] L. Barto, M. Kozik, and R. Willard. Near unanimity constraints have bounded pathwidth duality. In Proceedings of the 27th ACM/IEEE Symposium on Logic in Computer Science (LICS), pages 125–134, 2012.
- [4] Libor Barto and Marcin Kozik. Constraint satisfaction problems of bounded width. In Proceedings of the Annual Symposium on Foundations of Computer Science (FOCS), pages 595–603, 2009. doi:10.1109/FOCS.2009.32.
- [5] Libor Barto, Jakub Opršal, and Michael Pinsker. The wonderland of reflections. Israel Journal of Mathematics, 223(1):363–398, 2018.
- [6] Manuel Bodirsky. Graph homomorphisms and universal algebra. Lecture Notes, https://wwwpub.zih.tu-dresden.de/~bodirsky/GH-UA.pdf, 2023.
- [7] Manuel Bodirsky, Jakub Bulín, Florian Starke, and Michael Wernthaler. The smallest hard trees. Constraints, abs/2205.07528, 2022. doi:10.48550/arXiv.2205.07528.
- [8] Manuel Bodirsky and Víctor Dalmau. Datalog and constraint satisfaction with infinite templates. Journal on Computer and System Sciences, 79:79–100, 2013. A preliminary version appeared in the proceedings of the Symposium on Theoretical Aspects of Computer Science (STACS’05). doi:10.1016/J.JCSS.2012.05.012.
- [9] Manuel Bodirsky and Florian Starke. Maximal digraphs with respect to primitive positive constructability. Combinatorica, 42:997–1010, 2022. doi:10.1007/S00493-022-4918-1.
- [10] Manuel Bodirsky and Florian Starke. Symmetric linear arc monadic datalog and gadget reductions. https://arxiv.org/abs/2407.04924, 2025.
- [11] Manuel Bodirsky, Florian Starke, and Albert Vucaj. Smooth digraphs modulo primitive positive constructability and cyclic loop conditions. International Journal on Algebra and Computation, 31(5):939–967, 2021. Preprint available at ArXiv:1906.05699.
- [12] Andrei A. Bulatov. A dichotomy theorem for nonuniform CSPs. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, pages 319–330, 2017. doi:10.1109/FOCS.2017.37.
- [13] Andrei A. Bulatov, Andrei Krokhin, and Benoit Larose. Dualities for Constraint Satisfaction Problems, pages 93–124. Springer Berlin Heidelberg, Berlin, Heidelberg, 2008. doi:10.1007/978-3-540-92800-3_5.
- [14] Jakub Bulín, Andrei A. Krokhin, and Jakub Opršal. Algebraic approach to promise constraint satisfaction. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, STOC 2019, Phoenix, AZ, USA, June 23-26, 2019, pages 602–613, 2019. doi:10.1145/3313276.3316300.
- [15] Catarina Carvalho, Víctor Dalmau, and Andrei Krokhin. CSP duality and trees of bounded pathwidth. Theoretical Computer Science, 411:3188–3208, 2010. doi:10.1016/J.TCS.2010.05.016.
- [16] Catarina Carvalho, Víctor Dalmau, and Andrei A. Krokhin. Two new homomorphism dualities and lattice operations. J. Log. Comput., 21(6):1065–1092, 2011. doi:10.1093/LOGCOM/EXQ030.
- [17] Ashok K. Chandra and Philip M. Merlin. Optimal implementation of conjunctive queries in relational data bases. In Proceedings of the Symposium on Theory of Computing (STOC), pages 77–90, 1977. doi:10.1145/800105.803397.
- [18] Hubie Chen and Benoît Larose. Asking the metaquestions in constraint tractability. TOCT, 9(3):11:1–11:27, 2017. doi:10.1145/3134757.
- [19] Víctor Dalmau. Linear Datalog and bounded path duality of relational structures. Logical Methods in Computer Science, 1(1), 2005. doi:10.2168/LMCS-1(1:5)2005.
- [20] Víctor Dalmau and Benoît Larose. Maltsev + Datalog → symmetric Datalog. In Proceedings of the Twenty-Third Annual IEEE Symposium on Logic in Computer Science, LICS 2008, 24-27 June 2008, Pittsburgh, PA, USA, pages 297–306. IEEE Computer Society, 2008.
- [21] Victor Dalmau and Jakub Opršal. Local consistency as a reduction between constraint satisfaction problems, 2023. arXiv:2301.05084.
- [22] Víctor Dalmau and Justin Pearson. Closure functions and width 1 problems. In Proceedings of the International Conference on Principles and Practice of Constraint Programming (CP), pages 159–173, 1999. doi:10.1007/978-3-540-48085-3_12.
- [23] László Egri, Benoit Larose, and Pascal Tesson. Symmetric Datalog and constraint satisfaction problems in logspace. In Proceedings of the Symposium on Logic in Computer Science (LICS), pages 193–202, 2007.
- [24] László Egri, Benoît Larose, and Pascal Tesson. Directed st-connectivity is not expressible in symmetric Datalog. In Automata, Languages and Programming, 35th International Colloquium, ICALP 2008, Reykjavik, Iceland, July 7-11, 2008, Proceedings, Part II - Track B: Logic, Semantics, and Theory of Programming & Track C: Security and Cryptography Foundations, pages 172–183, 2008. doi:10.1007/978-3-540-70583-3_15.
- [25] Tomás Feder and Moshe Y. Vardi. The computational structure of monotone monadic SNP and constraint satisfaction: a study through Datalog and group theory. SIAM Journal on Computing, 28:57–104, 1999. doi:10.1137/S0097539794266766.
- [26] P. Hell, J. Nešetřil, and X. Zhu. Duality and polynomial testing of tree homomorphisms. TAMS, 348(4):1281–1297, 1996.
- [27] Pavol Hell and Jaroslav Nešetřil. Graphs and Homomorphisms. Oxford University Press, Oxford, 2004.
- [28] Wilfrid Hodges. A shorter model theory. Cambridge University Press, Cambridge, 1997.
- [29] P. C. Kanellakis. Logic programming and parallel complexity, pages 547–585. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 1988. Book chapter in ‘Foundations of Deductive Databases and Logic Programming’.
- [30] Alexandr Kazda. -permutability and linear Datalog implies symmetric Datalog. Logical Methods in Computer Science, Volume 14, Issue 2, April 2018. doi:10.23638/LMCS-14(2:3)2018.
- [31] Marcin Kozik, Andrei Krokhin, Matt Valeriote, and Ross Willard. Characterizations of several Maltsev conditions. Algebra universalis, 73(3):205–224, 2015. doi:10.1007/s00012-015-0327-2.
- [32] Benoit Larose and Pascal Tesson. Universal algebra and hardness results for constraint satisfaction problems. Theoretical Computer Science, 410(18):1629–1647, 2009. doi:10.1016/J.TCS.2008.12.048.
- [33] Benoit Larose and László Zádori. Bounded width problems and algebras. Algebra Universalis, 56(3-4):439–466, 2007.
- [34] Sebastian Meyer and Florian Starke. Finite simple groups in the primitive positive constructability poset, 2024. arXiv:2409.06487.
- [35] Reinhard Pöschel and Lev A. Kalužnin. Funktionen- und Relationenalgebren. Deutscher Verlag der Wissenschaften, Berlin, 1979.
- [36] Benjamin Rossman. Homomorphism preservation theorems. Journal of the ACM, 55(3), 2008. doi:10.1145/1379759.1379763.
- [37] Thomas J. Schaefer. The complexity of satisfiability problems. In Proceedings of the Symposium on Theory of Computing (STOC), pages 216–226, 1978. doi:10.1145/800133.804350.
- [38] Florian Starke. Digraphs modulo primitive positive constructability. Preprint, 2024. PhD dissertation, Institute of Algebra, TU Dresden.
- [39] Albert Vucaj and Dmitriy Zhuk. Submaximal clones over a three-element set up to minor-equivalence, 2024. arXiv:2304.12807.
- [40] Dmitriy Zhuk. A proof of the CSP dichotomy conjecture. J. ACM, 67(5):30:1–30:78, 2020. doi:10.1145/3402029.
- [41] Dmitriy N. Zhuk. A proof of CSP dichotomy conjecture. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, pages 331–342, 2017. URL: https://arxiv.org/abs/1704.01914.
Appendix A Appendix
A.1 Indicator Structures
In this section we revisit a common theme in constraint satisfaction, the concept of an indicator structure of a minor condition. To simplify the presentation, we only define the indicator structure for minor conditions with only one function symbol. For our purposes, this is without loss of generality, because for clones over a finite domain, every minor condition is equivalent to such a restricted minor condition. If and are operations, then the star product is defined to be the operation defined as
Lemma 31.
Let be a minor condition. Then there exists a minor condition with a single function symbol such that a clone over a finite domain satisfies if and only if it satisfies .
Proof.
First note that for every clone on a finite set there exists an idempotent clone on a finite set which is equivalent to it with respect to minion homomorphisms, i.e., there are minion homomorphism from to and vice versa. It is well-known and easy to see that if are the function symbols that appear in , and satisfies , also contains an operation of arity such that for every there exists such that (use that is closed under the star product and idempotent). Note that satisfies a minor identity if and only if satisfies a minor identity .
If is a relational -structure and is an equivalence relation on , the is the -structure whose domain are the equivalence classes of , and where holds if there exist such that holds in .
Definition 32.
Let be a relational -structure and let be a minor condition with a single function symbol of arity . Let be the smallest equivalence relation on such that if contains such that there is a map with and . Then the indicator structure of with respect to is the -structure .
The following is straightforward from the definitions.
Lemma 33.
Let be a structure and be a minor condition with a single function symbol . Then has a polymorphism satisfying if and only if the indicator structure of with respect to has a homomorphism to .
Appendix B Remarks on Related Results
The following remarks show that the results of Carvalho, Dalmau and Krokhin [15] can be extended in the same spirit as our Theorem 18.
Remark 34.
Let be the structure , also known as st-Con. Theorem 17 of Carvalho, Dalmau and Krokhin can be extended in the same spirit as our Theorem 18, by adding the following equivalent items:
-
5.
Every minor condition that holds in also holds in .
-
6.
There is a minion homomorphism from to .
-
7.
has a primitive positive construction from .
Proof.
It is well known that is generated by the two binary operations and .666Proof sketch: clearly, and preserve the relations of . For the converse inclusion, it suffices to verify that every relation that is preserved by and has a primitive positive definition in (see, e.g. [35]). Every Boolean relation preserved by and has a definition in CNF which is both Horn and dual Horn, so consists of clauses that can be defined using the relations in . This implies the claim. Let be a structure that is homomorphically equivalent to a structure with binary polymorphisms and such that is a distributive lattice. Note that is a distributive lattice as well. Let be the map that maps terms over to terms over by replacing and by and , respectively. Define the map as follows. Since is generated by and , for every there is a -term whose term operation is . Define as the term operation of . Note that this term operation is a polymorphism of . It is clear that is a minion homomorphism (even a clone homomorphism). We still need to show that is well defined. Let and be two -terms that both have the term operation . Since is a distributive lattice, there is a set of subsets of such that is the term operation of . Furthermore, and can both be rewritten (using associativity, commutativity, distributivity, and idempotence) into the term . Therefore, and can also both be rewritten into the term . Since is a distribute lattice, the term operations of , , and are the same. Hence, is well defined.
holds since has for every a -absorbing polymorphism of arity .
Remark 35.
We consider the structure where , , and for every . It is well known that is generated by the operation given by . Carvalho, Dalmau and Krokhin also introduce another type of duality in their paper: jellyfish duality. Their characterization in Theorem 18 in [15] can be extended by the following items:
-
6.
Every minor condition that holds in also holds in .
-
7.
There is a minion homomorphism from to .
-
8.
has a primitive positive construction from .
The proof of Remark 35 is mostly analogous to the previous one. Here we only sketch the proof that is generated by the operation given by .
Clearly, every relation of is preserved by the operation . For the converse inclusion, it suffices to verify that every relation that is preserved by has a primitive positive definition in (see, e.g., [35]). First note that , and hence every Boolean relation preserved by has a Horn definition; pick such a definition which is shortest possible. Suppose for contradiction that a Horn clause in contains a positive literal and two negative literals and . By the minimality assumption there are tuples such that satisfies and no other literal in that clause. Then satisfies none of , a contradiction. It follows that each clause can be defined using the relations in and the statement follows.