Math 2.0

Areas Mathematical logic Second-order logic and extensions of first-order logic Example

Three-colorability in existential monadic second-order logic

Builds on Monadic second-order logicK-colourable graphGraphFagin's theorem

Example

To color a graph with three colors is to choose three sets of vertices, one for each color. So a quantifier over sets of vertices can say that a coloring exists.

A graph is a structure (V,E)(V, E) with a symmetric and irreflexive edge relation EE. It is 3-colorable when there is a map c:V→{1,2,3}c : V \to \set{1, 2, 3} with c(u)≠c(v)c(u) \neq c(v) for every edge {u,v}\set{u, v}. The existential monadic second-order sentence χ3\chi_3 is this: ∃R∃G∃B(∀x (R(x)∨G(x)∨B(x))∧∀x∀y(E(x,y)→¬(R(x)∧R(y))∧¬(G(x)∧G(y))∧¬(B(x)∧B(y)))).\exists R \exists G \exists B \Bigl( \forall x\, (R(x) \lor G(x) \lor B(x)) \land \forall x \forall y \bigl( E(x, y) \to \neg (R(x) \land R(y)) \land \neg (G(x) \land G(y)) \land \neg (B(x) \land B(y)) \bigr) \Bigr). We show that a graph satisfies χ3\chi_3 if and only if it is 3-colorable.

  1. Let cc be a proper coloring with the colors 1,2,31, 2, 3. Put R=c−1(1)R = c^{-1}(1), G=c−1(2)G = c^{-1}(2) and B=c−1(3)B = c^{-1}(3).
  2. Every vertex has a color, so every vertex lies in RR, GG or BB, and the first conjunct holds.
  3. If E(u,v)E(u, v), then c(u)≠c(v)c(u) \neq c(v). So uu and vv do not lie in the same one of the three sets, and the second conjunct holds.
  4. Conversely, let R,G,BR, G, B satisfy the matrix of χ3\chi_3. The sets can overlap, so we put c(v)=1c(v) = 1 if v∈Rv \in R, c(v)=2c(v) = 2 if v∈G∖Rv \in G \setminus R, and c(v)=3c(v) = 3 otherwise.
  5. By the first conjunct, a vertex with c(v)=3c(v) = 3 lies in BB. So each vertex lies in the set that matches its color.
  6. If E(u,v)E(u, v) and c(u)=c(v)c(u) = c(v), then uu and vv lie in the same set by step 5, and this contradicts the second conjunct. So cc is proper.

Remarks

Two small graphs

The 5-cycle has the vertices 1,…,51, \ldots, 5 and the edges 12,23,34,45,5112, 23, 34, 45, 51. We try these sets: R={1,3},G={2,4},B={5}.R = \set{1, 3}, \qquad G = \set{2, 4}, \qquad B = \set{5}. Check: the edges join RR to GG, GG to RR, RR to GG, GG to BB and BB to RR. So no edge stays inside one set. The complete graph K4K_4 fails χ3\chi_3. Each of its four vertices lies in one of three sets. So two of them share a set by the pigeonhole principle, and these two vertices are adjacent.

Where the sentence sits

The sentence has the form ∃X1⋯∃Xk φ\exists X_1 \cdots \exists X_k\, \varphi with φ\varphi first-order, so it is in existential MSO (EMSO). It quantifies only over sets of vertices, not over sets of edges, so it is an MSO1\mathrm{MSO}_1 sentence.

More colors, and the cost of checking

For kk colors we use kk set variables and the same two conjuncts. For k=2k = 2 the sentence defines the bipartite graphs. A program decides 2-colorability in polynomial time, but 3-colorability is NP-complete. So the evaluation of one fixed EMSO sentence on finite graphs can already be NP-complete. This agrees with Fagin's theorem: existential second-order logic defines exactly the properties in NP. On graphs of bounded treewidth, Courcelle's theorem decides χ3\chi_3 in linear time.

Going deeper

For a student

We check χ3\chi_3 on the wheel W5W_5. It has a 5-cycle 1,2,3,4,51, 2, 3, 4, 5 and a center 00 that is joined to all five.

  1. In a proper coloring, the center is adjacent to every other vertex, so its color appears nowhere else. Say the center has color 33.
  2. Then the 5-cycle uses only the colors 11 and 22, so the colors must alternate along it.
  3. Going around from vertex 11, the vertices 1,3,51, 3, 5 get one color and the vertices 2,42, 4 get the other.
  4. Then the edge 5151 joins two vertices of the same color. So W5W_5 has no proper 3-coloring, and W5W_5 fails χ3\chi_3.

Check: a cycle with an odd number of vertices has no 2-coloring, and 55 is odd. The typical use of the sentence is to show that a graph property is in NP, or to apply Courcelle's theorem to it. Watch out: do not require in a proof that RR, GG and BB are disjoint when the sentence does not say so. Our sentence allows overlaps, and step 4 of the example removes them.

Reading path

To understand this page from the ground up, read these 48 pages in order. The foundations come first.

  1. Arity concept
  2. Boolean function concept
  3. Cartesian product concept
  4. First-order variable concept
  5. Function concept
  6. Graph concept
  7. K-colourable graph concept
  8. Power set concept
  9. Proposition concept
  10. Regular language concept
  11. Set concept
  12. String concept
  13. Tuple concept
  14. Turing machine concept
  15. Signature concept
  16. Logical connective definition
  17. Conjunction definition
  18. Disjunction definition
  19. Material implication definition
  20. Principle of bivalence concept
  21. Predicate concept
  22. Predicate definition
  23. Structure concept
  24. Biconditional definition
  25. Term concept
  26. Negation concept
  27. Negation definition
  28. Atomic formula concept
  29. Truth table concept
  30. Material implication concept
  31. Conjunction concept
  32. Disjunction concept
  33. Tautology concept
  34. Biconditional concept
  35. Universal quantifier concept
  36. Logical connective concept
  37. Existential quantifier concept
  38. Well-formed formula concept
  39. Propositional calculus concept
  40. Satisfaction concept
  41. First-order logic concept
  42. Free and bound variables concept
  43. Sentence concept
  44. Second-order logic definition
  45. Second-order logic concept
  46. Monadic second-order logic concept
  47. Fagin's theorem statement
  48. Three-colorability in existential monadic second-order logic example

Further reading

  1. Web https://en.wikipedia.org/wiki/Courcelle's_theorem, Vertex sets
  2. Web https://en.wikipedia.org/wiki/Monadic_second-order_logic, Variants
About this page
TagEHH5XEB6BG
URIm2://EHH5XEB6BG
Kindexample
WritingW0 stub
MSC03B16, 03C13, 05C15, 68Q19
Instance ofMonadic second-order logic
Part ofSecond-order logic and extensions of first-order logic
UsesMonadic second-order logic, K-colourable graph, Graph, Fagin's theorem
Changed23 November 2026, first written 17 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

History

Each change to this page, from its provenance log. A change by an agent names its run.

The changes to this page, the oldest first
DateChangeFieldBy
2026-11-17addthe whole nodetamnd
2026-11-23changethe section Exampletamnd
2026-11-23changethe explanation L1tamnd
2026-11-23changethe explanation L2tamnd
2026-11-23changethe section Remarkstamnd
2026-11-23changethe field nametamnd

What links here

No page links to this page yet.