1 Exercises about introductory part

Size: px
Start display at page:

Download "1 Exercises about introductory part"

Transcription

1 1 Exercises out introductory prt 1. Pigeonhole Principle sys: If you hve more pigeons thn pigeonholes, nd ech pigeon ies into some pigeonhole, then there must e t lest one hole tht hs more thn one pigeon. Wht hppens, if you hve s mny pigeonholes s there re nturl numers, nd s mny pigeons, s there re integers? Wht out, if you hve s mny pigeons s there re nturl numers, ut ech pigeon tries to mke nest with every other pigeon into dierent hole? (Only one nest cn e mde into one hole.) 2. There is coming n innite numer of usses, with innite numer of people in ech of them. How would you llocte the guests into rooms of Hilert's Hotel? 3. In the quest ook of Hilert's Hotel there is only nite numer of nmes in ech pge nd new quests must lwys write their nmes into the next empty line. How mny pges there must e in the ook so tht there is room for the new nmes (without reorgnizing the nmes) s long s there is room in the hotel (mye fter reorgnizing)? 4. In the Cntor's plnet everything is mesured with innite precision. Ech inhitnt hs unique nme, which consists of innite string in lphet {, }. Inhitnts... nd... hve decided to rrnge group tour to Hilert's Hotel, nd they hve invited ll inhitnts whose nmes re in lphetic order etween their own nmes. For exmple...'s little sister... nd...'s cousin's son... re invited. Cn you ccommodte everyody into Hilert's Hotel? Justify your nswer crefully! (Hint: Cntor's digonliztion method.) 5. Find the error in the following proof tht 2 = 1. Consider the eqution =. Multiply oth sides y to otin 2 =. Sutrct 2 from oth sides to get 2 2 = 2. Now fctor ech side, ( )( + ) = ( ), nd divide ech side y ( ), to get + =. Finlly, let nd equl 1, which shows tht 2 = Let X e set nd X the size of n = X. Prove y induction tht the size of the powerset of X is P(X) = 2 n. 1

2 7. Wht is wrong in the following induction proof tht ll cts re of the sme colour? Let n e the numer of cts. If n = 1 the clim holds clerly (one ct is lwys of the sme colour). Let's now suppose tht for ny group of n cts the clim holds. Then let's consider group of n + 1 cts. By selecting ny n cts from this group (which cn e done in n + 1 dierent wys) we get y the induction ssumption group in which ll the cts hve the sme colour. So ll n + 1 cts must e of the sme colour. 8. Prove the following clim. If there re n(n 2) people in the prty, then t lest two people hve equl numer of friends in the prty. 9. Prove y contrposition: If c is n odd integer numer, then the eqution n 2 + n c = 0 doesn't hve ny integer solution for n. 10. Construct decision prolem, which cn e used for evluting the diculty of the following computtionl prolem! () Clculte fctoril of n, n!, when n is nturl numer. () Order given word list into lphetic order. (c) Serch from given grph ll cliques i.e. such vertex sets tht there is n edge etween ll vertices in the set. Consider lso, how to code the input of decision prolem s string. Wht is the corresponding forml lnguge like? 11. Invent exmples out non-computtionl prolems! Could you still use computers somehow to help in solving the prolem? 12. Red the story out decision prolems nd complete it! 13. Let's consider the logic school of Kissstn gin. This time the topic is more complicted MIAU-system, which consists of the following rules: xuax xauy xuux xiuy 2

3 x MxM x xui xx x xi xua The tsk is to show tht even n empty string cn crete proper miow (MIAU) y the rules of the system! 14. Let's consider lphet Σ = {m, i, u}. We dene the the powers of lphet in the following wy: Σ 0 = {ɛ} (empty string) Σ k+1 = Σ Σ k = {x Σ nd x Σ k }. E.g. Σ 1 = {m, i, u}, Σ 2 = {mm, mi, mu, im, ii, iu, um, ui, uu}. How mny items (words) does Σ n contin? Wht out the whole lnguge Σ = i=0? 2 Exercises out regulr lnguges 1. By the UNIX commn egrep (extended grep) you cn serch for ptterns in the text, which cn e dened s regulr expressions. The sic syntx of egrep is following: egrep <expression> <file>, in which the expression cn e list of chrcters in the rckets, e.g. [cd]: ny of the chrcters,, c, d (expression1)(expression2): conctention of two expressions (expression1) (expression2): either expression1 or expression2 (expression) : 0 or more times the expression (closure of the expression) \: empty string in the edge of word \B: empty string in the middle of word Notice! The expression might need single quottion mrks ('expression') More informtion y commnd mn egrep. Test the commnd egrep with input le 3

4 Wht kind of ptterns do you nd with the following commnd? egrep '(uu) (st) (iss) (oit) (ll)' esim.c Do you invent simpler commnd, which nds exctly the poem lines? 2. Construct n egrep-commnd to nd the following lines from esim.c: ) Rows, which consist numers. ) Rows, which consist either word while or for c) Rows, which consist numer 10 d) Rows, which consist integers. (Notice! Your commnd should not ccept desiml numers.) 3. Construct n egrep commnd for nding emil nd street ddresses nd telephone numers from html le. Use the homepges of Kissstn Logic School s your input dt ( 4. Let's consider the following lnguges of the lphet Σ = {, }. For ech of the lnguges give two strings tht re memeers nd two strings tht re not memeers! ) ) () c) d) () e) (ɛ ) f) Σ Σ Σ Σ 5. Which strings elong to the lnguge descried y the following expression? (c h m r)t((c t) (s t)o)ught(m l tw r)ice 6. Which strings elong to the lnguge L( )? Wht out L(ɛ )? 7. Find shortest string which elongs to the lnguge descried y the following expression! 4

5 ) ( ) ) ( () ) c) ( )( ) 8. Construct the regulr expressions corresponding the following lnguges: ) {w {, } the third lst chrcter of w is } ) {w {, } w contins either sustring or } c) {w {, } w does not cointin string } 9. Construct the regulr expressions corresponding the following lnguges: ) {w {, } w contins n even numer of chrcters } ) {w {, } the length of w is odd} c) {w {, } numer of chrcters is multiple of 3} 10. Let's hve lphet Σ = {, }. Construct nite utomton, which recognizes the following lnguge: ) L(M) = L( ) ) L(M) = L( ) c) L(M) = L(ɛ) d) L(M) = L(ɛ ) e) L(M) = L(Σ ) 11. Simulte the given nite utomton s gme! Ech student corresponds to one stte, which reds the next input chrcter nd trnsfers the control to the successor stte. Accepting or rejecting stte reports out result. (One point for ech prticipnt!) 5

