 .In today's lecture, we will discuss Homsky hierarchy. Already, we have seen a few class of languages, regular languages, convex languages and recursive languages and then recursive and immorable languages. We have characterized all these class of languages grammatically and also using automata. We have found that regular language is a proper subset of convex free languages because every regular language can be generated by using some contract free grammar. But there is a language like say a to the power n b to the n and gatoran equal to 0, which is not regular that we have already proved, but this is a convex free language. Similarly, every convex free language is recursively immorable language because every convex free language can be generated by using some unstructured grammar and except by some Turing machine. But there is a language a to the power n b to the power n which is recursively immorable, but not convex free. So, that way regular language is properly contained within convex free language, convex free language is properly contained within recursively immorable language and then we will introduce some more class in between which is called context sensitive language and these four classes, these four classes of languages are said to be Honsky hierarchy is named after the famous language Honsky who proposed these languages as natural model for natural languages. So, this confinement we can show that regular language is properly contained within convex free language, convex free language is properly contained within recursively immorable language and we have introduced that regular right linear grammar generates regular language that means regular language generated by regular grammar and finite grammar accepts regular language and finite grammar and regular grammar these are equivalent that we have already shown. Similarly, two zone .tomata and convex free language, convex free grammar they are equivalent. So, p d a accepts convex language and a convex free grammar generates a convex language. Similarly, a Turing machine accepts recursively immorable language and similarly, a recursively language, immorable language is generated by an unrestricted grammar or structured grammar the same thing. Now, let us recall the definition of structured grammar. A structured grammar is a quadruple n t p s where n is a finite set of non-terminal symbols, t is a finite set of terminal symbols and s which is a non-terminal is called the start symbol and p is a finite subset of v n v star n v star cross v star where v is basically union of non-terminal terminals is called set of production rules. That means production rules is written basically by this notation alpha goes to beta where alpha is from v star n v star and beta is from v star that means beta may be epsilon, but the left hand side alpha must contain at least one non-terminal symbol. Now, if left hand side of each production is a non-terminal simply then we say that the grammar is a c f g. So, this structured grammar is set with c f g if the left hand side is a single non-terminal symbol. In addition in the right hand side of each production rule is a terminal string flowed by at most one non-terminal symbol then a grammar is set to be a regular grammar. So, based on this we can have a classification of grammar. So, alpha goes to beta if there is no restriction other than the rule that we have already given is said to be a type 0 grammar. If we keep on imposing some restriction on both sides then we get some other kind of grammar if length of alpha left hand side is less than or equal to the length of the right hand side then we say that this grammar is a type 1 grammar. And if the left hand side is single non-terminal it is called type 2 grammar or context free grammar. If besides this if the right hand side beta is either a sequence of terminal symbols or a sequence of terminal symbols followed by a non-terminal then we say that is type 3 grammar. So, already we know that the type 3 grammar generates regular language, type 2 grammar generates context free language, type 0 grammar generates recursively and invariable language, but we did not mention so far this type 1 grammar. We see that the type 1 grammar is nothing but it is called context sensitive grammar and it generates context sensitive language. So, we will first introduce this context sensitive language we will characterize this context sensitive language and then we will show that context sensitive language is properly contained within this recursively and invariable language in fact recursively language and there is at least one context language which is not context free. So, this shows the proper contentment of CSL within recursively language and CFL is within context sensitive language. Just consider an example of context sensitive language say this is a language n equal to equal number of ways followed by number of ways followed by same number of bs followed by same numbers of c's where n is greater than equal to 1 that means n equal to a to the n b to the n c to the n n greater than equal to 1. Now, we can generate this grammar using generate this language using the following production rules is a set of production rules where the first one says s goes to a b c s is a start symbol or a x b c x is a non-terminal x goes to a x b capital C capital C non-terminal or a b capital C then c b goes to b c and c c goes to c c. Now, we can show that this grammar can generate this language we know that this language is not a CFL, but this production rules set of production rules which follows the restriction imposed by this context free language in no production rule the left hand side length of the left hand side is more than the length of the right hand side it is at most equal at this point c b equal goes to b c, but in other cases it is less than the length of the right hand side. So, it is basically the type 1 grammar which is a context sensitive grammar it is context sensitive grammar. Now, therefore this set of non-terminal is s x c and set of terminal symbol is a b c. So, it is quite clear that this is a context sensitive grammar c h g just have a look at how can drive the strings or the form a to the n b to the n c to the n for some n greater than equal to 1. So, if n equal to 1 we simply generate use a first rule s goes to a b c to get a b c if n equal to we first use the second rule for s that means s goes to a x b c and then this x will be terminated by one of this we can term it by one of this if we keep on continuing with terming using this one will keep on generating more and more as b as n b n c and whenever we use this one we stop here generating any more as and once we use this production as goes to a b c then we keep on shifting the b which is there towards the right hand side will keep on shifting towards the left hand side. So, that all b's appear immediately after the group of as and eventually all capital c's will go towards the end extreme end and eventually all capital c's using this kind of rule capital c goes to c capital c c goes to c c small c c we can use or we can have we can convert all capital c's to small c's. So, that is what we have done for n equal to a x b c. So, this x is replaced by a x a b capital c now using the rule c b goes to b c we have shifted this b towards the left hand side by one symbol and we have got this string and eventually capital c c goes to small c c we have used the last step to get the c's similarly if you keep on continuing to use the production x goes to a x b c then we will have this kind of derivation as derives a x b c then replace this x by a x b c keep on continuing to replace this x by a x b c then after number of steps we will have this kind of string a d power k minus 1 a b c b c to the power k minus 2 then b c and eventually shifting this b in the extreme right towards the left hand side by using the rule c b goes to b c b capital c number of times we can shift all the b's towards the left hand side getting a power k b power k and then k numbers of k minus 1 numbers of capital c and small one small c at the extreme end and eventually using the rule capital c c small c goes to small c small c k numbers of steps k numbers of times we will eventually get the string a d power k b d power k c d power k so this grammar generates the language a d n b d n c d n so this is an example of context free grammar we will introduce a kind of automata called linear bounded automata and we will show that the linear bounded automata accepts context free languages now a linear bounded automaton is a non deterministic Turing machine satisfying the following conditions the first one is that it is input alphabet includes two special symbols one is left angular bracket and the other is right angular bracket the left and right these are the left and right end markers respectively and the l b a has no moves no more moves left from the left end marker and or right from the right towards the right end marker nor it may print another symbol over left end marker or right end marker that means left end marker and right end marker cannot be erased or can be replaced by any other symbol and head read head cannot move left towards the left end marker and right towards the right end marker now consider a linear bounded a linear bounded automata automaton m where q is a set of states input alphabet transition moves and q 0 is the star state say it is an l b a linear bounded automaton the language accepted by this linear bounded automaton m the set of all strings w over sigma other than what which does not contain left end marker right and marker or the head symbol such that it starts with this configuration initially that means it starts with a star symbol q 0 the input w is placed between the left and marker and right marker and the head read read head is reading the right end marker initially eventually from this if it moves to this configuration where it enters a state through the whole thing state and in that case that the con may be anything may have any content within this left angular bracket and right angular bracket alphabet any strings over string of terminals or any non-terminals then it is reading some symbol a since it has eventually entered the whole state for this string will be w will be accepted will now show that the l b a linear bounded automaton automata and conduct sensitive grammars are equivalent and this equivalence is shown as follows given a csgg conduct sensitive grammar g derision l b a linear bounded automaton a such that lg equal to l m similarly given an linear bounded automaton m derision csgg such that lg equal to l m minus epsilon so here since l b a might accept epsilon but since the csg the left hand side of the grammar is less than length of left hand side of grammar is less than or equal to the right hand side so therefore this conduct sensitive grammar cannot generate epsilon so epsilon cannot be generated by a conduct sensitive grammar so therefore it will be equivalent in that sense that it generates any string except by the linear bounded automaton except for the string epsilon now will first show that if there is a csg there is an equivalent linear bounded automaton m accepting the same language generated by the grammar g now clearly g is a structured grammar a special case of a structured grammar now will construct a Turing machine m equivalent to g in exactly the manner that was discussed earlier except that earlier that in the in the context of showing that a Turing machine and structured grammar are equivalent already have shown that Turing machines and structured grammars are equivalent in that context whatever construction we used will use the same construction except that instead of multi-tap consider it in a multi-track in such a case suppose w belongs to l of g then there is a derivation like this as derives w1 w1 derives w2 eventually w n minus 1 derives wn which is equal to w and in every step since we are using the production rules of a conduct sensitive grammar therefore the length of s must be less than equal to length of w1 because of the restriction that we have for conduct sensitive grammar and the length of w1 greater than length of w1 minus 1 and length of w1 is basically w now give the input w to the linear bounded automaton in the form w within this left n marker and the right n marker since each sensational form wi which is generated over various steps of m is not of length greater than w greater than the length of the w m does not use any steps beyond the n marker so this is for sure because in every step the length of w or wi is not greater than the length of the final string that will be generated so therefore in no step the Turing machine will use any cell towards the left side of the n marker or towards the left side of the left n marker or right side of the right n marker therefore m behaves as a linear bounded automaton as is at therefore m is an LBA which accepts the language generated by the C H G G let us now see the other direction that means if the original LBA m accepting some language so L m there has to be an equivalence C H G G except accepting the same generating the same language and that is your L G that means L m equal to L G consider that the linear bounded automaton is m with the elements q sigma delta and q naught we write sigma naught to be sigma minus these two symbols that means sigma naught does not contain the two n markers now construct grammar which is a required contraction grammar from this LBA we will see that T is a set of terminal symbols of sigma whatever terminal symbols is there in sigma we will have in T and n is a set of non terminals we have two special two non terminals s and a besides that we will have we use some composite symbols to represent the non terminals the composite symbols are of the form a alpha is a pair basically within square bracket a alpha where a is a terminal symbol and alpha is from this set C so it may be x for x in sigma 0 or it may contain angular bracket left angular bracket then x or x left angular bracket or it may contain both the angular bracket and x x may be any symbol from sigma naught or it may contain some state symbol q q belongs to capital Q and it may contain both state symbol and angular bracket along with this x so C may be anyone from this set alpha may be anyone from this set C and P consist of the set of production will consist of the following productions we will now see what are production rules to be used so the first production rule says that as goes to capital A and then this composite symbol a a q naught a comma a q naught or as goes to the single symbol non terminal is a comma within bracket within bracket a q naught here a is a terminal symbol and this a for a can generate this kind of strings a a and a left bracket a in fact using this one and two we can generate the input string here once we generate a string using as and a the first component if you collect the first component from each of the composite symbols that will give us the exactly input string and the second component basically represents the tap component and while deriving during derivation this grammar will simply simulate the moves of the Turing machine and linear one automaton m suppose that the automaton contains a move like this delta q x equal to P y instead q if it reaches a symbol x then it goes to state P and y y may be a print or y may be left left move or r y may be a right move if y is a print from some some symbol from input alphabet it prints then what is done if currently suppose a Turing machine or linear one automaton was reading symbol x it was in state q reading symbol x that is what given by this move then it simply changes that from q to P and x is sends to y that means it prints a new symbol y and here z 1 and z 2 may be any symbol may be epsilon or it may be left angular bracket or a right angular bracket so therefore z 1 and z 2 will remain same now if suppose the Turing machine or a linear one automaton in state q reading x goes to state P and it moves towards the right hand side here is moves towards the right hand side that means y equal to r in such a case suppose this is a last this difference this is a last symbol last non-terminal in such a case this angular bracket will appear at the end so therefore it will simply reading q reading Turing symbol x at state q it will simply go the right side of the symbol x that means it is now reading the right hand marker P otherwise if it is not the last symbol then there will be some other symbol towards right hand side so it is in state q read symbol x then it will simply move over the symbol x that means it will read the next symbol therefore it will go to read the symbol b so from a z q x next symbol is b b z dash where z dash may be any right angular bracket or epsilon it may be empty also so the state symbol q will move towards the right side to indicate that it is now reading the next symbol b so it is P b z dash z this may be empty and here this z may be the left angular bracket or it may be empty as well similarly you can see the move when it goes towards the left side these two are exactly similar to the previous two and a special case when it is reading the left hand marker it simply goes towards the right side it moves towards the right side so this is right side and it may sense a state to p so a q left angular bracket a z it is reading the left hand marker so there is no move towards the left side it has to move towards the right side so it can now read the symbol a similarly we can write the rule for when when the lba is reading the right hand marker in such a case of course there will be no right move so it has to go towards the left side to read the symbol which is there towards the left of the right hand marker and finally when the lba enters in a state which is a halting state is h is a halting state then simply we reduce this composite symbol to a where a is a symbol that is there to write the right side and then from then onward we can reduce this combination some composite symbol and the terminal symbol to a b so a comma alpha b will be now a b taking the first terminal symbol and these are terminal symbol similarly b a alpha will convert to b a so we see that each of the production is follows the rules of a contraction rules of contraction of grammar that means type one grammar so this grammar that constructed from the move towards the reading machine is exactly is a contract sensitive grammar now it is a written verification as in the case of the reading machines that this grammar g generates the language except by the linear model automaton except for epsilon suppose w is a string which is a 1 a 2 up to a n except by the automaton m so using rules 1 and 2 we can simply generate in a few steps square bracket a 1 comma left angular bracket a 1 then square bracket a 2 a 2 square bracket a 3 a 3 finally square bracket a n comma a n q naught left angular bracket you see that if you collect the first symbols from every composite symbol it constitutes the string a 1 a 2 up to a n which is the input string a 1 to a n and then we can use the other symbols following the moves of the grammar we can use other rules of the grammar eventually to generate the string eventually this can be converted or transformed to this string so we can transform this string from s we will get the generate this string eventually we can transform it to this string provided that the reading machine m accepts this particular string that means we can have we have some moves to accept this string by the linear model automaton we will last this by an example say this is a linear model automaton which generates or accepts all strings containing an a any string containing a will be accepted by this linear model automaton which is shown in the table the moves of the linear model automaton is shown in the table so q 0 q 1 q 2 are the states of the linear model automaton a b are terminal symbols and left angular bracket and right angular bracket are two special symbols that we have as left unmarker and right unmarker here in this capital a shows some arbitrary moves you can choose anything there because that situation does not arise since q 0 in the star state it always read the left right angular bracket so in such a case will enter in a state q 1 and go run left side because the string will be given like this a 1 a 2 up to say a n within this and will be reading this left unmarker at state q 0 so therefore first we have to move towards the left side that means we will move towards this side and enter instead q 1 now we will be reading the symbol a n that is the first move and once we are there in the state q 1 will keep on skipping the symbols until we see an a once we see an a if at q 1 we see an a we enter in the halting state and we move towards the right side or left side does not matter but if we see any other symbol b other symbol b then we are in the same state q 1 but moves towards the left side we keep keep on skipping the symbols but if we see the left angular bracket then we enter in a state q 2 and move towards the right and in q 2 again if we see an a we enter in an arbitrary state because that situation does not arise otherwise we would have entered in a halting state earlier in the state q 1 and if instead q 2 we see a b you enter in a state q 1 and move towards the left side so therefore at that point it will keep on oscillating so just consider a move of the Turing machine it starts say input string is a b whether the Turing machine did with an lba whether it accepts a b or not so q naught a b is that to n markers currently reading this this indicates the currently reading symbol right angular bracket so in the next move following this one q 0 right angular bracket goes to q 1 l so it will enter in state q 1 and it will move towards the left hand side head move towards the left hand side so it is now reading b so on q 1 b q 1 b it will again skip and move towards the left hand side the head move towards the left hand side state remains m now q 1 a q 1 a it will enter in a halting state it will enter in a halting state it will move towards the right hand side so since now it has now enter in a halting state this string a b is accepted by the linear bounded automaton now let us see whether this c h g which is constructed using the rules of the grammar generates the string a b or not so the if we apply the first rule so as derives a b b q naught for every for all a belonging to T we have this kind of rule as derives a as goes to a small a q naught is a rule we can apply and then this a goes to a a this rule can be used in the next step to terminate the non-terminal a so once we have this we see that the first symbol a b represent the input string a b and the others the second part can be used to similar the type of the l b a now this q 0 right in a bracket in this case it will simply move towards the left hand side following our rules of the move of the Turing machine q 0 right in a bracket it will move towards the left hand side so we will use the rules of the grammar corresponding rules of the grammar says b q 0 and then q 1 b in this step since q 1 b we have this rule q 1 b it goes towards the left side so therefore and it remains the same state q 1 so in this case so since there is no way to go here in the left side so this q 1 will move towards the left this symbol towards the left side composite symbol towards the left side so to have to read the symbol a that means it will be now left hand bracket q 1 a and similarly now q 1 a since we have the move q 1 a q 1 a is halting state and r so therefore the corresponding rule in the grammar csg will be according to construction so q 1 a will go to the right side and will read now symbol b and enter in the halting state so this will this will be a new situation so since it has entered in the halting state so this now will reduce to b according to a rule this rule that we have so according to a rule this rule on the context free connection with grammar so whenever we have halting state it will reduce to the symbol that is there towards a which is a left component so therefore in this case so this will reduce to b so there is what we have used over here and now b allow this now will reduce to a b so this a b so therefore s derives a b so this how this corresponding grammar generates the strings so therefore we have shown that context sensitive language context grammar and linear bound automaton automata are equivalent and the language generated by context sensitive grammar is said to be context sensitive language now we will show that context sensitive language is properly contained within recursive language first we will show that every context sensitive language is recursive let l be a context sensitive language generated by the grammar context sensitive grammar g will construct an algorithm a which accepts l that is given any string w from sigma star a accepts w if and only if w belongs to the language l so it goes like this given w belongs to sigma star the algorithm performs the following steps it constructs a graph whose vertices are the strings from n union sigma star whose length is less than or equal to w length is less than equal to w so here the vertices represents the strings over n union sigma star but the length which must be less than or equal to the length of the string w now for vertices alpha and beta are vertices of the graph we know that alpha there is beta in the grammar g if and only if there is an arc from alpha to beta so it is quite a g or you can see that alpha there is beta if only if there is an arc there is an arc from alpha to beta now note that the parts in the graph represents derivations in g therefore w belongs to l of g if and only if there is a part in the graph from vertex s to the vertex for w so if you can somehow find out a part from the vertex representing s to the vertex representing w then we know that s derives w now a simulation method which finds a part from s to w if exist and there are algorithms we can do it easily to find out a part from one vertex to another vertex in a graph and it reports s if there exists any such part to indicate that as derives w that means w is x generated by the grammar g otherwise it says that no it is exit so therefore we know that there exist such an algorithm and hence every csl can be shown to be recursive now we will show that there is a recursive language that is not context condensative to show the proper contentment we will show that there is a recursive language that is not condensative to show this we will consider a binary encoding binary encodings of all csg's context condensative grammars we will just consider some binary encoding suppose this g in angular bracket represents a binary encoding of a csg g now we define the language l like this l is a set of all binary encodings of all the csg's g in angular bracket binary encodings of all the csg's such as g is a csg and this encoding is not accepted or not generated by the grammar g now this l of course it belongs to 0 1 star because this is a binary encoding so here g must be a csg and this is the binary encoding and this is not accepted by or generated by the grammar g that is this encoding does not belong to lg now we will show that l is recursive this language l is recursive but it is not a context sensitive language to show that l is recursive if any input is given say any w belongs to 0 1 star is given we will say where are w defines a csg if it does not defines a csg obviously w does not belong to l that is quite clear now if w defines a csg then using the algorithm just we have described above given a previous result we decide whether or not w belongs to l of g so that we can always do by constructing graph and then looking for a path if there exist so therefore we can show that l is recursive because we can decide whether or not w belongs to lg now we show that l is not a context sensitive language so assume for contradiction that l is a context sensitive language then there exist a context sensitive grammar so g dash such that l g dash equal to l there must be some context sensitive grammar now we pause equation where are the encoding of that grammar g dash belongs to l there is a question that we ask suppose that this encoding belongs to l then according to a definition that this encoding does not belong to l of g dash so therefore this encoding does not belong to l so this is a contradiction that we have got similarly if we assume that this encoding belongs to l encoding of this grammar that we have assumed belongs to l then since g dash is a csg then encoding of this belongs to l of g that is encoding of this belongs to l again we have arrived at a contradiction by this argument so therefore our original assumption that l is a csl must be wrong so therefore such a grammar context sensitive grammar generating l does not exist so therefore it is not context sensitive language hence l is a there exist l is a l is a l is a recursive what is not context sensitive so hence we have the following strict containment between the between the language classes the class of context sensitive language is strictly contained in the class of recursive languages and hence we have got this hierarchy in fact we have some other classes like say first they have got this containment say regular language is properly contained within context free language context sensitive language is properly contained and cfl is properly contained in the context language and csl is properly contained within la disputa in the bother language in fact we have some other classes for example say DCFL determine condition language so reguar language is properly contained within you drink on language thatých let also we have taken earlier tQ determined context language proppers of some other context speech English context learning which purpose of some other context language and context language purpose . . . . . . . . . .