Abstract 1 Introduction 2 Preliminaries 3 Disjointness of the two cases of Conjecture 30 4 Complexity Dichotomy for Digraph Resilience Problems 5 Self-join-free queries and self-join variations 6 Hardness proofs 7 Proof of Theorem 34 References

The Complexity of Resilience for Digraph Queries

Manuel Bodirsky ORCID Institut für Algebra, TU Dresden, Germany Žaneta Semanišinová ORCID Institute of Discrete Mathematics and Geometry, TU Wien, Austria
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 {R} of directed graphs). Specifically, for every union μ of conjunctive digraph queries, the following problem is in P or NP-complete: given a directed multigraph G and a natural number u, can we remove u edges from G so that G¬μ? 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-constructions
Funding:
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.
Žaneta Semanišinová: The author has 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. This research was funded in whole or in part by the Austrian Science Fund (FWF) 10.55776/ESP6949724.
Copyright and License:
[Uncaptioned image] © Manuel Bodirsky and Žaneta Semanišinová; licensed under Creative Commons License CC-BY 4.0
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)
Related Version:
Full Version: https://arxiv.org/abs/2601.05346 [7]
Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim Thắng

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 u whether it is possible to remove at most u 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 R, that is, we prove the following:

Theorem 1.

If μ is a union of conjunctive queries over a binary signature {R}, then the resilience problem for μ is in P or NP-complete.

The class of unions of conjunctive queries over {R} 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 {R}, the query expresses a directed graph property and the resilience problem can be phrased as follows: given a directed multigraph G and a natural number u, can we remove u edges from G so that G¬μ? 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.12.4 and skipping Sections 2.52.8, and coming back to them when they are needed in the proofs in the article.

The set {0,1,2,} of natural numbers is denoted by . For k, the set {1,,k} will be denoted by [k]. 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

  • a< for every a,

  • a+=+a= for all a{}, and

  • 0=0=0 and a=a= for a>0.

Let A be a set and k. If tAk, then we implicitly assume that t=(t1,,tk), where t1,,tkA. If and f:AA is an operation on A and t1,,tAk, then we denote (f(t11,t12,,t1),,f(tk1,tk2,,tk)) by f(t1,,t) and say that f is applied componentwise.

2.1 Valued structures

Let C be a set and let k. A valued relation of arity k over C is a function R:Ck{}. We write C(k) for the set of all valued relations over C of arity k, and define

C:=kC(k).

A valued relation is called finite-valued if it takes values only in . Usual relations will also be called crisp relations. A valued relation RC(k) that only takes values from {0,} will be identified with the crisp relation {tCkR(t)=0}. The unary empty relation, where every element evaluates to , is denoted by . The crisp equality relation, where a pair of elements evaluates to 0 if they are equal and evaluates to otherwise, is denoted by (=)0. For RC(k) the feasibility relation of R is defined as Feas(R):={tCkR(t)<}.

A (relational) signature τ is a set of relation symbols, each of them equipped with an arity from . A valued τ-structure Γ consists of a set C, which is also called the domain of Γ, and a valued relation RΓC(k) for each relation symbol Rτ of arity k. All valued structures in this article have countable domains. We often write R instead of RΓ if the valued structure is clear from the context. A valued τ-structure where all valued relations only take values from {0,} 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 A,B,, respectively, and the domains of valued structures Γ,Δ, are denoted C,D,, respectively.

Example 2.

Let R be a binary relation symbol. Then ΓMC with the domain {0,1} and the signature {R} where RΓMC(x,y)=0 if x=0 and y=1, and RΓMC(x,y)=1 otherwise, is a valued structure.

If στ and Γ is a valued σ-structure such that RΓ=RΓ for every Rσ, 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 R(x1,,xk) for some Rτ of arity k, x=y, or . We introduce a generalization of conjunctions of atomic formulas to the valued setting. An atomic τ-expression is an expression of the form R(x1,,xk) for Rτ{(=)0,} and (not necessarily distinct) variable symbols x1,,xk. A τ-expression is an expression ϕ of the form i=1mϕi where m and ϕi for i{1,,m} is an atomic τ-expression. Note that the same atomic τ-expression might appear several times in the sum. We write ϕ(x1,,xn) for a τ-expression where all the variables are from the set {x1,,xn}. If Γ is a valued τ-structure, then a τ-expression ϕ(x1,,xn) defines over Γ a member of C(n) in a natural way, which we denote by ϕΓ. If ϕ is the empty sum then ϕΓ is constant 0.

