i 1 i 2 i 3... i p o 1 o 2 AUTOMATON q 1, q 2,,q n ... o q Model of a automaton Characteristics of automaton:

Size: px
Start display at page:

Download "i 1 i 2 i 3... i p o 1 o 2 AUTOMATON q 1, q 2,,q n ... o q Model of a automaton Characteristics of automaton:"

Transcription

1 Definition of n Automton:-An Automton is defined s system tht preforms certin functions without humn intervention. it ccepts rw mteril nd energy s input nd converts them into the finl product under the guidnce of control signls. or n utomt is defined s system where energy, mterils, nd informtion re trnsformed, trnsmitted nd used for performing some functions without direct involvement of mn. Ex: Any utomtic mchine like printing mchine, wshing mchine etc. i i 2 i 3... i p AUTOMATON q, q 2,,q n Model of utomton Chrcteristics of utomton: o o Input: i, i 2,,i p re the input of the model ech of which cn tke finite number of fixed vlues from n input I. 2. Output: o, o 2,,o q re the outputs of the model ech of which cn give the finite number of fixed vlues to n output O. 3. ttes: At ny instnt of time the utomton cn be in one of the sttes q, q 2,,q n. 4. ttes Reltion: The next stte of n utomton t ny instnt of time is determine by the present stte nd present input. 5. Output reltion: The output is relted to either stte only or to both the input nd the stte. Note: An utomton in which the output depends only on the input is clled n utomton without memory. Ex:- logic gte. An utomton in which the output depends on the stte nd input is clled n utomton with finite memory. Ex:- flipflops, shift register, Mely mchine. An utomton in which the output depends only on the sttes of the mchine is clled Moore Mchine. o q Description of Finite Automt (Finite tte Mchine): A Finite utomton cn be represented by five-tuple structure M(Q,Σ, δ, q, F), where. Q is finite non empty set of sttes. 2. Σ is finite non empty set of inputs clled the input lphbets. 3. is function which mps Q Σ into Q nd is clled trnsmission function (next stte function) (present stte input lphbet next stte). 4. q Q is the initil stte. 5. F Q is the set of finl sttes (my be more thn ). Note: Q Σ * into Q mens Present stte tring of input symbols(including Λ ) Next tte. tring being processed $ $ $ $ $ $ Reding Hed Finite Control Input Tpe Block digrm of finite utomton I) Input tpe: The input tpe is divided onto squres, ech squre contining single symbol from the input lphbet Σ. The end squres of the tpe contin the end mrker $. The bsence of the end mrkers indictes tht the tpe is of infinite long. Input string is processed from left to right. II) Reding Hed: The hed exmines only one squre t time nd cn move one squre either to the left or to the right, we restrict the movement of reding hed only to the right side. III) Finite Control: The input to the finite control will usully be the ymbol under the reding hed nd the present stte of the mchine. Outputs will be A). A motion of R-hed long the tpe to the next squre. B). The next stte of the finite stte mchine given by δ(q,).

2 Trnsition system: A Trnsition system is finite directed lbeled grph in which ech vertex(node) represents stte nd the directed edge indictes the trnsmission of stte nd the edges re lbeled with input/output. In Figure, the initil stte is represented by circle with n rrow pointing towrd it, the finl stte by two concentric circles nd the other sttes re represented by circle. The edges re lbeled by input/output (eq. / or /). For exmple, if the system is in the stte q & the input is is pplied, the system moves to stte q s there is directed edge from q to q with lbel/. It output. Definition of Trnsition ystem: A trnsition ystem consist of 5-tuple (Q,Σ, δ, Q, F). I. Here Q, nd F re finite non empty set of sttes, the input lphbets, nd set of finl sttes respectively, s in the cse of FA. II. Q Q nd Q is the non-empty set of initil stte. III. δ is finite Q Σ Q. In other words, if (q, ω, q 2 ) is in δ. It mens tht the grph strts t the vertex q, goes long set of edges nd reches the vertex q 2. A Trnsition system ccepts string w in Σ * if i). There exists pth which origintes from some initil stte, goes long the rrows nd termintes t some finl stte. ii). The pth vlue obtined by conctention of ll- edge-lbels of the pth is equl to w. / / ^/ q q q 3 / / / / q q / Fig. A Trnsition ystem. q 2 ^/ / Determine the initil nd finl sttes. q & q q 3 will be ccepted. will be rejected. Properties of Trnsition Functions: Property : δ(q, ) = q is finite utomt, This mens tht the stte of the system cn be chnged only by n input symbol. Property 2:- for ll strings w nd input symbol δ(q,w) = δ(δ (q,)w) δ(q,w)= δ( δ(q,w),) This property gives the stte fter the utomton consumes or reds the first symbol of string w. Ex: prove tht for ny input trnsition function δ nd for ny two input string x nd y. δ(q, xy) = δ(δ(q, x), y) Proof: By method pf mthemticl induction. Bsis: on y i.e. length of y when y =, y= Σ. L.H.= δ (q,x) = δ( δ(q,x),) (by using prop. 2) =R.H.. 2. Induction Hypothesis: Assume the result for ll string x nd string y with y =n. 3. Let y be string of length n+. Write y=y, where y = n. L.H.. = δ(q,xy ) = δ (q,x ) where x = xy = δ( δ(q,x )) ( by using prop. 2). = δ( δ(q,xy ) ) = δ( δ( δ(q,x), y ) ) by step 2.result = δ( δ(q,x)y ) = δ( δ(q,x)y) = R.H.. By the principle of mthemticl induction, this is true for ll strings. Ex.:- prove tht if δ(q,x) = δ(q,y), then δ(q,xz) = δ(q,yz) for ll strings z in Σ +. ol:- δ(q,xz) = δ( δ(q,x)z) by previous results. = δ( δ(q,y)z) (given) =(q,yz) (reverse the previous result)

3 Regulr Lnguges: regulr lnguge over n lphbet Σ is one tht cn be obtined from these bsic lnguges using the opertions Union, Conctention nd Kleene * (Kleene * opertion rises from the conctention to produce infinite lnguges). A regulr lnguge cn be described by explicit formul { } by leving out the set of { } or replcing them with ( ) nd replcing by +; the result is clled regulr expression. Lnguge Corresponding Regulr Expression. {^} ^ 2. {} 3. {} or ({},{},{}) 4. {,} or ({} {}) + 5. {,} or ({} {}) + 6. {,^}{} (+^) 7. {} * {} () * (+) 8. {} * {} () * or * or + 9. {,,} * (++) *. {,} * {{} * U{,^}) (+) * (() * ++^) Definition: Regulr Lnguges nd Regulr Expressions over Σ: The set R of regulr lnguges over Σ nd the corresponding regulr expressions re defined s follows:. Φ is n element of R, then the corresponding RE is Φ. 2. {^} is n element of R, then corresponding RE is ^. 3. For ech Σ is n element of R, nd the corresponding RE is. 4. If L nd L 2 re ny element of R nd r nd r 2 re corresponding RE.. L L 2 re ny element of R nd the corresponding RE is (r +r 2 ). b. L L 2 is n elements of ny element of R nd the corresponding RE is (r r 2 ). c. L * is n elements of R nd the corresponding RE is (r * ). Note: Only those lnguges tht cn be obtined by using sttements to 4 re regulr lnguges over Σ. Acceptbility of string by finite Automtion: Definition: A string x is ccepted by finite utomton M=(Q, Σ, δ, q, F) if δ(q, x)=q for some q F. This is bsiclly the cceptbility of string by the finl stte, Exmple: The FM is given below Tble: Input symbol tte q q 2 q q q 3 q q 2 q q 3 q 3 q q 2 q Here Q = { q, q, q 2, q 3 } Σ = {, } F = { q } Input tring(x) = δ( q, ) δ( q, ) δ( q, ) δ( q 2, ) δ( q 3, ) δ( q, ) δ( q, ) q Hence q q q q 2 q 3 q q q This indictes tht the current input symbol is being processed by mchine. q 2 Non-Deterministic FM: The concept of non-determinism plys centrl role in both the theory of lnguges nd the theory of computtion, nd it is useful to understnd this notion fully in very simple context initilly. The finite utomton model llows zero, one, or more trnsitions from stte on the sme input symbol. This model is clled nondeterministic finite utomton(nfa). q 3

