First Midterm Examination
|
|
- Cora Lamb
- 5 years ago
- Views:
Transcription
1 Çnky University Deprtment of Computer Engineering 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 the following DFA recognize? Descrie verlly q 0 q q 2 q 3 q 4 3) Let A e lnguge over Σ = {0, }. A = {w w ends with or 000}. ) Find n NFA tht recognizes A. ) Find n NFA tht recognizes A. 4) Find the regulr expression equivlent to the following NFA: ε q q 2 c d q 4 q 3 d 5) Show tht the lnguge A = {w w = w R } over Σ = {0, } is non-regulr. (Here, w R shows the reverse of the string w, for exmple 0 R = 0)
2 Answers ) q Strt c c c q c Reject,,c q c 2) Mny nswers re possile. Some of them, strting with the simplest re: Contins 0 nd ends with. Contins 0 nd 0 nd ends with. Contins t lest two symol chnges nd ends with. Contins t lest 3 symols,, 0 nd in this order (ut not necessrily consecutively) nd ends with. 3) 0, 0 0 0
3 0, ε 0 ε ε 0 0 4) GNFA: ε ε ε q q 3 q 2 d d c q 4 Eliminte q 4 nd q 2 : ε q q 3 c ε dd Eliminte q : q 3 ε Finlly: dd c (dd c ) So the nswer is: (dd c ) Other possile nswers re: [(dd) c ] (dd) or [(dd) (c ) ] 5) Suppose A is regulr. Let the pumping length e p. Choose w = 0 p 0 p. We know tht w = xyz nd xy p therefore y consists of zeros only. y = 0 k where k p. w = xyz A ut xyyz = 0 p+k 0 p / A for ny possile choice of y. So there is contrdiction. A is non-regulr y pumping lemm.
4 Çnky University Deprtment of Computer Engineering Fll Semester Second Midterm Exmintion ) Eliminte rules contining ε from the following grmmr: S AB 00A A BB 0 AB ε B B A 2) Give either PDA (pushdown utomton) or CFG (context free grmmr) for the lnguge { n m c m n n, m 0} over Σ = {,, c} 3) Let A = { n n+ c 4n n 0}. Show tht A is not context-free lnguge. 4) Descrie Turing mchine tht recognizes the lnguge A, given in question 3. 5) A Turing mchine with douly infinite tpe hs single tpe, ut its tpe is infinite to the left nd to the right. The tpe is initilly lnk except for the input. Show tht this is equivlent to n ordinry Turing mchine. Bonus) Give PDA (pushdown utomton) for the lnguge over Σ = {0, } mde of strings tht contin equl numers of 0 s nd s.
5 Answers ) S AB 00A B 00 A BB 0 AB B B B A 2) S S T T T c ε OR, ε, ε ε, ε $ ε, ε ε q q 2 q 3 ε, ε ε q 6 ε, $ ε q 5 ε, ε ε q 4, ε c, ε
6 3) Suppose A is context free. Let p e the pumping length. Choose w s w = p p+ c 4p. How cn we choose v nd y such tht p p+ c 4p = uvxyz? ) They contin more thn one symol. In this cse, the pumped string uv 2 xy 2 z will hve symols out of order. For exmple, it will contin s fter s. Therefore uv 2 xy 2 z / A. 2) They contin single symol. In tht cse, we cn pump t most two of the symols {,, c}. The remining one will hve the sme power in the pumped string. For exmple, if we choose v = nd y = we otin uv 2 xy 2 z = n+ n+2 c 4n / A Therefore we cnnot pump this string. By pumping lemm, A is not context free. 4). Sweep from left to right. IF ny symol is out of order (for exmple, s fter s) REJECT. 2. Go to strt. Serch for. IF found, cross it. (Replce y ) ELSE, Go to Serch for. IF found, cross it. ELSE, REJECT. 4. Repet 4 times: Serch for c. IF found, cross it. ELSE, REJECT. 5. Go to Sweep from left to right. IF there is one nd only one AND there is no c, ACCEPT. ELSE, REJECT.
7 5) We cn divide the doule tpe into two prts: positive nd negtive. Then, we cn mp it into norml Turing tpe y zig-zgging nd plcing positive squres to odd squres nd negtive squres to even squres s follows: { 2n n > 0 f(n) = 2n n < 0 OR Doule Tpe Norml Tpe We cn use the multi-tpe ide for doule tpe nd seprte the contents y #: Doule Tpe Norml Tpe n # 2 Note tht in this cse the # moves s the progrm proceeds. Bonus) 0, ε 0, 0 ε q 3 0, ε 0 ε, $ ε ε, ε 0, $ $ ε, ε $ q q 2 q 5 q 6 q ccept, ε 0, $ $ ε, ε ε, $ ε q 4, ε 0, ε Stte q 3 : Up to now, more 0 s thn s rrived. Stck contins 0 s. Stte q 4 : Up to now, more s thn 0 s rrived. Stck contins s.
8 Çnky University Deprtment of Computer Engineering Fll Semester Finl Exmintion ) Find n equivlent DFA for the following NFA:, q q 2 q 3 q 4 2) Give CFG tht genertes the following lnguge over Σ = {0, }: {w w is of odd length nd contins more 0 s thn s.} 3) Define the lnguge L s: A, k where A is n NFA, k is n integer nd A rejects ll strings of length k. Show tht L is decidle. (Hint: Give TM for L tht hlts) 4) Let A = the set of ll integer coefficient polynomils. B = the set of ll functions f : N N. C = the set of ll infinite strings on Σ = {0,, 2}. Choose one of these sets. Clim tht it is countle or uncountle. Prove your clim. 5) TS (Trveling Slesmn) PROBLEM: Given n cities, nd distnces d(i, j) etween them, wht is the minimum distnce of pth tht visits ech city once? HAMPATH (Hmiltonin Pth) PROBLEM: Given grph G, is there pth tht goes through ech node exctly once? ) Reformulte the TS prolem s Yes/No prolem. Cll it TS2. ) Given tht the HAMPATH prolem is NP-complete, show tht TS2 is NP-complete.
9 Answers ) q q 2 q 23 q 34 q 234, 2) S T 0T T 0T T 0 0T 0 T T ε 3). Simulte A on the TM. 2. Mrk strt stte. 3. For i = to k Mrk ll sttes tht cn e reched from mrked sttes in one step. If n ccept stte is mrked, Return REJECT. EndFor 4. Return ACCEPT. Another ide (tht is d style ut still works) is to mke list of ll strings of length k, give them one y one to our simultion of A nd reject if it ccepts ny one of them.
10 4) ) The set {...,, 0,, 2,...} is countle. Therefore there re countly mny 0 terms in the polynomil. Similrly, there re countly mny x terms. In tht wy, we hve to find countle union of countle sets which is countle. We cn count them in the sme wy we counted rtionl numers, y counting n infinite mtrix. ) We cn think of ech function s n infinite string. The set of such strings is uncountle. If we ssume there is list, we cn generte n element tht is not on the list using Cntor s digonl ide. This contrdicts the ssumption tht the list contins everything. This is the sme ide we used in proving uncountility of rel numers on [0, ]. c) The sme s ). 5) ) TS2 (Trveling Slesmn) PROBLEM: Given n cities, nd distnces d(i, j) etween them, nd positive numer k, is there pth tht visits ech city once nd hs length k? ) We hve to show tht HAMPATH P TS2 Suppose we cn solve ny TS2 prolem. Given HAMPATH prolem, trnsform it into TS2 s follows: If there is connection etween vertex i nd vertex j, set d(i, j) =. If there is no connection etween vertex i nd vertex j, set d(i, j) = 0. Set k = n (numer of vertices) If TS2 finds pth of length n (ctully, we hve length = n) it is the one we re looking for. Clerly, this reduction is of polynomil type.
11 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK Give the stte digrm of DFA or n NFA tht recognizes the lnguge A over lphet Σ = {0, } where A = {w w strts with 0 nd hs odd length, or strts with nd hs length t most 5} NFA: 0, q 0 q 2 q 3 0, 0, 0, 0, 0, q 4 q 5 q 6 q 7 q 8 DFA: 0, q 0 q 2 q 3 0, 0, 0, 0, 0, 0, 0, q 4 q 5 q 6 q 7 q 8 q 9
12 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK Give the stte digrm of DFA or n NFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w = } NFA: q q 2 DFA:, q q 2 q 3
13 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 2 Let A nd B e lnguges over Σ = {0, }. A = {w w contins } B = {w w does not contin 000} Give the stte digrm of n NFA tht recognizes A B. 0 0, strt ε q q 2 q 3 0 0, ε r r 2 r 3 r 4
14 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 2 Let A nd B e lnguges over Σ = {0, }. A = {w w contins 00} B = {w w contins even numer of zeros} Give the stte digrm of n NFA tht recognizes A B. 0 0, 0 0 ε 0 q q 2 q 3 q 4 q 5 q 6 0 A B
15 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 3 Let Σ = {, }. A lnguge is descried y the regulr expression: (Σ Σ ) ) Give string tht is in this lnguge. ) Give string tht is NOT in this lnguge. c) Give n NFA tht recognizes this lnguge. ) or or or ) or or c),, ε ε
16 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 3 Let Σ = {0, }. A lnguge is descried y the regulr expression: (ε 000 )(0) ) Give string tht is in this lnguge. ) Give string tht is NOT in this lnguge. c) Give n NFA tht recognizes this lnguge. ) 000 or or 0000 or 000 ) or 0000 or 0 or. c) 0 ε 0 0 0
17 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 4 Give CFG generting the following lnguge over Σ = {0, }: {w w is of even length nd strts nd ends with the sme symol.} S 0A0 A ε A 00A 0A 0A A ε
18 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 4 Give CFG generting the following lnguge over Σ = {0, }: {w w is of odd length nd contins t lest two 0 s.} S A0A0A A0B0B B0A0B B0B0A A 0B B B ε 00B 0B 0B B (Here, A is ny string of odd length nd B is ny string of even length.)
19 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 5 Give PDA (pushdown utomton) tht recognizes the lnguge { n 2n n 0} over Σ = {, }., ε ε, ε $ ε, ε ε ε, $ ε, ε, ε ε
20 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 5 Give PDA (pushdown utomton) tht recognizes the lnguge { 2n n n 0} over Σ = {, }., ε ε, ε $ ε, ε ε ε, $ ε, ε ε, ε
21 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 6 Let A = { n! n 0}. Use pumping lemm to show tht A is not context-free lnguge. Let the pumping length e p. Choose the string s s = p!. Now divide into five prts s s = uvxyz. Any choice for v nd y consist of s only. We know tht therefore Clerly, therefore vxy p uv 2 xy 2 z p! + p p! + p < (p + )! uv 2 xy 2 z (p+)! uv 2 xy 2 z / A So we cnnot pump this string.
22 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 6 Let B = { n2 n 0}. Use pumping lemm to show tht B is not context-free lnguge. Let the pumping length e p. Choose the string s s = p2. Now divide into five prts s s = uvxyz. Any choice for v nd y consist of s only. We know tht therefore Clerly, therefore vxy p uv 2 xy 2 z p 2 + p p 2 + p < (p + ) 2 uv 2 xy 2 z (p+)2 uv 2 xy 2 z / A So we cnnot pump this string.
23 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 7 Give description of Turing mchine M tht, given n input from {0,, #}, elimintes ll # s. For exmple, given input 0#0#0, the tpe should contin 000 when M hlts.. Move right until meeting the first #. If there is no #, ccept. 2. Move right, red symol, move left, write symol, move right. (This moves one symol one unit left, the symol could e 0,, # or lnk). 3. If symol is lnk, go to 4. Else, go to 2. (This moves ll symols to the right of # one unit left). 4. Move the hed to the strt nd go to.
24 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 7 Give description of Turing mchine M tht, given n input from {}, doules the numer of symols. For exmple, given input, the tpe should contin when M hlts.. If the first symol is lnk, ccept. If it is, put mrk on it nd move right. Put mrk on ll s until meeting lnk. 2. Move left until meeting the first (mrked ). Erse the mrk. If there s no mrked, ccept. 3. Move right until meeting lnk. Replce lnk with. 4. Go to 2., R L R, R, R, L q q 2 q 3 q 4, R, L R q ccept (Here, denotes the very first )
25 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 8 Let E DF A = { A A is DFA nd L(A) = }. In other words, A is DFA tht does not ccept ny string. Show tht E DF A is decidle lnguge. The following Turing mchine decides this lnguge. (Try to uild pth from ccept stte ckwrds to strt stte) On input A where A is DFA:. Mrk the ccept sttes of A. If there is no ccept stte, ACCEPT. 2. Repet until no new sttes get mrked: 3. If stte hs n rrow pointing to mrked stte, mrk it. 4. If strt stte is mrked, REJECT; otherwise, ACCEPT.
26 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 8 Let E CF G = { G G is CFG nd L(G) = }. In other words, G is CFG tht does not generte ny string. Show tht E CF G is decidle lnguge. The following Turing mchine decides this lnguge. (Try to uild pth from terminls ckwrds to S) On input G, where G is CFG:. Use Chomsky form. Mrk ll terminl symols. If there is no terminl, ACCEPT. 2. Repet until no new vriles get mrked: 3. Mrk ny vrile A if there is rule A, OR if there is rule A BC nd oth B nd C re mrked. 4. If S is not mrked, ACCEPT; otherwise, REJECT.
27 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 9 The VERTEX COVER prolem is defined s: Given grph nd n integer k, is there collection of k vertices such tht ech edge is connected to one of the vertices in the collection? Is VERTEX COVER in NP? Given solution, we cn verify it in polynomil time y the following method: INPUT A totl of n vertices, list of k vertices (cover), list of l edges. For i = to k For j = to l If vertex i is connected to edge j Mrk edge j EndIf EndFor EndFor For j = to l If edge j is unmrked Return REJECT EndIf EndFor Return ACCEPT We know tht k n nd l n(n )/2 so this lgorithm tkes O(n 3 ) + O(n 2 ) = O(n 3 ) time, i.e. polynomil time. Therefore VERTEX COVER is in NP. Note: We ssume connection etween vertices cn e checked in O() opertion.
28 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 9 The COLORING prolem is defined s: Given grph nd n integer k, is there wy to color the vertices with k colors such tht djcent vertices re colored differently? Is COLORING in NP? Given solution, we cn verify it in polynomil time y the following method: INPUT A list of n vertices with ech one hving one of k colors, list of l edges. For i = to n For j = i + to n If vertex i is connected to vertex j AND Color(i)==Color(j) Return REJECT EndIf EndFor EndFor Return ACCEPT This lgorithm tkes O(n 2 ) time, i.e. polynomil time. Therefore COLORING is in NP. Note: We ssume connection etween vertices cn e checked in O() opertion.
29 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 0 INDEPENDENT SET prolem: Given grph G nd n integer k, is there suset S of k vertices such tht no two vertices in S re connected? (All vertices re independent) VERTEX COVER prolem: Given grph G nd n integer k, is there suset S of k vertices such tht every edge hs t lest one endpoint in S? Show tht INDEPENDENT SET P VERTEX COVER Suppose we hve n lgorithm tht decides VERTEX COVER in polynomil time. INPUT A grph G with n vertices, n integer k. VERTEXCOVER(G, n k) // If reject, reject, if ccept, ccept. (Note tht, if there is vertex cover of n k elements, the remining k elements form n independent set. )
30 Çnky University Deprtment of Computer Engineering Nme-Surnme: CLASSWORK 0 PARTITION Prolem: Given finite set of integers, determine if it cn e prtitioned into two sets such tht the sum of ll integers in the first set equls the sum of ll integers in the second set. SUBSET SUM Prolem: Given set of integers nd numer k, determine if there is suset of these integers whose sum is k. Show tht PARTITION P SUBSET SUM Suppose we hve n lgorithm tht decides SUBSET SUM in polynomil time. INPUT A set S of integers, n integer k. Add ll elements of S. Cll the result TOTAL. If TOTAL is odd Return REJECT else SUBSETSUM(S, T OT AL/2) // If reject, reject, if ccept, ccept. EndIf Prepred y: Dr. Emre Sermutlu (204)
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 informationAssignment 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 informationHarvard 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 informationFormal 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 informationTalen 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 informationRevision 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 informationConvert 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 informationHomework 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 informationAUTOMATA 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 information1.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 informationRegular 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 informationHomework 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 information1. 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 informationCS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018
CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA
More information1 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 informationCS375: Logic and Theory of Computing
CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks
More informationName 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 informationLecture 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 informationWorked 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 informationCSCI FOUNDATIONS OF COMPUTER SCIENCE
1 CSCI- 2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2015 My 7, 2015 2 Announcements Homework 9 is due now. Some finl exm review problems will be posted on the web site tody. These re prcqce problems not
More informationTheory 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 informationChapter 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 informationNondeterminism 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 informationGrammar. 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 informationLet'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 informationCMPSCI 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 informationTheory 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 informationClosure 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 informationFinite 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 informationMinimal 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 informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES nd REGULAR EXPRESSIONS TUESDAY Jn 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w hs equl numer of
More informationFormal 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 informationNFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.
NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD
More informationCS 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 informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS
The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook
More informationIntermediate 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 informationCS 275 Automata and Formal Language Theory
CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)
More informationChapter 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 information1 From NFA to regular expression
Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work
More information1.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 informationCHAPTER 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 informationDeterministic 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 informationDesigning 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 informationFinite 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 information1. 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 informationCS 330 Formal Methods and Models
CS 330 Forml Methods nd Models Dn Richrds, section 003, George Mson University, Fll 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 7 1. Prove (p q) (p q), () (5pts) using truth tles. p q
More informationHomework 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 information5. (±±) Λ = 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 informationCS 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 informationCHAPTER 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 informationScanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:
Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes
More informationCMSC 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 informationCS375: 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 informationThe University of Nottingham
The University of Nottinghm SCHOOL OF COMPUTR SCINC AND INFORMATION TCHNOLOGY A LVL 1 MODUL, SPRING SMSTR 2004-2005 MACHINS AND THIR LANGUAGS Time llowed TWO hours Cndidtes must NOT strt writing their
More informationNormal Forms for Context-free Grammars
Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S
More informationFor 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 information12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014
CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple
More information12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016
CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple
More informationCSCI 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 informationCompiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite
More informationRegular 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 informationContext-Free Grammars and Languages
Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;
More informationCoalgebra, 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 informationCSC 473 Automata, Grammars & Languages 11/9/10
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is
More informationCS 330 Formal Methods and Models
CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q
More informationFinite-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 informationCS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS
CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)
More informationLexical 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 informationNon-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 informationCS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power
CS411-2015S-12 Turing Mchine Modifictions 1 12-0: Extending Turing Mchines When we dded stck to NFA to get PDA, we incresed computtionl power Cn we do the sme thing for Turing Mchines? Tht is, cn we dd
More informationMyhill-Nerode Theorem
Overview Myhill-Nerode Theorem Correspondence etween DA s nd MN reltions Cnonicl DA for L Computing cnonicl DFA Myhill-Nerode Theorem Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute
More informationTypes 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 informationFinite 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 informationCS415 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 informationAutomata 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 informationCSC 311 Theory of Computation
CSC 11 Theory of Computtion Tutoril on DFAs, NFAs, regulr expressions, regulr grmmr, closure of regulr lnguges, context-free grmmrs, non-deterministic push-down utomt, Turing mchines,etc. Tutoril 2 Second
More informationTutorial 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 informationRecursively Enumerable and Recursive. Languages
Recursively Enumerble nd Recursive nguges 1 Recll Definition (clss 19.pdf) Definition 10.4, inz, 6 th, pge 279 et S be set of strings. An enumertion procedure for Turing Mchine tht genertes ll strings
More informationThis 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 informationTypes 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 informationLinear Inequalities. Work Sheet 1
Work Sheet 1 Liner Inequlities Rent--Hep, cr rentl compny,chrges $ 15 per week plus $ 0.0 per mile to rent one of their crs. Suppose you re limited y how much money you cn spend for the week : You cn spend
More informationFABER 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 informationJava 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 informationBases for Vector Spaces
Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything
More informationNon-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 informationConverting Regular Expressions to Discrete Finite Automata: A Tutorial
Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert
More informationThoery 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 informationPart 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages
Automt & lnguges A primer on the Theory of Computtion Lurent Vnbever www.vnbever.eu Prt 5 out of 5 ETH Zürich (D-ITET) October, 19 2017 Lst week ws ll bout Context-Free Lnguges Context-Free Lnguges superset
More informationTable 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 informationset is not closed under matrix [ multiplication, ] and does not form a group.
Prolem 2.3: Which of the following collections of 2 2 mtrices with rel entries form groups under [ mtrix ] multipliction? i) Those of the form for which c d 2 Answer: The set of such mtrices is not closed
More informationCS 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 informationState 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 information11.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 informationNon-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 informationCS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6
CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized
More informationNFAs 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 informationExercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.
1 Exercises Chpter 1 Exercise 1.1. Let Σ e n lphet. Prove wv = w + v for ll strings w nd v. Prove # (wv) = # (w)+# (v) for every symol Σ nd every string w,v Σ. Exercise 1.2. Let w 1,w 2,...,w k e k strings,
More informationGNFA GNFA GNFA GNFA GNFA
DFA RE NFA DFA -NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with in-egree, n unique finl stte with
More informationCS 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 informationAutomata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.
Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent
More information