 So, in this lecture we discuss undecidability. We are curious to know that given any problem whether the problem can be solved or cannot be solved at all. So, if the problem is solved we say that it is decidable otherwise it is not decidable that means undecidable. So, we have seen that some problem already seen that there are some problems which are decidable and it was shown by giving Turing machines which holds on every input to decide the corresponding language. That means, there is a decided Turing machine to accept the corresponding language. So, for every problem we will have the corresponding language and if that language can be decided by a Turing machine then we say that that problem is solvable or decidable. So, today we will see undecidability. Now, a problem P is said to be unsolvable if there is no algorithm for P that means the language of P that is the language of P is undecidable. The corresponding language for a problem P which we denote like this in bracket angular bracket is undecidable that means there is no Turing machine that holds on any input accepting P that is what we say. Now, showing that a problem is decidable we can construct a Turing machine that is a decider to decide that language, but in to show that a problem is undecidable we should show that there is no Turing machine which can decide the corresponding language. So, constructing a Turing machine which a decider for a given language may be easy in some cases, but showing that no such Turing machine exists for a given language is not that easy. Therefore, given a problem to show that it is undecidable it may not be very easy to show that the problem is undecidable. Now, there another way to show that suppose that we have a problem already have shown it to be undecidable then there is a way to prove that some other problem is undecidable by using a tool by which basically translates from one problem to another and that is what is said to be reducibility. Now, reducibility is used to prove that if one problem is undecidable then some other problem can also be is also undecidable. Similarly, if some problem is decidable then some other problem is also decidable. So, let us formally define reducibility say L 1 is a language and L 2 is a language. So, L 1 is subset of sigma 1 star sigma 1 star and L 2 is a subset of sigma 2 star. So, the L 1 and L 2 these two are two languages we say that L 1 is reducible to L 2 and written as L 1 reduces to L 2 we use this less than equal to sign to indicate that. So, we say that L 1 is reducible to L 2 if there is a compatible function f from sigma 1 star to sigma 2 star such that for any string x any string x belongs to L 1 if and only if f x belongs to L 2. That means, since we say that there is a compute function is computable that means there is a Turing machine say M f that takes any string x that belongs to belong to sigma 1 star as input and translates it by means of f that means f of x to a string that belongs to L 2. So, if x belongs to sigma 1 star if x belongs to L 1 then f x belongs to L 2 similarly, if x does not belong to L 1 then f x does not belong to L 2. So, that is what the computable function does. So, if satisfies that then we say that L 1 is reducible to L 2 via this function comparable function f. Now, once we have this from this we can show that suppose L 1 is reducible to L 2 and L 2 is decidable then we can show that L 1 is also decidable. So, we can prove it by this since L 2 is decidable there must be an algorithm say M 2 that decides L 2 that is our assumption. Now, L 1 reduces to L 2 since L 1 reduces to L 2 there is a compatible function say f such that x belongs to L 1 if and only if f x belongs to L 2. Say M f with a Turing machine that computes f as we have given earlier there must be a Turing machine to compute this function f say M f is the function. Now, we will have M 1 the Turing machine which is a composition of M f and the algorithm M 2. So, M 2 is a Turing machine it is a algorithm beside similarly M f is a Turing machine which computes a function f. So, M f composition M 2 is the algorithm M 1. Now, we show that M 1 is basically an algorithm for L 1 that means L 1 is also decidable that is what we want to show. So, how to show that M 1 is an algorithm that decides L 1. Now, we have M 2 it takes some input and answers yes or no if answers yes if that input belongs to L of M 2 if it does not belong to L of M 2 it says no and M f computes the function f it takes an input x and it outputs f x. So, if x belongs to L 1 then f x belongs to L 2 if x does not belong to L 1 f x does not belong to L 2. Now, we have this composition of these two Turing machine just combine these two Turing machine M f and M 2 to have M 1. So, this M 1 takes any input x belong to sigma 1 star. So, here we use the Turing machine M f to compute f x and gives f x input to M 2. Now, since M 2 will always say either yes or no. So, whenever M 2 says yes M 1 also says yes whenever M 2 says no M 1 also says no. So, therefore, given any string x belong to sigma 1 star M 2 always will say yes or no. Therefore, M 1 also says yes or no and whenever it says yes. So, if x belongs to L 1 then f x belongs to L 2 and then M 1 outputs always yes that is the because since f x belongs to L 2 M 2 always say yes. So, therefore, M 1 also outputs yes because whenever x belongs to L 1 M 1 always outputs yes. Similarly, if x does not belong to L 1 suppose x does not belong to L 1 in such a case f x also does not belong to M 2. Since f x does not belong to L 2 M 2 says that no whenever M 2 says no M 1 also says no. Therefore, M 1 outputs no. So, therefore, whenever x belongs to L 1 M 1 outputs yes and whenever x does not belong to L 1 M 1 outputs no. Therefore, clearly M 1 is an L guard and M 1 decides L 1. So, therefore, L 1 is a decidable language assuming that L 2 is decidable. So, from this clearly we can say that now as a corollary if L 1 reduces to L 2 and L 1 is undecidable then so is L 2 L 2 must also be undecidable. So, you can use the same concept suppose we can use it I mean you can prove it by contradiction. Suppose that L 2 is decidable then we have M 2 for L 2 and always say yes or no on some input and then we can use the T unison M f which computes f. So, given any string x we first give it as input to M f which outputs f x. So, if x belongs to L 1 then f x belongs to L 2 if x does not belong to L 1 then f x does not belong to L 2. Now, this will f x will we use as input to M 2 and whenever M 2 says yes we say that M 1 also outputs yes and if M 2 says no then we say that M 1 also outputs no. Now, in such a case assuming that M 2 is decidable we now have an algorithm for L 1 if M 2 is decidable then so is L 1, but since L 1 is undecidable already we know that the no such Turing machine M 2 which are decidable for L 2 can exist. So, therefore, L 2 must also be undecidable. So, it is a simple corollary from the previous one. Now, you can take it as a exercise to show that if L 1 is reducible to L 2 and L 2 is reducible to L 3 then L 1 is reducible to L 3. That means, it satisfies the transitivity property. Now, what we can show is that to show that a language is a language L is undecidable we reduce an already known undecidable language to L that is how we can use this technique irreducibility. That means, you can apply this reduction from L 1 to L 2 to show that L 2 is undecidable whenever it already given that L 1 is undecidable. So, L 1 is already known undecidable problem we reduce L 1 to L 2 to show that L 2 is also undecidable. So, that is how we can use this technique irreducibility to show that some problems are undecidable. Further, we can use this transitivity property to show that some more problems are undecidable. So, more undecidable languages can be shown to be undecidable by using this transitivity property through reduction. Now, to prove that a problem is undecidable by using reduction we must have some already existing undecidable problem. So, we will first see one such problem which is undecidable. Let us consider the problem of membership for Turing machines already we have seen the membership problem for regular languages for connected languages. That means, given in string x and a language regular language L whether or not x is a member of L that is a membership problem for regular language. Similarly, we can define the membership problem for connected languages both these two problems have been shown to be decidable in the previous lecture. We know that we can construct an algorithm that means a Turing machine is a decider to decide the corresponding languages for those membership problems. But if we now consider the membership problem of Turing machines we can show that this membership problem of Turing machine is undecidable. So, the problem is given a Turing machine m and an input string x whether or not m accepts x. So, in this case m accepts x means it holds on every input x. So, whenever x belongs to a l m it says that it is yes otherwise it says no. The corresponding language is that m t m it is a encoding of all those strings m x where m is a Turing machine and x is a string and x belongs to l m. So, these are corresponding language for the membership problem of Turing machines. We also say that these are halting problem for Turing machine because the Turing machine has to halt on each and every input. We want to show that this halting problem is undecidable that is there is no algorithm for m t m. Now, whenever we say that this m x within angular bracket that is encoding for the Turing machine m and x. So, we have already seen how to encode a DFA. Similarly we can also encode any given Turing machine because the Turing machine will have a finite number of states a finite set of symbols which is alphabet. The way we encode it the states and the symbols in case of DFA can be used in this case also. That means if say q 1, q 2, q 3 these are all set of states for Turing machine. Then you can use a sequence of strings that means for q i we use 1 to the power i that means a sequence of 1 i 1 to encode the state q i. Similarly, if we have a 1, a 2 they are all symbols of the alphabet then a i will be dependent as 1 to the power i sequence of i 1. And we know that the transition function for Turing machines can be even dependent by a quadruple that means since we know that it is a q 0 some symbol a from here it can go to say some state q 1 that means l or r or whatever. So, you can write it as q 0, 0, q 1, l. So, this is the simply say q 0, a, q 1, l. So, by this quadruple we can represent the corresponding transition. So, for Turing machine we have a sequence of such transitions say this transition 1, this transition 2 and so on. So, all these transitions now can be say k transitions encoded by using a sequence of 0s and 1s. So, once we have a sequence of 0s and 1s for T 1 the way we did in case of DFA. So, T 1 and T 2 can be separate by say 3 0s, T 2 and T 3 can be separate by 3 0s. We can represent this lab bracket by 3 0s and so on. Even so we have 3 0s at the end of this. So, in any transitions a T i the symbols say q 0, a, q 1, l whatever we have in T 1 the encoding for each can be separated say T i is q 0, a, q 1, l. So, what will have q 0 will be say 1 power 1, a may be say 1 power 1. So, 1 power 1 and 1 power will be separate by say single 0 and similarly will be separate by single 0 then the code for q 1 it may be 1 power 2, single 0 say l may be 1 power 1 or whatever. So, therefore, this may be code for say T i and so on. So, it is transition will be separate 2 transitions separate by 3 0s or it may be say 2 0s as similar to DFA and even say when it ends it will have a sequence of 3 0s. So, we can use the same approach that we used in case of say DFA to encode a Turing machine and at the end of this after this we can give the corresponding sequence for the into string x. So, we have a way to represent or encode this string m x. So, the problem is when the show is that this is undecidable. Now, to show that this is undecidable that means there is no algorithm for m t m we first give a language which is not even recursively enumerable before showing that there is a does not exist any Turing machine for this language for this language m t m which is decided we want to first show that there exist a language which is not even recursively enumerable. That means there is no Turing machine that recognizes that language then we come back to this our original problem of showing that m t m is undecidable that is there is no decider for m t m. Now, to show that the original language which is not even recursively enumerable we first encode all the Turing machines as sequences of 0s and 1s. So, there will be infinite number of Turing machines. So, you can encode all these Turing machines. So, since Turing machines are sequences of 0s and 1s. So, the code of a Turing machine will be a member of sigma star where sigma is equal to 0 and 1. Now, these sequences of Turing machines can be ordered using some ordering. For example, suppose if the alphabet is 0 1 since we have Turing machine codes which is sequence of 0s and 1s. So, any Turing machine code will belong to that sigma 1 star. So, any Turing machine code will belong to the sequence of sigma 1 sigma star where sigma is 0 1 contains 2 symbols. Now, we can have an ordering of all the strings over 0 and 1s. For example, say it is alphabetical ordering considering that or you can say canonical ordering. So, where strings are ordered according to the alphabetical ordering, but the strings of shortest length will come first. That means, in this case the ordering will be say initially it will be epsilon where the string has length 0. Next string of length 1 there are only 2 possible cases 0 and 1. The string of length 2 we have 4 such strings and those 4 such strings will come in alphabetical order that means 0 0, 0 1, 1 0 and 1 1. Next we will have strings of length 3, again in alphabetical order say 0 0 0, 0 0 1 and so on finally, say 1 1 1 and then strings of length 4 and so on. So, therefore, we consider say it is a canonical ordering. So, all the Turing machine codes can be ordered using this kind of canonical ordering. So, Turing machine sequences will be ordered in canonical order. So, Turing machine M will be encoded by this M in angular bracket and since we ordered this in some canonical order. So, we put in the ordering say M 1 comes first, next comes M 2 and so on. Similarly, all the input strings x 1, x 2, x 3 will be ordered using some using a same canonical ordering and we put here in the sequence. So, accordingly we get a table arranging x in the column and M in the rows. Now, in this table we see the entries we fill up the entries, we fill up the entries, we fill up the entries in such a way that the i z entry is 1. If x j belongs to l of M i, since we are talking about i z entry. So, row i we have the corresponding machine Turing machine M i and column j we have the string x j. Now, if x j is accepted by the Turing machine M i, we just fill up that entry by 1, otherwise if x j does not belong to l of M i then we that corresponding entry will be 0. So, that is how we fill up all the entries. So, in this case M 1 accepts does not accept x 1. So, therefore it is 0. Say M 1 accepts x 2 that is why it is 1. Suppose M 1 accepts x 3 will be 1. Suppose that M 1 does not accept x 4. So, it will be 0 and so on. So, M 2 accepts x 1. So, it is 1, M 2 accepts x 2. So, it is 1. Suppose M 2 does not accept x 3 that will be 0 and so on. So, we fill up all the entries of this table according to this rule. So, please know that we have a sequence where we put all the Turing machine codes M 1 through M 1 M 2 and like that. Similarly, we have a sequence where we put we have ordering where we put all the strings of the sequence. Now, we consider language. So, that language is named as L D. So, L D is a set of all strings over 0 1 star all the string x over 0 1 star such that x is x i for some index i and x does not belong to l of M i. That means x does not belong to l of M i. That means all those strings x i such that x i does not belong to l of M i. That means it contains the entries from the diagonal because we are talking about x i does not belong to l of M i. So, we will consider the entries from the diagonals. So, if x i does not belong to l of M i then this is a member of the language L D. That why it is said to be diagonal language. Once we have defined a language L D that means L D contains those strings x i such that i i at entry in the table is 0 because we have used this rule. So, there is 0 if x i does not belong to l of M i and we are talking about the diagonal entries. Now, we will show that this language L D is not recursively enumerable. So, there is a word claim. So, language L D is not recursively enumerable. That means there is no tilling machine that recognizes this language L D. Now, to show this we assume that there is a tilling machine M that recognizes L D. That means say M is a tilling machine that recognizes L D, L M equal to L D. So, this is for contradiction. Assuming that there exists a tilling machine M such that L D equal to L M we arrive at a contradiction. So, if M is a tilling machine then M must appear in the ordering that we have already said say M 1, M 2 they are all tilling machine codes and so on. So, this M must also appear somewhere in the ordering say it is M k for some k. That means we identify the index of M say k such that M equal to M k. So, this M must appear in the ordering. Now, once we have found out this index k for which M equal to M k we ask the question whether x k the corresponding string x k for that k belongs to L D or not. Whether x k is a member of L D we ask this question. Suppose x k belongs to L D it may belong to L D. In such a case according to a definition the k k at entry in the table must be 0. This how we have defined. If k k at entry is 0 that is how we have defined this L D. If k k at entry is in the table is 0 what it says the way we fill up the table it says that x k does not belong to L of M k because that is how we defined the rule of over here. If it belongs to L of M i then it is 1 otherwise it is 0. So, if x k belongs to L D k k at entry in the table is 0 it says that x k does not belong to L of M k. That means x k does not belong to L of M because M is M k. Therefore, it says that x k does not belong to L D according to a definition again for L D. But this is a contradiction because we say that x k belongs to L D. Assuming that x k belongs to L D we have elected a contradiction that x k does not belong to L D. Similarly, if we assume that x does not belong to L D we again arrive at a contradiction because if x does not belong to L D k k at entry must be equal to 1 according to a definition of length language L D. If that is the case if k k at entry equal to 1 then according to our rule that we used to fill up the table entries we know that x k does x k belongs to L of M k that means x belongs to L of M. But according to again the definition of L D we know that x k now belongs to L D again a contradiction. So, in both cases whether x belongs to L D or x k belongs to L D or x k does not belong to L D we arrive at a contradiction always. Therefore, such a machine Turing machine M recognizing L D cannot be there does not exist such a Turing machine M accepting L D or recognizing L D does not exist. So, this must be the case that means our original assumption of such a Turing machine to recognize M must be wrong. Therefore, L D is not recursive and irreversible since there is no Turing machine recognizing L D L D must be not recursive and irreversible. Now, we use this language L D which is not recursive and irreversible is already shown to establish that the halting problem is undecidable. We have again come back to our original problem of showing that halting problem is undecidable for that we will be using this diagonal language L D. Now, we assume that for contradiction the halting problem is the halting problem M T M is decidable. So, that we have assumed for contradiction. So, since M T M is decidable there must be an algorithm say it is A h that decides M T M. So, for contradiction we have assumed that halting problem is decidable. So, therefore, we must have an algorithm that decides M T M and that algorithm is A h. So, that means if A h is the algorithm given any input string M and x encoded where M is a Turing machine and x is a string. A h will always say yes if x belongs to L M and A h will always say no if x does not belong to L M. So, then algorithm it will always have an yes and no answer if M accepts x it will say yes if M does not accept x it will say no. So, this is an algorithm for h. Now, we use h to construct an algorithm that x that decides the complement of the language L D L D complement. So, if complement of the language L D is decidable because we have we can construct an algorithm then since we have an algorithm for complement of L D that means L D complement is must be decidable. If L D complement decidable this implies that L D must also be decidable because that decidable language are closed under complement because if we have an algorithm for a language then its complement can also be decided just by complementing or reversing the output. But, we have always found that L D is not even recursively any variable. Therefore, our original assumption that such an algorithm a h exists to decide M T M is wrong. That means, since we have arrived a contradiction or original assumption that such an a h exists to decide M T M must be wrong. Now, let us see the algorithm for complement of L D to decide the complement of language L D by using the algorithm for M T M. So, this is a h algorithm for the halting problem given any input say m k x k encoding of a Turing machine and x k it will always say yes or no depending on whether x k belongs to m k it will say yes if x k does not belong to m k it will say no. Now, the algorithm for L D complement is M we use in M this algorithm a h M tracks a string x as input. Then it uses a machine which is an index machine that finds out the index k such that x is x k in the sequence. In the sequence we have arranged all the strings in some order which is called say canonical order. So, what the index k will be decided by this index machine and that is always possible a Turing machine can always do that. Once it has found out this index k there is a constructor Turing machine that constructs the sequence m k and x k that is also always possible if we know the index k was a corresponding Turing machine for that k m k and the string x k. So, this will be given this will be given as output this will be an output for c and this output we use an input to the Turing machine algorithm say a h and whenever a h say yes m also says yes whenever h says no m also says no. Now, suppose that this m says yes on x. So, when says m when m says yes on x we know that x is x k it must belong to L of m k because a h says yes whenever x k belongs to L of m k. That means k k at entry is 1. So, x belongs to x k belongs to L of m k if and only if k k at entry is 1. If and only if x belongs to L d complement. So, that is our definition of L d complement. Similarly m says no on x on the string x if and only if x k does not belong to L of m k. So, this m will say no if and only if this m k x k entry is rejected by a h that means x k does not belong to L of m k if and only if k k at entry is 0 and by definition if and only if this x k or x does not belong to L d complement. So, therefore, we have whenever say given an input x to this machine m will always have yes or no answer depending on whether x belongs to L d complement or x does not belong to L d complement. So, therefore, this is clearly an algorithm for L d complement. So, since now we know that we have an algorithm for L d complement, but we already know that since we have an algorithm for L d complement we have also an algorithm for L d because the this closed under complement, but we know that L d is not even recursively any more. Therefore, our original assumption that such an algorithm h exists for deciding the halting problem is wrong. So, no such algorithm exists to decide this halting problem. Therefore, we have proved our original claim that halting problem is undecidable. Now, given any other problem which undecidable we can reduce this halting problem to that problem to show that the given problem is also undecidable. Now, consider the following problem for a given turing machine say m is a turing machine we consider following problem. So, whether or not l m is empty that is language except by the turing machine is empty whether or not the language except by m is finite whether or not l m is recursive or is l m regular or whether the language except by the turing machine is context free. We want to know whether these problems are decidable or not. The corresponding language problem the language for those problems can be written as say E t m emptiness for turing machines set of all those encodings of turing machines such that l m is phi. Similarly, finiteness set of all those turing machines say m such that l m is finite. Similarly, recursive set of all turing machines m l m is recursive or say l m is context free that way you can find out or denote the corresponding languages. We can show that all these problems are basically undecidable to show that these problems are undecidable. We need to reduce each and every problem or I mean we can reduce halting problem to each and every problem. Since halting problem is already undecidable these problems are also undecidable. Now, instead of giving separate reactions for each of these problems what we can do is that we will give a general theorem that using the theorem we can show that each and every problem is that we have already stated these are all undecidable. Now, this general theorem is said to be your Rice's theorem. So, what it says is that a property that describes a proper subset of recursively enumerable languages in undecidable that property it may be any property like say it is finite finiteness or emptiness or whether it is regular recursive these are all properties. The set we subset from say sigma star is a recursively enumerable language we say that there is a property a property and there is a proper subset only the emptiness and the whole set these are not proper subsets and these are decidable in the sense that suppose we consider the whole set just take the example suppose in a university there are some faculties lots of faculties we have and there suppose there is only one department say it is computer science department. Now, if we ask the question given a faculty say there is a faculty here is a faculty where are he belongs to where is a computer science faculty. So, this is quite obvious because the we are considering a whole set the set of faculties and there is only one department. So, it is quite obvious that the faculty must be from computer science department similarly if you do not give any then that is also obvious there is an emptiness other than that any other set which a proper subset of recursively enumerable language and we can show that a property that describes a proper subset of recursively enumerable language is decidable. That means say p be a property that describes a proper subset of recursively language say s is a property a set of all languages l such that l is recursively enumerable that satisfies p. So, that is how we this set represents a property such that as a proper subset of all recursively enumerable languages. Now, we write the language for s like this say this is l s the set of all Turing machines such that l m satisfies p m is a Turing machine. So, m is a Turing machine and l m satisfies p. So, what we want to show is that this language l s is undecidable is a proper subset and this satisfies this for all those every Turing machine m satisfies this this l m satisfies this property whatever we describe say that language is recursive or that language is regular or that language of a Turing machine and like that and we know that these are must always be a proper subset. For example, say emptiness there are many Turing machines some might accept empty language and many Turing machines which may not accept empty language. So, therefore, we consider all those Turing machines some accepts the empty language and some do not accept empty language. So, therefore, that set is basically a proper subset of recursively enumerable languages. So, we want to show that this language l s is undecidable if we can show that this language l s is undecidable. So, any property related to recursively enumerable languages will be undecidable any property means it must be say subset of proper subset of recursively enumerable languages. So, we will consider this proof in the next lecture.