21 Notes PDF
21 Notes PDF
Reductions and NP
• A runs in time polynomial in |IX |. This implies that |IY | (size of IY ) is polynomial in
|IX |
Notation: X ≤P Y if X reduces to Y
Problem X polynomial time reduces to Y if there is an algorithm A for X that has the
following properties:
1
• on any given instance IX of X, A uses polynomial in |IX | “steps”
• Perhaps surprisingly, Karp reductions, although limited, suffice for most known NP-
Completeness proofs
2
• A formula ϕ is in 3CNF if it is a CNF formula such that every clause has exactly 3
literals
– (x1 ∨x2 ∨¬x4 )∧(x2 ∨¬x3 ∨x1 ) is a 3CNF formula, but (x1 ∨x2 ∨¬x4 )∧(x2 ∨¬x3 )∧x5
is not.
21.1.1.2 Satisfiability
SAT
Given a CNF formula ϕ, is there a truth assignment to variables such that ϕ evaluates to
true?
3-SAT
Given a 3CNF formula ϕ, is there a truth assignment to variables such that ϕ evaluates to
true?
3
21.1.2.2 SAT ≤P 3-SAT
Reduction Ideas
Challenge: Some of the clauses in ϕ may have less or more than 3 literals. For each clause
with < 3 or > 3 literals, we will construct a set of logically equivalent clauses.
• Case clause with 1 literal: Let c = `. Let u, v be new variables. Consider
c0 = (` ∨ u ∨ v) ∧ (` ∨ u ∨ ¬v) ∧ (` ∨ ¬u ∨ v) ∧ (` ∨ ¬u ∨ ¬v)
Observe that c0 is satisfiable iff c is satisfiable
21.1.2.5 An Example
Example 21.1.4 ϕ = (¬x1 ∨ ¬x4 ) ∧ (x1 ∨ ¬x2 ∨ ¬x3 ) ∧ (¬x2 ∨ ¬x3 ∨ x4 ∨ x1 ) ∧ (x1 ).
ψ = (¬x1 ∨ ¬x4 ∨ z) ∧ (¬x1 ∨ ¬x4 ∨ ¬z)
∧ (x1 ∨ ¬x2 ∨ ¬x3 )
∧ (¬x2 ∨ ¬x3 ∨ y1 ) ∧ (x4 ∨ x1 ∨ ¬y1 )
∧ (x1 ∨ u ∨ v) ∧ (x1 ∨ u ∨ ¬v) ∧ (x1 ∨ ¬u ∨ v) ∧ (x1 ∨ ¬u ∨ ¬v)
4
21.1.2.6 Overall Reduction Algorithm
Correctness (informal)
ϕ is satisfiable iff ψ is satisfiable because for each clause c, the new 3CNF formula c0 is
logically equivalent to c.
Goal Construct a graph Gϕ and number k such that Gϕ has an independent set of size k
iff ϕ is satisfiable. Gϕ should be constructible in time polynomial in size of ϕ
• Find a way to assign 0/1 (false/true) to the variables such that the formula evaluates
to true, that is each clause evaluates to true
• Pick a literal from each clause and find a truth assignment to make all of them true.
You will fail if two of the literals you pick are in conflict, i.e., you pick xi and ¬xi
5
¬x1 ¬x2 ¬x1
x2 x3 x1 x3 x2 x4
21.1.3.4 Correctness
Proposition 21.1.5 ϕ is satisfiable iff Gϕ has an independent set of size k (= number of
clauses in ϕ).
Proof :
⇒ Let a be the truth assignment satisfying ϕ
– Pick one of the vertices, corresponding to true literals under a, from each triangle.
This is an independent set of the appropriate size
Proof :
⇐ Let S be an independent set of size k
– S must contain exactly one vertex from each clause
– S cannot contain vertices labeled by conflicting clauses
– Thus, it is possible to obtain a truth assignment that makes in the literals in S
true; such an assignment satisfies one literal in every clause
6
21.1.3.6 Transitivity of Reductions
X ≤P Y and Y ≤P Z implies that X ≤P Z.
Note: X ≤P Y does not imply that Y ≤P X and hence it is very important to know the
FROM and TO in a reduction.
21.2 Definition of NP
21.2.0.7 Recap . . .
Problems
• Independent Set
• Vertex Cover
• Set Cover
• SAT
• 3-SAT
Relationship
≤P
3-SAT ≤P Independent Set ≥P Vertex Cover ≤P Set Cover
3-SAT ≤P SAT ≤P 3-SAT
21.3 Preliminaries
21.3.1 Problems and Algorithms
21.3.1.1 Problems and Algorithms: Formal Approach
Decision Problems
• Problem Instance: Binary string s, with size |s|
• Problem: A set X of strings on which the answer should be “yes”; we call these YES
instances of X. Strings not in X are NO instances of X.
7
21.3.1.2 Polynomial Time
Definition 21.3.2 Polynomial time (denoted P ) is the class of all (decision) problems that
have an algorithm that solves it in polynomial time
• most known polynomial time algorithms for “natural” problems have small polynomial
running times
Problems
• Independent Set
• Vertex Cover
• Set Cover
• SAT
• 3-SAT
There are of course undecidable problems (no algorithm at all!) but many problems that
we want to solve are like above.
Question: What is common to above problems?
8
21.3.1.5 Efficient Checkability
21.3.2 Certifiers/Verifiers
21.3.2.1 Certifiers
Definition 21.3.4 An algorithm C(·, ·) is a certifier for problem X if for every s ∈ X there
is some string t such that C(s, t) =”yes”, and conversely, if for some s and t, C(s, t) =”yes”
then s ∈ X.
The string t is called a certificate or proof for s
Efficient Certifier
C is an efficient certifier for problem X if there is a polynomial p(·) such that for every string
s, s ∈ X iff there is a string t with |t| ≤ p(|s|), C(s, t) = ”yes” and C runs in polynomial
time
– Certificate: Set S ⊆ V
– Certifier: Check |S| ≥ k and no pair of vertices in S is connected by an edge
21.3.3 Examples
21.3.3.1 Example: Vertex Cover
– Certificate: S ⊆ V
– Certifier: Check |S| ≤ k and that for every edge at least one endpoint is in S
9
21.3.3.2 Example: SAT
• Problem: Does formula ϕ have a satisfying truth assignment?
21.3.3.3 Example:Composites
• Problem: Is number s a composite?
21.4 NP
21.4.1 Definition
21.4.1.1 Nondeterministic Polynomial Time
Definition 21.4.1 Nondeterministic Polynomial Time (denoted by N P ) is the class of all
problems that have efficient certifiers
Example 21.4.2 ¡2-¿ Independent Set, Vertex Cover, Set Cover, SAT, 3-SAT, Composites
are all examples of problems in N P
21.4.2 Intractibility
21.4.2.1 P versus N P
Proposition 21.4.3 P ⊆ N P
For a problem in P no need for a certificate!
10
• Certifier C on input s, t, runs A(s) and returns the answer
Proof : Let X ∈ N P with certifier C. Need to design an exponential time algorithm for X
• For every t, with |t| ≤ p(|s|) run C(s, t); answer “yes” if any one of these calls returns
“yes”
21.4.2.4 Examples
• SAT: try all possible truth assignment to variables
11