Outline of T uring Mac hines and Complexit y 1. T uring mac hine (TM) = formal mo del of a computer running a particular program. ✦ W e m ust argue that the TM can do exactly what a computer can do, alb eit slo w er. 2. W e use the simplicit y of the TM mo del to pro v e formally that there are sp eci�c problems (=languages) that the TM cannot solv e. ✦ Tw o classes: \recursiv ely en umerable" = TM can accept the strings in the language but cannot tell for certain that a string is not in the language; \non-RE" = no TM can ev en recognize the mem b ers of the language in the RE sense. 3. W e then lo ok at problems (languages) that do ha v e TM's that accept them and alw a ys halt; i.e., they not only recognize the strings in the language, but they tell us when they are sure the string is not in the language. ✦ The classes P and N P are those languages recognizable b y deterministic (resp., nondeterministic) TM's that halt within a time that is some p olynomial in the input. ✦ P olynomial is as close as w e can get, b ecause real computers and di�eren t mo dels of (deterministic) TM's can di�er in their running time b y a p olynomial function, e.g., a problem migh t tak e 2 6 O ( n ) time on a real computer and O ( n ) on a TM. 4. NP-complete problems: Since w e don't kno w whether P = N P , but it app ears that at least some problems in N P tak e exp onen tial time, the b est w e can do is sho w that a certain problem is \NP-complete," = if this problem is in P , then all of N P is in P . 5. Some sp eci�c problems that are NP-complete: satis�abilit y of b o olean (prop ositional logic) form ulas, tra v eling salesman, etc. In tuiti v e Argumen t Ab out an Undecidabl e Problem Giv en a C program, do es it prin t hello, world. as the �rst 13 c haracters of output? 1
� W e pro v e there is no C program to solv e that problem b y supp osing that there w ere suc h a program H , the \hello-w orld-tester." ✦ H tak es as input a C program P and an input �le I for that program, and tells whether P , with input I , \prin ts hello w orld" (b y whic h w e mean it do es so as the �rst 13 c haracters). � Mo dify H to a new program H that acts lik e 1 H , but when H prin ts no , H prin ts hello, 1 world. ✦ Requires some though t: w e need to �nd where is prin ted and c hange the no statemen t. printf � Mo dify H to H . This program tak es only 1 2 one input, P , and acts lik e H with b oth its 1 program and data inputs equal to P . ✦ I.e., H ( P ) = H ( P ; P ). 2 1 ✦ Requires more though t: H m ust bu�er 2 its input so it can b e used as b oth the P and I inputs to H . 1 � H cannot exist. If it did, what w ould H ( H ) 2 2 2 do? ✦ If H ( H ) = yes , then H giv en H as 2 2 2 2 input eviden tly do es not prin t hello, But H ( H ) = H ( H ; H ) = world. 2 2 1 2 2 H ( H ; H ), and H prin ts if and only yes 2 2 1 if its �rst input, giv en its second input as data, prin ts Th us, H ( H ) hello, world. 2 2 = implies H ( H ) = yes hello, world. 2 2 ✦ But if H ( H ) = then hello, world. 2 2 H ( H ; H ) = and hello, world. 1 2 2 H ( H ; H ) = no . Th us, H ( H ) = 2 2 2 2 implies H ( H ) 6 = hello, world. hello, 2 2 world. The TM � Finite-state con trol, lik e PD A. � One read-write tap e serv es as b oth input and un b ounded storage device. ✦ T ap e divided in to c el ls . ✦ Eac h tap e holds one sym b ol from the tap e et . alphab ✦ T ap e is \semi-in�nite"; it ends only at the left. 2
� marks the \curren t" cell, whic h is T ap e he ad the only cell that can in�uence the mo v e of the TM. � Initially , tap e holds a a � � � a B B � � � where 1 2 n a a � � � a is the input , c hosen from an input 1 2 n (subset of the tap e alphab et) and B alphab et is the blank . F ormal TM M = ( Q; � ; � ; � ; q ; B ; F ), where: 0 � Q = �n te set of states. � � � = tap e alphab et; � � = input alphab et. � B in � � � = blank. � q in Q = start sym b ol; F � Q = accepting 0 states. � � tak es a state and tap e sym b ol, returns a new state, replacemen t sym b ol (either migh t not c hange) and a direction L=R for head motion. Example Non trivial examples are hard to come b y . Here's a TM that c hec ks its third sym b ol is 0, accepts if so, and runs forev er, if not. M = ( f p; q ; r ; s; t g ; f 0 ; 1 g ; f 0 ; 1 ; B g ; p; B ; f s g ) 1. � ( p; X ) = ( q ; X ; R ) for X = 0 ; 1. 2. � ( q ; X ) = ( r ; X ; R ) for X = 0 ; 1. 3. � ( r ; 0) = ( s; 0 ; L ). 4. � ( r ; 1) = ( t; 1 ; R ). 5. � ( t; X ) = ( t; X ; R ) for X = 0 ; 1 ; B . ID's of a T uring Mac hine The ID (instan taneous description) captures what is going on at an y momen t: the curren t state, the con ten ts of the tap e, and the p osition of the tap e head. � Keep things �nite b y dropping all sym b ols to the righ t of the head and to the righ t of the righ tmost non blank. ✦ Subtle p oin t: although there is no limit on ho w far righ t the head ma y mo v e and write non blanks, at an y �nite time, the TM has visited only a �nite pre�x of the in�nite tap e. 3
� Notation: �q � sa ys: ✦ � is the tap e con ten ts to the left of the head. ✦ The state is q . ✦ � is the non blank tap e con ten ts at or to the righ t of the tap e head. � ` One mo v e indicated b y ; zero, one, or more * ` mo v es represen ted b y . ✦ Chec k the reader for the detailed de�nition of ` . Example With input 0101, the sequence of ID's of the TM is: p 0101 ` 0 q 101 ` 01 r 01 ` 0 s 101. � A t that p oin t it halts, since state s has no mo v e when the head is scanning 1. ` ` With input 0111 the sequence is: p 0111 0 q 111 ` ` ` ` � � � 01 r 11 011 t 1 0111 t 0111 B t . � The TM nev er halts, but con tin ues to mo v e righ t. Acceptance b y Final State and b y Halting One w a y to de�ne the language of a TM is b y the set of input strings that cause it to reac h an accepting state. * � L ( M ) = f w j q w ` �p� for some p in F and 0 an y � and � in � � g . Another w a y is to de�ne the set of strings that cause the TM to = ha v e no next mo v e. halt * � f w j ` H ( M ) = q w �pX � , and � ( p; X ) is not 0 de�ned g . ✦ Subtle p oin t: a TM can to halt if app e ar the next mo v e w ould tak e the head o� the left end of the tap e. ✦ Giv en an y TM, w e can mark the left end so that nev er happ ens; i.e., w e pro duce a mo di�ed TM that accepts the same language and halts rather than fall o� the left end. Example � The TM M of our previous example has L ( M ) equal to those strings in the language of RE (0 + 1)(0 + 1)0(0 + 1) � . 4
Recommend
More recommend