Skip to content

[Rule] 3SAT to KClique #229

@isPANN

Description

@isPANN

name: Rule
about: Propose a new reduction rule
title: "[Rule] 3SAT to KClique"
labels: rule
assignees: ''
canonical_source_name: '3-Satisfiability (3SAT)'
canonical_target_name: 'KClique'
source_in_codebase: true
target_in_codebase: false

Source: KSatisfiability (K3)
Target: KClique
Motivation: Establishes NP-completeness of CLIQUE via polynomial-time reduction from 3SAT. This is one of Karp's 21 NP-complete problems (1972) and one of the most widely taught reductions in computational complexity. The construction elegantly encodes satisfiability constraints into graph structure, demonstrating that finding large complete subgraphs is computationally as hard as solving Boolean satisfiability.

Reference: Garey & Johnson, Computers and Intractability, A1.2 GT19

GJ Source Entry

[GT19] CLIQUE
INSTANCE: Graph G = (V,E), positive integer K <= |V|.
QUESTION: Does G contain a clique of size K or more, i.e., a subset V' <= V with |V'| >= K such that every two vertices in V' are joined by an edge in E?

Reference: [Karp, 1972]. Transformation from VERTEX COVER (see Chapter 3).
Comment: Solvable in polynomial time for graphs obeying any fixed degree bound d, for planar graphs, for edge graphs, for chordal graphs [Gavril, 1972], for comparability graphs [Even, Pnueli, and Lempel, 1972], for circle graphs [Gavril, 1973], and for circular arc graphs (given their representation as families of arcs) [Gavril, 1974a]. The variant in which, for a given r, 0 < r < 1, we are asked whether G contains a clique of size r|V| or more is NP-complete for any fixed value of r.

Reduction Algorithm

Summary:
Given a 3SAT instance φ with num_clauses clauses C_1, C_2, ..., C_{num_clauses}, each clause C_i = (l_{i,1} ∨ l_{i,2} ∨ l_{i,3}) containing exactly 3 literals over num_vars Boolean variables, construct a KClique instance (G, num_clauses) as follows:

  1. Vertex construction: For each clause C_i and each literal l_{i,j} in that clause, create a vertex v_{i,j}. This yields exactly 3·num_clauses vertices, organized into num_clauses groups (triples) of 3, one triple per clause.

  2. Edge construction: Connect two vertices v_{i,a} and v_{j,b} with an edge if and only if:

    • They belong to different clauses (i ≠ j), AND
    • Their literals are not contradictory (l_{i,a} is not the negation of l_{j,b}).
      In other words, edges are absent only between vertices in the same triple and between vertices labeled with complementary literals (x and ¬x).
  3. Clique size parameter: Set K = num_clauses.

  4. Solution extraction: Given a clique C of size num_clauses in G, construct a satisfying assignment by setting each literal corresponding to a vertex in C to TRUE. This is consistent because no two vertices in the clique have contradictory labels (such pairs have no edge, so cannot both be in a clique). Each clause is satisfied because the clique contains exactly one vertex from each triple.

Correctness:

  • (Forward) If φ is satisfiable, pick one true literal per clause. The corresponding num_clauses vertices form a clique: they are from different triples (so edges exist between them) and their labels are consistent with a single assignment (so no contradictory pairs).
  • (Backward) If G has a num_clauses-clique, no two vertices can come from the same triple (no intra-triple edges), so exactly one vertex per clause is selected. The labels on these vertices define a consistent truth assignment that satisfies all num_clauses clauses.

Note: Both KSatisfiability and KClique are satisfaction problems (Metric = bool), so no sat/opt type bridge is needed. The reduction maps satisfying assignments bijectively to k-cliques.

Source: Karp (1972), "Reducibility among combinatorial problems"; Sipser, Introduction to the Theory of Computation, Theorem 7.32; Garey & Johnson Chapter 3.

Size Overhead

Symbols:

  • num_clauses: number of clauses in the 3SAT formula
  • num_vars: number of variables in the 3SAT formula
Target metric (code name) Formula
num_vertices 3 * num_clauses
num_edges 9 * num_clauses * (num_clauses - 1) / 2 (upper bound)
k num_clauses

Derivation: There are 3·num_clauses vertices (3 per clause). Cross-triple vertex pairs total 9 · C(num_clauses, 2) = 9·num_clauses·(num_clauses − 1)/2. From these we subtract pairs with contradictory labels (x_i and ¬x_i across different triples). The exact number of contradictory pairs is instance-dependent, so the overhead uses the upper bound (zero contradictory pairs removed). In the worst case (all distinct variables per clause), this bound is tight.

Validation Method

  • Closed-loop test: construct a 3SAT instance, reduce to KClique (G, k), solve the KClique instance with BruteForce, extract the satisfying assignment from the clique vertices, verify it satisfies the original 3SAT formula.
  • Forward test: generate a known-satisfiable 3SAT instance, verify the constructed graph contains a k-clique.
  • Backward test: generate a known-unsatisfiable 3SAT instance, verify no k-clique exists in G.
  • Size verification: check that the graph has exactly 3·num_clauses vertices and that no intra-triple edges or contradictory-literal edges exist.

Example

Source instance (3SAT):
Variables: x_1, x_2, x_3 (num_vars = 3)
Clauses (num_clauses = 3):

  • C_1 = (x_1 ∨ ¬x_2 ∨ x_3)
  • C_2 = (¬x_1 ∨ x_2 ∨ ¬x_3)
  • C_3 = (x_1 ∨ x_2 ∨ x_3)

