 we continue our arguments that will show that there are non recursively enumerable languages. We recall that we said that the proof will be by a diagonalization argument and to begin that argument first thing we need to prove is this fact that all possible theme which accept languages over sigma you know sigma is a fixed alphabet. So, all possible themes which accept languages over sigma that is all those languages which are subsets of sigma star these Turing machines can be lined up what we mean by lined up that you can imagine we have a sequence m 1 m 2 m 3 m 4 etcetera these are all Turing machines and each one of these l m 1 l m 2 these are languages accepted by the corresponding Turing machine. And all these languages are languages over sigma that is one thing. So, that means each one of these Turing machines accept some language could be empty could be sigma star. So, they all accept languages over sigma and the other thing is that this enumeration this listing is exhaustive in the sense that if there is any language which that is consider any language which is over sigma. So, for that language if there is a Turing machine to accept it that Turing machine will occur somewhere in this enumeration. Now, so that would mean what so the two things that we are saying that all these are Turing machines which accept languages over sigma and any Turing machine that accepts some language over sigma will come somewhere in this enumeration which really means if you see immediately this point that the all the are languages which are over sigma they can be thought to be in this defined through this enumeration because you know they are an r e language over sigma they must by definition be a Turing machine to accept that r e language. And because of the property that we said that somewhere down the line that that Turing machine would occur. So, therefore, the list of corresponding r e languages as we have put the shown the correspondence that list will also have all languages which are r e over sigma. Now, what we show by diagonalization that language that we construct is different that language we call it l d d for diagonalization is different from each one of these. And therefore, l d is not r e over sigma because had it been an r e language then they would have been a Turing machine to accept it. And that Turing machine would have occurred somewhere down the line and then the corresponding language would have been here in this enumeration. But since our construction will be such that that it will be different from each one of these languages l d is not r e and by construction will see l d is also a language which is over sigma. So, the first point is this the enumeration of all Turing machines that accept languages over sigma. And that we show by showing that each one of this Turing machine can be encoded as a string. And this is a very important point that every Turing machine can be encoded equivalently you can think of represented by a finite string. What we are saying is you give me any Turing machine I will find the finite string which is the encoding or which is the representation of the Turing machine. Now, of course, we know a Turing machine is what Turing machine can be seen as what defines a Turing machine recall Turing machine M as a set of states then it has input alphabet sigma tape alphabet gamma then of course, transition function then it has initial state we need to specify. Then it will also have a symbol which we called blank because those are the that particular symbol will be there initially in most of the tape. And then of course, it will have some final accepting states this will be a Turing machine. Now, recall that this delta we can be represented by means of a set of quintuples. Now, if I just give you the set of quintuples corresponding to a particular Turing machine M from there you can figure out what are the what is this set which is the set of states what are the tape alphabet recall that input alphabet by default is sigma that is standard. The things that you do not have this information that which are the which is the initial state which is the blank symbol and which is or the set of final accepting state. So, first of all we will figure out how to represent that but first of all that the set of quintuples can be represented can be represented by finite stream. Now, remember this is possible because this set of quintuples for any Turing machine M that is a finite set. So, let us what is a quintuple we can think of a quintuple as quintuple by definition of course, is a 5 tuple and these 5 things are present state current symbol scanned then next state and then the symbol written on the square which you are scanning at that particular step and move by this mean whether the after writing the symbol whether the Turing machine will move one square to the left or to the right. Now, supposing the present state is q i the current symbol that you are scanning is the j th symbol the next state is k th state symbol that you are writing is s of l and the move is d, d can be left or right and each one of this can be coded as some number. You see for example, I can think of representing by i the number i the state q i it is very clear what the names of states are unimportant. So, long I have some ways of differentiating each of these states from other states. So, imagine that I am naming states as really numbers. So, state q i is the number i that is its representation same with symbol the symbol is j I can represent by a number j and this of course, will be represented by a number k this will be represented by a number l and the move is either 0 or 1 0 for maybe left move and 1 for right move. Now, we are continuing proving this fact. So, one particular quintuple can be represented just by means of this five numbers. Now, suppose I choose to represent these numbers in unary take a particular example, let us say this is the this is the fifth state we have the number five the symbol is second symbol it goes to third state writes the fourth symbol and it moves to right. So, the five numbers five two three four one would capture this quintuple. So, as I said will suppose I write these numbers in unary. So, five I will have to put you know in unary you put five ones plus one. So, six ones to represent five because the number 0 you will represent by just one and so on. So, for two you will have three ones that is the unary representation of two for three you will have four ones for four again you will have five ones and then I said one that is the right move we will have two ones. Now, what we can do is to separate these by zero right. So, a binary string therefore, represents the information contained here right and now you want to represent a set of quintuples. So, supposing the representation of one quintuple in a binary string let us say is you know quint one this is our representation of first quintuple which will be a binary string notice in that binary string two zeroes are never consecutive then you have quintuple two. Now, you can separate them out by putting two zeroes in between. So, a set a finite set of quintuples can be represented by means of a binary string the idea is very simple the two consecutive zeroes will separate the representation of quintuples and in the each quintuple a single zero will separate two parts of a quintuple. So, this is you can imagine that this therefore, will represent this idea is a very simple idea will represent any finite set of quintuples does not matter how big this set of states is or how big the set of symbols is because we are after all each such set is finite. So, there will be some finite representation of quintuple the total number of quintuples for a Turing machine will be finite. So, therefore, we have a binary string to represent all the quintuples notice this has all this information like the set of states set of symbols these informations we have we do not have in this representation what is the initial state neither we have information what are the final states. So, that these two pieces of information we can keep implicitly. So, let us say we just choose arbitrarily, but fix it once for all that the state zero or rather if you think q zero that means the number the state whose representation is the number zero is the initial state and you also do not have an information about what is the or what are the accepting states. So, again without loss of generality you can assume that the state q one whose representation will be the number one that is the only. Now, suppose you had a Turing machine which had many accepting states from there wherever the machine enters such an accepting state instead of halting there you go to a special state and halt there and say that is the accepting state. So, it is not difficult at all even if the original machine had a number of accepting states to define another Turing machine with a single accepting state which will be so far as the language recognized is concerned same way you know if you somebody had designed it to Turing machine which is not in which q zero is not the initial state you can just map do a simple map and go up some state with q zero and that would be the initial state. So, these things you can have without loss of any generality now only thing we have not said what is the blank symbol again we can arbitrarily choose one particular symbol to be the blank symbol. So, let us say the symbol you know is to present. So, once I have these implicit understanding or convention in place then I can claim what is that claim is this that binary string by a finite string and in fact over the alphabet 0 1 it is a binary string finite binary string will encode Turing machine what more you know just to make our life very simple. So, what we have said for every Turing machine we have a binary string to represent it now I would like to make it go the other way also I would like to say that every finite string represent some Turing machine. So, right now we will say how is that possible you know a string like 0 0 0 0 what does it represent after all there are no quintuples I can see in this etcetera. Now basically any such string which is not really representing a set of quintuples in this manner I choose to call them to represent I choose to say that this they represent a Turing machine which accepts the empty language. So, now we say that any ill formatted binary string. So, what do we mean by ill formatted which you do not see as representing a set of quintuples and that is easy to see even such a string you can easily figure out whether it is ill formatted or not we are now saying any ill formatted string is said to represent a Turing machine which accepts no string. So, basically which accepts the language fine that is the empty string. So, put together all these what I am saying is every finite binary string is a binary coding or representation language over sigma and for every Turing machine that accepts some language over sigma we have an encoding. So, now once you believe this statement then we have this situation just think of a canonical ordering of all binary string all finite binary string you know such a canonical ordering is you can one possibilities that you consider the strings to be ordered in lexicographically you know with the smallest first string so basically first you will have the empty string then 0, then 1, then 0, 0, then 0, 1, 1, 0, 1, 1, 0, 0, 0 and so on. Now, we are choosing to consider each one of these strings to be representing a Turing machine which is accepting some language over sigma. So, therefore this I can see as enumeration all Turing machine or enumeration of codes of all t m accepting languages over sigma. So, this is that and of course, we also can enumerate the same manner this set of all finite binary string. Supposing we do that in this fashion same enumeration except our understanding of these is that they are string binary string and these are Turing machine representations with accept languages. Now, without any loss of generality you can assume that both these symbols will be in so our input alphabet as both these symbols 0 and 1 this is you can assume loss of generality. Now, you see in a manner of writing this what I am defining is a kind of matrix which is a called it a and the entry a i j corresponds to what the ith Turing machine and the j th binary string and let me define it this way conceptually of course, no these are this is going to be an infinite matrix and nobody is going to fill it up. Conceptually imagine that you have defined the entry in this matrix in the following manner that a i j is going to be 1 if write it this way 1 if the Turing machine i accept the j th binary string that is in this enumeration j th means the j th string here is enumeration and 0 if it does not. So, just so basically now our job will be fairly easy job of describing l d the language which we define and which will show to be not recursively enumerable that l d is something let us say we define here definition of l d into l d is a binary string x. So, x will be the set of all x s all those x s will be in l d which will satisfy a certain condition and what is the condition the C m whose code will be given to us. So, what is the condition is x does not the string x. So, you see it is like this a string x is let us say the j th string right. Supposing x is the j th string there and then we look at the j th Turing machine here and we are concentrating about what is the behavior of the j th Turing machine on the j th string. So, in a way we are talking of the diagonal elements of this matrix which will define whether or not that particular string is a member of l d. Now, the claim is l d is not recursively enumerable suppose it is in by definition then by definition there is a Turing machine. Now, that Turing machine will come somewhere in the enumeration of all Turing machines which accept languages over sigma. So, let us say that let m be the number of strings which is the number of strings the r th our enumeration. Now, consider let x be the r th binary string is a fairly simple thing what we are saying that if l d is recursively enumerable then there is a Turing machine somewhere whose code is somewhere down this line would accept l d let that Turing machine be the r th Turing machine in the sense the r th binary string here represents that particular Turing machine and now we are considering x to be that r th binary string. So, do you do you understand that we are making we actually looking at a string in two ways that string as a string also that string as a encoding of a Turing machine. So, now, there are two possibilities are there what are in the sense that either this x x is in l d or x is not in l d now consider each of these cases separately. Supposing x is in l d that means what x would have satisfied this condition and the what is that condition? Why it again since x is in l d only those strings which will are in l d which satisfy this particular condition what is this condition saying the Turing machine whose code is x, but what is that Turing machine that Turing machine is m does not accept x. So, if x is in l d then from the definition of l d we have that m does not accept x, but then it is clear that the language accepted by m is not l d because we said that m is the Turing machine which accepts l d all right. So, this case leads us to a contradiction because x is in l d that means what if you x is accepted it should be accepted by m, but then we are seeing that l m is different from l d. So, the other possibility is x is not in l d, but if we x is not in l d that means what x is not in l d would mean that x or you know to look at it this way the R H Turing machine accept the R H string, but what is that R H Turing machine R H Turing machine is of course the machine m. So, I can say m would accept the R H string and of course the R H string is what is x. So, now here is a string x which is accepted by m which is not in l d. So, therefore, again I can conclude that the language accepted by m is different from l d all right. So, these are the only two possibilities either x is in l d or x is not in l d in either case assuming each one I am going to a contradiction. Therefore, what can I conclude I can conclude that this supposition is false we said that suppose l d is recursive. So, this proves by contradiction that l d is not recursive. You know I mean if you look at that proof once more you will see our construction of l d or our definition of l d what do I want in defining l d I want l d to be not an R E language. So, I should have l d is not the language l m 1 where m 1 is the first Turing machine in our enumeration of all Turing machines that accept languages over sigma. Similarly, I have to ensure that l is not l m 2 l d is not l m 3 l d is not l m 2 l d is not l m 3 l d is not l m 3 l and so on right which is the string. See for each one of this we have a witness of this fact if you see that the second string in this case or third string consider the third string in the enumeration of all binary string. Let it be x let x be the third string in the enumeration of all binary string and that of course, represents the machine m 3 also. Now what we have said that we will put x in l d if and only if x is not in the language accepted by the machine whose code is x. But since x is the third string in the enumeration this machine is also the third Turing machine that is how we have to define right. We are we are we will put x in l d provided x is not in l m 3 will not put x in l d if and only if x is in l m 3. So, this string x which is the third string in the enumeration is the witness of this fact. So, essentially what you have done by your definition of l d that you have a string which witnesses the correctness of each one of these assertions. Since l d is not the language accepted by any of these Turing machines and since all these Turing machines collectively exhaust the class of all Turing machines which accept languages over sigma we get to the fact that l d is not recursively enumerable. So, this is our diagonalization proof that there exist recursively enumerable there exist languages which are not recursively enumerable. Let us now define new class of languages and that class is called recursively the definition we will see a language l is recursive there is a Turing machine that one accept l and two halts on every. Now, you contrast this definition with recursively enumerable there we said a language is recursively enumerable if there is a Turing machine that just accept that we did not insist on whether it halts on all every input or not. So, if you contrast a recursive language with a recursively enumerable language the difference is this that whereas, a recursive language you will always have a Turing machine which will halt on each input. So, whether the input is in the language or not the Turing machine that accepts the language will always halt whereas, in case of R e if the language is R e what all we said was that there will be a Turing machine which will accept the language of course, acceptance means the Turing machine will halt on all input which are in the language. But if the input is not in the language then we are we have said nothing in fact the Turing machine can go into an infinite loop and that is one way of rejecting its input because it is not in the language. Now, why do we make this definition because you go back to our notion of a computational problem what is the computational problem computational problem is something for which we require an algorithm to solve it. For example, the computational problem would be given two numbers compute the GCD of course, you cannot do it by means of a table you have to have an algorithm to compute the GCD of two numbers. So, a solution of a computational problem if it exists is an algorithm and a special class of computational problem is decision problem and a decision problem is one where you have to decide that means you have to just say yes or no. So, we will have two output we will have two output yes or some inputs and no for some input. Now, a particular class of this decision problem will be membership decision problem we had talked about these things earlier, but let us once more go over this idea that a membership decision problem essentially is there is some you have some set A in mind you have the problem the computational problem of deciding given something whether that is an element of the set or not. So, your algorithm will be you know it will take some input and the output will be yes if x is in A and no if x is not in A. Of course, we have many many examples of decision problem which are basically membership decision set membership decision problem. For example, you would like to decide primality of a number. So, given a number you would like to decide whether it is prime or not. So, you would like to output yes if the number is prime. So, A here is the set of all prime. So, you will say yes if x is in A no if x is not in A that means x is not a prime. So, clearly you can do this. So, this is the decision problem for A membership decision problem for the set A to have such an algorithm and my point is that such an algorithm decides membership of A exists if and only if A is. So, what am I saying is that in this side I mean I put a line it is to say this is the domain of problem and this is the domain of language. The correspondence that I want to emphasize is the existence of a decision algorithm like this corresponds to the recursiveness of some language. So, in this case the membership decision problem for A is can be done by a program like this an algorithm like this if and only if A is recursive. So, another term we have something is such a problem such a problem which admits an algorithm is called computable or decidable. So, once more what is the point I am making I am saying that if an algorithm decides membership decision problem then is called decidable. So, decidable is an adjective which will use in the context of problem and that to decision problem. If you have an algorithm to solve a decision problem you will say that the problem is decidable, but just now what we said is if the corresponding decision problem is decidable you know this definition and what we have then it means the that set is recursive. So, my point is you can talk of decidability in one hand and really an equivalent question is recursiveness the set let us say name a set A. So, we say the membership decision problem for the set A is decidable if and only if A is recursive you should see that if you wanted an algorithm to decide something some set membership problem equivalently you would like to show that the set is recursive. So, what the notion decidability notion as I said is equivalent to or tantamounts to recursiveness notion and if a set membership problem is not decidable you call a problem if problem can be undecidable that would mean what that corresponding language would be corresponding language would be would not be recursive. Now, we have a notion of recursively enumerable languages. So, we had this notion of R e languages so if a language is R e then of course, you have a Turing machine to accept it the only problem with that Turing machine is that Turing machine may not halt on those inputs which are not in that language. But then it is not a that Turing machine can be cannot be used to decide the membership problem of the language because it would it may not halt to give out a nuance. So, therefore, the question that is of importance is that given an R e language is it recursive why is this question important because if I can show that an R e language is recursive then for that language I have a membership decision algorithm. The problem the decision problem would be decidable we will have a useful algorithm the point I am trying to say is that just contrast this case that consider primality. Now, suppose you have a Turing machine which accept the set of all prime, but the kind of question you would like to answer is somebody gives you a number n you would like to say yes if it is a prime no if it is not a prime. So, that Turing machine which of course, will say yes to all primes when given as input, but may not halt at all on some input which are composite. So, you cannot really use that Turing machine to make that practical decision that is a number prime. So, this question we can frame it in another way R all R e languages recursive clearly every recursive language is recursively enumerable because for a language to be recursive first of all it has to have a Turing machine to accept it and that immediately makes it recursively enumerable. So, R recursive implies recursively enumerable and the reverse question is therefore, we are asking if the answer to this question is yes then of course, should be very useful whenever we have a language to accept some set we have an algorithm to decide that language. Now, we can just put these questions in a slightly pictorial form. So, just imagine this is your set of all languages set of all languages over sigma and this is the set of or class of all R e languages. So, let me just mention this that we already know something which is here and not here what is that L D language L D right we know L D is a language over sigma, but L D is not recursively enumerable so, it is not within this and since every recursive language is also recursively enumerable the class of recursive language if I represent by this that class of that set is clearly a subset of this thing the question this really this question that we have put here is the separation as about the separation is the separation strict that is is the error language here or not and that is an important question. So, that means if I have something here although we have we can have a program which will always terminate on the yes instances it will not be yet decidable. So, in fact what we are going to show soon that indeed this separation is strict there will be something here which is in other words there will be a recursively enumerable language which is not recursive we will show that, but before that let me quickly tell you a couple of very simple facts about you know recursive and recursively enumerable languages first these are really observations of simple facts if first practice if L is recursive then so is L complement clearly because this is something we did for DFA right that same kind of situation will apply that any input you know L is recursive means you have a Turing machine which accepts L and it always holds. So, if the input is in the language it will go to an accepting state and hold of course, if it is not in the language it will go to a state in which it will hold, but that state is not accepting. So, now if you just switch accepting and non accepting states of that machine you will be recognized L complement. So, that is clear second thing is interesting also that if both L and L complement are recursively enumerable then L is recursive of course, when I say L is recursive immediately we have L complement is recursive. So, if both L and L complement are recursively enumerable then both of them are recursive right. Now, how do I show this? So, you see basically imagine that I have a Turing machine M 1 to accept L and another machine M 2 to accept L complement right. Now, think of another machine M dash which on any input x you know it makes a copy of that input x on another tape and alternative alternatively no it runs M 1 to run M 1 here and runs M 2 here. Now, alternately what I mean by that see basically M dash will simulate or you know behaves or let us say even number of steps like M 1 and for odd number of steps like M 2. So, it is switching between the work of M 1 and M 2 and since M 1 accepts L and M 2 accepts L complement one of these you know one of these machines will accept the input because if it is the input is in the language then M 1 would accept if the language if the input is not in the language then M 2 will accept. So, sooner or later one of these machines will halt in an acceptance and from there you know what is it? If it was M 2 which accepted it then x is not in the language L and if M 1 which accepted it and halted then you know x is not in the language. So, either case M complement will all or M bar this M dash this new machine would always halt on every input and therefore, you know you using this machine you know whether the input is in the language L or not right. So, in case you find this M prime finds it is M 1 which has accepted it will say yes. If M prime finds that it is M 2 which was accepting the language L 2 has accepted the input then it will say no the input does not belong to language L. Thereby since we have a Turing machine M dash which would always halt after saying yes or no it would halt and that would accept L we have proved correctness of the statement that if both L and L complement are recursively enumerable then L itself is recursive.