6 W E Sim Suomenlhti 12. Construct lock utomton for chnnel, which opens nd closes the locks nd increses nd decreses the wter level utomticlly. The Western lock gte cn e opened only when the wter is up nd the Estern gte only when the wter is down. You cn control the wter level only when oth gtes re closed. The utomton gets the following input dt from the control system: WD = wter down WU = wter up SW = ship from West SE = ship from Est GC = gtes closed SL = ship in lock You my suppose tht etween the ships the lock utomton wits one gte open, until the next ship rrives. (Notice! The utomton doesn't hve ny specil initil or nl sttes.) 13. Crete nite utomton tht descries the function of lift moving etween two oors. The lift my e either up or down. On oth oors, there is simple "come here" utton, nd in the lift there is n "up" nd "down" utton. In ddition, the lift hs door tht cn e opened nd closed; the lift only moves if the door is closed. (The utomton does not hve to hve specic fvorle sttes.) Input: pushing the uttons, opening nd closing the door. Sttes: up/down; door open/closed. Nottion: U = up, D = down, o = door open, c = door 6

7 closed. 14. Let Σ = {0, 1}. Construct deterministic nite utomton M, which recognizes the following lnguge ) L(M) = {w the length of w is odd} ) L(M) = {w numer of 1s in w is multiple of three} c) L(M) = {w w hs even numer of 1s nd 0s} 15. Crete minimum utomton tht is equivlent to the following deterministic nite utomton. A B D C 16. Crete minimum utomton tht is equivlent to the following deterministic nite utomton. 7

8 Generting regulr lnguge: "The Poem Automt" Implement progrm tht cretes rows ccording to the regulr expression (the)(attr) SUBJ PRED the (ATTR) OBJ( ATTRIB ɛ) Lnguges ATTR, SUBJ, OBJ, PRED nd ATTRIB consist of the following words, for exmple: ATTR = {ft, lck} SUBJ = {ct, moon, sh} OBJ = {ct, moon, sh} PRED = {shines, wtches, swims} ATTRIB = {in the sky, in the lke} Your progrm cn now produce 'verses' like the following: The lck ct wtches the ft sh in the lke The moon swims in the sky NB! Specify tht not ll predictes my e followed y n oject (e.g. swims). Expnd the exmple s you wish with words tht t into the poem! Add the exclmtions "Wht (ATTR) (SUBJ)!" 8

9 nd the questions "Are you (ATTR) (SUBJ)?" Return the code of your progrm nd exmples of your outputs (poems) to the instructor! Be redy to represent your progrm/poems in the rt exhiition! 18. Let's consider the comic in the lecture mteril out nondeterministic utomton consulting the doctor. Which middle phses does the opertion consist of? Does everything go s it should? 19. Invent t lest one phenomenon in your everydy life, which cn e descried s nondeterministic utomton. Drw the trnsition digrm of your utomton nd try to determinize it! 20. Crete non-deterministic nite utomt tht tests whether lphet {, } contins the chrcter string "" nd mke it deterministic. 21. Trnform the following utomton to deterministic! Give nondeterministic nite utomt to ccept the following lnguges. Try to tke dvntge of nondeterminism s much s possile. ) The set of strings over lphet {0, 1,..., 9} such tht the nl digit hs ppered efore. ) The set of strings over lphet {0, 1,..., 9} such tht the nl digit hs not ppered efore. c) The set of strings over lphet {0, 1} such tht there re two 0's seprted 9

