CS341 Lec16 Annotated Mar26
CS341 Lec16 Annotated Mar26
Winter 2024
[CLRS]
[CLRS]
Example 1: 3-SAT
S here is a 3-SAT formula
t here is a truth assignment
Algv (S, t): check whether t satisfies all clauses.
Example 1: 3-SAT
S here is a 3-SAT formula
t here is a truth assignment
Algv (S, t): check whether t satisfies all clauses.
P⊆ NP.
P⊆ NP.
3 The most important open problem in theoretical computer
science: is P equal to NP?
P⊆ NP.
3 The most important open problem in theoretical computer
science: is P equal to NP?
4 The name NP comes from Non-deterministic Polynomial time.
A non-deterministic machine, roughly speaking, has the power to
correctly guess a solution.
A. Jamshidpey Y. Lu (CS, UW) Lec 16: NP-completeness Winter 2024 4 / 11
NP-completeness
informally we say a problem is NP-complete if it is the hardest
problem in NP.
Consequences:
If we can prove 3-SAT ≤P X, then X is NP-complete. For
example IS ∈ NPC, since 3-SAT≤P IS.
Consequences:
If we can prove 3-SAT ≤P X, then X is NP-complete. For
example IS ∈ NPC, since 3-SAT≤P IS.
To prove that a problem X ∈ NP is NP-complete, we just
need to find a NP-complete problem Y , and prove that
Y ≤P X.
A. Jamshidpey Y. Lu (CS, UW) Lec 16: NP-completeness Winter 2024 5 / 11
Circuit satisfiability
Circuit-SAT
instance: a circuit = DAG with labels on the vertices
inputs labelled by boolean variables x1 , . . . , xn .
internal vertices labelled by and, or, not
there is a marked vertex v for the output
problem: is there a choice of boolean xi that makes v true?
Example
problem A: IS
instance S: complete graph with 3 vertices, k = 2
certificate t: 3 bits y1 , y2 , y3 (yes/no for each vertex)
circuit for ALGA (S, t) computes the “formula”
(y1 + y2 + y3 ≥ 2) ∧ y1 ∧ y2 ∧ y1 ∧ y3 ∧ y2 ∧ y3
gives
y1 ⇐⇒ (x1 ∧x2 ) ∧ y2 ⇐⇒ (x2 ∨x3 ) ∧ v ⇐⇒ (y1 ∧y2 ) ∧ v
and
gives
y1 ⇐⇒ (x1 ∧x2 ) ∧ y2 ⇐⇒ (x2 ∨x3 ) ∧ v ⇐⇒ (y1 ∧y2 ) ∧ v
and
3SAT, SAT
independent set, vertex cover, clique
(directed) Hamiltonian cycle, Hamiltonian path
traveling salesman
subset sum
0/1 knapsack