NP-Complete: Proof of Correctness More Reductions
NP-Complete: Proof of Correctness More Reductions
v2 v1
v2 v3
v1
v3
v2
v4
v4 v5 v4 v5
3-SAT to ISET, continued
The size of the transformation on the last slide is polynomial in the
number of clauses (m) + number of literals (n)
Adding opposing literals edges in the worst-case (full exploration of
graph for each vertex) is still polynomial in m², so the time of the
transformation is also polynomial
Now we must prove 3SAT “yes” ISET “yes”
3SAT ISET
Set target size for ISET = m
Identify only one “true” literal in each clause of 3SAT, select that vertex
in that “triangle” in ISET. Our set has no edges between nodes in the
same triangle.
Because this is a legal TA for 3SAT, we can’t select a complementary
version of a previously selected literal, so no edges will connect nodes
in different triangles.
Visual demonstration of
3SAT ISET
C = {v1, v2, v3} , {v1, v2, v4} ,
{v2, v4, v5} , {v3, v4, v5}
Select nodes corresponding to literals in
violet. These form an independent set of
size m.
v2 v1
v2 v3
v1
v3
v2
v4
v4 v5 v4 v5
3SAT ISET
So we have an ISET of size m, how does
this give us a valid TA for 3SAT?
At most one node comes from each triangle
There are m triangles, so there must be one
node in every triangle m clauses covered
Because of the opposing literals edges, no
conflicting truth assignments can be in ISET
Assign the literals in the ISET to true; other
literals don’t matter
Hamiltonian Path & H. Cycle
In Lecture 18, a (complex) proof was given that
HAMCYCLE (aka TSP) was NP-Complete
How can we show that HAMPATH is also NP-
Complete?
Take graph G and modify to G'
Show transformation is polynomial
Show that G' has HAMPATH if G has HAMCYCLE
Show that G has HAMCYCLE if G' has HAMPATH
HAMPATH/HAMCYCLE, cont'd
G' V2'
G V2
V
V1 Then create V1' and
V2' adjacent only to V1
Split any vertex V into two and V2, respectively.
V1'
identical vertices V1 and V2
(do not create E(V1,V2)). (The transformation is
trivially polynomial.)
Run HAMPATH on G'
If G had a HAMCYCLE, G' has a path through all the vertices
except V1' and V2' starting at V1 and ending at V2 that
corresponds to the cycle. Add V1' to the start of the path, V2' to
the end, and it's a HAMPATH.
If G' has a HAMPATH, it must start/end at V1'/V2' since they
have degree 1, so G has a HAMCYCLE starting from V
Hitting Set
Problem, given a set T of sets s1, s2 … sn,
is there a set H of at most k elements such
that H contains at least one element from
every s1…sn?
Example: T = {{1,2,3},{a,1},{a,b,c},{}}
k=2, no valid H!
k=3, H = {1,a,} (other choices exist)
How hard is this problem?
Hitting Set Complexity
Easy to show problem is in NP: would take at
most nk time to verify a given solution H
Is this NP-Complete?
Think about other problems you know are NP-
Complete: SAT (and cousins), Independent Set,
HP/HC, Vertex Cover (worksheet), Maximum Clique
(worksheet)
Look for a similar problem: something that involves
selecting one item to represent some collection of
items
Work in groups to find a reduction and argue
that it is correct
Vertex Cover ≤p Hitting Set
Both involve "select some items such that
all items are represent"
Construct: Given a graph G, for each edge
e = (u,v) create a set s = {u,v} and add s to
the universe T.
Now prove G has a vertex cover of size k
T has a hitting set of size k
Select k vertices to represent m edges vs.
select k elements to represent m sets
Vertex Cover Hitting Set
Vertex Cover Hitting Set
Suppose C is a cover of G of size k
By definition then, for every edge (u,v) in G, either
u C or v C
Then H can be set to C, and H must intersect
every set in T.
Vertex Cover Hitting Set
Suppose H is a hitting set of T of size k
Since H intersects every set, it has at least one
endpoint of every edge. Set C to be H.
Set Cover
Problem, given a set T of sets s1, s2 … sn,
is there a set S' of at most k sets such that
S' contains every element in T?
Example: T = {{1,2,3},{a,1},{a,b,c},{}}
k = 2, no legal S'!
k = 3, S' = {{1,2,3},{a,b,c},{}}
This should look very familiar!
Work in groups to find a reduction and
argue that it is correct
Vertex Cover ≤p Set Cover
Given a graph G, construct a universe of
sets T:
For each vertex V, create a set sv with all the
edges incident on V
Our “universe” is now the set of all edges in G
(each is listed twice)
T = {{ab,ac,ae},{ba,bc,bd},
A D {ca,cb},
{db,de,df},{ea,ed,ef},{fd,fe}}
B C E F
Vertex Cover Set Cover
Vertex Cover Set Cover
Suppose C is a cover of G of size k
To find S', select sets sw for every w C.
If there was an edge e=(u,v) in T not in S', then neither su nor
sv was selected, so neither u nor v was in the Vertex Cover, a
contradiction.
Vertex Cover Set Cover
Suppose S' is a set cover of T of size k
To find C, select vertex v for every sv S'
If there is an edge e=(u,v) in G not in C, then neither vertex u
nor v was selected, so neither su nor sv was in S'. Since {uv}
can only be found in su and sv this contradicts that S' is a
cover.