NPcompleteness Cook Theorem and NPcomplete problems NPcomplete problems
NP-completeness Cook Theorem and NP-complete problems
NP-complete problems Definition 10. 1. • A decision problem Π NP is called NP-complete if all other problems in NP polynomially transforms to Π.
Boolean variables Definition 10. 2. • Assume X = {x 1, …, xk} is a set of Boolean variables. A truth assignment for X is a function T: X → {true, false}. • We extend T to the set by setting if T(x) : = false and vice versa (x can be regarded as the negation of x). The elements of L are called the literals over X.
Literals • A clause over X is a set of literals over X. • A clause represents the disjunction of those literals and is satisfied by a truth assignment iff at least one of its members is true. • A family Z of clauses over X is satisfiable iff there is some truth assignment simultaneously satisfying all of its clauses.
Satisfiability • Instance: A set X of variables and a family Z of clauses over X. • Question: Is Z satisfiable?
Cook Theorem (Cook 1971) Theorem 10. 1 Satisfiability is NP-complete.
Proof • Satisfiability belongs to NP because a satisfying truth assignment serves as a certificate for any yes-instance, which of course can be checked in polynomial time.
Proof • Let now Π = (X, Y) be any other problem in NP. We have to show that P polynomially transforms to Satisfiability. • By definition there is a polynomial p and a decision problem • Π'=(X', Y') in P, where • X' = {x#c: x X, c {0, 1}└ p(size(x))┘} and • Y = {y X : c {0, 1}└ p(size(x))┘ : y#c Y'}. • Let Φ: {0, …, N}× A {⊔}→{-1, …, N}×A {⊔}×{-1, 0, 1} be a polynomial-time Turing machine for Π’ with alphabet A. • Let q be a polynomial such that time (Φ, x#c) ≤ q(size(x#c)) for all instances x#c X'. • size(x#c) = size(x) + 1 + └p(size(x))┘
Main idea • We will now construct a collection Z(x) of clauses over some set V(x) of Boolean variables for each x ∈ X, such that Z(x) is satisfiable if and only if x∈Y.
Variables • Q: =q(size(x) + 1 + └p(size(x))┘) • Q is an upper bound on the length of any computation of on input x#c, for any c ∈ {0, 1}p(size(x)). • V(x) contains the following Boolean variables: – vijσ , 0 ≤ i ≤ Q, -Q ≤ j ≤ Q и σ A {⊔} – wijn , 0 ≤ i ≤ Q, -Q ≤ j ≤ Q и − 1≤ n ≤ N;
Meaning of Variables • vijσ , 0 ≤ i ≤ Q, -Q ≤ j ≤ Q и σ A {⊔} (vijσ indicates whether after i steps of the computation the j-th position of the string contains the symbol σ); • wijn , 0 ≤ i ≤ Q, -Q ≤ j ≤ Q и − 1≤ n ≤ N; (wijn indicates whether at time i the j-th position of the string is scanned and the n-th instruction is executed).
Our goal • So if (n(i), s(i), π(i)) i = 0, 1, 2, …is a computation of Φ, then we intend to set – vijσ = true sj(i) =σ; – wijn = true π(i) = j и n(i) = n; – The collection Z(x) of clauses to be constructed will be satisfiable there is a string c with output(Φ, x#c)=1.
Требуемые условия для выполнимого набора дизъюнкций • At any time each position of the string contains a unique symbol. • At any time a unique position of the string is scanned and a single instruction is executed. • The algorithm starts correctly with input x#c for some c {0, 1}└ p(size(x))┘. • The algorithm works correctly ( (n, σ)=(m, τ, δ)). • When the algorithm reaches statement − 1, it stops. • Positions not being scanned remain unchanged. • The output of the algorithm is 1.
At any time each position of the string contains a unique symbol:
At any time a unique position of the string is scanned and a single instruction is executed:
The algorithm starts correctly with input x#c for some c {0, 1}└ p(size(x))┘. :
The algorithm works correctly ( (n, σ)=(m, τ, δ)).
When the algorithm reaches statement − 1, it stops:
Positions not being scanned remain unchanged:
The output of the algorithm is 1: {v. Q, 1, 1}, {v. Q, 2, ⊔}
Reduction is polynomial • The encoding length of Z(x) is O(Q 3 log Q): – There are O(Q 3) occurrences of literals, whose indices require O(log Q) space. • Since Q depends polynomially on size(x), we conclude that there is a polynomial-time algorithm which, given x, constructs Z(x). • Note that p, and q are fixed and not part of the input of this algorithm. • It remains to show that Z(x) is satisfiable if and only if x Y.
If Z(x) is satisfiable then x Y. • If Z(x) is satisfiable, consider a truth assignment T satisfying all clauses. • Let c {0, 1}└ p(size(x))┘, with cj = 1 for all j with T(v 0, size(x)+1+j, 1) = true and cj = 0 for all j with T(v 0, size(x)+1+j, 1) = false. • By the construction the variables reflect computation of on input x#c. • we may conclude that output( , x#c)=1. • Since is a certificate-checking algorithm, this implies that x is a yes-instance (x Y).
If x Y then Z(x) is satisfiable. • If x Y, let c be any certificate for x. • Let (n(i), s(i), π(i)) i = 0, 1, …, m be the computation of Φ on input x#c. • Then we define – T(vi, j, σ ) = true sj(i) = σ – T(wi, j, n ) = true π(i) = j and n(i) = n. – T(v i = m + 1, …, Q. i, j, σ ) = T(vi-1, j, σ ) – T(wi, j, n ) = T(wi-1, j, n ) i = m + 1, …, Q. • Then T is a truth assignment satisfying Z(x), completing the proof.
3 Sat • Instance: A set X of variables and a collection Z of clauses over X, each containing exactly three literals. • Question: Is Z satisfiable?
3 Sat Theorem 10. 2 (Cook 1971) 3 Sat is NP-complete.
Proof
Stable Set • Instance: A graph G and an integer k. • Question: Is there a stable set of k vertices? • A stable set in G is a set of pairwise non-adjacent vertices.
Stable Set Theorem 10. 3 (Karp 1972) Stable Set is NP-complete.
Sketch of proof • «Satisfiability» → «Stable Set» • «Satisfiability» : – Let Z ={Z 1, …, Zm} be a collection of clauses with Zi={λi 1, …, λiki} (i = 1, …, m), where the λij are literals over some set X of variables. • We shall construct a graph G such that G has a stable set of size m if and only if there is a truth assignment satisfying all m clauses.
Reduction • For each clause Zi we introduce a clique of ki vertices according to the literals in this clause. • Vertices corresponding to different clauses are connected by an edge if and only if the literals contradict each other.
Instance
Proof • Suppose G has a stable set of size m. • Then its vertices specify pairwise compatible literals belonging to different clauses. • Setting each of these literals to be true (and setting variables not occurring there arbitrarily) we obtain a truth assignment satisfying all m clauses.
Proof • Conversely, if some truth assignment satisfies all m clauses, then we choose a literal which is true out of each clause. • The set of corresponding vertices then defines a stable set of size m in G.
Homework Vertex Cover • Instance. A graph G and an integer k. • Question. Is there a vertex cover of cardinality k? Clique • Instance. A graph G and an integer k. • Question. Has G a clique of cardinality k? Prove NP-completeness of Vertex cover and Clique.
- Slides: 34