 .In this lecture, we will discuss decidability. Already, we have introduced Turing machine as a model of general purpose computer. The notion of algorithm has also been defined in terms of Turing machine by means of search Turing thesis. We will now see that some problems can be solved algorithmically while others cannot. So, it gives us the limits of algorithmic solvability. In decidability, we will consider some example of languages that are decidable by algorithms. That is, there are Turing machines to decide those languages. Of course, while giving Turing machines as algorithms, that means, decider Turing machines, rather than spelling out the full specification of Turing machines, that means the states, transition functions, etcetera, we provide only a high level description, where we use English prose to describe an algorithm, ignoring the implementation details. That means, we do not mention how the Turing machine manages step or head. We now consider some example languages that are decidable. We consider languages to represent various computational problems, just for our convenience. So, first we see problems from regular languages itself. So, first let us consider membership problem for regular languages. So, the problem is that given a string x belonging to sigma star for some sigma and a regular language L over that alphabet, whether or not the string x belongs to L. So, there is a problem. So, this problem, the corresponding language for this problem can be stated as M R L, which is the set of all strings like this. So, A x such that A is a DFA and x belongs to L of A. So, why we are switching here A to B DFA? Because since we want to see whether x belongs to L or not, we need to give an algorithm. That means we need to design Turing machine to decide this problem. Now, we have to give a description of the language to the Turing machine. How to describe this language? How this description of the language should be given to the Turing machine as input is the main problem? Because language may be infinite. So, we need to have some finite presentation of the language, so that we can give it as an input. So, there are different kinds of finite interpretations. For example, so we have a regular expression. By using regular expression, we can give or represent the any language or we can also use a finite automata, for example, say DFA to describe the language. So, here we will consider finite automata to describe the language. So, therefore, this A x, this is the string where A is the encoding of the DFA and x is a string. So, the problem is the language of problem is the set of all strings like this A x in encoding such that A is a DFA and x belongs to L of A. Now, since you have said that we need to give an encoding of A, that means the DFA, we first consider how to encode a given DFA. Let us see the encoding of DFA or coding of a DFA. So, if A is a DFA, then corresponding encoding will be written as A within angular bracket. So, that is why we have written here in the language as A x within angular bracket. So, these are encoding. Consider, for example, this DFA where we have two states q 1 and q 2 and the inputs are from the alphabet 0 1. So, these are corresponding transition function delta. It has only one, it has single one initial state q 1 and only one final state that is q 2. From the transition function, we all the transition function can be represented as triplets say first one q 1 on input 0 it goes to q 1. So, we represent like this q 1 0 q 1. Second one is that q 1 on 1 goes to q 2. So, q 1 1 q 2 like that we can also represent the other two transitions. Now, we give a encoding of this DFA using strings over 0 and 1. So, to start with the left bracket we represent using three zeros and then since a finite number of states will be using say if we have q 1 q 2 up to say q k. We use a sequence of ones to represent the states. That means, 1 to the power i will be represented will be used to represent the state q i. Similarly, to represent the symbol from the alphabet again we use sequence of ones only. For example, say a 1 a 2 say a m these are symbols from the alphabet then we will be using 1 to the power i to represent the symbol a i. Therefore, we can now encode every transition like this. So, after three zeros we denote the left bracket. So, q 1 will be denoted as 1 to the power i that means 1. Now, next we will use 0 as a separator after using 0 here as separator. We use single symbol say 1 3 power i only 1 to denote 0 and then again 0 as a separator then 1 to represent q 1. So, 1 0 1 0 1 this is the code for a corresponding transition q 1 0 q 1 then this transition will be separated from the other transitions by 2 0 over here and then for this transition q 1 will be written as by 1 separate by 0 then this symbol 1 will be written by 2 ones because there are 2 symbols 0 and 1 0 will be written by 1 and 1 will be written by 1 1 and then q 2 will be written by 2 ones 1 3 power 2 because there are 2 states q 1 and q 2 for q 1 we have single 1 and for q 2 we have 2 ones. So, this is the code for this particular transition. Next it will be separate by again 2 zeros and this is the code accordingly for this transition 2 zeros again to separate and this will be the code for the corresponding transition over here. Then again we will use 3 zeros to indicate that we have no more transitions over here all the transitions have been encoded and then we indicate the set of final states after this. So, since q 2 is the final states so we use 2 ones according to our notations for q 2 we have 2 ones and then we use 3 zeros to indicate that there is no more final states over here. So, this is the encoding for the DFA. So, in general if we have a DFA having final numbers of states q 1 through q 1 q n final numbers of symbols a 1 through say m delta is a transition function q 1 is the initial state and the set of final states over here q i 1 q i 2 up to q i k. What we do is that q i will be written by 1 3 power i this string and a i will be written by 1 3 power i these strings and if t 1 t 2 t r are the transitions then the DFA a is dependent by 3 zeros the coding code of t 1 2 0 then the code of t 2 again 2 0 the code of t 3 and so on up to the code of t r the r f transition then 3 zeros to indicate that there is no more transition and then 1 3 power i 1 to indicate that these are final state q i 1 is the final state 0 1 3 power i 2 q i 2 is the final state and so on up to q i k to indicate that q i k q i 1 q i 2 up to q i k these are the final states and eventually 3 zeros to indicate the end. So, that is how we represent or encode any given DFA so once we have encoded what we do we use a Turing machine so this encoding of a along with after the encoding what we have say this is the encoding of a we had 0 0 0 t 1 0 0 and so on 0 0 t r 0 0 0 1 to the power i 1 0 1 to the power i 2 0 up to your 1 to the power i k 0 0 0 and after this we after this we place the string x whatever it may be so it is again a sequence of 0's and 1's 0 1 or whatever is sequence of 0's and 1's so this overall will give us the string a x so therefore that is how we give the input to the Turing machine so we consider for simulation we consider a 4 tap Turing machine on the first step we place the string encoding of Turing machine along with the string that means encoding of a and x together where dollar is a first symbol on the second tap we put so initially the what a Turing machine can do it can look for the first group of 3 0's second group of 3 0's and finally last group of 3 0's once it gets the last group of 3 0's the third group of 3 0's it knows that there is no more final sets and whatever is there after this will be the string x so once it can identify the string x it can copy that string x from the first step to the second step so in a number of steps the Turing machine can copy the second component that means the string to the second step now in the fourth step the Turing machine again can find out or identify all the final steps of the DFA and it can copy on a third step the final steps of the DFA and the third step will be considered as a current tap or that means a tap which is used for simulation of the Turing machine now will give the algorithm for a model to do that we need to know how the Turing machine will simulate the behavior of the DFA and it will say yes whenever the DFA eventually accepts the string x and it will say no whenever the DFA does not accept the string x so the Turing machine will first see put the initial step that means the 1 because key 1 is the initial step that is why it will put 1 in the third step in the simulation step then looking at the symbol the first symbol of x so it is it knows that it is in state current state is key 1 it will first see what is the current state current symbol from the second step therefore from the first step which is a encoding Turing machine which contains the transitions of the DFA it will see what is your key 1 with the first symbol of x suppose say 0 it will see was a third component in that transition in the transition which is available in the first step accordingly if it is key 1 it will print 1 over here in the third step otherwise if you say it is key 2 then it will print 2 ones over here on the third step to indicate that the DFA has changed its state to key 2 according to transition function given on the first step in the encoding so this will be continued in this way looking at the symbols of second step the current state in the third step will any transition matching the current state and the current symbol it will keep on changing the state in the third step so eventually whenever the input string is exhausted then the Turing machine check the content of the third step so it will indicate what is the current state if that current state you will see whether it is a final state from the fourth step whether that state belong is a state which is there in the third step or fourth step or not if it is it knows that the input is exhausted and it has entered in a final state so therefore the DFA should accept otherwise the DFA will reject just given string x so that is how the Turing machine will simulate the behavior DFA using a fourth step Turing machine so once you know how it goes you can now give the algorithm for the language MRL so in this case the input is of this form AX where A is a DFA and X is the input to the DFA A so AX is the encoding is given to the Turing machine so Turing machine either output yes or no so if it outputs yes that means the DFA A accepts the string x if it outputs no it means that the DFA A rejects the string x so in step 1 it will simulate the DFA A on input x so it is now quite clear how the DFA how the Turing machine will simulate the DFA A on input x using a fourth step using its four steps in step 2 the simulation ends in a final state then the DFA will say yes otherwise it will say that no so this is the algorithm for MRL so therefore MRL is decidable that means the membership problem of regular language is decidable now let us see the emptiness problem of regular language so in this case the problem is that given a regular language L whether or not L is empty so the corresponding language for this problem is that ERL which is set of all strings A where A is a DFA and this is an encoding of the DFA and L is 5 that means it does not accept any string so for this now would not give the Turing machine specifically all the states and like that but simply will give the algorithm so in this case the input is DFA A which is having the state q input symbol sigma delta is a function q notice the initial state and F is a set of states so it is a DFA is an input and output is again yes or no depending on whether L of A is 5 or L of A is not 5 in the first step what a Turing machine can do it will mark the initial state of the DFA so there is single initial state it will mark the state in step 2 the Turing machine will repeat step 3 until no new state gets marked so step 3 is that if a state p is already marked suppose p is already a marked state then if delta p A equal to q so this can be determined from the first step where the description of the or the encoding of the DFA is available if delta p A is equal to q then it will also mark q because p is already marked on some symbol it goes to q then it will mark q as well so this step will be continued until no more no new states gets marked so eventually when it comes out from step 3 if no final state is marked it means that the DFA cannot enter in any of the final states in such a case it will say yes that means it will not accept any string otherwise it will say no that means the DFA accepts some string that means the language of the DFA is not empty now there is an alternative way to solve the same problem that means to decide the same problem that means the emptiness problem the alternative way we can prove it by means of these two theorems or constructed from these theorems suppose there is DFA A with n states and L is the language except by the DFA now we can prove that L is not equal to phi if and only if A accepts a string of length less than n so this we have kept it kept as exercise you can prove it easily by using pumping lemma already pumping lemma for regular language have been discussed and you can apply that pumping lemma for regular languages to prove that L is not empty if and only if the DFA accepts some string of length less than n similarly the second theorem says that L is infinite if and only if A accepts a string x whose length is greater than or equal to n or less than twice n or n is a number of states of course so we can use the first theorem to prove that or to decide whether the language of a DFA is empty or not that means emptiness of regular languages whether it is decidable or not so in this case the Turing machine basically can list out all the strings of length less than n so there are finite numbers of strings like that of length at most n and all these strings can be generated on the on one type of a Turing machine and then the Turing machine can simulate the DFA on that string so it will continue to generate the strings of length up to n and then test it or run the simulation or simulate the behavior of the DFA whether it accepts or not so eventually if the DFA accepts any string of length at most n or less than n then it can determine it can decide that it can output that L not equal to empty otherwise it is empty so similarly since there are finite numbers of strings of length greater than or equal to n and less than twice n because numbers of states in a DFA is finite so Turing machine can always generate all those strings on one of its step one by one systematically and then verify by simulating the DFA on that string whether it accepts or not if any one of the strings is accepted by the DFA whose length is greater than equal to n or less than twice n then it can decide that the language of the DFA is infinite so whether given regular language is infinite that means the corresponding for this problem the corresponding language is IRL the encoding of DFA A such that is a DFA and LA is infinite so you can show that IRL is decidable by constructing a Turing machine which will output yes or no accordingly now let us see the problem of equivalence of two regular languages the problem is that given two regular languages L1 and L2 is L1 equal to L2 whether they are identical the corresponding language is that is equivalence of regular language given two DFA's A and B these are encoding of DFA A B so A and B are DFA's and LA equal to LB whether they accept the same language or not so these are corresponding language problem now to solve this problem or to decide this language will first construct a new DFA which is say C from this given DFA A and B such that C accepts only those strings accepted by either A or B but not by both that means language of C is written as L of A interaction complement of LB union complement of LA interaction L of B these what is called the symmetric difference of A and B now given a DFA we know how to construct the DFA which accepts the complement of L of A so A is the DFA L of A is the language accepted by the DFA so complement of L of A will be accepted by that DFA where we just intersense the final states and non final states all the non final states will be final states and the final state will be non final state so that new DFA will accept the complement of the previous DFA so therefore from B we know how to construct the DFA which accepts complement of LB similarly from A we know how to construct the DFA which accepts complement of LA similarly we have given the procedure to construct interaction of two DFA similarly the union of two DFA so therefore we know how to construct the DFA C which is a symmetric difference of A and B now if we see carefully the language of C is fine you will find that language of C is fine even only if the language of A language accept by A and language accept by B are identical so therefore this problem now reduces the problem of whether LA equal to LB reduces the problem of finding whether LC equal to Phi or not now what we can do we can now just use the same algorithm for emptiness that we have already given over here so the algorithm for emptiness to determine whether LC equal to Phi or not so therefore if LC equal to Phi then LA equal to LB otherwise LA is not equal to LB so therefore you can determine whether the problem of equivalence of regular languages we can say that the problem of equivalence of regular language are decidable so after considering the problems from regular language let us now consider the membership problem of context free language that means the problem is that given a string X over sigma star for some sigma and a context free language L over that sigma whether or not X is a member of L same problem similar to the membership problem of regular languages only is that here the language is CFL context free the corresponding language is that is MCFG in this case we represent the language by giving the corresponding context free grammar in case of regular languages we used DFA as input so in this case we use the corresponding grammar G as input so in this case whenever we say that we use angular bracket it shows that this encoding of the G and given string X the way we have given the encoding for a DFA can also be extended to give an encoding of any given grammar so therefore we assume that such an encoding exist it is possible so this GX is the string a set of all strings GX the language that set of all strings GX where G is the grammar CFG and X is a string and here G is CFG and X is a string such that X belongs to L of G so these are corresponding language for this given membership problem of CFL now let us see whether it is decidable we can show that this is decidable by giving an algorithm now in this case what we can do in a for algorithm the input to consider as a CFG and a string X but here we assume that the X is not equal to epsilon in a string is epsilon then we can determine where it belongs to the grammar G or not by looking at the productions then you can only find out whether that epsilon belongs to the language or not by simply looking at the production now the string machine simply output yes or no depending on whether X belongs to the language or not in a first step we convert the CFG to CNF we know that in CNF all productions of the form a goes to BC that means the right hand side we can have only two non terminals or a goes to say a single symbol this kind of productions are allowed in CNF so since this is the case if we have a string say X of length n we can show that to derive this string X of length n using this grammar if X really belongs to L then it will take no more than 2 n minus 1 steps so makes n numbers of steps it may take is 2 n minus 1 because the right hand side of every production is obtained at most 2 where both are non terminals so after converting the grammar G to CNF because this algorithm we have already given in the context of your simplification of current speed and current speed grammars so we list all the derivations with 2 n minus 1 steps where n is number of length of the string once it is done once it knows all the derivations of length with 2 n minus 1 steps if any one of these derivations generate this string X then the termination will output yes otherwise the difference none derives the string X the termination will output no that means it is not accepted so therefore the membership problem of CFG or convex speed language is decidable since we have a algorithm to decide it