Title: Computer Science 500 Theory of Computation Spring, 2000, April 19
1Computer Science 500Theory of ComputationSpring,
2000, April 19 1. R.T. practice quiz 2.
3-colorability 3. PUZZLE
2Problem 1 For each language, state 1) Does
Rice Theorem apply (directly) to the
language?2a) If your answer to (1) is yes,
what fact does Rices Theorem imply? 2b) If your
answer to (1) is no, why does Rices Theorem
not apply?
A) La M L(M) LU B) Lb M M
halts on exactly one of its inputs C) Lc
PARTION S ? T ? S Sw?T w Sw?T w D) Ld
M L(M) ? Lu AND L(M) ? Lu E) Le M
L(M) LU F) Lf M L(M) is regular
4 (imaginary) points each
3NP-completedefinition
A language L is NP-complete iff 1) L ? NP
2) L is NP-hard
43 Definitions Coloring, Chromatic Number,
3-COLOR
1. A coloring of an undirected graph G is a
labeling (coloring) of Gs vertices so that no
two vertices of the same label (color) are
adjacent. 2. The Chromatic Number of an
undirected graph G is the minimum number of
colors (labels) k such that G can be colored
using only these colors. 3. 3-COLOR G G is
an undirected graph with chromatic number 3
5Claim 3-COLOR is NP-complete
(step 1)
Proof 1) 3-COLOR G G is an undirected graph
s.t. ?s VG ? 1,2,3 where ?(v,w) ? EG, we
have s(v) ? s(w) ? S1,p NP 2) 3-COLOR is
NP-hard we will show 3-SAT ltp 3-COLOR
63-SAT ltp 3-COLOR
Define Reduction f 1. f formulas ?
undirected graphs 2. f is poly-time computable
(step 2)
Input Boolean formula F in 3-SAT form e.g. F
(a or b or not c) AND ((not a) or b or d) AND
Let C be the number of clauses and N be the
number of variables
Output graph G 3. ? F, F ? 3-SAT ? f(F)
G ? 3-COLOR
7(step 3)
? f, f(f) G where G G is a graph with N
pairs, C or-gadgets, and 2 extra vertices
(total of 2N 6C 2 vertices)
- There is one variable gadget in G per variable
in f - ? i 1 lt i lt N, the gadget has two vertices
named xi and xi which are connected by an
edge. - There is one clause gadget in G per clause in
f - ? j 1 lt j lt C, the gadget has six vertices
named and connected internally as follows
Terminal 1
mid_output
mid_Terminal
Last_output
Terminal 2
Terminal 3
8- There is one vertex named N that is connected
to every vertex in the variable gadgets and all
the mid_output and Last_output output vertices
in the clause gadgets - There is one vertex named F that is connected
to the N vertex and every Last_output output
vertex in the clause gadgets - For each clause j 1 lt j lt C, and value i 1
lt i lt 3, the ith literal in the clause j is
connected to the terminal_i in the jth clause
gadget.
9Showing the reduction f 3-SAT to 3-COLOR is
correct
(step 4)
1. ?f, f ?3-SAT ? f(f) G ? 3-COLOR 2. ?f, f
?3-SAT ? f(f) G ? 3-COLOR
10Showing 1.
(step 5)
Given an assignment, X, define coloring p Color
the F vertex 2 and the N vertex 3. For
each vertex gadget i1ltiltN, if xi true, let
color(vertex xi) 1 if xi false, let
color(vertex xi) 2 For each clause gadget
j1ltjltC, The vertex Last_output vertex is
colored 1 and the other vertices are colored
consistently -- as a separate exercise, show that
this is possible so long as at least of the input
vertices connected to a terminal is colored
1. Claim The resulting coloring will be a legal
3-coloring
11Showing 2.
(step 6)
If f(f) G ? 3-COLOR , then ?s VG ? 1,2,3
where ?(v,w) ? EG, we have s(v) ? s(w) Note that
any such coloring s must have the following
form The colors of the F vertex, the N
vertex, and any Last_output vertex must be
different. Furthermore, the colors of the
Last_output vertices must all be the same
color. Denote this color as T. Define
assignment x ?i1ltiltN, if color(vertex xi )
T, then xi true if color(vertex xi ) T, then
xi false X will be a satisfying assignment
because for each clause the color(last_output)
T implies that at least one of the inputs must
have been colored T (exercise)
12HW Problem Sipser 7.26 Sipser describes a game
PUZZLE in which K cards are placed in a box in
one of two orientations flipped around a vertical
axis. There are R rows per card with a hole
either on the left side of the card, right side
of the card, both, or neither. PUZZLE is those
sets of cards that have an set of orientations
that completely covers the bottom of the
box. Show that PUZZLE is NP-complete. Proof As
usual, we need to show 1. PUZZLE is in NP 2.
PUZZLE is NP-hard (1) Given the set of cards
c1 ck, a witness that c1 ck is in PUZZLE is a
sequence of choices (y1, y2 yk) where yi up
or down PUZZLE (c1 ck) ? (y1, y2 yk)
s.t. cards (c1 ck) will cover the bottom of the
box when placed according to orientations (y1, y2
yk)
13PUZZLE is NP-hard. We show 3-SAT ltp PUZZLE We
will demonstrate a function f 1. f formulas ?
sets of cards such that 2. f is polynomial-time
computable 3. ? ?, ? ? 3-SAT ? f(?) ?
PUZZLE There is a natural correspondence
between a variable xi being true or false and
card ci being up or down Therefore, our reduction
f will create one card ci for every variable
xi There is also a natural correspondence
between a variable satisfying a clause and a card
covering the left side of a row.
Let C be the number of clauses and N be the
number of variables
14? f, f(f) (c, c1 cN) where
- Each card has C rows
- special card c that has holes in and only in
the left side of each row. (w.l.o.g. we can and
will assume this card is placed first in the box
in the up orientation) - ?i,j, where 1 lt i lt N, 1 lt j lt C, card ci does
not have a hole - 1) on the left side of row j iff literal xi
occurs in clause j. - 2) on the right side of row j iff literal xi
occurs in clause j.
15Showing the reduction f 3-SAT to PUZZLE is
correct
1. ?f, f ?3-SAT ? f(f) (c, c1 cN) ? PUZZLE
2. ?f, f ?3-SAT ? f(f) (c, c1 cN) ? PUZZLE
(reduction does not necessarily preserve the size
of the witness set)
16Showing 1.
Given an assignment, X, define B ?i1ltiltN, if
xi true, let yi up if xi false, let yi
down Note that ?j1ltjltC, if clause j is
satisfied by literal z, then the card
that corresponds to the variable of z will cover
the jth hole onthe left side of c.
17Showing 2.
If f(f) (c, c1 cN) ? PUZZLE, then ? (y, y1,
y2 yN) s.t. cards (c, c1 cN) will cover the
bottom of the box when placed according to
orientations (y, y1, y2 yN) Note that we can
assume that y up because, if y down, we
could reverse the orientation of all the
cards. Define assignment x ?i1ltiltN, if yi
up, then xi true if yi down, then xi
false
18Claim
X, as constructed, will be a satisfying
assignment Proof Let clausej be any of the C
clauses Because the cards cover clause hole j
on the left side of c, there is a card ci such
that ci covers this hole. If ci is in the up
orientation, then xi true and so the literal
xi occurs in clause j and clause j is
satisfied If ci is in the down orientation,
then xi false and so the literal xi occurs
in clause j and clause j is satisfied