4 For one input there is one or more output sttes. Figure: Trnsition system representing NDA If n utomton is in stte {q } nd the input symbol is, wht will be the next stte?, from figre it is cler tht next stte will be either {q } or {q }. ome moves of the mchine cnnot be determined uniquely by the input symbol nd the present stte. uch mchines re clled NDA. Definition: A Non-Deterministic Finite Automt (NDFA) is 5 tuple (Q, Σ, δ, q, F), where I) Q is finite non-empty set of sttes. II) Σ is finite non-empty set of inputs. III) δ is the trnsition function mpping from Q into 2 Q which is the power set of Q, the set of ll subset of Q. IV) q Q is the initil stte; nd V) F Q is the set of finl sttes. ome rules to generte FA, b + b (+b)c q q q 2 q q q q b b q q b q F F F F c F F (NFA) (+b)(c+d) ( + b) Φ ome regulr Expression nd their corresponding FA, + + ( + ) () * (+) + (++) q q q b q F q,b,b q q q q q q q q, q F F q q 2 q c d q 2 q f q F F F q 3 F q q 4 q 2 q 3 F F F F F

5 Difference between DFA nd NDFA is only in δ. for DFA outcome is stte, i.e. n element of Q; for NDFA, the outcome is subset of Q. Fcts of designing Procedure of FA we cn describe some fcts or observtion of FA. In the designing of the FA, first of ll we hve to nlyze the set of strings i.e. lnguge which is ccepted by the FA. b. Mke sure tht every stte is check for the output stte for every input symbol of Σ. c. Mke sure tht no stte must hve two different output sttes for single input symbol. d. Mke sure tht there is one initil stte nd t lest one finl stte in trnsition digrm of FA. Exmple: Construct FA tht ccepts set strings where the number of s in every string is multiple of three over lphbet Σ = {, }. olution: Multiple of three mens number of s on the string my be, 3, 6, 9, 2,... q Exmple: Design FA for the Lnguge L ={() I 2j i, j }. olution: By nlysis Lnguge L, it is cler tht FA will ccepts strings strt with ny number of (not empty) nd end with even number of s. q q q 2 q 3 q 4 q 5, q 2 q Exmple: Design FA over lphbet Σ = {, }, which ccepts the set of strings either strt with nd or end with. olution: By the nlysis of problem, it is cler tht FA will ccepts the strings such s,,,,,. Exmple: Design FA which ccepts the lnguge L= {w/ w hs both n even number of s nd n even number of s over lphbets Σ = {, }}. olution: exmple:nfa, q q q 2 w = q q 3 q 4 q 5 q 3 q 4 δ(q, ) = { q, q 3, q 4 } q, since q 4 is n ccepting stte, the input string will be ccepted by NDFA. q q q 2 q 3 q 2,

6 Exmple: NFA,,, q q q 2 q 3 δ * (q, ) = δ ( r, ) r (q,) = δ ( r, ) r (q,q ) = δ(q,) δ(q,) { q, q } { q 2 } δ * ( q, ) = δ ( r, ) r (q,) = δ ( r, ) r { q } = δ (q, ) = {q, q } δ * (q, ) = δ ( r, ) r (q,) = δ ( r, ) r {q, q, q 2 } = δ(q, ) δ(q, ) δ(q 2, ) = { q, q } { q 2 } { q 3 } = { q, q, q 2, q 3 } The Equivlence of DFA nd NDFA: or Prove tht for every NFA, there is n corresponding FA which simulte the behvior of NFA. for every string L. olution: Before describing the equivlence of NFA nd DFA, let us tke look t the term equivlence. The term equivlence mens equl in some respect. For exmple, BA degree is equivlent to n B.E. degree, s both re bchelor degrees, nd for ppering in the civil services exmintion, either of them is eqully pplicble. However, both re not equl, s person with BA degree cnnot be ppointed s engineer nd person with BA degree cnnot be ppointed s history techer. I. A DFA cn simulte the behvior of NDFA by incresing the number of sttes. II. Any NDFA is more generl mchine without being more powerful. let M = ( Q, Σ, q, δ, F ) is n NFA. M = (Q, Σ, q, δ, F ) is DFA. I) Q = 2 Q II) q = { q } III) Σ =Σ IV) F = { q Q nd q F } V) δ (q, ) = δ ( r, ) r q δ ([q, q 2,, q i ], ) = δ(q, ) δ(q 2, ) δ(q i, ) equivlently δ ([q, q 2,, q i ], ) = [ p, p 2,..., p j ] if nd only if δ ({q, q 2,, q i }, ) = {p, p 2,..., p j } δ (q, x ) = [q, q 2,, q i ] if nd only if δ (q, x ) = {q, q 2,, q i } Prove by using Mthemticl Induction. Bsis: x = δ (q, ) = { q } nd δ (q, ) = q = {q } so the eqution is true. 2. Assume eqution is true for ll string y with y = m δ (q, y) = δ (q, y) 3. let x be string of length m+. x= y δ (q, y) = δ (δ (q, y), ) = δ (δ (q, y), ) = δ ( r, ) r (q,y) = δ ( q, y ) Exmples: Construct deterministic utomton equivlent to M = ( [q, q ], {,}, δ, q, {q } ) where δ is stte/ Σ q q q q q q q

7 olution: i. The sttes re subset of {q, q } i.e. {Φ}, {q }, {q }, { q, q }. ii. [q ] is initil stte. iii. [q ] nd [q, q ] re finl sttes, both sttes contin q. iv. Trnsition tble for DFA stte/ Σ Φ Φ Φ [q ] [q ] [q ] [q ] [q ] [q, q ] [q, q ] [q, q ] [q, q ] When M hs n-sttes, the corresponding FA hs 2 n sttes. However, we need not to construct δ for ll these 2 n sttes. But only for those sttes re rechble from {q }, we hlt on when no more new sttes pper under the input. Exmple: Find deterministic cceptor equivlent to M = ( [q, q, q 2 ], {, b}, δ, q, {q 2 } ) where δ is stte/ Σ q q, q q 2 q q q q 2 q, q olution: M = { 2 Q, {,b}, δ, [q ], F } F = { [ q 2 ], [q, q 2 ], [q. q 2 ], [q, q, q 2 ] } stte/ Σ [q ] [q, q ] [q 2 ] [q 2 ] [q, q ] [q, q ] [q, q ] [ q, q 2 ] [ q, q 2 ] [q ] [q, q ] Exmple: Find deterministic cceptor equivlent to M = ({q, q, q 2, q 3 }, {,b}, δ, q, {q 3 } ) where δ is stte/ Σ q q, q q q q 2 q q 2 q 3 q 3 q 2 q 3 ol: M = (2 Q, {,b}, δ, [q ], F ) F = [q 3 ], [q. q 3 ], [q, q 3 ], [q 2, q 3 ], [q, q, q 3 ], [q, q 2, q 3 ], [q, q 2, q 3 ] nd [q, q, q 2, q 3 ] stte/ Σ [q ] [q, q ] [q ] [q,q ] [q,q,q 2 ] [q, q ] [q,q,q 2 ] [q, q, q 2, q 3 ] [q,q,q 3 ] [q,q,q 3 ] [q,q,q 2 ] [q,q,q 2 ] [q, q, q 2, q 3 ] [q, q, q 2, q 3 ] [q, q, q 2, q 3 ] Exmple: Convert he NFA given in Figure to its equivlent DFA.,b b q q 2 q f Trnsition tble for the NFA in figure Current tte Input ymbol b q q, q 2 q q 2 q f q f Trnsition Tble for DFA corresponding to DFA Current tte Input ymbol b [q ] [q, q 2 ] [q ] [q, q 2 ] [q, q 2 ] [q, q f ] [q, q f ] [q, q 2 ] [q ] Exmple: Convert the NFA given in Tble to Corresponding DFA. Trnsition Tble for n NFA Current tte Input ymbol q q 2 q f q 2 q 3 q 3 q 4 q 3 q 4 q 3, q f q f q Trnsition Tble for DFA corresponding to DFA Current tte Input ymbol [q ] [q 2 ] [q f ] [q 2 ] ϕ [q 3 ] [q 3 ] [q 4 ] [q 3 ]

