Theory of Computation Lecture #6 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 39
Lecture 6: Overview Prove the equivalence of enumerators and TMs. Dovetailing Definition of Algorithm The Church-Turing Thesis. Encodings. Hilbert s 10th problem. Matijasevič s Theorem. Sarmad Abbasi (Virtual University) Theory of Computation 2 / 39
Enumerators Enumerator s are another model of computation. They do not take any input and only produce output. Let us define them formally: An enumerator E = (Q, Σ, Γ, q 0, δ). 1 Q is the set of states. 2 Σ is the output alphabet and #, Σ. 3 Γ is the work alphabet and Γ. 4 q 0 is the start state. 5 δ is the transition function. Well what is the domain and range of δ. δ : Q Γ Q Γ{L, R} (Σ {ɛ, #}) Sarmad Abbasi (Virtual University) Theory of Computation 3 / 39
Enumerators How does the a configuration of E look like: αqβ, w 1 #w 2 # w k 1 #x where α, β (Γ ) and x (Σ Σ #) Sarmad Abbasi (Virtual University) Theory of Computation 4 / 39
Enumerators Write the definition of the yields relation for enumerators. We say that E outputs a string w if it reaches a configuration αqβ, w 1 #w 2 w k 1 #w# Sarmad Abbasi (Virtual University) Theory of Computation 5 / 39
Enumerators L(E) the language enumerated by E is the set of all strings that it outputs. Sarmad Abbasi (Virtual University) Theory of Computation 6 / 39
Enumerators Last time we outlined a proof of the following theorem. A language L is Turing-recognizable if and only if some enumerator enumerates it. Sarmad Abbasi (Virtual University) Theory of Computation 7 / 39
Enumerators One side was easy: Let L be a language enumerated by an enumerator E. The L is Turing recognizable. To prove this we are given that an enumerator E enumerates L. We have to show that some Turing machine M accepts L. The informal description of the Turing machine is as follows: 1 Input x 2 Run the Enumerator E each time it outputs a string w check if w = x. If w = x go to accept state. Otherwise, continue. Sarmad Abbasi (Virtual University) Theory of Computation 8 / 39
Enumerators The other side was a bit tricky. But let us look at the details. If L is Turing recognizable then there is an enumerator E that enumerates L. Since L is Turing recognizable therefore some TM M accepts L. We can use M as a subroutine in our enumerator E. Here is our first attempt. Recall that we know how to generate strings in lexicographical order as ɛ, 0, 1, 00, 01, 10, 11,..., 1 For i = 1,..., 2 Simulate the machine M on x i 3 If M accepts x i output x i. Why is this wrong? Sarmad Abbasi (Virtual University) Theory of Computation 9 / 39
Enumerators Lets say 1 M accepts ɛ. 2 M rejects 0. 3 M accepts 1. 4 M loops forever on 00. 5 M accepts 01. Then the enumerator will never output 01. Whereas, 01 L. So, we have to get around this problem. Sarmad Abbasi (Virtual University) Theory of Computation 10 / 39
Dovetailing The solution is given by dovetailing: 1 For i = 1, 2, 3,..., 2 For j = 1, 2,..., i 3 Simulate M on x j for i steps only. 4 If M accepts x j output x j. Sarmad Abbasi (Virtual University) Theory of Computation 11 / 39
Dovetailing Suppose x t L. Then M accepts x t and it must accept x t is some finite number of steps. Lets say this number is k. Then we claim that when i = max(k, t) the string x t will be outputted. That is because M is simulated for on x 1,..., x i for i steps. Since, i t hence x t {x 1,..., x i } and since i k hence M will accept x t in k steps and x t will be outputted. Sarmad Abbasi (Virtual University) Theory of Computation 12 / 39
Dovetailing Hence all strings that are in L are enumerated by this enumerators. To see if x L then E will not enumerate it, we simply observe that E only enumerates strings that are accepted by M. Sarmad Abbasi (Virtual University) Theory of Computation 13 / 39
Dovetailing A minor point to notice is that E enumerates a given string many many times. If this bothers you, you can modify E so that it enumerates each string only once. Now, E keeps a list of all the strings it has enumerated and checks the list before enumerating every string if it has been enumerated before. Show that if L is Turing recognizable then there is an enumerator E that enumerates L. Furthermore, each string of L is enumerated by E exactly once. Sarmad Abbasi (Virtual University) Theory of Computation 14 / 39
Definition of an algorithm Intuitive notion of algorithms equals Turing machine algorithms Another way to put it: An algorithm is a Turing machine that halts on all inputs. An algorithm is a decider. Sarmad Abbasi (Virtual University) Theory of Computation 15 / 39
Church-Turing Thesis The Church-Turing thesis states that the intuitive notion of algorithms is equivalent to the mathematical concept of a Turing machine. It gives the formal definition for answering questions like Hilbert s tenth problem. Sarmad Abbasi (Virtual University) Theory of Computation 16 / 39
Encodings Note that we always take inputs to be strings over some alphabet Σ. Suppose Σ = {a, b, c, d} we can map 1 a to 00; that is e(a) = 00. 2 b to 01; that is e(a) = 01. 3 c to 10; that is e(a) = 10. 4 d to 01; that is e(a) = 11. This way we can encode any alphabet to {0, 1}. Note that this maps Σ to {0, 1} in a natural way. e(w 1 w 2... w n ) = e(w 1 )e(w 2 ) e(w n ). Sarmad Abbasi (Virtual University) Theory of Computation 17 / 39
Encodings Suppose we can define L Σ L e = {e(w) : w L}. Designing a TM for M or designing a TM for L e is equally difficult or easy. Sarmad Abbasi (Virtual University) Theory of Computation 18 / 39
Encodings We want to solve problems where the input is an interesting object such as a graph, or a matrix. However, our definitions only allow us inputs which are strings. But, this is usually not a restriction. Let us look at a few examples: L = {(i, j) : i 2 = j} (1, 1), (2, 4), (3, 9) are in L and (1, 3), (2, 5), (3, 1) are not in L. L is a subset of N N. Sarmad Abbasi (Virtual University) Theory of Computation 19 / 39
Encodings What we can do is to encode the pairs into strings. Let us say we reserve 11 to represent a 1, 00 to represent a 0 and 01 will be the separator. Then we can encode (2, 4) to 110001110000 We represent the encoding of a pair (i, j) by < (i, j) >. Then we can solve the following problem This is a language over {0, 1}. L = {< (i, j) >: i 2 = j} Sarmad Abbasi (Virtual University) Theory of Computation 20 / 39
Encodings Let us look at another example: D = {A : A is a n n with integer entires and det(a) = 0} Sarmad Abbasi (Virtual University) Theory of Computation 21 / 39
Encodings How can we encode this problem so that it becomes a language over {0, 1}. Lets say we have the matrix ( ) 2 5 3 6 Sarmad Abbasi (Virtual University) Theory of Computation 22 / 39
Encodings First we can write it as linearly as 2, 5, 3, 6. Now, we can write all the numbers in binary where 00 represents a 0, 11 represents a 1 and 01 represents the separator,. So ( ) 2 5 = 11000111001101111101111100 3 6 Sarmad Abbasi (Virtual University) Theory of Computation 23 / 39
Encodings Now, we can define the following language D = { A : A is a n n with integer entires and det(a) = 0} Sarmad Abbasi (Virtual University) Theory of Computation 24 / 39
Encodings Similarly we can encode graphs into strings: Let us do an example: Consider the graph shown in the following figure: Sarmad Abbasi (Virtual University) Theory of Computation 25 / 39
Encodings This graph can be written as a vertex list followed by an edge list as follows: 1 101 represents ). 2 110 represent (. 3 011 represents,. 4 000 represents 0 5 111 represents 1. (1, 2, 3, 4)((1, 2), (2, 3), (3, 1), (1, 4)). and now it is easy to encode this whole graph into a 0/1 string. The encoding starts as 110111011111000011111111011111 000000101110110111011111000101011110 which is very long but not conceptually difficult. Sarmad Abbasi (Virtual University) Theory of Computation 26 / 39
Encodings Thus suppose we have We can instead look at L = {G : G is connected }. L = { G : G is connected }. This should not be surprising for you. As computer scientist you know that everything inside a computer is represented by 0 s and 1 s. Sarmad Abbasi (Virtual University) Theory of Computation 27 / 39
Hilbert s Tenth Problem Recall from the first lecture: Hilbert s tenth problem was about diaphantine equations. Let us cast it in modern language. Devise an algorithm that would decide if a (multi-variate) polynomial has integral roots Here is an example of a multivariate polynomial: 6x 3 yz 2 + 3xy 2 x 3 10. Sarmad Abbasi (Virtual University) Theory of Computation 28 / 39
Hilbert s Tenth Problem Hilbert asked to study the language H = { p : p is a polynomial with integral roots}. Once again mean encodings. Is there a Turing machine M that halts on all inputs and L(M) = H Sarmad Abbasi (Virtual University) Theory of Computation 29 / 39
Matijasevič Theorem Theorem (Matijasevič 1970) H is not decidable. There is no Turing machine M that halts on all inputs with L(M) = H. Sarmad Abbasi (Virtual University) Theory of Computation 30 / 39
Matijasevič Theorem Let look at a simpler language: H 1 = { p : p is a polynomial in x and has an integral root} Lets see that H 1 is Turing decidable: Sarmad Abbasi (Virtual University) Theory of Computation 31 / 39
Matijasevič Theorem Here is the description of a TM 1 On input p. 2 for i = 0, 1, 2,..., 3 evaluate the polynomial on x = i and x = i. If it evaluates to 0 accept. Sarmad Abbasi (Virtual University) Theory of Computation 32 / 39
Matijasevič Theorem Note the the above machine is not a decider. It is only a recognizer. Show that H 1 is also Turing decidable. Sarmad Abbasi (Virtual University) Theory of Computation 33 / 39
How to describe a Turing machine There are three ways to do it. 1 formal description. 2 implementation description. 3 high-level description. Sarmad Abbasi (Virtual University) Theory of Computation 34 / 39
How to describe a Turing machine In a formal description you have to specify the whole TM using the 7-things needed. That is you have to specify (Q, Σ, Γ, q 0, q a, q r, δ). We have seen examples of this in the last two lectures. Sarmad Abbasi (Virtual University) Theory of Computation 35 / 39
How to describe a Turing machine Implementation description: In this you refer to the tapes of the Turing machine and explain how it moves and performs its task. Let look at an example A TM can be described as follows: L = {w#w : w {0, 1} }. 1 Scan the input and make sure it is of the form w 1 #w 2 where w 1, w 2 {0, 1}. Or in other words make sure there is only one # in the input. 2 Zigzag over the input matching symbols of w 1 and w 2. 3 If all symbols match then accept. If any symbol fails to match reject. Sarmad Abbasi (Virtual University) Theory of Computation 36 / 39
How to describe a Turing machine In a high level description we do not refer to the tapes. We simply describe the Turing machine as an algorithm. We simply give psuedo-code for the algorithm. Suppose we wish to show that L = { j : i 2 = j for some i}. A description of TM can be given as follows: 1 On input j. 2 For i = 1,..., j 3 check if i 2 = j if it is accept. 4 Reject Note that in this case, we are assuming many things. Sarmad Abbasi (Virtual University) Theory of Computation 37 / 39
How to describe a Turing machine We are assuming that we can build a machine (subroutine) that can multiply numbers, check for equality etc. Sarmad Abbasi (Virtual University) Theory of Computation 38 / 39
How to describe a Turing machine When you give a high-level description you must be convinced that you can convert it into a formal one in principle. Although it will take a very long time to do so. Sarmad Abbasi (Virtual University) Theory of Computation 39 / 39