10 y numer of 1's tht is multiple of 4. Note tht 0 is n llowle multiple of Remove ll ɛ-trnsitions from the Golins' Gingerred utomton nd trnsform it to deterministic! (See Wht kind of lnguge does the Golins' Gingerred utomton recognize? Descrie the lnguge s regulr expression! 25. Give the regulr expressions corresponding the following utomt! () () 26. Construct the nite utomt corresponding the following regulr expressions! )() () )(( ) ) ) 27. Show tht the set of regulr lnguges is closed under cut nd ctention! I.e. if L 1 nd L 2 re regulr lnguges, then lso L 1 L2 nd L 1 L 2 re regulr. (Hint: utomt.) 28. Are the following lnguges regulr? Justify your nswer crefully! 10

11 () {w w is chrcter string of length 3 consisting of 's nd 's} () {ww w {, } } (c) {w there re s mny 1's s 0's in w (d) {w there re twice s mny 0's s 1's in w} 29. Wht hppens if you try to prove n ctully regulr lnguge s non-regulr y the Pumping Lemm? Consider for exmple lnguges L 1 =, L 2 = {, }, L 3 = { }. 30. Wht is wrong in the following Pumping lemm proofs? ) Let L = {() i () j i, j 0}. Clim: L is nonregulr. Proof: Let x = () n () k = 2n 2n, x = 4n. Now x cn e divided into prts uvw only in one wy: u = i, v = j, j 1, w = 2n i j 2n. Now uv 0 w = 2n j 2n / L, thus L is non-regulr. ) Let L = {c r k k r 1, k 0} { k l k, l 0}. Clim: L is regulr. Proof: L = L 1 L 2, in which L 1 = {c r k k r 1, k 0} nd L 2 = { k l k, l 0}. For ll x L either x L1 or x L2. Let's consider oth cses: 1) If x L 1, let's select x = c n k k. x = n + 2k > n. x cn e divided into prts uvw only in one wy: u = c i, v = c j, j 1, w = c n i j k k. Now uv k w L for ll k = 0, 1, 2,..., i.e. we cn lwys pump x. 2) If x L 2, let's select x = n l, x = n + l. x cn e divided into prts in only one wy u = i, v = j, j 1, w = n i j l. uv k w L for ll k = 0, 1, 2,... L is regulr. 31. We know tht in generl the prolem REG(L) (i.e. is the given lnguge L regulr or not) is unsolvle. Wht is the reson for tht? Could you still invent progrm, which would help people to prove y the Pumping Lemm tht the given lnguge is nonregulr? 32. The stronger version of the Pumping Lemm gives oth sucient nd necessry conditions for the regulrity of lnguge: 11

12 Pumping Lemm 2: The lnguge A Σ is regulr if nd only if there is constnt n 1 such tht for ll x Σ, if x n then there exists u, v, w such tht x = uvw nd v 1, nd for ll i 0 nd ll yinσ xy A if nd only if uv i wy A. Bsed on this, could you mke progrm, which decides for ny given lnguge A, if it is regulr or not? 33. Prove with the Pumping lemm tht the following lnguges re non-regulr: () { n n c k n, k = 0, 1,...} () { n k c k n, k = 0, 1,...} (c) { n n m m n, k = 0, 1,...} 34. Let's denote y w R the string w written ckwrds (i.e. if w = n, then w R = n ). The string is plindrome if w = w R (e.g. "mdmimdm"). Consider the plindrome lnguge L pl = {ww R w {, } }. Prove with the Pumping Lemm tht L pl is non-regulr! 35. Write progrm, which trnsforms simple HTML le into corresponding ltex le. HTML le <html><ody> text </ody></html> corresponds to ltex le \documentclss[4pper,12pt]{rticle} \egin{document} text \end{document}. Text contins only norml text nd title denitions. Title denitions <h1>title</h1>, <h2>title</h2>, <h3>title</h3> re generted in ltex y \section{title}, \susection{title} nd \sususection{title}. Is n ppliction sed on nite utomt powerful enough for checking, if the HTML le is lso correct? 36. How could you use regulr expressions nd nite utomt in prctice? Give t lest three pplictions! 37. Wht cn you sy out time requirements of prolems, which elong to the clss of regulr lnguges? Wht out their spce requirements? (Hint: Consider the progrm representtion of nite utomton.) Is there ny dierence if the corresponding utomton is deterministic or undeterministic? 12