8 [q 4 ] [q 3, q f ] ϕ [q f ] ϕ [q ] [q 3, q f ] [q 4 ] [q, q 3 ] [q, q 3 ] [q 2, q 4 ] [q 3, q f ] [q 2, q 4 ] [q 3, q f ] [q 3 ] Exmple: Convert the NFA fiven in tble to its corresponding DFA. Trnsition Tble for n NFA Current tte Input ymbol q q q, q 2 q q 2 q q 2 q Trnsition Tble for DFA corresponding to DFA Current tte Input ymbol [q ] [q ] [q, q 2 ] [q ] [q 2 ] [q ] [q 2 ] [q ] ϕ [q, q 2 ] [q, q ] [q, q 2 ] [q, q ] [q, q 2 ] [q, q 2 ] [q, q 2 ] [q, q 2 ] [q ] ϕ ϕ ϕ NFA with -moves : b 2 Fig:- NFA with - moves If there is NFA M with - moves, then there exists n equivlent DFA M which hs equl string recognizing power or if some NFA M with - moves ccepts n input string w, then there exists n equivlent DFA M which lso ccepts w. Method for constructing equivlent DFA from given NFA with -moves.. Using - closure Method 3 4 we use two opertions - closure nd move() closure(q): et of sttes which re rechble from stte q on - input including stte q. It is equivlent to one stte of equivlent DFA. 2. move(q,) = set of rechble sttes on input from stte q. - closure ( move ( q,)): Next stte from stte q on input ( Note: - closure( ) = ) Initil stte of equivlent DFA is - closure(), is the initil stte of given NFA nd finl sttes re those sets, which hve tlest one finl stte of given NFA. Exmple: Consider the NFA with - moves shown in figure. q q 3 q Fig: NFA with - moves. Find the equivlent DFA. ol: M = ( Q, Σ, δ,, F ) = - closure (initil stte of NFA) = - closure (q ) (stte rechble from q on input - including q ) = { q, q, q 2 } δ (, ) = - closure ( move ({ q, q, q 2 }, )) = - closure (q 3 ) = { q 3, q 5, q f } (next stte) let A = { q 3, q 5, q f }. where q 2 b q 4 δ (, b ) = - closure ( move ({ q, q, q 2 }, b )) = - closure (q 4 ) = {q 4, q 5, q f } let B = {q 4, q 5, q f } q 5 q f

9 Here we hve two sttes A & B. so we hve to define possible trnsitions from these sttes nd we continue the process until no next stte remin to be considered. δ ( A, ) = - closure ( move ({ q 3, q 5, q f }, )) = - closure ( move ( ϕ ) ) = ϕ. δ ( A, b ) = - closure ( move ({ q 3, q 5, q f }, b )) = - closure ( move ( ϕ ) ) = ϕ. δ ( B, ) = - closure ( move ({q 4, q 5, q f }, )) = - closure ( move ( ϕ ) ) = ϕ. δ ( B, b ) = - closure ( move ({q 4, q 5, q f }, b )) = - closure ( move ( ϕ ) ) = ϕ. Tble for DFA stte/σ b A B A ϕ ϕ B ϕ ϕ Q = {, A, B } Σ = {, b} F = { A, B } Exmple: Consider the following NFA with - moves. Construct n equivlent DFA. q 3 q 5 b P q q 2 q 7 q 8 b q 4 Figure: NFA hving - moves let M = ( Q, Σ, δ,, F ) is n equivlent DFA = - closure (initil stte of NFA) = - closure (P) (stte rechble from P on input - including P) = { P } (next stte) δ (, ) = - closure ( move ({ P }, )) = - closure (q ) = { q, q 2, q 3, q 4, q 8 } (next stte) b q 6 A B q 9 let A = { q, q 2, q 3, q 4, q 8 },where δ (, b ) = - closure ( move ({P}, b )) = - closure ( ϕ ) = ϕ. δ ( A, ) = - closure ( move ({ q, q 2, q 3, q 4, q 8 }, )) = - closure (q 5 ) = {q 2, q 3, q 4, q 5, q 7, q 8 } (next stte) let B ={q 2, q 3, q 4, q 5, q 7, q 8 } δ ( A, b ) = - closure ( move ({ q, q 2, q 3, q 4, q 8 }, b )) = - closure (q 6, q f ) = {q 2, q 3, q 4, q 6, q 7, q 8, q f } (next stte) let C = {q 2, q 3, q 4, q 6, q 7, q 8, q f } δ ( B, ) = - closure ( move ({q 2, q 3, q 4, q 5, q 7, q 8 }, )) = - closure(q 5 ) ={q 2, q 3, q 4, q 5, q 7, q 8 } =B δ ( B, b ) = - closure ( move ({q 2, q 3, q 4, q 5, q 7, q 8 }, b )) = - closure (q 6, q f ) = {q 2, q 3, q 4, q 6, q 7, q 8, q f } = C. δ ( C, ) = - closure ( move ({q 2, q 3, q 4, q 6, q 7, q 8, q f }, )) = - closure(q 5 ) ={q 2, q 3, q 4, q 5, q 7, q 8 }=B δ ( C, b ) = - closure ( move ({q 2, q 3, q 4, q 6, q 7, q 8, q f }, b )) = - closure (q 6, q f ) = {q 2, q 3, q 4, q 6, q 7, q 8, q f } = C. stte/σ b A A B C B B C C B C A b b 2. Removl of Null Moves B The bsic trtegies for the removl of null string re s follows: Let A nd B be the two sttes connected by null string. b C

10 trtegy : If A is n initil stte, then move A to overlp B with ll its connected structures s shown in figure. A trtegy 2: If B is finl stte, then move B to overlp A with ll its connected structures s shown in figure. A B B trtegy 3: If A is the initil stte nd B is the finl stte, then move A to overlp B with ll its connected structures nd mke A the finl stte s shown in figure. A B A trtegy 4: If both A nd B re norml sttes ( neither finl nor initil), either cn be moved to overlp the other with ll its connected structures. Note: If there is confusion in removing the null moves, remove them using -closure s discussed erlier. Kleene s Theorem: () (b) (c) ) Union q B q f q 2 f f 2 f 2 Union(P + Q ) A q 8 b) Conctention q = q c) Kleene * Conctention(PQ) q f q Kleenee * P * Equivlent of FA to Regulr et: The method going to give for constructing finite utomton equivlent to given regulr expression is clled subset method which involves two steps. tep : Construct trnsition grph equivlent to the regulr expression using - moves. This is done by kleene s theorem. tep 2: Construct the trnsition tble for the trnsition grph obtined in step. Using the method conversion of NFA to DFA & construct the equivlent DFA. f f Exmple:- Construct finite utomton for the regulr lnguge represented by the regulr expression ( + b ) * cd * e. olution: The following steps detils the cretion of the finite utomton for the given expression: tep : The regulr expression ( + b) * mens the repetition of the symbol nd b ny number of times (including zero) nd in ny order. Thus, the utomton for this prt of the regulr expression is given by loop tht repets for both nd b t ny stte s shown in figure i. f f q 2 f 2 f 2

