0% found this document useful (0 votes)
38 views34 pages

Unit 2

Unit 2nd notes of kuk University class notes

Uploaded by

khushalhanduja
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)
38 views34 pages

Unit 2

Unit 2nd notes of kuk University class notes

Uploaded by

khushalhanduja
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/ 34
UNIT} INTRODUCTION TO MACHINES AN PROPERTIES OF REGULAR SE Learning Objectives 2.1. Introduction of Machines 2.7. Pumping Lemma for Regular Sets & Apotcae 2.2 Finite State Machine of Pumping Lemma 2.3 Properties and limitations of Finite State Machine 2.8 Construction of Regular Expression from OF 2.4 Moore and Mealy Machines using Arden’s Theorem 2.5 Equivalence of Moore and Mealy Machines 2.9 Closure Properties-of Regular Sets 2.6 Minimization of DFA 2.2 State Partition Methods —} 2.1 INTRODUCTION OF MACHINES One limitation of the finite automation is that output is limited to a binary signal accepts ( not accepted (0). The only explicit task a machine has done so for is to recognize a languages. Fini, automata are like computers in that they receive input and process the input by changing state only output that we have seen finite automate produce so far is a yes/no at the - end P processing and which is also one of the limitation of finite automata. These problems can be solve by attaching output either with state or with transition in a finite automata. If we assume that all the printing of output is to be done at the end of the Programs run, a which time we have an instruction that dumps a buffer that has been assembled there we have maximum on the number of characters that dumps a buffer that has been assembled, then W have a maximum on the number of characters, then we have a maximum on the number ¢j characters that the program can print, namely, the size of the buffer. However, theoretically | should be able to have outputs of any finite length. For example, we might simply want to prin out a copy of the input string, which could itself be arbitrarily long. These questions that have be faced if we are to claim that our mathematical models of FAs and Transition graphs represen] actual physical machines. 2.2 FINITE STATE MACHINE It involves the concept of internal state | Finite state machine = Basic machine + Internal state | Basic machine can be defined as the most primitive machine which recognize and input. Lé Jand generates an output set 0 where 1 and 0 are finite. i Example : AN OR gate is a basic machine. Therefore, finite state machines has : 1. A set of states, 2, Input alphabet set, 3. For some form of finite state machine are output alphabet set. ; gunctions whi 1 ine function (MAF) :IxS—>0 A es S>s ye state machine are classified in tw. + rest state machine with output. Sap 3 pine state machine without output. Cite machine with output contains two well known machi S machine MOORE and MEALY oPERTIES AND LIMITATIONS OF FINITE STATE MACHINE ! : jzcuse ee Limitations of FSM, re writethe properties and limitations of finite abit a9 state machine (FSM). (KU, . Dec. 2005) Q ait efine term finite state machine iimitati 3? CTE and what are limitations of FSM? (KU, Dec. 2007) we Finite state machine : See section 2.2. ad timiations oF FSM: i lkiplication of two very Jong no is not possible. Recognition of palindrome is not possible. Recognition of well formed ness if parenthesis (WEP) is not possible. tis due to fact that FSM has no memory to remember the previous information. Well formed parenthesis is(Q)) O of left and right parenthesis. equal no. 4, One side snovement of head : The finite state control moves the lead in one direction on i/p string that is from left to right. 5, Impossibility of. ‘Remembering : FSM can't keep check on the no. and times some variable appear ‘ ae example, L={O""/20) We can’t construct a FSM. Properties of Finite State Machine: 1, Periodicity: A FSM have Jimited no. of states. So, for most of | thei/p sequence @ state or ano. af states are repeated. (Q eqn. wr 7 Input 0 0 1 ipuagdeiad State sequence Gia wiih fi acre 89 Tis y gan ate Pe frimes: ASM generateano.ofequivalens® classes tip Sanne ei nate omar erage then both i and Jae present" se equivalence class if : 5(qyn) 5 God) aaa raster mind Solved Quostion PAPErS (Automay 8(A,01) = 8(8(A,0),1) : =6(4,1) B 8(4,1)=B So, string 01 and 1 are is same equivalence class. 2.4 MOORE AND MEALY MACHINES Moore machines : It is a finite automata in which iia more machine every state of this finite machine has a fix output. There is no accept state is a moore machine because its purpose is not te Codie one, not or accept or reject any string. It is not a language recognize, it is an outp! i Each state ofa Moore machine producea one-character output: immediately upon the ‘Machine, entry into that state. At the beginning in stating state produces an output before any input has been read. In case of Moore machine for any input sequence of symbols the output sequence will be n+ 1symbols. Formal definition of Moore machine M: M=[QE,4,8 ido 1. Q=Itis the nonempty and finite set of states in M. | 2, E=Itis the finite and non empty set of symbols. 3. A=Itis the non empty and finite set of outputs. 4, qy= It is the initial and starting state of M. 5. 6. ut is associated with each state % . 5=Itis the transition function which is responsible for transition in MO and same as in FA, . 1.= Its the transition function which is maps Q to A and going the output associated each state. Representation of Moore machine : The moore machine is also represented by transition table or transition diagram. 1. Transition Table : The transition table for moore machine are : Present state Next State 0 1 4% % 0 n n % 1 ry ho 4 0 0 93 93, 40 Here an output column is inserted to associate on output with the each state: * ‘The output is associated with the help of mapping function (21), M (qq)= 0,04 q,)=1, 24 (G3) =0, 2 (gq) =0 2. Transition diagram :In moore machine there is no final state and output for every statels written just above the corresponding state. Shown in figure below : 2 ing 9 me sition a put will be - 00010 [5 symbols] [Length of output is more than length of input string ‘Ain which output is associated with each transition. Inmelay: machines lar input symbol has a fix output. Machine: [tis F. Men for a particu! on 19 machines and Properties of Regular Sts 000 ond B—og—og god ¢ string in moore machine : Suy , diagram we will process thes a have a string 0111 [4 symbols] by an ; amealy macine isasix tuple [Q 2,4, 8,440) athe symbol except 2 have the same meaning as in moore machine. itis output function mapping ZXQ into 4. 4! maps QXE > A that is 21 [q, a] gives the output associated with the transition from So, ps speqoninput 3 resentation of Mealy Machine: Mealy machine also represented b; the transition table Repres y sof transition diagram. Transition Tabl ‘on table for mealy machine are + ere a Present Q rate State OP State OrP > %0 n 0 n 9 u % 7 4s 9 n n A 4 13 43 1 7 0 The output is associated with all transition MW fgg 1-9 (gy =0 2 {qy 0 2 (qy W=1 ay Transition diagram : In mealy machine there is no final state and output is there for input ut for every input symbol is represented as level on ea Bencorresponding transition outp! nin the join input symbol / corresP' onding output. ved Question Papors (Automata master Mind S ot 4/0 Cy («) 170 D ! Processing of the string by Mealy machine : Suppose W”° have a string 0111. Vy gq tp Og output = 1001. ‘ In mealy machine the length of input string is equal to length of output string. Q.5. Define the finite state machine. Describe moore and mealy machines in detail. (KU, Dec. 2005) ‘Ans. Finite State machine : Sec section 2.2. Moore and Mealy machine : Sec section 2.4, Q.6. Describe moore and mealy machine with the help ofan example. (KU, Dec. 2009) Ans. Sec section 2.4. 2.4.1 Difference between Moore and Mealy Machines Q.7. Differentiate between moore and mealy machine with the help of are example. (KU, Dec. 2005) Q.8. Differentiate between moore and mealy machine. (KU, Dec. 2007) (KU, Dec. 2007) Q.9. Compare moore and mealy machine with example. ‘Ans. 1. In Moore machine output is associated with states output associated with transitions. 2, Moore machine generates output for &- output for string or A-input. 3. Output Mapping function for Moore is N04 2.= Mapping for = States set A= output alphabet set Output Mapping function for Mealy is IA: 0x5 — Al 2= input alphabet set 4, Output of Moore machine is one character longer than its i/p eqn. Ifn= length of i/p string the n + 1=length of o/p is always, But in case of Mealy machine output string is of same length as input string’s lengt! but in case of Mealy machine string also but Mealy machine do not produce Meanly can be represented as ; (ay? A yIVALENCE OF MOORE AND MEALY MACHINES } we talk about equivalence of two mox 7 ore machi ‘ weit same input, that produce the same re two.menly- machines ve mest} i associated with its start before it begins processing its a a machine outputs the iis input. The output of a mealy machine is alwa ae output is always one bat noore machine cannot be equivalent to a mealy re ne eee eee eee ec Tnachine is equivalent to a mealy machine if, given the ie a seneeiie BY Femi after removing, the first character is the same as the output at the Se ae {sing this definition of equivalence, our text proves that for every moore machine there is a | pit mealy machine and vice versa, It does this with wo constictive algorithms one for . amoore machine to a mealy machine and one for going the other direction. 0. Explain mealy and moore machine, Explain the procedure to convert from mealy to ioote and moore to mealy. (KU, Dec. 2007) ‘Ans, Mealy and moore machine : Sec section 2.4. Conversion from mealy to moore and conversion from moore to mealy— Conversion from Mealy to Moore : We will see this with the help of an example. Suppose, we have following Mooly machine: for any state say q,and determine the no. of different column. t state the no. of states being equal to theno. of diff. ~ Welook into the next state column outputs associated with 9; in the ci ~ We splite the q; into several differen! output associated with qj, For example, here q; is as: Cutput 0 and 1, So, we split qo into 4 sociated with one Op 1 and q, is associated with two diff. 9 with O/p and qp, with output 1. 4a1 column can be rearranged as Now, the pair of state and O/p in the next state 0 1 OlP n 4% 4920 és 420 n 440 o ax n 940 a 43 am n 9 440 1 4% 0 4a G1 43 1 pete How in the table of M yp and gy. Here one More thing is machine, O/P 0 is associate Moore machine. Whose state transi core M/C, O/P 0 is associated with Yao 2 that the initial state q, associates with I/Po. We get O/P 1. So, this Moore m/s accepts null string also but .d with each transition from 4; tions are identical to 4; SEE nd 1 with qy;. Similar is theasd d with output 1. Which mean, ‘his is not the case of Mealy yo: $9, we can add a new state qyit but O/P is 0. Conversion Moore to Mealy m: Consider a Moore machine “% 420 20 440 440 449 3 %3 achine : rRooHKoHS = yetion to Machines and ——_— en En re ; ta chine, we will c B ealy onstruct a pai a » FOF cgmples state q, and q, associated wi ir of state “ ated With Ofp 1 and Omen Pomel Tespectively. 5 ji. Draw the moore machine for mod-3 of bi a Jn binary we have two symbol (0, 1) of binary string treated as binary integer. 50, 2° 0) Decimal No. Mod3 Fat | Wehave three types of output after Mod3i..,0, 1, 2 $0, A={0,1,2} ce machine for 10000 = 16/321 Six tuples are : 1, QF qv 42) 2, $=(0,1) i 3, A={0, 1,2) 4 MG) 0,a =" (=? 5, = % 6, Transition function. Now, verify the moo: aster Mind Solved Question Paper® (Automata ff 62 Q.12. Design a moore machine which ¢ over the alphabet (0, 1) ubstring a ab i cu, in inpy, courts the occurrence of 8 Dec, 2013) string. Ans, Suppose, we design the string A= (0,1) 0=If we do not get ab | 1=If we got aab Q.14. Design a mealy machine for binary to octal number: Ans. [_BinaryNo. al 000 001 010 011 100 101 110 111 00/0 117 011/38 locum, coins a ote to Machines and Properties of Regular Sets ie amealy machine, which can output oe js even or odd. The input symbols are on according to the total number an een (KU, Dec. 2012) t= 1 ifthe parity of input sequence is odd ie, No, of ss ut =0if the vat of the input pr is even ie, no, 4 ti even evey,) on Construct a FSM that delays an input string bits, giving 0 asthe ist two bitsof fos Now, we have one bit (ee machine, ~ (KU, Dee, 2007) agp-consider ip string is01101001 ot 1 ta oe 90. dp dc ade ngs oth Meee (Q.17, Convert the following mealy ue into moore pen : (KU, Dec, 2007) 6 % b | | PS. NS, O/P NS. olP 0 a 1 0 40 i 7 F F z 4. 0 0 1 92 2 é it . of Now, we look into the next states aint for any state say q; and determine the no. of ren ou mut ted with q; in that column: lage i alte, en wiferent states the no, of states being equal to the no. of ing, ith | “Uilto the no. of different output associated on Mi Wea 'sa eo Hete, qi associated with two different Table can be represented as Master Mind Solved Question Papers Ps, few’ a or NS. ow Foo 0 nh 1 0 n 1 1 h 0 0 qo 1 Now, pair of state and O/p in the next state column can be rearranged as : PS. [Rote b OP 400 00 n a 41 900 n 1 % u n 1 fa b G01 Q Now, initial state (as the property of Mo So, we can add an 4q9 associated with and put 0. Means it pro ore machine). Mahing) (Moore Machine) duces output 0 for a-string alsy ‘ew state q’ in moore machine whose state transition are identical to ‘o but O/p is 1 E NS. | I PS. a b O/P q 400 n 1 400 900 n 0 9 400 n 1 n " 2 i a loore Pea » On bee Q.18. Design a FSM for up-down counter, (KU, Dec, 2007) Ans. Finite machine for UP = down counter is as follow. Here, we have total 8 states (3-bits) ele cist Machines and Properties of Regular Sete imple conc follow eet ept. From any state (assume) by’ (” it works as Down-counter as shown in rl ae yn bY e mealy machine and moo: re i ¢ fy ? oe “ent: machine. Convert the following mealy machine aly machine and moore machine : See Section 2.4. pss. Me fj conversion of Mealy machine into moore equivalent: State ia Op z Op 40 n 0 % 0 n % 1 » OR b h 0 h 1 93, 493 1 n 1 —t =i took into the next state column. Here, we have two diff ofp for state that is 0 & 1. $0, according to procedure split state q, into two diff, state qi and qy;- Now, the transition table is Asweknow Moore machine generate output for string also in comparsion to mealy machine. state) q having output 0 and same transitions for ‘a’ on here we also one new state (initial 8 for gy. = 66 astor Mind solved Question Papers Lecce Transition table for Moore machine (i) Q.20. Consider the moore machine desc corresponding mealy machine. Present State | 7H h 43 ‘Ans. 1, First construct the table for mealy machine Bleed 0 a State Next State Olp | Next State Olp th n 9 % 0 » nh 0 % 1 % h 0 % 1 2. Inabove tables rows corresponding to q, & 43 are identical. So, we can delete one of the two states i.e, JOT 4. Now, delete q, row and replace 9, by 4, in the other rows. The new table will be Present State NextState | Olp | Next State Olp 7H n 9 n i n 0 iA 2.6. MINIMIZATION OF DFA Sec section 1.7. 2.6.1 Methods for the Minimization of DFA These are three methods for the minimization of DFA: 1. HIT&Trial Method 2. Partition method 3, Myhill-Nerode Theorem jal Method of DFA : Minim;. \ 4 fos to minimize the DEA poe 0 Make the transition table of th { ) emove the in accessible (ant Sives DFA, Now divide rows of ifanateh Gite states i from (@ (7) One set contains the le into the transi non final states, two sets: ition table. ) Other set contains the fit . e final tates t js 4? Svcs ofp ait Fen ete oat step 407 both ae state in the sd Skip one of then ; a combine the two ae Ky You dts findlag se le with the other a bees & ow, com you wil rows. z fe: Minimize the following DE wee theta table of minimized DF pam TRIAL meth be 1ods : he unreachable state we the dy Step 2: Remove t Here q; is State & mal Je state so remo’ the unreachabl n table = ke new transitiol rf Lo —_ eo ition table in two S25 ° =~ ) Step 3: Divide transit | Set for non finay ay 2 fs << } sett ae from Ist table : the similar rows Step 4: Now, remove 40 Step 6 : Now, remove similar rows form set 2. Step 7 : Now combine both the sets to get the minimized DFA? p This is Minimized DFA ate PARTITION METHOD i Jain state partitioning algorithm with a sui examy «state partitioning algorithm is used to ina Fi o .e Finite automata. (KU, Dec. 2008) psgorthom si tract partition (x) of the states of git given F.A. by breaking iti g it into a set of final and non- 4, cons final states- L Construction ofmnew: BEGIN For (each grouP of) Do ame subgroup if for Divide gP- G into subgroups such that two state P and Qare i is the si up i/p symbol they are making transitions t pain a all such subgroup in x new. fo same group of t- END Ifnnew #7 then set 7 = Troy Tepeat Step 2. Otherwise we have to step have. Choose representative states from each group of Remove any dead states and any unreachable state of present. Example: Master Mind Solved Questio 70 besa () Prepare the transition table for the given DFA Before to other set eee (oI Ix 4 Ae) @ %=(ty Wy I 0 Z ah % 4% Equivalence class of b> q, % % final states Equivalence class of non-final states 4 G8) = (Oy Gu 45746) Oy 43} oy 4 48) 2% 6@ % % bow 6 Qo % 0) = (dy My 454) (A 4} Ao) 40h D BAc ton 1 Machines and Propertios of Regular Sots Theorem: 10 e ibe Myhill-Nerode Theorem, | cri fe pest Myhill-Nerode theorem, (KU, Dec. 2005) m ete Myhill-Nerode theorem and its applications, (KU, Dec. 2007) ‘ (KU, Dec. 2006) a pill Nerode Theorem: pe sjerode theorem is used to eliminate useless states F f fre vi agiscussins theorem, we will study some terms : oma DE ¢ i lation as bei é jn equivalence re s being true o fe fit of strue for some se of walle? = ice . a specific pair of string x and y. on iB yitand only if y has the some relate SS use relation R such that xRY = yRa, yt ya yk (symmetric) il 4 RZ then = xRz. (Transitive) : 2 jg true [Reflexive] ia ation Rj means equivalence relation R over the language. notation R,, means equivalence relation R over the machine M. ss t Et into equivalen 4 spo divides the set al ce classes, one class for each state reachable in that of M from the starting state to. To get R, from this we have to consider only the ajar state i abe states of M. eat _ nent of the Myhill Nerode Theorem ; The Mill Nerode theorem say the following ents are equivalent : J ThesetL, asubset of ¥" is accepted by a DFA. [L is regular language] 2, Lis the union of same of the equivalane class of a right invariant [with respect to concatenation] equivalence relation of finite index. 4, Letequivalence relation R, be defined by +R, if and only iffor all zin 2, xz isin Lexact by when yz isin L. Then, R, is of finite index. Implementation 6f Myhill Neorde Theorem 1, Firstly remove the unreachable states from the DFA. 2, Build two dimensional matrix labelling the right side 45 9, P. Label the top as 4g, 4}-- all states & denote this as q. 4, Now, put dashes in the lower triangular pair of the matrix, We will use only upper past of matrix because xRmy = yRmx is symmetric. We will also use (P, q) to index into the matrix with the subscript of the state called P always less than the subscript of the state called q. 5 4, We can have one of three things in the matrix location where there is no dash. () AX indicates a distinct state from our initialization. [It means from [P, q] one state is final _ other is non final or vice versa. () xat the location [P, q] indicate that P is disti (@ We will label all empty matrix location with O. The Olocation means P & q are equivalent and will be the same state minimization machine. . Now, mark “” at [P, 4] in upper triangle se lower than the subscript of q or P in [Q-F] * all states and denote this as inguishable from 4. ‘h that P in F & q in (Q-F) as subscript of P is F will be X. py 72 : Master Mind Solved Question Papers 6. Now, begin every pair of district states (P, Q) in FXF and for every pair of digticy S [QF] « (Q-F] q ve ~ If for any input symbol [R,S] has X orx then put x at [P, 4] check [sr] if, shag where : r= 8 [p, a] s=6 [q, a] 3 is the input symbol in 5]. > If [p, q] has a dash then mark x at {q, p]- 7. Mark are the empty position ‘’ in upper triangle. 8. To find out the states in minimized DFA check all the rows of final matrix, The minimized machine will contain the states equal to the number of rows COntains entries [including the initial state if row starts with initial state does not contain only Og 0 If a row start with qx is having O at q(y) and qz positions then [4,, 4, 4,) will a sa minimum machine. 7 9. For finding in transition, we use the same method used in partition method & transition of it for all input symbols is in E. a Example : Minimize the automata given below with the help of Myhill Nerode theorem, Step 1 : Remove the unreachable states first in this there is no unreachable state. Step 2: Q= (4 41 9a Ay Iu 457 96401 4) 4 I state = gy F= (yy 46) QF= [40 9 Iw 47 46) Build the matrix for the state qy, q,... 9g & mark — in lower triangle. tion to Machines and Properties ts Regular Sets oe mark Xt [Pd i upper triangle such tha zB (Prete subcript of P is lower than 4 t Pin F and q in {Q- F] or in Pin[Q \ (oF Uta a a A (A 9) ; yt (ay 40) 4s Arb (9) (4 4) ay a) "FIX (42 (4 4a) (45 ya (qua (qv aah tv ash (vad, (y 43) ay ark ® and o in the matrix. Fst consider (Q-F)= {90 9 44 4p 4g) ofl (QF)= (to At 44) (to a 0 9) (Oy tah phe (Oy Fabs Guy Ary La Ag) (tor Gh Now, we will select (p, 9) from (Q-F) x (Q-F) wewill find [r,s] a8 (@ 4)markX inal the pq shownabove r=8(P,q} &8=5{g,c) iflr.s)=X or x then {p,q} will bex, it{r,s) isneither X nor x the {p, q} will be 0. “for [gq 4} 7= 8 (do = 4, S=5 lay =a now is matrix (qq, 4a} = X So (9p, 4} will be. -y for ay 947 = 8404} 4 8=8 (dy 945 {a 9g) =X & (dy 43) =* for ity 44h 77 5 (9 D2 42 $= 8 [ty = M5 [4a 95) is neither X nor x $0 [4a 94) =0 Now, repeat step 4 for all [p, qlin [QF] x{Q-F. :Now, repeat step 4 for all [P, q] in [F* Fl ‘After completion of all [P, ], we will set rest of the entries in t Now, make matrix after filling (a he upper triangle will be 0. all entries. La | % | Loe de HR = = 1 oxen meme R RIS from the above ‘matrix. ymata {Gy 4 45, 4eh to agh | state of the DFA. Sip 6: Note find the states of minimized auto Qe (lagh (tv 40) Initial state will qo because it iS the initia Final state will be {qz 4y 49 46 u Master Mind Solved Question Papers (Automata Now, prepare the transition table for minimized DFA. —$_——— a b > (a0) (ay 4) (41-94) {av 44) {4 4y95 46) (dy dy 45 46) “dy 4546) (aya) (97.48) one>> This is minimize DFA. Q.25. Minimize the following DFA : State Q700 0 OPaSe Dam > BNP A B Cc E F G H (KU, Dec. 2007) Encircle means final state. Ans. Step 1. Construct partition set (n) of the states of given F.A. by breaking it into a set of final and non final state. Now a= ((ABCEEGH),(D)) Step 2. For i/p symbol ‘0’ a= ((A.BEGH},(CE} (D)) For I/P symbol ‘1’ = (AG), {H}, {BF}, (CE), {D} new Step3. o * x= ((A,G}, (HI, {BF}, {CE}, {D} For i/p symbol ‘0’ w= {(4,G}, (H), (BF, (CE), (D}} For i/p symbol ‘1’ T new = (A,G}, {H), {BF}, (CE), (D} Step 4. Ta Te Therefore, final values of {A,G), (A), (B,F), {CE}, {D} 2 t Machines and Pr piste Toperties of a mh SS we Roguiar Setp 3 choose seprentative states from eq, : c 1 Broup of x, ere state His unreachable state, So r, 0 90 remove sti ge minimize DFA is fate E atl eH from Transition diagram. sansition Table is State 0 A B B A Cc D © D (9.26. What is minimum automata? How minimum automata is constructed. (KU, Dec. 2012) 1 A c B A ‘ans See Section 2.6 and 2.6.1 (Minimization of DA). 17 PUMPING LEMMA FOR REGULAR SETS & APPLICATION OF PUMPING LEMMA : Q.27, Define pumping lemma. Describe the application of pumping lemma. (KU, Dec. 2005) 0.28, Discuss the application of pumping Jemma. (KU, Dec. 2005) (KU, Dec. 2010) e pumping Jemma for regular language. gular sets and explain the ap) Jication of pumping lemma. (KU, Dee. 2012) 029, State and prov 230. State pumping lemma forte} Ans, Pumping lemma is useful because of the following reasons + 1, It gives a method for generating many substrings from a given long string, It provides means to break a given sufficient long input string into several substrings. 2, Itgives necessary condition {@) to prove whether the language is regular or not Statement : Let L be the regular language there exist a constant n which depends on L such | latfor every string w in L such that rength of iol 2nana ve can reak the string w into YZ Such that : © y# © [y should never be null string] (i) Ixyl_snflength Ix, yl 0 string x yz is also in L. fa regular or not regular Fanguage It is a1,. It is used to check whether a given language is Je eae ht useful to check whether the aeeuck Sept ‘a finite automata is finite or infinite, Proof: If L is regular, itis accepted by a DFA. : 3 M= (Q 5, 5 qo F) with some of fixed number of states SAY" Consider any string w of lengi, 1 or more say 2 W=A, Ay dy mM>n and fori=1,2...m.Let 8 (4, ay, a>... a;) = q; where qo is the start state and first jsymbolsofw. | ___ By Pigeonhole principle it is not possible for e Since there are only n different states. thus we can fin that 9, = 9. So, we can break w three parts such that w = xy2. WA, hn 58551 59 oe By My B42 A =>X= 4, My ay SYR Bier 4 is the state, where M reaches after Teading ach of the 1 + 1 states dy 4--» 4, tO be disti dt two integers j and k with O' 0. Case 1:Fori=0 When i= 0 then w= xyz = xz x, is accepted. Since, the automation goes from the start state qq to q; on input x and since, qs also q, and q, reaches q,, (the accept state) on input z. Hence, x, is accepted. Therefore, xz EL. Case 2:Fori>1 Then M goes from 4, to q; on input string x, then goes i times into the loop q; to q, on input yf and then goes to the accept states on input zie. xy'2 ZL. Thus, for all i> 0, w=.xy'z is accepted by M. Hence, the statement of the theorem is true. Application of pumping Lemma : The pumping lemma is extremely useful in proving that certain sets are non regular. The steps to prove that L is not regular : 1. Select the language L, you with to prove non regular. 2, Select 1 the constant in pumping lemma. > ‘ion to. Machines and tes of Regular Sets 7 ¢ Sind gelect aS B (our choice fl now break the string $ into, y aie 5, You Tnined by the sh 1 determine MA \e showing fc fp for which xy! isnetin Ly jmay depend on 7, x, yand 2, x reak form of pumping Lema: Sy eee Wert ly! >0,3Y'2—>L for ever npposeLisan infinite language. Then, there a7 strings ¥ @ sir 31. Prove that prime is non a ii 0. regular (by pumping lemma) where prime = (a? where Py a (Ku, Dec. 2006) depend implicitly on the value of chosen actleve 2 contradiction Ws thetic Ere ET and ly! 2+ ¢ pumping lemma by showing for any * ¥ and 2 %, yand z determined by the previous that there may concluded that L is not regular. Your selection of os. Consider the language prime = a?, where pis prime). Show that above language (KU, jar. ee er yearegil Dec. 2007) ns. 1. Let L be a regular language, are the no, of states of finite automata accepting L- ider a stri; 2 Frais pee ei ice 4 Br Here, the string w consists of all a's the number Consider w= a? where p> Forall i, xyz ¢L ayz= (yz) )" Be) yt Now y consists of all as. So y=a", m>0 wee? (amy = a * ml) Fori=1,w=aeL fori=2,w=artPme L[v ptm is nota prime no.) cS Fori=p+1,w=ar™eL Here, xyz¢L «. Lisnot regular. 0.33, Prove that 0" 1 01 m21 is not regular language. Ans, We prove it by pumping Lemma. Siep (1): Let L be the regular language n be the no. of States of finites automata M accepting L. Sep (2): Consider a string w, such that {wl 2m, Here are consider w= 0" 10" 1 The length of wis 2 (n+ 1)21. Sep 3) : Now by pumping lemma we ca 2 w= xyz= 010" Siep 4: For a integer, we want to find that xyz such that xyzeL ryz= (xy2) (W) ycan be in following forms + (KU, Dec. 2007) rn break the string w into xyz. Such that Ixy! <1 ly 21 th of string would be greater than is that a () yhas one 1. y can’t now two 1's, Since, the leng' ie, = = o"10"1 (a) oz pr +14 22" itt 78 Master Mind Solved Question Papers (Automata Fori=1, w=0"eL Fori=2, w= 0" eL xyizeL oy yhas no 1 ie, all a's are then y=a,x>0 w= ore = 2mx-1), 42 ¢ L ie, fori=1, w=O"I2eL w=2rPeL xyz eL So aby contradiction, we have proved that the language L is not regular. Q.34. Show that the following grammar is not regular. (Use pumping lemma) (KU, Dec. 2098) Ans, © Le (aibiziz1} (@ Let L be a regular language, n are the number of states of the frie anton accepting 1 (i) Consider a string w, such that Iw! > 1, then the string w consists of a & b Let w= abi Since lwl =i+i=2i>n (Letn=i} (ii) Now by pumping lemma, we can break the sting w into xyz w= xyz= alibi te) Now, we have to find and some suitable integer j such that xy'z ¢ L. xy'z= (xy) = (ab) 4 Now, what can be the possible values of |y| > 1. Since the string consists of Only as and bs, There would be three possible cases of y. AIS ale; al. b" imate y=a,121 ayiz = albi (aiyi-1 = gitiG-D pf Taking j=1, w=adbleL J=2, wealbicL Ey xyzeL (i) ycan beall Vie, y=b", m=1 re w= aii (pryi-1 = qipitm (j-1) Taking j=1, w=abieL J=L w= abit ¢ 1, (iii) y has botha’s and bsie, y= (a'b™) . w= abi (a'bmy-1 = git G-lpitmgj-1) S niroauetlon to Machines and Proy erties of Regular Sots eigen eel weableL ie ts aMlpin 1 go, webave prove that xy'z € L. So, language L = (ai bili o%* prove that language L = {a" b" forn=0, 1, 2, Vier wales ce L= {a", b for all n=0, 1. i ne i L= {e, ab, an bb, aaa bbb, ...) vows 9 string from the language aa bb select x, y, zheren=4 Now a ab b xyiz=aababb his string is not in L. So it is proved that given L is not regular. Bac 4 th ke ro yae Now fori=2 xjz=aabbb. ‘This is again not inL. Hence, proved itis not regular language. (936. Prove that L={a" ba" for n= 0/1, 3nhis not regular. ‘Ans. L= (b, aba, aabaa, aaabana.,.) Now, select any string from L aaabana heren=7 Now, select x, Ys 2 an aban Sa To ees Now, for i= 2 xyz aq ab ab aaa in L so it is proved that itis not regular. ‘This string is not yf z for k> 1} isnota regular language- Q.,37, Prove that Let Ans, L xyes X92 3992 NE) Now, select a string from L. xy yy? Case 1: Now, break the string in %, Y, 2 xen, yyy 8 Then Fori=2 (Wy) ¥ = xy )? yz = xyyyyy So, it is regular language. Fori=3 X=E, y= xy, 2= yyz Fori=2 GyPyyz F = xyxyyyz This string do not belong to L. So, it is not a regular language. Q.38. Prove that language which contains set of string of balanced parenthesis ()() 0 not regular. Ma Ans, Break the string in x, y & z WOO rye Fori=2 xyz=(()())() Fori=0 xz=((()) So, it is not a regular language. 2.8 CONSTRUCTION OF REGULAR EXPRESSION FROM DFA USING ARDEN’S THEOREM .__ Regular expression is mathematical expression for a given regular language. We know thay for every regular language there exist a deterministic finite automata. Therefore, we can construct regular expression for every deterministic finite automata. Ardens’s Theorem : Let P and Q be two regular expression over alphabet E. If P does nop contain null stringa, then there exists a unique solution for the equation. R=Q+RP (A) That is R= QP” Proof : Since R= Q+ RP Put this value of R in RHS. of eq. (A) R=Q+[Q+RP] P=Q+QP+RP* When we put the value of R again and again, we get the following equation : R=Q+QP+QP?+0P%.... R= Q[1+P+P2+P%., R= Q[a+P+P?+P3+...] [+ Q:1=Qsois.aQ] R=QP" Use of Arden’s theorem to find Regular expression for a deterministic finite Automata. Note : Procedure to construct Regular Expressions from Finite Automata : . Transition Diagram has only one initial state. 2. Transition Diagram should not have any €-transitions. 3. Its vertices are Gy 94, For Foy o=-1 In 4. q, is the RF representing the set of strings accepted by the system even though 4; isthe final state. 2. ay denotes the RE representing the set of labels of edges from 4, to 4g; when no such edge aj= 1. Then we can find following set of equations in gy, 4y 45.4, = Hi * a Oy + + Gym + = M2 * Fy 0la9 + + Gy, 1 In= 1 San Aan May Gy ch Now by applying substitution and Arden’s law we can express q in terms of a, It willbelit required RE. 4 ution to Machines and Properts off legular Sets construct Regular expression from follow; a ing DFA ly, find the equation from DFA. = %.b+qy-a+€ = 4-4 93 = 4.0 a= %q- 4+ Gy-b+ G4 (a+b) pos. Fist putqoand fin th = b+93-at€ = 4+ bate a, = lceetg k a im P 5 aya € (ab bay {By=R=Qy") $0the regular expression equivalent to DFA are (ab+ba)* with input over {a,b} and output over{0, 1) that prints ao 40. Construct a Mealy machine ipeonsumed and a1 for every & starting with the first (otherwise a0 is printed) eg. the cutput for the string, “abbaabaa” is 40001001”. (KU, Dec. 2010) Ans. bio A= (ab) Output = (0,1) Output 0 for each b : and Output alternate 1&0 fora starting with Ae xu, Dee. 2010 Qu, Design a modulo-4 up-down counter, " , ec. Ans, If X= 0 the device counts up 0, 1, 2,3, 0% 2, 3and X= 1 if the device counts down 4 )3,2,1,0,3, 2,1 Master Mind Solved Question Papers (Automata Q.42. Design two input, two output sequence detector which produces an output 1 time the sequence 0101 is detected, ea output 0 atall othertimes, eg when the input sequen, is 01010 the corresponding output sequence is 000101. (U, Dee. 2070 Ans. The corresponding machine is Q.43. Design a FSM with minimum states which accepts all strings over {a, b} such thay number of a’s is divisible by 2 & numbers of b’s dividable by 5. (KU, Dec, 2011) Q.44. Find the equivalence partition of states of machine of Fig. 1. (KU, Dec. 2011) Fig.1 Ps X=0 Ns,Z x=1 Q2peemeD OEOHDS ou4u0ots pooommoxr TAmmgAeD> ann0v007s rPUNANAMHOD y a a ea Chapter 2 : Introduction to Machines and Properties of Regular Sots 83 Mealy machine pee] TOIL OQass zommpsS0nws PION n mam om PGOOnsam ot POOTNOSS aw esnseeae mo 0 1 1 0 = 1 0 1 1 1 1 ag Lo na Q.45. Give state table to minimal machine of Fig. 1. of Q. No. 44. (KU, Dec. 2011) Ans. 0 1 >A H B F D € D E D & F E D c F € © G ‘Se D © & 4 m= (A,B, CD, EG) (HH) = ((A} {B,CD,E,F.G) (Hl) 0+FDCDCC 1+ DEFCCD Hee — A=(A} B={B,C,D,E,EG} C=} Q={A,B,C} | ; F=(q } | qo lA) | SB hy ie Master Mind Solved Question Papers (Automat, 2.9 CLOSURE PROPERTIS OF REGULAR SETS Q.46. Explain closure of regular sets. " LU, Dec, With the help of Globes ears wl De ee eee ae language L is formed from them by certain operation then L is also regular. The Principal qg.18 Properties of regular languages are: at a 1. The union of two regular languages is regular IfL and M are regular languages, then LUM. ... The intersection of two re; soisLAM. 3. The compliment of two regular languages is regula =, then *~L is also regular language. . The difference of two regular languages is regular. IfLand Mare regular languages then so isL-M. The reversal of a regular language is regular. The reversal of a string means that the sting | is written backward, ie,, reversal of abcde is edcba. | The closure of a regular language is regular. If L is a regular language, then so is Lx, 7. The concatenation of regular language is regular. If Land M are regular languages, thensy isL.M. 8. The homo morphism of a regular language is regular. 9. The inverse homomorphism of two regular langauge is regular. Theorem: If L, and L, are regular language then prove that L, U Ly, Ly . L; and L,* arealsp regular. Proof: If L, and L, are regular language then we have a regular expression corresponding i L,andL,. Let r, is the regular exp. for L,. Let r, is the regular exp. for L,. By the definition of regular expression. 1, +Ty fy Ty fy" isalsoa regular expression. So the language derived from r, + ry 7, .7y 7," will also be regular language. So L1+Ly L;. Ly Ly* are also a regular language. — Now, FA for union operation LUM. gular languages is regular. If L and M are regular languages the, R e IFL is regular language over alpha, | » " ee FA for L FA forM [O-~-O} © FA forL FA forM — FA for concatenation operation L.. M. € — _gnapter 2 Introduction to Machines and Propeties of Regular Sets s — FA forL* ~ The reversal of a regular language is regular, The reversal of a string ay, My @y string written backwards. Ley By yyy oo Oy For example, w= 110110 wR = 011011 w= abaab wR = baaba — Steps to convert a finite automota for L¥ if we have an automata for L®, CFA will be non determination will ¢). DFA for string ending with a over (a, b) Qrs a a, L= {a;ba, aa, ana, bba, aba; ...) L¥= String starting with a ice,, (a, ab, aa, ana, ab, aba, ....) @ Reverse all the arcs of the transition diagram (oa a @ The accepting state for the new automata will be starting state of the original automata. Ove a Qo, (ii) Create a new state Py with transition on E to all the accepting states of original automata. ! It will accept the string starting with a. Theorem: If L is regular then L¥ is also regular. Proof: As'L is regular language then we can construct a finite automata M. Now, we will construct M! for L¥. IfW e L we have a path from qo to some final state in F with path value W. By reversing the edges we get a path is M! from new initial state to final state. If path value SYS We ie = 86 Mast Mind Solved! Question Papers So, if We Land WRE LR, Here, WR is accepted by the M! and WR ELK, So, all strings in LR are accepted by the M!. So, Lisa regular language, ~ The complement of a regular language is regular. If is a regular language over Zthen T (*- 1) is also a regular language. Proof: We can prove it by converting an automata that accept L to the automata that Firstly the will design the finite automata for L. Hy Now to design the automata for L we simply change the accept state to Non final Stat '8e Non-final states to final state of the automata for language L. ay Now, we will get the machine that accepts all strings that belong to Land Teject a belongs to L. Sting Tf an automata accept are the strings belongs to [, then it means L is a regular langgy €.8., Design a DFA for L in which all strings end with a. L= (a, aa, ba, aba, baa, abba, aaaa, bbba, ...) DFA for L = (¢,b, ab, bb, baab, ab, ...) It will accept all strings to L. = The intersections of two regular language are regular, LetL, and L, are two regular language the L, - L, are also regular. Proof : By using demorgan law ae kok (F +0, Now, because L, and L, are regular then T, and T, are also regular from previous cos! property. Now, L; + Ty is also regular from first regular property. Now, if L; + I) is regular than T, +1, is also regular. So, => The difference of two regul L-Marealso regular. “3h 2 1, 0. Ly is also regular. lar language is regular. If and Mare the regular langu2®® 1g: ntroduction to Machines and Properties of Regular logular Sets proofs L-M=LaM Lett Now, ae {1,2, 3} ed ee, M'= (1,2) L-M=(1,2) LOM ={1,2) % hence, L-M=Ln M Here Mis peaulae so M is also regular by closure property. Now, Land M is regular then Ly M is also regul vie property. ‘therefore, L~M is also regular. 2 a ° are i pe i, R= (atd}*b+b(a+b)ra __ Q448. Write the regular expression to generate a identifier in C language. Ans. (l+-)(4d+-)* Here 1 is any letter or alphabet dis any number or digit ~ is under score.

You might also like