CPS 140 - Mthemticl Foundtions of CS Dr. S. Rodger Section: Other Models of Turing Mchines èhndoutè Deænition: Two utomt re equivlent if they ccept the sme lnguge. We will demonstrte equivlence etween two clsses of utomt y showing tht for every mchine in one clss, there is mchine in the second clss tht cn simulte it, nd vice vers. Turing Mchines with Sty Option Allow the tpe hed to sty in plce fter writing. Modify æ, Theorem Clss of stndrd TM's is equivlent to clss of TM's with sty option. Proof: æ èèè: Given stndrd TM M, then there exists TM M' with sty option such tht LèMè=LèM'è. èesyè æ èèè: Given TM M with sty option, construct stndrd TM M' such tht LèMè=LèM'è. M=èK,æ;,;æ;q 0 ;B,Fè M'= For ech trnsition in M with move èl or Rè put the trnsition in M'. So, for æèq i ;è=èq j ;;LorRè put into æ 0 For ech trnsition in M with S èsty-optionè, move right nd move left. So for æèq i ;è=èq j ;;Sè LèMè=LèM'è. QED. 1
Deænition: A multiple trck TM divides ech cell of the tpe into k cells, for some constnt k. A 3-trck TM: c 1 1 1 tpe hed Amultiple trck TM strts with the input on the ærst trck, ll other trcks re lnk. æ: Theorem Clss of stndrd TM's is equivlent to clss of TM's with multiple trcks. æ èèè: Given stndrd TM M there exists TM M' with multiple trcks such tht LèMè=LèM'è. æ èèè: Given TM M with multiple trcks there exists stndrd TM M' such tht LèMè=LèM'è. 2
Deænition: A TM with semi-inænite tpe is stndrd TM with left oundry. Theorem Clss of stndrd TM's is equivlent to clss of TM's with semi-inænite tpes. æ èèè: Given stndrd TM M there exists TM M' with semi-inænite tpe such tht LèMè=LèM'è. Given M, construct 2-trck semi-inænite TM M' TM M... c... TM M # # c... right hlf left hlf æ èèè: Given TM M with semi-inænite tpe there exists stndrd TM M' such tht LèMè=LèM'è. 3
Deænition: tpes. An Multitpe Turing Mchine is stndrd TM with multiple è ænite numerè redèwrite Control Unit tpe 2 tpe 1 c tpe 3 For n n-tpe TM, deæne æ: Theorem Clss of Multitpe TM's is equivlent to clss of stndrd TM's. æ èèè: Given stndrd TM M, construct multitpe TM M' such tht LèMè=LèM'è. æ èèè: Given n-tpe TM M construct stndrd TM M' such tht LèMè=LèM'è. 4
Deænition: An Oæ-Line Turing Mchine is stndrd TM with 2 tpes: red-only input tpe nd redèwrite output tpe. Deæne æ: c input tpe (red only) Control Unit d red/write tpe Theorem Clss of stndrd TM's is equivlent to clss of Oæ-line TM's. æ èèè: Given stndrd TM M there exists n oæ-line TM M' such tht LèMè=LèM'è. æ èèè: Given n oæ-line TM M there exists stndrd TM M' such tht LèMè=LèM'è. 5
Running Time of Turing Mchines The running time of TM's is deæned to e the count of the numer of moves, writes nd reds. Since ech trnsition does ll three of these, you cn just count the numer of moves, nd multiple your nswer y 3. Exmple: Given L=f n n c n jné0g. Given w2 æ æ, is w in L? Write 3-tpe TM for this prolem. Deænition: An Multidimensionl-tpe Turing Mchine is stndrd TM with multidimensionl tpe èexpnds inænitely in multidimensionsè. èwe will just exmine the 2-dimensionl-tpe TMè. " è c! è The tpe hed ènot shownè would e pointing to one of the tpe cells. Deæne æ: 6
Theorem Clss of stndrd TM's is equivlent to clss of 2-dimensionl-tpe TM's. æ èèè: Given stndrd TM M, construct 2-dim-tpe TM M' such tht LèMè=LèM'è. æ èèè: Given 2-dim tpe TM M, construct stndrd TM M' such tht LèMè=LèM'è. Imgine numering ech cell on the 2-dim tpe TM using x-y-coordintes. Note tht there re only ænite numer of symols èignoring lnksè written on the 2-dim tpe. " -1,2 1,2 2,2 è -2,1-1,1 1,1 2,1 c 3,1! -2,-1-1,-1 1,-1 2,-1 Construct M' to e 2 trck TM. The ærst trck stores ll symols èignoring lnksè written on the 2-dim tpe, nd the second trck stores the position of ech symol. Mrkers èèè re used to seprte positions nd symols. è è è è c è 1 è 1 è 1 1 è 1 è 1 1 1 è 1 " The tpe hed in M' will point to the sme symol nd position tht M points to. M' will simulte move inmy serching its tpe for the next position. If the position is not listed, then the position is dded with B s the vlue written in tht position. Deænition: A nondeterministic Turing mchine is stndrd TM in which the rnge of the trnsition function is set of possile trnsitions. Deæne æ: Theorem Clss of deterministic TM's is equivlent to clss of nondeterministic TM's. æ èèè: Given deterministic TM M, construct nondeterministic TM M' such tht LèMè=LèM'è. æ èèè: Given nondeterministic TM M, construct deterministic TM M' such tht LèMè=LèM'è. Every time there is choice in the trnsition function new mchine should e creted. Construct M' to e 2-dim tpe TM. Two rows will represent the simultion of one mchine. The ærst row stores the contents of the tpe, nd the second row stores the position of the tpe hed nd the current stte of the mchine. Whenever there is choice in M, two new rows will e dded to M' to simulte the new mchine. Mrkers èèè re used to indicte the current work re. 7
A step consists of mking one move for ech of the current mchines. If ny of these mchines hve choice, then dditionl mchines re dded èi.e. two rows dded to the 2-dim tpe TM. For exmple: Consider the following trnsition: æèq 0 ;è=fèq 1 ;;Rè;èq 2 ;;Lè;èq 1 ;c;règ Suppose the 2-dim tpe egins in stte q 0 with input c. Note tht q 0 lso represents the position of the tpe hed on M. è è è è è è c è è q 0 è è è è è è The one move hs three choices, so 2 dditionl mchines re strted. è è è è è è è c è è q 1 è è c è è q 2 è è c c è è q 1 è è è è è è è The ærst two rows represent tking the ærst choice ove. The next two rows represent tking the second choice ove. The lst two rows represent tking the third choice ove. Note the tpe hed of M' hs not e shown. It would point to squre within the mrked region. Deænition: A 2-stck NPDA is n NPDA with 2 stcks. Control Unit stck 1 stck 2 Deæne æ: 8
Consider the following lnguges which could not e ccepted y n NPDA. 1. L=f n n c n jné0g 2. L=f n n n n jné0g 3. L=fw 2 æ æ j numer of 's equls numer of 's equls numer of c'sg, æ=f; ; cg Theorem Clss of 2-stck NPDA's is equivlent to clss of stndrd TM's. æ èèè: Given 2-stck NPDA, construct 3-tpe TM M' such tht LèMè=LèM'è. æ èèè: Given stndrd TM M, construct 2-stck NPDA M' such tht LèMè=LèM'è. 9
Universl TM - progrmmle TM æ Input: í n encoded TM M í input string w æ Output: í Simulte M on w An encoding of TM Let TM M=fK,æ;,;æ;q 1 ;B,Fg æ K=fq 1 ;q 2 ;:::;q n g Designte q 1 s the strt stte. Designte q 2 s the only ænl stte. q n will e encoded s n 1's æ Moves L will e encoded y 1 R will e encoded y 11 æ,=f 1 ; 2 ;:::; m g where 1 will lwys represent the B. If we use 0's s seprtors etween symols deæning æ, then we cn deæne TM s string of 0's nd 1's. For exmple, consider the simple TM: ;,R ;,L q 1 q 2,=fB,,g which would e encoded s 10
The TM hs 2 trnsitions, æèq 1,è=èq 1,,Rè, æèq 1,è=èq 2,,Lè which cn e represented s 5-tuples: èq 1,,q 1,,Rè,èq 1,,q 2,,Lè Thus, the encoding of the TM is: 0101101011011010111011011010 where the ærst group of 1's è1è represents q 1, the second group of 1's è11è represents '', etc. The ærst æve groups of 1's represent the ærst trnsition ove, nd the second æve groups of 1's represent the second trnsition ove. The input to the universl TM would e the code of TM followed y the code of the input string. Use 2 0's to seprte the TM code nd the input string. For exmple, the encoding of the TM ove with input string ë" would e encoded s: 010110101101101011101101101001101110110 Question: Given w 2f0;1g +,iswthe encoding of TM? 11
Universl TM The Universl TM èdenoted M U è is 3-tpe TM: Control Unit 0 1 1 0... tpe contents of M 0 1 0 encoding of M 1... 1 1 1 current stte of M Tpe 1 contins the encoding of TM M. Tpe 2 contins the contents of the tpe of M. Tpe 3 contins the current stte. Suppose TM M ws in stte q 3 nd it's tpe hed ws pointing to n ''. The universl TM would hve the encoding of q 3 èrepresented y 111è on tpe 3, nd tpe 2's hed would e pointing to the ærst symol in the encoding of n ''. Progrm for M U 1. Strt with ll input èencoding of TM nd string wè on tpe 1. Verify tht it contins the encoding of TM. 2. Move input w to tpe 2 3. Initilize tpe 3 to 1 èthe initil stteè 4. Repet èsimulte TM Mè èè consult tpe 2 nd 3, èsuppose current symol on tpe 2 is nd stte on tpe 3 is pè èè lookup the move ètrnsitionè on tpe 1, èsuppose æèp,è=èq,,rè.è ècè pply the move æ write on tpe 2 èwrite è æ move on tpe 2 èmove rightè æ write new stte on tpe 3 èwrite qè Oservtion: Every TM cn e encoded s string of 0's nd 1's. Enumertion procedure - process to list ll elements of set in ordered fshion. Deænition: An inænite set is countle if its elements hve 1-1 correspondence with the positive integers. Exmples: æ S = f positive odd integers g æ S=frel numers g æ S=fw2æ + g,æ=f; g 12
æ S=fTM's g æ S=fèi,jè j i,jé0, re integersg Liner Bounded Automt We plce restrictions on the mount oftpewe cn use, restricting our usge to the size of the input string. An input string is listed with 'ë' signifying the left end of the input nd 'ë' signifying the right end of the input. The tpe hed cnnot move to the left of 'ë' or to the right or 'ë'. ë c ë " Deænition: A liner ounded utomton èlbaè is nondeterministic TM M=èK,æ;,;æ;q 0 ;B,Fè such tht ë; ë 2 æ nd the tpe hed cnnot move out of the conænes of ëë's. Thus, æèq i ; ëè = èq j ; ë;rè, nd æèq i ; ëè=èq j ;ë;lè Deænition: Let M e LBA. LèMè=fw 2 èæ,fë;ëgè æ jq 0 ëwë æ`ëx 1 q f x 2 ëg Exmple: L=f n n c n jné0gis ccepted y some LBA 13