Definition 3.

Let k, let RC(k), and let α be a permutation of C. Then α preserves R if for all tCk we have R(α(t))=R(t). If Γ is a valued structure with domain C, then an automorphism of Γ is a permutation of C that preserves all valued relations of Γ.

The set of all automorphisms of Γ is denoted by Aut(Γ), and forms a group with respect to composition.

Let A be a set and RAk. An operation f:AA on the set A preserves R if f(t1,,t)R for every t1,,tR. If 𝔄 is a relational structure and f preserves all relations of 𝔄, then f is called a polymorphism of 𝔄. The set of all polymorphisms of 𝔄 is denoted by Pol(𝔄) and is closed under composition. We write Pol()(𝔄) for the set of -ary operations in Pol(𝔄), . Unary polymorphisms are called endomorphisms and Pol(1)(𝔄) is also denoted by End(𝔄).

Let τ be a relational signature and let 𝔄 and 𝔅 be relational τ-structures. A map h:AB is called a homomorphism from 𝔄 to 𝔅 if for every Rτ of arity k and every tR𝔄, h(t)R𝔅. 𝔄 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 VCSP(Γ), is the computational problem to decide for a given τ-expression ϕ(x1,,xn) and a given u whether there exists tCn such that ϕΓ(t)u. We refer to ϕ(x1,,xn) as an instance of VCSP(Γ), and to u as the threshold. Tuples tCn such that ϕΓ(t)u are called a solution for (ϕ,u). The cost of ϕ (with respect to Γ) is defined to be

inftCnϕΓ(t).

In some contexts, it is beneficial to consider only a given τ-expression ϕ to be the input of VCSP(Γ) (rather than ϕ and the threshold u) and a tuple tCn is then called a solution for ϕ if the cost of ϕ equals ϕΓ(t). 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 tCn such that ϕΓ(t)< then ϕ is called satisfiable.

For relational structures, VCSPs specialize to CSPs, as explained below.

 Remark 5.

If 𝔄 is a relational τ-structure, then CSP(𝔄) is the problem of deciding satisfiability of conjunctions of atomic formulas over τ in 𝔄. Note that for every τ-expression ϕ(x1,,xn), ϕ𝔄 defines a crisp relation and can be viewed as a conjunction of atomic formulas, which defines the same relation. Minimizing ϕ𝔄 then corresponds to finding tAn such that ϕ𝔄(t)=0, i.e. t that satisfies all atomic formulas in the conjunction. Therefore, VCSP(𝔄) and CSP(𝔄) are essentially the same problem.

Example 6.

The problem VCSP(ΓMC) for the valued structure ΓMC from Example 2 models the directed max-cut problem: given a finite directed multigraph (V,E), find a partition of the vertices V into two classes A and B such that the number of edges from A to B is maximal. Maximising the number of edges from A to B amounts to minimising the number e of edges within A, within B, and from B to A. So when we associate A to the preimage of 0 and B to the preimage of 1, computing the answer corresponds to finding the evaluation map f:V{0,1} that minimises the value

(x,y)ERΓMC(f(x),f(y)),

which can be formulated as an instance of VCSP(ΓMC). Conversely, every instance of VCSP(ΓMC) corresponds to a directed max-cut instance.

Example 7.

