1 / 6

Homework 7 Solutions

isha
Download Presentation

Homework 7 Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Homework #7 Solutions

    2. #1. Use the pumping lemma for CFLs to show L = {ai bj ai bj | i, j > 0} is not a CFL. Proof by contradiction using the Pumping Lemma. Assume L is context-free. L is obviously infinite, since i, j > 0. Pick a string w in L with length |w| > m, for example, w = a m b m a m b m, j > 0. Then w = uvxyz with |vxy| < m and |vy| > 1 and uvixy i z is also in L for all i > 0 The analyses to the right show that this language cannot be context-free because uv2xy2z is not in L.

    3. Show that each of these languages is context-free. G1 S?AC|? A?aAbb|? C?cC|? L1: |bs| = 2?|as| L2: |cs| = 2?|bs| So L1 ? L2 = { anb2nc4n | n ? 0 } #2. Consider the following 2 languages:

    4. 2b) Is L1n L2 context-free? Justify your answer. L1: |bs| = 2?|as| L2: |cs| = 2?|bs| So L1 ? L2 = { anb2nc4n | n ? 0 } Not context-free (easy use of pumping lemma.) Pick z = amb2mc4m

    5. #3. Convert the following grammar to Chomsky Normal Form S? A | A B a | A b A A ? A a | ? B ? B b | BC C ? C B | C A | b B Eliminate ?-productions: S? A | A B a | A b A | B a | b A | A b | ? A ? A a | a B ? B b | BC C ? C B | C A | b B | C

    6. #3 cont. 2. Remove unit productions S? A a | a | A B a | A b A | B a | b A | A b | ? A ? A a | a B ? B b | BC C ? C B | C A | b B 3. a) Eliminate useless (non-generating) symbols and all productions involving one or more of those symbols. S? A a | a | A b A | b A | A b A ? A a | a b) Eliminate unreachable symbols: None 4. Convert to CNF: S ? ????A A1 | A B |B1 A | A B1 A1 ? a B ? B1A B1 ? b A ? A A1 | a

    7. #4. Let G be a grammar in Chomsky Normal Form. Fill in the following table.

More Related