The Complexity of Resilience for Digraph Queries
Abstract
We prove a complexity dichotomy for the resilience problem for unions of conjunctive digraph queries (i.e., for existential positive sentences over the signature of directed graphs). Specifically, for every union of conjunctive digraph queries, the following problem is in P or NP-complete: given a directed multigraph and a natural number , can we remove edges from so that ? In fact, we verify a more general dichotomy conjecture from [6] for all resilience problems in the special case of directed graphs, and show that for such unions of queries there exists a countably infinite (‘dual’) valued structure which either primitively positively constructs 1-in-3-3-SAT, and hence the resilience problem for is NP-complete by general principles, or has a pseudo cyclic canonical fractional polymorphism, and the resilience problem for is in P.
Keywords and phrases:
valued constraints, unions of conjunctive queries, resilience, computational complexity, pp-constructionsFunding:
Manuel Bodirsky: The author has been funded by the European Research Council (Project POCOCOP, ERC Synergy Grant 101071674) and by the DFG (Project FinHom, Grant 467967530). 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.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Problems, reductions and completeness ; Theory of computation Complexity theory and logic ; Theory of computation Database query processing and optimization (theory)Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The resilience problem for a fixed conjunctive query, or more generally for a union of conjunctive queries , is the problem of deciding for a given database and whether it is possible to remove at most tuples from so that does not satisfy . The resilience problem lies at the core of algorithmic challenges in various forms of reverse data management, where an action is required on the input data to achieve a desired outcome in the output data [18]. The computational complexity of this problem depends on the query . The resilience problem is always in NP, and often NP-complete, but for some queries the problem can be solved in polynomial time; see, e.g., [12, 13, 17, 6] for some partial classification results.
The computational complexity of the problem also depends on whether we view the database under set semantics (i.e., is treated as a relational structure) or under bag semantics (i.e., is a structure where each tuple appears with some multiplicity), and both settings have been studied in the literature (in particular, see [6, 17] for results in bag semantics). The importance of bag semantics stems from applications: bag databases represent SQL databases more faithfully. There are examples of conjunctive queries for which the resilience problem in bag and set semantics have different complexities [17].
Recently, a connection between the resilience problem under bag semantics and valued constraint satisfaction has been established [6]. The connection is based on the fact that for every union of connected conjunctive queries , the resilience problem in bag semantics is equal to a valued constraint satisfaction problem (VCSP) for some template dependent on , and therefore the algebraic tools developed for describing the complexity of VCSPs can be utilized. To do so, we focus in this paper on the resilience problem exclusively under bag semantics and from now on, always implicitly assume this semantics for resilience problems.
It has been conjectured that resilience problems exhibit a complexity dichotomy in the sense that all problems are NP-complete or in P [17]. This conjecture has been verified in some special cases, for instance if is a conjunctive query which is self-join-free [17], or if is a union of conjunctive queries that are Berge-acyclic [6]. The proof of the latter is based on a connection to finite-domain VCSPs, which also covers resilience problems for regular path queries (RPQs), and even two-way RPQs. Resilience of (one-way) RPQs has also been studied recently in [1] where the authors present language-theoretic conditions for computational hardness. However, the conjecture in full generality remains open.
In this article, we confirm the complexity dichotomy conjecture in the special case where the signature of the database consists of a single binary relation symbol , that is, we prove the following:
Theorem 1.
If is a union of conjunctive queries over a binary signature , then the resilience problem for is in P or NP-complete.
The class of unions of conjunctive queries over is incomparable with the class of queries studied in [13] (in set semantics), since they study queries with arbitrary signatures, but with a single repetition of a single binary relation symbol. In the case that the signature is equal to , the query expresses a directed graph property and the resilience problem can be phrased as follows: given a directed multigraph and a natural number , can we remove edges from so that ? Edge-removal problems have been studied from a computational complexity perspective in the graph theory community as well, especially for concrete properties [15, Section A1.2]. In [11] the authors study edge-removal problems for first-order logic properties in general; however, they only consider simple undirected graphs and study the problem from the perspective of parametrized complexity, where the number of edges that is removed is the parameter.
The scope of our contribution extends beyond verifying the complexity dichotomy conjecture for digraph resilience problems: we also verify a variant of a stronger conjecture (from [6]) which provides a precise mathematical condition aiming at predicting the border between NP-hardness and polynomial-time tractability, based on simulations of a hard Boolean constraint satisfaction problem (CSP) using so-called pp-constructions. This condition is one-sided correct in the sense that if it applies, the corresponding resilience problem is NP-hard. The authors of [6] conjectured that if the condition does not apply, the resilience problem is in P.
Several results in the present paper are relevant for the larger research goal of classifying the complexity of all resilience problems in bag semantics by modeling them as VCSPs and applying methods and results from the VCSP literature. For instance, our result that the two conditions of the dichotomy statement are disjoint (Corollary 33) holds for resilience problems in general (without the assumption that P NP). Another result that holds for resilience in general is Theorem 40, which provides pp-constructions (and, therefore, polynomial-time reductions) based on the idea of self-join variations from [13]. We believe that this paper is an important step towards classifying the complexity for resilience problems of queries with self joins and understanding reductions between resilience problems by algebraic and logic tools.
2 Preliminaries
In this section, we provide preliminaries that cover the notions appearing in Section 4, where the main theorem of the article (Theorem 34) is stated. Since the theorem provides not only a complexity dichotomy, but also an algebraic one, this requires several notions from the theory of VCSPs. For readers mostly interested in the complexity of resilience problems on its own, we recommend reading only Sections 2.1–2.4 and skipping Sections 2.5–2.8, and coming back to them when they are needed in the proofs in the article.
The set of natural numbers is denoted by . For , the set will be denoted by . The set of rational numbers is denoted by and the standard strict linear order on by . The set of real numbers is denoted by . We also need an additional value ; all we need to know about is that
-
for every ,
-
for all , and
-
and for .
Let be a set and . If , then we implicitly assume that , where . If and is an operation on and , then we denote by and say that is applied componentwise.
2.1 Valued structures
Let be a set and let . A valued relation of arity over is a function . We write for the set of all valued relations over of arity , and define
A valued relation is called finite-valued if it takes values only in . Usual relations will also be called crisp relations. A valued relation that only takes values from will be identified with the crisp relation The unary empty relation, where every element evaluates to , is denoted by . The crisp equality relation, where a pair of elements evaluates to if they are equal and evaluates to otherwise, is denoted by . For the feasibility relation of is defined as
A (relational) signature is a set of relation symbols, each of them equipped with an arity from . A valued -structure consists of a set , which is also called the domain of , and a valued relation for each relation symbol of arity . All valued structures in this article have countable domains. We often write instead of if the valued structure is clear from the context. A valued -structure where all valued relations only take values from may be viewed as a relational or crisp -structure in the classical sense. When not specified, we assume that the domains of relational structures are denoted , respectively, and the domains of valued structures are denoted , respectively.
Example 2.
Let be a binary relation symbol. Then with the domain and the signature where if and , and otherwise, is a valued structure.
If and is a valued -structure such that for every , then we call a reduct of and an expansion of .
Let be a relational signature. A first-order formula is called atomic if it is of the form for some of arity , , or . We introduce a generalization of conjunctions of atomic formulas to the valued setting. An atomic -expression is an expression of the form for and (not necessarily distinct) variable symbols . A -expression is an expression of the form where and for is an atomic -expression. Note that the same atomic -expression might appear several times in the sum. We write for a -expression where all the variables are from the set . If is a valued -structure, then a -expression defines over a member of in a natural way, which we denote by . If is the empty sum then is constant .
Definition 3.
Let , let , and let be a permutation of . Then preserves if for all we have . If is a valued structure with domain , then an automorphism of is a permutation of that preserves all valued relations of .
The set of all automorphisms of is denoted by , and forms a group with respect to composition.
Let be a set and . An operation on the set preserves if for every . If is a relational structure and preserves all relations of , then is called a polymorphism of . The set of all polymorphisms of is denoted by and is closed under composition. We write for the set of -ary operations in , . Unary polymorphisms are called endomorphisms and is also denoted by .
Let be a relational signature and let and be relational -structures. A map is called a homomorphism from to if for every of arity and every , . and are called homomorphically equivalent if there is a homomorphism from to and from to , and they are called homomorphically incomparable if there is no homomorphism from to or from to . The generalizations of the notions of polymorphisms and homomorphisms to valued structures will be defined in Sections 2.7 and 2.8.
2.2 Valued constraint satisfaction problems
In this section we assume that is a fixed valued -structure for a finite signature . We first define the valued constraint satisfaction problem of a relational structure and then explain the connection to the less general constraint satisfaction problem in Remark 5.
Definition 4.
The valued constraint satisfaction problem for , denoted by , is the computational problem to decide for a given -expression and a given whether there exists such that . We refer to as an instance of , and to as the threshold. Tuples such that are called a solution for . The cost of (with respect to ) is defined to be
In some contexts, it is beneficial to consider only a given -expression to be the input of (rather than and the threshold ) and a tuple is then called a solution for if the cost of equals . Note that in general there might not be any solution; however, this is never the case for VCSPs considered in this paper as they stem from resilience problems. If there exists a tuple such that then is called satisfiable.
For relational structures, VCSPs specialize to CSPs, as explained below.
Remark 5.
If is a relational -structure, then is the problem of deciding satisfiability of conjunctions of atomic formulas over in . Note that for every -expression , defines a crisp relation and can be viewed as a conjunction of atomic formulas, which defines the same relation. Minimizing then corresponds to finding such that , i.e. that satisfies all atomic formulas in the conjunction. Therefore, and are essentially the same problem.
Example 6.
The problem for the valued structure from Example 2 models the directed max-cut problem: given a finite directed multigraph , find a partition of the vertices into two classes and such that the number of edges from to is maximal. Maximising the number of edges from to amounts to minimising the number of edges within , within , and from to . So when we associate to the preimage of and to the preimage of , computing the answer corresponds to finding the evaluation map that minimises the value
which can be formulated as an instance of . Conversely, every instance of corresponds to a directed max-cut instance.
Example 7.
Consider the relation . is the so called 1-in-3-3-SAT problem, which is known to be NP-complete (see, e.g., [4, Example 1.2.2]).
2.3 Conjunctive queries and resilience
A first-order formula is called primitive positive if it is an existentially quantified conjunction of atomic formulas. A conjunctive query over a (relational) signature is a primitive positive -sentence and a union of conjunctive queries is a (finite) disjunction of conjunctive queries. Note that every existential positive sentence can be written as a union of conjunctive queries.
If is a relational -structure and is a union of conjunctive queries over with a quantifier-free part , we say that witnesses that if . Given conjunctive queries and over , we say that is equivalent to if if and only if for every finite relational -structure . We say a conjunctive query is minimal if every conjunctive query which is equivalent to has at least as many atoms as . For every conjunctive query , there exists a minimal equivalent query that can be obtained from by removing zero or more atoms [9].
A multiset relation on a set of arity is a multiset with elements from and a bag database over a relational signature consists of a finite domain and for every of arity , a multiset relation of arity . A bag database satisfies a union of conjunctive queries if the relational structure obtained from by forgetting the multiplicities of tuples in its relations satisfies . In the present paper, we study the resilience problem for unions of conjunctive queries in bag semantics; from now on we will refer to this problem just as the resilience problem. Let be a finite relational signature and a union of conjunctive queries over . The input to the resilience problem for consists of a bag database over , and the task is to compute the number of tuples that have to be removed from relations of so that does not satisfy . This number is called the resilience of (with respect to ). As usual, this can be turned into a decision problem where the input also contains a natural number and the question is whether the resilience is at most . Clearly, does not satisfy if and only if its resilience is . It is easy to see that the resilience problem for any union of conjunctive queries is in NP.
The canonical database of a conjunctive query with relational signature is the relational -structure whose domain are the variables of and where for of arity if and only if contains the conjunct ; we denote the canonical database by .
Remark 8.
All terminology introduced for -structures also applies to conjunctive queries over : by definition, a query has the property if its canonical database has the property.
Note that by the above remark, we can talk about homomorphisms between queries and queries being homomorphically incomparable. Observe that if two queries are non-equivalent and minimal, they must be homomorphically incomparable (see, e.g., [9]).
A relational -structure is connected if it cannot be written as the disjoint union of two relational -structures with non-empty domains. We show that when classifying the resilience problem for conjunctive queries, it suffices to consider queries that are connected.
Lemma 9 ([6, Lemma 8.5]).
Let be conjunctive queries such that does not imply if . Let and suppose that occurs in a union of conjunctive queries. For , let be the union of queries obtained by replacing by in . Then the resilience problem for is NP-hard if the resilience problem for one of the is NP-hard. Conversely, if the resilience problem is in P for each , then the resilience problem for is in P as well.
By applying Lemma 9 finitely many times, we obtain that, when classifying the complexity of the resilience problem for unions of conjunctive queries, we may restrict our attention to unions of connected conjunctive queries.
2.4 Connection between resilience and VCSPs
In this section we summarize the key points of the connection between resilience problems and VCSPs, originally introduced in [6].
Definition 10.
Let be a relational -structure. Define to be the valued -structure on the same domain as such that for each , if and otherwise.
If is a union of conjunctive queries with signature , then a dual of is a relational -structure with the property that a finite relational -structure has a homomorphism to if and only if does not satisfy . If and are both duals of , then they are homomorphically equivalent by compactness [4, Lemma 4.1.7].
Proposition 11 ([6, Proposition 8.14]).
Let be a union of connected conjunctive queries with signature . Then the resilience problem for is polynomial-time equivalent to for any dual of .
Let , let be a set and a permutation group on . An orbit of -tuples of is a set of the form for some . A permutation group on a countable set is called oligomorphic if for every there are finitely many orbits of -tuples in [8]. From now on, whenever we write that a structure has an oligomorphic automorphism group, we also imply that its domain is countable. Clearly, every valued structure with a finite domain has an oligomorphic automorphism group. A countable relational structure has an oligomorphic automorphism group if and only if it is -categorical, i.e., if all countable models of its first-order theory are isomorphic [16].
A relational -structure embeds into a relational -structure if there is an injective map from to that preserves all relations of and their complements; the corresponding map is called an embedding. The age of a relational -structure is the class of all finite relational -structures that embed into it. A relational structure with a relational signature is called
-
finitely bounded if is finite and there exists a universal -sentence such that a finite relational structure is in the age of iff ;
-
homogeneous if every isomorphism between finite substructures of can be extended to an automorphism of .
If is finitely bounded and homogeneous, then is oligomorphic.
Theorem 12 ([6, Theorem 8.12]).
For every union of connected conjunctive queries over a finite relational signature there exists a -structure such that the following statements hold:
-
1.
is a reduct of a finitely bounded and homogeneous structure .
-
2.
A countable -structure satisfies if and only if it embeds into .
-
3.
is finitely bounded.
-
4.
and are oligomorphic.
The existence of the dual for a union of connected conjunctive queries is the key to obtaining another dual , which has a strong model-theoretic property introduced in the following definition. If is a permutation group on a set , then denotes the closure of in the space with respect to the topology of pointwise convergence. This is the unique topology such that the closed subsets of are precisely the endomorphism monoids of relational structures; see, e.g., [4, Proposition 4.4.2]. Note that might contain some operations that are not surjective, but if for some relational structure , then all operations in are still embeddings of into that preserve all first-order formulas.
Definition 13.
A relational structure with an oligomorphic automorphism group is a model-complete core if .
For every relational structure with an oligomorphic automorphism group, there exists a model-complete core homomorphically equivalent to , which is unique up to isomomorphism called the model-complete core of [3, Theorem 16], [4, Proposition 4.7.7]. Intuitively, the model-complete core of is in a sense a “minimal” structure with the same CSP as . If the domain of is finite, then the domain of its model-complete core (usually just called core) is also finite.
The Gaifman graph of a relational structure is the undirected graph with vertex set where are adjacent if and only if and there exists a tuple in a relation of that contains both and . The Gaifman graph of a conjunctive query is the Gaifman graph of the canonical database of that query.
The following is an analogue of Theorem 12 for the model-complete core of . The statements in the theorem should be considered to be previously known; we provide a proof with references to the literature for the convenience of the reader.
Theorem 14.
Let be a union of connected conjunctive queries over a finite relational signature . Then the model-complete core 111In [6], the notation was used for a different dual of , which we do not need in this paper. of the structure from Theorem 12 satisfies the following:
-
1.
is a reduct of a finitely bounded and homogeneous structure .
-
2.
A countable -structure satisfies if and only if there is a homomorphism from to .
-
3.
If for each query in , the Gaifman graph of is complete, then is homogeneous.
-
4.
and are oligomorphic.
Proof.
Item (2) is a consequence of being homomorphically equivalent to .
To prove (3), suppose that for each query in , the Gaifman graph of is complete. By [6, Theorem 8.13], there exists a dual of , which is homogeneous. By [4, Proposition 4.7.7], the model-complete core of is also homogeneous. Note that is homomorphically equivalent to as they are both duals of and hence, by uniqueness, it is the model-complete core of .
For item (4), note that the automorphism group of is oligomorphic since it is homogeneous with finite relational signature. The automorphism group of is oligomorphic, since this property is clearly preserved under taking reducts.
Note that since is unique up to isomorphism and homomorphic equivalence is transitive, the structure does not depend on the concrete choice of . For a union of connected conjunctive queries , let . In most results, this will be the valued structure to which we apply results about for a dual of .
2.5 Expressive power
The concept of expressive power introduced in this section is a basis for polynomial-time gadget reductions between VCSPs.
Definition 15.
Let be a set and . We say that can be obtained from by
-
projecting if is of arity , is of arity and for all
-
non-negative scaling if there exists such that ;
-
shifting if there exists such that .
If is of arity , then the relation that contains all minimal-value tuples of is
Note that in item (1) might be irrational or . If this is the case, then does not express a valued relation because valued relations must have weights from . However, if is preserved by all permutations of an oligomorphic automorphism group, then attains only finitely many values and therefore this is never the case.
If , then an atomic expression over is an atomic -expression where . We say that is closed under forming sums of atomic expressions if it contains all valued relations defined by sums of atomic expressions over .
Definition 16 (valued relational clone).
A valued relational clone (over a set ) is a subset of that is closed under forming sums of atomic expressions, projecting, shifting, non-negative scaling, , and ; we refer to expressions formed this way as pp-expressions. For a valued structure with the domain , we write for the smallest relational clone that contains the valued relations of . If , we say that pp-expresses .
The acronym “pp” stands for primitive positive, since the concept of pp-expressions for valued structures is a generalization of primitive positive definitions used for reductions between CSPs.
2.6 Fractional maps
Let and be sets. We equip the space of functions from to with the topology of pointwise convergence, where is taken to be discrete. In this topology, a basis of open sets is given by for and for some . For any topological space , we denote by the Borel -algebra on , i.e., the smallest subset of the powerset which contains all open sets and is closed under countable intersection and complement. We write for the set .
Definition 17 (fractional map).
Let and be sets. A fractional map from to is a probability distribution that is, and is countably additive: if are disjoint, then
We often use for both the entire fractional map and for the map .
The set carries the topology inherited from the standard topology on . We also view as a topological space with a basis of open sets given by all open intervals for , and additionally all sets of the form (thus, is equipped with its order topology when ordered in the natural way).
A (real-valued) random variable is a measurable function , i.e., pre-images of elements of under are in . If is a real-valued random variable, then the expected value of (with respect to a probability distribution ) is denoted by and is defined via the Lebesgue integral
In the rest of the paper, we will work exclusively with topological spaces of the form for some sets and .
2.7 Pp-constructions
In this section, we introduce a concept of pp-constructions which generalize pp-expressions and provide polynomial-time reductions between VCSPs. We first define fractional homomorphisms.
Definition 18 (fractional homomorphism).
Let and be valued -structures with domains and , respectively. A fractional homomorphism from to is a fractional map from to such that for every of arity and every tuple it holds for the random variable given by that exists and that
We refer to [6] for a detailed introduction to fractional homomorphisms. Two valued -structures and are said to be fractionally homomorphically equivalent, if there is a fractional homomorphism from to and from to .
Remark 19.
If is a union of conjunctive queries with duals and , then and are homomorphically equivalent. Hence, and are fractionally homomorphically equivalent witnessed by fractional maps where the respective homomorphisms have probability .
As a next step towards the definition of a pp-construction, we define pp-powers.
Definition 20 (pp-power).
Let be a valued structure with a domain and let . Then a (-th) pp-power of is a valued structure with the domain such that for every valued relation of of arity there exists a valued relation of arity in such that
We can now define the notion of a pp-construction.
Definition 21 (pp-construction).
Let be valued structures. Then has a pp-construction in if is fractionally homomorphically equivalent to a structure which is a pp-power of .
The relation of pp-constructability is transitive: if , , and are valued structures such that pp-constructs and pp-constructs , then pp-constructs [6, Lemma 5.12]. Note that whenever is a union of connected conjunctive queries and pp-constructs a valued structure , then for every dual of , the valued structure pp-constructs , because and are fractionally homomorphically equivalent (Remark 19).
The motivation for introducing pp-constructions stems from the following lemma: pp-constructions give rise to polynomial-time reductions.
Lemma 22 ([6, Corollary 5.10 and 5.11]).
Let and be valued structures with finite signatures and oligomorphic automorphism groups such that has a pp-construction in . Then there is a polynomial-time reduction from to . In particular, if , then is NP-hard.
2.8 Fractional polymorphisms
We now introduce fractional polymorphisms of valued structures, which generalize polymorphisms of relational structures. For valued structures with a finite domain, our definition specialises to the established notion of a fractional polymorphism which has been used to study the complexity of VCSPs for valued structures over finite domains (see, e.g. [22]); it is known that fractional polymorphisms of a finite-domain valued structure capture the complexity of its VCSP up to polynomial-time reductions [10, 14]. Our definition is taken from [6] and allows arbitrary probability distributions in contrast to [23, 21, 24].
Let . A fractional operation on of arity is a fractional map from to . The set of all fractional operations on a set of arity is denoted by .
Definition 24.
A fractional operation improves a valued relation if for all
| (1) |
Note that (1) has the interpretation that the expected value of is at most the average of the values , .
Definition 25 (fractional polymorphism).
If a fractional operation improves every valued relation in a valued structure , then is called a fractional polymorphism of ; the set of all fractional polymorphisms of is denoted by .
Remark 26.
A fractional polymorphism of arity of a valued -structure might also be viewed as a fractional homomorphism from a specific -th pp-power of , which we denote by , to : the domain of is , and for every of arity we have
Example 27.
Let be a set and be the -th projection of arity , which is given by . The fractional operation of arity such that for every is a fractional polymorphism of every valued structure with domain .
Lemma 28 (Lemma 6.8 in [6]).
Let be a valued -structure over a countable domain . Then every valued relation is improved by all fractional polymorphisms of .
Let be a relational structure and a permutation group on the domain of . Let and . The operation is pseudo cyclic with respect to if there exist such that for all ,
The operation is canonical with respect to if for all and , the orbit of the -tuple with respect to only depends on the orbits of with respect to . A fractional operation on of arity is called pseudo cyclic with respect to if for the set of all pseudo cyclic operations with respect to of arity . Canonicity for fractional operations is defined analogously. The following theorem is a special case of [6, Theorem 7.13].
Theorem 29.
Let be a union of connected conjunctive queries and let be a finitely bounded and homogenous expansion of (it exists by Theorem 14). If has a canonical pseudo cyclic fractional polymorphism with respect to , then and the resilience problem for is in P.
We formulate an adaptation of [6, Conjecture 8.17] for the valued structure , which replaces the structure used in [6] (and without considering so-called exogenous relations, which we do not introduce in this paper).
Conjecture 30.
Let be a union of connected conjunctive queries over the signature and let be a finitely bounded homogeneous expansion of . Then exactly one of the following holds:
-
has a pp-construction in , and is NP-complete.
-
has a fractional polymorphism of arity which is canonical and pseudo cyclic with respect to , and is in P.
The main reason to use instead of in this conjecture is Corollary 33, which shows that for the converse of the implication in Conjecture 30 is true: if has a canonical and pseudo cyclic fractional polymorphism, then it does not pp-construct ; see also the discussion in Section 3. The relationship between the two conjectures will be a subject of further investigation; at the moment we cannot prove that if has a canonical and pseudo cyclic fractional polymorphism, then so does , or vice versa.
3 Disjointness of the two cases of Conjecture 30
In this section we prove that the two cases in the complexity dichotomy of Conjecture 30 are disjoint. For a valued structure , we denote by the relational structure on the same domain whose relations are all relations from that attain only values and . Observe that by Lemma 28, .
Observation 31.
Let be a union of conjunctive queries. Then is a model-complete core.
Proof.
Note that for every , the structure contains . In particular, by Lemma 28.
Therefore, is a model-complete core.
Let be a permutation group on a set . An operation on a set is called pseudo Taylor with respect to if for every there exist and variables such that and for all , A fractional operation on of arity is called pseudo Taylor with respect to if for the set of all pseudo Taylor operations with respect to on of arity . Note that every pseudo cyclic operation with respect to is pseudo Taylor with respect to ; similarly, pseudo Taylor fractional operations generalize pseudo cyclic fractional operations. The following result is not specific to resilience problems, but holds for VCSPs of valued structures with an oligomorphic automorphism group in general.
Theorem 32.
Let be a valued structure with an oligomorphic automorphism group such that is a model-complete core and such that has a pseudo cyclic (or, more generally, a pseudo Taylor) fractional polymorphism with respect to . Then does not pp-construct .
Proof.
Suppose for contradiction that pp-constructs . By Proposition 2.22 in [25], pp-constructs as well. By results in [2] (see, e.g., Theorem 10.3.5 in [4]), cannot have a pseudo Taylor polymorphism with respect to , and in particular, it cannot have a pseudo cyclic polymorphism with respect to .
By the definition of a pseudo cyclic fractional operation, there is a set of pseudo cyclic operations of arity on such that . By Lemma 28, is also a fractional polymorphism of . By Proposition 3.22 in [25], . In particular, is non-empty. This is in contradiction to not containing any pseudo cyclic operations. The proof in the case that is just a pseudo Taylor operation is analogous.
Corollary 33.
Let be a union of conjunctive queries such that has a pseudo cyclic, or, more generally, a pseudo Taylor fractional polymorphism with respect to . Then does not pp-construct .
Proof.
By Observation 31, the structure is a model-complete core. Now the statement follows from Theorem 32.
Observe that to prove Conjecture 30 it suffices to show that whenever does not pp-construct , it has a canonical pseudo cyclic fractional polymorphism: this follows from Corollary 33 (the two cases are known to be disjoint), Theorem 29 (the tractability result for canonical pseudo cyclic fractional polymorphisms) and Lemma 22 (the hardness condition based on pp-constructions).
4 Complexity Dichotomy for Digraph Resilience Problems
From now on, denotes a binary relational symbol. We will often view -structures as directed graphs. Let
The main result of the present article is the following theorem, which is a stronger version of Theorem 1 presented in Section 1.
Theorem 34.
Let be a union of conjunctive queries over the signature . Then the resilience problem of is in P or NP-complete. If all conjunctive queries in are minimal, connected, and pairwise non-equivalent, then exactly one of the following holds:
-
1.
is equal to , , or , and the resilience of is in P. In this case, has a fractional polymorphism, which is canonical and pseudo cyclic with respect to .
-
2.
pp-constructs and the resilience problem of is NP-complete.
We first sketch the proof strategy for Theorem 34. First observe that one may assume without loss of generality that all queries in are minimal, connected, and pairwise non-equivalent. If is equal to , , , then the properties from item 1 are proven in Lemma 35. Otherwise, we prove that either contains a query that contains a cycle of length , or it has a finite dual without directed cycles. In both of these cases we show that item 2 holds.
It is easy to see that the resilience problem for , or is in P. In Lemma 35 we give a stronger algebraic statement which corresponds to item 1 in Theorem 34; this was essentially known before, and we prove it in the long version of this article [7] for the convenience of the reader.
Lemma 35.
For every , the valued structure has a canonical pseudo cyclic fractional polymorphism with respect to . In particular, the resilience problem for is in P.
5 Self-join-free queries and self-join variations
Self-join-freeness is a fundamental and frequently used concept in database theory.
Definition 36 (self-join-free queries).
A union of conjunctive queries is called self-join-free if every relation symbol appears at most once in .
Note that this is a more restrictive notion than a union of self-join-free conjunctive queries.
Lemma 37.
Let be a self-join-free union of conjunctive queries over the signature containing a conjunctive query with signature . Let be the -reduct of . Then is a dual of , and the -reduct of is equal to .
Proof.
Clearly, . Let be a finite relational -structure such that . Let be a -expansion of where for every is empty. Then and hence has a homomorphism to . The same map is a homomorphism from to . It follows that is a dual of . The last statement is clear from the definitions.
We introduce a construction for obtaining queries with self joins from self-join-free queries, which will be crucial in our hardness proofs.
Definition 38.
Let be a self-join-free union of conjunctive queries over the signature and let be a map that preserves the arities. Then the union of queries resulting from by replacing each atom by is denoted by . We say that is -injective if for all of the same arity such that contains a query with atoms and for some variables , .
A union of queries of the form for some self-join-free and arity-preserving is often called a self-join variation of in the literature [13].
Lemma 39.
Every union of minimal conjunctive queries over a signature can be written as for some self-join-free union of conjunctive queries with signature containing and some -injective .
Proof.
For every , let be the number of occurrences of in and let . Let , where all symbols , , are fresh and of the same arity as . Define to be the union of conjunctive queries obtained from by replacing the occurrences of in by (each of the symbols is used once) for every ; observe that is self-join-free. Let be defined by , . Then . Moreover, is -injective, because queries in are minimal and therefore contain each atom at most once.
We proceed to present the main result of this section – Theorem 40. The theorem and its proof is inspired by [13, Lemma 21]; their result is a special case of Theorem 40, because it only applies to conjunctive queries rather than unions of conjunctive queries, and because it only states a polynomial-time reduction, whereas our result even provides a pp-construction (which implies a polynomial-time reduction via Lemma 22).
Theorem 40.
Let be a self-join-free union of connected conjunctive queries over the signature and let be a -injective map that preserves arities. If all queries in are minimal and pairwise non-equivalent, then pp-constructs . In particular, the resilience problem for reduces in polynomial time to the resilience problem for .
Proof.
Let be the finite set of variables of , which is also the set of variables of and let be the set of conjunctive queries that form the union . Note that since all queries in are connected, the same is true for . Also, since all queries in are pairwise non-equivalent and minimal, they are pairwise homomorphically incomparable (see Section 2.3).
Let be the domain of . Let , i.e., is a finite power of ; it will be more convenient to use as an indexing set rather than the set . We define a pp-power of on the domain with the signature . For every of arity and , if is an atom in a query in , then
The idea is that the combination of query, relation symbol, and variables uniquely identifies an atom in and therefore encodes the difference between relation symbols and from such that .
Note that since relations in are --valued, the same is true for the relations in and hence for a relational -structure on the domain where for every and , if is an atom in a query in , then
(see Figure 1 for an illustration of the relationship between and ).
Claim.
is a dual of .
To see this, we first argue that . If witnesses that where is a query in , then it is straightforward to verify that the map defined by witnesses that and hence , a contradiction with being a dual for . Therefore, .
It remains to show that if is a relational -structure on a finite domain such that , then maps homomorphically into . To this end, we construct an -structure on the domain . For every , if is an atom in a query in and , we put the tuple in . No other tuples are in the relations of .
We argue that . Suppose for contradiction that there exists a a conjunctive query in over a variable set and a map witnessing that . Then for every atom in we have . We define maps and by setting and where and are such that for some . Recall that is connected. Therefore, by the construction, is constant; let be the only element of the image of .
Let be an atom in . Since the tuple has been put in , contains an atom where is such that . Therefore, there is an atom in . Hence, defines a homomorphism from to . Since the queries in are pairwise homomorphically incomparable, we must have . Moreover, since is an atom in , we must have the atoms , , …, in , for all .
Since is a homomorphism from to and is minimal, the image of is equal to . Therefore, is surjective. Since is a finite set, this implies that is a permutation of with an inverse for some . By the previous paragraph is an atom in .
Let be any map satisfying for every that for the such that . Then for every atom in , we have that is an atom of , and therefore is an atom of as well. Since witnesses that holds in ,
By the -injectivity of , there is no atom in with , so we must have by the definition of . Thus, witnesses that and hence, , a contradiction. It follows that .
Since is a dual of , there is a homomorphism . Let be defined by . We claim that a homomorphism from to . To see this, let be of arity and . Let be a query in with an atom . Then and since is a homomorphism, . Then, by the definition of ,
It follows that is a dual of .
6 Hardness proofs
The goal of this section is to present several hardness results that will be used in the proof of Theorem 34. First we have to define several graph-theoretical notions that will be useful in this section. Let be a directed multigraph and . A directed walk in of length is a sequence of elements of such that for every . The walk is closed if . A directed path in of length is a directed walk such that for all distinct . A directed cycle in of length is a closed directed walk such that for all distinct . An oriented cycle in of length is a sequence of elements of such that , for every , or , and for every , , .
Suppose now that is undirected. A cycle in is any sequence that forms an oriented cycle in when viewed as a directed multigraph. We say that is a tree if it does not contain any cycles and if it is connected in the sense that the graph obtained from by replacing multiple edges by single edges is connected (see Section 2.3).
6.1 Hardness for queries with orientations of cycles
A signature is called binary if all relation symbols in are binary. In this section, we work with binary signatures in general rather than just the signature . For any conjunctive query over a binary signature , let denote the undirected multigraph whose edge relation is the union (as a multiset) of all the relations of the canonical database .
In this section we prove hardness for the resilience problem for minimal connected conjunctive queries over a binary signature such that contains a cycle of length at least , and, more generally, for unions that contain such a query. To this end, we start with a result about self-join-free conjunctive queries, which together with Theorem 40 will yield a hardness proof for any query over a binary signature.
Theorem 41.
Let be a connected self-join-free conjunctive query over a binary signature . If contains a cycle of length , then pp-constructs .
The proof of Theorem 41 is inspired by a much simpler pp-construction presented in [6, Example 8.18] for the query , which is the simplest query in the scope of Theorem 41. We recommend having a look at this example as a warm-up for this proof; the proof of Theorem 41 can be found in the long version of the article [7]. The main difference from the general proof is that is a query with a complete Gaifman graph and therefore has a homogeneous dual222We remark that the dual used in [6, Example 8.18] is a different dual from . The dual used there embeds every finite relational -structure that does not satisfy , whereas our dual is a model-complete core; so, for example, the empty structure on two vertices maps homomorphically into , but does not have an embedding. , which significantly simplifies the second part of the construction. The following corollary generalizes Theorem 41.
Corollary 42.
Let be a union of minimal connected pairwise non-equivalent conjunctive queries over a binary signature containing a conjunctive query . If contains a cycle of length , then pp-constructs and the resilience problem for is NP-complete.
Proof.
Let be a self-join-free union of connected conjunctive queries over a binary signature such that for some -injective ; it exists by Lemma 39. Let be a conjunctive query from such that and let be the signature of .
By Theorem 40, pp-constructs . By Lemma 37, the -reduct of is equal to for some dual of . Since and are both duals of , the valued structure is fractionally homomorphically equivalent to (Remark 19). Therefore, pp-constructs . By Theorem 41, pp-constructs . By the transitivity of pp-constructability, pp-constructs . By Lemma 22, is NP-hard. By Proposition 11, the resilience problem for is NP-hard, and thus NP-complete.
6.2 Hardness for queries with finite acyclic duals
In this section we prove that the resilience problem for queries that have a non-trivial finite dual without directed cycles is NP-hard. We stress that this lemma crucially relies on our approach to analyse the complexity of the resilience problem for using the dual structure and .
Lemma 43.
Let be a union of conjunctive queries over the signature such that the domain of is finite. Assume that contains at least one edge and does not contain any directed cycles. Then pp-constructs .
Proof.
Let be the domain of . Let be the length of the longest directed path in ; it exists, because is finite and does not contain any directed cycles. Let be the pp-expression
Let . Then if and only if there is a directed path in of length starting with the edge . If , then if and only if there is a directed path in of length starting in . Finally, if , then . Let be the valued -structure on the domain where for all . Note that .
Recall the valued structure from Example 2. Let be such that there is a directed path in of length starting with the edge . Let be defined by and . It is straightforward to verify that defined by is a fractional homomorphism from to . Let be defined by for every such that there is a directed path of length starting in and otherwise. We argue that defined by is a fractional homomorphism from to . Let . Note that if , then trivially . Suppose therefore that . Then by the definition of , there is a directed path in of length starting with the edge . By the definition of , we have . Since there is no directed path of length in and does not contain directed cycles, there is no directed path of length starting in and therefore . Hence, . It follows that is a fractional homomorphism from to .
By the previous paragraph, is fractionally homomorphically equivalent to . Since , we have that pp-constructs . We have already mentioned in Example 23 that pp-constructs . By the transitivity of pp-constructability, pp-constructs .
7 Proof of Theorem 34
We are now ready to prove the main result of the paper.
Proof of Theorem 34.
Since , items (1) and (2) are mutually exclusive by Corollary 33. Hence it is enough to prove that item (1) or item (2) holds. Without loss of generality, we may assume that all queries in are pairwise non-equivalent, minimal and connected (see Lemma 9). In particular, the queries in are pairwise homomorphically incomparable (see Section 2.3). By this assumption, if contains or , then is equal to or to , respectively, in which case item (1) holds by Lemma 35. We may therefore assume that contains neither nor .
If contains a conjunctive query such that contains a cycle of length , then item (2) holds by Corollary 42. Suppose that this is not the case. Then for every query in , is a tree, or contains the atoms and for some variables , in which case by the minimality of . Note that every such that is a tree has a homomorphism to , so whenever contains . In this case, item (1) holds by Lemma 35. Suppose therefore that and hence, is a tree for every query in . Then has a finite dual by [20] (see also [6, Theorem 8.7]). Since is the model-complete core of this dual, it also has a finite domain, so it is a finite directed graph with an edge relation . Note that contains at least one edge, because . It is easy to see that every orientation of a tree (in particular, every in ) maps homomorphically to every directed cycle; thus, does not contain directed cycles. By Lemma 43, pp-constructs . By Lemma 22 and Proposition 11, the resilience problem for is NP-complete. Therefore, item (2) holds.
References
- [1] Antoine Amarilli, Wolfgang Gatterbauer, Neha Makhija, and Mikaël Monet. Resilience for regular path queries: Towards a complexity classification. Proc. ACM Manag. Data, 3(2), June 2025. doi:10.1145/3725245.
- [2] Libor Barto, Michael Kompatscher, Miroslav Olšák, Trung Van Pham, and Michael Pinsker. Equations in oligomorphic clones and the constraint satisfaction problem for -categorical structures. Journal of Mathematical Logic, 19(2):#1950010, 2019. doi:10.1142/S0219061319500107.
- [3] Manuel Bodirsky. Cores of countably categorical structures. Logical Methods in Computer Science (LMCS), 3(1):1–16, 2007. doi:10.2168/LMCS-3(1:2)2007.
- [4] Manuel Bodirsky. Complexity of Infinite-Domain Constraint Satisfaction. Lecture Notes in Logic (52). Cambridge University Press, 2021. doi:10.1017/9781107337534.
- [5] Manuel Bodirsky. Automorphism groups, 2023. Course Notes, TU Dresden, https://wwwpub.zih.tu-dresden.de/˜bodirsky/Automorphism-Groups.pdf.
- [6] Manuel Bodirsky, Žaneta Semanišinová, and Carsten Lutz. The complexity of resilience problems via valued constraint satisfaction problems. In Proceedings of the 39th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS ’24, New York, NY, USA, 2024. Association for Computing Machinery. doi:10.1145/3661814.3662071.
- [7] Manuel Bodirsky and Žaneta Semanišinová. The complexity of resilience for digraph queries, 2026. arXiv:2601.05346.
- [8] Peter J. Cameron. Oligomorphic permutation groups. Cambridge University Press, Cambridge, 1990.
- [9] 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.
- [10] David A. Cohen, Martin C. Cooper, Páidí Creed, Peter G. Jeavons, and Stanislav Živný. An algebraic theory of complexity for discrete optimization. SIAM J. Comput., 42(5):1915–1939, 2013. doi:10.1137/130906398.
- [11] Fedor V. Fomin, Petr A. Golovach, and Dimitrios M. Thilikos. On the parameterized complexity of graph modification to first-order logic properties. Theory of Computing Systems, 64(2):251–271, 2020. doi:10.1007/s00224-019-09938-8.
- [12] Cibele Freire, Wolfgang Gatterbauer, Neil Immerman, and Alexandra Meliou. The complexity of resilience and responsibility for self-join-free conjunctive queries. Proc. VLDB Endow., 9(3):180–191, 2015. doi:10.14778/2850583.2850592.
- [13] Cibele Freire, Wolfgang Gatterbauer, Neil Immerman, and Alexandra Meliou. New results for the complexity of resilience for binary conjunctive queries with self-joins. In Proceedings of the 39th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS 2020, Portland, OR, USA, June 14-19, 2020, pages 271–284, 2020. doi:10.1145/3375395.3387647.
- [14] Peter Fulla and Stanislav Živný. A Galois connection for weighted (relational) clones of infinite size. TOCT, 8(3):9:1–9:21, 2016. doi:10.1145/2898438.
- [15] Michael Garey and David Johnson. A guide to NP-completeness. CSLI Press, Stanford, 1978.
- [16] Wilfrid Hodges. A shorter model theory. Cambridge University Press, Cambridge, 1997.
- [17] Neha Makhija and Wolfgang Gatterbauer. A unified approach for resilience and causal responsibility with integer linear programming (ilp) and lp relaxations. Proc. ACM Manag. Data, 1(4), December 2023. doi:10.1145/3626715.
- [18] Alexandra Meliou, Wolfgang Gatterbauer, and Dan Suciu. Reverse data management. Proc. VLDB Endow., 4(12):1490–1493, August 2011. doi:10.14778/3402755.3402803.
- [19] Antoine Mottet and Michael Pinsker. Cores over Ramsey structures. Journal of Symbolic Logic, 86(1):352–361, 2021. doi:10.1017/jsl.2021.6.
- [20] J. Nešetřil and C. Tardif. Duality theorems for finite structures. Journal of Combinatorial Theory, Series B, 80:80–97, 2000. doi:10.1006/jctb.2000.1970.
- [21] Friedrich Martin Schneider and Caterina Viola. An application of Farkas’ lemma to finite-valued constraint satisfaction problems over infinite domains. Journal of Mathematical Analysis and Applications, 517(1):126591, 2023. doi:10.1016/j.jmaa.2022.126591.
- [22] Johan Thapper and Stanislav Živný. The complexity of finite-valued CSPs. In Proceedings of the Symposium on Theory of Computing Conference (STOC), Palo Alto, CA, USA, June 1-4, 2013, pages 695–704, 2013. doi:10.1145/2488608.2488697.
- [23] Caterina Viola. Valued Constraint Satisfaction Problems over Infinite Domains. PhD thesis, TU Dresden, 2020.
- [24] Caterina Viola and Stanislav Zivný. The combined basic LP and affine IP relaxation for promise VCSPs on infinite domains. ACM Trans. Algorithms, 17(3):21:1–21:23, 2021. doi:10.1145/3458041.
- [25] Žaneta Semanišinová. Valued Constraint Satisfaction in Structures with an Oligomorphic Automorphism Group. Dissertation, TU Dresden, Dresden, Germany, 2025. Available at https://nbn-resolving.org/urn:nbn:de:bsz:14-qucosa2-974737.