Consider the relation OIT={(0,0,1),(0,1,0),(1,0,0)}. CSP({0,1};OIT) 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 μ(v1,,vn), we say that α:{v1,,vn}A witnesses that 𝔄μ if 𝔄μ(α(v1),,α(vn)). Given conjunctive queries μ1 and μ2 over τ, we say that μ1 is equivalent to μ2 if 𝔄μ1 if and only if 𝔄μ2 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 A of arity k is a multiset with elements from Ak and a bag database 𝔄 over a relational signature τ consists of a finite domain A and for every Rτ of arity k, a multiset relation R𝔄 of arity k. 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 u and the question is whether the resilience is at most u. Clearly, 𝔄 does not satisfy μ if and only if its resilience is 0. 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 (x1,,xk)R𝔄 for Rτ of arity k if and only if μ contains the conjunct R(x1,,xk); 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 ν1,,νk be conjunctive queries such that νi does not imply νj if ij. Let ν=(ν1νk) and suppose that ν occurs in a union μ of conjunctive queries. For i{1,,k}, let μi be the union of queries obtained by replacing ν by νi in μ. Then the resilience problem for μ is NP-hard if the resilience problem for one of the μi is NP-hard. Conversely, if the resilience problem is in P for each μi, 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 𝔅01 to be the valued τ-structure on the same domain as 𝔅 such that for each Rτ, R𝔅01(a)=0 if aR𝔅 and R𝔅01(a)=1 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 VCSP(𝔅01) for any dual 𝔅 of μ.

Let k, let C be a set and G a permutation group on C. An orbit of k-tuples of G is a set of the form {α(t)αG} for some tCk. A permutation group G on a countable set is called oligomorphic if for every k there are finitely many orbits of k-tuples in G [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 A to B 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 Aut(𝔅) 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. 1.

    𝔅μ is a reduct of a finitely bounded and homogeneous structure 𝔅.

  2. 2.

    A countable τ-structure 𝔄 satisfies ¬μ if and only if it embeds into 𝔅μ.

  3. 3.

    𝔅μ is finitely bounded.

  4. 4.

    Aut(𝔅) and Aut(𝔅μ) 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 G is a permutation group on a set C, then G¯ denotes the closure of G in the space CC with respect to the topology of pointwise convergence. This is the unique topology such that the closed subsets of CC are precisely the endomorphism monoids of relational structures; see, e.g., [4, Proposition 4.4.2]. Note that G¯ might contain some operations that are not surjective, but if G=Aut(𝔅) for some relational structure 𝔅, then all operations in G¯ 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 Aut(𝔅)¯=End(𝔅).

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 A where a,bA are adjacent if and only if ab and there exists a tuple in a relation of 𝔄 that contains both a and b. 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. 1.

    μ is a reduct of a finitely bounded and homogeneous structure 𝔅.

  2. 2.

    A countable τ-structure 𝔄 satisfies ¬μ if and only if there is a homomorphism from 𝔄 to μ.

  3. 3.

    If for each query ν in μ, the Gaifman graph of ν is complete, then μ is homogeneous.

  4. 4.

    Aut(𝔅) and Aut(μ) are oligomorphic.

Proof.

Item (1) follows from results in [19]; see [5, Corollary 7.5.15] for an explicit reference.

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 Δμ:=(μ)01. In most results, this will be the valued structure to which we apply results about 𝔅01 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 A be a set and R,RA. We say that R can be obtained from R by

  • projecting if R is of arity k, R is of arity k+n and for all sAk

    R(s)=inftAnR(s,t).
  • non-negative scaling if there exists a0 such that R=aR;

  • shifting if there exists a such that R=R+a.

If R is of arity k, then the relation that contains all minimal-value tuples of R is

Opt(R):={tFeas(R)R(t)R(s) for every sAk}.

Note that inftAnR(s,t) in item (1) might be irrational or . If this is the case, then inftAnR(s,t) does not express a valued relation because valued relations must have weights from {}. However, if R is preserved by all permutations of an oligomorphic automorphism group, then R attains only finitely many values and therefore this is never the case.

If 𝒮A, 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 C) is a subset of C that is closed under forming sums of atomic expressions, projecting, shifting, non-negative scaling, Feas, and Opt; we refer to expressions formed this way as pp-expressions. For a valued structure Γ with the domain C, we write Γ for the smallest relational clone that contains the valued relations of Γ. If RΓ, we say that Γ pp-expresses R.

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 A and B be sets. We equip the space AB of functions from B to A with the topology of pointwise convergence, where A is taken to be discrete. In this topology, a basis of open sets is given by 𝒮s,t:={fABf(s)=t} for sBk and tAk for some k. For any topological space T, we denote by (T) the Borel σ-algebra on T, i.e., the smallest subset of the powerset 𝒫(T) which contains all open sets and is closed under countable intersection and complement. We write [0,1] for the set {x0x1}.

