 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 arity 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 a 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. 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. 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 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 for universal quantifier universally choose one of these and do the same 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. So, the time that we are talking about is like the free 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 the quantifier depth. So, quantifier rank many assignments so you will quantifier rank of three times for each of these you have to look at log a bits a is the domain here. So, you got 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 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 free times again the for each of these this many bits you have to store. So, this much space in case what is width of fee the width of a formula is the maximum of how many free variables you have got where that fee prime is a sub formula fee closure of fee 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 way. So, this is this much space. Now, very simple algorithm and what is to 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 p space. 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 q b f you only think that we know for doing p space hard enough right. So, if you have a q b f 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 this 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 unary 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 unary predicate p i x and wherever I had something of the form there exist p i I will make it there exist x x i sorry and for all p i x i is what I should 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 q b of sentence alpha evaluate to one if and only if in this structure p alpha is true that tells you that in fact first order model checking is p space complete. So, looking at this we get further some some more by so 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 a right. 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 we 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 right if I fix a property and then I am looking at various structures graphs having that 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 mean not as a I take these structures as input somehow we will see right and I want to check whether the input structure satisfies this 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 is 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 is something that you can check very easily but it is not first order definable right and you do an EF game and show that it is 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 are 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 am not going to take up that I want to just say that we are 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 for first order logic we need to do something not clear what exactly we should do the 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 going to 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 it and then gives me an element of Sigma star well you're machine three 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 structure I'm being loose 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 if and only now I'm only talking about codes to you could want I just wanted so the linear order on a finite set so that everything 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 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 for every a Sigma I have a formula for every K this kind to say that if I take if I take the X bar element in the C 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 parity K you've got any elements in the domain you've got utmost end to the K tuples that you're 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 A 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 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 you're coding another thing that we can assume or rather we will assume is that the atomic case is efficient to check so what do I mean by that I mean if you have got a structure and I have some R which is in the vocabulary and I want to check that particular tuple satisfies this so 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 we'll 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 sigma star so I'm saying that so this is that x barth element of is labeled in the structure that I'm evaluating it the property I should be able to 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 is there that's a property that I want to define 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 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 a 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 tau if I give a if I give a sentence if phi is an L sentence probably tau 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 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 the A belonging to take all the structures which take the codes that is the language and that language is in the complexity class so now if I now have for any class of structures there exists a sentence such that again you have the in the for yes of course 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 if I take all the structures that satisfy it is exactly that 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 that I will 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 if I take a sentence now look at all finite structures finite models of that 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 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 so this is a local job but in fact spectra can be thought of in the following way if you have got a spectrum there is a first order sentence this first order sentence is over some vocabulary 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 exist some r1 there exist some rn such that this first order sentence over this vocabulary 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 what about finite models of these once you have got this you might as well ask this question over some arbitrary relational vocabulary as well and then you have quantified away some of them so those are what are called generalized spectrum so this is something that our upa minister would be even more pleased with so generalized 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 you write these and free where this is over a vocabulary which may have these r1 through rn and some more and if you like Greek symbols you call the sigma 11 and Fagin's theorem says that a class finite models is a generalized spectrum if and only if it is an NP 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 you can get some piece also out of the proof suppose you are given a sentence in ESO so you are 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 am going to take ordered structures and look at the codes and what I am now saying is the problem is I have a Turing machine that is supposed to sit and look at some given structure look at the code of that structure and see if it satisfies the sentence I want to show that that is something that can be done by an NP machine that is what it means to say that this is an NP so how is your NP machine going to look at this so I am 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 is of Arity K then that relation can be represented as a bit string of length so R Arity K I should say R I K 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 does my Turing machine do it first guesses these N relations all these bit strings it just sits and 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 is something that I can do in fact in polynomial time I have fixed this for the fee and I am 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 so 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 Fagin's theorem says that a 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 a Turing machine M it's operating over codes so it's operating over the alphabet the coding alphabet sigma delta q 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 does 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 it's going to give an output accept or reject so it's accepting a class in this way 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 size 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 phi such that the structure satisfies phi if and only if this x bar these relations code up the computation computation table if you like of the machine M this is the 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 x bar then what I can do is the ESO sentence that we are looking for basically is of this kind so the C 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 so Prithik started with saying 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 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 1 to k and this is something as I said that we will code them up by tuples in a to the k that's the obvious strategy and we can we can define successor we can define so given any x bar here I can define x bar plus 1 x bar minus 1 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 am saying is that lifting it to the like psychographic ordering is something that I can write in first order logic as well so we have formulas for all these 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 let me call it 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 the structure and end I have to say that I am not in one of the rejecting states 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 will have 1 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 a belonging to sigma I will have y a to be the pairs t r such that machine in state q reading the arc cell finds symbol this is another relation that I love and then something for head to say that at time t actually I don't know at time t is enough so that's why I don't have time t reading r that's enough so at time t if I have these from this it's quite straight forward to write all the this end is the simplest thing right so let's write that this says that and over minus not of xq it says that I am not in a final state I am not in a rejecting state and of course we want a code of the last one in fact you can code 0 you can code the last element all these things you can do more but this is for a particular coding for a particular reason so start what are the things that we have to say I have to say that in at time t I am in state q 0 and I am at time 0 I am at the left most position and here is where I need that coding I have to say I am 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 now what do I want 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 am looking at is reading the letter a if that is so my y predicate should be saying at time 0 that particular symbol is having the that is the place where you use it there is only place where you need it actually so this is clear now I have to say how do you do the one step 2 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 I am 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 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 1 this is where I then at that position it continues to be a if the head is somewhere else right whatever movement I make I am not going to change it is only where the head is pointing I will make a change right if it is somewhere else I am not going to that is what what about change just writing in place like this I hope you do not mind I just got used to it over here to write arrow A is going to say actually once you understand the meaning of these things take forward what you should say but let us just do this because this is the only one that is going to be of some importance as we go so if you are in state q so you are in state q at head is at the r bar cell and y a off and and in the post if I want here is maybe I will call it x and y sorry post is going to have at the next instant I am in prime and z is going to be y bar a prime 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 you know looking at successor on that and that is a critical one that is 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 have 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 am not going to do this proof I assure you you can sit and do it and it goes through and actually 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 it's an interesting exercise but I am 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 one one 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 so again let me 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 prefixes 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 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 started with first order spectra and we said I can always put an existential second order 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 am always talking about something that is close standardized morphism 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 have got is a set right now if it's a set that what is the representation of that as a bit string that will 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 very interesting line and therefore you can next p time yeah next p time and so therefore the representation 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 as I said some money for value or whatever I don't know what the good English term for it 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 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 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 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 I can write this as implies so I can split this into three formulas of this kind well I bother because they have a particular form these are horn formulas these are horn clauses I have 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 horn satisfiability is something that we know something that we can do efficiently so horn clauses have a particular status so there is one suggestion here that maybe if you want to capture not NP but if you want to look at polynomial time if you have 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 this gives a suggestion for what kind of a logic that you might be looking for if you are trying to capture instead of NP so the logic that you look at is the following there exists R1 and then you have where these are horn clauses which have a particular form in general it is just some string of first order quantifiers and horn clauses using these just want to distinguish between variables that occur in the head then variables that occur in the tail you do not need to do that let me so the clauses 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 f o formula not involving the R1 through Rn and this is either a positive atom or 0 so this is the horn clauses this is a little weird here so for the moment I will come to it a little later this is I am 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 beta