11 Previous tte tep 2: The finite utomton corresponding to the regulr expression cd * consists of n rc with the c. this rc comes from the previous stte of the finite utomton from where cd * follows sequentilly. This rc ends on stte, sy A, on which there is loop to indicte the nuber of repetitions (including zero) of d. The prt of the finite utomton corresponding to the regulr expression cd * is shown in figure 2. tep 3: The finite utomton corresponding to the regulr expression e, consists of n rc with lbel e coming from previous stte nd ending into some stte, sy F. since e is the lst prt of the totl regulr expression ( + b ) * cd * e, F hs to be finl stte. The prt of the finite utomton corresponding to the regulr expression e is shown in figure 3. tep 4: The complete finite utomton for the regulr expression ( + b ) * cd * e cn be obtined by combining the finite utomt in fig -3 serilly, s shown in figure 4. d, b Figure e Figure 3 F Previous tte, b Exmple: Construct the FA equivlent to the RE ( + ) * ( + )( + ) * olution: (Construction of trnsition grph): First we construct the trnsition grph with -moves then eliminte -moves. q ( + ) * ( + )( + ) * () ( + ) * ( + ) ( + ) * q q q 2 q f (b) ( + ) ( + ) ( + ) q q 5 q q 2 q 6 q f d c e A F c Figure 2 Figure 4 q f A q, q 7 q5 q q 2 Exmple: Construct the FA equivlent to the regulr expression + ( + ) * olution: (Construction of trnsition grph): First we construct the trnsition grph with -moves then eliminte -moves. (e) d q 8 (d), q, 7 q q 2 q 8 (e) + ( + ) * q () q + q q 4 q q ( + ) * (b) q 2 q q 2 q 2 q q (c) (d) q 3 q 3 q f, q f q 6 q f q f q f q f

12 Exmple: Design grmmr generting the lnguge L = { wcw R w (, b) + }. olution: (, b) + indictes tht w contin t lest one symbol. The exmple strings re in the lnguge L re c, bcb, bbcbb, c, bbcbb,... Thus productions P re bb X bxb X c Exmple: Design grmmr generting the lnguge L = { n b n n }. olution: Every string contins equl number of s nd b s. Every string w in L contins substring of s followed by substring of equl number of b s. The exmple strings in the lnguge L re b, bb, bbbb, bbb,.... Thus productions P re b b Exmple: Design grmmr generting the lnguge L = { n c m b n m, n }. olution: every string w belonging to the lnguge begins with substring contining symbols. this follows substring of c symbols. the substring of c s follows the substring of b symbols nd the number of b s is the sme s tht of s. the exmple strings in the lnguge re cb, ccb, cccbbb, ccbbb,.... Thus, we hve the set of productions P s follows: b Xb X cx c. Exmple: Design grmmr generting the lnguge L = { n b m m, n }. olution: every string w belonging to the lnguge begins with substring contining symbols. This follows substring of b symbols nd the number of b s re independent of s. The exmple strings in the lnguge L re b, b, bb, bbbb, bbb, bbb, etc. Thus the productions P re: AB A A B bb b Exmple: Design grmmr generting the lnguge L = { n b n c n n }. olution: Every string w belonging to the lnguge begins with substring contining symbols. This follows substring of equl number of b symbols, which further follows the substring of sme number of c symbols. The exmple strings in the lnguge L re bc, bbbccc, bbcc, bbbbcccc,... etc. Thus the productions P re: Xc bc cx Xc bx bb it cn be seen tht every string in the lnguge L hs the length 3n. Exmple: Design grmmr generting the lnguge L = { ww w (, b) + } olution: we see tht ech string in the lnguge L is of the length 2n (n ). The first substring of length n is the sme s tht of the subsequent substring of length n. The exmple strings in the lnguge L re, bb, bbbb, bb, bbbb, bbbb,.... thus productions P re : XYZ XY XA bxb AZ YZ BZ YbZ A A Ab ba B B Bb bb Y Y by Yb XY Z Exmple: Design grmmr for lnguge of ll plindromes over {, b}. olution: The bsis for our grmmr is s follows: Note: Finl stte is lso known s Accepting stte.

13 An lphbet or b is plindrome. If string x is plindrome then the strings x nd bxb re lso plindromes. thus the grmmr cn be designed s follows: bb b bb. Exmple: Design grmmr for lnguge L over {, b} such tht ech string in L contins equl number of s nd b s. olution: The string cn strt with either or b. Thus, we hve the production X by Now the design of X should be such tht it inserts one b more thn in the output string. imilrly, design of Y should be such tht it inserts one more thn b in the output string, Thus, we hve X b XX b Y byy Questions: Find the regulr expression corresponding to following:., b Σ strting from (bb) - bb ( + b ) * 2., b Σ ending with (b) - ( + b ) * b 3., b Σ ending with (b) nd strting with (bb). - bb ( + b ) * b 4., b Σ contining exctly 2 s - b * b * b * 5., b Σ contining tmost 2 s - b * + b * b * + b * b * b * 6., b Σ contining tlest 2 s - b * ( + b) * ( + b) * 7., b Σ contining bb s substring - ( + b) * bb ( + b ) * 8. tring of length 2. - ( + b) ( + b) or ( + b) 2 9. tring of length 6. - (+b)(+b)(+b)(+b)(+b)(+b). tring of length 2 or less. - ( + + b ) ( + + b ). tring of even length - ( + b + b + bb) * 2. tring with odd number of s - * ( * * ) * * 3. tring of length of 6 or less. - ( + + ) 6 4. trings ending with nd not contining - ( + ) + 5. Lnguge of C identifiers. - ( l + _) ( l + d + _ ) * 6. Rel Literls in Pscl - sd + (pd + + pd + Esd + + Esd + ) 7. trings Contining exctly 2 s - * * * 8. tring contining tlest 2 s. - * ( + ) * ( + ) * 9. trings tht do not end with ( + ) * + ( + ) * 2. trings tht begin or end with or. - ( + ) ( + ) * + ( + ) * ( + ) 2. trings not contining the substring - ( + ) ( + ) * or ( + ) * ( + ) 22. trings in which the number of s is even - * ( * * ) * 23. trings contining no more thn one occurrence of the string. - ( + ) * ( + + ) ( + ) * 24. trings in which every is followed immeditely by. - * ( + ) * 25. {,, 2} { 2n + n > } - ( ) { w {, b } * w hs only one } - b * b * 28. et of ll strings over {, } which hs tmost 2 s * * + * * * 29. { 2, 5, 8,... } - () * 3. { n n is divisible by 2 or 3 or n = 5 } - () * + () * + 3. trings beginning nd ending with.

14 - ( + b ) * 32. trings hving tmost one pir s or tmost one pir of s. - ( + ) * + ( + ) * ( + ) * + ( + ) * + ( + ) * ( + ) * 33. tring in which number of occurrences of is divisible by 3. - ( b * b * b * b * ) * 34. tring with 3 consecutive - ( + b ) * bbb ( + b ) * 35. trings beginning with - ( + ) * 36. tring ending with nd beginning with. - ( + ) * Difference between DFA nd NDFA r. DFA NDFA. Deterministic Finite Automt 2. Every trnsition is unique nd deterministic in nture. 3. Null-trnsitions re not llowed 4. Requires less memory s trnsition digrm needs less number of sttes. 5. Rnge of trnsition is δ:q Σ Q. 6. All DFA s re NDFA s but vice vers is not true. Non-Deterministic Finite Automt Multiple trnsition for n input on stte re possible, which mens moves re nondeterministic in nture. Null-trnsitions llowed. Applictions of Finite Automton. re Requires more memory s trnsition digrms needs more number of sttes. Rnge of trnsition is δ:q Σ 2 Q All DFA re NDFA.. Lexicl Anlyzers: Lexicl nlysis is prt of compiltion nd used to recognize the vlidity of input progrms. Whether the input progrm is grmmticlly constructed or not. 2. Text Editor: smrt nd speedy text editors cn be constructed using FA. 3. pell checkers: spell checkers cn be designed using FA. In our computer system, we hve dictionry, FA cn recognize the correctness of word nd cn give the pproprite suggestion to the users lso. 4. equentil Circuits: FA cn lso be used to design sequentil circuits. 5. Imge Processing. 6. Nturl Lnguge Processing. 7. Internet Browsers: To scn lrge body of informtion. 8. Communiction: Designing of protocols for exchnge of informtion. 9. Pttern mtching.. Forensic cience. Cellulr mchines uses cellulr Automt Limittions of Finite Automton: FA is most restricted model of utomtic mchines. It is n bstrct model of computer system. FA hs following limittions:. The memory is limited. 2. Memory is red-only memory. 3. Memory is sequentilly ccessed. 4. FA hs only string recognizing power. 5. Hed movement is restricted in one direction, either from left to right or from right to left. 6. Limited Computbility men it cn ct like scnner FA re not computing devices but these ct only s scnner. 7. Periodicity: FA cnnot remember lrge mount of informtion or strings of lrge size. 8. Impossibility of Multiplictions: Full length of multiplier nd multiplicnd cnnot be stored. 9. Binry Response: Response of FA is binry either ccepted or rejected fter long sequence of moves.

