EECS 336: Introduction to Algorithms Lecture 15 P vs. NP (cont.)

advertisement
EECS 336: Introduction to Algorithms
P vs. NP (cont.)
Lecture 15
NP, 3-SAT, Hamiltonian Cycle
• c(·) = costs on edges.
Reading: 8.4-8.5
output: cycle C that
Last time:
• passes through all vertices exactly
once.
P
• minimizes total cost e∈C c(e).
• tractability and intractability
• decision problems
Today:
• N P-completeness
Problem 4: 3-SAT
• “notorious problem” NP.
input: boolean formula f (z)
• redutions from 3-SAT.
• in conjunctive normal form (CNF)
• three literals per or-clause
• or-clauses anded together.
Problem 1: Independent Set (INDEPoutput:
SET)
input: G = (V, E)
• “Yes” if assignment z with f (z) =
T exists
output: S ⊂ V
• “No” otherwise.
• satisfying ∀v ∈ S, (u, v) 6∈ E
Problem 5: Hamiltonian Cycle (HC)
• maximizing |S|
input: G = (V, E) (directed)
Problem 2: SAT
output: cycle C to visit each vertex exactly
once.
Problem 3: Traveling Salesman (TSP)
input:
Note: since Xd =P X, we write “X” but we
mean “Xd ”
• G = (V, E), complete graph.
1
A notoriously hard problem
• decision problem verifier program
V P.
• polynomial p(·).
“one problem to solve them all”
• decision problem instance: x
Note: all example problem have short
certificates that could easily verify “yes” in- output:
stance.
•
Def: N P is the class of problems that have
short (polynomial sized) certificates that can
easily (in polynomial time) verify “yes” in•
stances.
“Yes” if exists certificate c such that
V P (x, c) has “verified = true” at
computational step p(|x|).
“No” otherwise.
Historical Note: N P = non-deterministic Fact: NP is N P-complete.
polynomial time
Note: Unknown whether P = N P.
“a nondeterministic algorithm could guess
the certificate and then verify it in polyno- Note: ≤P is transitive: if Y ≤P X and
X ≤P Z then Y ≤P Z.
mial time”
Note: Not all problems are in N P.
Plan:
E.g., unsatisfiability.
1. NP ≤P · · · ≤P 3-SAT
Def:
2. 3-SAT ≤P INDEP-SET
• Problem X is in N P if exists short
easily-verifiable certificate.
• Problem X is N P-hard if ∀Y
N P, Y ≤P X.
3. 3-SAT ≤P HC ≤P TSP
∈
• Problem X is N P-complete if X ∈ N P
and X is N P-hard.
Lemma: INDEP-SET ∈ N P.
Lemma: SAT ∈ N P.
Lemma: TSP ∈ N P.
Goal: show INDEP-SET, SAT, TSP are
N P-complete.
Notorious Problem: NP
input:
2
Problem: Hamiltonian Cycle
TSP
input: G = (V, E) (directed)
Lemma 0.1 TSP is N P-hard.
output: cycle C to visit each vertex exactly Proof: reduction from Hamiltonian Cycle
once.
• encode edges with cost 1
Lemma: hamiltonian cycle is N P-hard
• encode non-edges with cost n.
Proof: (reduction from 3-SAT)
⇒ exists HC iff TSP cost ≤ n
Step 1: construction
• turn 3-SAT formula f in to graph G with
hamiltonian cycle iff f is satisfiable.
• idea: variable = isolated path, right-toleft = true, left-to-right = false.
• idea: clause is node, which needs to be
hit by at most one literal being true.
• construction:
• left-right path per variable.
• splice in clause nodes.
Step 2: runtime.
Step 3: correctness.
3
Download