in this lecture we will be studying about a regular grammar so before we start with regular grammar let us try to understand what is a grammar so in normal human languages what is the use of grammar or why do we use grammar so grammar is actually a set of rules that we used for proper conversation with each other so in the same way for writing computer languages also there is a mathematical model of grammar which is used to write the languages in the correct way so Nom chsky he gave a mathematical model of grammar which is effective for writing computer languages so this person Nom chsky he gave a mathematical model of grammar which can be used for writing computer languages and according to n Chomsky there are four types of grammars which we will discuss here so the types of grammar that we have according to n Chomsky are type zero grammar type 1 grammar type two and type three grammars so we will discuss them starting from the bottom so first let's see type three grammar so in type three grammar the grammar that is accepted are regular grammar which we will be studying in this lecture and then the language accepted by this type three grammar are regular languages which we have already studied in the previous lectures and then the automaton that is used for Designing this kind of grammar that is type three grammar is finite State automat that is a finite State machine of fin set automata which we have already studied in the previous lectures okay and then we have type two grammar in which the grammar accepted are context free grammar and then the language accepted by type two grammar are context free languages which we will be studying in the following lectures and then the automat that is used for Designing this is the pushdown automata all right and then we have type one grammar in which the grammar accepted is context sensitive grammar and then the language accepted by this is context sensitive language and then the automat that is used for Designing this is the linear bounded automatan and then we have type zero grammar in which the grammar accepted or unrestricted grammar and then the language accepted by this is the recursively enumerable language and then the automaton that is used for Designing this is the touring machine okay so these are the types of grammar that we have according to n Chomsky classification and we will be starting with regular grammar which will be discussed in this lecture so first let us see how can we Define grammar and then we will come to regular grammar okay so here we will see how can we formally describe grammar so a grammar G can be formally described using four tles given as G equal to V T S and P so grammar G can be defined using four tles which are VT S and P and let's see what does these tles mean where V equal to the set of variables or non-terminal symbols so V are a set of variables or non-terminal symbols and T is a set of terminal symbols and S is a start symbol and P is a production rule for Terminals and non-terminals okay so VT and S are easy to understand but let us try to understand what is p p is a production rule a production rule has the form Alpha tends to Beta or Alpha gives beta where Alpha and beta are strings on V Union T that means it can belong to the set of non-terminal symbols and terminal symbols and at least one symbol of alpha belongs to V which is a set of non-terminal symbols so don't worry even if it is a bit confusing it will become clear when we take the example so here we have an example given we have a grammar G and then it is equal to and we have a set of symbols here s a b then we again have small AB s and then this production rule so let us try to understand this example grammar which is given here and let us try to see what are the tles in this so we have the first tle which is V which is the set of variables or non- terminal symbols so here it is s a and b s a b these are the variables of the set of non-terminal symbols and then we have t which is the set of terminal symbols which are A and B A and B are the terminal symbols and then we have start symbol S which is equal to S itself here start symbol is given by S and then we have a production rule P which is given by this so the production rule is given like this s gives a and a gives small A and B gives small B so this is the production rule of this grammar now let us try to take an example and see some strings that can be formed using this grammar that is given here so we have to look at the production rules over here so our starting symbol is s so I take s and I can say that s gives AB from this production rule s gives AB so s gives ab and then we also have in the production rule that a gives small a so instead of this big letter A I can write small a because a gives small a a and then this B let me write it as it is and then this B also we see that it gives small B so this a I write as it is and instead of this B I can write small B by this production rule so we get a string AB now this string AB is something that is designed using this grammar so this is how we will Design uh strings or we will find out strings that will be accepted by C grammars okay so I hope that made the concept of grammar clear to us so if that is clear let us go to the next part that is regular grammar which we will be discussing now okay now let's come to regular grammar so regular grammar it is of two types it can be divided into two types the first one is right linear grammar and the other one is left linear grammar so let us see what is the meaning of right linear grammar and left linear grammar and let us try to find out the difference between them so a grammar is said to be right linear if all Productions are of the form a gives XB and a also gives X where A and B belongs to V which is the set of non-terminal symbols and X belongs to T which is a set of terminal symbols so if you have a grammar and if the Productions rules are of this form here if you look here we see that X is a terminal symbol and B is a non-terminal symbol now if the non-terminal symbol lies to the right of the terminal symbol then it is said to be a right linear grammar so here we see that X is a terminal symbol and B which is a non-terminal symbol lies to the right side of X the terminal symbol so it is a right linear grammar and then left linear grammar is just the opposite of that I hope you can already see the difference a grammar is said to be left linear if all Productions are of the form a gives b x and a gives X where a belongs to set of non-terminals and X belongs to set of terminal symbols so here we see that X is a terminal symbol and B which is a non-terminal symbol lies to the left of the terminal symbol which is X so this kind of grammars which have this kind of production rules are said to be left Le grammar so let us take a simple example to understand it in a better way so here let me take an example where I have a grammar whose production rule is of the form s gives a b s and also B let's say so s gives a b s and also B so here A and B are the terminal symbols and S is the non-terminal symbol so here we see that s which is a non-terminal symbol lies to the right of A and B which is the terminal symbol so this is a right linear grammar so this is right linear now if I have another grammar s which has a production rule of the form s gives s BB and also B so here B is a terminal symbol and S is a non-terminal symbol and we see that the non-terminal symbol S lies to the left of the terminal symbols B so this is a left linear grammar so this is how you identify right linear grammars and left linear grammars and this is the difference between them so I hope this made us the concept of right linear grammar and left linear grammar clear to us which are the types of regular grammar and we also understood what is the meaning of grammar and we also saw the types of grammar according to n chomsky's classification so I hope this was helpful to you thank you for watching and see you in the next one [Applause] [Music]