The Class of Languages P � If a (deterministic) TM has some M p olynomial p ( n ) suc h that nev er mak es M more than p ( n ) mo v es when presen ted with input of length n , then is said to b e a M TM . p olynomial-time � P is the set of languages that are accepted b y p olynomial- tim e TM's. � P Equiv alen tly , is the set of problems that can b e solv ed b y a real computer b y a p olynomial- time algorithm. ✦ Wh y? Because while T ( n ) steps on a 3 computer ma y b ecome T ( n ) steps on a TM, T ( n ) cannot b e a p olynomial unless 3 T ( n ) is. ✦ Man y famili ar problems are in P : graph reac habilit y (transitiv e closure), matrix m ultiplication (is this matrix the pro duct of these other t w o matrices?), etc. The Class of Languages N P � A nondeterministic TM that nev er mak es more than p ( n ) mo v es in an y sequence of c hoices for some p olynomial p ) is said to b e a NTM . p olynomial-time � N P is the set of languages that are accepted b y p olynomial -tim e NTM's. � N P Man y problems are in but app ear not to P b e in : TSP (is there a tour of all the no des � in a graph with total edge w eigh t k ?), SA T (do es this Bo olean expression ha v e a satisfying assignmen t of its v ariables?), CLIQUE (do es this graph ha v e a set of no des with edges k b et w een ev ery pair?). � One of the great mathematical questions of our age: Is there an ything in N P that is not in P ? NP-Complete Problems \ P N P If w e can't resolv e the = question, w e can N P at least demonstrate that certain problems in are \hardest," in the sense that if an y one of them P P N P w ere in , then = . � Called NP-c omplete problems. � In tellectual lev erage: eac h NP-complete problem's apparen t di�cult y reenforces the b elief that they are all hard. 1
Metho d for Pro ving NP-complete Problems � P olynomial- tim e reductions ( PTR ): tak e time that is some p olynomial in the input size to con v ert instances of one problem to instances of another. ✦ Of course, the same algorithm con v erts non-instances of one to non-instances of the other. � If P PTR to P , and P is in P , then so is 1 2 2 P . 1 ✦ Wh y? Com bine the PTR and test to P 2 get a p olynomial -tim e algorithm for . P 1 � Start b y sho wing problem in N P has every a PTR to (= satis�abilit y of a Bo olean SA T form ula). ✦ Th us, if SA T is in P , ev erything in N P is in P ; i.e., P = N P ! � Then, more problems can b e pro v en NP- complete b y sho wing that SA T PTRs to them, directly , or indirectly . ✦ Key p oin t: the comp osition of an y �nite n um b er of PTR's is a PTR. � Don't forget that y ou also need to sho w the problem is in N P (usually easy , but necessary). Reduction of An y in N P to SA T L Assume L = L ( M ) for some NTM M that is time- b ounded b y p olynomial p ( n ). � Key idea: if w , of length n , is in L , then there is a sequence of p ( n ) + 1 ID's, eac h of length p ( n ) + 1, that demonstrates acceptance of . w ✦ W ell not exactly: the accepting sequence migh t b e shorter. If so, extend ` to allo w ` � � if � is an ID with an accepting state. ✦ Still not exactly: some ID's will b e shorter than p ( n ) + 1 sym b ols. P ad those out with blanks. � No w, w e can imagine a square arra y of sym b ols X , for i and j ranging from 0 to ij p ( n ), where X is the sym b ol in p osition j of ij the i th ID. 2
� Giv en string , construct a Bo olean w expression that sa ys \these X 's represen t ij an accepting computation of w . ✦ V ery Imp ortan t : The construction m ust b e carried out in time p olynomial j w j . in n = In fact, w e need only O (1) � 2 � w ork p er [or ( n ) total] X O p ij ✦ Another imp ortan t principle: The output cannot b e longer than the amoun t of time tak en to generate it, so w e are sa ying that the Bo olean expression will ha v e O (1) \stu� " p er X . ij � The prop ositional v ariables in the desired expression are named , whic h w e should y i;j;Y in terpret as an assertion that the sym b ol X ij is . Y � The desired expression E ( w ) is S ^ M ^ F = starts, mo v es, and �nishes righ t. Starts Righ t � S is the AND of eac h of the prop er v ariables: ^ ^ � � � ^ ^ ^ � � � ^ y y y y 0 ; 0 ;q 0 ; 1 ;a 0 ;n;a 0 ;n +1 ;B 0 1 n y 0 ;p ( n ) ;B ✦ Here, is the start state, = , q w a ; : : : ; a 0 1 n and B is the blank. Mo v es Righ t Key idea: the v alue of dep ends only on the X i;j three sym b ols ab o v e it, to the northeast, and the north w est. � Ho w ev er, since the comp onen ts of a mo v e (next state, new sym b ol, and head direction) m ust come from the same NTM c hoice, w e need rules that sa y: when X is the state, i � 1 ;j then all three of , , and X X X i;j � 1 ij i;j +1 are determined from , , and X X i � 1 ;j � 1 i � 1 ;j b y one c hoice of mo v e. X i � 1 ;j +1 � W e also ha v e rules that sa y when the head is not near X , then X = X . ij ij i � 1 ;j � Details in the reader. The essen tial p oin t is that w e can write an expression for eac h X ij in (1) time. O ✦ Therefore, this expression is O (1) long, indep enden t of n . 3
Finishes Righ t Key idea: w e de�ned the TM to rep eat its ID once it accepts, so w e can b e sure the last ID has an accepting state if the TM accepts. � is therefore the OR of all v ariables F y p ( n ) ;j;q where is an accepting state. q Conjunctiv e Normal F orm W e no w kno w SA T is NP-complete. Ho w ev er, when reducing to other problems, it is con v enien t to use a restricted v ersion of SA T, called 3SA T, where the Bo olean expression is the AND of clauses , and eac h clause consists of exactly 3 als . liter � A literal is a v ariable or a negated v ariable. ✦ : y E.g., x or . W e shall sometimes use the common con v en tion where � represen ts x the negation of x . � A is the OR of literals. clause ✦ E.g., ( x _ y � _ z ). ✦ W e shall often follo w common con v en tion and use + for _ in clauses, e.g., ( x + � + ), and also use juxtap osition (lik e y z a m ultipli cation) for ^ . � An expression that is the AND of clauses is in (CNF). c onjunctive normal form CSA T Satis�abilit y for CNF expressions is NP complete. � The pro of (reduction from SA T) is simple, b ecause the expression S ^ M ^ F w e deriv ed is already the pro duct (AND) of expressions whose size is O (1), i.e., not dep enden t on n = j w j . � First, w e can push all the : 's do wn the expression un til they apply only to v ariables; i.e., an y expression is con v erted to an AND- OR expression of literals. ✦ Use DeMor gan 's laws : : ( E ^ F ) = ( : E ) _ ( : F ) and : ( E _ F ) = ( : E ) ^ ( : F ). ✦ Changes the size of the expression b y only : 's a constan t factor (b ecause extra and p ossibly paren theses are in tro duced). 4
Recommend
More recommend