15 Moore nd Mely Mchines: Finite utomt with output: The finite utomt which we were considered in the erlier hve binry output i.e. either they ccept the string or they do not ccept the string. This cceptbility ws decided on the bsis of the rechbility of finl stte by the initil stte. Now, we remove this restriction nd consider the model where the outputs cn be chosen from some other lphbets. The vlue of the output function Z(t) in the most generl cse is function of the present stte q(t) nd present input x(t), i.e. Z(t) = λ(q(t), x(t) ) Where λ is clled the output function. This generlized model is usully clled the mely mchine. if the output function Z(t) depends only on the present stte nd is independent of the current input, the output function my be written s Z(T) = λ(q(t)) this restricted model is clled the Moore mchine. Definition: A Moore mchine hs 6-tuple (Q, Σ, Δ,δ, λ,q ), where I. Q is finite set of sttes. II. Σ is the input lphbet, III. Δ is the output lphbet, IV. δ is the trnsition function Σ Q into Q. V. λ is the output function mpping Q into Δ. VI. q is initil stte. Exmple: Moore Mchine Present Next tte Output stte = = (λ ) q q 3 q q q q 2 q 2 q 2 q 3 q 3 q 3 q q / Trnsition grph input string output Definition: A Mely mchine hs 6-tuple (Q, Σ, Δ,δ, λ,q ), where I. Q is finite set of sttes. II. Δ is the output lphbet, III. Σ is the input lphbet, IV. δ is the trnsition function Σ Q into Q. V. λ is the output function mpping Σ Q into Δ. VI. q is initil stte. Present tte Exmple: Mely Mchine Next tte = = stte output stte output q q 3 q 2 q 2 q q 4 q 3 q 2 q q 4 q 4 q 3 Input string : q 3 / q / Trnsition grph q 2 / q q 3 q q q 2 q q 3 q 2 / q 4 / q q 3 q 2 q 4 q 3 Output tring =

16 Note: for Moore mchine, if the input string is of length n, the output string is of length n+. The first output is λ(q ) for ll output strings. In the cse of Mely mchine if the input string is of length n, the output string is lso sme length. Convert the Following Moore Mchine to Mely Mchine. Present Next tte Output tte = = (λ) q q 3 q q q q 2 q 2 q 2 q 3 q 3 q 3 q Present = = tte Next O/p Next O/p q q 3 q q q q 2 q 2 q 2 q 3= q 3 q 3 q Convert the Following Moore Mchine to Mely Mchine. Present Next tte Output tte = = (λ) q q q 2 q 2 q q 3 q 3 q q 3 Present = = tte Next O/p Next O/p q q q 2 q 2 q 2 q 3 q 3 q 3 q Present = = tte Next O/p Next O/p q q 3 q 2 q 2 q q 4 q 2 q q 4 q 3 q 2 q q 4 q 4 q 3 q 4 q 4 q 3 Present Next tte Output tte = = (λ) q q 3 q 2 q 2 q q 4 q 2 q q 4 q 3 q 2 q q 4 q 4 q 3 q 4 q 4 q 3 Convert the Following Mely Mchine to Moore Mchine. Present = = tte Next O/p Next O/p q q 2 z q 3 z q 2 q 2 z 2 q 3 z q 3 q 2 z q 3 z 2 Present = = tte Next O/p Next O/p q q 2 z q 3 z q 2 q 22 z 2 q 3 z q 22 q 22 z 2 q 3 z q 3 q 2 z q 32 z 2 q 3 q 2 z q 32 z 2 Convert the Following Mely Mchine to Moore Mchine. Present = = tte Next O/p Next O/p q q 3 q 2 q 2 q q 4 q 3 q 2 q q 4 q 4 q 3 Present Next tte Output tte = = (λ) q q 2 q 3 q 2 q 22 q 3 z q 22 q 22 q 3 z 2 q 3 q 2 q 32 z q 3 q 2 q 32 z 2

17 Question: Design Moore mchine which counts the occurrence of substring b in input string. olution: Let the Moore mchine be M = (Q, Σ, Δ, δ, λ,q ) Q = { q, q, q 2, q 3 } Σ = {, b} We will design this mchine in such wy tht mchine prints out the chrcter except for q 3, which prints. To get q 3, we must come from stte q 2 nd hve st red b. To get stte q 2, we must red tlest two s in row, hving strted in ny stte. Δ = {, } λ (q ) =, λ (q ) =, λ (q 2 ) =, λ (q 3 ) = The following mchine will counts b occurrence for us. b q / q / q / b q / b b Question: Construct mely mchine which clcultes the residue mod-4 for ech binry string treted s binry integer. olution: When we divide ny number by 4 then reminder cn be,, 2, &3. so clerly mely mchine will hve four sttes. Let the Mely mchine be M = (Q, Σ, Δ, δ, λ,q ) Q = { q, q 2, q 3, q 4 } Σ = {, b} Δ = {, } q is the initil stte & δ is trnsition function. λ ( q, ) = λ ( q, ) = λ ( q 2, ) = λ ( q 2, ) = λ ( q 3, ) = λ ( q 3, ) = λ ( q 4, ) = λ ( q 4, ) = Trnsition Digrm for M is s follows: / q / q 2 / / By the nlyzing mely mchine trnsition digrm, we cn esily notice tht it is lso finite utomt without ny finl stte nd output is there for input-symbol on corresponding trnsition. Output for every input symbol is represented s level on ech trnsition corresponding output. For e.q. in between q nd q 2 is lbeled by /, is input symbol nd is the output symbol. Question: Design mely mchine, which prints s complement of input bit string over lphbet Σ = {, }. olution: If input string is then s complements of will be, so we hve to design mely mchine which will print output for the input string. M = (Q, Σ, Δ, δ, λ,q ) Q = { q } Σ = {, } Δ = {, } q is the initil stte. Question: Construct mely mchine which clculte residue mod-4 for ech binry string treted s binry integer. olution: M = (Q, Σ, Δ, δ, λ,q ) Q = { q, q, q 2, q 3 } Σ = {, } Δ = {,, 2, 3} / q / q / / / q / /2 q 2 /3 /2 q 3 /3 / /

