T2answers - gument should • use the fact that R is regular • use the fact that the intersection between a regular language and a CFL is a CFL

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

View Full Document Right Arrow Icon
University of Central Florida School of Computer Science COT 4210 Spring 2004 Prof. Rene Peralta T2: answers to selected problems 1. Put the following grammar in Chomsky Normal Form. S SS + AA A AB + a B BS + b + λ answer: S TT + AA T TT + AA A AB + a B BT + TT + AA + b 2. Write a context-free grammar for the following language L = { a n b k a m | m = n + k, m, n, k 0 } . answer: Write L as L = { a n b k a k a n | n, k 0 } . Then it is easy to see the following grammar produces L . S aSa + T T aTb + λ 3. Let M be the following DFA (?I don’t seem to have the picture). Write left-linear and right-linear grammars for the language accepted by M. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
4. Eliminate left-recursion from the following grammar S SB + A A AB + a B Ba + b answer: Note S AB * A aB * B ba * Let R BR + λ T aT + λ and S AR A aR B bT 5. Consider the following languages L = { ωω r ω | ω ( a + b ) * } R = { ω | ω ( a + b ) * and ω has exactly 6 b’s } T = L R (a) Give a string in T of length 12. answer: bbaaaabbbbaa . (b) Find a string ω b ( a + b ) * b of length 6 such that ωωω T . answer: baaaab . 2
Background image of page 2
(c) Give a convincing argument that L is not context-free. Your ar-
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: gument should • use the fact that R is regular; • use the fact that the intersection between a regular language and a CFL is a CFL; • define a string z ∈ T for which the pumping lemma for CFL’s does not hold; • a concise and convincing explanation of why z cannot be “pumped”. answer: Assume L is context-free. Since R is regular, T = L ∩ R is context-free. A string z of the form z = ba n bba n bba n b is in T . For n large enough, the pumping lemma for CFL’s must hold for z . Since words in T have exactly six b ’s, z can only be “pumped” at two regions containing only a ’s. The resulting strings are of the form ba k bba l bba m b with k, l, m not necessarily equal. In the latter case, the word cannot be in T , contradiction. Therefore L cannot be context-free. 3...
View Full Document

This note was uploaded on 06/09/2011 for the course COT 4210 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 3

T2answers - gument should • use the fact that R is regular • use the fact that the intersection between a regular language and a CFL is a CFL

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online