II. New for today:
f : {0, 1}* ® {0, 1}* such that for all x Î {0, 1}*, x Î L1 if and only if f(x) Î L2. We call the function f the reduction function, and a polynomial-time algorithm F that computes f as the reduction algorithm.
Examples:
SAT (SATisfiability) problem:
The first expression is not in 3CNF, because both
the first and the second clauses contain more than 3 literals (4 literals
in this example), but it can be logically converted
to 3CNF as follows:
(X1Ú X2Ú Ø Y1) Ù (Y1Ú Ø X4Ú X6) Ù (X3Ú Ø X2Ú Ø Y2) Ù (Y2Ú X4Ú X5) Ù (X1Ú Ø X2) Ù (X4Ú X5)
The logical equivalence between this expression and
the original one can be proved using a truth table to see whether both
expressions return the same value.
In general, if a boolean expression has one or more
term(s) with more than 3 literals, the expression is not in 3CNF.
However, this expression can be logically converted
into one in 3CNF by the addition of new vaiables (such as y1,
y2, in
the example above).
Clique Problem:
Instance of the problem: an undirected graph G, and an integer K.
Question: Does the graph have a "clique" of size at least K?
A clique in an undirected graph G = (V, E) is a subset
V’ Í V of vertices, each pair of which
is connected by an edge in E.
In other words, a clique is a complete subgraph
of G. The size of the clique is the number of vertices it contains.
To prove that CLIQUE is NP-complete, we need show:
2. We next show that the clique problem is
NP-hard by proving that 3-SAT £ p CLIQUE.
The reduction algorithm begins
with an instance of 3-SAT. Let F=C1Ù
C2Ù ×
× × Ù
Cm be a boolean formula in 3-CNF with m clauses and n
variables. For
r = 1, 2, …, m, each clause Cr has exactly
three distinct literals l1r, l2r,
and l3r. We shall construct a graph G such that F
is
satisfiable if and only if G has a clique of size m.
The graph G= (V, E) is constructed as follows. For each clause
Cr = (l1rÚ
l2rÚ
l3r) in F, we place a triple of vertices v1r,
v2r, and v3r in V. We put an
edge between two vertices vir and vjs
if both of the following hold:
F = (X1Ú X2Ú ØX7) Ù (X7Ú ØX4Ú X6) Ù (X3Ú ØX2Ú ØX8) Ù (X8Ú X4Ú X5) Ù (X1Ú ØX2) Ù (X4Ú X5),
Then the graph in Figure 2. shows all the edges in
the G incident on one of the vertices corresponding to the first literal
in the first clause.
Figure 2 The graph derived from the 3-CNF
formula F = C1Ù C2Ù
C3Ù C4Ù
C5Ù C6,
where C1= (X1Ú
X2Ú ØX7),
C2= (X7Ú
ØX4Ú
X6), C3= (X3Ú
ØX2Ú
ØX8), C4=
(X8Ú X4Ú
X5), C5= (X1Ú
ØX2), and C6=
(X4Ú X5),
in reducing
3-CNF-SAT to CLIQUE. A satisfying assignment of
the formula is (X1 = 1, X2 = 0, X3 = 0,
X4 = 0, X5 = 0, X6 = 1,
X7 = 1, X8 = 1), corresponding
to the clique with green shaded vertices. In this example, X1
is connected to every vertex
except ØX1.
Now we have shown how to construct an instance of a clique.
Claim: F is satisfiable if and only if G has a clique of at least size k.
Proof (in both ways)
(Þ ) First, suppose
that F has a satisfying assignment. Then, each clause Cr contains
at least one literal lir that is assigned 1,
and each such literal corresponds to a vertex vir.
Picking one such "true" literal from each clause yields a set of V’ of
k
vertices. We claim that V’ is a clique. For any
two vertices vir, vjr Î
V’, where r ¹ s, both corresponding literals
lir and ljs
are mapped to 1 by the given satisfying
assignment, and thus the literals cannot be complements. Thus, by the construction
of G, the edge (vir, vjs)
belongs to E.
(Ü ) Conversely,
suppose that G has a clique V’ of size k. No edges in G connect vertices
in the same triple, and so V’
contains exactly one vertex per triple. We can assign
1 to each literal lir such that vir
Î V’ without fear of assigning 1 to both
a literal and its complement, since G contains no
edges between inconsistent literals. Each clause is satisfied, and so F
is
satisfied. (Any variables that correspond to no
vertex in the clique may be set arbitrarily.)