Constructed target instance (KClique):
Vertices (3·num_clauses = 9):

  • Triple 1 (C_1): v_{1,1}=x_1, v_{1,2}=¬x_2, v_{1,3}=x_3
  • Triple 2 (C_2): v_{2,1}=¬x_1, v_{2,2}=x_2, v_{2,3}=¬x_3
  • Triple 3 (C_3): v_{3,1}=x_1, v_{3,2}=x_2, v_{3,3}=x_3

Edges (connect cross-triple non-contradictory pairs):

  • v_{1,1}(x_1) — v_{2,2}(x_2): YES
  • v_{1,1}(x_1) — v_{2,3}(¬x_3): YES
  • v_{1,1}(x_1) — v_{2,1}(¬x_1): NO (contradictory)
  • v_{1,1}(x_1) — v_{3,1}(x_1): YES
  • v_{1,1}(x_1) — v_{3,2}(x_2): YES
  • v_{1,1}(x_1) — v_{3,3}(x_3): YES
  • v_{1,2}(¬x_2) — v_{2,1}(¬x_1): YES
  • v_{1,2}(¬x_2) — v_{2,2}(x_2): NO (contradictory)
  • v_{1,2}(¬x_2) — v_{2,3}(¬x_3): YES
  • v_{1,2}(¬x_2) — v_{3,1}(x_1): YES
  • v_{1,2}(¬x_2) — v_{3,2}(x_2): NO (contradictory)
  • v_{1,2}(¬x_2) — v_{3,3}(x_3): YES
  • v_{1,3}(x_3) — v_{2,1}(¬x_1): YES
  • v_{1,3}(x_3) — v_{2,2}(x_2): YES
  • v_{1,3}(x_3) — v_{2,3}(¬x_3): NO (contradictory)
  • v_{1,3}(x_3) — v_{3,1}(x_1): YES
  • v_{1,3}(x_3) — v_{3,2}(x_2): YES
  • v_{1,3}(x_3) — v_{3,3}(x_3): YES
  • v_{2,1}(¬x_1) — v_{3,1}(x_1): NO (contradictory)
  • v_{2,1}(¬x_1) — v_{3,2}(x_2): YES
  • v_{2,1}(¬x_1) — v_{3,3}(x_3): YES
  • v_{2,2}(x_2) — v_{3,1}(x_1): YES
  • v_{2,2}(x_2) — v_{3,2}(x_2): YES
  • v_{2,2}(x_2) — v_{3,3}(x_3): YES
  • v_{2,3}(¬x_3) — v_{3,1}(x_1): YES
  • v_{2,3}(¬x_3) — v_{3,2}(x_2): YES
  • v_{2,3}(¬x_3) — v_{3,3}(x_3): NO (contradictory)

Contradictory pairs (6 total): v_{1,1}–v_{2,1}, v_{1,2}–v_{2,2}, v_{1,2}–v_{3,2}, v_{1,3}–v_{2,3}, v_{2,1}–v_{3,1}, v_{2,3}–v_{3,3}.

Total edges: 27 cross-triple pairs − 6 contradictory = 21 edges.

Clique size: K = 3

Solution mapping:

  • 3-clique in G: {v_{1,1}(x_1), v_{2,2}(x_2), v_{3,3}(x_3)}
    • Check edges: v_{1,1}–v_{2,2} (YES), v_{1,1}–v_{3,3} (YES), v_{2,2}–v_{3,3} (YES). Valid clique.
  • Extracted assignment: x_1 = TRUE, x_2 = TRUE, x_3 = TRUE
  • Verification against 3SAT:
    • C_1 = (T ∨ F ∨ T) = TRUE
    • C_2 = (F ∨ T ∨ F) = TRUE
    • C_3 = (T ∨ T ∨ T) = TRUE
  • All clauses satisfied. ✓

Alternative clique: {v_{1,2}(¬x_2), v_{2,1}(¬x_1), v_{3,3}(x_3)} is also a valid 3-clique (all three pairs have edges). Extracted assignment: x_1 = FALSE, x_2 = FALSE, x_3 = TRUE. Verification: C_1 = (F ∨ T ∨ T) = T, C_2 = (T ∨ F ∨ F) = T, C_3 = (F ∨ F ∨ T) = T. ✓

The formula has 5 satisfying assignments out of 8 total, and the graph has 12 distinct 3-cliques.

References

  • [Karp, 1972]: [Karp1972] Richard M. Karp (1972). "Reducibility among combinatorial problems". In: Complexity of Computer Computations. Plenum Press.
  • [Gavril, 1972]: [Gavril1972] F. Gavril (1972). "Algorithms for minimum coloring, maximum clique, minimum covering by cliques, and maximum independent set of a chordal graph". SIAM Journal on Computing 1, pp. 180-187.
  • [Even, Pnueli, and Lempel, 1972]: [Even1972] S. Even and A. Pnueli and A. Lempel (1972). "Permutation graphs and transitive graphs". Journal of the Association for Computing Machinery 19, pp. 400-410.
  • [Gavril, 1973]: [Gavril1973] F. Gavril (1973). "Algorithms for a maximum clique and a maximum independent set of a circle graph". Networks 3, pp. 261-273.
  • [Gavril, 1974a]: [Gavril1974a] F. Gavril (1974). "Algorithms on circular-arc graphs". Networks 4, pp. 357-369.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.ruleA new reduction rule to be added.

    Type

    No type

    Projects

    Status

    Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions