This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: l38 Chapter 4 Normal Forms for ContextFree Grammars Exercises 1 39 The derivation in the Chomsky normal form grammar generates six variables. Each B —> bb l C
of these is transformed to a terminal by a rule of the form A —> a. The Greibach normal I C —> cc 1 A
form derivation generates a terminal with each rule application. The derivation is completed '
using only six rule applications. El 9‘ G: S _) A l C
A —+ (IA 1 a  B
B —> 273 I b
C #4) CC 1 c l B Exercises 10 G s —> AB 1 C For Exercises 1 through 5, construct an equivalent essentially nonconn'acting grammar ~ A a 0A l B ' '   . .. . ' B —> [73 l C
GL With a nonrecursive start symbol. Give a regular expression for the language of each
grammar. C—+cClaA ' ‘ ‘ ' h ' G of Exercise 1.
1. G: S ~> 05  [75  B 11. Eliminate the chain rules from t e grammar L B _’ bb l C l A 12. Eliminate the chain rules from the grammar GL of Exercise 4 C —> CC I A 13 Prove that Algorithm 442 generates the set of variables that derive terminal strings.
2. G: s —> ABC A ' A —> aA  a t B _) b3 l A For Exercises 14 through 16, construct an equivalent grammar WlthOUl 11561683 symbols C .9 CC 1 A Trace the generation of the sets of TERM and REACH used to construct GT and GU.
3. G: S —> BSA  A Describe the language generated by the grammar. A —> M 1 x B—>Bbal 14.G:S—>AA[CleB
4. GzS—rABIBCS A—WAla A—>aAC B—>bBbC B —> bbB  b C —> 03 C —> CC I A D —> dB 1 d
5.G:S—>ABC!aBC 15. G:S—>uABD A—>aABC AeaAlaABlaD B—rbBI/‘t BaaBaClBF C —> cC I )~ C —> Bb  aAC  E
6. Prove Lemma 43.2. D —> [7D  bC l b
E —> (:3 l bC
For Exercises 7 through 10, constructan equivalent grammar GC that does not contain chain F _, a p 1 “G 1 a
rules. Give a regular expression for the language of each grammar. Note that these grammars G _, a I b do not contain Avrules. 16. G:S—>ACHBB
7. st—sAsm AauAlaF
A—>aAbBC B—>CFHb
B—>bBb C—>aClDH
C—>c'CB D—>aDlBD]Ca
B.G:S—>ABC F—>bBlb A—>aalB H—>dHd 140 Chapter 4 Normal Forms for ContextFree Grammars Exercises 141 17. Show that all the symbols of the grammar b) What is the maximum depth of a derivation tree for a string of length n in L(G)? c) What is the minimum depth of a derivation tree for a string of length n in L(G)? G: S —> A  CB
A _> C I D 25. Give the upper diagonal matrix produced by the CYK algorithm when run with the
Chomsky normal form grammar from Example 4.5.2 and the input strings abbb and
B —> M?  b aabbb.
C ) CC I c 26. Let G be the Chomsky normal form grammar
D —> dD  d : S —> AX AY '
are useful. C(mstruct an equivalent grammar GC by removing the chain rules from G. I I a Show that GC contains useless symbols. X —’ AX l a
18. Convert the grammar Y —> BY la
G:S—>aAABa A9"
B b.
A —+ AA la "
B _> AbB I bb Give t c upper diagonal matrix produced by the CYK algorithm when rrrn With the grammar G and the input strings buaa and abaaa. to Chomsky normal form. G already satisﬁes the conditions on the start symbol 5, Arules, useless symbols. and chain rules. ' 27. Lethe the grammar
G: S—r A  B
A —> (103 l Aab l Aba
B—>bBBbabu. 19. Convert the grammar G: S—>aAbBABCla A —> all a I a) Give a regular expression for MG)
3 _> bBCC I b b) Construct a grammar G’ that contains no leftrecursive rules and is equivalent to G.
C —> abc a: 28. Construct a grammar G’ that contains no left—recursive rules and is equivalent to
to Chomsky normal form. G already satisﬁes the conditions on the start symbol S, . Arules, useless symbols, and chain rules. G: S _) A l C
20. Convert the result of Exercise 9 to Chomsky nonnal form. A _) AaB I AaC I B I a
21. Convert the result of Exercise 1 l to Chomsky normal foml. B _’ Bb I Cb
C —> ('C l c. 22. Convert the result of Exercise 12 t0 Chomsky normal form. 23. Convert the grammar Give a leftmost derivation of the string aacmcb in the grammars G and G’. G: S __) A I A3“ I AbA 29. Construct a grammar G’ that contains no leftrecursive rules and is equivalent to A~9Aak G:S—>AlB
B—aBbIBC A—>AAAaB
C—aCBlCAle B—>BBbb. m Chomsky normal form 30. Construct a Greibach normal form grammar equivalent to " 24. Let G be a grammar in Chomsky normal form. S —+ aAb  a a) What is the length of a derivation of a string of length n in L(G)? A —> 55 1 b_ ...
View
Full
Document
This note was uploaded on 05/12/2011 for the course CS 4114 taught by Professor Ehrich,r during the Spring '08 term at Virginia Tech.
 Spring '08
 Ehrich,R

Click to edit the document details