0% found this document useful (0 votes)
43 views

Chap 9 NP Complete

This document introduces the concepts of P, NP, and NP-completeness. It discusses: - P is the set of problems solvable in polynomial time by a deterministic Turing machine. - NP is the set of problems solvable in polynomial time by a non-deterministic Turing machine. - NP-complete problems are problems in NP that are the hardest to solve, such that any problem in NP can be reduced to an NP-complete problem in polynomial time. - The document then discusses Cook's theorem, which proved that SATISFIABILITY is the first NP-complete problem by showing it can be reduced to any other problem in NP in polynomial time. This established the concept of

Uploaded by

Rubinder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Chap 9 NP Complete

This document introduces the concepts of P, NP, and NP-completeness. It discusses: - P is the set of problems solvable in polynomial time by a deterministic Turing machine. - NP is the set of problems solvable in polynomial time by a non-deterministic Turing machine. - NP-complete problems are problems in NP that are the hardest to solve, such that any problem in NP can be reduced to an NP-complete problem in polynomial time. - The document then discusses Cook's theorem, which proved that SATISFIABILITY is the first NP-complete problem by showing it can be reduced to any other problem in NP in polynomial time. This established the concept of

Uploaded by

Rubinder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction to the Theory NP-Completeness

(Reference book: Computers and Intractability: A Guide to the Theory of NP-


Completeness by Michael Gary and David Johnson)

P: The set of problems that can be solved in


