0% found this document useful (0 votes)
29 views24 pages

Automata Thoery

Really worth while to work hard

Uploaded by

punita0369
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
29 views24 pages

Automata Thoery

Really worth while to work hard

Uploaded by

punita0369
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 24
ara THEORY 483 sTATE AUTOMATA (FSA) * Automata” is derived from the Greek word" au'to! to ucta” he aa sgelf-acting". An automaton (Autom in ace propelled computing, device which foll wats of operations automatically, ont * automaton with a finite number of states is called a finite state ata in plural) is an lows a predetermined ston. automata is a state machine that takes a strin, i changes its state accordingly. Finite ome fees ¢ size 10° regular expressions. When a regular expression is fed into oF goat, it changes its state for each literal (ie. for each symbol) Ft string is successfully Processed and the automata reaches its eo , then it will be accepted i.e. the string that was fed said to be wen of language in hand, otherwise it will be rejected. Hence, & finite automata is a computational device whose input is ‘ and output is one of the two values that we can call, accept and eo Finite Automaton. A finite automaton is a collection of ape (Q, Zs 9s Jo» F), where Q is finite set of states, E is finite set of jat symbols, 6 is next state transition function defined as j:qx-> Q do is the initial state from where any input is processed ye) and F is set of final state/states (F C Q). FINITE AUTOMATA MODEL Finite automata can be represented by input tape and finite control. ee input tape is a linear tape having some number of cells. Each input iol is placed in each cell. The finite control decides the next state on niving particular input from input tape. The tape reader reads the cells seby one from left to right, and at a time, only one input symbol is read. @[b[¢]a] b] b[b | Input tape Tape reader reading the input symbol Finite Control (Finite Automata Model) ~ 484 PRECIZE DISCRETE MATHEMATICS Bic y a 5, FINITE AUTOMATA CONSTRUCTION Let L(r) be a regular language recognized by some finite ona ‘Then finite automata has following features : (i States: States of finite automata are represented by Circle, = names are written inside circles. The state from where the automata (ii) Start State/Initial state: re arrow pointed towards it s known as the start state. Start state has an fates: All intermediate states have ASt tg (ii) Intermediate St erm id another pointing out from them. arrows; one pointing to an (iv) Final State: If the input string is successfully Processed, the automata is expected to be in this state. Final state is representeq double circles. A set of states which the machine may halt in, provi ded has no input left, in order to accept the string as part of the language ig called final state. (v) Transition: The Transition from one state to another stae happens when a desired symbol in the input is found. Upon transition, automata can either move to the next state or stay in the same state, Movement from one state to another is shown as a directed arrow, where the arrows points to the destination state. If automata stays in the same state, an arrow pointing from a state to itself is drawn. In the diagram, we can see that on given 0 as input to finite automata in state go, the finite automata changes state to g, and always go to final state q, on starting input 0. It can accept 01, 00, 000, 001, ... etc, It cannot accept any string which starts with 1 because it never goto final state on a string starting with 1. 'YPES OF FINITE AUTOMATA There are two types of finite automata : 1. Deterministic Finite Automata (DFA) 2. Non-Deterministic Finite Automata (NFA) ata THEORY 485 I oe rministic Finite Automata (DFA) ih eee 5 jn Deterministic Finite Automata (DFA), deterministic refers to the ss of the computation, In the DFA. i ett . there is only one path f i ge input from the Current state to the next state. DFA does oat p ot the null move ie. DFA cannot change state without any input oso f oition- Deterministic Finite Automata, A deterministic finite onal (DFA) is a collection of S- tuple M =(Q, 5, 40. F), where Q _ g non-empty finite set of states, © is a finite set of input symbols or patel © 18 8 state transition function i.e, 5: Q x E> Q, go is the iil state OF start state from where any input is processed (go € Q) and set of final state/states of Q (F . Now, M is in state q, and input symbol is a2. If i{g1+42) = 9a» then M changes its state from q; to gp and so on. After processing all the input symbols of string, M is at some state, say q, . The sting is said to be accepted if g, ¢ F and rejected if g, ¢ F 12. Acceptance of Strings A DFA accepts a string w = 4,2) d3..d, if there is a sequence of Sat6S 99, GivesGn in. Q such that @ qo is the initial state. (i) 8 qu ajat) = Gat forall OSi41-' follows : 42}.{0-1}.5.90-492}). where 6 is defined iS 8( qos 0) = 91+8(4o» 1) = 40» 5641+ 0) = 92+ ie Bans 1V= 92-842» 0)= 40596920 Y= ts V then M is a DFA 0s M is a collection of S-tuple (Q, 2, 8, go, } is finite non-empty set of states, £ = {0, 1} is where Q= {9019192 re of input symbols, 6 is the transition function, qo is the initial state F= {gp}, the set of final state. Now, we check whether the input string, say 101, is accepted DFA (M). The first input symbol of the string is 1 and initially M is i state gp. Now, the transition 6(q9, 1) = Yo» therefore after processing M is again in state go. The next input symbol is 0. Currently, M is i state go, it reads the next input symbol 0 ana 6( 40. 0) = 9). Therefe after processing the second input symbol 0, M is in state q,. The nt input symbol is 1. Currently, M is in state q), it reads the next in symbol 1 and 8(q), 1) = gz. Therefore, after processing the thi input symbol 1, M is in state q2. Thus after processing the input stri 101, M js in state gp which is a final state. Hence input string 101 i accepted by DFA. Ina similar manner, now suppose that the input string is 01101. ‘The first input symbol of the string is O and initially M is in state q Now, (go, 0) = 91, therefore after processing 0, M changes its from qq to g. The next input symbol is 1. Currently, M is in state 41, reads the next input symbol 1 and 6(q). 1) = gj. Therefore processing the second input symbol 1, M changes its state from q) t0 4 The next input symbol is 1. Currently, M is in state q», it reads the input symbol 1 and 6(q2, 1) = gy. Therefore after processing the this input symbol 1, M changes its state from gj to qj. The next inp symbol is 0. Currently, M is in state gj, it reads the next input symbol rowaTA THEORY ra pala 0)= 42- oe after processing the fourth input symbol 0, wi changes its state from 4) to go. Finally, the last input symbol is 0 wyrently, M is in state da, it reads the last input symbol 1 and jee After processing the last input symbol 1, M again changes isso from ga'0 41 ‘Thus after processing the input string 01101, M is in state q rota final state. Hence this input string is not accepted by DFA. DFA receive: i it mark. When Feceives an input string, iA starts from the initial state, : (13. Transition Table which to process the string it Transition table is basically a tabular Tepresentation of the transition function that takes two arguments (a state and a symbol) and returns a value (the “next state"), where 7 Rows corresponds to states. ¢ Columns corresponds to input symbols. © Entries corresponds to next states, © The initial state is marked with an arrow. © The accept/final states are marked with a star (*) For example, for the above DFA (M), the transition table is given by input symbol | 0 1 State > 4% n qo n 9 2 *H 0 4% L 6.4, State Diagram or Transition Diagram A state transition diagram or simply a transition diagram is a directed graph which can be constructed as follows : 1. Each state of M ie .each element of Q is represented by small cirele and the circle is labelled with the state. __ PRECIZE DISCRETE MATHEMATICS B.c.a_ Py s identified by an incoming unlabelleq aroy 488 2. The initial state go i not originating from any vertex. 3. Accepting/final states are indi 4, There is a directed edge from state q)to state q, labelled g it 6(q;, a) = gj. If there are several input symbols that cause a transition, the edge is labelled by the list of these symbols. The state diagram of above DFA (M) is as follows : ‘ 1 icated by double circles, 6.1.5. Language Recognition One of the most important applications of finite state automata is in language recognition. This application plays a fundamental role in the design and construction of compliers for programming languages, Each automata (M) with input alphabet © defines a language over 5, denoted by L(M), as follows : Let w = ja)..d_ be a word on &. Then w determines the path P= (40,41,41542+92+-4m»Jm) in the state diagram of an automaton M, where qo is the initial state and 8(4,.1,a;) = 9; fori2 1. ‘We can say that M recognizes the word w if the final state of M after processing string w is an accepting state in F. The language L(M) of automaton (M) is the collection of all those words from 2 which are accepted by M. 6.2, Non- Deterministic Finite Automata (NFA) In non-deterministic finite automata (NFA), there exist many paths for the ‘specific input from the current state to the next state. NFA is similar to DFA except the following additional features : () Null move is allowed i.e., it can move forward without reading symbols, (i Ability to transmit to any number of states for a particular input. Ura THEORY ‘ figures we can see that i ‘se 90 and for input a, a next states g, and ary, ftom state go and », there are tWo next ig o 4 gi» Thus, it is not ® determined that with a se input where to go next. That's why i in deterministic finite automaton, aa Non-Deterministic Finite Automata (NFA). An NFA (non- iitic finite automata) can be represented by a5 tuple (Q£, 8, where Qis a finite non-empty set of States, Z is a finite set of bol, 8 isthe state transition function 8 :Q x E> PQ) = 22, , PQ) is the set of all subsets of Q or Power set of Q, gq is the sate from where any input is processed (qo € Q) and Fc Qisa set il satelstates of Q. 1 Graphical Representation of NFA an NFA is represented by directed graphs called state diagram in sail this finite automaton is | Each element of Q is represented by small circle and the circle is with the state. ° 2, The initial state go is identified by an incoming arrow not jaating from any vertex. f 4. Accepting/final states are indicated by double circles. 4, The arc labelled with an input character show the transitions. Letus illustrate this with the help of following example : Consider an NFA consisting of five tuple M = ({9,91,92}; {0, 1), hy {90}), where 5(G0,0) = go, H» 5a!) = 1 8(q1,0) = go, 8) = do» (42,0) = 9, 5251) = ds 92» . Q= Finite set of states = {99,91»92}» 490 PRECIZE DISCRETE MATHEMATICS B.C.A.p ¥= (0, 1), set of input symbols, go = initial state from where input is processed, and gy Q F = {gp}, set of final state. The transition table of an NFA is given by input symbol 0 it State + > 4% + 4% cn Nn 2 % * 2 Ns ‘The state transition diagram is shown as follows : Definition. Dead State. All those non-final states which transits to itsel for all input symbols in © are called as dead states. Dead state is al called trap state. In other words, if a transition leads to a state from which it can neve escape, such a state is called a trap state or the dead state. There is no wa to reach the final or the accepting state from this state. 6.2.2. Strings Processed by NFA Now let us see how non-deterministic finite automata performs i computation. Suppose that we are running a non-deterministic finite automata. giving a particular input on some state, we get multiple ways to proceed. For example, suppose we are on state gq in non-deterministic fini automata and the input symbol is a . On reading the input symbol, we get) multiple ways to proceed to the next state. The machine splits into multiple copies of itself and follow all the possibilities in parallel. Each copy of the machine takes one of the possible ways to proceed and continue in that direction. If at any stage, further choices arises the yata THEORY oN spl again. The copy of the Machine ends if the input symbol sine appear on any of the AMTOWS existing the state Occupied by that ni the machine along with the brane! of computation associated ii finally, if any one of these Copies reach the Accept state at the end te ut, then the NFA accept the Input string. To illustrate this, let us ii ne equence of computation for string ababba on following NFA : 491 Symbol Read ae 4 492 PRECIZE DISCRETE MATHEMATICS B.C.A. (PU 6.3. Difference Between DFA and NFA Following is the list of differences between DFA and NFA : transition can be determined in DFA. as the transition from one state to other cannot be determined in NFA. S.No. DFA NFA | 1 DFA stands for NFA stands for y deterministic Finite | deterministic finite 4 ‘Automata. In DFA, | automata. In NFA, | the transition from a | the transition from } state is to a single a state can be to particular next state | multiple next states for each input foreachinput |. ‘ symbol. Hence, it is] symbol. Hence, it is. called deterministic called non- deterministic 2 | There isno empty Empty string string transitions in | transitions are also DFA permitted. 3 | DFA requires more | NFA requires less | space space than DFA. ey 4 Time needed for | Time needed for z executing an input | executing an input a string is less. string is more. a 5 A string is accepted | A string is accepted “ by a DFA, ifit by aNFA, if at iy transits to a final least one of all aa state. possible transitions a ends in a final state. § 6 All DFA are NFA. | Not all NFA are ? DFA. 7 | DFA is more difficult | NFA is easier to j to construct. construct. _| 8 There is no There is much randomness as the more randomness — l ORY ont ae 493 pl 1, Construct a DFA over {0, 1} which accepts string 01 or 10, Here, the input alphabet £ = {0, 1}. be we need to construct a DFA over {0, 1} which accepts string 01 or nly. There are five states required to construct this DFA. We can sociate meaning to each state as : + go + Initial state from where any input is processed. This state represent "no symbol accepting state”. + q :State which accept first symbol of string 01 ie. 0. * gy :State which accept first symbol of string 10 ie. 1. + qy : State'which accept either string 01 or 10. Thus q3 is the final state. * qq : Dead state/Reject state. The transition table can be written as follows: Accepting Input symbol | 0 1 State No symbol > a n nD 0 n % % i n % % 01 or 10 *Q3 % % Dead state % » 4 q% DFA can be shown by a transition diagram as : ay PRECIZE DISCRETE MATHEMATICS B.C.A,. (| 0,1, Q © Example 2. Construct a DFA which accepts set of all strings over {a, of length 2. Sol. Here, the input alphabet 2 = {a, b}. We need to construct a DFA over {a, 6}. which accepts strit having length 2 only. The strings that will be generated from particular language are aa, ab, ba, bb. There are fous states required to construct this DFA. We associate meaning to each state as : * qo : Initial state from where any input is processed. This accepting no symbol (string having length 0). © q : State which accept strings having length 1. * 2 + State which accept strings having length 2. Thus q> i final state. © — Gy : Reject state/Dead state . The transition table can be written as follows : “Accepting ut symbol | a b strings of length: State 2 > 4% a u 1 n QR Q 2 *a % % Dead state % a A e 5 r . RY TA THEO 495 fA can be shown by a transition diagram as : (2 (a) a,b la, b (44) (Dead state) O a,b gale 3. Construct a DFA which accepts set of all strings over {a, 5} vagh2 3. iHere, the input alphabet E = {a, 5}. We need to construct a DFA over {a, 6} which accepts strings ving length 2 3, The strings that will be generated from this particular ‘guage are aaa, aab, aba, baa, bba, bab, abb, bbb, aaaa.... There are four states required to construct this DFA. We can sciate meaning to each state as : 4p : Initial state which accepts no symbol. i.e. string of length 0. 4 : State which accept strings of length 1. 4% : State which accept strings of length 2. 43 : State which accept strings of length > 3. Thus q3 is a final state, The transition table can be written as follows : Accepting ut symbol | a b Stings of length: State 0 > 4 n n 1 a n n 2 2 % a 23 *gs % % PRECIZE DISCRETE MATHEMATICS B.C.A, 496 DFA can be shown by a transition diagram as : Example 4, Construct a DFA which accepts set of all strings over ( of length at most 2 (S 2). Sol. Here, the input alphabet E = {a, b}. We need to construct a DFA over {a, 6} which accepts having length at most 2. The strings that will be generated from: particular language are ¢, a, b, aa, ab, ba, and bb. There are four states required to construct this DFA. We: associate meaning to each state as : © qo : Initial state which accepts strings having length 0 i.e. consisting of no symbol. Since DFA accepts a string of len therefore it must be a final state. © gj : State which accept strings of length 1. Since DFA acc string of length 1 also, therefore it also a final state. © ga : State which accept strings having length 2. It is a final as DFA accepts string of length 2 also. © gg : Reject state/Dead state, The transition table can be written as follows : Accepting ut symbol | a. b strings of length: sua >*40 % a ! “4 2 2 2 *Q % % % r roMaTa THEORY 497 pFA can be shown by a transition diagram as: a,b ssample 5. Construct a DFA which accepts set of all strings over {a, b} tutends with a string abb. Sol Here, the input alphabet E = {a, 5}. We need to construct a DFA which accepts all strings that ends with asting abb. The strings that will be generated from this particular lnguage are, abb, bab, aabb, aaabb, ababb, .... There are four states required to construct this DFA. We can associate meaning to each state as : * qo : Initial state which accepts no symbol. * gy : State which accept strings ending with a. * gp: State which accept strings ending with ab, * qs : State which accept strings ending with abb. Thus q3 is the final state. The transition table can be written as follows : Accepting wut symbol | a 6 State No symbol (¢) > 4% a | % String ends with a en na | % String ends with ab 2 n % — String ends with abb *95 a | % 498 PRECIZE DISCRETE MATHEMATICS B.C.A_ (Pu)! The above transition table is explained as follows : When input a is given to state qo i.e. when € is concatenated with input a, then we have, ¢.a = a. Then we get a string that is ending with symbol a, which corresponds to state qj. 8(qo.4)= 1. Again, when input b is given to state qo i.e. when ¢ is concatenated with input b, then we have, ¢.b = 6. Then we get a string that is only ending with symbol b. Since we have no state which accepts the string ending with only, therefore by giving input b to state qo, it will not move to any other state. 8 (40,5)= g0- Now on giving input a to state q,, we get a string that ends with aa. But we have no state which accepts string that ends with aa. Therefore we have to cross out one symbol at a time from left hand side. Then we get a string that only ends with a which corresponds to state q, 6(H,a)= 4. Again by giving input b to state q,, we get a string that ends with ab with corresponds to state ¢ 8(q,4)= 92- Similarly on giving input a to state ¢>, we get a string that ends with aba. Since we have no state which accepts strings that ends with aba, therefore we have to cross out one symbol at a time from left hand side. Then we get a string that ends with ba. But we don't have a state which accepts strings that ends with ba. Therefore again we cross out one symbol and we get a string that ends with a only, which corresponds to state q. (42,4) = 1 Again on giving input b to state go, we get a string that ends with abb which corresponds to state q3. 4 | TA THEORY roma 499 92, 6)= 93. Now on giving input a to state 93, We get a string that ends with . Since we have no state which accepts string that ends with abba, efore We cross Out one symbol at a time from left hand side, Then we astring that ends with bba. But we do not hat n ve a state which accey ong that ends with bba. ‘Therefore again cross out one symbol and ve astring that ends with ba, But we do not have state which accepts gring that ends with ba. Similarly, crossing out one more symbol, we get sting that ends with a only which corresponds to state nN: 8(93,4)= 9. Ina similar way, we can see that 5(93,)= go. Hence, DFA can be shown by a transition diagram as : Example 6. Construct a DFA which accepts set of all strings over {a, by that starts with a string abb. Sol. Here, the input alphabet 5 = {a, b}. We need to construct a DFA over {a, b} which accepts all strings ‘tat starts with abb. The strings that will be generated from this particular ‘anguage are abb, abba, abbb, abbaa, abbab, There are five states required to construct this DFA. We can ‘Ssociate meaning to each state as : * — qo : Initial state which accepts no symbol. * — q : State which accept strings that starts with a. © gy : State which accepts strings that starts with ab. 500 PRECIZE DISCRETE MATHEMATICS B.C.A. (PU) © gy :State which accepts strings that starts with abb. Thus, 9 is a final state, © gy : Reject state/Trap state. The transition table can be written as: ‘Accepting, Input symbol a b State No symbol (e) > 4 a | % String starting with a a ~ | a String starting with ab n a | a String starting with abb +9 % % Dead State % % % ‘The above transition table is explained as follows : When input a is given to state qo i.e. when € is concatenated with input a, then we have, € a = a, Then we get a string that starts with symbol a, which corresponds to state 4, 8(40,4)= 41. Again when input is given to state qq i.e. when & (corresponding to state gq) is concatenated with input b, then we have, ¢ b= b. Then we get a string that starts with symbol b. Therefore we get a string which is not starting with a, ab or abb. Hence it corresponds to dead state q%: (G0, 5)= a9. ‘Now on giving input a to state qj , we get a string that starts with aa which corresponds to dead state. 84,4) = a. RY Fons THEO! = Again by giving input b to state M1» We get a string that starts with ich corresponds to state q». 8(q1,5)= 92- similarly on giving input a to state g., we get a string that starts ihaba which corresponds to dead state gy . 8(92,4)= q- Again on giving input b to state q>, we get a string that starts with gb which corresponds to state 3 . (92 6)= 43. Now on giving input a to state q3, we get a string that starts with ahaa. Although we do not have a state which accepts strings that starts with abaa, But if we consider this string, it is starting with abb which corresponds to state q3. Note that only for final state, we need to consider final state itself (self loop). Ina similar way, 8 (q3, b)= 93. DFA can be shown by a transition diagram as : pw a,b Remark, For the problems of DFA that starts with a particular string, we have to remember the following points : 1. If there is a state corresponding to the given problem, then directly write that state. 2. If there is no state corresponding to the given problem, then go to % (dead state). 3. Only for final state, we have to write the self loop. 502 PRECIZE DISCRETE MATHEMATICS B.C.A, (Pp Example 7. Construct a DFA which accepts set of all strings over {a, that contains substring abb. Sol. Here, the input alphabet E = {a, 6}. We need to construct a DFA over {a, 5} which accepts all strin, that contains substring abb. The strings that will be generated from this particular language are abb, aabb, babb, abba, abbb etc. There are four states required to construct this DFA. We associate meaning to each state as : © qo : Initial state which accepts no symbol. © qj ; State which accepts strings that contains substring a, © gz : State which accepts strings that contains substring ab, © qs : State which accepts strings that contains substring ‘ab’ Thus q; is the final state. The transition tablé can be written as: Accepting Input symbol | @ 6 State No symbol (£) > 4 1 4 Substring a un n % Substring ab ” % % Substring abb *a % 3 The above transition table is explained as follows : When input a is given to state gq i.e. when € (corresponding to state 0) is concatenated with input a, then we have, ¢ a = a. Then we get & string that contains substring a, which corresponds to state 9, - g0,a)= 4. Again when input d is given to state qo i-e. when € is concatenated with input 5, then we have, e b = b. Then we get a string that contains Substring 5. But we have no state which accepts strings that contains r TA THEORY rome 503 b. So, when input 5 is given to’state 40» DFA does not change ist sates 8(q0, 5)= 4o- Now on giving input a to state gj, we get a string that contains gpsting a4. Since we have no state which accepts string that contains isting 42, therefore we have to cross out one symbol at a time from gs. Then we get a string that contains substring a which corresponds to gate 1 - | qa) = H- Again by giving input 5 to state q,, we get a string that contains abstring ab which corresponds to state q2. (41,5) = 92. . Similarly on giving input a to state g>, we get a string that contains sbstring aba. Since we have no state that contains substring aba, therefore we have to cross out one symbol at a time from LHS. Then we {eta string that contains substring ba. But we have no state that contains substring ba. Again by crossing out one more symbol, we get a string that contains substring a, which corresponds to state qy - 8(42,4)= H- Similarly by giving input 6 to state gp, we get a string that contains substring abb, which corresponds to state 43 8(42,8)= 9. Again when input a is given to state 43, ‘ubstting abba. Although we do not have a state which accepts string that Contains substring abba, but if we consider this string, it is contains Substring abb, which corresponds to state 43 - we get a string that contains 8(43,.4)= 43- 504 PRECIZE DISCRETE MATHEMATICS B.C.A, (py) Note that only for the final state q3, we have to consider final state itself ie. self loop. 8(43,5)= 3. Hence, a DFA can be shown by a transition diagram as : Remark. For the problems of DFA that accepts strings containing substring, we have to remember the following points : 1. There is no need of dead state. 2. If there is a state corresponding to given problem, then write that state directly. 3. If there is no state corresponding to given problem, then go to initial state qo. 4. Only for final state, we have to write the self’ loop. Example 8. Construct a DFA which accepts all strings over {a, b} whose length is divisible by 3. Sol. Here, the input alphabet E = (a, 5}. We need to construct a DFA over {a, 5} which accepts all strings whose length is divisible by 3. The strings that will be generated from this particular language are ¢, aaa, aab, bab, aaaaab etc. There are three states required to construct this DFA. We caf associate meaning to each state as : Jo : Initial state accepting those’ strings that gives remainder 0 when length of string is divided by 3. Thus go isa final state. q + State accepting those strings that gives remainder | when length of string is divided by 3. TA THEORY 508 own ; State accepting those strings that gives remainder 2 when * jength of string is divided by 3. ‘he ransition table can be written as : Accepting Input symbol a b grings that gives following, remainder when length is divided by3 State’ >*4 n u un 2 2 n q % Hence, a DFA can be shown by a transition diagram es : a,b tmmple 9. Construct a DFA which accepts all strings over {a, 5} in ich number of a’s and b's is even. Here, the input alphabet E = {a, b}. ‘We are to construct a DFA over {a, b} which accepts all strings in ich number of a’s and b’s is even. The strings that will be generated inthis particular language are aabb, aaaabbbb, aaaab, aabbbb, ... There are four states required to construct this DFA. We can Fociate meaning to each state as > * qo : Initial state accepting those strings in which ‘number of a’s and b's is even. * q\ : State accepting those strings in which number of a’s is even and number of b’s is odd. * qy : State accepting those strings in which number of a’s is odd and number of 8's is even. 506 PRECIZE DISCRETE MATHEMATICS B.C.A_ © qq : State accepting those strings in which number of a's is odd. Here qo is the final state as we have to accept those strings in number of a’s and b’s is even. The transition table can be written as: Accepting strings in a which number of ? a’s and b's is even "4 ced ou a’s is even and b's is u % | 4% odd } a’s is odd and b's is n % | 4%. even i a's and b's is odd % a | 2 Hence, a DFA can be shown by a diagram as : sine mae eS Remark. (i) If we are to construct a DFA which accepts all strings o¥ {a, 6} in which number of a’s is even and number of b's is odd, tht instead of go, g, must be a final state. |

You might also like