 So, I will start with some discussion on a for model checking and from that we will move on to Fagan's theorem and some consequences. So, what is the situation here we are looking at a finite structure and you are asked whether a formula of a stratologic is true in it and you have some to the domain A. So, the structure by structure I am always talking about in this case a relational vocabulary. So, you have a domain you have a set and some end relations given to you of appropriate additive and so we will be interested in what is the complexity of this something that probably very easy that everybody knows about. This is just the evaluation problem you are given the formula and you are given an assignment to the free variables you just have to find out whether it is true or false right. So, how do you do that well simple way is first push all the negations inside and then you have an alternating algorithm the structure is finite everything is only finite now ok. So, how does it do? So, you look at the structure of the formula in the atomic case well you are already given the structure. So, that means you are given the finite structure interpretation for all the relations for your atomic formula just evaluate it you have it is a positive or a negative negative atom evaluate this is positive or negative atom and then when it is of the form C 1 or C 2 choose I belonging to 1 to 2 and then run the model checking algorithm for the same structure where you take the free variables of V i if it is conjunction universally choose one of the two and do the same for existential quantifier choose some element of the domain now we have rho a and for universal quantifier universally choose one of these and do the same as above. Now, how much time does a procedure like this take? Well you have to look at the depth of the syntax tree. So, the whatever depth or height of the syntax tree you have to go down that much time and then you have to look at the time needed for the variable assignment right. So, the time that we are talking about is like the phi plus well on every path what you have to do you have to look at the quantifier rank many what is the quantifier rank you are nesting the quantifier then as the quantifier depth right. So, quantifier rank many assignments. So, you will quantifier rank of phi times for each of these you have to look at log a bits a is the domain here. So, you got so this is this much time alternating time what about the space requirement? Well at any point of time you have to store the current you have to store a pointer to the current position in the formula that you are looking at. So, that will require log length of phi well again variable assignment you have to store the current assignment right for whatever free variable that you are looking at well you have to look at the free variables for every sub formula because you are going into sub formula. So, you look at the width of phi times again the for each of these this many bits you have to store. So, this much space in case what is width of phi the width of a formula is the maximum of how many free variables you have got where that phi prime is a sub formula phi closure of phi we can say, but do not worry. So, basically look at all the sub formulas look at how many free variables are used and take the maximum that is the width. So, this is this much space now very simple algorithm and what is this say that well this is alternating linear time and we know that alternating polynomial time you can identify with p space. So, this is an algorithm that is in fact it is very easy to in fact also show that the problem is p space complete. How do you do that reduction from QBF? The only thing that we know for doing p space hard enough right. So, if you have a QBF sentence alpha right I want to reduce it to the model checking problem for first order logic right. That means I have to pick a structure and come up with a first order formula such that the validity of the sentence this sentence evaluates to one if and only if in the associated structure that I have picked the formula that I have designed is in fact true in that structure well what is the structure that I pick. So, structure I pick is very simple A is 0 1 I have a unity predicate on it which is going to evaluate to one. What is the translation not very difficult to guess right because yes. So, wherever you have a atomic proposition p I map it to. So, let us say p i I will map it to a unity predicate p i x and wherever I had something of the form there exists p i I will make it there exists x x i sorry for all p x i and that gives you a translation and it is then on this particular structure where each of these variables can take Boolean values you want to make sure that the formula that you are constructing you construct this formula now. So, given alpha I have you construct this p alpha and you can check that the QBF sentence alpha evaluates to one if and only if in this structure p alpha is true and that tells you that in fact first order model checking is space complete. Looking at this we get further some more pysauce for after all defining it that way. What is that if I fix a formula p and look at the complexity of model checking of if I now want I want to look at all structures a such that. So, the only input I am going to look at is these structures and I want to see what is the complexity then it is clear that this is something that I can do in alternating logarithmic time and in fact I can do it in log space deterministic log space. So, if you fix p the model checking that we are looking at is in deterministic log space basically says that if you have got a first order definable property then I can check it algorithmically quite easily. If I fix a property and then I am looking at various structures graphs having the property and I want to check and it says that if it is a first order definable property then I can check it very easily that is really what this is about. What about the converse so what is the statement that I am saying if property is first order definable checking is easy as a kind of slogan or mantra. I want to check I take these structures as input somehow we will see and I want to check whether the input structure satisfies the fixed property of course how do you take structures as input is the sort of thing that we want to but what about the converse if I can check a property easily maybe in log space I can I define it in first order logic now this is not only false but it's sort of miserably false and this is what Abhishek was spending time explaining to you that look there are properties like what just that the domain has only even number of elements right it's something that you can check very easily but it's not first order definable right and you do an EF game and show that it's not first order definable lots and lots of properties that you can check quite easily but you can't define them in the first order logic for the relational vocabulary that you're talking about now of course you can say why first about relational vocabulary maybe you should look at you know vocabulary with function symbols addition whatever nice things like that so I'm not going to take up that I'm going to just say that we're going to stick to relational vocabulary there is going to be a lot of stuff on databases and so on so that should be enough motivation but there are other but question is is there some way you can relax relate logical definability and computational complexity that's the general question and that is really what motivates all this stuff so what we want to do is to relate logical definability the grand program is that computational complexity but first order logic we need to do something not clear what exactly we should do but there is this problem already right what is you take a property and you want to take structures as input and check how are you gonna check structures as input we are used to tuning machines which read words right so one good way is to say I'll have coding I'll have a code which will take an ordered structure that means what not only do I take these finite structures that I'm talking about I'll assume that there is some ordering on and then gives me an element of Sigma star well doing machines read words so you have code but then logics do not distinguish isomorphic structure so that means the recording that we choose should preserve isomorphism or identify isomorphic structures I'm being lose but what I want to say is that if you take two structures that are isomorphic the code should be the same and if two structures are non-isomorphic the code should be different I'm talking about an effort only I'm now I'm only talking about codes I just want to say yeah yeah so this is a linear order on a finite set so and it should be polynomially bounded in what in the size of the domain set right so if I take a structure and produce a code for it that code should not be too long right it should be poly in the size of the structure what else will we want well I would want it to be a for definable by which I mean that I have a first-order formula so something like for every a Sigma I have a formula for every k kind to say that if I take if I take the x bar element in the sea in the word that is labeled by a what do I mean by the x bar element right so what we want to do so the trick is basically going to be code numbers by tuples okay so you've got this so you take any relation of arity k you've got any elements in the domain you've got at most n to the k tuples that we are going to look at right now once you have a linear order on the elements of the domain I can lift it to a lexicographic ordering k to the k I take the lexicographic ordering and again I can define a linear ordering on this right so numbers from 0 1 to n to the k I can identify with tuples right so when I talk about that I can talk about a bar element which is actually something here right so this is the trick and this is something that it's easy to do but unless you work out a couple of coding in exercises in you know in the tutorials this thing is not entirely clear what the problem is but I would suggest that it's easy to do you can write a sort of formula for doing that and this is something we will assume that your coding another thing that we can assume rather than we will assume is that the atomic case is efficient to check so what do I mean by that I mean if you've got a structure and I have some R which is in the vocabulary and I want to check that particular tuple that is basically I want to check the atomic case I should be able to go down right remember this is presented as a string to me and the fact that whether this tuple is in this relation or not is going to be somewhere down the string I should be able to go there and figure out this is a check that I should be able to do efficiently efficiently linear time lock space choose your so some coding will assume so basically your finite structures if I want Turing machines to read they'll be reading not the structure of course but codes of structure so when we talk about a class of structures being in NP or being in P space or whatever we are talking about the codes of these structures forming looking at the languages of subjects of sigma star yeah so I'm saying that so this is that x bar element of is labeled in the structure that I'm evaluating it yeah that property I should be able to yeah so basically when I go down in the list I want to find the whatever jth element by going over to the tuple I should be able to check what is the letter of the alphabet that's a property that I want to because your Turing machine will have to go down in the string which is coding the structure and figure out whether the particular letter is A or B or C or O okay so if we have these now we can try to define given a language L by which I mean a given a logical language a complexity class C class of structures class of finite structures and from no one when I say class I'm talking about a class of structures that's closed under isomorphism and over a non-empty vocabulary so this is something that I'm going to whenever I say class I'm not going to write this closed under isomorphism we say that what is it that we want now you give me any for any vocabulary now if I give a sentence if phi is an L sentence vocabulary now I can look at the class of all structures right so if I now look at all codes of K I'm going to assume ordered structures this is an ordered structure over that particular vocabulary such that is in the complexity class this is one thing I want right so basically the problem of checking this property over this class of structures is in this complexity class it can be done in whatever appropriate resources and the other way what is the other way you give me any class take any structure in the class and if I look at A belonging to take all the structures which take the codes that is the language and that language is in the complexity so now if I now have for any class of structures there exists a sentence such that again you have the in the in the for yes of course K if I take a class that so here I have to actually write code of K so if I take a class and take the language that you get by looking at the codes if it is in the complexity class then I can define it such that the problem of checking all you know if I take all the structures that satisfy it after all this can we actually do something and that's really so to think about this there is one interesting and it's a famous thing to know so I might as well mention so given any first order sentence I can talk about the set of all numbers such that he has a model of size n I take a sentence now look at all finite structures finite models of sentence it has a model of that size so this is called a spectrum this is a subset of natural numbers and one of the very old questions was characterize spectra another interesting question was is the complementation of a spectrum a spectrum is the complement of a spectrum interesting questions and important questions so important that in India there is a you know controller and auditor general looking at spectrum problems and you know this is a local joke yeah there but in fact spectra can be thought of in the following way if you've got a spectrum there is a first order sentence right this first order sentence is over some vocabulary top let's say it's over R1 to Rn I can identify the spectrum of a first order sentence spectrum with models of a second-order sentence which looks like this consider a second-order sentence where I quantify there exists some R1 there exists some Rn such that this first-order sentence over this vocabulary hold right whatever if it has a model of some size at all this fellow is going to have finite models all finite models of this second-order sentence but this is over the empty vocabulary in fact what you can do is now that you have got this idea that okay so why not look at models of existential sentences second-order sentences which have a string of existential quantifiers of this form and then a first-order sentence over that vocabulary right what about finite models of these once you've got this you might as well ask this question over some arbitrary relational vocabulary as well fees over some vocabulary and then you have quantified away some of them so those are what are called generalized spectrum so this is something that our u.p.a. ministers will be given more please read so generally spectra now what we are looking at are finite models of sentences of this form so sentences of this form is what we call existential second-order logic where there basically these and fee where this is over a vocabulary which may have these R1 to Rn and some other words and if you like greek symbols you call this sigma 1 1 and I guess theorem says that class of finite models is a generalized spectrum if and only if it is in this sense that the complexity class NP is identified with class of finite models of existential second-order sentence and so what this talk is really about is a proof of this theorem and as I said if we can get some price also a lot of the proof suppose you are given a sentence in ESO so you're given something of this form now I want to show that if I look at the class of all finite structures that satisfy it so take all now we are as I said I'm going to take ordered structures and look at the codes and what I'm now saying is the problem is I have a Turing machine that's supposed to sit and look at some given structure look at the code of that structure and see if it satisfies the center and I want to show that that is something that can be done by an NP machine that's what it means to say that this is an NP machine so how is your NP machine going to look at this so I'm given a finite structure finite ordered structure in fact and now I want to check whether it satisfies this now the domain is of some size n now take any particular relation here it's of arity k then that relation can be represented as a bit string of length so r arity k I should say r I can be represented by a bit string of length k to the n to the k so I can represent it by a bit string of this length so what is my Turing machine do it first guesses these and relation all these bits just it's and guess guesses and then now it checks whether this is the first order now first order model checking as we observed is something that can be done in polynomial alternating linear time is what I said well for this particular for a fixed formula it's something that I can do in fact in polynomial time I have fixed this free and I'm looking at so here is something that a machine which guesses polynomially many bits and then applies a deterministic polynomial time algorithm this is what an NP machine finds very joyful to do this is something that can be done in by an NP machine so if you give me an existential second order sentence checking whether a finite structure satisfies that property is something that is an NP against theorem says that the converse is also true what is that you start with a class of structures that's an NP I can find an existential second order sentence whose models are exactly though so how do you do this this is the coding that we are all used to so let's assume that we have we have a Turing machine M it's operating over codes so it's operating over the alphabet the coding alphabet sigma delta q 0 some accepting states some rejecting states the initial state and delta is a map from q cross sigma to minus one for move left zero for state one for move right and what is this machine do it takes the code of a structure and checks and in time n to the k where n is the size of the domain it's going to stop and give an output except other deck right so it's accepting a class in this way right when we say that a class is in NP what do we mean there is a Turing machine of this kind which will take a member of that class a code of a member of that class and it's a poly time machine so that means so if it takes the code of then where n in time n to the k it accepts or rejects so what is the strategy the strategy for constructing a sentence well you come up with a bunch of relations some whole bunch of relations and a first order formula fee such that the structure satisfies me if and only if this x bar these relations code up the computation computation table like off the machine this idea you come up with a first order sentence that codes up this n to the k size computation table sitting there if I can come up with a first order formula of this kind over this vocabulary then what I can do is the ESO sentence that we are looking for basically is off this kind so the fee that we are looking for will say there exists less than there exists x bar less than is a linear order this is the sentence that we are looking for if we do the job of constructing the first order sentence correctly this stuff can be done right so Prithik started with say how you would write it and you have a bunch of existential quantifiers sitting in front second order quantifiers and this will be an ESO sentence of the property so this is what we need to do and for doing this what are the things that we need to do as I said we have to code up numbers k and this is something as I said that we will code them up by tuples in a to the k that's the strategy and we can define successor we can define so given any x bar here I can define x bar plus one x bar minus one and for any fixed integer m I can define x bar plus m these are all things that I can define in first order logic that means what I'm saying is that lifting it to the lexicographic ordering is something that I can write in first order logic so we have formulas for now what is the fee that we are going to look at this is the usual thing it's going to have some thing about the starting state and one step or do and end how do I write all these things I have to say that initially the machine is in to the left of the tape scanning the input code of that structure and end I have to say that I'm not in one of the rejecting state and in here I have to look at the transition and so far this I need some predicates and I need some relation that so for every q we'll have one xq which is a unary predicate this will have the codes of all time time t such that machine is in state q at time t for every for every a belonging to sigma I'll have y a to be the pairs t r such that machine in state q reading the arc cell finds symbol a this is another relation that and then something for head to say that time t actually I don't know at time t is enough that's why I don't have a time t reading arc that's enough so at time t if I have these from this it's quite straightforward to write all the I mean this end is the simplest thing right so it's right this says that and over minus not of xq it says that I'm not in a final state I'm not in a rejecting state and of course we want to code of the last one in fact you can code zero you can code the last element all these things you can do more but this is for a particular particular coding for a particular reason so start what are the things that we have to say I have to say that in a time t I'm in state q zero and I'm at time zero I'm at the left most position and here is where I need that coding I have to say I'm reading that input symbol right the input what is the input the y is going to what is the y going to say and over alpha a implies it says that if you now look at the code of the input remember I said my code has the property that I have a first order formula that tells me if I look at the string out there right any particular position that I'm looking at is is reading the letter a if that is so my y predicate should be saying at time zero that particular symbol is having the that's the place where you use it it's the only place where you need it so this is clear now I have to say how do you do the one step two is going to have two parts the part that needs no change and the part that says transition how do you say when do you say no change well I'm reading some symbol a and the head is somewhere else right at the next step I continue to read the same symbol right obviously suddenly the some dramatic changes should not happen so Nate no change here so if I have got time t the exit position is reading a and head is somewhere else means anti prime plus one this is where I use all this then at that position it continues to be a if the head is somewhere else right whatever movement I make I'm not going to change it's only where the head is pointing I'll make a change right if it is somewhere else I'm not going to that's what what about change writing in place like this I hope you don't mind I just got used to it over here so preq a is going to say actually once we understand the meaning of these things it's straightforward what it should say but let's just do this because this is the only one that's going to be of some importance as we go so if you are in state q so you are in state q at head this is at the r bar cell and y a off and and in the post I want here is maybe I'll call it x and y sorry post is going to have at the next instant diamond prime and z is going to be y bar y a prime and I have to talk about this move to the left x and y are related by this m now there is a little predicate here let me in the interest of time skip this here this is just going to say if m is minus one I have got to y bar is actually x minus one x plus one the z is written correctly I have to do the coding I want to skip a bit because time is running out and I want to say a few things now for people who are used to the cook levin coding is not this is quite similar but except that you are using this lexicographic ordering and come you know looking at successor on that and that's a critical one that's a non-trivial the mark being made and there is some particular structure here this is the only thing that you really have to concentrate on now of course having done this coding you have to prove right this is the sort of thing you always do and say you know as an exercise you sit and show that now I've got a coding for this thing there are two statements to be proved if you remember right if I consider a structure the steering machine if it holds correctly actually that satisfies the sentence and if I take any structure that satisfies it my machine will accept it I'm not going to do this proof I assure you you can sit and do it and it goes through nicely basically you have to set up a configuration the idea of the steering machine check that it's coded correctly at each step and go down there are some subtleties one thing common point it's an interesting exercise but I'm not going to do that this is only to remark that you so for against theorem you can do this coding and convince yourself that existential second-order sentences that is sigma 11 sentences capture NP in a precise way in fact you can just going to mention a couple of things you can go further and show if we write this as the slogan ESO equals NP again we write it as a slogan like this whatever we have talked about you can do you can go through the proof you can think a little more and in fact convince yourself that second-order logic if I don't have existential prefix if I look at arbitrary second-order sentence that gives you the polynomial time hierarchy and then we said something about these things are over a non-empty vocabulary right what I mentioned spectra what are spectra spectra are finite models of existential second-order sentences over the empty vocabulary that's how we got it right started with first-order spectra and we said I can always put an existential second-order you know a prefix of that but there is a bit of a problem over empty vocabulary in this that I was doing I said whenever I write a class of structures I'm always talking about something that's closed into the isomorphism over non-empty vocabulary please when I write kappa think that but that's very critical when we are you know thinking about this because over the empty vocabulary right how will you represent the string the coding that we did was polynomial in the size of the structure right but if over an empty vocabulary all you've got is a set right now if it's a set that what is the representation of that as a bit string that'll be logarithmic in the size of the structure right so the coding that you do will give you something that's exponential right this is going to be something that runs in time exponential in the size of the input if you pursue this logic in fact you can show that the spectra correspond to xp time it's a very interesting line and therefore you can next p time yeah next p time and so therefore the complementation problem amounts to saying is next p time equals co next p time so this is only to say that from just looking at the way you do the coding and thinking about it you can get some money for value or whatever i don't know what the good english term for it anyway so the but actually you can get even more by looking at the coding a little carefully if you look at the formulas that we have used right they all have a particular form except this fellow here actually i should write it so that you can see the drama if i did the same thing but if i had a machine that was not a non-deterministic an np machine but supposing what i was doing was actually a deterministic machine so i start with a tuning machine that's looking at structures right and in deterministic polynomial time comes out and says accept or reject and i'm trying to code it as a sentence of this kind what will be the kind of coding that i would be using just go down this and see now here something will happen here i don't need this disjunction right i don't have to go through this for all once i have got qa delta is going to tell me precisely what is the triple that i have got so i can actually replace this by the following formulas so i have uh i can write this as implies so i can split this into three formulas of this kind why should i bother well i bother because they have a particular form these are horn formulas these are horn clouds i've written it as conjunction with a head sitting here always with one formula to the right of the conjunction and i was doing the first sort of model checking i wanted to look at the horn case as well and i forgot okay yeah so it's because well horn satisfiability is something that we know something that we can do efficiently so horn classes have a particular status so there is one suggestion here that may be if you want to capture not NP but if you want to look at polynomial time right deterministic polynomial time if you've got a deterministic Turing machine sitting here and you are doing the coding the logic that you should be looking for is not full existential second-order logic but existential second-order horn of some kind what is that logic right this gives a suggestion for what kind of a logic that you might be looking for if you are trying to capture P instead of NP so the logic that you look at is the following it exists R1 and then you have where these are CIR horn classes which have a particular form in general it's just some string of first order quantifiers and horn classes these just want to distinguish between variables that occur in the head then variables that occur in the tail you don't need to do that so the the classes have a particular form what is the particular form that they would have they are of the form some head where each of the beta i's are positive atoms or some fo formula not involving the R1 through Rn and this is either a positive atom so this is the horn classes this is a little weird here so for the moment I'll come to it a little later this is I'm saying this is simply suggested by what kind of coding you might want and fixing it from the coding that you have so this is basically the ESO horn logic and the claim is that over ordered structures this logic captures p time there's only red this is the claim for one way basically we have then this is over and it's critically over ordered structure and it's important because earlier for doing the fagin coding what did we do we went through all this to come up with the first-order sentence and then prefixed it with something saying there exists less than there exists all this stuff right and inside you could say less than is a linear order but you can't do that now saying that something is a linear order is not something that i can use with on i can do with corncloth proof of that is something else i'm only saying that you can't do it and therefore you have to have ordered structure now so this is something that's a very important theme here that if you're going to talk about logic scattering p time you're saying it over ordered and that's why when we started doing the coding we started with ordered structures take the order and lift it to the elixicographic ordering on a to the k and use that in all the coding so this is something that's built into this whole machinery so by the way when you're doing this stuff much you must think about well formulas order invariant it's not relevant perhaps to this but now that we are thinking of it might as well right so i'll say that c is ordered invariant if i take any structure a if less than and less than prime or two different linear orders on it i would like this you would ideally like that it should not matter which linear order you choose on the on the domain right now as an exercise think about what kind of formulas would be order invariant what kind of formulas are not order invariant play around with this and it'll give you some clue about why all this fuss is being made that's one thing in fact also now that we are about it if i give you a formula can you check whether it's order invariant or not check something like that any if this were how about looking at it this way i suppose i had an algorithm for checking whether a formula is order invariant how would i use it in all this test of technology that so clearly i'm saying that order structures is quite critical here but if you're you know i could do some preprocessing check that my formulas order invariant i could just use it and then something is going on here okay so i don't know maybe this is it in my class usually ask for a vote right how many people think that this is something that you can check check efficiently or you cannot check at all that is undecidable i think a conjecture is worth making because that will help you think about this i think i'm not going to go into that i think there will be a lot of fuss about