18 Arden s Theorem: let P nd Q be two regulr expressions over Σ. If P does not contin, then the following eqution in R, is R = Q + RP ---(i) hs unique solution QP * ---(ii) Proof: let us First check if QP * is solution to (i). To check this, let us substitute R by QP * on both sides of (i) R = Q + RP = Q + QP * P = Q ( + P * P) = QP * Hence eqn(i) is stisfied when R = QP *. This mens R = QP * is solution of eqn(i). Let us check if it is the only solution. To do this, replce R by Q + RP on the Right Hnd ide. of eqn(ii), we get R = Q + RP = Q + ( Q + RP )P = Q + QP + RP 2 = Q + QP + ( Q + RP )P 2 = Q + QP + QP 2 + RP 3... = Q + QP + QP QP i + RP i+ = Q ( + P + P P i ) + RP i+ We now show tht ny solution of eqution (i) is equivlent to QP *. Let w be the string of length I in the set R. then w belongs to the set Q ( + P + P P i ) + RP i+. As P does not contin, RP i+ hs no string less thn i+. This mens tht w belongs to the set RP i+. This mens tht w belongs to the set Q ( + P + P P i ) nd hence to QP *. Rules for using Arden s Theorem:. The trnsition grph does n t hve - moves. 2. It hs only one initil stte. 3. V i the regulr expression ( of finl stte) represents the set of strings ccepted by the system ( V i is finl stte). 4. q = Σ q i (incoming edge) lphbets + (only for initil stte). Conversion of FA to Regulr Expression. Exmple: The trnsition system is given in figure. b q 2 q 3 Prove tht the strings recognized re ( + ( b + ) * b ) * ( b + ) * we cn directly pply the method since the grph does not contin ny -move nd there is only one initil stte. q = q + q 2 b + q 2 = q + q 2 b + q 3 q 3 = q 2 reduce the number of unknowns by repeted substitution. q 2 = q + q 2 b + q 3 q 2 = q + q 2 b + q 2 q 2 = q + q 2 ( b + ) R = Q + R P QP * q 2 = q ( b + ) * Now substitute q 2 in q q = q + q 2 b + q = q + q ( b + ) * b + q = q ( + (b + ) * + R = R P + Q QP * q =.( + (b + ) * ) * = ( + (b + ) * ) * q 2 = ( + ( b + ) * ) * ( b + ) * q 3 = ( + ( b + ) * ) * ( b + ) * ince q 3 is finl stte, the set of strings recognized by the grph. Exmple: b q q q 2 b b q 3 b q 4

19 We cn directly pply the method since the grph does not contin ny -move nd there is only one initil stte. q = q 2 b + q 3 + q 2 = q q 3 = q b q 4 = q 2 + q 3 b + q 4 + q 4 b q = q 2 b + q 3 b + q = q b + q b + q = q (b + b ) + R = R P + Q QP * q =.(b + b ) * q = (b + b ) * Exmple:-, q q 2 q 3 We cn directly pply the method since the grph does not contin ny -move nd there is only one initil stte. q = q + q 2 = q + q 2 q 3 = q 2 + q 3 ( + ) q = q + R = RP + Q QP * q =.() * = * q 2 = q + q 2 q 2 = * + q 2 R = Q + RP QP * q 2 = * * As the finl sttes re q nd q 2, we need not solve q 3. q + q 2 * + * * * ( + * ) = * * Pumping Leem for regulr Lnguges/Regulr ets: Pumping Lemm: let M = (Q, Σ, δ, q, F ) be finite utomton with n sttes. let L be the regulr set ccepted by M. let x L nd x n, then there exists μνω such tht x = μνω, ν nd μν m ω L for ech m. Proof: suppose tht the set Q hs n elements. for ny string x in L with length tlest n. of we write x = 2 n ; then the sequence of n+ sttes. q = δ * ( q, ) q = δ * ( q, ) q 2 = δ * ( q, 2 ) q 3 = δ * ( q, 2 3 )... q n = δ * ( q, 2... n ) ν µ ω suppose q i = q i + p i i + p n then q q i δ * ( q, 2... i ) = q i δ * ( q i, i+ i+2... i+p ) = q i+p = q i δ * ( q i, i+p+ i+p+2... n ) = q f F To simplify the nottion, let μ = 2... i ν = i+ i+2... i+p ω = i+p+ i+p+2... n if i will be if i + p will be since δ * ( q i, ν ) = q i, hve δ * ( q i, ν m ) = q i for every m nd it follows tht δ * ( q, μν m ω ) = q f for every m since p > nd i + p n. Note: The decomposition is vlid only for strings of length greter thn or equl to the number of q f

20 sttes. for such string x = μνω s mny times s we like nd get strings of the form μν m ω which re longer thn μνω nd re in L. by considering the pth from q to q i nd then the pth from q i to q f ( without going through the loop), we get pth ending in finl stte with pth vlue μω ( this corresponds to the cse when m = ). Appliction of Pumping Lemm: This problem cn be used to prove tht certin sets re not regulr. we now give the steps needed for proving tht given set is not regulr. tep : Assume tht L is regulr. Let n be the number of sttes in the corresponding FA. tep 2: Choose string x such tht x n, use pumping lemm to write x = μνω with μν n nd ν >. tep 3: Find suitble integer m such tht μν m ω L. this contrdicts our ssumption Hence L is not regulr. 2 Exmple: how tht the set L = { i I } is not regulr. ol: L = {,, 4, 9, 6,... } = {,,,,... } tep : uppose L is regulr. let n be the number of sttes in finite utomton ccepting L. tep 2: let x = n 2. then x = 2 n > n. by pumping lemm, we cn write x= μνω with μν n nd ν >. tep 3: Consider μν 2 ω. μν 2 ω = μ + 2 ν + ω > μ + ν + ω s ν >. this mens 2 n = μνω = μ + ν + ω < μν 2 ω s μν n we hve ν n. therefore μν 2 ω = μ + 2 ν + ω i.e. 2 n < μν 2 ω 2 n + n < 2 n < μν 2 ω < ( n + ) 2 2 n + n. 2 n + n + n + Hence, μν 2 2 ω strictly lies between n nd ( n + ) 2, but is not equl to ny one of them. thus, μν 2 ω is not perfect squre nd so μν 2 ω L. but by pumping lemm, μν 2 ω L. this is contrdiction. thus L is not regulr. Exmple: how tht L = { Q Q is prime} is not regulr. olution: tep : We suppose L is regulr. let n be the number of sttes in the finite utomton ccepting L. tep 2: Let Q be prime number greter thn n. let x = Q. by pumping lemm, x be written s x = μνω, with μν n nd ν >. μ, ν, ω re simply strings of s. so ν = p for some p (nd n). tep 3: let m = Q+, the μν m ω = μνω + ν m- = Q + (m-)p = Q + QP = Q(+p). by pumping lemm, μν m ω L. but μν m ω = Q + Qp = Q(+p) nd Q(+p) is not prime. so μν m ω L. this is contrdiction. thus L is not regulr. Exmple: how tht L = { i i i } is not regulr. olution: tep : uppose L is regulr. Let n be the number of sttes in the finite utomton ccepting L. tep 2: let x = n n. then x = 2n > n. by pumping lemm, we write x = μνω with μν n nd ν >. tep 3: we wnt to find m, s the μν m ω L for getting contrdiction. the string ν cn be in ny of the following: cse : ν hs only s i.e. ν = k for some k. cse 2: ν hs only s i.e. ν = l for some l. cse 3: ν hs both s nd s i.e. ν = k l for some k, l. in cse, we cn tke m=, s μνω = n n, μω= n-k n. s k, n-k n so μω L. In cse 2, we cn tke m =, s μνω = n n, μω= n n-l. s l, n-l n so μν L.

21 In cse 3, we cn tke m =2, s μνω = n-k k l n-l. μν 2 ω = n-k k l k l n-l, s μν 2 ω is not of the form n n, μν 2 ω L. thus in ll the cses we get contrdiction. Thus L is not regulr. Exmple: how tht L = {zz z {, b} * } is not regulr. ol: tep : suppose L is regulr, let n be the number of sttes in the utomton M ccepting L. tep 2: let us consider zz = n b n b in L zz = 2(n+) > n. we cn pply pumping lemm to write zz = μνω with μν n nd ν >. tep 3: We wnt to find m so tht μν m ω L for getting contrdiction. the string ν cn be in only one of the following form: cse : ν hs no b s i.e. y = k for some k. cse 2: ν hs only one b. we my note tht ν cn not hve two b s if so ν n+2. but ν μν n. in cse, we cn tke m =. then μν ω = μω is of the for n-k b n b, here n-k n, we cn not write μω in the form so μω L. In cse 2, we cn tke m =. then μν ω = μω hs only one b ( s one b is removed from μνω, b being in ν). so μω L s ny element in L should hve n even number of s nd n even number of b s. thus in both cse, we get contrdiction. therefore, L is not regulr. Exmple: Is L = { 2n n } regulr? olution: We cn write 2n s ( 2 ) m, where m } is simply { 2 } * so L is represented by the regulr expression (P) *, where P represents { 2 }. the corresponding FA is shown in figure: q q Pumping lemm fils to solve this problem becuse this is regulr grmmr. Closure properties of Regulr sets: q f q 2 The term closure property reltes to mthemticl system (structure) contining set nd opertions performed on the elements of the set. For exmple, let I + be the set of positive integers nd ddition (+) nd subtrction (-) be the two opertions performed on the elements of this set. When the ddition opertion is performed on the elements of this set the result obtined is some positive integer nd belongs I +. When the subtrction opertion is performed, the result obtined my or my not belongs to I +. Thus the execution of the ddition opertion does not violte the boundry of the set I + wheres subtrction my do so. We sy tht the set I + is closed over the ddition opertion but not over subtrction. imilrly, set of ll 3 3mtrices is closed over the opertion of ddition, subtrction nd trnspose, but not over the opertion of the determinnt. Every regulr set cn be expressed by its corresponding regulr expression. In ddition, for every regulr expression, there exists corresponding regulr set. If n opertion performed on regulr set(s) leds to nother set, which is lso regulr, then the regulr set(s) re closed over tht opertion. The regulr sets re closed over the opertions of union, conctention, trnspose, complement, intersection, difference nd Kleene s str.. Regulr sets re closed over the union opertion. Proof: let nd 2 be two regulr sets ssocited with regulr expressions R nd R 2 respectively. Let there be set 3 = ( 2 ). then every element of 3 cn be expressed either by expression R, R 2 or both. Thus, the set 3 cn be generted by the regulr expression (R + R 2 ). The ssocition of 3 with regulr sets hs generted regulr set, regulr sets re closed over the Union opertion. 2. Regulr sets re closed over the conctention opertion.

