CSE396, Spring 2016 Problem Set 5 Due Thu. Mar. 24

advertisement
CSE396, Spring 2016
Problem Set 5
Due Thu. Mar. 24
Reading
The week after spring break will cover proofs that context-free grammars G generate
certain languages A. This will hark back to the material on proofs by induction in Chapter
0 and apply them to CFG’s. I will show how to abbreviate proofs of “L(G) ⊆ A” (in words:
the grammar is sound for the specification A) by assigning properties to each variable and
verifying that each rule preserves them, so that the proof does not have to explicitly mention
the number “n” of steps in derivations that it is inducting on. Proofs of “A ⊆ L(G)”—an
idea I called “comprehensiveness” when there was a DFA M in place of G—need to keep the
“n,” however, and hence can be rather painful.
This homework is based on lectures before break, though it “previews” the week after
break. So besides reviewing Section 2.1, please read the handout on “Induction Proofs and
Context-Free Grammars,” which is posted on the course webpage. (It’s handwritten—please
let me know if there’s any part you can’t read.) Problem sets 6 and 7 will be among the
longest, because proofs involving context-free grammars are long. . .
(1) Text, chapter 2, exercise 2.1 on p154 (2nd ed. p128, 1st. ed. p119). Note that the
text grammar simplifies the realistic one I gave by not having cases for minus and divides, and
in having just a terminal option for ‘a’ rather than “any letter”—in reality, a programming
language has syntax for a legal identifier there. (3 × 4 = 12 pts.)
(2) Review exercise 2.3 on the following page (2nd ed., same page). The answers are
given at the end of the chapter; they are (a) R, X, S, T , (b) a, b, (c) R, (d) ab, ba, aab (among
others), (e) , a, b (among others), (f–n) FTFTTFTTF, (o) L(G) is the complement of the
language of palindromes.
Now delete the rule T −→ from the G in exercise 2.3 to get a new grammar G0 . Say
which answers change. Then prove as best you can that L(G0 ) does not have any even-length
strings. This is intended as a lead-in to the “Structural Induction” topic after break. (12 +
12 = 24 pts.)
(3) Text, chapter 2, exercise 2.9 on page 155 (2nd ed., page 129, 1st ed., page 120).
If you say yes, give two different parse trees for some string in your G. If you say no, try to
prove it. (18 pts., for 54 total on this set.)
Download