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

Cclasses Reductions

Uploaded by

t24156
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)
8 views

Cclasses Reductions

Uploaded by

t24156
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/ 25

NP-Completeness and Reductions

SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

An instance of SAT is a boolean formula ϕ composed of


1. n boolean variables (x1 , x2 . . . xn )
2. m boolean connectives (∧, ∨, ¬, →, ↔)
3. parentheses

A boolean formula ϕ in a length that is polynomial in n + m.


The satisfiability problem asks whether a given boolean formula is
satisfiable; in formal-language terms,

SAT = {< ϕ >: ϕ is a satisfiable boolean formula}


NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

This problem has the historical honor of being the first problem ever
shown to be NP-complete. In other words,
Theorem
SAT ∈ P ⇐⇒ P = NP
The proof is beyond the scope of this course and for now, we shall
assume this claim to be true.
Not all formulas can be satisfied. For example

(x1 ∨ x2 ) ∧ (x1 ∨ ¬x2 ) ∧ (¬x1 ∨ x2 ) ∧ (¬x1 ∨ ¬x2 )


has no satisfying assignment for variables x1 and x2 , because no
matter what values x1 and x2 are given, exactly three clauses will
evaluate to true and one clause will evaluate to false.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

In 3-CNF-SAT, we are asked whether a given boolean formula ϕ in


3-CNF is satisfiable.

3-CNF-SAT seem to be relatively easier than the general SAT


problem, as the general problem can have clauses with more than 3
variables as well.

However, there is a polynomial time reduction which can convert


any SAT formula into a 3-CNF form. So if there existed a
polynomial time algorithm for 3-CNF -SAT , one would also
automatically get a polynomial time algorithm for SAT .
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

▶ We have already seen that 3-CNF-SAT is in NP, as one can


verify a certificate in polynomial time.

▶ If we can find a way to transform any instance of SAT to an


instance of 3-CNF-SAT which preserves membership relations
in their respective sets, then we can say that 3-CNF-SAT is
also NP-Complete.
For that, we need to devise a gadget/strategy.
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

Step-1, we construct a binary “parse” tree for the input formula ϕ,


with literals as leaves and connectives as internal nodes.

If the input formula contain a clause such as the OR of several


literals, we use associativity to parenthesize the expression fully so
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

We introduce a variable yi for the output of each internal node.


Then, we rewrite the original formula ϕ as the AND of the root
variable and a conjunction of clauses describing the operation of
each node.

Observe that the formula ϕ′ thus obtained is a conjunction of


clauses ϕ′i , each of which has at most 3 literals. The only
requirement that we might fail to meet is that each clause has to be
an OR of 3 literals.
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

Step-2, Converts each clause ϕ′i into conjunctive normal form.


1. construct a truth table for ϕ′i by evaluating all possible
assignments to its variables.
2. Using the truth-table entries that evaluate to 0, we build a
formula in disjunctive normal form (or DNF)—an OR of
ANDs—that is equivalent to ¬ϕ′i
3. Negate this formula using De-Morgan’s law to complement all
literals, change ORs into ANDs, and change ANDs into ORs
¬(a ∨ b) = ¬a ∧ ¬b
¬(a ∧ b) = ¬a ∨ ¬b
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

For example, we convert the clause ϕ′1 = (y1 ↔ (y2 ∨ ¬x2 )) into
CNF as follows. The truth table for ϕ′1 is shown.

The DNF formula equivalent to ¬ϕ′1 is


NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

At this point, we have a reformulation of the original problem as a


CNF which has at most 3 literals.
In Step-3, we now want each clause to have exactly 3 distinct
literals.
1. If a clause has 3 literals, do not change anything.
2. If a clause Ci has 2 literals, say Ci = (v1 ∨ v2 ), then replace
this clause with (v1 ∨ v2 ∨ p) ∧ (v1 ∨ v2 ∨ ¬p)
3. If a clause Ci has 1 literal, say Ci = (v1 ), then replace this
clause with
(v1 ∨ p ∨ q) ∧ (v1 ∨ ¬p ∨ q) ∧ (v1 ∨ p ∨ ¬q) ∧ (v1 ∨ ¬p ∨ ¬q)
These modifications are such that the newly obtained formula is
satisfiable if and only if the original formula is satisfiable.
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

We must also show that the reduction can be computed in


polynomial time.
1. Step-1 introduces at most 1 variable and 1 clause per
connective in ϕ.
2. Step-2 can introduce at most 8 clauses per clause into the
formula, since each clause has at most 3 variables, and the
truth table for each clause has at most 8 rows.
3. Step-3 introduces at most 4 clauses per clause. Thus, the size
of the resulting formula after step-3 is polynomial in the length
of the original formula. Each of the constructions can easily be
accomplished in polynomial time.
Thus, 3-CNF-SAT is also an NP-Complete problem.
NP-Completeness and Reductions
arbitrary length clause → 3 literal clause
SAT to 3-CNF-SAT
→ Conjuctive Normal Form
3SAT’s and Cliques
Adding Dummy variables
CLIQUE to Vertex Cover
Example of Polynomial Time Reduction