22 Proof: Let nd 2 be the two regulr sets ssocited with the regulr expressions R nd R 2 respectively. Let there be set 3 creted by the conctention of the elements of nd 2 in order. Now ech string belonging to 3 is such tht it cn be decomposed into two prts, with the first belonging to (corresponding to R ) nd the second to 2 (corresponding to R 2 ). Thus, every element of 3 cn be generted by the regulr expression R R 2. The ssocition of 3 with regulr expression (R R 2 ) indictes tht 3 is regulr set. ince conctention of two regulr sets hs generted regulr set, regulr sets re closed over conctention opertion. 3. Regulr sets re closed over the trnspose (string reversl) opertion. Proof: Let be regulr set ssocited with the regulr expression R. let M be the finite utomton corresponding to R. Now, for every string (w ), there is pth in M from the initil stte to finl stte. Now, the following opertions re performed on M to crete new finite utomton, sy M 2.. Reverse the direction of every rc/rm. b. Chnge the initil stte ( origionlly in M ) to the finl stte. c. Crete new strt stte nd connect it to ll the cceptor sttes of M using - trnsitions. d. Remove ll -trnsitions. Let 2 be set of ll strings ccepted by M 2. Now every string (x 2 ) is reverse (trnspose) of some string (w ) thus 2 is set of trnsposed strings of. ince 2 is ssocited with finite utomton M 2, it is ssocited with regulr expression, Hence 2 is regulr set hs creted nother regulr set, regulr sets re loosed over the trnspose opertion. q q If finl stte is rechble from initil stte then L T is lso regulr. 4. Regulr sets re closed over the complement opertion Proof: let L be regulr set(lnguge) over the chrcter set Σ; then its complement L is set of ll string over Σ * tht re not in L, tht is L = Σ * - L. Let M be the finite utomton for the lnguge L. now, covert ll the finl sttes ofm to nonfinl sttes nd vice vers to generte new finite utomton, sy M. Now, if for string ω, M stops in finl stte the M stops in the non-finl stte nd vicevers. Hence M is the finite utomton for ince there is finite utomton for, is regulr set. Hence, regulr sets re closed over the complement opertion. 5. Regulr sets re closed over intersection opertion Proof: let nd 2 be two regulr sets. Therefore, their complements s nd s 2 re lso regulr sets. Union of s nd s 2, tht is, ( s s 2) is lso regulr sets. Complement of ( s s 2), tht is, ( s s2 ) is lso regulr set. By De Morgn s Lw, 2 = ( s s2 ). Hence, ( 2 ) is lso regulr set. Therefore, regulr sets re closed over the intersection opertion. 6. Regulr sets re closed over the difference opertion. q q q 2, d, Fo

23 Proof: let nd 2 be te two regulr sets. since 2 is regulr set, s 2 is lso regulr set, ( s 2) is lso regulr set. s 2 = 2 is lso regulr set. Therefore, regulr sets re closed over the intersection opertion. 7. Regulr sets re closed over the Kleene s str. proof: The closure over Kleene s str( ) is lso known s Kleene s closure. closure of regulr set over Kleene s str mens tht if R is regulr expression, then R * is lso regulr expression. Let R be regulr expression nd M be its corresponding finite utomton, s shown in figure, q q i q k q f Now wrp round the finite utomton M nd superimpose the finl stte q f with the initil stte q to mke the initil stte s the finl stte nd to crete new finite utomton, sy M s shown in figure. q q i q k Now if string ω is ccepted by the finite utomton M, then M ccepts ll the strings tht involve the repetition of ω. such s, ω, ωω, ωωω nd so on. Thus, M is finite utomton for R *. since there exists finite utomton for R *, it is regulr set corresponding to R *. Hence, regulr sets re closed over Kleene s closure. Myhill-Nerode Theorem [ Equivlent clsses nd Regulr Lnguges]: Consider lnguge L with Σ = {, } such tht string ω belong to L if nd only if it ends with. we cn ctegorized, ll the strings into two ctegories ( clsses), those ending with (sy clss C) nd those ending with (sy clss C2). All the strings in the clss C belongs to the lnguge set L nd those in the clss C2 do not belongs to L. The lnguge L cn be implemented on the finite stte mchine (FM) such tht ech stte in the FM corresponds to prticulr clss. FA contins minimum two sttes.. where the strings belonging to the clss C rech the finl stte nd 2. Other where the strings belonging to the clss C2 rech the non-finl stte. Thus, the lnguge L cn be implemented using FA. F ince L is regulr. imilrly consider lnguge L 2 over {, } such tht ll strings belonging to L 2 wnd with. ll the string clssified into 5-clsses. Clss C: string length less thn 2 I.e.,,. Clss C2: those ending with. Clss C3: those ending with. Clss C4: those ending with. Clss C5: those ending with. q q since L 2 is regulr If the number of equivlent clsses over lnguge L is finite then the lnguge L is regulr. This sttement is refered to s Myhill- Nerode theorem. L 3 = { n n n>} to recognize this mchine should be ble to remember how mny s it hs seen nd if the no. of s is exctly the sme s tht of number of s. However, the FM is devoid of ny kind of memory the count nd mtch it q f