Definition 17 (fractional map).

Let A and B be sets. A fractional map from B to A is a probability distribution (AB,(AB),ω:(AB)[0,1]), that is, ω(AB)=1 and ω is countably additive: if S1,S2,(AB) are disjoint, then

ω(iSi)=iω(Si).

We often use ω for both the entire fractional map and for the map ω:(AB)[0,1].

The set [0,1] 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 (a,b) for a,b, a<b and additionally all sets of the form {xx>a}{} (thus, {} is equipped with its order topology when ordered in the natural way).

A (real-valued) random variable is a measurable function X:T{}, i.e., pre-images of elements of ({}) under X are in (T). If X is a real-valued random variable, then the expected value of X (with respect to a probability distribution ω) is denoted by Eω[X] and is defined via the Lebesgue integral

Eω[X]:=TX𝑑ω.

In the rest of the paper, we will work exclusively with topological spaces T of the form AB for some sets A and B.

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 C and D, respectively. A fractional homomorphism from Δ to Γ is a fractional map ω from D to C such that for every Rτ of arity k and every tuple tDk it holds for the random variable X:CD{} given by fRΓ(f(t)) that Eω[X] exists and that Eω[X]RΔ(t).

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, 𝔅01 and 01 are fractionally homomorphically equivalent witnessed by fractional maps where the respective homomorphisms have probability 1.

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 C and let d. Then a (d-th) pp-power of Γ is a valued structure Δ with the domain Cd such that for every valued relation R of Δ of arity k there exists a valued relation S of arity kd in Γ such that

R((x11,,xd1),,(x1k,,xdk))=S(x11,,xd1,,x1k,,xdk).

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 Γ1, Γ2, and Γ3 are valued structures such that Γ1 pp-constructs Γ2 and Γ2 pp-constructs Γ3, then Γ1 pp-constructs Γ3 [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 𝔅01 pp-constructs Γ, because Δμ and 𝔅01 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 VCSP(Δ) to VCSP(Γ). In particular, if Δ=({0,1};OIT), then VCSP(Γ) is NP-hard.

Example 23.

Recall the valued structure ΓMC from Example 2. It is known that ΓMC pp-constructs ({0,1},OIT) [25, Example 2.18] and by Lemma 22, VCSP(ΓMC) 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 A of arity is a fractional map from A to A. The set of all fractional operations on a set A of arity is denoted by A().

Definition 24.

A fractional operation ωA() improves a valued relation RA(k) if for all t1,,tAk

E:=Eω[fR(f(t1,,t))] exists, and E1j=1R(tj). (1)

Note that (1) has the interpretation that the expected value of R(f(t1,,t)) is at most the average of the values R(t1),, R(t).

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 fPol(Γ).

 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 C, and for every Rτ of arity k we have

RΓ((x11,,x1),,(x1k,,xk)):=1i=1RΓ(xi1,,xik).
Example 27.

Let A be a set and πi𝒪A() be the i-th projection of arity , which is given by πi(x1,,x)=xi. The fractional operation Id of arity such that Id(πi)=1 for every i{1,,} is a fractional polymorphism of every valued structure with domain A.

Lemma 28 (Lemma 6.8 in [6]).

Let Γ be a valued τ-structure Γ over a countable domain C. Then every valued relation RΓ is improved by all fractional polymorphisms of Γ.

Let 𝔄 be a relational structure and G a permutation group on the domain A of 𝔄. Let 2 and f:AA. The operation f is pseudo cyclic with respect to G if there exist e1,,eG¯ such that for all x1,,xA,

e1f(x1,x2,,x)=e2f(x2,,x,x1)==ef(x,x1,,x1).

The operation f is canonical with respect to G if for all k and t1,,tAk, the orbit of the k-tuple f(t1,,t) with respect to G only depends on the orbits of t1,,t with respect to G. A fractional operation ω on C of arity is called pseudo cyclic with respect to G if ω(S)=1 for the set S of all pseudo cyclic operations with respect to G 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 Aut(𝔄), then VCSP(Δμ) 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:

  • ({0,1};OIT) has a pp-construction in Δμ, and VCSP(Δμ) is NP-complete.

  • Δμ has a fractional polymorphism of arity 2 which is canonical and pseudo cyclic with respect to Aut(𝔄), and VCSP(Δμ) is in P.

The main reason to use Δμ instead of Γμ:=(𝔅μ)01 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 ({0,1};OIT); 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 0 and . Observe that by Lemma 28, Aut(Γ)Aut(Γ).

Observation 31.

Let μ be a union of conjunctive queries. Then Δμ is a model-complete core.

Proof.

Note that for every Rτ, the structure Δμ contains Rμ=Opt(RΔμ). In particular, End(Δμ)End(μ) by Lemma 28.

End(Δμ)End(μ) =Aut(μ)¯ (μ is a model-compl. core)
=Aut(Δμ)¯Aut(Δμ)¯End(Δμ).

Therefore, Δμ is a model-complete core.

Let G be a permutation group on a set C. An operation f:CC on a set C is called pseudo Taylor with respect to G if for every i{1,,} there exist e1,e2G¯ and variables z1,,z,z1,,z{x,y} such that zizi and for all x,yC, e1(f(z1,,zn))=e2(f(z1,,zn)). A fractional operation ω on C of arity is called pseudo Taylor with respect to G if ω(T)=1 for the set T of all pseudo Taylor operations with respect to G on C of arity . Note that every pseudo cyclic operation with respect to G is pseudo Taylor with respect to G; 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 Aut(Γ). Then Γ does not pp-construct K3.

Proof.

Suppose for contradiction that Γ pp-constructs K3. By Proposition 2.22 in [25], Γ pp-constructs K3 as well. By results in [2] (see, e.g., Theorem 10.3.5 in [4]), Γ cannot have a pseudo Taylor polymorphism with respect to Aut(Γ), and in particular, it cannot have a pseudo cyclic polymorphism with respect to Aut(Γ).

By the definition of a pseudo cyclic fractional operation, there is a set S of pseudo cyclic operations of arity on C such that ω(S)=1. By Lemma 28, ω is also a fractional polymorphism of Γ. By Proposition 3.22 in [25], ω(SPol()(Γ))=1. In particular, SPol()(Γ) is non-empty. This is in contradiction to Pol(Γ) 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 Aut(Δμ). Then Δμ does not pp-construct K3.

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 ({0,1};OIT), 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).