13 3 Exercises out context-free lnguges 1. Let's hve context-free grmmr G = (V, Σ, P, S), V = {A, B, C, D, S} Σ, in which Σ = {Jim, ig, green, cheese, te}, nd rules P re: A B CA S ADA C ig green B cheese Jim D te Wht kind of strings elong to the lnguge descried y G? Give some exples! Do the following sentences elong to the lnguge L(G): ig ig green cheese, te Jim ig cheese? 2. Construct nite utomton, which recognizes the lnguge descried y the following grmmr. Wht is the corresponding regulr expression? S A B A S A B B ɛ 3. Give right-liner grmmr tht descries the lnguge L = {w {, } w does not contin sustring } 4. All words of the lnguge of outerspce liens follows the Blurs normlform. Blur is Whoozit, followed y one or more Whtzit. Whoozit is letter 'x', which cn e followed y ny numer of letters 'y' (lso zero). Whtzit is letter 'q', which is followed y either letter 'z' or 'd', followed y Whoozit. Give the context-free grmmr, which descries the Blurs lnguge. Cn you now give the corresponding regulr expression? (Hint: construct rst the utomton from the grmmr!) 5. For regulr expression holds the following rule:: If r = rs t, then r = ts, when ɛ / L(s). Show, why this rule holds with the help of context-free grmmrs! 13

14 6. Crete context-free grmmr tht produces progrmming lnguge expressions consisting of n innite numer of 'for' loops inside ech other nd elementry opertions, in the sme wy s in the exmple. for (i = N; i < N; i + +) { for (j=n; j<n; j++) { ; } } in which N is n integer. 7. Descrie the following type of C-progrms s context-free grmmr! the function tkes the form fcttype fctnme(prtype pr (,prtype pr) ) { fcttrunk } in which fcttype my e void or int nd prtype is int. fcttrunk is n ifexpression or ssignment the ssignment tkes the form vrile=vlue; pr nd the vrile re vrile nmes consisting of one letter the vlue is n integer the ifexpression tkes the form if (condition) ifexpression ssignment; or if (condition) ifexpression ssignment; else ifexpression ssignment; or n empty chrcter string the condition tkes the form (vrile=vlue) 8. Drw the following pushdown utomton M: M = ({q 0, q 1, q 2 }, {, }, {A}, δ, q 0, {q 1, q 2 }}, in which δ(q 0,, ɛ) = {(q 0, A)} δ(q 0, ɛ, ɛ) = {(q 1, ɛ)} 14

15 δ(q 0,, A) = {(q 2, ɛ)} δ(q 1, ɛ, A) = {(q 1, ɛ)} δ(q 2,, A) = {(q 2, ɛ)} δ(q 2, ɛ, A) = {(q 2, ɛ)} Wht kind of lnguge does M recognize? Trce ll computtion pths with input strings, nd! Does M ccept strings nd? 9. Write tht w R = the chrcter string w ckwrds (i.e. if w = n, then w R = n ). The chrcter string is plindrome if w = w R (e.g. "mdmimdm"). Consider the lnguge PAL = { w {, } w = w R }. tht is formed y plindromes in the lphet {, }. ) Give context-free grmmr, which produces the lnguge. ) Construct pushdown utomton, which recognizes the lnguge. 10. Crete context-free grmmr tht produces Romn numers tht re less thn 90. The numers re L=50, X=10, V=5, I=1. XII=12, for exmple, nd XIV=14, XL=40, XLIX=49. For thew ske of simplicity, you my ssume tht n empty chrcter string signies 0 nd the chrcter string LXL the numer Construct pushdown utomton, which recognizes the Romn numers tht re less thn 90, s descried in the previous tsk! 12. In the Logic school of Kissstn the current topic is context-free lnguges. In this clss the cts consider the following lnguge: One miow cn egin with one or more miu nd in the end there is equl numer of mu's. Between them cn e 0 or more u's. Or the miow is mow, which is followed y one or more u. Mow egins with miu or mu, which is followed y 0 or more u's. ) Give context-free grmmr, which produces the lnguge. ) Give some exmples words of this lnguge. c) Construct pushdown utomton, which recognizes this lnguge. 13. Wht kind of lnguge does the following pushdown utomton M recognize? M = ({q 0, q 1 }, {, }, {A, A 1, B, B 1, A, A 1, B, B 1 }, δ, q 0, {q 0 }) 15

