Turing machine recap A Turing machine TM is a tuple M = (Γ, Q, δ) where Γ: set of symbols that TM s tapes can contain. Q: possible states TM can be in. qstart: the TM starts in this state qhalt: the TM halts when this state is reached Computability and Complexity Storage for TM : A special register stores the current state. 1 input tape, 1 output tape and 1 work tape obustness of TM Alphabet size doesn t matter Many details of our TM quite arbitrary Does restricting the alphabet Γ to {0, 1,, } matter? No! If function f is computable by a TM using alphabet Γ, then it is computable in time 4 log Γ T (n) by a TM using the alphabet {0, 1,, }. Does using more work tapes make everything much faster? No! If function f is computable by a TM using k tapes, then it is computable in time 5kT (n) 2 by a TM using a single work tape. Church-Turing Hypothesis Every physically realizable computation device can be simulated by a TM. Claim If function f is computable by a TM M using alphabet Γ, then it is computable in time 4 log Γ T (n) by a TM M using the alphabet {0, 1,, }. Have to decide: How to represent each symbol of Γ using {0, 1,, }. Use binary encoding. Each symbol encoded by log Γ bits. How to simulate each step of M. ead the encoded symbol via log Γ bits. Problem: remember the bits read. Modify the transition table appropriately Lookup the (remembered) read bits in the (modified) table
emembering bits read Problem: How to remember the bits read? q i q j q q 0 q 01 q 010 0 q 0 0 1 q 01 1 0 q 010 0 0 q 0100 0 q 1 q 0100 1 Total time required n x y i b j 3 y 0 1 0 0 1 b What is the number of states in M? Each line in the transition table of M creates 4 log Γ states. log Γ steps to read the symbol encoding. log Γ steps to go back to the start of the symbol encoding. log Γ steps to write the new symbol encoding. 2 log Γ in case the tape-head moves to the left. What is the size of the transition table? Q Γ Total number of states required: Q Γ 4 log Γ. Each step of M requires 5 log Γ steps of M. Total time taken: 5 log Γ T (n) steps. Lets say that i 01001 and j 01010. Then, Q Γ Q Γ {L, S, } q 0 q0 0 q0 1 q01 1 q01 0 q010 0 q010 0 q0100 0 q0100 1 qb1.01001 1 L qb1.01001 qb2.01001 L qb2.01001 qb3.01001 L qb3.01001 qb4.01001 L qb4.01001 qw1.01001 S qw1.01001 qw2.01001 0 qw2.01001 qw3.01001 1 qw3.01001 qw4.01001 0 qw4.01001 qw5.01001 1 qw5.01001 q 0 Note: need to move back 2 log Γ steps as well! More work tapes do not make much difference Claim If a function f is computable by a TM M using k tapes, then its computable in time 5kT (n) 2 by a TM using a single work tape. Proof Lets consider that a TM M computes the function f and has k tapes (plus additional input and output tapes) Next we consider a single work tape Turing machine ˆM ˆM encodes the k tapes of M on a single tape by using locations 1, k + 1, 2k + 1,... to encode the first tape, locations 2, k + 2, 2k + 2,... to encode the second tape etc. For every symbol a in M s alphabet, ˆM will contain both the symbol a and the symbol â. In the encoding of each tape, exactly one symbol will be of the ˆ type, indicating that the corresponding head of M is positioned in that location.
More work tapes do not make much difference Universal Turing Machines Proof Cont d To simulate one step of M, the machine makes two passes of its work tape: first it traverses the tape in the left-to-right direction and records (via additional states) the k symbols of the form â Then ˆM uses M s transition function to determine the new state, symbols, and head movements and sweeps the tape back in the right-to-left direction to update the encoding accordingly. ˆM will never reach more than location kt (n) of its work tape, meaning that for each of the at most T (n) steps of M, ˆM performs at most 5kT (n) work (sweeping back and forth requires about 2T (n) steps, and some additional steps needed for updating head movement and book keeping). So far, constructed Turing machines for a specific task. a primitive computer that only performs one task. Not very useful, since there are many things we want to do. Question: does there exist a TM that does many things? In other words, given a program P and an input x for P, run P on x. Note that a program is just an algorithm for doing something, i.e., its a Turing machine. So...given any TM M and x, does there exist a TM UTM that will run M on x How to give M to UTM? Since M is a machine. How does one give a machine to a machine? How can there be a fixed machine UTM that will run any other TM? What is a Turing machine really The Algorithm for TM How does one give a machine to a machine? Observe that the TM s are not all that different Can assume all have 1 input tape, 1 output tape, 1 work tape. Can assume Γ = {0, 1,, } The only thing different between different Turing machines is the transition table But the transition table can be written up as a string of bits! Mα: TM represented by string of bits α M {0, 1} : string of bits representing M So UTM takes α and x, and simulates Mα on x. How can there be a fixed machine UTM that will run any other TM? According to Church-Turing hypothesis, any algorithm can be turned into a TM. Clever idea: unning a TM is also just an algorithm! For example, we ran the TM for PAL(x) by hand. We just have to follow some rules, i.e., there is a simple algorithm for running a TM : ead a symbol of x. Scan the transition table to find a rule which applies. Apply this rule to write new symbol and move the tape head. So we just have to design a TM that can run the above algorithm.
Universal Turing Machine Simulating M α Storage: T1: input tape containing α, x. T2: output tape Three work tapes: T3 contains the current state of Mα T4 is used the same way as Mα s work-tape. T5 contains the transition function. Transition function of UTM: Scan T5 to find a match of the state with T3 Scan T5 to find a match of symbol with T1 and T4. Copy new state to T3 Copy new symbol to T4 and move heads of T1 and T3. Some Quotes Uncomputable functions If we were so clever that we could understand our brain, our brain would be so complex that we couldn t understand it. It seemed unworthy of a grown man to spend his time on such trivialities, but what was I to do? Bertrand ussell. f is computable by a TM M if M(x) = f (x) x It would seem that any function f : {0, 1} {0, 1} can be computed by a Turing machine. We don t care how much time is taken So just spend as much time till the computation of the function finishes. Uncomputable functions exist There exists UC : {0, 1} {0, 1} not computable by any TM. HALT(P, x): Given program P and x, does P halt on x? Halting function HALT is not computable by any TM.
Uncomputable functions exist HALT Uncomputable functions exist There exists UC : {0, 1} {0, 1} not computable by any TM. Proof. Define the function UC as follows: UC(α) = 0 if Mα(α) = 1 UC(α) = 1 if Mα(α) = 0 or Mα doesn t halt on input α. Claim: There is no TM that computes UC. For contradiction, assume M computes UC( ) M always halts at {0, 1}. What is M( M ) = UC( M )? M( M ) = 0 = UC( M ) = 0 if M M ( M ) = 1 M( M ) = 1 = UC( M ) = 1 if M M ( M ) = 0 Halting function HALT is not computable by any TM Proof. Again, assume a TM MH computes HALT We show how to use MH to compute UC a contradiction. On input α, run MH(α, α). If MH(α, α) says that Mα(α) doesn t halt Then know that UC(α) = 1. If MH(α, α) says that Mα(α) does halt Simply run Mα on α, since we know it ll halt! If Mα(α) = 1, know that UC(α) = 0 If Mα(α) = 0, know that UC(α) = 1 The Halting problem spawns more problems Uncountable Sets and Uncomputable functions Using reductions, can show many problems to be undecidable Goal: show that the problem A is undecidable Establish that, if there were an algorithm for problem A, then there would be an algorithm for HALT HALT doesn t have an algorithm, hence so doesn t A Claim: This is undecidable: {M: M halts on all inputs} educe HALT to this problem Given M; x construct the following machine M : M (y) = M(x) if y = x, M (y) = 0 otherwise M halts on all inputs if and only if M halts on x Correspondence between two problems Just like as they are some sets which are uncountable i.e there does not exist a one-to-one correspondence between them and the set of natural numbers, similarly there are some functions which are uncomputable. We will create a correspondence between the two problems To achieve this we make use of the following well known result of set theory.
Uncountable Sets and Uncomputable Functions Uncountable Sets and Uncomputable Functions Claim There does not exist any bijection between an infinite set and its power set Proof Consider an infinite set S and its corresponding power set P We show a contradiction if bijection f : S P Let i be any element of S and A be any element of P If bijection exists, every i S is mapped to unique A P and vice versa Consider the following set A P: A = {i S : i / f (i)} A : All i which are not present in the set f (i) Proof Cont d Now lets look at A more closely Since f is a bijection, j such that f (j) = A Here is the fatal question: Is j A? What if the answer is Yes : If j A, then by definition of A, j maps to a set which does not contain j Contradiction! What if the answer is No : If j / A, then j is mapping to a set (A ) which doesn t contain j. So by definition of A, j should be in A. Contradiction! Uncountable Sets and Uncomputable functions Claim: Uncomputable functions exist Consider each element of the infinite set to be a bit string. We know that a Turing Machine can be represented by a string. So each string represents a Turing Machine Then each element in the power set corresponds to a set of strings. We know that a language is just a set of strings, so we can represent each element of the power set by some language Since there are some subsets (elements of the power set) which map to no element in the set, there exist some languages for which there is no Turing Machine Which proves that there are certain functions which are uncomputable