Computational complexity CSPs are also studied in
computational complexity theory,
finite model theory and
universal algebra. It turned out that questions about the complexity of CSPs translate into important universal-algebraic questions about underlying algebras. This approach is known as the
algebraic approach to CSPs. Since every computational decision problem is
polynomial-time equivalent to a CSP with an infinite template, general CSPs can have arbitrary complexity. In particular, there are also CSPs within the class of
NP-intermediate problems, whose existence was demonstrated by
Ladner, under the assumption that
P ≠ NP. However, a large class of CSPs arising from natural applications satisfy a complexity dichotomy, meaning that every CSP within that class is either in
P or
NP-complete. These CSPs thus provide one of the largest known subsets of
NP which avoids
NP-intermediate problems. A complexity dichotomy was first proven by
Schaefer for Boolean CSPs, i.e. CSPs over a 2-element domain and where all the available relations are
Boolean operators. This result has been generalized for various classes of CSPs, most notably for all CSPs over finite domains. This
finite-domain dichotomy conjecture was first formulated by Tomás Feder and Moshe Vardi, and finally proven independently by Andrei Bulatov and Dmitriy Zhuk in 2017. Other classes for which a complexity dichotomy has been confirmed are • all
first-order reducts of (\mathbb{Q},, • all first-order reducts of the
countable random graph, • all first-order reducts of the
model companion of the class of all C-relations, • all first-order reducts of the universal homogenous
poset, • all first-order reducts of homogenous undirected graphs, • all first-order reducts of all unary structures, • all CSPs in the complexity class MMSNP. Most classes of CSPs that are known to be tractable are those where the
hypergraph of constraints has bounded
treewidth, or where the constraints have arbitrary form but there exist equationally non-trivial polymorphisms of the set of constraint relations. An
infinite-domain dichotomy conjecture has been formulated for all CSPs of reducts of finitely bounded homogenous structures, stating that the CSP of such a structure is in P if and only if its
polymorphism clone is equationally non-trivial, and NP-hard otherwise. The complexity of such infinite-domain CSPs as well as of other generalisations (Valued CSPs, Quantified CSPs, Promise CSPs) is still an area of active research. Every CSP can also be considered as a
conjunctive query containment problem.
Function problems A similar situation exists between the functional classes
FP and
#P. By a generalization of
Ladner's theorem, there are also problems in neither FP nor
#P-complete as long as FP ≠ #P. As in the decision case, a problem in the #CSP is defined by a set of relations. Each problem takes a
Boolean formula as input and the task is to compute the number of satisfying assignments. This can be further generalized by using larger domain sizes and attaching a weight to each satisfying assignment and computing the sum of these weights. It is known that any complex weighted #CSP problem is either in FP or #P-hard. ==Variants==