The main reason to work with the dual μ in this paper, instead of the dual 𝔅μ that was used in [6], comes from the proof of Theorem 32 above: we need the property that μ is a model-complete core to get that Δμ is a model-complete core and hence to be able to apply the results from [2].

4 Complexity Dichotomy for Digraph Resilience Problems

From now on, R denotes a binary relational symbol. We will often view {R}-structures as directed graphs. Let

μ :=xR(x,x),
μe :=x,yR(x,y), and
μc :=x,y(R(x,y)R(y,x)).

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 {R}. 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. 1.

    μ is equal to μ, μe, or μc, and the resilience of μ is in P. In this case, Δμ has a fractional polymorphism, which is canonical and pseudo cyclic with respect to Aut(μ).

  2. 2.

    Δμ pp-constructs ({0,1};OIT) 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 μ, μe, μc, then the properties from item 1 are proven in Lemma 35. Otherwise, we prove that either μ contains a query μ0 that contains a cycle of length 3, 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 μ, μe or μc 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 μ{μ,μe,μc}, 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 𝔅01.

Proof.

Clearly, 𝔅¬ν. Let 𝔄 be a finite relational ρ-structure such that 𝔄¬ν. Let 𝔄 be a τ-expansion of 𝔄 where R𝔄 for every Rτρ 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 f:ττ be a map that preserves the arities. Then the union of queries resulting from ν by replacing each atom R(x1,,xk) by f(R)(x1,,xk) is denoted by f(ν). We say that f is ν-injective if for all R,Sτ of the same arity k such that ν contains a query with atoms R(x1,,xk) and S(x1,,xk) for some variables x1,,xk, f(R)f(S).

A union of queries of the form f(ν) for some self-join-free ν and arity-preserving f 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 f(ν) for some self-join-free union of conjunctive queries ν with signature τ containing σ and some ν-injective f:τσ.