Let 3SAT = {< ϕ > |ϕ is a satisfiable 3CNF-formula }. If an


assignment satisfies a cnf-formula, each clause must contain at least
one literal that evaluates to 1.
Theorem
3SAT is polynomial time reducible to CLIQUE.

Proof Idea The polynomial time reduction f that we will try to


demonstrate from 3SAT to CLIQUE converts formulas to graphs.

In the constructed graphs, cliques of a specified size correspond to


satisfying assignments of the formula.
Structures within the graph are designed to mimic the behavior of
the variables and clauses.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

Let ϕ be a formula with k clauses such as

ϕ = (a1 ∨ b1 ∨ c1 ) ∧ (a2 ∨ b2 ∨ c2 ) ∧ . . . ∧ (ak ∨ bk ∨ ck )

The reduction f generates the string < G , k >, where G is an


undirected graph defined as follows.

The nodes in G are organized into k groups of three nodes each


called the triples, t1 , . . . , tk . Each triple corresponds to one of the
clauses in ϕ, and each node in a triple corresponds to a literal in the
associated clause. Label each node of G with its corresponding
literal in ϕ.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

In some textbooks, the plus sign denotes Logical OR ∨ and the dot
sign sign denotes Logical AND ∧
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

The edges of G connect all but two types of pairs of nodes in G .


No edge is present between nodes in the same triple, and no edge is
present between two nodes with opposite labels (such as x2 & ¬x2 ).
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

We show that ϕ is satisfiable if and only if G has a k-clique.

If ϕ has a satisfying assignment.


=⇒ In that satisfying assignment, at least one literal is true in
every clause.
=⇒ In each triple of G, we select one node corresponding to a true
literal in the satisfying assignment.
If more than one literal is true in a particular clause, we choose one
of the true literals arbitrarily.
=⇒ The nodes just selected form a k-clique.

Nodes cannot be from the same triple because we selected only one
node per triple.
Nodes cannot have contradictory labels because the associated
literals were both true in the satisfying assignment.
=⇒ G contains a k-clique.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

Suppose that G has a k-clique.


=⇒ No two of the clique’s nodes occur in the same triple because
nodes in the same triple aren’t connected by edges.
=⇒ Each of the k triples contains exactly one of the k clique
nodes. We assign truth values to the variables of ϕ so that each
literal labeling a clique node is made true.

Doing so is always possible because two nodes labeled in a


contradictory way are not connected by an edge and hence both
can’t be in the clique.
This assignment to the variables satisfies ϕ because each triple
contains a clique node and hence each clause contains a literal that
is assigned TRUE.
=⇒ ϕ is satisfiable.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

A vertex cover of an undirected graph G (V , E ) is a subset V ′ ⊆ V


such that if (u, v ) ∈ E , then u ∈ V ′ or v ∈ V ′ (or both). That is,
each vertex “covers” its incident edges, and a vertex cover for G is
a set of vertices that covers all the edges in E .
The size of a vertex cover is the number of vertices in it.
As a language, we define

VERTEX −COVER = {< G , k >: graph G has a vertex cover of size k}

This problem is also NP-Complete.


NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

VERTEX − COVER is in NP. A certificate would be set of vertices


and in polynomial time, we can check if at least one of the vertices
of any edge are in the certificate set of vertices or not.

We prove that the vertex-cover problem is NP-hard. For that we use


CLIQUE problem.

G consists of same vertices in G and all and only those edges which
are absent from G .

The output of the reduction algorithm is the instance


< G , |V | − k > of the vertex-cover problem for an instance
< G , k > for the clique problem.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

We need to show, that the graph G has a clique of size k ⇐⇒ the


graph G has a vertex cover of size |V | − k.
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

→ Suppose that G has a clique V ′ ⊆ V with V ′ = k. We claim


that V − V ′ is a vertex cover in G . Let (u, v ) be any edge in E .

Then, (u, v ) ∈
/ E , which implies that at least one of u or v does not
belong to V , since every pair of vertices in V is connected by an
edge of E .

Equivalently, at least one of u or v is in V − V ′ , which means that


edge (u, v ) is covered by V − V ′ . Since (u, v ) was chosen
arbitrarily from E , every edge of E is covered by a vertex in V − V ′ .

Hence, the set V − V ′ , which has size |V | − k, forms a vertex cover


for G .
NP-Completeness and Reductions
SAT to 3-CNF-SAT
3SAT’s and Cliques
CLIQUE to Vertex Cover

→ Suppose that G has a vertex cover V ′ ⊆ V , where


|V ′ | = |V | − k.

Then, for all (u, v ) ∈ V , if (u, v ) ∈ E , then u ∈ V ′ or v ∈ V ′ or


both.

The contrapositive of this implication is that for all u, v ∈ V , if


u∈ / V ′ and v ∈
/ V ′ , then (u, v ) ∈ E . In other words, V − V ′ is a
clique, and it has size |V | − |V ′ | = k.

You might also like