 .We have already discussed and introduced deterministic finite automaton. So, today we will discuss another kind of automaton that is called non-stimulistic finite automaton. Before that, we will just introduce one or two examples of deterministic finite automaton and then we will proceed to describe formally non-stimulistic finite automaton. We have said that a DFA is a quintuple. So, a is a DFA, a quintuple q sigma delta q 0 and f. So, where q is a set of finite states, sigma is a set of alphabet, delta is a transition map, q is a start state or initial state and f is a set of final state. Now, just consider the language over the alphabet containing two symbols, say a b. Just consider the language over this alphabet, set of all strings over a b which ends with a. That means, it is of the form x a such that x belongs to a b whole star. So, x is any string over a b and eventually is terminated with a. So, how to construct a DFA for this language? Now, if we observe that we observe that every string ends with a symbol a. So, if we assume a state q 0 to be the initial state, then an occurrence of a has to be distinguished in the state q 0. So, this can be done by making a transition from this state on input symbol a to some other state say this q 1. So, on symbol a and the initial state q 0 will transit to state q 1, just so distinguish the occurrence of the symbol a. Now, whereas on symbol b will continue to be in q 0 itself, because we need not distinguish the occurrence of b in the state q 0. Now, on subsequent a at q 1 just remain in the same state q 1, because it does not matter it will still end with a. Now, by making q 1 is a final state all such strings can be accepted. Now, if we encounter a b at q 1. So, it is a b at q 1. So, we need to go out of q 1 as q 1 is a final state and we do not want to terminate the string with b. And once you go out from q 1 on symbol b again we need to see whether an a has occurred again or not, but since q 0 is doing the same job. So, therefore, on b you can directly go to q 0. So, that after that again you can check whether an a has occurred. So, therefore, this will cover all possibilities and you will see that this d f a will accept the language that we have just given that means the set of all strings over a b that ends with that end with a. Now, let us consider under d f a where it has states like an initial state this state on b goes to the next state and on a it remains in the same state. So, this state on a goes to the under state again which is a final state and this on b again goes to another final state. Now, this final state on b goes to this state and this on a goes to the initial state and this state on b remains on the same state whereas, this on a goes to the other final state. So, unlike the example that you have just given it is little bit tricky to find out or determine what the language accepted by this d f a. Now, but if you if you spend some time it may be possible to conclude that the language accepted by this d f a is nothing but the set of all strings over a b with last but one symbol as b that means it accepts the strings of the form x b and then a or b where x is any string over the sigma or that means over a b. So, any string concurrently do it b and then concurrently do it either a or b will be accepted by this d f a but it is not so easy to comprehend the language accepted by this d f a rather if this language is given then it is quite easy to construct a transition diagram of final automaton which will accept this language. For example, say we start with the initial state say b this on a and b will remain on the same state on b it will go to state q q on a and b will go to state say r which is a final state and there is no transition out of a. So, this type of automaton what we have found is that there may be multiple transition that means from state p we have transition on a to p itself and to q. So, we have multiple next states on state p then we do not have any transition out of state r on any input symbol neither on a nor on b we do not have any transition out of b. So, this is slightly different consider to the automaton that we have already drawn that is the d f a. So, in this automaton if say a b b a b a is given as input then we can trace we can find out two execution traces for this string. For example, on input symbol a and b we can always remain at p we take a remain at p we take b remain at p we take b remain at p we take a remain at p we take b remain at p and we take a remain at p again we can keep on doing the same thing on a remain at p b remain at p b remain at p a remain at p and whenever we get this b from p to q we can have a transition on b and finally from q on symbol a we can go to the state r. So, clearly these are two possible execution traces on the input string a b b a b a for this finite automaton. Therefore, we have two next states p and r on the input string a b b a b a for this finite automaton. Now, since for this input string we have two execution traces and we reach in one case the state p the next state is p and for the r case the next state is r and here r is a final state if we assume that in chart case in one of the execution traces whenever after completion the state reach is a final state we say that the string is accepted. If we consider this notion of acceptance then we say that this string will be accepted by this finite automaton. So, this type of automaton with some additional features where we have multiple next states or where there may not be any next on some input symbol and with some more additional features is said to be non deterministic finite automaton. So, what will do we will now formally introduced the notion of non deterministic finite automaton in contrast to DFA where we have a unique. So, we are going to introduce non deterministic finite automaton or simply an FA. So, in contrast to DFA where we have a unique next state for a transition from a state on an input symbol. Now, we consider a finite automaton with non deterministic transitions that means a transition is non deterministic if there are several transitions from a state out of a single symbol say a there may be multiple transitions the same symbol a or possibly there may be zero transition that means there may not be any transition out of a state on some symbol a there may not be any transition. So, either multiple next states or no next state and then there may be a transition out of a state without taking an input to some other state this type of transition is said to be an epsilon transition. So, those are possible non deterministic transitions we are going to introduce in non deterministic finite automaton. So, formally in the line of deterministic finite automaton we define a non deterministic finite automaton or NFA as a quintuple. So, n is a quintuple again it is q sigma delta q 0 f where q sigma q 0 and f they are having all same meaning as you define in case of a DFA and we simply differentiate this delta the transition map for this NFA. So, what we have said is that in case of NFA it can go from one state on some input symbol say sigma to multiple next states. So, it is not a single state now in case of DFA it was simply q the transition map was defined like this q cross sigma goes to q. So, in this case it may go to multiple next states or there may not be any next state that means it is a any subset of q that means it is a power set of q which is introduced as or denoted as p q is a power set of q. And since we take not only a symbol from sigma, but it may be an epsilon also because there may be some epsilon transition without taking an input there may be transition out of a state from one state to another state. So, therefore, it is q cross sigma union epsilon. So, the transition map is defined as q cross sigma union epsilon goes to the power set of q. So, that is how we define the transition now one thing is very clear is that every DFA can be treated as an NFA because DFA is a special case of NFA. So, this is quite clear from our definition. Now, let us give an example consider a DFA NFA where the set of states is basically q 0, q 1, q 2, q 3 and q 4. There are five states sigma is a b contains two symbols the set of final states is basically q 1 and q 3 and delta is defined by the following map. So, it was defined delta by giving this map. So, in this case we have five states q 0, q 1, q 2, q 3 and q 4. So, for the input symbol a and b we will have two columns besides that we will have need to have a column for epsilon to consider the possibility for epsilon transition. Let us say q 0 on a transit to q 1. So, it is subset containing only state q 1. So, q 0 on b there is suppose no next state. So, it is an empty set phi. So, q 0 on epsilon suppose it goes to state q 4. So, it is a subset containing state q 4. So, q 1 on a does not have any transition there is phi. So, q 1 on b say it remains in the same state. So, it is q 1 containing the only subset containing only state q 1 and q 1 on epsilon suppose it goes to q 2. So, it is subset containing a state q 2. Similarly, suppose q 2 on a it goes to two states there are two transitions defined say multiple next states q 2 and q 3. So, it is subset containing two states q 2 and q 3 say q 2 on b suppose it goes to q 3 and q 2 on epsilon suppose it goes to no other states. So, it is phi. Similarly, on q 3 there is no transition defined on any input symbol neither on epsilon. So, it is all phi. Similarly, q 4 on a suppose it remains in the same state q 4 on b suppose it goes to q 3 and q 4 on epsilon no transition is defined. Suppose, this is a transition map that we have. So, the way we have drawn the transition diagram already for DFA in this case also you can draw a transition diagram for the NFA q 0 is the initial state. So, q 0 on a goes to q 1 b no transition defined and on epsilon it goes to q 4. So, there are two transitions on a and epsilon suppose on a it goes to q 1 that you have given and on epsilon it goes to q 4 and q 1 is also a final state again as given in the transition map q 1 on b remains in the same state and q 1 on epsilon goes to state q 2 and there is no transition defined on a for state q 1. So, q 2 on a remains in the same state as given the transition map and q 2 on a again goes to the state q 3 as I define multiple next states for q 2 on input symbol a q 2 on b it also goes to q 3 and on q 3 we do not have any transition defined on any input symbol and then q 4 on a remains in the same state q 4 and on b it goes to the other final state q 3. So, this is a transition map that we have drawn for a example n f n. Now, just consider what are the non-transition that we have in this particular n f n. So, non-transition are that there is no transition from q 0 on input symbol b there is no transition defined then there are multiple transitions from q 2 on input a there are two transition defined on q 2 and q 3 and then there are epsilon transitions from q 0 to q 4 on epsilon and q 1 to q 2 on epsilon q 0 to q 4 on epsilon and q 1 to q 2 on epsilon. So, these are the various possible non-transitions that we have similarly on at q 3 there is no transition defined on any input symbol. So, these are all possible non-transitions that we have in this example now just consider the string a b and let us process the string a b at state q 0 and let us see what is the execution trace in this case. We will see that process the string a b at state q 0 from q 0 taking a it may go to state q 1 and at q 1 taking b it may remain in the same state q 1. So, this is one possible execution trace then the next one is that q 0 without taking any input say this epsilon transition. So, this is the epsilon transition that we have it can go to state q 4 at a state q 4 taking input symbol a it may remain in the same state q 4 and from q 4 taking this transition it may go on input symbol b to state q 3. Then the third possibility is that q 0 taking a it can go to q 1 and then at q 1 taking an epsilon transition it can go to q 2 and at q 2 taking b on input symbol b it will go to state q 3. So, this is another possible execution trace for a given string a b at state q 0. Another possible execution trace is that at q 0 it will take the input a go to state q 1 then it will take input string input symbol b it will remain in the same state q 1 because on q 1 on input symbol b it may remain in the same state and then can take epsilon transition at q 1 and go to state q 2. Now, see that there are three distinct states q 1 q 3 which are reachable from q 2 via the string a b. That means, while tracing a path from q 0 on string a b what we have considered is that we considered possible insertions of epsilon in the string. That means, wherever is epsilon transition defined that means in a second case what we have considered is that we have considered the string to be epsilon a b because we have taken first an epsilon move and then we have taken the move on a on q 4 and a move on b at q 4. In the second case we have considered the string to be a epsilon b because first we have considered a move on a at q 0 then we have considered an epsilon move because it is defined over here at state q 0 at q 1 and we have moved to q 2 and at q 2 we have gone to b q 2 we have gone to q 3 on input symbol b similarly in the last case we have considered a string to be a b epsilon because the last step is an epsilon transition because it is defined and we have taken accordingly and we have moved to the state q 2. So, wherever the epsilon transitions are defined we can take it and hence we can consider possible insertion of epsilon at various positions of the string. So, it is clear that if we process the input string a b at the state q 0 then the set of next states set of next states are q 1 q 2 and q 3. Now, just consider n f a q sigma delta q 0 and f now given an input string x out of form say a 1 a 2 up to some symbol say a k and an input state and the state out of the n f a say it is p the set of next states starting with p we process the string x then we will get a set of next states we define as delta hat p x. Now, this can easily be computed by using a tree structure which is called computation tree of delta hat p x. So, let us first define what is a computation tree for delta hat p x. So, if you consider delta hat p x where x is a 1 a 2 up to your a k then a computation tree for this delta hat p x is basically a tree which is rooted at node p. So, root node is p then children of root node p are precisely those nodes which are reachable or which are having having transition from p via epsilon or the input symbol a 1 the first input symbol we started p and then we see where are any possible transition on epsilon or on the first input symbol a 1. So, all those nodes will be the children of p then for any node if we have the branch from the root to that node if the branch is labeled which a 1 a 2 up to say a i then the children of those nodes will be exactly children of that node will be exactly those nodes where we have a transition from this node to that node via the input symbol a i plus 1 because the next input symbol is a i plus 1 we have to go up to a k or via an epsilon transition. So, we need to consider where are in epsilon move from this node or any move on input symbol a i plus 1. So, all those nodes will be the children of this particular node then if there is a final state whose branch from the root suppose this branch from the root this node is labeled x which is equal to a 1 a 2 up to a k then we simply put a tick mark. Finally, if the label of a branch of a leaf node suppose we have constructed a tree and eventually we have arrived a leaf node because there is no any transition defined on any input symbol from that particular node. So, therefore, we have arrived a leaf node and the label of this branch is a preffy of x is not x, but it is a preffy of x then we put a cross mark to indicate that we cannot could not process the full string x starting with x following this path. So, that is how we have defined a composition tree. Now, let us draw the composition tree for the string a b that means for the string a b starting at q 0 for a given n f a example n f a example n f a was this one .So, starting at q 0 we can have we can process the string a b in a different way that we have already given over here. So, accordingly we can start at q 0 is a root node then we can process the string a b following this path take a we arrive at node q 1 or we can also follow an epsilon transition to arrive at node q 4 starting at a if we concentrate input b we will move to state q 1 again because on b q 1 remains the same state and since q 1 at this q 1 we have process the full string you put a tick mark over here and then on epsilon it goes to state q 2 similarly at state q 1 taking an epsilon transition you can go to state q 2 without taking an input. So, far we have process only a in this bronze and at q 2 taking b you can arrive at the state q 3. So, here again we have process the full string a b along this path. So, we put a tick mark over here and via this q 0 on epsilon to on epsilon it goes to q 4 at q 4 taking the input a it remains in the same state q 4 and at q 4 taking b you can go to q 3 and there is no transition define on q 3 and you have already process the full string a b over here. So, you put a tick mark. So, that is how we have drawn the combination tree for the string for delta hat q 0 a b similarly we can also draw the combination tree for the string a b b say delta hat q 0 a b b. So, if you follow the same process then what will you see is that the combination tree looks like this one q 0 on a it goes to q 1 taking b it goes to q 1 again and taking b it goes to q 1 remains in the same state and at q 1 you can take an epsilon transition which will go to q 2. But already we have process the full string over here a b b therefore, you put a tick mark over here similarly taking the first taking first a it will go to q 1 and then taking an epsilon at q 1 it can go to q 2 and q 2 taking a b it can go to q 3, but q 3 no further transition define. So, therefore, if you follow this part a epsilon b we have process only a b not the full string a b b. So, therefore, you put a cross mark over here similarly if you follow this part a b then at q 1 again you can take an epsilon transition to go to state q 2 and on q 2 taking b you can go to state q 3. Now, you see that no further transition define on q 3 and the string that we have process starting from q 0 is q 0 to this q 3 on this part is a b epsilon b that means a b b. So, we have process the full string. So, therefore, you put a tick mark over here and then at q 0 initially you could have taken an epsilon transition and you could have gone to state q 4 at q 4 taking a it can remain the same state q 4 and taking input b you can go to state q 3 where no further transition is defined. So, therefore, the string that we have process starting from q 0 is epsilon a b it is not the full string a b b. So, we put a cross mark over here. Now, as the automation given in the example is non deterministic if a string is processed in a state then there may be multiple next states that we have already seen. For example, if we process the string a b b at q 0 the multiple next states are possible next states are q 2 q 3 q 2 and q 3 only. So, delta hat q 0 a b b is q 2 and q 3. Similarly, if we process the string say b b a just let us go to the n f a if you process the string b b b a b b a then there is no any transition defined from q 0 on input symbol b the only possible way to transit via this epsilon transition to q 4 on q 4 on the input small b we can go to q 3. So, we can process the first b and then we will go to state q 3 once we arrive at state q 3 there is no further transition defined on any input symbol. Hence, after processing the first b we cannot proceed further. So, therefore, for this case delta hat q 0 b b a is empty because we could not process the string thus given a string say x equal to a 1 a 2 up to a k and the state and the state say p of the automaton. Now, by treating x as epsilon a 1 epsilon a 2 epsilon a 3 so on epsilon a k epsilon that means inserting epsilon in between every two symbols and at the end and at the beginning and by looking at the possible complete branches starting at p we find the next states for p via x. Now, to introduce the notion of delta hat that means extended function in an n f a we first introduce the notion of epsilon closure. So, we need to define what is the extended function for an n f a to define this formally we need to first define what is epsilon closure. So, let us first define epsilon closure. So, an epsilon closure obvious that p is noted as e p epsilon closure p is defined as the set of all states that are reachable from p via 0 or more epsilon transitions. So, just follow 0 or more epsilon transitions whatever states are reachable from p that set of states is said to be epsilon closure of the state p. For example, in our example n f a that we have given here the epsilon closure of q 0 will be following this epsilon transition from q 0 can arrive at q 4 and without taking any input we may also remain in the same state q 0. Therefore, the epsilon closure of q 0 since without taking any input remain in the same state q 0 and then epsilon transition defined on q 0 to q 4. So, these are only two possible states that can reach from q 0 following 0 or more epsilon transition q 0 is following 0 epsilon transition q 4 is arrived at by following 1 epsilon transition. So, this is the set of possible states that can arrive at. So, therefore, this is the epsilon closure of q 0 similarly you can define epsilon closure of q 1 you can arrive at the state q 1 without taking any input that means 0 epsilon transition and then by taking one epsilon transition which is defined on q 1 it will go to it goes to q 2. So, this is the set of possible states following 0 or more epsilon transitions on state q 1 and hence is epsilon closure of q 1. Similarly, if you look carefully you will find that your q 2 is the single state q 2 because we there is no epsilon transition defined on it only taking 0 epsilon move will remain the same state q 2. Therefore, this is the only possible state that we have similarly e q 3 epsilon closure q 3 is the set containing q 3 only and epsilon closure of q 4 is a set containing q 4 only. So, according to the definition we have computed the epsilon closure of each and every state for the example n f a that we have already given. Now, if a give state is given say a is a set of states we can also compute the epsilon closure of this set by first computing epsilon closure of each and every state in a and then taking union that means epsilon closure of the state set of states of a is nothing but union of all epsilon closure sub states p where p is a state that belongs to a. So, that is how we define epsilon closure of a set of states a. Once we have defined this epsilon closure we are now ready to formally define the set of next states via a string that means delta hat p x or the extended transition function for an n f a. So, we define delta hat p x or extended transition function for n f a as this. So, is a map from q cross is x any string from sigma star sigma star it goes to power set of q it may be empty or any subset of q by giving two steps. So, first is that delta hat q epsilon without taking any input or taking zero or more epsilon moves water state is stable from this state is given by epsilon closure of q and then delta hat q x a. So, x a x is any string over sigma star then delta hat q x a is defined as. So, what you do is that you see what are the possible states delta p a where p is a state that you can arrive at by processing the string x starting at q that means delta hat first you compute delta hat q x. So, there will be a set of states first state suppose p next state is p dash and so on. Now, you see the next symbol is a. So, what state you can arrive at by processing a at p where p is a state that belongs to delta hat q x and you take the union then for all possible p that we have in delta hat q x for p p dash say p double dash we compute this that means for p belonging to delta hat q x for every p. So, once we find out the state that you can arrive at on symbol a for every p belonging to delta hat q x we take the epsilon closure of this because there may be again further epsilon transition possible from that state. So, after defining external transition function now we can define the acceptance of a string and the language of an NFA. We say that a string x belonging to sigma star is accepted by an NFA say n which is q sigma delta q 0 f if delta hat q 0 x starting at q 0 if we process the string x. So, we will get a set of states and in that set of states if we have a final state then we say that that string is x that means if delta hat q 0 x and f they have a common element that means if this interaction is non empty we say that a string is accepted. So, in the context of combustion tree of q 0 x there should be a final state among the nodes marked ticked. So, wherever we have marked a tick if there is a node which is a final state then we say that the string is accepted. The language accepted by the NFA n is defined as the language of n collection of all those strings x belonging to sigma star such that delta hat q 0 x and f has a common element at least. So, that is how we have defined the language accepted by an NFA.