16 δ(q 0,, ɛ) = {(q 1, A 1 )} δ(q 0,, ɛ) = {(q 1, B)} δ(q 1,, ɛ) = {(q 1, A 1 )} δ(q 1,, B) = {(q 1, B 1 )} δ(q 1,, B 1 ) = {(q 1, ɛ)} δ(q 1,, B) = {(q 1, B 1 )} δ(q 1,, A 1 ) = {(q 1, A)} δ(q 1,, A 1 ) = {(q 1, A)} δ(q 1,, ɛ) = {(q 1, B)} δ(q 1,, A) = {(q 1, ɛ)} δ(q 1,, A 1 ) = {(q 1, B 1 )} δ(q 1,, A 1 ) = {(q 1, B 1 )} 14. Show tht the following grmmrs re miguous! Cn you give n unmiguous grmmr which descries the sme lnguge? () S S SS ɛ () S S S ɛ 15. Construct grmmr which produces lnguge { m n c m+n m, n 0}. Is your grmmr miguous or unmiguous? 16. Wht does it mtter if lnguge is inherently miguous? 17. Show tht the following lnguges re context-free!: ){ m n m n} ){ m n c p d q m + n = p + q} c){uw u, w {, }, u = w } d){ m n n m 2n} 18. Let Σ = {m, i, u, }. Let's consider the grmmr: S miun mus SmiuA ɛ N miunmu U U uu ɛ A Au ɛ Give the leftmost nd the rightmost derivtion nd the prsing tree for the string 16

17 miumiuuumumumiumiuu! Is the grmmr unmiguous or miguous? 19. Does the following grmmr stisfy the LL(1) condition? S (L) p q L LndS LorS S Wht kind of lnguge does it decrie? 20. Give (s pseudocode) recursive prser for the lnguge descried y the previous grmmr. (N.B. Trnsform it rst to LL(1) if needed!) 21. Let L e lnguge, the words of which re constructed from ny text nd legl prntheses structures. I.e. s in the prolem 8, ut now there cn e text in the middle of prntheses. E.g. sentence (ig) ct niml (either lion or tiger {which re rre } or ser-toothed tiger {which extincts [red further Kurten ] shme } or leoprd) is n ttrctive (ut dngerous!) friend elongs to the lnguge. You cn suppose for simplisity tht the text prts consist of only lowercse letters..z nd spces. Give LL(1) grmmr, which descries the lnguge, nd design for it recursive prser! 22. Let's consider simple progrmming lnguge, in which ll progrms re of form egin SENTENCE; end. SENTENCE cn e simple ssignment VARI- ABLE:=FACTOR;, VARIABLE:=FACTOR+FACTOR; or VARIABLE:=FACTOR- FACTOR;, in which FACTOR is either vrile,..., z or unsigned integer. Or SENTENCE is while structure: while (CONDITION) do egin SENTENCE end. CONDITION compres two fctors with opertor <,<=,>,>=,==,<>. Construct grmmr for the lnguge nd descrie, how it is prsered recursively! 23. Crete context-free grmmr, which descries the polynoms of vrile x. For the ske of simplicity, you my ssume tht the coecients nd the exponents of the terms re integers of one digit nd tht the rst term is without prex. The terms do not hve to e in specic order, nd there my e temrs of the sme denomintion in the polynom. Give the derivtion trees of the following strings in your grmmr: 2 x 2 2 x + 1, x x x 2 3x, x, 5! Cn you construct recursive prser for the lnguge? 17

18 24. Write progrm which trnsforms HTML list structures into corresponding ltex lists. HTML lists re of form <ul>(<li>text)+</ul> nd <ol>(<li>text) + </ol> nd in ltex the corresponding lists re \egin{itemize}(\item text) + \end{itemize} j \egin{enumerte} (\item text) + \end{enumerte}. Notice tht there cn e severl nested lists! 25. Show tht the following lnguges re deterministic: ) { m n m n} ) {wcw R w {, } } c) { m c m } { m d 2m } 26. Trnsfor the grmmr S (S) A A SS ɛ into Chomsky norml form. Give lso the middle steps (removing ɛ-productions nd unit productions)! 27. Trnsfor the grmmr S ABC A A ɛ B B ɛ C cc c into Chomsky norml form. Give lso the middle steps! 28. Simulte the CYK-lgorithm, when it decides, if the strings, nd elong to the lnguge descried y the grmmr S AS A SA If the nswer is yes, give lso the corresponding prse tree. 29. Progrm the CYK lgorithm for grmmr S AB BC A BA B CC C AB Test your progrm with dierent strings! 18

