{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $\\mathbb{B}$ be a finite [[relational structure|MJF9M19E3E]] with finitely many relations.\nThe problem $\\mathrm{CSP}(\\mathbb{B})$ takes as input a finite structure $\\mathbb{A}$ of the same signature and asks whether there is a [[homomorphism|KBXSZC6BV1]] from $\\mathbb{A}$ to $\\mathbb{B}$.\nA finite structure is a *core* if each of its endomorphisms is an automorphism.\nLet $\\mathbb{C}$ be the core of $\\mathbb{B}$, that is, a core that admits homomorphisms $\\mathbb{B} \\to \\mathbb{C}$ and $\\mathbb{C} \\to \\mathbb{B}$; it is unique up to isomorphism.\nA *Taylor polymorphism* of $\\mathbb{C}$ is a [[polymorphism|A0K9EZRM7E]] $t$ of $\\mathbb{C}$ of some arity $n \\ge 2$ that is a [[Taylor operation|QEAMRNRJJD]].\nThat is, $t(x, \\ldots, x) = x$ for all $x$.\nAlso, for each position $i \\le n$, $t$ satisfies an identity $t(u_1, \\ldots, u_n) \\approx t(v_1, \\ldots, v_n)$ with each $u_j, v_j \\in \\set{x, y}$, $u_i = x$ and $v_i = y$.\nThen exactly one of the following holds.\n\n1. $\\mathbb{C}$ has a Taylor polymorphism, and $\\mathrm{CSP}(\\mathbb{B})$ is solvable in polynomial time.\n2. $\\mathbb{C}$ has no Taylor polymorphism, and $\\mathrm{CSP}(\\mathbb{B})$ is NP-complete.\n\nIn particular, each such constraint satisfaction problem is either in P or NP-complete.\n\n## Remarks\n\nThe two algebraic cases exclude each other.\nThe two complexity outcomes are different only if $\\mathrm{P} \\ne \\mathrm{NP}$.\nThe hardness half was proved earlier in the [[algebraic approach to constraint satisfaction|3EH4F5H7FT]].\nWithout a Taylor polymorphism, the polymorphism clone of the core allows a reduction from an NP-complete problem such as 3-colouring.\nThe tractability half was proved independently by Andrei Bulatov and by Dmitriy Zhuk, with two different polynomial-time algorithms.\nThis settled the [[Feder–Vardi dichotomy conjecture|WNHZC07XVP]].\nBy a theorem of Siggers, a finite core has a Taylor polymorphism exactly when it has an idempotent 6-ary polymorphism $s$ of a special form.\nThis $s$ satisfies $s(x, y, x, z, y, z) = s(y, x, z, x, z, y)$ for all $x, y, z$; see [[Siggers term|JYW1H3J8SX]].\n\nExample: let $\\mathbb{B} = K_n$ be the complete graph on $n$ vertices.\nThen $\\mathrm{CSP}(K_n)$ is the $n$-colouring problem.\nFor $n = 2$, the majority operation on the two vertices is a polymorphism and a Taylor operation.\nSo $2$-colouring is in P.\nFor $n \\ge 3$ the graph $K_n$ is a core with no Taylor polymorphism, and $n$-colouring is NP-complete.\nMore generally, let $H$ be a finite undirected graph.\nThen $\\mathrm{CSP}(H)$ is in P if $H$ is bipartite or has a loop, and NP-complete otherwise (Hell and Nešetřil).\n\nPassing to the core matters, because a Taylor polymorphism must be idempotent.\nFor example, the disjoint union of $K_3$ and a single vertex with a loop has no Taylor polymorphism.\nIts core is the looped vertex, which has one, and indeed its CSP is trivial: every input maps to the loop.\n\n## Explanations\n\n### L1 human\n\nMany puzzles ask to label the points of a finite input so that given local rules hold, as in map colouring or Sudoku-like constraints.\nWhen the allowed labels and rules are fixed, each such puzzle type is a constraint satisfaction problem.\nThe theorem says that every such problem type is either solvable by a fast algorithm or as hard as any problem in NP.\nThere is nothing in between.\nWhich side a problem falls on is decided by an algebraic test: whether the rules are preserved by a certain kind of \"averaging\" operation.\n\n### L2 human\n\nThe polymorphisms of $\\mathbb{B}$ form a clone, and the complexity of $\\mathrm{CSP}(\\mathbb{B})$ depends only on the identities that this clone satisfies.\nThe Taylor condition is the weakest nontrivial such identity, and by the cyclic term and Siggers term theorems it can be tested by a single identity.\nEarlier special cases include Schaefer's theorem for Boolean structures and the Hell–Nešetřil theorem for undirected graphs.\nFor infinite templates, and for counting or optimisation versions, separate classification programs exist.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "3EH4F5H7FT"
    ],
    "kind": "statement",
    "msc": [
      "08A70",
      "68Q25",
      "08A40"
    ],
    "name": "CSP dichotomy theorem",
    "role": "theorem",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Constraint_satisfaction_problem"
      }
    ],
    "tag": "ZA4YXJ9T1P",
    "uses": [
      "MJF9M19E3E",
      "KBXSZC6BV1",
      "A0K9EZRM7E",
      "QEAMRNRJJD"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/ZA4YXJ9T1P/",
  "links": [
    {
      "field": "about",
      "target": "3EH4F5H7FT"
    },
    {
      "field": "uses",
      "target": "MJF9M19E3E"
    },
    {
      "field": "uses",
      "target": "KBXSZC6BV1"
    },
    {
      "field": "uses",
      "target": "A0K9EZRM7E"
    },
    {
      "field": "uses",
      "target": "QEAMRNRJJD"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/ZA4YXJ9T1P.md",
  "msc": [
    "08A70",
    "68Q25",
    "08A40"
  ],
  "name": "CSP dichotomy theorem",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/ZA4/ZA4YXJ9T1P.md",
  "status": null,
  "tag": "ZA4YXJ9T1P",
  "uri": "m2://ZA4YXJ9T1P",
  "url": "https://tamnd.github.io/math2/wiki/csp-dichotomy-theorem/",
  "writing": {
    "tag": "ZA4YXJ9T1P",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