Proof.

For every Rσ, let nR be the number of occurrences of R in μ and let R0:=R. Let τ=Rσ{R0,R1,,RnR1}, where all symbols Ri, i1, are fresh and of the same arity as R. Define ν to be the union of conjunctive queries obtained from μ by replacing the occurrences of R in μ by R0,,RnR1 (each of the symbols is used once) for every Rσ; observe that ν is self-join-free. Let f:τστ be defined by f(R0)==f(RnR1)=R, Rσ. Then f(ν)=μ. Moreover, f 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 f:ττ be a ν-injective map that preserves arities. If all queries in f(ν) are minimal and pairwise non-equivalent, then Δf(ν) pp-constructs Δν. In particular, the resilience problem for ν reduces in polynomial time to the resilience problem for f(ν).

Proof.

Let V be the finite set of variables of ν, which is also the set of variables of μ:=f(ν) and let Q 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 Dμ be the domain of Δμ. Let D:=(Dμ)V×Q, i.e., D is a finite power of Dμ; it will be more convenient to use V×Q as an indexing set rather than the set {1,,|V×Q|}. We define a pp-power Δ of Δμ on the domain D with the signature τ. For every Rτ of arity k and (d1,,dk)Dk, if R(x1,,xk) is an atom in a query ν0 in ν, then

RΔ(d1,,dk):=f(R)Δμ(dx1,ν01,,dxk,ν0k).

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 R and R from τ such that f(R)=f(R).

Note that since relations in Δμ are 0-1-valued, the same is true for the relations in Δ and hence Δ=𝔅01 for a relational τ-structure 𝔅 on the domain D where for every Rτ and (d1,,dk)Dk, if R(x1,,xk) is an atom in a query ν0 in ν, then

𝔅R(d1,,dk)μf(R)(dx1,ν01,,dxk,ν0k)

(see Figure 1 for an illustration of the relationship between μ and 𝔅).

Figure 1: An illustration of the relationship between the structures μ and 𝔅 from the proof of Theorem 40 for ν=x,y(R(x,y)S(y,x)) and μ=x,y(R(x,y)R(y,x)). The tuples in R are depicted in red and tuples in S in blue.
Claim.

𝔅 is a dual of ν.

To see this, we first argue that 𝔅⊧̸ν. If α:VD witnesses that 𝔅ν0 where ν0 is a query in ν, then it is straightforward to verify that the map α:VDμ defined by vα(v)v,ν0 witnesses that μf(ν0) and hence μμ, a contradiction with μ being a dual for μ. Therefore, 𝔅⊧̸ν.

It remains to show that if 𝔄 is a relational τ-structure on a finite domain A such that 𝔄⊧̸ν, then 𝔄 maps homomorphically into 𝔅. To this end, we construct an f(τ)-structure 𝔄 on the domain A={av,ν0aA,vV,ν0Q}. For every Rτ, if R(x1,,xk) is an atom in a query ν0 in ν and (a1,,ak)R𝔄, we put the tuple ((a1)x1,ν0,,(ak)xk,ν0) in f(R)𝔄. No other tuples are in the relations of 𝔄.

We argue that 𝔄⊧̸μ. Suppose for contradiction that there exists a a conjunctive query μ0 in μ over a variable set V0V and a map β:V0A witnessing that 𝔄μ0. Then for every atom f(R)(x1,,xk) in μ0 we have (β(x1),,β(xk))f(R)𝔄. We define maps βQ:V0Q and βV:V0V by setting βQ(x):=ν0 and βV(x):=y where ν0Q and yV are such that β(x)=ay,ν0 for some aA. Recall that μ0 is connected. Therefore, by the construction, βQ is constant; let ν0Q be the only element of the image of βQ.