19 30. How would you prse the following lnguge? It is enough to give the sic strtegy. ) HTML ) Cluses of propositionl logic, which consist of tomic cluses A, B,..., Z, opertions,,,,, nd prntheses. c) C- or Pscl-source code d) SQL-query 31. Let L 1 = { n 2n c m n, m o} nd L 2 = { n m c 2m n, m o}. Is L 1 L2 context-free lnguge? Justify your nswer! 32. Design n ecient lgorithm, which recognizes, if the given nonterminl symol is nullle (i.e. cn it produce ɛ in some derivtion)! 33. Prove tht context-free lnguges re closed under union, conctention nd closure. I.e. if L 1 nd L 2 re context-free, then ) L 1 L2 ) L 1 L 2 c) L 1 re context-free. (Hint: Suppose tht there exists pushdown utomt M(L 1 ) nd M(L 2 ) nd construct pushdown utomt for comined lnguges.) 34. Lnguge { n n c n n 0} cnnot e recognized y common pushdown utomton. Could it e recognized, if you hd two stcks ville? If it could, drw the trnsition digrm of the utomton nd simulte its ehviour! If not, then justify, why not! 35. Prove y the Pumping Lemm for context-free lnguges tht {ww w {, } } is not context-free! 36. Prove y the Pumpinh Lemm for context-free lnguges tht { p p is prime} is not context-free! 4 Exercises out Turing mchines 1. Simulte the ehviour of given Turing mchine s gme. (Your exercise techer will hve some trnsition digrms of dierent size of Turing mchines.) If there re enough students in the group, you cn mke competition 19

20 etween the mchines in recognizing lnguge. Ech student corresponds stte, performs required writing opertion on the tpe, moves the reding hed nd gives the control to the correct successor stte. The ccepting or rejecting nl stte reports the result. (One point for ech prticipnt of the gme!) 2. Wht does the following Turing mchine do? Simulte its ehviour with dierent input strings of s nd s! /A,R /, R /, R A/A,R B/B,R /,L /,L </A,L A/A,L B/B,L A/,R B/,R A/A,R B/B,R /,L /,L >/>,R </<,L /B,R </B,L /,R /,R A/A,R B/B,R </<,L 3. Construct Turing mchine, which reds the input string, until it nds two consecutice s. The input lphet is {, }. 4. Construct stndrd Turing mchine, which sutrcts one from the input inry string. I.e. n integer n is given s inry string x, in which the most signicnt its re left nd lest signicnt right (e.g. 8=1000). If n > 0, the 20

21 mchine replces x y the inry representtion of integer n 1. If n = 0, the tpe remins the sme, nd the mchine moves to the rejecting nl stte. 5. Construct Turing mchine, which divides the input numer represented s inry numer y two, if it is even. With odd numers the mchine trnsfers to the rejecting nl stte. The inry numers re represented ) the most signicnt it on right ) the most signicnt it on left 6. Construct stndrd Turing mchine, which recognizes the lnguge {ww R w {, } }. 7. Construct stndrd Turing mchine, which trnsform the string w into string ww R (w {, } ). 8. Construct stndrd Turing mchine, which recognizes the lnguge {w {, } w contins equl numer of 's nd 's}. 9. Construct stndrd Turing mchine, which lists ll words in lnguge 1 n, n = 0, 1,... The mchine egins with emty tpe, nd genertes unry numers 1, 11, 111, 1111,... (Notice! Your mchine will never hlt.) 10. Construct Turing mchine, which genertes inry representtions of ll nturl numers 0,1,00,01,10,11,000,001,... You cn represent the inry numers s the lest signicnt it on left. 11. Construct 2-tpe Turing mchine, which gets input string w {, } on its 1. tpe, nd writes string w R (=w in reversed order) onto 2. tpe. You cn use specil direction S=sty. 12. Construct 3-tpe Turing mchine, which clcultes it-nd opertion. Binry strings p nd q re given on the rst two tpes nd the mchine clcultes the result p&q onto thrid tpe. You cn ssume tht p nd q re of equl length. 13. Construct 3-tpe Turing mchine for multiplying unry numers. Unry presenttions of numers p nd q re given on the rst two tpes (e.g. p = 5 is coded s 11111) nd the mchine clcultes the unry presenttion of the 21

22 product n = p q onto third tpe. You cn use specil direction S=sty. How would you implement the sme with 1-tpe stndrd mchine? 14. Let's consider the following nondeterministic Turing mchine: M = ({q 0, q 1, q 2, q f }, {0, 1}, {0, 1}, δ, q 0, q f, q no ), whose trnsition digrm is dened s δ(q 0, 0) = {q 0, 1, R), (q 1, 1, R)} δ(q 1, 1) = {q 2, 0, L)} δ(q 2, 1) = {q 0, 1, R)} δ(q 1, <) = {q f, <, R)} Wht does the mchine do? Hint: simulte its ehviour with dierent inry strings. (You cn use JFLAP, if you wnt.) 15. Construct nondeterministic Turing mchine, which recognizes the lnguge {ww w {, } }. 16. Consider the nondeterministic Turing mchine TEST_COMPOSITE (look t the English mteril given to you), which recognizes composite numers. Could you mke prime tester mchine y chnging the ccepting nd rejecting sttes of the mchine? Justify your nswer! 17. Descrie (unformlly) nondeterministic Turing mchine, which recognizes the following lnguge: The words of the lnguge re of form w 1 #w 2 #...#w n for ny n such tht for ll i w i {, } nd for some j w j is the inry representtion of integer j. N.B.! Utilize the nondeterminism s much s possile, i.e. prefer much rnched ut short pths. (The mchine guesses the correct pth nondeterministiclly.) 18. Construct nondeterministic 2-tpe Turing mchine, which solves suset sum prolem. Fctors x 1,..., x n re given on the rst tpe, s unry numers, seprted y chrcter #, nd numer K is given on the second tpe s unry numer. The mchine should check if the rst tpe contins suset sum, which is K. E.g. in 1#1111#11 we cn nd suset sum K = 111. (I.e. we should select non-deterministiclly the fctors, which sum up to K, if such exist.) 22

