 We are going to introduce an important special class of contested grammars called linear grammar. Further, we discuss even restricted class, which are useful to understand regular languages better. What are linear grammars? A C F G N sigma P S is said to be linear, if every production rule of G has at most one non-terminal symbol on its right hand size. That is, if you take any production rule A goes to alpha, then either alpha is a terminal string or it is of the form x, b, y for some terminal strings x, y and b a non-terminal symbol. Now, accordingly we call the languages generated by linear grammars are linear languages. Let us look at some examples. We have C F G's for a power k k greater than equal to 0. What is the grammar that we have introduced for this language? We have discussed like this. This grammar generates a power k k greater than equal to 0 and you can clearly see that there is at most one non-terminal symbol on the right hand side of each production rule because we said that either it is a terminal string or on the right hand side of production rule, there can be one non-terminal symbol. So, here there are two production rules. One is empty string on its right hand side and other is having A S. So, each production rule has at most one non-terminal symbol on right hand side and this grammar, this C F G that generates the language A power k k greater than equal to 0 is a linear grammar and we have introduced a grammar, context free grammar for A power n B power n and where the production rules we gave it like this. Again you see that there is at most one non-terminal symbol on the right hand side of each production rule. There are two production rules here and thus you can see the grammar what we have introduced for the language A power n B power n greater than equal to 0. For this that is also a linear grammar and hence this language is linear. Also we have introduced a grammar for A power m B power n C power m plus 1 for all m n positive I mean non-negative. So, for this the grammar what we have introduced you can clearly recollect and observe that clearly it is a linear grammar. In contrast let us consider the following C F G for the language because I ask you to work for a context free grammar for this language. For example, one can consider suppose if I consider this context free grammar for this language you can clearly see that you know S is S can be A B these production rules. This S can be A B this production rule is having two portions A and B and the portion A produces the string of the form A power n B power n and B produces B power m C power n. So, that the desired string can be the desired string can be derived through this grammar. For example, this B goes to B B C this is how it is given or you can terminate. So, this is actually following the philosophy behind the grammar which generates A power n B power n such that n greater than equal to 0 that example only thing here since we have to produce strings of the form A power m B power m plus n C power n. So, any string here you can see A power m B power m C B power n C power n that is what is the form. So, here you have two parts A power m B power n through the non-terminal symbol A you can generate and B power n C power n through the non-terminal symbol B that you can generate and if you consider the production rule S goes to A B this takes the concatenation of these two and thus this grammar and thus this grammar can generate the language A power m B power m plus n C power n m n greater than equal to 0. And if you consider this grammar for this language you see here is a production rule S goes to A B on the right hand side you have two non-terminal symbols. And thus this grammar for this language is not linear because every production rule should have at most one non-terminal symbol on the right hand on its right hand side. So, here is a production rule in which you have two non-terminal symbol on its right hand side thus this grammar is not linear grammar. Now, you can observe this point if G is a linear grammar then every derivation in G is a left most derivation as well as right most derivation. The reason why here thus there is exactly one non-terminal symbol in the sentential form of each of internal step in the derivation because every production rule has at most one non-terminal symbol on its right hand side. So, each sentential form you will have only one non-terminal symbol thus when you apply a further production rule you will be applying on it. And thus what you can understand that that is only non-terminal symbol available on its in any only one non-terminal symbol will be available in each sentential form of each step in a derivation. And thus you can treat it as first non-terminal symbol that is left most non-terminal symbol that is as well as it is right most non-terminal symbol. And thus each derivation is you can understand that it is a left most derivation as well as right most derivation. Now, we will introduce some more restrictions on this linear grammar to go further in the direction of regular grammars. And this regular grammars what we are going to introduce is essentially to give the facility to understand regular languages better because in the beginning we have already mentioned that the grammars that we are introducing here in the context of regular languages you know to understand them better we are introducing that is how we have mentioned. Now, the tool CFG how languages can be generated and all those things we have introduced and certain examples that I hope now you are familiar with. Now, the notion right linear grammar will give you the concept of regular grammars to understand regular languages better. So, now how do we define this right linear grammar a linear grammar you consider a linear grammar that means each production rule on its right hand side you will have at most one non-terminal symbol. But we put further restriction that it is said to be right linear G is said to be right linear if the non-terminal symbol on the right hand side of each production rule if it is available it should occur at the right end that is each production rule the right hand side of each production rule is a terminal string followed by at most one non-terminal symbol. That means either it is of the form a goes to x for x a terminal string or it is of the form x b where x is a terminal string and b a non-terminal symbol. That means a terminal string followed by at most one non-terminal symbol that is that is the restriction that we are considering and such linear grammar is called right linear grammar similarly one can define left linear grammars in which each production rule I mean right hand side of each production rule is of the form at most one non-terminal symbol followed by a terminal string. So, that means a goes to x or a goes to b x of this form and now again you can see the similarity between these two definitions and thus any result that I will observe for right linear grammars one can imitate to get a parallel result for left linear grammars also and in fact what we can understand what we can observe is the notion of left linear grammars is equivalent to right linear grammars what is the meaning of equivalence here, whatever is the language that you generate through a left linear grammar corresponding to the language you can construct a right linear grammar and conversely. That means for a right linear grammar whatever is the language that you have correspondent it language you can construct a left linear grammar. That is the equivalence here left linear grammars and right linear grammars are equivalent. To prove this result you Now, we will be introducing some more tools and at that time I will recollect and we will remark once again and how to understand that these two are equivalent. We will postpone the proof for the time being and let us look at some examples of right linear grammars. If you consider this context free grammar s goes to a s or epsilon you know what is the language generated by this grammar, we have discussed this for several times that is the language a power k such that k greater than or equal to 0. This is the language generated by this grammar and you can clearly see that any non-terminal symbol that is appearing and right hand side of each production rule that is appearing in the right most position of the production rule and thus you can see by definition this is a right linear grammar and the language generated by this is a power k such that k greater than or equal to 0. Now, as I have remarked that left linear grammars and right linear grammars are equivalent at least for this example. Now, I will give a left linear grammar also here to understand that you have a left linear grammar for this language. If you consider the production rule which is of the form s goes to s a or epsilon you can quickly understand that you can generate this language. Because the production rule this time what I am considering is s a or epsilon and whatever the way that I have proved that this grammar this grammar generates a power k k greater than or equal to 0 you can imitate the same and understand that this grammar also generates the same language and this is a left linear grammar. Now, let us consider this language set of all those strings for a b with odd number of a s because number of a s in x is of the form 2 n plus 1 that means there are odd number of a s I am claiming that it is a linear language. In fact, you can have a right linear grammar for this of course equivalently you can have a left linear grammar for this language. For example, you can by now you understood that what is the what is the importance of non terminal symbols in the production rules like how we are constructing the production rules to generate a particular language targeted language. So, in this connection let me just demonstrate the construction of a grammar for this language. So, if you consider a string a 1 a 2 a n as we are claiming to give a right linear grammar a production rule I will look forward is of this form or of course, a goes to x. Now, here x is a terminal string in particular I will restrict myself to a particular symbol of a alphabet. So, that way in a derivation for example, a typical derivation what it will be it will generate first a 1 then you will have some non terminal symbol let me call it as a 1 and then since as I am claiming in each step I will be generating 1 1 symbol each. So, may be a 1 a 2 then some non terminal symbol sorry a 2 and so on a 1 a 2 a n and say a n and this non terminal symbol if I terminate with m epsilon then I will have that a 1 a 2 a n. So, look here the type of production rule I am targeting a terminal string followed by at most non terminal symbol because unless a non terminal symbol is there I cannot proceed further to continue this derivation. So, in the first step I am assuming not a terminal string at least one symbol I am assuming to generate say it is a 1 and the non terminal symbol because it is in the right side of the production rule I mean right end of the production rule I will have something that is a 1 and now if I continue like this in each step I am assuming to produce 1 1 symbol each say a 1 a 2 here and so on in the n th step I am having a 1 a 2 a n with a n as a non terminal symbol here. But what is the criteria that a string to satisfy to fall in the language that is the number of a s in the string is odd number of a s in the string is odd. So, that means, as and when I am producing a in the string I should somehow remember that at least it is not the count, but at least I should be able to understand that whether that the number of a s is even or odd because the possibility is either even or odd. So, when it is in odd in number then I will give the possibility to terminate the derivation when the situation is I have produced so for even number of a s then I should take care that the derivation should not terminate. So, that should there you should have a possibility to do further continuum that is the philosophy one may observe at this point of time and thus at least I should have 2 non terminal symbols one is essentially which allows you to continue the derivation further and which will not allow you to terminate and one non terminal symbol which allows you to terminate the derivation. Let me call for the purpose o and e these are the 2 non non terminal symbols o is for the one at a particular situation I will have this non terminal symbol o in the derivation if so far I have produced odd number of a s likewise I will use e the non terminal symbol e if in the derivation if so far I have produced even number of a s. So, thus I am choosing these 2 and you understand that in the beginning of the derivation of course, I do not have anything generated that means in the beginning of the derivation that is start symbol of course, I am writing here we have we are uniformly following s. So, whatever it is here that is even number of a s the number of a s is 0. So, that means, the start symbol that means the derivation if I started e then thereafter I will continue. So, I will start with e and for example, if I have generated b for example, if I have generated b in the beginning then the situation is so far I have produced even number of a s and thus I can connect it to e here because as I have mentioned at a particular central form if I am getting e that means so far I have produced even number of even number of a s here there are 0 number of a s and thus I can have this kind of step. Suppose, if I have produced in the beginning a then since I have so far odd number of a s in the derivation we will have o here. So, let me look at the first step this way now the situation is if I have odd number of a s I have the possible I should have the possibility to terminate the derivation whereas, in case of e I should not have that means e will not be terminated that means we do not introduce the production rule e goes to epsilon sort of, but you can introduce the production rule this o goes to epsilon and now clearly you can see that I have a production rule e goes to b e because I am saying this is one step. Similarly, here e goes to a o is one production rule in this context suppose if I further continue and suppose if you have produced a then as this production rule you know indicates that you have produced odd number of a s I can have this kind of thing e goes to a o that production rule that I can use. So, the production rules so far I am let me write here e goes to b e e goes to a o these two production rules that I have and for example now when you have non-terminal symbol o and if you have produced one more a what is the possibility now you have two a s that means even number of a s and this should be indicated by giving the non-terminal symbol e in the derivation that means b a a e for example if I have produced one more a that means now this o when you are with the non-terminal symbol o in the sentential form if I produce a then I will connect this to e and if I produce b then the number of a s so far generated is not going to change and thus if there are odd number of a s then it is still odd number of a s so o goes to b o. And as I had mentioned we give the possibility to terminate o through this epsilon and we do not give the possibility e goes to epsilon because if you have e in the sentential form there the number of a s is even and we should not terminate the derivation. So, with this philosophy these are the production rules that we have discussed and you can observe that these production rules precisely generate all the strings which with all the strings which are having odd number of a s. Let me give a derivation because the production rules remember that now what is the grammar that I have to mention because I have not used as here as per our convention if I just give the production rules then s is the non-terminal symbol which is always start symbol in this context we will consider e to be the start symbol. So, the grammar g with e o as non-terminal symbols and a b as terminal symbols and a production rules and e as a start symbol this grammar with the production rules as we have written here e goes to b e or a o o goes to b o or a e or epsilon these are the production rules o goes to b o or a e or o goes to epsilon. So, these production rules if you consider the language generated by the grammar is as desired that means all those strings x in a b star such that the number of s in x is odd. So, you consider a typical derivation and observe that typical derivation which derives a terminal string and observe that that string is in this language and for every string in this language you can give a derivation in this grammar that you can observe. So, take it as an exercise exercise is to show this thing the language generated by this grammar is precisely generating those strings which are having odd number of s and now you look at here the production rules that I have obtained here every production rule has on the right side at most one non-terminal symbol and thus this is a linear grammar and moreover the non-terminal symbol that is appearing on the right side is appearing at the right end and thus you can see clearly this is. So, this question mark is your exercise and clearly this grammar g is right linear. Now, you can follow this philosophy and somehow to see that you can give a left linear grammar for this language. So, you can take this as an exercise. So, an exercise another exercise here give a left linear grammar for the language x in a b star such that number of s in x is odd. So, for the same language you can give a left linear grammar. So, we have understood that this language can be generated through a right linear grammar. Now, let us look at this theorem the language generated by a right linear grammar is regular. Now, if you recollect because what are the examples just before we have discussed this language when we have introduced regular languages through regular expressions. If you remember this language is introduced and mentioned that giving a regular expression for this language is little bit difficult and we are going to give certain tools to represent this and understand that it is a regular language. So, in this context the concept of grammar particularly the concept of right linear grammar is given here and observed that you know this language can be generated through a right linear grammar. And as we have targeted saying that grammars will be a better tool and this theorem is essentially capturing this philosophy mentioning that the language generated by right linear grammar is regular. That means from this theorem you can conclude that the language just mentioned is in fact a regular language. Of course, we have not observed through the regular expression, but that philosophy is captured through this theorem. In fact, any regular language can be generated through a right linear grammar that is what is here. Now, proof of this theorem is little bit you know involved to other we can prove it here, but it will be little bit intricate at this point of time and we will be introducing better tools to prove this theorem and you can have a very elegant proof letter. So, we will push on the proof of this theorem and of course, what is mentioned for every regular language L there exist a right linear grammar that generates L. So, that means what essentially the theorem says that the regular grammars precisely generates regular languages. Now, because this right linear grammars are generating regular languages we can now call them as regular grammars. And because of the equivalence between right linear grammars and left linear grammars we can also say that left linear grammars are regular grammars. So, regular grammars here after if I if we use the term regular grammar that is you can say it is a right linear grammar or a left linear grammar. Now, let us look at some examples that we have already observed that the regular and corresponding right linear grammars we will give. So, that you will get familiarity with this right linear grammars and thus what are the languages for which you could not identify regular expressions you may try through right linear grammars to show that they are regular languages. This you have already observed that it is regular because you gave a regular expression for this because all those strings in which a b as a substring you know this is a regular language. What is the regular expression for that that is a plus b whole star a b a plus b whole star. So, this is a regular expression you know that represents this language and that this is a regular language. Now, if you look for a right linear grammar for this you will get the familiarity how to give a right linear grammar for a regular language. And then for regular languages if you analyze the strings and if you give corresponding right linear grammars because of the theorem you can conclude that they are regular languages. Although you do not have regular expressions you may not be able to give regular expression at this point of time. Once we prove that theorem by that by the time you will be able to give even regular expressions also. Although it may be very cumbersome to see and a tedious to write you may certainly give regular expressions for the regular languages. So, what is a right linear grammar or a regular grammar for this. If you consider these production rules because again the philosophy is the non terminal symbols should represent in a derivation what is so far generated. If you have a particular non terminal symbol in a particular sentential form in a derivation it should give you the opinion it should give you the idea that what is the string so far that you have generated. So, for this purpose here we have considered you know s and a and of course, once I say this is the grammar then s is the start symbol of that grammar. Now, these production rules because if you look at any string in this it is some x a b y for x y in with any number of a s I mean with any combination of any a s and b s that is an element of a plus b whole star. But you should have at least one a b that is what is the typical string. So, the production rules here given are essentially to produce any string with a combination of a s and b s you know that production rules should be of this form a s or b s because these production rules will generate any string with a s and b s in any combination. But once you produce a b then again you can generate any string so that is the situation here, but you should not terminate s unless you produce a b because once we have a freedom here you might be just producing b s, but you would not have produced any a b or you would have produced several a s, but you have not produced a b following to that. So, that way we should not terminate the symbol non terminal symbol a s so I do not have I should not introduce the production less goes to epsilon here rather we connect to another non terminal symbol which will be used to terminate the derivation, but that non terminal symbol I will introduce only when we have produced a b in a derivation. So, for that purpose if you have produced a b then I connect to the non terminal symbol a this non terminal symbol a now can produce any string over a b that means again these rules and this you can terminate whenever you want. So, thus these are the production rules you know if you consider you can observe that the grammar with this production rules precisely generates this language. Again here you take it as an exercise to prove that the grammar g generates the language as desired and you understand that this is a right linear grammar again because any production rule here you observe if a non terminal symbol is appearing on it is right hand side that is appearing at the right end of the production rule here or here or anywhere you see wherever the non terminal symbol is appearing on it is right hand side you have that is appearing at the right end now let us consider this grammar s goes to little a capital a little b capital s or epsilon and this a goes to little a capital s or little b capital a consider this and you can quickly see that this is a right linear grammar. And now you can think of what is the further right linear grammar what is the language associated to this grammar you can think of that and observe that that particular language that particular language because this is a right linear grammar you can understand that it is also a regular language you can think about this as an exercise and observe that the corresponding language for this grammar is regular it is easy to understand we have already discussed one similar such example. If you analyze the strings generated by this you can quickly ascertain what is the general representation of a string in the language and thus you can give the language in set well reform to understand that language is regular because it is generated through a right linear grammar. Now, let us consider this regular expression a star b plus and as you understand that that is a regular language the language represented by this is a regular language what is that this is all those strings of the form a power m b power n such that m greater than equal to 0 m greater than equal to 1. Once it is a star here you can have f 0 and also here 0 number of a's so that means you know strings of the form a power m b power n m can be 0, but b this n the number of b's here the following b's cannot be non 0 here the number of b's should be greater than equal to 1 because b plus is used here. Now, you can give a right linear grammar for this again here because you require at least 1 b. So, unless you produce b unless you produce b you should not have the termination of the derivation and of course, you need not produce a's that is why the production rule s goes to b can if you use directly s goes to b in the first step you are not producing you are not going to produce any a's and after that you are going to produce any number of b's at least 1 b of course and any number of b's you can produce and terminate the derivation by producing you know b's if you want that leading a's of course, you have to use this production rule as many a's as you want and then you connect to b and then produce number of b's as required and then terminate the derivation and observe that this grammar with of course, s as a start symbol this grammar produces this language this grammar produces this language and understand that this right linear grammar is generating this regular language. Now, little more complicated example that you would not have attempted to give a regular expression for this as well the number of a's the number of a's in a string or a b is 2 mod 3 that means if you take a string and count the number of a's divided by 3 the remainder should be 2 that is what the number of a's is congruent to 2 mod 3 means this. So, let us look at giving because we may not be able to think about a regular expression for this even for this even for the earlier language that is number of a's is congruent to 1 mod 2 that means it is odd number of a's for that itself we have postponed to discuss it is regular it is similar to that, but little more even complicated. Once you take the philosophy of the previous example you can give a right linear grammar for this and hence you can observe this languages and hence you can observe the languages regular what is the previous example first let me write the previous example that is number of a's x is odd. So, this can be written as set of all x in a b star. So, I am trying to write in this form number of a's in x is congruent to 1 mod 2 number of a's in x is congruent to 1 mod 2. So, that means when you divide the number of a's by 2 the remainder is 1 that is when you call the number of a's is odd. Now, what is the present example and we know a right linear grammar for this language we have already discussed a right linear grammar for this now in the present context what we are considering the number of a's in x is congruent to 2 mod 3. So, in the previous example we have considered 2 non-terminal symbols because when you divide the number of a's the possibility of reminder either it is 0 or 1 that means either even number of a's you would have or odd number of a's you would have and that way we have considered 2 non-terminal symbols and when you are having in a sentential form O which is representing odd number of a's then you give the possibility of terminating it otherwise you are not giving that means you have to continue to produce. Similarly, here since you are dividing with 3 you can now consider and you look at number of reminders possible that is 0, 1, 2. So, among these for these 3 reminders you know you give 3 non-terminal symbols to start with may be you can call them as a 1, a 2, a 3 or a 0, a 1, a 2 to represent you know that is representing the reminder a 0 may be you call it as a 1, a 2 these are the non-terminal symbols a 0 if it is appearing in the sentential form that means I will I have produced you know I have produced the number of a's congruent to 0 mod 3 that means the reminder is 0 and when you have a 1 that means the number of a's is congruent to 1 mod 3 that means the reminder when you divided by 3 is 1 and similarly a 2 the reminder is 2. Now, in the beginning when I am starting the number of a's of course, so the non-terminal symbol a 1 should be the start symbol and if I am producing any b's I am not going to worry to count there. So, that way a 1 goes to say b a 1 similarly this sorry that this a 1 is not the start symbol because the number of a's in the beginning is a 0 I mean the number of a's will be 0 and thus the reminder will be 0. So, a 0 will be declared as a start symbol and the number of b's that we are producing in a not we are not going to count and that way this production will help you to produce as many b's as you want when you have a 1 and similarly when you have a 1 you can produce as many b's as you want similarly for a 2. So, these are the production rules which are not worried to produce I mean which are not worried to count the number of b's that you want to produce in a string and now in a sentential form say we have started with this start symbol a 0 and after finitely many steps you have produced some string x and suppose you have a 0 here as we are targeting greatly in a grammar the non-terminal symbol will always be at the right end. So, that is how I am writing this way suppose you have a not here what is the meaning of this the number of a's in x is congruent to 0 mod 3. That means, so far when you divide that you have 0 number of I mean the reminder will be 0 and the number of a's that is the meaning if you have a not now if you have produced one more a because as far as b's concerned we have already discussed about the production rules here these 3 production rules are given suppose if you want to produce a then what it should be what should it become this a not. So, since we are adding one more a the reminder will become now 1. So, thus if you are from a not if you are producing one more a then I have to connect it to a 1 and similarly if I have a 1 in this place the number of a's that are produced say let me now use this production rule and continue this derivation that is x a a 1. So, that means in x a I have you know the number of a's in x a is congruent to 1 mod 3 if you have one more a generated that means from a 1 if you want to generate one more a you have to connect it to a 2 because a 2 is representing that reminder 2 that reminder 2. So, this production rule can be introduced that way and for example, when you are at a 2 if you have produced one more a then the reminder will become 0. So, it should be connected to a not. So, along with these 3 rules we include these 3 rules along with these 3 rules we include with these 3 rules and where we have to terminate because our target is to produce all those strings in which the number of a's is congruent to 2 mod 3 whenever in a string if you have produced with this condition that means you have the non terminal symbol a 2 in that. So, this non terminal symbol a 2 can be terminated. So, the production rule or epsilon when a 2 goes to epsilon can be introduced for this purpose and thus you understand systematically that these 6 plus 6 plus 1. So, total 7 rules what is the derivation you consider you can produce any string in which the number of a's is 2 is congruent to 2 mod 3 and conversely you consider any string in which you have a's and b's and number of a's is congruent to 2 mod 3 if you consider then you can produce using you can produce that string you can derive that string in this grammar with these 7 rules. So, the grammar with these 7 rules with start symbol a not that is important here with start symbol a not can generate this language the desired language of course, here I have mentioned with a's that is a not and a is taking care of a is taking the role of a 1 and b is taking the role of a 2 because a is when I have in a sentential form when a's is appearing the start symbol that means the number of a's is congruent to 0 mod 3 that is a start symbol. So, a's is equal to a not a is equal to a 1 b is equal to a 2 you consider and this 7 rules generates this language and hence this language is regular because this is a right linear grammar and hence the language is regular. Now, let me give one more example that number of 0's in string is even if and only if number of 1's in a string is odd. So, if you consider all those strings in over 0 1 with this condition number of 0's in x is even if and only if number of 1's in x is odd. The condition itself is looking little bit complicated you can of course, what you can do you can little bit analyze this condition this this logical statement you can little bit analyze and give the appropriate conditions mean sort of primitive conditions and you may try for a right linear grammar or so called regular grammar for this to understand this is regular of course, trying for a regular expression is anyway difficult and a simple point for you is you may try for a regular grammar for this, but it will also be tedious when to analyze and understand. We will introduce even better tools to understand regular grammars further and you can understand that this is regular in future. So, in order to go in the direction of that in order to introduce a better tool to understand regular grammars we first give one representation that is called a digraph representation for this regular grammars or right linear grammars and this representation will give you the facility to understand the a better tool to think of a better tool for regular languages that is the digraph representation. So, this digraph representation I will introduce this digraph representation for a regular grammars. So, given a right linear grammar g n sigma p s we define a digraph v e where the vertex set is the non terminal symbols union with a new symbol I consider say dollar and the edge set e is formed as follows. If you take a production rule that is of the form a terminal you know a goes to x b form or a goes to x. So, when you have the production rule a goes to x b then I make the non terminal symbols a b they are vertices in the digraph I will make them adjacent you will put an r from a to b or if you have the production rule of the form a goes to x then I consider the edge between from a to the new symbol dollar. Of course, what are the r's that I am introducing here we will label them. So, this is a label digraph as a matter of fact that is labeled by whatever is the string that you have here that x will be the label of that arc. So, that is how we are defining this digraph representation for a right linear grammar. Now, let us look at an example if you consider this right linear grammar this is the digraph corresponding to that because you see s a there are the two non terminal symbols I have two nodes here s and a and a new node with dollar and whatever is the production rule that you consider accordingly the r's are introduced where s goes to a s r b s that means you have an arc from s to s labeled a of course you have another arc that means here is an essentially loop here from s to s labeled b also we are simply putting one loop here and labeling a comma b. When you connect from s to a you have the terminal string a b so that is the label of this arc from going from s to a and in a you have a loop for a and b that is how it is given and now when you have a terminal string that is only thing here that s goes to epsilon is only such production rule. So, those production rules will give you r's from that particular non terminal symbols to the new symbol dollar that is what is here this epsilon is connected to is connecting from a to dollar. So, thus this representation you know this this example I hope illustrates you how to give a digraph for a right linear grammar and not only that if you are given a digraph representation for a right linear grammar you can write the corresponding production rules that is not a big deal. Look at for example, this digraph for a right linear grammar you can quickly say what are the corresponding production rules. You can say that these two are non terminal symbols in that s and b are the non terminal symbols and the production rules are s goes to a s and s goes to a s is a production rule and you can say that s goes to b is a production rule because epsilon b means s goes to b is a production rule and you have a production rule b goes to b b b capital b and you know you are terminating with the production rule b goes to little b because that is going to dollar. So, these are the production rules for that. So, given a digraph representation for a right linear grammar you can write the corresponding production rules also and now here one important philosophical point I will introduce which which gives you the better understanding when we are talking about a better tool for regular languages. The pass in the digraph represents derivations particularly when we are interested from the start symbol to the you know the pass from start symbol to the dollar. Now, if you consider the derivation s goes to a s that goes to a a s and goes to a a b and then that goes to a a little b corresponding to this path in the previous example you can quickly see that this is the corresponding path is the corresponding path and the concatenation of the labels on this path called labels of the path here after we may call that gives a desired string because if you concatenate a a epsilon b if you concatenate these labels that is the label of this path that you can see this is the string that you are deriving from the start symbol s in the in the derivation. So, that means the labels if you take the labels of the paths from the start symbol s to dollar that gives you this that give a corresponding to which you can of course have a derivation in the grammar and that string can be generated to the grammar. So, through this digraph representation we can understand that the pass from labels of the pass from start symbol to the dollar which are the corresponding derivation the corresponding derivation will give you the derivation for the string and conversely. So, we can easily see the correspondence between these two derivations and the paths the correspondence and you can see that this concept will give you better understanding better understanding about you know derivations through this digraph representation.