Table of Contents
Fetching ...

Counting Answers to Unions of Conjunctive Queries: Natural Tractability Criteria and Meta-Complexity

Jacob Focke, Leslie Ann Goldberg, Marc Roth, Stanislav Živný

TL;DR

Counting answers to unions of conjunctive queries (#UCQ) under input-structure restrictions is studied with a focus on a natural, checkable tractability criterion. The authors prove that #UCQ(C) is fixed-parameter tractable iff the combined query $oldsymbol{ abla}( ext{UCQ})$ and its contract have bounded treewidth (under deletion-closedness), with a simplification to the quantifier-free case where only $oldsymbol{ abla}(C)$ matters. For linear-time solvability of a single UCQ, tractability reduces to acyclicity of terms in the CQ expansion, but a general computable criterion does not exist; the meta problem $ extsc{Meta}$ is NP-hard and admits near-optimal upper bounds under the Triangle Conjecture, ETH and non-uniform ETH. A topological reduction shows strong lower bounds via the reduced Euler characteristic of simplicial complexes, while a WL-dimension connection ties query complexity to hereditary treewidth. Together, these results frame practical criteria for UCQ counting, reveal intrinsic meta-complexity barriers, and link database query counting to graph isomorphism and topological invariants.

Abstract

We study the problem of counting answers to unions of conjunctive queries (UCQs) under structural restrictions on the input query. Concretely, given a class C of UCQs, the problem #UCQ(C) provides as input a UCQ Q in C and a database D and the problem is to compute the number of answers of Q in D. Chen and Mengel [PODS'16] have shown that for any recursively enumerable class C, the problem #UCQ(C) is either fixed-parameter tractable or hard for one of the parameterised complexity classes W[1] or #W[1]. However, their tractability criterion is unwieldy in the sense that, given any concrete class C of UCQs, it is not easy to determine how hard it is to count answers to queries in C. Moreover, given a single specific UCQ Q, it is not easy to determine how hard it is to count answers to Q. In this work, we address the question of finding a natural tractability criterion: The combined conjunctive query of a UCQ $\varphi_1 \vee \dots \vee \varphi_\ell$ is the conjunctive query $\varphi_1 \wedge \dots \wedge \varphi_\ell$. We show that under natural closure properties of C, the problem #UCQ(C) is fixed-parameter tractable if and only if the combined conjunctive queries of UCQs in C, and their contracts, have bounded treewidth. A contract of a conjunctive query is an augmented structure, taking into account how the quantified variables are connected to the free variables. If all variables are free, then a conjunctive query is equal to its contract; in this special case the criterion for fixed-parameter tractability of #UCQ(C) thus simplifies to the combined queries having bounded treewidth. Finally, we give evidence that a closure property on C is necessary for obtaining a natural tractability criterion: We show that even for a single UCQ Q, the meta problem of deciding whether #UCQ({Q}) can be solved in time $O(|D|^d)$ is NP-hard for any fixed $d\geq 1$.

Counting Answers to Unions of Conjunctive Queries: Natural Tractability Criteria and Meta-Complexity

TL;DR

Counting answers to unions of conjunctive queries (#UCQ) under input-structure restrictions is studied with a focus on a natural, checkable tractability criterion. The authors prove that #UCQ(C) is fixed-parameter tractable iff the combined query and its contract have bounded treewidth (under deletion-closedness), with a simplification to the quantifier-free case where only matters. For linear-time solvability of a single UCQ, tractability reduces to acyclicity of terms in the CQ expansion, but a general computable criterion does not exist; the meta problem is NP-hard and admits near-optimal upper bounds under the Triangle Conjecture, ETH and non-uniform ETH. A topological reduction shows strong lower bounds via the reduced Euler characteristic of simplicial complexes, while a WL-dimension connection ties query complexity to hereditary treewidth. Together, these results frame practical criteria for UCQ counting, reveal intrinsic meta-complexity barriers, and link database query counting to graph isomorphism and topological invariants.

Abstract

We study the problem of counting answers to unions of conjunctive queries (UCQs) under structural restrictions on the input query. Concretely, given a class C of UCQs, the problem #UCQ(C) provides as input a UCQ Q in C and a database D and the problem is to compute the number of answers of Q in D. Chen and Mengel [PODS'16] have shown that for any recursively enumerable class C, the problem #UCQ(C) is either fixed-parameter tractable or hard for one of the parameterised complexity classes W[1] or #W[1]. However, their tractability criterion is unwieldy in the sense that, given any concrete class C of UCQs, it is not easy to determine how hard it is to count answers to queries in C. Moreover, given a single specific UCQ Q, it is not easy to determine how hard it is to count answers to Q. In this work, we address the question of finding a natural tractability criterion: The combined conjunctive query of a UCQ is the conjunctive query . We show that under natural closure properties of C, the problem #UCQ(C) is fixed-parameter tractable if and only if the combined conjunctive queries of UCQs in C, and their contracts, have bounded treewidth. A contract of a conjunctive query is an augmented structure, taking into account how the quantified variables are connected to the free variables. If all variables are free, then a conjunctive query is equal to its contract; in this special case the criterion for fixed-parameter tractability of #UCQ(C) thus simplifies to the combined queries having bounded treewidth. Finally, we give evidence that a closure property on C is necessary for obtaining a natural tractability criterion: We show that even for a single UCQ Q, the meta problem of deciding whether #UCQ({Q}) can be solved in time is NP-hard for any fixed .
Paper Structure (26 sections, 41 theorems, 33 equations, 2 figures, 1 algorithm)

This paper contains 26 sections, 41 theorems, 33 equations, 2 figures, 1 algorithm.

Key Result

Theorem 1

Let $C$ be a recursively enumerable class of UCQs of bounded arity. If the treewidth of $\Gamma(C)$ and of $\mathsf{contract}(\Gamma(C))$ is bounded, then $\#\textsc{UCQ}(C)$ is fixed-parameter tractable. Otherwise, $\#\textsc{UCQ}(C)$ is $\mathrm{W[1]}$-hard.

Figures (2)

  • Figure 1: Two complexes over the groundset $\Omega=\{1,2,3,4\}$. Let $\Delta_1$ be the complex shown on the left. It has facets $\{2,3,4\}$, $\{1,2\}$, $\{1,3\}$, and $\{1,4\}$. Let $\Delta_2$ be the complex shown on the right, with facets $\{1,2\}$, $\{2,3\}$, $\{1,3\}$, and $\{4\}$. The reduced Euler characteristic of these complexes is computed as follows: Since $\Delta_1$ has one face of size $3$ ($\{2,3,4\}$), $6$ faces of size $2$, $4$ faces of size $1$, and the empty set as face of size $0$ it holds that $\hat{\chi}(\Delta_1) = - (-1 + 6 - 4 +1) = -2$. Similarly, we have $\hat{\chi}(\Delta_2) = - (3 - 4 + 1) = 0$.
  • Figure 2: (Top:) The structure $\mathcal{K}_3^4$. (Bottom:) Substructures $\mathcal{S}_A$ for some selected $A\subseteq [4]$. Observe that all of the $\mathcal{S}_A$ are acyclic.

Theorems & Definitions (83)

  • Theorem 1: ChenM16
  • Theorem 2
  • Theorem 3
  • Theorem 4: See Theorem 12 in BraultBaron13, and BeraGLSS22Mengel25arxiv
  • Theorem 5
  • Definition 6: WL-dimension
  • Theorem 7
  • Theorem 8
  • Conjecture 9: ETH ImpagliazzoP01
  • Conjecture 10: Non-uniform ETH ChenEF12
  • ...and 73 more