23 19. Construct stndrd Turing mchine, which egins with empty tpe nd genertes s mny 1s s possile on its tpe efore hlting.(the mchine must hlt nlly!) The mchine cn e composed of t most 3 sttes nd the ccepting nl stte. 20. Give n unrestricted (or context-sensitive) grmmr, which produces lnguge L = { i 2i i i > 0}. Give the derivtion for string in the grmmr! 21. Chomsky thought tht nturl lnguge cn e descried y context-sensitive grmmrs, in which ll productions cn e represented in form: S ɛ or αaβ αωβ, in which A is non-terminl symol nd ω ɛ. Give some exmple of (syntctic) structure in nturl lnguge, which requires such context α_β! (You cn consider exmples in your own ntive lnguge, ut explin the feture lso in English.) Do you elieve tht ll structures of nturl lnguge cn e descried with context-sensitive grmmrs? 5 Exercises out solvility nd unsolvility 1. The Universl Turing mchine hs invited ll Turing mchines of the universum into Universl Truring Symposium, which is hold in Hilert's Hotel. The room reservtions hve een done with the codes c M of the Turing mchines. Is there enough rooms for ll Turing mchines, if there re no other guests in the hotel? How would you llocte the rooms? 2. Drw the Turing mchine descried y the following code! Wht re the codes of the following Turing mchines? () δ(q 0, 0) = (q 0, 0, R) δ(q 0, 1) = (q 0, 1, R) δ(q 0, <) = (q yes, <, L) () δ(q 0, 0) = (q 1, 0, R) δ(q 0, 1) = (q no, 1, R) 23

24 δ(q 0, <) = (q no, <, L) δ(q 1, 0) = (q yes, 0, R) δ(q 1, 1) = (q 0, 1, R) δ(q 1, <) = (q yes, <, L) 4. Write progrm, which gets trnsition function of Turing mchine s its input, nd outputs its code. You cn give the trnsition function in text le in the following form: on the 1. row the numer of sttes n (thus q no = q n ) nd on the following rows the trnsitions δ(q, ) = (q,, ) written s qq. 5. Simulte the ehviour of the universl Turing mchine, when it is given s its input c M w the code of the mchine in -prt of the previous tsk nd string 0101! 6. Construct nite utomton, which recognizes the legl codes of Turing mchines. Wht is the corresponding regulr expression? 7. Construct stndrd Turing mchine, which recognizes the legl codes of Turing mchines. 8. Let the lnguges A nd B e recursive enumerle. (i.e. there exists Turing mchines M A nd M B, which recognize the given lnguges nd hlt in Yescse, ut not necessrily in No-cse.) Prove tht lnguges A B nd A B re lso recursive enumerle i.e. you cn construct for them Turing mchines, which hlt t lest in Yes-cse for ll input strings! 9. Let A e recursive enumerle lnguge. Cn you construct Turing mchine for its complement lnguge A from the mchine M A y chnging the ccepting nd rejecting nl sttes? 10. Prove tht lnguge {c M M hlts on input ɛ} is recursive enumerle ut not recursive! I.e. invent for it Turing mchine, which hlts in Yes-cse, ut not necessrily in No-cse! 11. Give n exmple of Turing mchine, which ) ccepts its own code. ) does not ccept its own code. 24

25 12. Are the following properties of Turing mchines syntctic or semntic? If the property is syntctic, how it cn e solved? ) Fron M's initil stte there is t lest one trnsition with, which does not led to error stte. ) If M is strted with input, it trnsfers to rejecting stte. c) The computtion of M tkes with ny input t most 10 steps. d) M hs t most 10 trnsitions. e) From M's initil stte you cn get into the nl stte without writing nything. 13. Show tht the following semntic properties of recursive enumerle lnguges re nontrivil (trivil property holds for none or for ll lnguges). ) L contins string w. ) L is nite. c) L is regulr. d) L is {0, 1}. 14. Give two exmples of trivil properties: one, which doesn't hold for ny recursive enumerle lnguge nd the other, which holds for ll! 15. Which of the following properties of Turing mchines re solvle? (Hint: either invent n lgorithm ide or consider, if the property is semntic.) ) M hlts on ll even inry numers. ) If M is strted with empty input, it reches stte q on t most 10 steps, or if it is strted with input it reches stte p on t most 20 steps. c) M doesn't contin ny trnsition into stte q, in which it would write end chrcter <. d) Stte q cn e reched from stte p on t most 3 steps. e) M hs less thn 100 sttes nd M hlts on input We know tht for recursive reduction of prolems m holds: i) If A m B nd B is recursive enumerle, then A is recursive enumerle. i) If A m B nd B is recursive, then A is recursive. Is lnguge X recursive, recursive enumerle or totlly unsolvle in the following cses? 25

