 to reiterate one iteration of the machine that we are trying to build is that it will consider one A and will find a corresponding B and a corresponding C. Then it will come back and position itself to the A which was just checked. So, what we want in an iteration once more that this is the next A the left most available A. So, this will be crossed off and then the machine will move to the right and in this process what it is trying is that it will find a corresponding B it will put a tick and still go on towards right find a corresponding C and then it will put a dollar. So, that means corresponding to that A it has found a B and a C and now the iteration should start all over again, but now it should position its head here. So, that the next iteration can start and we have seen that these four states when you were when the machine is first is in this state starting the iteration it will come back to this state for the next state for two it will position itself correctly for the next iteration. Now, so this iterations are going on then what happens at the end several things can happen that it will find that indeed all the A's have been checked off with B's and C's should then the machine come to the conclusion that the number of A's is equal to number of B's equal to number of C's not really you see it is like this suppose you have a number of A's and then slightly smaller number of B's or a number of B's which is less than the number of A's and then some C's. So, you will be able to check off for each A 1 B this A also you will be able to check off 1 B and 1 C, but in this particular example corresponding to this A will not be able to find a B. So, that is one possible way that the machine will find that something is wrong. So, there are several cases the right cases of course the number of A's is equal to number of B's and equal to number of C's. So, the head will come all the way here it finds an x and move to the right. So, long the iterations are going on it will find an A, but now if the block of A's are over what is it going to find it is going to find a tick as it moves from the x to right. So, it has found an x it of course does not change that x and then moves to the right in this case you can see that it will find the tick. So, it is possible that it will find a tick in this place what does that signify it signifies that the block of A's is such that that for every particular A we have been able to tick off a corresponding B and a corresponding C right. So, in that case when this tick comes we know that block of A's have been you know taken care of. Now, the question is the input is of the correct form provided no B's or C's are left. So, how can we do that we will move to the right and as we move to the right if we find any B or any C left then of course we know that number of A's was less than either number of B's or number of C's. So, for example in this case if we are moving to the right see we have come to this state moving now moving to the right to check if there is a B or a C is still left which has not been you know either in case of B it has been ticked off or in case of a C we had put a corresponding dollar. So, in case we find a B what we know we do not have to change that B, but we know that this input that we have has more B's than the number of A's. So, in this particular case what we can do we can go to a state where we can halt and with the understanding that the string input string is not a correct one. So, we can say halt and not accept. Similarly, if we find a C again we can write a C there and say the number of C's is more than the number of A's such was the input. So, in that case again we should halt and not accept. However, as we are moving to the right in case we find you see what is going to happen look at this case. So, it came here it found the tick this is where we entered this state we found this take and moving to the right and then here what we are going to find if there are no B's or no C's left we are going to find a blank. So, in this state as it is moving to the right if it finds a blank it does not change that blank symbol, but it knows that the number of A's of course is exactly equal to the number of B's and the number of C's. So, in this case it halt it goes to a state which is halt and accept. So, have you taken care of all the possibilities not really you see what may happen number of A's could have been more than either number of B's or number of C's that particular possibility we have not yet taken care of in this diagram in this transition diagram. How does the machine know that the number of B's or number of C's is less than the original number of A's. So, for example here you see it is in this state what is it looking for it is looking for a B to put a tick, but in this state if it finds that the C block had already started how would that happen that in this state if it sees either a C or a dollar then it knows that the B block is over and yet we are short of at least 1 B. So, in this case for example if it finds a dollar or a C it knows that the number of A's is definitely more than number of B's. So, let me just put it this way dollar because it does not need to change it and similarly if it finds a C then again it is a C or you know it has gone you know it has found not a B, but either a dollar or a C. So, in that case what should happen this case is again reaching a state where it is halt and not accept. So, this takes care of the case where the input is such that that number of A's is more than the number of B's, but it could have been the number of A's is more than number of C's. So, that situation will be discovered here you see like in this state it is looking for a C and in case of course it finds a C it puts a dollar, but if it does not find a C supposing there all C's have been already taken care of then what is it going to find as it moves to the right keeps on moving to the right it is going to find a blank. So, in case it finds a blank then again it knows that the number of A's is more than the number of C's. So, here again it should halt in this state and not accept. You can see the basic idea is that that with the capability Turing machine has a Turing machine has that is being in a state depending on the input it can decide to go to the some other state writing a particular symbol and move either left to the right this simple you know mechanism in defining a Turing machine at least in this particular example we can see that it suffices to distinguish between all strings which are of the form equal number of A's followed by equal number of B's followed by equal number of C's this particular this set of strings can be differentiated from those strings where number of A's and number of B's and number of C's did not match. So, we can therefore see that this device that is Turing machine can indeed do something which no push down automata could do which no context free grammar could generate could define that particular language of a n b n c n remember this particular language cannot be either generated by a context free grammar or equivalently cannot be recognized by a push down automata. But, here we see that a Turing machine does have the capability to recognize these strings and not those strings where number of A's and B's and C's do not match. Let us just to be clear about the working of a Turing machine what we can do the way we can you know given a program we can trace the execution of a program in a similar manner we can trace the execution of a Turing machine. So, let us just trace the execution of this Turing machine on a very simple input string. So, let us say our input string is at least I will carry out a few steps. So, that you understand what does it mean to trace the execution of a Turing machine. So, let us see you had and I am not writing the blanks symbols. So, these are here remember the Turing machine starts in this state scanning the leftmost state that is what we said in this diagram really we have not if you look at it there is no indication where does the Turing machine begin and by convention what we do we know I mean we know that we want this state is the state in which the Turing machine is supposed to begin. So, what we do is we put an arrow coming from nowhere into this state to indicate that this is the initial state. So, this is the initial state and we have the name for this state is q 0. So, one way of doing this tracing the execution will be that will write the basically will describe the tape remember all this is on tape and there are some blank symbols flanking both sides and the machine is in state q 0 in the beginning and scanning this particular symbol. So, one way of indicating all that will be the machine is in state q 0 and scanning this what we are going to do is going to put an underline put a small line below the symbol where the head of the Turing machine is. So, this is describing our initial scenario in the right in the beginning machine is the idea is if it sees an a it puts an x and goes to this state. So, the next snapshot or after the state change has been effected what are you going to see you will see that the Turing machine is in state q 1 and the head has move one cell to the right. So, we can describe that by saying the machine is in state q 1 and the head is here, but you see before that what did it do the machine as it change the state it change the symbol it was scanning which was this a into an x. So, this is now an x and the head is here everything else remains of course as before the machine is in state q 1. So, this is the state and now what is what we can see that in this state what is it scanning it is scanning an a what will happen it will remain in the same state and it will not change that particular symbol you see. So, the next time instant the situation will look like this I am sorry. So, this is it is it was scanning an a it will write the same a and move to the right. So, it will now look at this symbol in q 1 now if you see a b you are supposed to put a tic and go to state q 2 this is the state q 2. So, therefore, next state is going to be q 2 and this b is change to tic which we have shown there and what happens now you go to state q 2 by moving to the right. So, the head has move one cell to the right and not now it will scan a b and you know you can see that at least look at one more instant of time what is going to happen the machine is in machine is in state q 2 scanning the symbol b. So, machine is in state q 2 this is q 2 remember scanning the scanning b it will remain in the same state and move to because see this is the diagram in this diagram the arrow is coming back to the same state and this state is associated with a right move. So, the head will move one step to the right. So, really it will remain in the same state therefore, without changing the symbol and it will move one cell to the right. So, therefore, the machine will be in state q 2 scanning the symbol c and this goes on. So, although it is a laborious process, but then tracing execution of any program even a simple program you must must have done it sometime it is fairly what should we say it is a kind of tedious and laborious process, but at the same time what I am trying to show you by means of this that it is possible to very methodically trace the execution of a Turing machine step by step. So, just in case we have doubts about the working of a Turing machine we can follow an execution sequence to ensure to be sure that what exactly does the Turing machine do on the given input. So, now there are certain things in this diagram which is a little messy which we can take care of. So, that you know it does not distract us so much see I mean if you look at this. What is it doing we are saying that if you are in state q 3 and if you see a dollar write the same symbol there and remain in the same state. So, similar such things will be there all over we can avoid so much of cluttering by a very simple convention that is will not show on the diagram all those self-loops in which the symbol does not change. So, let me be very clear what we mean is so it is a convention that we will omit self-loop transitions which change there are actually 1, 2, 3, 4 transitions which are like this here by self once more the by self-loop transition we mean a transition from a state to itself. And in if in that transition the symbol that was being scanned at that time if it remains that it the Turing machine does not change that symbol. So, how do you specify that it is seeing a dollar and it writes back the same dollar. So, the symbol really does not change on the input state in such case we say you know it is by convention will not show will not show this such transitions. If you do that how will this figure look so will remove these transitions these basically we are not removing the transition, but basically we are not drawing the convention being that if you are in a state and nothing is specified that means you remain in the state without changing the symbol and the move is according to the move which is associated with the state. So, this is these are also transitions which do not change the symbol and into the same state. So, I can actually remove showing them explicitly this is another such transition which also I do not draw it is understood and similarly this one any other such thing not really and this looks neater because right for example, here you are in state q 3 and in q 3 suppose you are seeing you are seeing something let us say dollar what would happen it is nothing is mentioned here this diagram it is not explicitly mentioned what the Turing machine does when the it is in state q 3 scanning dollar since nothing is mentioned by this convention will assume that it remains in the same state writing the same symbol. So, we will see an another example where we will write a ways from the beginning we will use this convention and only thing is of course, if we follow this convention like here nothing is shown, but then these are states where you would like to halt. So, what we can do therefore, instead of drawing a particular you know symbol or a circle for the state we will just say that we halt and do not accept and similarly we here remove this and we will simply say that we halt and accept and so on. You understood what is the reason that we are removing this explicit showing of these states the reason is because if we follow that convention if you are here then it means that the all those if I just draw like this it means that all those self loop transitions were there and then it is contradicting that we are saying it is halt. So, we will just say we will remove this and we will say like here halt and not accept at least we have one example of a Turing machine which does something which is in a way fairly complex because something this task is something with no finite state machine or no PDA could do. Let us now consider one more example just to get our ideas well fixed about Turing machine and these transition diagrams. The example that we consider now is converting not let us put it this way that we will be given a block of 1's in the input and corresponding to this block of 1's if we see this block of 1's as coding a unary number what is the corresponding binary number representation. So, we of course this task is we are all familiar with that suppose I am given 1, 2, 3, 4, 5, 6, 7, 8, 9, 1's let us say and this and in unary this block of 1's represents the number 9. So, 1, 2, 3, 4, 5, 6, 7, 8, 9. In binary we would say that that this being the binary representation of the same number 9 or the task that we would like to carry out is that given a block of 1's we would like to see it as a unary number and the corresponding binary code for that number we would like to write down by means of a Turing machine. So, therefore, it is the task of you can see the problem is converting unary representation to binary. How do we do it? Of course we know all of us know the algorithm for obtaining the binary representation from a unary representation what do we do we divided by successively we keep dividing by 2 and if the remainder is 1 that is we know that the one more bit that we have found of the binary representation and then we work with the result of the division by 2 for the rest. So, for this 9 what would happen that if you divided by 2 you will be left with remainder 1. So, that becomes the least significant digit and the result of the division by 2 is quotient is 4. So, 4 when you divide by 2 you are going to get quotient will be 2 and the remainder will be 0 that is the next significant bit of the representation that you would find. Then 2 if you divide by 2 you will get the remainder to be 0 and the quotient to be 1 result of the division to be 1 and this one when you divide by 0 if the result is going to be 0 the result of the division is 0 in the sense of quotient is 0 and the remainder is 1. So, that we write here and this is indeed the and then this is become 0 and that means there is no more nothing more to be done in the conversion. So, this is what we would like to carry out by means of a Turing machine. Now, only thing is we see that we have a block of 1s as well as if we use gain 1 for the binary representation there is a kind of clash just it is simpler to use two other symbols for 1 and 0 the conventional 1 and 0. So, let us say we will use a for 0 and b for 1 b for 1 and b for 1 and b for 1 and b for 1 and b to represent 1 in the binary representation. So, in that case what we will what we get corresponding to this we should get b a a b to fix our convention ideas about the input itself. Remember, what we have is to begin with a blank tape with some 1s and of course, these are blanks and we would like to get corresponding to this block of 1s the binary representation, but we will we are coding 1 as b and a as 0 and it will be convenient as you will see that to write the result at the left. So, basically this being the input finally, what we should have finally, we should have b a a b and block of these block of 1s. Remember, that these b with a slash stands for blank. So, this is the conversion that we would like to effect by means of a Turing machine. We have said divide by 2 take the remainder how do we carry out these activities by means of the kind of primitives which are available with Turing machine. In this case that can be done quite simply. So, let me first show you the idea. So, remember we had this 9 block at least that example we had 9 1s. Now, suppose what you do is you make a scan and what the idea is put across for this and then leave it like that then. So, what is happening the first one that you get you put across the next one you do not change. However, the next one you put across next one you do not change next one similarly, you will put across this one you do not change this you put across this you do not change this you put across. Now, you see what we are seeing what we are doing we are it is like the previous example that we are trying to check for every one another corresponding one. So, for this one which we crossed I found the one I am not really changing then we are doing this for this one found this one for this one we found this one for this one found this one for this one we what happened we did not find another one. So, once more that for this one we found another one for this one we found another one for this one we found another one for this we found another one for this we put across, but we did not find another one. Now, do you see what is the conclusion that we can come to that the conclusion is that the original block of ones must have been odd because it is of course, obvious that if you have an odd number of ones then as you are pairing of one one with another one, particular one will be left off and which is this one which got left off. So, we know that that this is odd another way of saying is. So, conclusion in this case is block of ones odd, but if we have a block of ones which is odd that means what that if we divide by two the remainder is going to be one. So, this is equivalent to this conclusion that the original block of ones is odd that is equivalent to that the remainder is one on division by. So, we have found indeed the least significant bit of the binary representation. We have found the least significant bit of the binary representation which because the remainder is one that least significant bit is going to be one. So, we should write a b here, but remember that now we should carry out with the iteration and we should have had somewhere the result of the division. When you divide 9 by 2 result of the division is 4, but you see the way we have done the number of ones which are left on this block if you ignore the crosses the number of ones which are left is indeed the result of the division you see. So, again the next iteration suppose you write this b that is the result of the remainder of the division by 2 and you had this. Now, again you do the same thing this one you put a cross of course, ignore any previous crosses and then this one. So, the next one that you have ignoring crosses you leave that crosses you ignore this one you put a cross cross and this one is left as such and this one is left as such and then it is cross. So, now you see what is happened that this one you could check off this one you could check off and whatever no other one. So, in that case we know the result of the division by 2 of the block of ones remaining here that is 0 because that because the number of ones in this case is even we checked off we could manage to check off each we could pair up like this paired up with this this particular one was paired up with this. And therefore, the result is of the division is 0 result in the sense the remainder of the division by 2 is 0. So, here we should write a and start the next iteration as you can see what is going to happen after this we remember we are ignoring crosses. So, this one will put a cross and ignoring crosses the next one will leave it as such this is cross. So, again the result of the remainder of the division by 2 is 0. So, b a so this will again be a now we are writing getting the next significant digit starting from the least significant bit. And finally, in this case we have one. So, just the block of ones as one. So, we ignore crosses and we make it a cross and we find that there is no one to pair this particular one with. So, the result of the division is by 2 is odd. So, we know that this would be b and this what we see that there are no more ones left. If you recall what we did for this example when we did the usual kind of division by 2 take the remainder when finally, successively after dividing by 2 when the you know number that was finally, left was 0. That means, we have taken care of the entire number and whatever we have is the binary representation. So, what we are going to do now is to see how this can be carried out by means of a Turing machine and we will see that Turing machine is going to be fairly