 So, you know that language written by a regular expression is defined as regular language. Now, we are in a position to provide alternative definition of regular languages via finite automaton either DFA or NFA and also via regular grammars. That is the class of regular languages is precisely the class of languages accepted by finite automata and also it is the class of languages generated by regular grammars. So, these results will give by providing a few theorems. So, first we are going to prove that regular expressions are equivalent to finite automaton. That means, the class of languages accepted by DFA or NFA is same as that written by regular expressions. So, we say that a regular expression R is equivalent to a finite automaton A. Suppose, A is a finite automaton, we say that R is equivalent to the finite automaton A. If the language written by the regular expression is precisely accepted by the finite automaton A. Now, in order to prove this equivalence regular expressions are equivalent to finite automaton. So, what we will do? We prove these two. Given a regular expression R E, we construct an equivalent finite automaton and then given a DFA, we show that L of A is regular. That means, there is a regular expression R that represents the same language accepted by the finite automaton A that is L A. Now, to prove one we will first prove this first point. So, we will first prove three lemmas. So, what we will assume is that say R 1 is a regular expression and R 2 is a regular expression. Then let us assume that there exist finite automaton say A 1 denoted as Q 1 sigma delta 1 Q 1 F 1 and which accept the language written by the regular expression R 1. That means, L of A 1 is exactly L of R 1 and assume that for this regular expression R 2, we have an automaton say A 2 given by Q 2 sigma delta 2 Q 2 and F 2 such that L of A 2 is exactly L of R 2. So, we assume that for two regular expressions, even regular expressions we have two automaton A 1 and A 2 respectively that accepts the corresponding language of the regular expressions. Now, we prove these lemmas. So, first lemmas says that there exist a finite automaton except in L of R 1 plus R 2. That means, given R 1 and R 2 and the corresponding finite automata, then we can construct a finite automaton accepting a language R 1 plus R 2. Let us see how can you do that. So, let us assume that the automaton A 1 for R 1 for L of R 1 is this one. So, there is star state which is Q 1 and there are many other states and eventually set of final states. Let us denote it as F 1. So, this is the automaton A 1. Similarly, we have the finite automaton A 2 for L of R 2 where we have the star state Q 2 as you have already defined and set of final states this is F 2. So, this automaton accepts L of R 2. So, A 2 is for L of R 2. Now, from these two automaton will construct a finite automaton which is say A which will accept the language L of R 1 plus R 2. Now, to do that from A 1 and A 2 we construct say A which will accept L of R 1 plus R 2 we claim that way. So, it is nothing but Q sigma delta Q 0 F the corresponding elements where Q is basically all the states in A 1 union states in A 2 and then we introduce a new state which is star state of the automaton A that is Q 0 is the new state that we have introduced. Then set of final states for this automaton A is the union of the final states of A 1 and A 2 and we define delta which is from Q cross sigma union epsilon this is basically an NFA goes to the power set of Q. So, we define by we define this transition map by this. So, delta Q A for this automaton where Q is any state then it may be we keep all the transitions from the automaton A 1 that means delta 1 Q A. If Q belongs to Q 1 capital Q 1 and A belongs to sigma union epsilon that means it retains all the transition functions of automaton A. It also retains all the transition functions of the automaton Q 2 that means delta Q A equal to delta 2 Q A if Q belongs to Q 2 because we have used delta 2 and A belongs to sigma union epsilon. Finally, from the star state Q 0 if Q equal to Q 0 if there is a star state then on epsilon the automaton A will transit to either Q 1 there is star state of A 1 or Q 2 that means it is nothing but Q 1 union Q 2. So, if Q equal to Q 0 and A equal to epsilon. So, on epsilon transition from the star state of new automaton A it will move to either the star state of A 1 or the star state of Q 2 that means in this figure what we do we for the automaton A we introduce a new star state that is Q 0 and from this Q 0 to the star state of A 1 we give epsilon transition and from the star state of A we give epsilon transition to the star state of A 2 and the resultant automaton that you have got the resultant automaton that you have got is the automaton A and I claim that this automaton A accepts the language written by the regular expression R 1 plus R 2 that means L of A is nothing but L of R 1 plus R 2. So, intuitively it is quite clear because if this automaton A accepts the language accepts the string suppose x belongs to L of A then it has to start it to process the string x start Q 0 it must first I will transit to star state of A 1 or it may transit to the star state of Q 2 by taking an epsilon transition first without loss of generality if it transits to the star state of A 1 that is Q 1 and from this point on word it will follow all the transitions of A 1 because we have retained all the transitions of A 1 and then on word by processing the string x eventually it will one of the final states that is one of the final states from F 1 and since F 1 and since F 1 is also a final state of this automaton F the string the string will be accepted by the automaton A 1 as well since axis process at star state Q 1 and eventually it enters a final state which is in F 1 that means formally you can write it that for x belong to sigma star x belongs to the language of the automaton A if and only if there is a transition or it processes the string starting at state Q 0 delta hat Q 0 x and eventually it arrives at the final state that means the set of next states intersection F not equal to phi that is how we define the acceptance by an F A if and only if delta hat you can write it as Q 0 epsilon x because x can be written as epsilon x intersection F not equal to phi if and only if delta hat since this Q 0 epsilon x we can write it as delta hat Q 0 epsilon first process the string epsilon and then it take the string x so we apply the same x and transition function delta hat this interaction F not equal to not equal to phi not equal to phi now the way we have defined this transition delta hat Q 0 epsilon there is nothing but it may go to either Q 1 or Q 2 that means we will have delta hat 2 sets Q 1 and Q 2 because if we start start set of the automaton A take epsilon transition it may either go to Q 1 or it may go to Q 2 then it will process the string x so this interaction F not equal to phi so this means that if and only if delta delta hat Q 1 x and delta hat Q 2 x and take the union that is how we define delta hat Q 2 x Q 2 comma x so this intersection F not equal to phi so if and only if by applying laws of set theory we can write it as delta hat Q 1 x union sorry intersection F intersection F union delta hat from this delta hat Q 2 x interaction F Q 2 x intersection F this not equal to this if and only if since this F over here delta hat we are considering only the moves of automaton A 1 delta hat Q 1 x we started at start set of Q 1 and from that point on word there will not be any transition from automaton A 2 so therefore we can write this as F 1 union and this one we can write it as delta Q 2 x since from this point on word we will take only the transitions from automaton A 2 therefore we can write it as F 2 so this is not equal to phi so this if and only if this says that x belongs to language the automaton A because start the start set of automaton A 1 process of string x so if you arrive at at least some set which belongs to the automaton I mean final set of A 1 similarly this says that x belongs to L of A 2 so therefore x belongs to either this or either L of A 1 or x belongs to L of A 2 so since this not equal to phi delta hat Q 1 x interaction F 1 not equal to phi means x belongs to L of A 1 similarly delta hat Q 2 x interaction F 2 not equal to phi this belongs that means x belongs to L of A 2 this means x belongs to L of A 1 union x belongs to L of A 2 therefore if x belongs to L of A then x must belong to either L of A 1 or x must belong to either L of A 2 therefore L of A equal to L of A 1 union L of A 2 so this is proved. Now in lemma 2 we will show that so if there exist fine automaton for regular expressions R 1 and R 2 then there exist a finite automaton accepting L of R 1 R 2 which is a concatenation of the 2 regular expressions let us prove it so it looks quite simple and similar to the previous one so what you do if this is the automaton A 1 with star state Q 1 and the set of final states F 1 and this is the automaton A 2 this is for L of R 2 and this is for L of R 1 which has a star state Q 2 and the set of final states F 2 what you do in the automaton A that you construct for L of R 1 R 2 from this 2 automata A 1 and A 2 we consider this F 1 to be F 1 the set of final states to be non final states and give epsilon transition from each of these final states to the star state of automaton A 2 and in A this is the new automaton A that you have constructed Q 1 in the star state and F 2 the set of final states of A 2 will be the will also be the final state of A and all these final states of Q 1 will be non final states or ordinary states in A now we claim that the language accepted by the automaton A is nothing but the language accepted by A 1 concatenation language accepted by A 2. So, therefore, it is nothing but L of R 1 concatenation R 2 formally the construction can be shown to be like this A is a going to pull it Q sigma delta is Q 1 is a star state of A and F 2 set of final states of A 2 is a final states of final states final states of A. So, where Q equal to Q 1 union Q 2 we have not introduced any new state over here the set of states remains same Q 1 union Q 2 and delta is defined by let us define delta like this. So, delta of Q A is basically delta 1 Q A we retain all the transitions of this state of this automaton A 1. Therefore, delta Q A what is automaton will retain all the transitions of this one except that there will be a transition on epsilon from the set of final states to the star state of Q 2. So, there is nothing but delta Q A equal to delta 1 Q A if Q belongs to Q 1 if Q belongs to Q 1 and A belongs to sigma union epsilon of course, this will be Q 2 if Q belongs to F 1 that means, for all states other than F 1 we retain this transition whenever it enters a final state of A 1 then on epsilon it goes to the star state of A 2. Similarly, once it enters the star of Q 2 we retain all the transitions of A 2 that means, delta Q A equal to delta 2 Q A if Q belongs to Q 2 and A belongs to sigma union epsilon that is as well. So, this is a transition function that is defined for the automaton A that we have already constructed. Now, we claim that L of A equal to L of A 1 combination L of A 2 to do that suppose that there is string x which is A 1 A 2 up to say A n and this belongs to say L of A that means, this automaton A that we have constructed from A 1 and A 2 accepts the string x which is the form A 1 A 2 up to say A n where each A i belongs to sigma that is delta hat Q 1 x star state of automaton A is Q 1 if it process the string x at the star state then it will eventually it is a final state that means, this intersection F 2 not equal to phi this is from the definition of acceptance of A string. Now, it is clear from the construction of the automaton A that only way to reach from Q 1 the only way to reach Q 1 reach from Q 1 any state of F 2 is via this state Q 2 because we have to arrive first one final states of A 1 from there we have to take an epsilon transition to Q 2 and then only we will be able to arrive at one final states of F 1 and we have only epsilon transition from F 1 to Q 2 does while traversing through x while it traverses through x the automaton A from Q 1 to some states of F 2 there must exist some state that belongs to F 1 and some number k which is less than or equal to n where n is a number of symbols over here such that p must belong to the set of next states when you process from star state the string A 1 A 2 up to A k. So, after processing up to k the automaton enters the state p where p is a final set of A 1 from there it has to take epsilon transition to Q 2 and then delta hat Q 2 A k plus 1 A k plus 2 up to it is a process the whole string and this will eventually it is a final state of A 2 that means this intersection F 2 not equal to 5 then what I found is that the string x 1 which is A 1 A 2 up to A k this must belong to the language of the automaton A 1 because it has started the star state of automaton A 1 and process the string say this is x 1 and p is a final state of F 1 therefore, this string must be accepted this x 1 must be accepted by the automaton A 1. So, this belongs to language of A 1 and the x 2 the other string this string say call it x 2 A k plus 1 A k plus 2 A n since after processing this string x 2 at the star state of Q 2 and taking all the moves of A 2 it eventually enters a final state because this intersection F 2 is not equal to 5 therefore, this must belong to the language of A 2. Therefore, x which is equal to x 1 x 2 must belong to L of A 1 concatenation L of A 2 conversely to prove the converse say x some string x belonging to H C master belongs to the language of L of A 1 L of A 2 then we can write x as x 1 x 2 such that x 1 belongs to L of A 1 and x 2 belongs to L of A 2. So, for some x 1 belong to sigma star it must belong to L of A 1 and x 2 must belong to L of A 2. So, that x 1 x 2 is nothing but x therefore, if that is the case then delta hat Q 1 x 1 intersection F 1 not equal to 5. Similarly, for this from this we get delta hat Q 2 x 2 intersection F 2 not equal to 5 according to the definition of acceptance of string by each of these automation. Now, if we consider this computation Q 1 x Q 1 x is Q 1 x 1 x 2. So, in 0 or more steps eventually it will arrive at P after processing the string x 1 and x 2 will get to be processed. So, where for some P belong to the final sets of final set of F 1 now from here this configuration can be written as P epsilon x 2 and here from this since P belongs to the final set of A 1 by taking epsilon transition from dead state it can go to the star set of A 2. So, therefore, in one step it will go to star set of Q 2 from P epsilon and x 2 will remain because you know that delta P epsilon equal to Q 2. Now, from this point onward taking 0 or more steps eventually when it is processed it will arrive at some state say P dash and the string epsilon will be actually exhausted where P dash is a final set of F 2. So, since we have this computation therefore, delta hat Q 1 x intersection F 2 not equal to 5. So, if you start at Q 1 process the whole string x eventually we arrive at a state P dash which belongs to F 2 therefore, delta hat Q 1 x interaction F not equal to 5. So, this implies x belongs to L of A. So, therefore, we have proved this lemma. Now, let us show or prove under lemma which is a lemma tree it says that given any regular expression R 1 if we have a final automaton to accept the language written by this regular expression R 1 then there exist a finite automaton accepting the language L of R 1 star L of R 1 star. That means, the clean closure the regular what a clean closure of the regular expression R 1 will have a finite automaton we can always construct a finite automaton. So, what we do in the construction is that so, if this is the finite automaton accepting the language written by the regular expression L of R 1 it will have a star state Q 1 and a set of final states set is F 1. So, we construct a new automaton say it is A say it is A 1 accepting L of R 1 we construct a new automaton where we introduce a new star state that is Q 0 a new final states final state say it is P and we consider all the final states of A 1 to be non-final states in the automaton A. Then we give epsilon transition from the final it is all final states of A 1 to the final state P of automaton A we provide epsilon transition from final states of A 1 to the star state of A 1 and also we provide an epsilon transition from a star state of A to the final states of final state of A. So, clearly this is a NFA and this NFA we have constructed from the automaton A 1 for L of R 1. So, clearly the automaton A contains the element Q sigma delta Q 0 F where Q is Q 1 union we have introduced a new star state and final state P and delta Q A for the automaton A is defined as it will go to state either Q 1 or P on epsilon transition on epsilon transition. If the state Q belongs to the final state of so this epsilon transition if it belongs to this final state of A 1 or it is a star state of A that means for this epsilon transition. So, if Q belongs to F 1 union Q 0 then on epsilon transition A equal to epsilon it will go to either Q 1 F 1 to Q 0 to sorry this is Q 1 Q 0 to Q 1 or F 1 to P or Q 0 to P and then it takes or retains all the generations of the automaton A 1 if Q belongs to Q 1 and A belongs to sigma union epsilon. So, that is how we have constructed the automaton A from the automaton A 1 and we claim that this automaton A accepts the language L of R 1 star this because without taking an input at a star state it may go to the star state of A 1 and then using this transition using this transition from the final states once it which says the final state using this transition may again come back to the star state of Q 1 and it can be done many numbers of times. So, that denotes R 1 star because this automaton A 1 accepts L of R 1. So, since we have introduced this loop on epsilon transition from the final state to the star state of from a star from the final state of A 1 to the star state of A 1 because of this anything that lead the automaton A 1 from the star state to final state that can be taken many number of times and since because of this epsilon transition from star state of Q 0 to the final state of star state of A Q 0 to the final state P of A epsilon is also accepted by the automaton A. So, therefore, this is nothing but L of R 1 star let us prove this formally we prove that L of A is nothing but L of A 1 star. Now, for x belonging to sigma star let us consider any string over sigma star x belongs to L of A means delta hat Q 0 x from a star state you process this eventually it must arrive at a state P with a final state of the automaton A. This implies that either x is epsilon in such a case from a star state Q 0 directly we can go to state P or delta hat Q 0 x intersection F 1 not equal to phi that means we process the string x at state Q 0 eventually arrive at on the final state of A 1 and from there we can take the epsilon transition to P that we also we can accept the string. So, either x equal epsilon or this must be true if x equal epsilon then trivially x belongs to L of A 1 star. So, it is quite trivial otherwise there exists a sequence of states say P 1 P 2 P k which belongs to F 1 and some substrings of x is x 1 x 2 to say x k such that we can arrive at P 1 after processing the string x 1 at the star state Q 1 process the string x 1 at Q 1 this is x n transition function then you can arrive at string P 2 that means P 2 belongs to delta hat Q 2 x 2 and so on eventually P k belongs to delta hat. So, it is Q 1 every time you start at the star state of the automaton A 1 so Q 1 x k process the string x k at the star state of Q 1 and eventually it will lead us to state P k thus for all i greater than or equal to 1 less than or equal to k x i must belong to L of A 1 because in each case P 1 P 2 P k they belong to the state set of final states. So, therefore, each substring x i x 1 x 2 x k must belong to the language L of A 1 therefore, x belongs to L of A 1 star. So, we have shown approved three lemmas that means given automaton final automaton for the language dependent by R 1 there is A 1 and for R 2 if the automaton is A 2 then you can always construct final automaton accepting the languages L of R 1 plus R 2 L of R 1 R 2 and L of L of R 1 star. Now, we are going to prove the theorem that the language denoted by a regular expression regular expression can be accepted by a finite automaton. So, in that we will be using these three lemmas say lemma 1 lemma 2 and lemma 3 now let us prove this theorem. So, proof of the theorem so we proved the result by induction on the number of operators of a regular expression. So, number of operators of a regular expression R we apply in that is on that suppose R has 0 operators then that is the basis case in such a case R must be either epsilon or phi or it may be a single symbol A that belongs to the input alphabet because there is no operators involved it must be a single symbol it may be phi or it may be epsilon. For each of the cases we can construct final automaton to accept this for example, if R equal to epsilon then the finite automaton containing the single state and which is a star state and also a final state. So, this state will accept and this finite automaton will accept the string epsilon. Similarly, if R equal to phi then a finite automaton of this form say this is the state P star state and for any symbol A belonging to sigma there is a flip and there is no final state. In such a case no string will be accepted by this finite automaton and hence R equal to phi or we can also do it like this we can incorporate a final state say P star state. So, for all A belonging to sigma we give a self-loop here and then say this is the final state say this is Q and we give a transition from Q on all A belonging to sigma. So, since there is no part from the star state to the final state this will also accept empty set. So, therefore, this is the automaton either this or this one is an automaton to accept the empty set and then if R equal to single symbol A then this automaton with star state P on A it goes to the final state Q. So, this automaton will accept the language the language of the automaton will be simply the singleton A. So, therefore, this automaton accepts R where R equal to A. Now, suppose that the result is true for regular expressions with say K or fewer operators. Suppose R is a regular expression which has K or fewer operators and for that case assume that the result is true we have a finite automaton to accept the same language represent by R that is the hypothesis. Now, consider a regular expression R that has K plus 1 operators we have to show that for this regular expression also or say R dash which has K plus 1 operators then for this regular expression also will be able to construct a final automaton. So, how to do that if this expression regular expression has K plus 1 operators then there are three cases according to the operators involved in regular expression or with regular expression. So, number 1 this R s must be R 1 plus R 2 number 2 it may be this R s must be R 1 R 2 or number 3 this R s must be some R 1 star. So, you have considered this some concatenation and clean closure. So, in any case you know that both R 1 and R 2 since R s has K plus 1 operators both R 1 and R 2 must have K or fewer operators. So, therefore, for each of this R 1 and R 2 we have already finite automaton for R 1 and R 2 is already available according to inductive hypothesis. Now, already we have shown by using this lemma 1 and lemma 2 and lemma 3 that if there is a finite automaton for R 1 and R 2 then we have finite automaton for L of R 1 plus R 2 L of R 1 R 2 and L of R 1 star. Therefore, so therefore, for R s which has K plus 1 operators which is nothing but R 1 plus R 2 or it may be R 1 R 2 or R 1 star will have finite automaton accepting R s. So, therefore, for L of R s we have a finite automaton. So, therefore, given any regular expression R will be able to construct a finite automaton accepting the language represented by this regular expression. So, this completes the proof that theorem that for any given regular expression we can construct a finite automaton accepting the same language. Now, let us give an example demonstrating the construction of an NFA for a regular expression. Consider regular expression say R which is a star b plus a. We will just follow the steps which we have already described to construct finite automaton for regular expression R. First we will use the corresponding NFA for each sub expression of a star b plus a. For this a and the first sub expression the corresponding automaton according to our construction is this one containing a symbol two states starts in a finite state within a single transition on symbol a. So, this automaton accepts the regular expression simply a. From this by the construction of clean closure we can have for the sub expression a star we can construct the automaton like this. We start with this automaton this a. We introduce a new star state and a final state and we make this to be non-final state then this a new star state then epsilon transition directly to this final state epsilon transition to this star state of the previous automaton epsilon transition to the final state from the previous final state and from this final state of the previous automaton to the star state we give an epsilon transition. So, according to the construction this automaton will accept the language of the regular expression a star. Then for b similarly expression b we have the automaton containing two states where there is single transition on input symbol b. Therefore, for a star b that means concatenation of this a star and b we can now construct the automaton like this. First you consider this automaton and then epsilon transition to this one epsilon transition. So, these are automaton for a star and these are automaton for singleton b. Now, according to the construction we consider this to be a non-final state and from this non-final state we give an epsilon transition to the star state of this automaton and we make this to be the star state of the automaton and this is the final state of this automaton. So, this will accept the language of the regular expression a star b. So, therefore, the automaton for a star b plus a will be this automaton union will create now a new star state and the automaton for a will be for this a we draw here the transition diagram for the automaton with a singleton a and we create a new star state give epsilon transition to the star state of previous automaton and epsilon transition to star state of this automaton. So, these are star state of the new automaton and this one and this one will the final state of this new automaton which will accept the language a star b or a.