 So, complexity theory today we will be discussing one of the important problems in mathematics and computer science. So, in connection to that first let me overview on what we have already discussed about you know regarding time bounded Turing machines. And in that context we have talked about a class of languages which are decidable in time t. Time t the class time t we have introduced the notation which is representing which is to denote the class of Turing decidable languages of course decidable languages which is the time parameter t. So, in decidable in time t that we have introduced. Now, let me just quickly review some of the fundamentals related to the polynomials. If I consider a polynomial say a naught plus a 1 n plus a 2 n square and so on plus a d n power d where d is the degree of this polynomial I will assume a d not equal to 0. If I call this polynomial say f n you know clearly that f n is in the class n power d this big o notation you all might know. Now, moreover you can see that this is in the class theta n power d. So, this is of this polynomial f n is of same rate of growth with the polynomial just n power d. So, in fact you can look at that this class theta n power d you know in this class you have those polynomials of degree d and in this context you may understand that the polynomial f n is in the big o class of n power d plus 1 or may be higher number than d. But this if you take a polynomial say for example, g n which is of degree say d plus 1 you can see that say let me just simply take this polynomial n power d plus 1 this is a polynomial you can see that this is not in n power d class. So, here what I wanted to just quickly mention that if you take those polynomials of same degree whatever the lower order terms what are the coefficients that you have you can quickly understand that I hope all these things that you would have learnt and you have done in other courses particularly in algorithms also you have used all these things you can say that a polynomial of degree d is of same rate of growth with any polynomial of degree d what are the coefficients on the lower order terms and what are the coefficients. So, that is a theta class of n power d that you have now using this I will define an important class called p. So, what is this this is I will define it as now union time n power d d is a natural numbers running over natural numbers. So, what is the meaning of this this is p is that is p is the class of languages which are decidable in polynomial time because if you take any language which is decidable in time t which is a polynomial you know that is in time t class. Now, that t if it is a polynomial it is in the class of time n power d where d is a degree of that particular polynomial. Now, we have taken union of all those languages and all those classes. So, this p we are defining this script to p I am writing distinguishing between some other you know normal letters or wherever I would be using. So, this class p I have defined to be the class of all those languages which are decidable in polynomial time. Now, if you ask for examples of course there are what are the examples in the previous lecture that we have discussed they are all clearly in polynomial time I have given some linear time languages which are decidable in linear time particularly regular languages which are decidable in 2 n plus 4 time. And we have some example discussed that is working in quadratic time and what are all the languages many languages. So, far we have discussed here they are all in clearly in p because what are the deciders that we have constructed you can verify that they are working in they are working in polynomial time there is a polynomial time decider to compute to decide those languages. Now, so thus for the class p I am not giving any more examples because we have we are already equipped with many of many of the examples. Now, I will talk about a new concept called NP what is that NP this is essentially non deterministic variant of the class p we have just defined. Now, I will look for the non determinism when I am looking for the non determinism particular non deterministic turing machine the way that we have introduced that is not a decider. So, it is not actually taking a decision on the inputs in contrast with the standard turing machine. So, we will include that feature when I am talking when I am introducing the time bound on non deterministic machine and accordingly we will define the class NP first let me start with associating time to a non deterministic machine. So, for that let me start. So, let t from natural numbers to natural numbers is a time function be a function and consider a language L or some alphabet let me say sigma naught star a language as earlier. Now, I will start with the non deterministic machine instead of standard deterministic turing machine. We say a non deterministic turing machine non deterministic turing machine say I may call it as m q sigma this is the transition relation there q naught initial state with the alphabet under consideration is subset of the sigma alphabet of that this accepts L in non deterministic time I do not want to call it as time because the variance is there I call it as non deterministic time t. So, this time what we are associating for a non deterministic machine we call it as it is accepting this machine is accepting L in non deterministic time t if the following holds following holds what are the condition I write now the holds. So, what is that for all x in sigma naught star you take any string x is in L if and only if you give that as input to the machine. So, in this format we give it will hold in time t in within t number of steps of course, when it is halting what is there on the tape it is not a decider. So, I do not expect any s r no sort of thing, but it will lose some something on the tape that means for some y z in sigma star something and of course, a in sigma and this t what it has to maintain it should be less than or equal to t mod x. So, the number of steps it takes to compute on it by the time it holds you know the number of steps it takes is less than or equal to t mod x with respect to the input parameter mod x the length of x. So, what we have defined essentially this is a non deterministic variant of the earlier in the earlier lecture whatever that we have defined about time time bounded Turing machine here when you are considering non determinism we know that there is no decision here which is something like saying s r no on a given input. So, if it is halting it has to halt within the required number of steps that is with respect to the time where we are associating T. So, now as earlier we say this is a continuation of that definition we say that L is acceptable in non deterministic time T in non deterministic time T if there is a non deterministic Turing machine there is a non deterministic Turing machine that accepts L in non deterministic time T non deterministic time T. So, we know just we have defined when do we say it to a non deterministic Turing machine accepts a language in non deterministic time T. Now, if you want to say a particular language is acceptable in non deterministic time T you should have one non deterministic Turing machine doing this performing that. So, in connection to that as earlier now I introduce this notation n time a class. So, n time T I mean all those languages L which are decidable sorry because this is non determinism here which is acceptable because there is no decision here acceptable in non deterministic time T in non deterministic time T. So, as earlier when we have talked about time T those are the languages which are decidable in time T that is a deterministic Turing machine here we are having a non deterministic version. So, n time T is all those languages which are acceptable because non deterministic Turing machine would not take a decision if the string is in the language it will simply accept. So, so within the required time it has to accept. So, acceptable in non deterministic time T n T. So, extending this now let me introduce the class what I was talking about n P I am using script letters to distinguish from other classes that would be talking about union n time n power d. So, d runs over natural numbers. So, what is the meaning of this this is all those languages which are acceptable in non deterministic polynomial time because n power d when I am writing. So, n time a polynomial if you look at you know this class is essentially same as n time n power d where degrees of that particular polynomial. So, we know this. So, if I am considering union of all those languages on all those classes. So, that is what I am calling n P. So, in words I can say that these are those languages which are acceptable by which are acceptable in non deterministic polynomial time instead of just saying non deterministic time that time I am associating it should be a polynomial. So, n P is the class of all those languages which are acceptable in non deterministic polynomial time T. Now, you can quickly see that you can quickly see that we know that every deterministic Turing machine can be seen as a non deterministic Turing machine. So, that is a restricted version and so clearly as time T or in particular I can write n d it is a subset of n time n d we have this this class P is contained in n P is very quickly to see because every deterministic Turing machine can be treated as a non deterministic Turing machine and thus I can say that P is contained in n P. Now, the question is whether these two are equal. So, the question is whether or not P equal to n P. Now, this particular problem in mathematics and computer science this is one of the you know toughest problems and this problem has such an importance the importance of with respect to the importance of this particular problem you know this is one of the seven problems listed for million dollar price by clay clay mathematical institute. So, clay mathematical institute just to just to give some you know importance of this with respect to that clay mathematical institute clay mathematics institute has announced million dollar price for say one for each of the seven problems and only one problem so far is settled and this is one of the problems among those seven problems. And if one settles this that means to prove whether P equal to n P or P not equal to n P it is very clear that P is contained in n P now the point is whether there is a language in n P which is not in P. So, that is the question so if one can address this problem who will get he will get here he will get one million dollar price as per the announcement of clay mathematics institute. So, this is one of the important and long standing problem in mathematics and computer science. Now, in order to talk about more details about this particular problem whether P equal to n P I will little more create some background to understand about this in this lecture that is let me start with this particular concept a function a function f from sigma 1 star to sigma 2 star is said to be computed by a deterministic or computed in time t by a deterministic because now I have to mention earlier I use it to simply say Turing machine because now we are talking about non determinism also simultaneously. I will now mention that deterministic Turing machine deterministic Turing machine M say let me write q sigma delta q naught f and only if for all x in sigma 1 star if you give that as input. So, the number of steps I am counting that is the main variant here affects the output that you are getting with t number of steps for some t t less than equal to mod x. So, in connection to this definition I will now make as earlier that we say f is computable in time t in time t if there is a deterministic Turing machine I will simply write a Turing machine Turing machine M that computes that computes f in time t. So, look here whatever the earlier procedures or you know concepts that we have discussed with respect to Turing machines we are now quantifying them. For example, in the previous lecture when I am talking about time bounded Turing machines for standard Turing machine I have taken there I have considered only the so called a decider and a quantifying a quantifying measure of that. That means, we have the decision we are quantifying. So, with respect to a particular number of steps the particular number is associated through a function. So, we are calling it as a time function similarly when I am talking about non determinism. So, for non deterministic machine also we have associated the number of steps because when it is taking when it when it is computing certain thing. So, the number of steps that we are counting and with respect to a particular time function that we are also with respect to which we are talking about we are associating a time function. Now, when I am talking about standard Turing machine you know there is a concept a Turing machine computes a particular function. Now, again in that particular context also we are quantifying it that means we are associating a time function to that particular concept. Now, in a similar thing I need not actually I have I need not introduced, but as a formalism I am introducing here. So, if you take a function a computable function that means a Turing computable function means there is a Turing machine which computes that particular function. Now, if you want to associate time to that how many steps it is taking to compute whatever the on the input that you are giving you know in a if a Turing machine computes a particular function. On every input it will use certain some output suppose x is given as input f x if f is a particular function it is halting by printing f x as output. Now, when we are associating time to that as earlier now here you will count the number of steps and the number if you want to say it is computing in particular time capital T the time function. So, the number of steps it is taking should be less than or equal to the capital T of that particular strength the length in terms of that. So, that is what is the variant now we are discussing here. So, a function f from sigma 1 star to sigma 2 star you take a function which is a computable function if you say there is a Turing machine which is computing this, but now when I am associating time to this it is computed in time t by a deterministic Turing machine m if for all the inputs that is from sigma 1 star when you take the number of steps it is taking if I write t. So, it should halt within t number of steps where t should be less than or equal to capital T mod x and now a function f is computable in time t if there is a Turing machine that computes in time t. So, this is the variant that we have defined now whatever the concepts that is associated to that is associated to Turing machines we will now in this particular topic complexity issues when we are discussing we will we will give the parallel formalisms and discuss with respect to the quantifying that. Anyway this concept I am introducing because we have just mentioned we have just talked about a problem whether p is equal to n p what I will do I will introduce an important class of languages which are actually very much useful in order to understand well about the problem p equal to n p. So, in the direction I will introduce a class called you know n p complete languages n p complete the class n p complete. So, for which you know I will just built up the background now through this concepts and now we will talk about the n p complete languages. In this particular context in case if you have the t to be polynomial in case t is a polynomial in case t is a polynomial we say that function f is polynomial time computable. So, this is polynomial time computable. So, just we have mentioned when do we say function is computable in time t that we have mentioned now if this particular time what we are associating if this time if it is a polynomial then we say it is a polynomial time computable function. Now, just to look at examples if you take a language which is already in p that means there is a polynomial time decider for the if this is if you take a language in p then this is a simple example straight forward example then the function if I consider the function f l defined by I define naturally this way y n if x is in l otherwise suppose if you define like this you know the corresponding the corresponding Turing machine on x it prints y if it is in l if x is not in l it prints n you know this thing. Now, since this is in p there is a polynomial time decider. So, the same decider you know compute this particular this thing is clearly and thus clearly is a polynomial time computable function a polynomial time computable function this is clearly a polynomial. So, f l whatever we have defined here. So, the same decider will be useful let me give some other example which you may understand better of course, that is a trivial and straight forward example what I have discussed now let me take this take sigma 1 to b say singleton a very simple example. So, that you know you will understand this concept better consider singleton b if I define the function f from sigma 1 star to sigma 2 star you know the strings of sigma 1 star they are simply composed a power n form what do I consider f of a power n I will simply send it to b power n n greater than equal to 0. So, I will just define like this now you can give a decider for this you can you can give a Turing machine which compute this function as earlier our input format this is we have fixed. So, certain number of s that you will give on the tape you are starting here. So, what do you do you may simply go through this and replace each a by b this is what you will print and you come back to this position and halt. So, either you will going you can print miss or while coming you can print miss whatever your wish take a left move if you have a print b there and take a left move keep doing this when you receive blank here you may simply take r hash that means you will come to this end from here you will come to this end. So, because you have to halt finally, here by the time you know you would have replace all the a's if they are available with b's. Now, you can ask me because when I am concentrating this particular Turing machine the alphabet can be can have this blank a's and b's because b need to be printed. Now, in this particular context if you receive say for example, b you can define arbitrarily because we do not want to handle that here. So, you define arbitrarily whatever that you want because particularly when you take the input which is in sigma 1 star because you look at the definition the way that we have defined. If you take x in sigma 1 star if you give that as input what are the number of steps it is taking to halt with the output f x because x we are taking from sigma 1 star only. So, I am not worried about if there is b. So, you define arbitrarily you define arbitrarily. So, this particular decider this particular decider what is doing if you have input a power n then it will print b power n on the tape and it will halt. How much time it will take suppose if you look at that look here you are starting from here you take a left move you take a left move here and then left move and so on. So, if you have n number of a's here you take n number of left moves and one more left move to this. So, there are n plus 1 left moves and while coming you are replacing each a by b that means there are n number of printing steps because each a is. So, n number of printing steps. So, from this position when you want to go here again you have n plus 1 right moves the total is 3 n plus 2 steps that we are taking. So, you can quickly see that this particular function if you consider tn to be 3 n plus 2 this function f I have considered f is computable in time t in particular this t is a polynomial and therefore, is a polynomial time computable function polynomial time computable function. Likewise you know just to make this concept familiar you know you can consider several examples of this sort and practice and see say some more let me just give you here. If I consider say sigma 1 equal to sigma 2 equal to say a b I may consider a function say for example, g from sigma 1 star to sigma 2 star I give like this if you take any string x I give x dash where x dash is obtained from x which is obtained from x by replacing a by b and vice versa. Suppose if you consider this function what you are supposed to do wherever a is there on the input tape you have to replace it by b wherever b is there you have to replace it by a that is what you have to do you will scan through that once and you will come back and halt the original position because the output format is when you give x you have to print f x on the tape and halt at the right blank. So, this kind of function also you can quickly realize that I hope you can observe that it will you can make it in 3 n plus 2 time. So, 3 n plus 2 is a polynomial this is also a polynomial time computable function and there are several such you know deciders that you have several such a touring mission that you have constructed to compute functions. So, you can now cross check like whether it is taking polynomial time what is the polynomial that you are getting accordingly you can report that some of the examples which are computable in polynomial time. Now, let me give another definition here let l 1 a language over sigma 1 and l 2 a language over sigma 2 the languages I am defining this now what I am defining a polynomial time computable function computable function f from sigma 1 star to sigma 2 star is called a polynomial time transformation. So, I am introducing this technical term here polynomial time transformation from l 1 to l 2 if and only for each x in sigma 1 star the following holds what is that x is in l 1 if and only if this f of x is in l 2. Now, can you guess what is the corresponding concept without talking about the time here look what is the concept we have talked about if you consider a language l 1 over sigma 1 l 2 over sigma 2 we are talking about a computable function from sigma 1 star to sigma 2 star satisfying a particular property what is that particular property x is in l 1 if and only if f of x is in l 2 what is this particular concept because when you want to talk about this you have we have discussed in the context of undecidability the reduction there is a reduction mapping as we say a language l 1 you reducible to a language l 2 when do we say that if there is a computable function from sigma 1 star to sigma 2 star satisfying this condition x is in l 1 if and only if f of x is in l 2. So, this is essentially quantitative version this is quantitative version with respect to time correspond of reducibility concept. So, I can also say this particular thing because in which case what we have written the notation l 1 less than equal to l 2 l 1 less than equal to l 2 that means l 1 is reducible to l 2. So, corresponding to that now this in this particular context I will put a p here which means that l 1 is polynomial time reducible time reducible to l 2. So, we know you know already the concept l 1 reducible to l 2 that means there should be a Turing computable function from sigma 1 star to sigma 2 star satisfying this particular condition whatever I am marking here. Now, we are associating to that computable function it should work in polynomial time. So, it should be a polynomial time computable function f and therefore, corresponding to that polynomial time I am just a subscripting this p also here in this notation. So, we call this as l 1 is polynomial time reducible to l 2 you can now says instead of calling this polynomial time transformation if you want you can also use this is called polynomial time reduction is also you can call it as also call polynomial time reduction polynomial time reduction. So, you are taking the reduction takes place from l 1 to l 2 more over this reduction takes polynomial time. So, the notation that we have introduced is this. Now, using this particular concept let me give the definition of NP complete class what we are looking for this is for NP complete language a language l say over some sigma or is said to be NP complete is said to be NP complete if and only the first condition we put is that language should be in NP number 2 for all l dash if you take any language in NP what do I require this l dash should be reducible to l in polynomial time. So, that is for every l dash in NP there is a polynomial time transformation let me write shortcut polynomial time transformation polynomial transformation from l dash to l. So, in other words every language in NP is reducible to l in polynomial time. So, the class NP complete the class NP complete we define like this clearly this is a subset of NP we are now we can you know suppose if this is NP class we have already observed that this is you know p is contained in NP, but we do not know whether there is whether there are some elements here or not in this gap and now this statement which is given in number 2 also people call it as NP hardness NP hardness what is the meaning of this that means the problem l is as hard as any NP problem that means if you reduce a problem in NP to this you know this statement that if l is solvable then l dash is solvable. So, that means this problem l is as hard as any NP problem therefore, this is called it as this condition is also called it as NP hard. So, this if I write like this NP hard this intersection because a problem which is in NP and NP hard this is what is NP c this is what NP complete problems NP c. Now, I have run purposefully you know by just with marking like this now I will present to you one important result as follows anyway let me just restate that once again reemphasize a language l in sigma star is said to be NP complete if it is in if it is NP as well as NP hard that is how this diagram is clearly showing this intersection of NP NP hard essentially NP complete problems. Now, the following result will be helpful to understand the big picture about the problem with respect to NP complete class the theorem is this the theorem is let l be an NP complete language then p equal to NP if and only if l is in p you see the statement. If a language is NP complete and if that language is also in p then p equal to NP and p equal to NP is possible if l is in p that means to get that million dollar price what you have to do if you can identify an NP complete language which is in p that is all. So, understanding this particular concept you know through NP complete is giving some characteristic property about the problem p equal to NP first let us prove this because one side is very obvious very clear that is this portion suppose l is in p this implies there is a deterministic Turing machine. So, this side is obvious the forward direction is obvious let me consider that first suppose p equal to p equal to NP then it is very clear that since l is NP complete from the definition you see l is NP complete l is in NP from the definition of NP complete l is in NP. So, that and since p we have assumed p equal to this p equal to NP you can say that l is also in p. So, this side is very obvious from the definition of NP complete. So, now let us consider this part. Suppose l is in p suppose l is in p this implies there is a deterministic Turing machine say m l. So, this implies there exist a deterministic Turing machine let me write simply Turing machine m l that decides l in polynomial time l in polynomial time. So, let me say that is p l the polynomial corresponding polynomial let me say it is p l. Now, what we have what we have to show p equal to NP to show p equal to NP we know clearly that p is contained in NP. Now, if you choose an arbitrary language in NP we will observe that that is also in p. So, that means let me start with an arbitrary language let l dash in NP be arbitrary let us take an arbitrary language from there an arbitrary language. Let us consider an arbitrary language since l now let us use the hypothesis that l is NP complete since l is NP complete what do we have this l dash should be reducible to l in polynomial time. That means, we have this l dash is less than equal to p l. So, that is there is a polynomial time transformation f from as a polynomial time transformation let me write like this say there is a polynomial time transformation under consideration say sigma 1 star to sigma 2 star because l l is an NP complete language I said. So, l is a subset of sigma 2 star if you assume. So, there is a polynomial this is a polynomial transformation which reduces l dash to l. So, that means this is a Turing computable function that computes that is computed by some Turing machine M f in polynomial time in polynomial time say let me call it as say P f. So, I hope I am clear here you start with an arbitrary language l dash in NP take an arbitrary language. Now, since l is NP complete we have l dash less than equal to p l that means l dash is reducible to l in polynomial time. That means there is a polynomial time transformation f from the underlying alphabets. So, here I am assuming that is l dash is l dash is a subset of sigma 1 star l is subset of sigma 2 star. So, f is a computable function which is computed by Turing machine. So, this is a Turing machine. So, this is computed by Turing machine M f in time P f. Now, what do I do I will give you a Turing machine which computes l dash in polynomial time which decides l dash in polynomial time. So, that this is an arbitrary language l dash goes in P and thus you will have that P equal to NP. So, what is the Turing machine you can also quickly see this if you consider M f M l what is M l M l is a Turing machine that decides l if I compose these two Turing machines M f and M l. So, in this in this form now you observe that if you give any input to M f what happens from sigma 1 star whatever that you give by the time. So, let me draw a small picture here what I am the composition you know this kind of construction. So, the input x say for example, if you give to this what are the output because this M f produces f x this f x will be given as input to M l and M l is a decider it says yes or no this is the this is the idea. Now, you observe that if you give x to M f it gives f x and f x is fed to M l if it says yes what is the meaning of that f x is in the language l if it says no f x is not in the language l. So, now using this condition since f is a polynomial time transformation from sigma 1 to sigma 2 star what is the condition associated to this here whatever that x is in l dash if and only if f of x is in l this is the condition associated to this when it is a polynomial transformation. Now, if f x is in l then corresponding to that it says yes if f x is not in l then it says no that means if and only if this particular Turing machine this M f M l says yes y on x I am just marking here once again if you give an arbitrary input x from sigma 1 star from this alphabet M f will compute and leaves f x as output. So, with the condition that x belongs to l dash if and only if f x f x is in l with this condition and now f x when you give input to M l it says yes it says yes only when f x is in l otherwise it says no. So, what is the condition we have f x is in l if and only if this M f M l this particular Turing machine says yes on x. So, that means clearly this M f M l this Turing machine M f M l decides the language l dash. So, what do I get we have got a decider to decide the language l dash now how much time it takes if you look at that sits M f M l how much time it is taking if you look at this particular one by the time it finishes as we have assumed p f is the particular function polynomial. So, it takes this much time this much time to get the output here f x and what will be the length of f x if you look at the length of f x will be maximum this much this is the maximum length of f x. Now, on this particular output f x will be applying this M l where p l is the polynomial that much time it will take. So, some of these two. So, clearly some of this is a polynomial with the parameter mod x and this is a polynomial composition of a polynomial. So, clearly this is a polynomial clearly this is a polynomial. So, that means for l dash we have got a decider which decides in polynomial time and thus l dash is in p. So, since l dash is arbitrary we have p is equal to n p. So, through this result you understand the importance of n p complete languages. So, if you know some. So, just look at this statement if you know some n p complete language if you can obtain a polynomial time decider for this then p equal to n p the problem will be settled. But of course, getting such a language n p complete language and in fact observing the language is n p complete is very difficult because if you look at the definition you have to reduce every n p language to that in polynomial time. So, there has to that is one hard condition to observe and you know even if you get an n p complete language in hand observing that it has a polynomial time is even tougher task. So, that means to show that p equal to n p we have a characterization here. So, through this I am just presenting you know the concept of n p complete through the concept of n p complete and we have observed the importance of n p complete languages as well. We will continue these discussions in the future lectures you know by identifying certain n p complete languages etcetera.