Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
81 views
39 pages
Turing Machines
Automata Notes _ Ch. 5
Uploaded by
Siddharth Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Turing Machines For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
81 views
39 pages
Turing Machines
Automata Notes _ Ch. 5
Uploaded by
Siddharth Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Turing Machines For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Turing Machines For Later
You are on page 1
/ 39
Search
Fullscreen
for the follow Turing Machines ore ie}; show that foreguarex- . LEARNING OBJECTIVES ‘ter completing tis chapter, the reader wil be able to understand the folowing * computational problems that can be solved using a Turing machine (TM) ing stements + Formal model of TM per Assume * Comparison of frite automata (FA) and TM on the basis oftheir ed over the relative computational powers + Recursively enumerabe languages and recursive languages gla), then * concept of composite TM and iterative TM Multitape TM, mult-stack TM, and multitrack TM regula), then * concept of universal Tung machine (UTM) * Hating problem and limits of eomputabilty then 1 « church's Turing hypothesis * Solvable, semi-sohable, and unsolvable problems ce te * Total and partial recursive functions )"} is regular * Post's correspondence problem (PCP) 441 INTRODUCTION The limitations of finite state machines (FSMs) necessitate the search for a more powerful machine. We have seen that an FSM cannot remember an arbitrarily lon sequence of symbols. It has a read head that can move only in one direction—to the right always. It cannot move backwards {o retrieve previous information stored onto the tape. Similarly, though the two-way finite automaton (2FA) has a read head that can move in any direction, it cannot store (write) anything onto the tape; hence, it cannot multiply two numbers, as the process requires intermediate results to be stored onto the tape. Furthermore, an FSM cannot check if a set of parentheses are well-formed or for palindrome sequences. All these limitations arise because the FSMs do not have memory, and hence, they cannot solve problems that need to store data to be used for later computation,mitations of FSMs in detail in Chapter 2 (refe Section 2.14). To hese limitations, we require a more powerful machine, whi has the following properte 1. Finite state control similar to that of the FSM—since any program needs a number of functions/states. 2. External memory capable of remembering arbitrarily long sequences of inpul achieve this, the machine should have unbounded one-dimensional m a t can choose any required part, by moving to the left, right, or stayin; n (i., no movement)—the entire unbounded tape acts as an infinite mem store (write onto the tape)—the machine head should b heal Ability to consume its own output as input during execution at a later time (lik complete feedback control system)—for this, all the intermediate infor E be stored in the memory. For example, while multiplying numbers (multiplicaiag is a process of repetitive addition), itis required to store the intermediate or pati sums, which are later added to get the final answer. Hence, the distinction betweg the input and output symbols needs to be dropped. This means that exteal communication as well as communication within the machine should rest am >mmon alphabs he aforementioned characteris satisfied by the Turing machine (TM), w s proposed by Alan Turing, a decade prior to the designing of the first shared-progal computer. This concept of the Turing machine led to the concept of algorithms and tl cedures, since the basis of the TM is to first divide the process into primitive opera 4,2. ELEMENTS OF A TURING MACHINE \'TM consists of the following: an read or write a symbol at a time, and move either to the left, iil An infinite tape, extending on either side offi head, marked-off into square cells, on which mbols from an alphabet set can be written Ti tape represents the unbounded one-dimensiil memory (refer to Fig. 4.1), which is consi — : — > be fi ith blank characters, 6's, ul ‘symbols, called the external alpha consists of lower-case English letters, digi Sia sual punctuation marks, and the blank characte A finite set of states denot 5; the mac Figure 41 Turing machine resides in one of these states 43n Chapter 2 (refer to erful machine, which pences of inputs—to gional memory from ght, or staying in one be a read/write hea iia later time (like a ate information mu ahers (multiplication termediate or partial distinction between means that external (TM), whick first shared-pros algorithms and finite 9 primitive operations ble, and then execute ther to the left, right. cell side of the which the can be written. The sexteral alphabet set English leters, digits, e blank character B. by S; the machine iG MACHINES The TM thus overcomes all the limitations of the FSM. It has infinite memory in the form of a tape that is unbounded at both the ends; a read/write head tha direction, and helps the machine retrieve information from the tape that is stored earlier—in way, this can be considered as converting the dumb storage into memory; it can consume its own output a in the algorithm execution. All input for use at a later st make it a completely powerful machine. The TM and FSM are thus two extremes—an FSM is a minimal machine hereas a TM is the most powerful machine 43 TURING MACHINE FORMALISM As we have already seen, a’TM has a finite set of symbols /, and a finite set of states 5 (one of which is the halt al state), A TMis denoted with the help of three functions, namely, the mact state transition function (STF), and the direction function (DIF), which are defined as: ne function (MAF). MAF:1x SI STE IX SS DIF: 1X $ > D = (L,R,N} where, L stands for ‘move towards left by t by one tape cell position’, and NV stands for ‘no movement, that is, stay in the same ne tape cell position’, R stands for ‘move towards position or remain at the same tape cell, which has been read last Note: Observe that the MAF for FSM is defined as: Ix $—> O, s there is a distinction between 1 inpat and output; on the other hand, in case of a'TM, itis defined as: / Based on the machine’s state—which is an element of S—at any given time, and the fen time, the machine either takes input symbol read—which is an element of /—at an . halt state) or performs the following three actions: 1. The input symbol read is erased and another symbol (possibly a blank character or the same symbol tape cell, 2. The internal state of the machine is changed (possibly to the same state as it was initially in). 3. The head either moves one cell towards the right or left, or remains in the same position, These actions can be described collectively by an ordered set of five elements, that is, a quintuple. For example, (a, a, b, 8, L) rep € I, while the machi sents such a quintuple, which exists if the head S, writes b onto the tape cell after erasi sin state reais 4, changes the machine state to € S, and moves the To represent these quintuples together, a table called a transition matrix or functional matrix (FM) is used. Such a matrix is a combination of the aforementioned three individual functions—the MAF, STF, and DIF. In this functional matrix, the rows and columns are labelled by symbols forms S and /, respectively (as in FSMs), while the remaining triples, thatis, (b, B, L are placed as the entries of the matrix.Table 41. Example functional mat If the number of symbols in S, that is, the number of states = s nd the number of symbols in /, that is, number of tag symbols hen the size of the functional mat : z ¥ umber of output triples. For an example, refer to Table 4.1 aR OBR vaR that in Table 4.1, $ has three states and has three tape i hence, the functional matrix is of siz » anctio x, then an example transition can b T in while in a state, the machine eras ites a again hanges the state from nd mo 4 position to the left by one tape n the aforementione he significant change after transition is just the positiog ne head, because the symbol on the tape a and the current state of the machine, th emain the same even after the transition. Therefore, instead of writin le triple in the functional matrix, we can sav by writing of Simplified functional matrix the significant changes. Hence, the aforementioned triple can ti i simplif 5 fi 1 es * 2 BR The modified functional matrix, in which we only record the signi wW int. changes after deleting all other insignificant entries to save s called a simplified functional matrix (SFM). The SFN Note: Itis also possible to convert a quintuple representation to a quadruple representation. Fu symbol a by b and the second transition 8) is about moving the head position a Formal Definition [- Finite set of allowable tape symbols, including blank character b : The set of input symbols, which is a subset of |, excluding blank character #Esto save spac SPM eq Table 4.2 psentation. For deterministic. jb 8) and poof the three position one tuple notation baracter qo: Start (or initial) state € Q F: Set of final states (or halt states) CQ Functional matrix, such that 8: (Q xT) > (@ xT x { In hay rministic TM, there should be a unique triple (b, fd) for ever state « on some symbol a, for 6 (a, a) in the functional matr Notes: {6 may be undefined for some arguments, which are represented inthe table as —", (simi to the transition table of an FSM), Refer to Tables 4.1 and 4.2 2. FSM isa special case ofa TM. If we make the tape length finite and restrict the head moveme only to one direction, then the functional matrix corresponding to this FSM will specify IX $, whieh is, nothing but the state transition function (STF), 44 INSTANTANEOUS DESCRIPTION state of the TM, that is, g € Q, and s the stein, We define a move (or transition) of M as follows: Let “ a4, be an ID of M. This ID indicates that the cui Suppose, 6 (*, p, L) isa transition, wher Ii = n+ 1, then a;is taken to be b, that is, blank charact If 7 = 0, then the tape head moves one position to the left of the first symbol tha considered to be blank character b, in the next ID If {> 1, then we can write the ID for the aforementioned transition as Similarly, for the move 6 , write dy oo = oo Oy Ifthe two IDs are rel i's We say that the second n cen here, If one { result zero number of moves), then The language accepted by M is denoted by L(M) and isthe set of those words in * th leftmost cel Formally, we can define the language accepted by M = (0, 8.18, gy Bs 1) = (w|w and quW for some p in F an Let us consider an example of a TM.THEORY OF COMPUTATIO ok Consider an SFM for a'TM with the following: - Example 4.1 1= (0.1.0) 5 = (a, B, y= halt) D=(LR.M The SEM is Find the purpose of the aforementioned TM, provid: en in Table 4 the initial configuration of the TM is as given in Fig. 4.2. role lopetepel Table 4.3 SFM for examph 1 ; Read/Write head B - -— Ww e Siate a] Figure 42 Intel configuration of Solution It is very important to note that the functional matrix gives us only half the formation on what the TM does, and unless we know the init ID of the TM, we cannot determine its purpose. Thus, the interpretation of the TM is highl dependent on its initial configuration, which includes the following: what the TM sta ‘ape, and the initial state of the machine. Note that the interpretation may differ for different initial configurations even configuration of initia with, how the input string is assumed to be placed onto the for the same functional matrix. Therefore, we can say that the initial configuration or the initial ID is like the assumption ribed by the functional mat that forms the basis forthe interpretation of the algorithm dese AAs we can see, initially the machine is the state a, and the head points to the blank char acter b just before the actual string begins; hence, a is the initial or start state of the TM, We observe that the function of the aforementioned TM is to replace the last (or ending Lby ed; it 0, whenever a sequence of 0's followed by a | is Let us simulate the workit oo01b M ba0001p a boaoole 8 (a,0) = (R) M 5 wooa0lp 8 (a,0) = (R) 4.5 TRANS! Figure 4.3if the T™M. M M $0000 yh 5B. =(yM The simulation of a TM for a particular input is a recording of the transition from one ID to another. The simul on given here is a formal notation, However, the IDs can also be represented using a s We observe th he tape cell to be read. This change makes it visibly simple for the reader to understand, In this chapter, we are going to follow the same changed notation for represen for TM in pr nce to the formal one. Using the simpler ID notation, the aforeme poooi moved oni 00008 changed 1 to 0, chan moved one position to ri 6), halt after th 45 TRANSITION GRAPH FOR TURING MACHINE " ATMcanalso © represented pictorially with the help of a transition graph (TG). In such a graph, the nodes denote the internal states from + “@ the set S. A pair of nodes is connected by a directed edge (or arc) labelled by the input symbol from the set [, followed by an arre and the new output symbol again from the set |— this symbol is to b written after erasing the previous symbol; the direction of th Haka d from the set D. The transition graph for the TM in shown in Fig. 4.3 Figure43 TGforexampleTM Example 4.1D=(L,R.N) Here, quis considered as the start state whi The SFM for the TM is as gi Table 44 SFM ofaTM f parentheses are wel-orme I s r ) Baad o Rub Sh gene wee 4 L L 4 Law L { the TM encounters an e ‘aright parenthesis ‘)',itends up in halt giving R, as outpu output. Ifthe entire sequence of parentheses is balanced, then the machine moves to the palt state qs giving the output O, indicating acceptable inpu We observe from Table 4.4 that state qo is responsible for searching for the first right warenthesis *)’. It moves towards the right, ignoring any left parenthesis “(’ that is encoun reed. Once the right parenthesis is found, itis replaced with “**; then the machine move ‘one position tothe left and changes to state q,. Sta responsible for searching toward he left for the matching left parenthesis "(, Once the first left parenthesis *( is found, itis placed with “*”, and the machine moves back to qp. Thus, the states qp and qr at he first two steps of the algorithm While moving towards the left and searching for the left parenthesis “(° while in if the machine cannot find “(, that is, the machine reads *;" (left end-marker) instead, then itis an error condition, In such a case, the machine generates output symbol R,, indicating fan extra right parenthesis, and to the halt st On the other hand, if while moving towards the right in gp and searching for the first \t parenth the machine reads *;’ (right end-marker), indicating there are no more ight parentheses *)’, to be changed to ‘*", the machine moves to state qa. In state q3, one needs to check for any unmatched left parentheses, ‘(, that are left, In state q,, while m¢ ing to the left, if the machine comes across the symbol ‘;’ (left end-marker), indicating condition. Hence, the machine generates the output O, indicating that the input string i Tow tring is not well-formed and has at k i parenthesis "(’, This is n error condition and the machine generates output symbol L, and halts. ph for this TM The transition pown in Fig. 4.5Figure 4.5. TM for checking if a set of parentheses are configuration (b) TG fc Simulation 1. Let us simulate the working of the aforementioned TM on the sequence “The output symbol 0 indicates that the string *(( well-formed.Let us now simulate the working of this TM for input sequent inally, et us simulate the working of this TM for an empty sequen Example 4.3 Design a TM to find the 2's complement of Solution The initial configuration of the TM is consider (MSB), of the binary number. The binary number is delimited by semicolons which are s the end-marke emaining tape is filled with blank character The algorithm we are going to use is the same as that used in Exam 7 Algorithm by 0, till you reach the left end-marker *;’ of the or this TM, we hiURING MACHINES 15 Table 45 SFM fora TM that finds 2's con 2 binary numb s 0 k R L t L OL Qn The TG for the TM nin Fig. 4.6(b) sant (@)> Dom Read/Write hea Figure 4.6 find the 2. number (a) ntl configuration (b) TG for TM that Simulation Let us simulate the working of this TM for the string “01010Table 46 each 1 D1010 5 Gn) 01010 3.0) o10l0 8g. =(@L o1llo 8 (gn 0) = (11) 0110 8 (gz 1) = OL) t 10110 q2,0) = (IL) 10110 8 Gnd=@N) nerates the 2's complement, for the input string “01010°, as *10110" Example 44 Design a'TM that replaces all occurrences of “111" by “I01" froma sequence of Solution The juired TM is a typical sequence detector machine (Mealy machine) that we have studied in Chapter 2. Let the initial configuration of the TM bx in Fig. 4.7(a) The initial state is assumed to be qo. The string is delimited at the rightmost end by a semicolon *;, which is used as the end-marker. The TM starts reading from the leftmost symbol in the input str FM fora TM that replaces The SFM for the required TM, which c curence of'11'by 101" of “111” by ‘101" is as given in Table 4.6, For this TM, we have fils td 0.103 mS Hae sas $= law an ae at GR GR gs Dati kiN Gah TGS iq We se from Table 46 that sates gg, and gy colctively den Oust — aera easton sate and point the mile | which oR ir replaced by 0 in state q,; thus, the string is replaced by *101". Once the replacement is done, the TM moves to state q,, which resets to state qo for repeating the same process again t sequence of *I11” that may exist. The TG for the TM is shown in Fig. 4.7(b}Wie bead Figure 4.7 TM that ‘tt by 101 Simulation Let us simulate the working of the TM lin1011 1111011 ri i 1i1id 1011011 orlo1i t o1l01li (2) Ina confgur by 101 jon 0) TG fo onstructed for TM that URING MACHINES.hus, the TM has converte Note: As we know, the particular problem we hi ssed ean also be solved using Mealy Example 4.5 Design a TM that recognizes words of the form 0" I" for n 20. Solution Let us assume the initial configuration as shown in Fig. 4.8(a). The transition graph for the TM is shown in Fig. 4.8 b J o[t l? 5 Ox a PEN nat ‘ Figure 8 TM tatrecogies stig of fo 01" nO (ital confguraten () Tnsion gap Algorithm. 1. Replace the first 0 by some other symbol, say a, and move towards the right till you first rst I by some other symbol, say ¢, and move towards the left till you immediately next to the one that was previously replaced by a. 3. Repeat the procedure till all 0's are replaced by a's For this TM, we have The SFM for the TM is as shown in TableTURINGMACHINES 15 Table 47 SFM fora TM that nizes sting 0 s 0 1 a ¢ b a apr ~ 8R eN (accept) B R cyl = R Y L - aR L Ss tring t0 “101 4 2 a a ay taciapn) ved using Mealy problems that are Here, « is the initial state of the machine and ¢ is the halt state. The transition diagram s drawn as shown 4.800). Simulation , 1. Letus simulate the working of the machine for the sti Ha). The transition 0011 7 11 5(a,0)=(@6R) . > 3B.) = (ey) 3(y.0) =) t 5) Trnstion graph a0ctb 3(,a) = (aR) ° cacis 5(a,0)= (BR ie right wll you B B the left il you aacte nated Py aOF COMPUTATION aaceb (a,c) = GR) 3 aacep 8 (6,0) = (R) t aacch 5 (6, B) = (oN Thus, the string ‘0011” is accepted by the TM. 2. Let us simulate the working of this TM for the empty stri nitial configuration b 3 (a,b) =(€N) by the machine as it fits the pattern 0" I" for n = 0. In case of epte empty string, the machine starts reading th trailing blank character, b. Example 4.6 Desi n a TM that recognizes strings containing equal number of ( eal Solution Let Algoritin Starting from the initial f you reach the first 0 replace it by “*", and move right Figu till you reach the first 1; replace that also by the same symbol, 2. Ifyou reach | first, then repla first 0; replace that also that with the symbol “*”, and move right till you reach 3. Repeat the procedure till you finish reading all 1’s and 0's. If any 1 or 0 remains, there must be an error, and the machine should reject the input For this TM, we have 1 = (0, 1,3.% 7, F), where T = accepted; and F = rejected The SFM for the TM is as shown in Table 4.8. The init I state qo makes transition to 4, after replacing the input symbol 0 by *. State hence carries the responsibility of finding the matching symbol 1, State qs is reached m qo on finding the symbol 1; hence q, needs to find the matching 0 so that the number of 0's and 1's are same. The output symbol T'is generated if the number of O's and 1's are ‘equal in the input string; else output F is generated,Table 4.8 SFM fora TM that ac 1 s 0 1 a% “qR RT a Rak Fa a L ears a ‘al = R FaN TM that recogr Figure 49 Simulation 1. Letus simulate the w tion diagram for the TM is as shown in Fig. 4.9(b tings containing equal numberof O's and accep all stings containing equal number c king of the TM for the lol initial 10100 5 10100 8(g 5 (4 fsa G for TM tat (2) lita configuration (b) configuration aR D=@®)nple 4.7 Design a TM that recognizes binary palindrome Solution et the initial configuration of the TM be as shown in Fig. 4.10(a). In this case that the head initially points to the left end-marker *;, thatig ust prior to the actual start of the input. This assumption is the basis for the algorithm wel write. Note that if we make a different assumption—for example, we may assume th head points to the first input symbol—the algorithm as well as the SFM t erated for the TM will be differen Algorith Read the first symbol, which may be 0 or 1. Replace it by some oth 2. Move towards the right to find nd of the sequence, that is, the right end marker “'. Then, move one position to the left to point to the last symbo 3. Read the last symbol. If itis equal to the symbol that we read at the other en replace it with *;, and continue the process 4. If itis not equal, then the sequence is not a palindrome sequene For this TM, we have at the input sequence is a pal TM; and F indicates that the input is not a palindrome sequence and is therefore rejecte py the TM. The SFM for the TM is as shown in Table 4 Table 49. SFM for TM that recogni 1 s 0 F T L L ak a aR TaN a R R aul 4s gol = FQN Tag au R R aul 3 a gol TaeN“The transition graph is drawn as shown in Fig. 4.1008), Q)ReadiWrite head (ea mv OR 1-R +R or OOO). rab eo ioe 9s Figure 4.10 TM that recognizes binary palindromes (a) Il co for TM that recognizes binary palindrom Simulation of the TM that we which is a binary palindrome seque 1. Let us simulate the workin, have constructed fi D110 8 Go) = R) TURING MA iquraonThe output F indicates that the string ‘O1" is not a palindrome string, and hence rejected by the TM. Example 4.8 Design a TM, which compares two positive integers m and n and prox output Gif m > ms Ly i and E, if m = n Solution This TM is a symbol manipulation system. For this, we need to represent numbers in the unary format. If we c nsider © = {a}, then the numbers can be represented hat many a’s. For example, ‘2° in unary format can be writte be written as ‘aaaa The initial conti ration of the TM is assumed as shown in Fig. 4.11(a). Notice that th 'wo numbers, m and n, are separated by a punctuation symbol *. (comma The transition diagram for the required TM is shown in Fig. 4.11(b Dieter CE Figure 4.11. TM that compares two (b) Transition grap e+ (Ina configurationAlgorithm 1. Replace o 2. Move right tll you get the first a no a is remaining of m that is to be r then m > 1 4. Move left to find the next a of m; if fi the aforementioned two ste ‘otherwise, the one with some remaining a's must be greater than the other. For this TM, we have D The SEM for 10. Table 10 SFM fora TM that compares two postive intege Z s a * b G L E 4 “aR aR R 4 R Gri eS es 2 pauer (ee 4 “qb z es eae = 2 4 L L L Rees su a LasN RR EgsN Initially, the TM is in state qo, which replaces one a from m by “*", and makes a transi tion to a new state q,. State g, is responsible for finding the beginning of the next numbei ‘on accomplishing this, g, makes transition to q,, State q, replaces one a from n by to match the one that we have replaced from m earlier. Essentially, we subtract 1 both the numbers. Now, if the TM replaces one a from m by a “#", but there is no a left to be replaced in » then it means that in state g_ the TM does not find any a; it instead read b. In this case, the TM generates the output G, to indicate that the first r et us consider another scenario. If there is no a left in the number reads comma go; then, it changes to state q,, State qut whether there is a nd number n, Ifthe TM finds an ¢38 THEORY OF COMPUTATION bab (ao) = Qa) Lp 5 (qua) = (Lqs™) The output L, indicates that m = 0 is less than n = 1 oe Let us consider the case when both numbers are equal: let m =n = 1 = ‘a ba.ap initial configuration bab « Qk bey a) =(* gL) bee 8 (qs. B) = (GoR) ’ 4 i bere (a (® | E 8 (qs, B) = (Ey as) Thus, m and n are equal, which is indicated by the output E Example 49 Design a TM that performs the addition of two unary numbers, Solution the pair of numbers expressed in unary form usin symbol ‘a’, that is, a number x is represented by x consecutive a's, Let the initial configuration of the machine be as shown in Fig. 4.12(a). As both the unary numbers are represented using the letter ‘a’, they are separated by the delimiter ‘c’ on the tape The initial state of the TM is a, as specified in Fig. 4.12(a). The TG for this TM shown in Fig, 4.12(b)Figure 412 TM that pe dition of two unary numbers () Initial configuration (6 dk Algorithm. Addition is nothing but concatenation. This is exactly similar to what is taugh rimary level mathematics. To achieve ‘m + n’, let us represent m and n by som such as blue balls and then perform aggregation. Put m blue balls into a bucket ai blue balls into the same bucket; the ives the value after addition Replace each a from the first number, that is, the string of a's on the blank character # and add one a after the string of a's representing the second nu Table 4.11. SFM for aTM that adds two equal to the result of addition resides on the r in Table 4.1 Note: In this example, entries for 8 state are not shown because they are null entries halt state. In all previous amples, we have used ‘-" (hyphens) to indicate them ‘Simulation fa Let us simulate the working of the TM for the following example First number = 3 = ‘aaa’ in pre nd put n ket. I unary num At the end, replace the ¢ with a blank cha j For this TM, we hi 5 a Hehe 1 ) a BR bon $= {a.B, 7.8 = halt} D={(LRN B R ayN OR The simplified functional matrix for the TM is y Loageass B aacaab bhaace bhaacaaa bhaacaaab bhaacaaap t bbb B bopact 6B.B=(ayN) 5(a,a) = (BBR)bbbacaaab B bbbacaaab B bacaaaab bbbacaaaab bop bbbacaaaab bow bbbacaaaab bbpbe B bbbbcaaaab 1 B bbbbcaaaap B bbbscaaaah bbbbcaaaaab t bbbbca 5 (B,a) =(R) 6 (B,a) =(R) 8B, =(ayN) b(ya=C a(na=C dina=O s(nO=D 8 (ya) = (L) (7,8) = (@R) 6(a,a)=(UBR) 8B.0=) 5 (B.a)=(R) 3(B,a) =(R) 5B.) = 8 (B.a) = (R) 5B. = (ayFY OF COMPUTATION bbbbcaaaaap 6.) =) aaaaab b.a=D bbbbcaaaaap b(.a=L t aaaaab b.a=D s.0=0 5 (yb) =(@R) 8 (a,c) = B3N) Thus, the addition of the two numbers “3 + the five a’s that a 2" is completed, and that is indicated by left on the tape before the machine halts Example 4.10 Desig a TM that multiplies two unary numbers, Solution Multip pave already discussed unary ication, as we know, is repetitive addition of multiplicand to itself. We TM in th multiplicand, then n x dition usir previous example If m is the multiplier and nis mm can be viewed as nXm=n-+n-+...mnumber of times Thus, we consider addition as the concatenation of m number of n’s. of the TM a n Fig ). The mul: both unary representations of the decimal numbers. They symbol 1 Let us consider the initial configuration tiplier and multiplicand for example, the decimal number 2 The rest of the tape is assumed to be filled with all 0’s instead of 6's. The Figure 4.13 Result of multiplication O) Reads Write head z (Smear) oe a) © TM that mutipis two unary numbers (a) It (for the operation 2 configuration (b) Final configuration of TMTURING MACHINES 17 multiplier and multiplicand are separated by a comma * and delimited at both the ends by semicolons *;’. The head points to the separator symbol *, initial The result of the multiplication is written after the right end-marker n (2). We have an example final configuration of the TM for a sample multiplication (2 * 2), shown in Fig, 4.13(b). Observe how the result is written and where it is written onto th tape. The result is also represented in unary format but using the symbol b. The multiplier the end gets replaced with 0's. The algorithm thus is a destructive one, as it modifies the parameters sent to it (in this case, th Algorithm 1. Replace one ‘1’ of the multiplier by ‘0’, that is, subtract one from the multiplier. 2. To add fond the right end-marker multiplicand to the result area, that is, be replace one ‘I of the multiplicand by some symbol, say ‘a’ 3. Find the end of the result where ‘0’ can be found, replace it with symbol presented by all ‘b’s) 4. Repeat the aforementioned steps 2 and 3 till all the ’s in the multiplicand are a replaced by “d 5. The multiplicand is added once to the result area; hence, reset the multiplicand to all 's again and repeat the steps starting from 6. Stop when all the ‘1's in the multiplier are re For this TM, we have S= {a.B. 78,6, = halt) D=(LRN} The SFM for the TM is shown in Table 4 Table 4.412 SFM fora TM that t s 0 1 a b a L OpR on L B R aR
hs or this TM e fat of the TM is, et te bd ut 1 ba, b} initially points to S= (4 ds Ai 45 Qo = halt} es Simulation us simulate the working of TM n Lis I he right Divisor = 3 = “111 Po's inthe di dividend = 8 = “1111111 os LLLL Leh initial configuratio eps 1 1 5 (qn 1) R) ial, in Exam a Subtraction of the divisor from dividend begiThe number of a's in the divisor area represents the remainder, and the number of I's after the right end-marker ‘;' represents the result of th when 8 is divided by 3 is 2, and the remainder is 2 Example 4.13 Design a TM to find the value of log, (n), where n is any binary number and a perfect power of 2 Solution —Itis given that n is a binary number and a perfect power of 2 We know 2'=2= 10 (binary) 2° = 8 = 1000 (binary From the aforementioned listing, we have ‘© number of 0's after first 1 in the binary format) 1 = 2 (two 0°s after first 1 in binary format, whit power of 2, is equal to the number of 0's after the first 1 in the given number n. Algorithm Count of the number of zeros after the beginning ‘1' of the binary number ‘n’; it gives us the required answe 1. Read the first digit, that is, 1, and ignore i 2. Read the following 0 from the string that follows the 1, replace it by a symbol, a, and write a symbol, ¢, after the right end-marker 3. Repeat the procedure til all the 0's that follow 1 get replaced by a 4, The number of c's written after the right end-marker gives the required value of lo Thus, the input string is in binary format and the resultant value is in unary forms using symbo Note: We could use a simpler algorithm as well, which simply replaces the first digit 1 with blank character the remaining number of 0's gives the required answer. However, this would destroy the input parameter, and hence we do not use this algorithm, The initial configuration of the required TM is shown in Fig, 4.16(a), and its transition graph is shown in Fig. 4.16(b),it obtained s would Figure 4.16 Finding th The SFM is c shown in Table 4.15. I s L 0 RagR qu a R aR 4 i L % Simulation 2°), We know that for this number n, log; (1) 1000; 66 initial Let us simulate the working of the TM that we hai guration (b) TG for TM that finds log. at nds og, a ¢ 6 R “gal a0 L < constructed for n = 1000 presentedcho 3 (qo.0) = (aq R) aaa 5 (gz, 0) = (R) laaa;ccby 5g) = (R) laaazcecb 8 (gn B) = (cash t 5 (quo) = azcec® 8g, =O cb (oR) : 0 a The TM halts with the result ccc, which is the expected value, that is We could also replace all the as to have a non-destructing algorithm 'sby 0's again, in order to retain the input parameter, s 4.7 COMPLEXITY OF A TURING MACHINE The complexity of a TM is directly proportional to the size of the functional matrix. In other words, we can say that the complexity of a TM depends on the number of symbols that are being used and the number of states of the TM. Hence Complexity ofaTM =|[ |x|] (or|I|x|$}), where, |[ | = Cardinality of tape alphabet (i.e., number of tape symbols) nd | Q | = Number of states of the TM. Let us consider Example 4.13 in which we designed a TM that finds log nis a perfect power of 2, and is represented in binary format. For this examy (1.0.4.6. 5) O = 140 41 dos 4 halt}Therefore, the complenty of the TM = [|x| |= 6 x 5 Thus, while designing a TM, we must ensure that it has minimum complexity, that is we should design «TM such that it ha: lesser number of input symbols and state 4.8 COMPOSITE AND ITERATIVE TURING MACHINES Two or more Turing machines can be combined to solve a complex problem, such th output of one TM forms the input to the next TM, and so on. This is called composition For realizing a composite TM (or a CTM), the functional matrices of the component TMs are combined by re-labeling the symbols, as required, and suitably branching to an appropriate state rather than the halt state at the completion pmponent TM. Figure Another way of having a combination TM is by applying its own output as input r a) depicts a composition of n TMs titively. This is called iteration or recursion, and the TM is said to be an iterative TM. or ITM). For an example, refer t0 F Input at |_ [aM Lopate | Oxapu Figure 4.17 posite and iterative TMs (a) Composite TM (CTM) erative TM (TH The idea of a composite TM gives rise to the concept of breaking a complicated j into a number of smaller jobs, implementing each separately, and then combining then et for the job required to be done. Th roblem into simple jobs and design different TMs for each job. This is a typical s re, we can divide ration of concerns achieved in software development; it is analogous to the Funct -omposition that we know from discrete mathematics: f g (x) = f(g (x)). The output of ¢ (x) is given as input to function f. In a way, modulat influenced by CTM. Functionally, most of the TMs that we have implemented earlier in the chapter, for on, are examples of iterative TMs. Example 4.14 Design a TM to find the value of n°, where m is any integer = 0, Solution Let us consider the initial cor The numb ted in unary form using 0's, as shown in F 8(a). We fin 7? is in terms of the multiplication ‘n X n°. This involves copying n after the comm: onto the tape, and using that as the multiplicand—represented in unary form using symbol 1—as shown in Fig. 4.18(b). We can then perform the multiplication ‘n % n’, as we have n Example 4.10, Figure 4.18(b) is the initial configuration for the M that performsfoblem, such that the ealled compositio B of the component Bbiy branching to an Performance of each pte eT in i TH (TM) f complicated job B combining them B we can divide Ba typical sey Bs tthe function f). The output of Fan be considered the chapter, for Bbiraction, and so ber= 0, B 4.18 (a) F4.18(a). We find Frthe comma fm using symbol DM that performs Multiplier Muli Figure 4.18 TM that computes n(n =) (a) nital configuration (b) Configuration ater copy ‘Observe that the TM that compute The first'TM prepares the output in the form can be considered as a composition of two TM: ested in Figure 4.18(b), which can be use as input for the second TM that performs multiplication, The second TM is similar to the cone that we have already designed in Example 4.10; the SFM for this TM is describ Table 4.12 with a as the initial state. Hence, we need to design the first TM, which converts J as input b the initial configuration shown in Fig, 4.18(a) into the form that can be us the second TM, whose initial configuration is shown in Fig. 4.18(b. Algorithm 1. Replace one O ata time by symbol | and Table46 SF? this pro 7 d by 1 2 replaced by I's , 3, Thus, another copy of n gets prepared fter the right end-marker, *;’. This is 4% aR GR done to store n as the multiplier as well g, Rak as multiplicand onto the tap ; ai fi 4, Now, replace the end-marker comma, *, and add another end- 4 a ot marker,“ atthe end of the copy of m gy L ee created a the right end z The SFM for the required TM Table 4.16. ‘Simulation ing of the TM for n = 2.
You might also like
Unit 4-Theory of Computation
PDF
No ratings yet
Unit 4-Theory of Computation
69 pages
Unit-4 Turing Machine (TOC)
PDF
No ratings yet
Unit-4 Turing Machine (TOC)
87 pages
Flat Unit 4
PDF
No ratings yet
Flat Unit 4
70 pages
Turing Machine Unit IV
PDF
No ratings yet
Turing Machine Unit IV
47 pages
Unit Iv
PDF
No ratings yet
Unit Iv
23 pages
Complexity Theory Chapter 1
PDF
100% (1)
Complexity Theory Chapter 1
53 pages
Chapter 2
PDF
No ratings yet
Chapter 2
139 pages
Fla Unit 4 and 5
PDF
No ratings yet
Fla Unit 4 and 5
198 pages
Unit 4
PDF
No ratings yet
Unit 4
100 pages
Module 5 TuringMachine
PDF
No ratings yet
Module 5 TuringMachine
78 pages
Fla Unit 4
PDF
No ratings yet
Fla Unit 4
103 pages
TOC Chapter8
PDF
No ratings yet
TOC Chapter8
36 pages
Unit 3 TM
PDF
No ratings yet
Unit 3 TM
46 pages
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Nos
PDF
No ratings yet
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Nos
35 pages
Flat Unit-5
PDF
No ratings yet
Flat Unit-5
30 pages
F L, A C: Ormal Anguages Utomata and Omputation
PDF
No ratings yet
F L, A C: Ormal Anguages Utomata and Omputation
32 pages
Turing Machines
PDF
No ratings yet
Turing Machines
52 pages
It 503 (A) Toc Unit 5 Notes
PDF
No ratings yet
It 503 (A) Toc Unit 5 Notes
16 pages
Chapter 5 TuM
PDF
No ratings yet
Chapter 5 TuM
70 pages
8 Turing Machines
PDF
No ratings yet
8 Turing Machines
93 pages
Turing Machine PDF
PDF
No ratings yet
Turing Machine PDF
15 pages
Turing 1
PDF
No ratings yet
Turing 1
37 pages
Turing Machine
PDF
No ratings yet
Turing Machine
57 pages
Turing Machines New Modified 2025
PDF
No ratings yet
Turing Machines New Modified 2025
88 pages
Turing Machine
PDF
No ratings yet
Turing Machine
84 pages
Tutorial Nine
PDF
No ratings yet
Tutorial Nine
49 pages
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Page Nos
PDF
No ratings yet
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Page Nos
76 pages
Module 2
PDF
No ratings yet
Module 2
36 pages
1 - Module 1.1 Regular Expressions
PDF
No ratings yet
1 - Module 1.1 Regular Expressions
23 pages
2it70 Chap4
PDF
No ratings yet
2it70 Chap4
26 pages
PCC CS501 5
PDF
No ratings yet
PCC CS501 5
52 pages
1 - Module 1.2 - Equivalence of RE and FA
PDF
No ratings yet
1 - Module 1.2 - Equivalence of RE and FA
69 pages
Turing Machines
PDF
No ratings yet
Turing Machines
21 pages
3.3.1 (TM)
PDF
No ratings yet
3.3.1 (TM)
26 pages
Turing Machine
PDF
No ratings yet
Turing Machine
16 pages
4 TuringMachines
PDF
No ratings yet
4 TuringMachines
26 pages
Unit Vii
PDF
No ratings yet
Unit Vii
11 pages
Lecture 14. Turing Machines
PDF
No ratings yet
Lecture 14. Turing Machines
23 pages
Automat 1
PDF
No ratings yet
Automat 1
14 pages
Turing 1
PDF
No ratings yet
Turing 1
20 pages
Turing Machines
PDF
No ratings yet
Turing Machines
18 pages
Turing Machine
PDF
No ratings yet
Turing Machine
59 pages
Turing Machine
PDF
No ratings yet
Turing Machine
32 pages
HN ATC Notes Module 4 Part4
PDF
No ratings yet
HN ATC Notes Module 4 Part4
13 pages
Turing Machine
PDF
No ratings yet
Turing Machine
27 pages
Unit 4
PDF
No ratings yet
Unit 4
13 pages
Turing Machine 1
PDF
No ratings yet
Turing Machine 1
18 pages
Jan-June 2025 Btcs 4 Sem v10 Btcs404 Btcs404 Unit5 Notes
PDF
No ratings yet
Jan-June 2025 Btcs 4 Sem v10 Btcs404 Btcs404 Unit5 Notes
10 pages
Introduction To Turing Machine
PDF
No ratings yet
Introduction To Turing Machine
7 pages
Unit 5 - Theory of Computation - WWW - Rgpvnotes.in
PDF
No ratings yet
Unit 5 - Theory of Computation - WWW - Rgpvnotes.in
17 pages
Unit
PDF
No ratings yet
Unit
12 pages
Unit 5 - Theory of Computation - WWW - Rgpvnotes.in
PDF
No ratings yet
Unit 5 - Theory of Computation - WWW - Rgpvnotes.in
17 pages
Unit 3 Toc
PDF
No ratings yet
Unit 3 Toc
17 pages
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Page Nos
PDF
No ratings yet
Unit 1 Models For Executing Algorithms - Iii: TM: Structure Page Nos
35 pages
Turing Machine
PDF
No ratings yet
Turing Machine
6 pages
Toc CHP-4
PDF
No ratings yet
Toc CHP-4
10 pages
Definitions of The Turing Machine
PDF
No ratings yet
Definitions of The Turing Machine
10 pages
Umair 2
PDF
No ratings yet
Umair 2
7 pages
HN Atc Handout 4 2 TM
PDF
No ratings yet
HN Atc Handout 4 2 TM
7 pages
Formal Definition of Turing Machine
PDF
No ratings yet
Formal Definition of Turing Machine
5 pages
Turing Machine: Presented By: Gagan Virk
PDF
No ratings yet
Turing Machine: Presented By: Gagan Virk
17 pages
(An Alternate View Of) Turing Machines: This Handout Was Written by Maggie Johnson and Mehran Sahami
PDF
No ratings yet
(An Alternate View Of) Turing Machines: This Handout Was Written by Maggie Johnson and Mehran Sahami
9 pages