Let f(R)(x1,,xk) be an atom in μ0. Since the tuple (β(x1),,β(xk)) has been put in f(R)𝔄, ν0 contains an atom R(βV(x1),,βV(xk)) where Rτ is such that f(R)=f(R). Therefore, there is an atom f(R)(βV(x1),,βV(xk)) in f(ν0). Hence, βV defines a homomorphism from μ0 to f(ν0). Since the queries in μ are pairwise homomorphically incomparable, we must have f(ν0)=μ0. Moreover, since f(R)(x1,,xk) is an atom in μ0, we must have the atoms f(R)(βV(x1),,βV(xk)), f(R)(βV2(x1),,βV2(xk)), …, f(R)(βVp(x1),,βVp(xk)) in f(ν0)=μ0, for all p.

Since βV is a homomorphism from μ0 to μ0 and μ0 is minimal, the image of βV is equal to V0. Therefore, βV:V0V0 is surjective. Since V0 is a finite set, this implies that βV is a permutation of V0 with an inverse βV1=βVp for some p. By the previous paragraph f(R)(βV1(x1),,βV1(xk)) is an atom in μ0.

Let β:VA be any map satisfying for every xV0 that β(x)=a for the aA such that β(βV1(x))=ax,ν0. Then for every atom R(x1,,xk) in ν0, we have that f(R)(x1,,xk) is an atom of μ0, and therefore f(R)(βV1(x1),,βV1(xk)) is an atom of μ0 as well. Since β witnesses that μ0 holds in 𝔄,

(β(x1)x1,ν0,,β(xk)xk,ν0)=(β(βV1(x1)),,β(βV1(xk)))f(R)𝔄.

By the ν-injectivity of f, there is no atom R(x1,,xk) in ν0 with f(R)=f(R), so we must have (β(x1),,β(xk))R𝔄 by the definition of 𝔄. Thus, β witnesses that 𝔄ν0 and hence, 𝔄ν, a contradiction. It follows that 𝔄⊧̸μ.

Since μ is a dual of μ, there is a homomorphism h:𝔄μ. Let h:𝔄𝔅 be defined by h(a):=(h(av,ν0))vV,ν0Q. We claim that h a homomorphism from 𝔄 to 𝔅. To see this, let Rτ be of arity k and (a1,,ak)R𝔄. Let ν0 be a query in ν with an atom R(x1,,xk). Then ((a1)x1,ν0,,(ak)xk,ν0)f(R)𝔄 and since h is a homomorphism, (h((a1)x1,ν0),,h((ak)xk,ν0))f(R)μ. Then, by the definition of 𝔅,

(h(a1),,h(ak))=((h((a1)v,ν0))vV,ν0Q,,(h((ak)v,ν0))vV,ν0Q)R𝔅.

It follows that 𝔅 is a dual of ν.

Since 𝔅 and ν are duals of ν, they are homomorphically equivalent and hence Δ and Δν are fractionally homomorphically equivalent (see Remark 19). Since Δ is a pp-power of Δμ, it follows that Δμ pp-constructs Δν. The final statement of the theorem follows from Lemma 22 and Proposition 11.

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 𝔊=(V;E) be a directed multigraph and k. A directed walk in 𝔊 of length k is a sequence W=(v0,v1,,vk) of elements of V such that (vi,vi+1)E for every i{0,,k1}. The walk W is closed if v0=vk. A directed path in 𝔊 of length k is a directed walk (v0,,vk) such that vivj for all distinct i,j{0,,k}. A directed cycle in 𝔊 of length k is a closed directed walk (v0,,vk) such that vivj for all distinct i,j{0,,k1}. An oriented cycle in 𝔊 of length k is a sequence (v0,v1,,vk) of elements of V such that vk=v0, for every i{0,,k1}, (vi,vi+1)E or (vi+1,vi)E, and for every j{0,,k1}, ji, vivj.

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 {R}. For any conjunctive query μ over a binary signature τ, let Multigraph(μ) 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 Multigraph(μ) contains a cycle of length at least 3, 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 Multigraph(μ) contains a cycle of length 3, then Δμ pp-constructs ({0,1},OIT).

The proof of Theorem 41 is inspired by a much simpler pp-construction presented in [6, Example 8.18] for the query μ:=x,y,z(R(x,y)S(y,z)T(z,x)), 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 {R,S,T}-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 μ0. If Multigraph(μ0) contains a cycle of length 3, then Δμ pp-constructs ({0,1};OIT) 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 μ=f(μ) for some μ-injective f:ττ; it exists by Lemma 39. Let μ0 be a conjunctive query from μ such that μ0=f(μ0) and let τ0τ be the signature of μ0.

