Graph coloring #
KColoring k is the set of graphs, given by a list of vertices and a list of edges, whose
declared vertices can be colored with k colors so that adjacent vertices get different colors
[Kar72]; ThreeColoring is KColoring 3. Graphs are read through
Cslib.Complexity.Graph.toSimpleGraph restricted to the declared vertices (SimpleGraph.induce),
and colorings through SimpleGraph.Colorable. Edges with an undeclared endpoint and self-loops
are therefore ignored. A graph without declared vertices belongs to every KColoring k, and for
k = 0 these are the only members.
A certificate for KColoring k gives each declared vertex k bits, at the position of its first
occurrence; the color is the number of set bits, which must be below k.
The reduction SAT.toThreeColoring is the palette, variable and clause gadget construction for
3-colorability, a standard exercise Sipser, Chapter 7. Three palette vertices T, F
and B form a triangle; the two literals of each variable form a triangle with B, so they take
the colors of T and F in some order. The gadget of a clause is a chain of OR gadgets: its stage
0 is adjacent to T and B, hence colored like F; stage j + 1 is a triangle attached to the
output of stage j and to the j-th literal, whose output can take the color of T exactly when
one of them does; and the output of the last stage is adjacent to F and B, hence colored like
T. Chaining handles clauses of every width, including the empty clause, so the reduction is from
SAT; it also reduces ThreeSAT after rejecting clauses with more than three literals.
For k = m + 3 colors, SAT.toKColoring m adds m universal vertices adjacent to every vertex
and to each other. They take m colors of their own, and the gadget vertices are colored with the
remaining three, so KColoring k is NP-complete for every k ≥ 3.
Main definitions #
Cslib.Complexity.KColoring,Cslib.Complexity.ThreeColoring.Cslib.Complexity.KColoring.colorOf,Cslib.Complexity.KColoring.verifier.Cslib.Complexity.SAT.toThreeColoring,Cslib.Complexity.SAT.toKColoring.
Main results #
Cslib.Complexity.mem_KColoring_iff: membership as a bounded natural-number coloring.Cslib.Complexity.KColoring.isVerifier,Cslib.Complexity.KColoring.mem_NP:KColoring k ∈ NP encGraphfor everyk.Cslib.Complexity.SAT.toThreeColoring_mem_iff:toThreeColoring φ ∈ ThreeColoring ↔ φ ∈ SAT.Cslib.Complexity.SAT.computableInPolyTime_toThreeColoring: the reduction is polynomial-time.Cslib.Complexity.polyTimeReducible_SAT_ThreeColoring,Cslib.Complexity.polyTimeReducible_ThreeSAT_ThreeColoring,Cslib.Complexity.ThreeColoring_npHard,Cslib.Complexity.ThreeColoring_npComplete:ThreeColoringisNP-complete.Cslib.Complexity.SAT.length_toThreeColoring_le: the graph of the 3-coloring reduction has linearly many vertices and edges for clauses of bounded width.Cslib.Complexity.SAT.toKColoring_mem_iff:toKColoring m φ ∈ KColoring (m + 3) ↔ φ ∈ SAT.Cslib.Complexity.polyTimeReducible_SAT_KColoring,Cslib.Complexity.KColoring_npHard,Cslib.Complexity.KColoring_npComplete:KColoring kisNP-complete fork ≥ 3.
References #
The graphs whose declared vertices can be colored with three colors, adjacent vertices getting different colors Sipser, Chapter 7.
Instances For
The verifier #
KColoring.verifier k verifies KColoring k with certificates of k bits per symbol of the
encoded graph.
Reading a color from a certificate is polynomial-time, with the color in unary.
The KColoring k verifier is polynomial-time.
The gadget graph #
The palette vertex of color c: color 0 reads true, 1 reads false and 2 is the base
color.
Instances For
The vertex of a literal of φ, numbered by the first occurrence of its variable in φ.
Instances For
Vertex r of stage j of the gadget of clause i; vertex 2 is the output of the stage.
Instances For
The edges between the two literals of the variable x and the base palette vertex.
Instances For
Stage j + 1 of the gadget of clause i: a triangle attached to the output of stage j and
to the literal l.
Instances For
The gadget of the clause c with index i: the output of stage 0 is adjacent to the true
and base palette vertices, one stage follows for each literal, and the output of the last stage is
adjacent to the false and base palette vertices.
Instances For
The edges of the gadget graph of φ: the palette triangle, the variable triangles and the
clause gadgets.
Instances For
The reduction from SAT to ThreeColoring: the gadget graph of φ, whose declared vertices
are the endpoints of its edges.
Instances For
Correctness of the reduction #
Correctness of the 3-coloring reduction. A formula is satisfiable exactly when its gadget graph is 3-colorable.
Polynomial-time reduction #
The reduction toThreeColoring is computable in polynomial time: vertex labels are computed in
unary from clause, position and first-occurrence indices, then converted to binary.
Size #
The 3-coloring reduction has linear size. On formulas with m clauses of at most k
literals, the graph of SAT.toThreeColoring has at most (24 k + 12) m + 9 vertices and edges in
total, counted as listed.
More colors #
The r-th universal vertex of the reduction to KColoring (m + 3).
Instances For
The edges of the gadget graph of φ together with m universal vertices, each adjacent to
every vertex of the gadget graph and to the other universal vertices.
Instances For
The reduction from SAT to KColoring (m + 3): the gadget graph of φ with m universal
vertices, which take m colors of their own.
Instances For
Correctness of the (m + 3)-coloring reduction. A formula is satisfiable exactly when its
gadget graph with m universal vertices is (m + 3)-colorable.
The reduction toKColoring m is computable in polynomial time for every fixed m.
SAT reduces to ThreeColoring in polynomial time via SAT.toThreeColoring.
ThreeSAT reduces to ThreeColoring in polynomial time: a formula with a clause of more than
three literals is mapped to the gadget graph of the empty clause, which is not 3-colorable.
ThreeColoring is NP-hard.
ThreeColoring is NP-complete Garey and Johnson.
For k ≥ 3, SAT reduces to KColoring k in polynomial time via SAT.toKColoring (k - 3).
For k ≥ 3, KColoring k is NP-complete Garey and Johnson.