Lecture 29 30
Lecture 29 30
Lecture 29-30
Sarmad Abbasi
Virtual University
This means
1 SAT is in NP.
2 Every language (problem) in NP is polynomial time reducible to
SAT.
One way to view this theorem is by the following picture:
This means
1 SAT is in NP.
2 Every language (problem) in NP is polynomial time reducible to
SAT.
One way to view this theorem is by the following picture:
Question
Is SAT the only NP-complete problem?
Let us for the sake of argument assume that there is another language
let us call it L that is also NP-complete. What properties it will have:
1 It has to be in NP. Suppose we can establish this by giving a
verification algorithm.
2 All languages L0 ∈ NP will be polynomial time reducible to L.
In particular since SAT ∈ NP hence we must also have
SAT ≤p L.
SAT ≤p L.
SAT ≤p L. (1)
L0 ≤p L
thereby showing that L is NP-complete.
Theorem
If A ≤p B and B ≤p C then
A ≤p C
that is ≤p is a transitive relation.
The proof of this fact is so simple that we can revise it in a few minutes.
How much time does it take to compute h. Let |x| = n. Then it takes
O(nk )
K ≤p W
x1 ∨ x5 ∨ x7 .
x1 ∨ x4 ∨ x6 ∨ x8 .
x3 ∨ x5 ∨ x11 .
A formula in conjunctive normal form (CNF) is just an and of clauses.
So it looks like this:
We will say that a formula is in 3CNF if all the clauses have exactly
three literals.
Let us illustrate the proof of this theorem by an example. I will leave the
details to you. Let us say we have a boolean formula φ given by
Now, we can introduce a variable for each wire of the circuit. So, we
first label each wire with y 0 s. As shown in the figure.
y5 ∨ y1 ∨ y2
This says that either y5 is false. Or if it is true then one of the y1 or y2
should be true. Note that this is a clause with three literals.
Similarly, suppose we have a and gate with y7 and two wires y3 and y4
feeding into it. We can write
(y7 ∨ y3 ) ∧ (y7 ∨ y4 )
So for each wire we can write a formula which is the and over all the
wires. Finally we add the clause yn where yn is the output wire.
y5 ∧ (y5 ∨ y1 ∨ y2 ) ∧ · · ·
To satisfy this formula the output wire must be set to true. To satisfy
the formula for the output wire the two wires feeding it must be set to
true and so on....Thus to make ψ true we must make an assignment of
the x variables that makes φ true and so on...
It is your homework to show that you can now convert ψ into a formula
in which each clause has exactly three literals.
It is easy to see that this transformation can be done in polynomial
time.
Theorem
3SAT is NP-complete.
Definition
Let G = (V , E) be a graph. I ⊆ V is called an independent set if the
vertices in I have no edges between them. Thus for all x, y ∈ I where
x 6= y
{x, y } 6∈ E.
Theorem
SAT ≤p IS
Consequently IS is also NP-complete.
Theorem
φ is satisfiable if and only if Gφ contains an independent set of size m.
Where m is the number of clauses in φ.
SAT ≤p 3SAT ≤ IS
Is it true that
IS ≤p SAT ?