Formal Language and Automata Theory: CS2004 24 Uses of Turing Machines 24 Introduction We have previously covered the application of Turing Machine as a recognizer and decider In this lecture we will discuss the uses of Turing Machine as an enumerator and a function computer We will also give an introduction to Universal Turing machines 242 Turing machine as an Enumerator Simply put, an Enumerator is a Turing machine with an output printer The Turing machine can use the printer as an output device to print strings The following diagram gives a schematic of an enumerator :- # a b write only once tape FSC work tape Figure : Schematic of an Enumerator The language enumerated by an enumerator E is the collection of strings that it eventually prints out E may generate the strings in any order, possibly with repetitions We must also note that there is no input to an enumerator Also, if the enumerating TM does not halt, it may print an infinite list of strings A formal definition of an enumerator follows 242 Definition An enumerator E is a 6-tuple where is the finite set of states;
Page 2 of 0 Uses of Turing Machines 2 3 4 5 6 is the print tape alphabet, not containing the blank symbol ; is the work tape alphabet, where is the initial state ; is the final state and ; is the transition function for the two tape device ; 2422 Example If then the enumerator will output the following strings :- '&(&(&(&! # % Theorem A language is Turing-recognizable if and only if some enumerator enumerates it Proof of (IF: To show that if an enumerator E enumerates a language L, there is a Turing Machine M which recognizes L Given an input string, we design * in the following way : Run E to enumerate the next string + of Compare it with 2 If,-+ accept, else goto * Proof of (ONLY IF: To show that if a Turing machine recognizes a language, there is an enumerator for '&(&(&(& Let 0/ be a list of all possible strings in 2 One can readily construct an enumerator 354 which generates such a sequence An enumerator 3 for * works as follows: Repeat the following for 679 ;: ;< >=&(&(&(&(& Run * for 6 steps on each input %/ '&(&(&(&(&(& 2 If any computation is accepted, print out the corresponding @? ; If * out accepts a particular string it eventually appears on the list generated by 3A4, after which it is printed 243 Turing Machine as a function computer Let us first take a look at what a partial function is - Name of the Scribe Dept of Computer Science & Engg IIT Kharagpur, India
Chapter 24: Uses of Turing Machines Page 3 of 0 / / + 243 Definition A function A B is called a partial function if A, there is at most one element B Note that it is possible that a certain element of A may not be mapped to any element in B An example of a partial function has been represented below A B A partial function Figure 2: An example of a partial function is said to be Turing computable if there exists a TM *, where halt state; such that &(&(&(&(& / '&(&(&(& '&(&(&(& where + / and / Below is an example with the addition function -+ 0 0 # q 0 0 0 h Figure 3: Addition function Hence, a function n is computed by a TM if is also computed by a TM where '&(&(&(&(&(&(& > > '&(&(&(&(&(& Name of the Scribe Dept of Computer Science & Engg IIT Kharagpur, India
Page 4 of 0 Uses of Turing Machines Here is the encoding of in We now move on to Universal Turing Machines 244 Universal Turing Machines A Universal Turing Machine is one which can accept the description of another Turing machine as input and simulate the operation of that Turing machine To construct a universal TM we need to devise an encoding scheme to serve all TM s Let us first discuss a few notations- Since we are going the encode the description of a TM, we need to standardize our notation of the state transition function Note that can be represented in more than one ways as shown below- i a b, M p ii a iii a,b M M,N q Figure 4: Different notations for We propose the following representations for the above - 2 3 (p,a = (q,b,m (p,a = (q,a,m (p,a = (q,a,m, (p,b = (q,b,n Let us consider the following language -,-+ The state transition diagram of a TM * which accepts can be represented as below - 0, R L 0 R q p f a 0 R f r Figure 5: State transition diagram for * We now give the formal description of * : * Name of the Scribe Dept of Computer Science & Engg IIT Kharagpur, India
Chapter 24: Uses of Turing Machines Page 5 of 0 We define an encoding alphabet and propose the following encoding scheme:, # ## #%# To distinguish between two symbols of the same field we use the encoding string and to distinguish between two different fields we use Hence the state transition functions are encoded as % Now the description of * can be encoded as : # #% %#% This is followed by the encoded strings of each of the state transition functions and finally A universal TM expects a description of any TM * followed by an input string which is the encoded form of an input to * operates on the entire input string in the same way as * operates on,ie, accepts (or rejects the input string only if * accepts (or rejects &(&(&(&(& Name of the Scribe Dept of Computer Science & Engg IIT Kharagpur, India