{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw9 - ’9 Lumpy“ a LUI IlCAl‘I ‘EV\JI nuln...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ’9 Lumpy“ a LUI IlCAl‘I ‘EV: \JI nuln “I": (3) Build the derivation tree for the derivations in parts (a) and (b). d) Use set notation to define L(G). . Lethethegrarnmar S—ySABH A—)0A|0 3—4me. a) Give a leftmost derivation of 0bb00b. b) Give two leftmost derivations of 00. c) Build the derivation tree for the derivations in part (b). d) Give a regular expression for L(G). . Let DT be the derivation tree S AAB /\ /\ a A A B 1 1 I 0 0 b a) Give a leftmost derivation that generates the tree DT. b) Give a rightmost derivation that generates the tree DT. c) How many different derivations are there that generate DT? . Give the leftmost and rightmost derivations corresponding to each of the derivation trees given in Figure 3.3. For each of the following context-free grammars, use set notation to define the language generated by the grammar. a) SaaaSBIA d) SfiaSblA B—rbBlb AacAdcha' B-raBblab b)S—>0$bb|A e)S—>0.S‘BiaB AficAle Babblb C) S—tabdeA A—bL‘dAbflll Construct a grammar over {0, b, 0} whose language is {anbhcm In, in > 0}. 11mean in, Construct a grammar over {0, b, c} whose language is {a at :v 0}. . Construct a grammar over {0, b, c} whose language is {0"me I0 5 n + m 5 i}. -n—um-un- — — . Construct a grammar over {0, 17} whose language is {amb" | 0 5 n 5 m 5 3n}. . Construct a grammar over {0, b} whose language is {0”‘b‘0” { i = m + n}. . Construct a grammar over {0, b} whose language contains precisely the strings with the same number of 0’s and b’s. . Construct a grammar over {0, b} whose language contains precisely the strings of odd length that have the same symbol in the first and middle positions. For each of the following regular grammars, give a regular expression for the language generated by the grammar. a) S—>0A c)S—>0S{bA AeaAIbAlb A—rbB B—HIBIJL b) S—>0A d) SeaSleIA A—)0A|bB A-—>0A{bs B-+bB];t 'l Exercises 15 through 25, give a regular grammar that generates the described language. The set of strings over {0, b, c} in Which all the 0’s precede the 5’s, which in turn precede the e’s. It is possible that there are no 0’s, 17’s. or c’s. The set of strings over {0, b} that contain the substring 00 and the substring bb. " The set of strings over {0, b} in which the subslring 00 occurs at least twice. (Hint: . Beware of the substring 000.) The set of strings over {0, b} that contain the substring 0b and the substring £70. The set of strings over {0, b} in which the number of 0’s is divisible by three. The set of strings over {0, b} in which every 0 is either immediately preceded or immediately followed by b, for example, baab, aba, and b. _. The set of strings over {0, b} that do not contain the substring aha. _‘.'_ The set of strings over {0, b} in which the substn'ng 00 occurs exactly once. The set of strings of odd length over {0, b} that contain exactly two b’s. -_t The set of strings over {0, b, c} with an odd number of occurrences of the substring 0b. The set of strings over {0, b} With an even number of 0’s or an odd number of 17’s. The grammar in Figure 3.1 generates (b‘ab‘ab‘fi, the set of all strings with a positive, even number of 0’s. Prove this. . Prove that the grammar given in Example 3.2.2 generates the prescribed language. . Let G be the grammar S—+0Sb|B a—tbsw. Prove that L(G) = {0"b’” | 0 5 n < m}. . 5. Give the state diagram of a PDA M that accepts {afib‘fi | 0 5 j 5 i} with acceptance by empty stack. Explain the role of the stack symbols in the computation of M. Trace the computations of M with input aabb and aaaabb. 6. The machine M alt/A bAfit % brill g accepts the language L = {nibi | i a 0} by final state and empty stack. a) Give the state diagram of a PDA that accepts L by empty stack. b) Give the state diagram of a PDA that accepts L by final state. 7. Let L be the language {to e {(3, b}* | to has a prefix containing more b’s than a’s}. For example, baa, abba, abbaaa E L. but aab, aabbab 9! L. a) Construct a PDA that accepts L by final state. b) Construct a PDA that accepts L by empty stack. 8. Let M = (Q, E, l", 5, go. F) be a PDA that accepts L by final state and empty stack. Prove that there is a PDA that accepts L by final state alone. 9. Let M = (Q, E, F, 6, go, F) be a PDA that accepts L by final state and empty stack. Prove that there is a PDA that accepts L by empty stack alone. 10. Let L = {afibi 1 t" 2 0}. 3) Construct a PDA M1 with L(Ml) = L. b) Coastruct an atomic PDA M2 with L(Mz) = L. c) Construct an extended PDA M3 with L(M3) = L that has fewer transitions than M]. (:1) Trace the computation that accepts the string cab in each of the automata con- structed in parts (a), (b), and (c). 11. Let L = {elite-3“ | 1' z 0}. a) Construct a PDA M1 with L(Ml) = L. b) Construct an atomic PDA M2 with L(MZ) = c) Construct an extended PDA M3 with L(M3) = L that has fewer transitions than M1. d) Trace the computation that accepts the string aabbb in each of the antomata con- structed in parts (a), fb), and (c). 12. Use the technique of Theorem 7.3.1 to construct a PDA that accepts the language of the Greibach normal form grammar SaaABAIaBB A—ybAlb B—chlc. 13 Let G be a grammar in Greibach normal form and M the PDA constructed from G. Prove that if [(10, u. A] l— [qp A. w] m M. then there' is a derivation S => aw in G. This completes the proof of Theorem 7. 3. l. ' .LethethePDA Q = {tint 91, ‘12} “909 a, l) = {lim- All = {0. bl 8(th. b, A) 2 {[QI- 1]} F = {A} 3(91: b, A) = {[92, Al} F = {42} “42:17: A) = {[91, ll}- a) Give the state diagram of M. ' b) Give a set-theoretic definition of L(M). c) Using the technique from Theorem 7.3.2, build a context-free grannnar G that __ generates L(M). ' (1) Trace the computation of aabbbb in M. _ e) Give the derivation of aabbbb in G. LetM be the FDA in Example 7.1.1. . a) Trace the computation in M that accepts bbcbb. b) Use the technique from Theorem 1.3.2 to construct a grammar G that accepts L(M). c) Give the derivation of bbcbb in G. __ f. Theorem 7.3.2 presented a technique for constructing a grammar that generates the . language accepted by an extended PDA. The transitions of the PDA pushed at most two "£5: variables onto the stack. Generalize this construction to build grammars from arbitrary . extended PDAs. Prove that the resulting grammar generates the language of the PDA. Use the pumping lemma to prove that each of the following languages is not context- ' free. a) {at | k is a perfect square} b) {aibfcidi | t, j a 0} c) {teak}:i It a 0} Id) {a*‘bic"|0<i <j<k~<zi} e) {wwa | w e {0, b}*} f) The set of finite-length prefixes of the infinite string abaabcaabaaaab. . . ba"ba"+lb . . . . .. . a) Prove that the language L] = {ainic-l l 1'. j 2 0} is context-free. b) Prove that the language L; = {Oi-bica- | i, j Z O} is context-free. c) Prove that Lln L; is not context-free. - _ — _.... 'D“_D"' 19. a) Prove that the language L. = {a‘ bi old-l ti, j 2 0} is context-free. b) Prove that the language L2 = {ajblc‘dk | i, j, k 2 0} is context-free. c) Prove that LID L3 is not context-free. 20. Let L be the language consisting of all strings over {a, b} with the same number of (1’5 and b’s. Show that the pumping lemma is satisfied for L. That is. show Ihat every string 2 of length It or more has a decomposition that satisfies the conditions of the pumping lemma. 21. Let M be a PDA. Prove that there is a decision procedure to determine whether a) L(M) is empty. b) L(M) is finite. 0) LM) is infinite. * 22. A grammar G = (V, 2, P, S) is called linear if every rule has the form A—Hr 11—»qu where u, v e 2* and A, B e V. A language is called linear if it is generated by a linear grammar. Prove the following pumping lemma for linear languages. Let L be a linear language. Then there is a constant k such that for all z e L with length(z) 2: k, 2 can be written 2 = uvwxy With i) lengtMuvxy) 5 k, ii) lengthwx) > 0, and iii) uvlwxiy e L, fori 3 0. 23. a) Construct a DFA N that accepts a]! strings in {a, b}* with an odd number of a’s. b) Construct a PDA M that accepts {.93le l i 2 0}. c) Use the technique from Theorem 15.3 to construct a PDA M’ that accepts L(N) n L(M). (1) Trace the computations that accept cash in N, M, and M’. 24. Let G = (V, E. P, S) be a context-free grammar. Define an extended PDA M as follows: Q = {9'0} 5010,19 A) = {[90, 5]} E=EG 5010.1. A)={[¢on wllAfiwEP} F=EGUV 5(qn,a,a)={[qu,l]|aeE}. F=l40l Prove that L(M) = L(G). 25. Complete the proof of Theorem 7.5.3. ve that the set of contextLfi'ee languages is closed under reversal. -t L be a context-free language over 2‘. and a e 2. Define erfl(L) to be the set obtained y removing all occurrences of a from strings of L. The language err-“(D is the language with a erased. For example, if abab, bacb, an e L, then bb, herb, and A E erfl(L). Prove that era(L) is context-free. Hint: Convert the grammar that generates L to one u. generates areas). '- -e notion of a string homomorphism was introduced in Exercise 6.19. Let L be a context-free language over E and let I: :E“ —> 2* be a homomorphism. _) Prove that h(L) = {h(w) | w e L} is context-free, that is, that the context-free I languages are closed under homomorphisms. ) Use the result of part (a) to show that erflfL) is context~free. c) Give an example to show that the homomorphic image of a noncontext-free language ' may be context—free. _ - h : 2* --> )3’ be a homomorphism and L a context-free language over 2. Prove that {iii ] h(w) E L} is context-free. In other words. the family of context-free languages is closed under inverse homomorphic images. Use closure under homomorphic images and inverse images to show that the following guages are not context-free. z) stowed} H. j 2 0} '_ ' {aibflc'fi |i z 0} “ ,{tabr'tbcx‘tcar I i 2 0} raphic Notes ,9 own automata were introduced in Oettinger [1961]. Deterministic pushdown au- ' were studied in Fischer {1963] and Schutzenberger [1963] and their acceptance Aanguages generated by LR(k) grammars is from Knuth [1965]. The relationship be- context—free languages and pushdown automata was discovered by Chomsky {1962], .2 1963], and Schutzenberger [1963]. The closure properties for context-free languages ' -- in Section 7.5 are from Bar-Hillel, Perles, and Shamir [1961] and Scheinberg .9}. A solution to Exercises 28 and 29 can be found in Ginsburg and Rose [1963b]. e pumping lemma for context-free languages is from Bar-Hillel, Perles, and Shamir 1-]. A stronger version of the pumping lemma is given in Ogden [1968]. Parikh’s :.'-'-m [1966] provides another tool for establishing that languages are not context-free. ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern