Sie sind auf Seite 1von 13

NP & Computational Intractability : Part II

Satyajit Thakor
IIT Mandi

20 April, 2017
The satisfiability problem

I An abstract problem: set decision variables such that they


satisfy constraints e.g., Boolean algebraic equations.
I Set of Boolean variables X = {x1 , . . . , xn }
I A term is a variable xi or its negation x
i :

ti {x1 , . . . , xn , x n }.
1 , . . . , x

I A clause is a disjunction of distinct terms:

t1 t2 . . . tl

I A clause has length if it contains l terms.


I A truth assignment for X is an assignment of the value 0 or 1 to
each xi :
: X {0, 1}
The satisfiability problem

I An assignment satisfies a clause C if it causes C to evaluate to 1


under the rules of Boolean logic.
I This is equivalent to requiring that at least one of the terms in
C should receive the value 1.
I An assignment satisfies a collection of clauses C1 , . . . , Ck if it
causes all of the Ci to evaluate to 1:

C1 C2 . . . Ck = 1

I In this case, is a satisfying assignment with respect to


C1 , . . . , Ck ; and that the set of clauses C1 , . . . , Ck are satisfiable.
I Example: For clauses (x1 x x1 x
2 ), ( 3 ), (x2 , x
3 )...
I Assigning 1 to all variables is not a satisfying assignment but
assigning 0 is.
The satisfiability problem

I Satisfiability problem or SAT: Given a set of clauses C1 , . . . , Ck


over a set of variables X = {x1 , . . . , xn }, does there exist a
satisfying truth assignment?
I 3-Satisfiability problem or 3-SAT: Given a set of clauses
C1 , . . . , Ck , each of length 3, over a set of variables
X = {x1 , . . . , xn }, does there exist a satisfying truth
assignment?
I SAT and 3-SAT are really fundamental combinatorial search
problems.
I Make n independent decisions (the assignments for each xi ) so
as to satisfy a set of constraints.
I There are several ways to satisfy each constraint in isolation,
but we have to arrange decisions so that all constraints are
satisfied simultaneously.
Reducing 3-SAT to independent set

I To solve an instance of 3-SAT using a black box for independent


set, we need a way to encode all these Boolean constraints in
the nodes and edges of a graph, so that satisfiability
corresponds to the existence of a large independent set.
I Theorem 1: 3-SAT P independent set.
I Proof: Choose one term from each clause, and then find a truth
assignment that causes all these terms to evaluate to 1, thereby
satisfying all clauses.
I Succeed if we can select a term from each clause in such a way
that no two selected terms conflict.
I Two terms conflict if one is equal to a variable xi and the other
is equal to its negation x
i .
I If we avoid conflicting terms, we can find a truth assignment
that makes the selected terms from each clause evaluate to 1.
Reducing 3-SAT to independent set

I Construct a graph G = (V, E) consisting of 3k nodes grouped


into k triangles.
I Three vertices vi1 , vi2 , vi3 joined to one another by edges.
I vij is labeled with the jth term from the clause Ci of the 3-SAT
instance.
I Since two vertices cannot be selected from the same triangle,
they consist of all ways of choosing one vertex from each of the
triangles.
I This is implementing our goal of choosing a term in each clause
that will evaluate to 1.
I But we have so far not prevented ourselves from choosing two
terms that conflict.
Reducing 3-SAT to independent set
I Encode conflicts by adding some more edges to the graph: For
each pair of vertices whose labels correspond to terms that
conflict, we add an edge between them.
I Select one node from each triangle so that no conflicting pairs of
vertices are chosen - this is precisely what the 3-SAT instance
requires.
Reducing 3-SAT to independent set

I Claim: 3-SAT instance is satisfiable if and only if the graph G


constructed has an independent set of size at least k.
I [Proof of only if part: If the 3-SAT instance is satisfiable, then
each triangle in our graph contains at least one node whose
label evaluates to 1.
I Let S be a set consisting of one such node from each triangle.
I S must be independent: if there were an edge between two
nodes u, v S, then the labels of u and v would have to conflict;
but this is not possible, since they both evaluate to 1.]
I [Proof of if part: Suppose G has an independent set S of size at
least k.
I Then, the size of S is exactly k, and it must consist of one node
from each triangle.
Reducing 3-SAT to independent set
I There is a truth assignment for the variables in the 3-SAT
instance with the property that the labels of all nodes in S
evaluate to 1:
I For each variable xi , if neither xi nor x
i appears as a label of a
node in S, then arbitrarily set (xi ) = 1.
I Otherwise, exactly one of xi or x
i appears as a label of a node in
S; for if one node in S were labeled xi and another were labeled
x
i , then there would be an edge between these two nodes,
contradicting our assumption that S is an independent set.
I Thus, if xi appears as a label of a node in S, we set (xi ) = 1,
and otherwise we set (xi ) = 0. By constructing in this way,
all labels of nodes in S will evaluate to 1.] .

I A useful Theorem 2: If Z P Y , and Y P X, then Z P X.


Reducing 3-SAT to independent set

I If a 3-SAT instance is satisfiable, we can prove this by revealing


the satisfying assignment.
I It may be an enormously difficult task to actually find such an
assignment; but if weve found it, its easy to plug it into the
clauses and check that they are all satisfied.
I The difference between finding a solution and checking a
proposed solution:
I For independent set or 3-SAT, we do not know a
polynomial-time algorithm to find solutions; but checking a
proposed solution to these problems can be easily done in
polynomial time.
Problems and algorithms

I The input to a computational problem will be encoded as a


finite binary string s. We denote the length of a string s by |s|.
I We will identify a decision problem X with the set of strings on
which the answer is yes.
I An algorithm A for a decision problem receives an input string s
and returns the value yes or no - denote this returned value
by A(s).
I We say that A solves the problem X if for all strings s, we have
A(s) = yes if and only if s X.
I A has a polynomial running time if there is a polynomial
function p() so that for every input string s, the algorithm A
terminates on s in at most O(p(|s|)) steps.
I Definition: The set P is the set of all problems X for which
there exists an algorithm A with a polynomial running time
that solves X.
Efficient certification
I A checking algorithm for a problem X has a different
structure from an algorithm that actually seeks to solve the
problem: in order to check a solution, we need the input
string s, as well as a separate certificate string t that contains
the evidence that s is a yes instance of X.
I Definition: B is an efficient certifier for a problem X if the
following properties hold.
I (1) B is a polynomial-time algorithm that takes two input
arguments s and t.
I (2) There is a polynomial function p so that for every string s,
we have s X if and only if there exists a string t such that
|t| p(|s|) and B(s, t) = yes.
I Example (a case of prime factorization): Is a given natural
number a composite number?
NP

I Definition: The set N P is the set of all problems for which


there exists an efficient certifier.

I Theorem 2: P N P
I Proof: Next lecture...

Das könnte Ihnen auch gefallen