By Theorem 40, Δμ pp-constructs Δμ. By Lemma 37, the τ0-reduct of Δμ is equal to 𝔅01 for some dual 𝔅 of μ0. Since 𝔅 and μ0 are both duals of μ0, the valued structure 𝔅01 is fractionally homomorphically equivalent to Δμ0=(μ0)01 (Remark 19). Therefore, Δμ pp-constructs Δμ0. By Theorem 41, Δμ0 pp-constructs ({0,1};OIT). By the transitivity of pp-constructability, Δμ pp-constructs ({0,1};OIT). By Lemma 22, VCSP(Δμ) 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 {R} such that the domain of μ is finite. Assume that μ contains at least one edge and does not contain any directed cycles. Then Δμ pp-constructs ({0,1};OIT).

Proof.

Let C be the domain of μ. Let k be the length of the longest directed path in μ; it exists, because μ is finite and does not contain any directed cycles. Let ϕ(x0,x1) be the pp-expression

infx2,xk(R(x0,x1)+Opt(R)(x1,x2)+Opt(R)(xk1,xk)).

Let (x,y)C2. Then ϕΔμ(x,y)=0 if and only if there is a directed path in μ of length k starting with the edge (x,y). If ϕΔμ(x,y)0, then ϕΔμ(x,y)=1 if and only if there is a directed path in μ of length k1 starting in y. Finally, if ϕΔμ(x,y){0,1}, then ϕΔμ(x,y)=. Let Γ be the valued {R}-structure on the domain C where RΓ(x,y)=ϕΔμ(x,y) for all (x,y)C2. Note that RΓΔμ.

Recall the valued structure ΓMC from Example 2. Let a,bC be such that there is a directed path in μ of length k starting with the edge (a,b). Let f:{0,1}C be defined by f(0):=a and f(1):=b. It is straightforward to verify that ωf defined by ωf(f)=1 is a fractional homomorphism from ΓMC to Γ. Let g:C{0,1} be defined by g(x)=0 for every xC such that there is a directed path of length k starting in x and g(x)=1 otherwise. We argue that ωg defined by ωg(g)=1 is a fractional homomorphism from Γ to ΓMC. Let (x,y)C2. Note that if RΓ(x,y)1, then trivially RΓMC(g(x),g(y))RΓ(x,y). Suppose therefore that RΓ(x,y)=0. Then by the definition of ϕ, there is a directed path in 𝔅 of length k starting with the edge (x,y). By the definition of g, we have g(x)=0. Since there is no directed path of length k+1 in μ and μ does not contain directed cycles, there is no directed path of length k starting in y and therefore g(y)=1. Hence, RΓMC(g(x),g(y))RΓ(x,y). It follows that ωg is a fractional homomorphism from Γ to ΓMC.

By the previous paragraph, Γ is fractionally homomorphically equivalent to ΓMC. Since RΓΔμ, we have that Δμ pp-constructs ΓMC. We have already mentioned in Example 23 that ΓMC pp-constructs ({0,1},OIT). By the transitivity of pp-constructability, Δμ pp-constructs ({0,1},OIT).

7 Proof of Theorem 34

We are now ready to prove the main result of the paper.

Proof of Theorem 34.

Since Aut(μ)=Aut(Δμ), 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 μe, then μ is equal to μ or to μe, respectively, in which case item (1) holds by Lemma 35. We may therefore assume that μ contains neither μ nor μe.

If μ contains a conjunctive query μ0 such that Multigraph(μ0) contains a cycle of length 3, then item (2) holds by Corollary 42. Suppose that this is not the case. Then for every query ν in μ, Multigraph(ν) is a tree, or ν contains the atoms R(x,y) and R(y,x) for some variables xy, in which case ν=μc by the minimality of ν. Note that every ν such that Multigraph(ν) is a tree has a homomorphism to μc, so μ=μc whenever μ contains μc. In this case, item (1) holds by Lemma 35. Suppose therefore that μμc and hence, Multigraph(ν) 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 R. Note that μ contains at least one edge, because μμe. 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 ({0,1};OIT). 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.