polynomial time in a deterministic Turing machine
Introduction to the Theory NP-Completeness
(Reference book: Computers and Intractability: A Guide to the Theory of NP-
Completeness by Michael Gary and David Johnson

P: The set of problems that can be solved in


polynomial time in a deterministic Turing machine

Finite
state
control

Tape Read-write head

... ...
-3 -2 -1 0 1 2 3 4
Introduction to the Theory NP-Completeness
(Reference book: Computers and Intractability: A Guide to the Theory of NP-
Completeness by Michael Gary and David Johnson

P: The set of problems that can be solved in polynomial


time in a deterministic Turing machine

NP: The set of problems that can be solved in polynomial


time in a non-deterministic Turing machine
Finite
Guessing
State
module
control

Guessing Read-write
Tape head head

... ...
-3 -2 -1 0 1 2 3 4
Introduction to the Theory NP-Completeness
(Reference book: Computers and Intractability: A Guide to the Theory of NP-
Completeness by Michael Gary and David Johnson

P: The set of problems that can be solved in polynomial


time in a deterministic Turing machine

NP: The set of problems that can be solved in polynomial


time in a non-deterministic Turing machine

NP-Complete: A problem X is NP-Complete if it is a


member of the set NP and every problem in NP can
be transformed to X in polynomial time

Second Definition: If a problem X is NP-Complete and X


can be transformed in polynomial time to another
problem Y, then Y is also an NP-Complete problem.
NP-Completeness
Non-deterministic Turing machine: A NDTM has a
guessing module and a checking module. The guessing
module comes up with a solution and the checking module
verifies if the guessed solution is correct.

Polynomial Time Nondeterministic Algorithm is basically a


definitional device for capturing the notion of polynomial
time verifiability, rather than a realistic method for solving
decision problems.
NP-Completeness

Let U = {u1, u2, , um} be a set of Boolean


variables. A truth assignment for U is a function
t: U {T, F}. If t(u) = T we say that u is true
under t; if t(u) = F we say that u is false. If u
is a variable in U, then u and are literals over
U. The literal u is true under t if and only if the
variable u is true under t; the literal is true, if
and only if the variable u is false under t.
NP-Completeness
A clause c is a set of literals over U. It represents the
disjunction of those literals and is satisfied by a truth
assignment if and only if at least one member is true under
that assignment.

For example, c1 {u1 , u 3 , u8 } . This will be satisfied by t,


unless t (u1 ) F , t (u3 ) T and t (u8 ) F

A collection C of clauses over U is satisfied if and only if there


exists some truth assignment for U, that simultaneously
satisfies all clauses in C.
NP-Completeness
SATISFIABILITY Problem
Instance: A set U of variables and a collection C of clauses
over U.
Question: Is there a satisfying truth assignment?

SATISFIABILITY is NP-Complete (Cooks Theorem)

SATISFIABILITY is the first NP-Complete problem

How do you prove the first NP-Complete problem?


Basic NP-Complete Problems

3 - SATISFIABILITY (3SAT)
INSTANCE: Collection C={c1, c2 , , cm} of clauses on a finite set U of
variables such that | ci |=3 for 1 i m
QUESTION: Is there a truth assignment for U that satisfies all the clauses
in C?
3 DIMENSIONAL MATCHING (3DM)
INSTANCE: A set M W X Y , where W, X and Y are disjoint sets
having the same number q of elements.
QUESTION: Does M contain a matching, that is a subset M ' M such
that |M| = q and no two elements of M agree in any
coordinate?
VERTEX COVER (VC)
INSTANCE: A graph G=(V,E) and a positive integer K V
QUESTION: Is there a vertex cover of size K or less for G, that is, a subset
V ' V such that V ' k and, for each edge {u, v} E , at
least one of u and v belongs to V ?
CLIQUE
INSTANCE: A graph G = (V, E) and a positive integer J V
QUESTION: Does G contain a clique of size J or more, that is, a subset
V ' V such that V ' J and every two vertices in V are joined
by an edge in E?

HAMILTONIAN CIRCUIT (HC)


INSTANCE: A graph G = (V, E)
QUESTION: Does G contain a Hamiltonian circuit, that is, an ordering
v1 , v2 ,..., vn of the vertices of G, where n V , such that
{vn , v1} E and {vi , vi 1} E for all i, 1 i n ?

PARTITION
INSTANCE: A finite set A and a size s(a) Z for each a A
QUESTION: Is there a subset A ' A such that s (a) s(a)?
a A' a A A'
SATISFIABILITY

3SAT

3DM VC

PARTITION HC CLIQUE

Sequence of transformations used to prove NP-Completeness


3-SAT is NP-Complete

Proof by transformation from the SATISFIABILITY Problem

Two steps are involved


Step 1: From an instance of the SAT problem ISAT generate an
instance of the 3-SAT problem I3-SAT

Step2: Prove that ISAT YSAT if and only if I3-SAT Y3-SAT

Generation of an instance of 3-SAT from an instance of SAT


An instance of SAT is specified by
A set of variables U {u1 ,..., un }
A set of clauses
C {c1 ,..., cm }
U {u1 ,..., un }
ISAT:
C {c1 ,..., cm }

We will construct a collection C of three literal clauses


on a set U of variables such that C is satisfiable if and
only if C is satisfiable
The construction of C will merely replace each individual
clause cj C by an equivalent collection Cj of three
literal clauses, based on the original variables U and
some additional variables Uj whose use will be limited to
clauses on Cj . The variables and the clauses in I3-SAT will
be m
U' U U 'j
j 1
m
'
C C 'j
j 1
Let cj be given by {z1, z2, ,zk} where zis are all literals
derived from the variables in U. The way in which Cj and Uj
are formed depends on the value of k

U 'j { y1j , y 2j }
k=1
' 1 2 1 2 1 2 1 2
C j {{z1 , y , y },{z1 , y , y j },{z1 , y j , y },{z1 , y j , y j }}
j j j j

k=2 U ' 1
{y } C ' 1 1
{{z1 , z2 , y },{z1 , z2 , y j }}
j j j j

k=3 U 'j C 'j {{c j }}

U 'j { y ij :1 i k 3}
k>3 ' 1 i i 1 k 3
C j {{z1 , z2 , y }} {{ y j , zi 2 , y }:1 i
j j k 4} {{ y j , zk 1 , zk }}
We need to show that
ISAT YSAT I3-SAT Y3-SAT

Step 1: ISAT YSAT I3-SAT Y3-SAT


Step 2: ISAT YSAT I3-SAT Y3-SAT
If t is a satisfying truth assignment of the set of clauses C,
we need to show how t can be extended to t: U {T, F}
satisfying C.

Since the variables in U- U are partitioned into sets Uj and


since the variables in each Uj occur only in clauses
belonging to Cj , we need only to show how t can be
extended to the sets Uj one at a time, and in each case we
need only to verify that all the clauses in the corresponding
Cj , are satisfied
When k = 1, 2 or 3, then the clauses in Cj are already
satisfied by t and we can arbitrarily extend t to Uj

When k > 3, we do the following:


Since C is a satisfying truth assignment, there must
be at least one literal that is set true by t
l = least integer such that the literal zl is set true under t

l 1 or 2 t ' ( y ij ) F, 1 i k 3
l k 1 or k t ' ( y ij ) T , 1 i k 3
otherwise t ' ( y ij ) T , 1 i l 2
and t ' ( y ij ) F, l 1 i k 3
Vertex Cover (VC) Problem is NP-Complete

Proof by transformation from the 3-SAT Problem

Two steps are involved


Step 1: From an instance of the 3-SAT problem I3-SAT generate an
instance of the VC problem IVC

Step2: Prove that I3-SAT Y3-SAT if and only if IVC YVC

Generation of an instance of VC from an instance of 3-SAT


An instance of 3-SAT is specified by
A set of variables
U {u1 ,..., un }
A set of clauses, each with three literals C {c1 ,..., cm }
3-SAT U {u1 ,..., un }
C {c1 ,..., cm }
VC G (V , E ), k
ui U i (Vi , Ei )
Vi {ui , u i }, Ei {{ui , u i }} Truth Setting Component

cj C Sj (V j' , E 'j )
Satisfaction Testing Component
'
V j {a1[ j ], a2 [ j ], a3[ j ]}
E 'j {{a1[ j ], a2 [ j ]},{a2 [ j ], a3[ j ]},{a3[ j ], a1[ j ]}}

E ''j {{a1[ j ], x j },{a2 [ j ], y j },{a3[ j ], z j }}


cj (x , y , z ) Communication Edges
j j j

G (V , E )
Set k = n + 2m
n m n m m
' '
V ( Vi ) ( V) E
j ( Ei ) ( E )
j ( E ''j )
i 1 j 1 i 1 j 1 j 1
Example: Generation of a instance of VC from an instance of 3-SAT

I3-SAT: U= {u1, u2, u3, u4}, C = {{u1, 3, 4}, {1, u2, 4}}

u1 u1 u2 u2 u3 u3 u4 u4

a2[1] a2[2]

a1[1] a3[1] a1[2] a3[2]

You might also like