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$.
翻译:我们研究在输入查询的结构限制下,计数合取查询并集(UCQ)答案的问题。具体而言,给定一个UCQ类C,问题#UCQ(C)的输入是C中的一个UCQ Q和一个数据库D,目标是计算Q在D中的答案数量。Chen和Mengel [PODS'16] 已证明:对于任意递归可枚举类C,问题#UCQ(C)要么是固定参数易解的,要么对参数化复杂度类W[1]或#W[1]中的一个是困难的。然而,他们的易解性判据难以应用——给定任意具体的UCQ类C时,判定计数该类中查询答案的难度并不容易;同样,给定单个具体的UCQ Q,判定计数其答案的难度也不容易。本文旨在寻找一个自然的易解性判据:UCQ $\varphi_1 \vee \dots \vee \varphi_\ell$ 的联合合取查询是合取查询 $\varphi_1 \wedge \dots \wedge \varphi_\ell$。我们证明,在C满足自然封闭性质的条件下,问题#UCQ(C)是固定参数易解的当且仅当C中UCQ的联合合取查询及其契约(contract)具有有界树宽。合取查询的契约是一种增强结构,考虑了量化变量与自由变量之间的连接方式。若所有变量均为自由变量,则合取查询等于其契约;在此特殊情况下,#UCQ(C)的固定参数易解判据简化为联合查询具有有界树宽。最后,我们给出证据表明,C的封闭性质对获得自然易解判据是必要的:我们证明,即使对于单个UCQ Q,判定#UCQ({Q})是否能在$O(|D|^d)$时间内求解的元问题,对任意固定的$d\geq 1$而言是NP困难的。