24 with the count. the no. of equivlent clsses generted by the lnguge L 3 over {,} * is infinite, with ech clss corresponding to number of s on ny string. ince the number equivlent clsses re not finite, ccording to Myhill-Nerode theorem, the lnguge L 3 is not regulr. Consider lnguge L 4 = {w w is plindrome over {,b}}. Now, the recursive definition of plindrome over {, b} is s follows: - is plindrome is plindrome b is plindrome if string x is plindrome then x, bxb re plindromes. To recognize L 4, mchine should be ble to mrk the middle of the string nd mtch the symbols on the both sides of the middle. FM hs no memory, so counting is n t possible. nother possible mechnism is to crete clss corresponding to the string before the middle of the input string nd to mtch this clss with the clss of the reverse string fter the middle. if they re sme then the string is plindrome. Otherwise, it is not. However the number of possible clsses for the string before the middle is infinite; hence the lnguge L 4 cn not be implemented on finite utomton nd hence, is not regulr. L 5 = {ww w is string over {.} is not regulr} becuse the lnguge L 5 belongs to the sme group s the lnguge L 4. L 6 over Σ = {,, 2, 3, 4, 5, 6, 7, 8, 9}; string w over Σ * belongs to L 6 if the number formed by w is divisible by 9. For exmple: 9, 8, 27,... re belongs to L 6, 2, 3,... rest does not belongs to L 6. Here string cn be divided into 9 equivlent clsses, with ech clss corresponding to reminder to 8. if reminder, then the string Current stte q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 belongs to L 6, otherwise it does not since the number of equivlent clsses. for L 6 is finite(9), the lnguge L 6 cn be implemented on the FM nd therefore L 6 is regulr. Input ymbol q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 q q q 2 q 3 q 4 q 5 q 6 q 7 q 8 Minimiztion of Finite Automt: Definition: Two stte q nd q 2 re equivlent ( denoted by q q 2 ). if both δ(q, x) nd δ(q 2, x) re finl sttes or both of them re non finl stte for ll x Σ *. As it is difficult to construct δ(q, x) nd δ(q 2, x) for ll x Σ * becuse there re n infinite number of strings in Σ *. Definition: Two sttes q nd q 2 re k-equivlent( k ) if both δ(q, x) nd δ(q 2, x) re finl sttes or both non finl sttes for ll strings x of length k or less. Exmple: Current tte Input tte b q q (N) q 4 (N) q q 5 (N) q f (F) q 2 q f (F) q 5 (N) q 3 q 6 (N) q 4 (N) q 4 q f (F) q 5 (N) q 5 q 5 (N) q 3 (N) q 6 q 5 (N) q f (F) q (N) q f (F) q f ) -level equivlence: The only string with length zero i.e., if is pplied on ny stte q i remins on the sme stte q i. if is pplied in stte q f we get finl stte.

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun: CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Automata and Languages

Automata and Languages Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model? CS125 Lecture 11 Fll 2016 11.1 Finite Automt Motivtion: TMs without tpe: mybe we cn t lest fully understnd such simple model? Algorithms (e.g. string mtching) Computing with very limited memory Forml verifiction

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!) CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata CSC4510 AUTOMATA 5.1 Definitions nd Exmples 5.2 Deterministic Pushdown Automt Definitions nd Exmples A lnguge cn be generted by CFG if nd only if it cn be ccepted by pushdown utomton. A pushdown utomton

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

More information

Thoery of Automata CS402

Thoery of Automata CS402 Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

More information

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

State Minimization for DFAs

State Minimization for DFAs Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir CSCI 2400 Models of Computtion, Section 3 Solutions to Homework 4 Problem 1. ll the solutions below refer to the Pumping Lemm of Theorem 4.8, pge 119. () L = f n b l k : k n + lg Let's ssume for contrdiction

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

1 Structural induction

1 Structural induction Discrete Structures Prelim 2 smple questions Solutions CS2800 Questions selected for Spring 2018 1 Structurl induction 1. We define set S of functions from Z to Z inductively s follows: Rule 1. For ny

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

More on automata. Michael George. March 24 April 7, 2014

More on automata. Michael George. March 24 April 7, 2014 More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3. Finite utomt nd regulr

More information

Java II Finite Automata I

Java II Finite Automata I Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression

More information

Worked out examples Finite Automata

Worked out examples Finite Automata Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will

More information

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion

More information

1 Structural induction, finite automata, regular expressions

1 Structural induction, finite automata, regular expressions Discrete Structures Prelim 2 smple uestions s CS2800 Questions selected for spring 2017 1 Structurl induction, finite utomt, regulr expressions 1. We define set S of functions from Z to Z inductively s

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

This lecture covers Chapter 8 of HMU: Properties of CFLs

This lecture covers Chapter 8 of HMU: Properties of CFLs This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

USA Mathematical Talent Search Round 1 Solutions Year 21 Academic Year

USA Mathematical Talent Search Round 1 Solutions Year 21 Academic Year 1/1/21. Fill in the circles in the picture t right with the digits 1-8, one digit in ech circle with no digit repeted, so tht no two circles tht re connected by line segment contin consecutive digits.

More information

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)

More information

Non-Deterministic Finite Automata

Non-Deterministic Finite Automata Non-Deterministic Finite Automt http://users.comlb.ox.c.uk/luke. ong/teching/moc/nf2up.pdf 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q1 q2 2 Alphbet ={} Two choices q1 q2 3 Alphbet ={} Two choices

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1 Non Deterministic Automt Forml Lnguges nd Automt - Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

State space systems analysis (continued) Stability. A. Definitions A system is said to be Asymptotically Stable (AS) when it satisfies

State space systems analysis (continued) Stability. A. Definitions A system is said to be Asymptotically Stable (AS) when it satisfies Stte spce systems nlysis (continued) Stbility A. Definitions A system is sid to be Asymptoticlly Stble (AS) when it stisfies ut () = 0, t > 0 lim xt () 0. t A system is AS if nd only if the impulse response

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

More information

Turing Machines Part One

Turing Machines Part One Turing Mchines Prt One Wht problems cn we solve with computer? Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges Tht sme drwing, to scle. All Lnguges The Problem Finite

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

Homework Solution - Set 5 Due: Friday 10/03/08

Homework Solution - Set 5 Due: Friday 10/03/08 CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.

More information

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

Deterministic Finite-State Automata

Deterministic Finite-State Automata Deterministic Finite-Stte Automt Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 12 August 2013 Outline 1 Introduction 2 Exmple DFA 1 DFA for Odd number of

More information

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

How to simulate Turing machines by invertible one-dimensional cellular automata

How to simulate Turing machines by invertible one-dimensional cellular automata How to simulte Turing mchines by invertible one-dimensionl cellulr utomt Jen-Christophe Dubcq Déprtement de Mthémtiques et d Informtique, École Normle Supérieure de Lyon, 46, llée d Itlie, 69364 Lyon Cedex

More information

Revision Sheet. (a) Give a regular expression for each of the following languages:

Revision Sheet. (a) Give a regular expression for each of the following languages: Theoreticl Computer Science (Bridging Course) Dr. G. D. Tipldi F. Bonirdi Winter Semester 2014/2015 Revision Sheet University of Freiurg Deprtment of Computer Science Question 1 (Finite Automt, 8 + 6 points)

More information

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers 80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input

More information

SOLUTIONS FOR ADMISSIONS TEST IN MATHEMATICS, COMPUTER SCIENCE AND JOINT SCHOOLS WEDNESDAY 5 NOVEMBER 2014

SOLUTIONS FOR ADMISSIONS TEST IN MATHEMATICS, COMPUTER SCIENCE AND JOINT SCHOOLS WEDNESDAY 5 NOVEMBER 2014 SOLUTIONS FOR ADMISSIONS TEST IN MATHEMATICS, COMPUTER SCIENCE AND JOINT SCHOOLS WEDNESDAY 5 NOVEMBER 014 Mrk Scheme: Ech prt of Question 1 is worth four mrks which re wrded solely for the correct nswer.

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

Finite Automata Part Three

Finite Automata Part Three Finite Automt Prt Three Hello Hello Wonderful Wonderful Condensed Condensed Slide Slide Reders! Reders! The The first first hlf hlf of of this this lecture lecture consists consists lmost lmost exclusively

More information