26 ) For universl lnguge U holds U m X. ) For lnguge H nd for n unknown recursive enumerle lnguge Y holds H m Y nd Y m X. (H = {c M w M hlts on input w}) c) For H's complement H holds H m X. d) For Hmiltonin Cycle -lnguge HC = {x x codes grph G, which contins Hmiltonin cy holds X m HC. e) HC m X N.B.! Rememer the contrposition rule: A B B A. 17. Prove tht the following property is unsolvle: Given code of Turing mchine c M, stte q nd input w. Does M enter y input w into stte q? 18. Are the following lnguges recursive, recursive enumerle or totlly unsolvle? ) L 1 = {c M The code of mchine M c M is plindrom}. ) L 2 = {c M c M is code of mchine M nd M recognizes ll plindroms in lphet {0, 1}}. (Denition of plindroms: Denote w = n, if n = n n , then w is plindrom.) 19. Are the following prolems solvle, prtilly solvle or totlly unsolvle? ) Does the given Turing mchine hlt on ll input? ) Does the given Turing mchine hlt on no input? c) Does the given Turing mchine hlt on t lest one input? c) Does the given Turing mchine fil to hlt on t lest one input? 20. The following prolems re known to e unsolvle, ut re they prtilly solvle or totlly unsolvle? ) Does the lnguge L(M) contin t lest two strings? ) Is L(M) nite? c) Is L(M) context-free lnguge? 1 Hmiltonin cycle=cycle, which goes through ll vertices exctly once. 26

27 21. Invent some concrete exmples of unsolvle prolems! (Other thn hlting prolem.) N.B.! Justify the unsolvility. Is the prolem prtilly solvle (i.e. recursive enumerle lnguge) or totlly unsolvle prolem? 22. Are the following prolems solvle or unsolvle? If they re unsolvle, tell if they re prtilly solvle or totlly unsolvle. If they re solvle, give the wekest type of mchine (nite utomton, pushdown utomton, Turing mchine), which solves the prolem! ) Give the integer nollkoht? for ritrry polynom 1 x n + 2 x n x + 0! ) Progrm for compiler n error checker, which gets s its input code of progrm nd checks tht the progrm doesn't perform division y 0 during it execution. c) Sech if the given text le contins either words ct nd lck or words ird nd white, ut not oth. d) Check tht in the given text le word niml is followed y word wise, only if word ct ppers in the sme sentence. e) Construct generl virus tester, which recognizes ll dngerous progrms i.e. such progrms, which cn chnge system les during their execution. 27

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

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

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

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

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

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

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

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

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

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

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

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

The 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 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

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

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

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

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

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

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

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

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

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

CS 275 Automata and Formal Language Theory

CS 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 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

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

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

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

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

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

Context-Free Grammars and Languages

Context-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 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

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

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

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

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

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

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

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

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

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

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes CSE 260-002: Exm 3-ANSWERS, Spring 20 ime: 50 minutes Nme: his exm hs 4 pges nd 0 prolems totling 00 points. his exm is closed ook nd closed notes.. Wrshll s lgorithm for trnsitive closure computtion is

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

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

Normal Forms for Context-free Grammars

Normal 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 information

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch. Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough

More information

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. 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 information

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

Exercises 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 information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.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 information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

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

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

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

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

CS 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 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

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

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

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

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

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

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

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

CSC 311 Theory of Computation

CSC 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 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

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.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 information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 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 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

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

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

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

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

The University of Nottingham

The 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 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

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15 Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll

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

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

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

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

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

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

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

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 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 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

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

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

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata 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

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

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler 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 information

CSCI FOUNDATIONS OF COMPUTER SCIENCE

CSCI 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 information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

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

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

Bases for Vector Spaces

Bases 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 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

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

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7 CS103 Hndout 32 Fll 2016 Novemer 11, 2016 Prolem Set 7 Wht cn you do with regulr expressions? Wht re the limits of regulr lnguges? On this prolem set, you'll find out! As lwys, plese feel free to drop

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 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

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

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

CSC 473 Automata, Grammars & Languages 11/9/10

CSC 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 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