CS5371 Theory of Computation
Homework 2
Due: 2:00 pm, October 31, 2006 (before class)
-
Let G be a CFG in Chomsky normal form that contains b variables. Show that, if G generates some string with a derivation having at least 2b steps, L(G) is infinite.
-
Give a formal description and the corresponding state diagram of a PDA that recognizes the language A = {w | 2#a(w) ≠ 3#b(w), w∈{a,b}*}, where #c(w) denotes the number of character c occurring in the word w.
-
Let C = {xy | x, y ∈ {0,1}*, |x| = |y|, and x ≠ y}. Show that C is a context-free language.
-
Let A = {wtwR | w,t ∈{0,1}* and |w| = |t|}. Prove that A is not a context-free language.
-
(Ogden’s Lemma.) There is a stronger version of the CFL pumping lemma known as Ogden’s lemma. It differs from the pumping lemma by allowing us to focus on any p “distinguished” positions of a string z and guaranteeing that the strings to be pumped have between 1 and p distinguished positions. The formal statement of Ogden’s lemma is: Let L be a context-free language. Then there is a constant p such that for any string z in L with at least p characters, we can mark any p or more positions in z to be distinguished, and then z can be written as z = uvwxy, satisfying the following conditions:
-
vwx has at most p distinguished positions.
-
vx has at least one distinguished position.
-
For all i 0, uviwxiy is in L.
Prove Ogden’s lemma. (Hint: The proof is really the same as that of the pumping lemma if we pretend that the non-distinguished positions of z are not present as we select a long path in the parse tree for z.)
-
(Bonus Question) In this question, we apply Ogden’s lemma and show that the language L = {aibjck | i = j or j = k where i, j, k≥0} is inherently ambiguous.
-
Suppose that G = (V, T, , S) is a CFG for L, and let p be the constant specified for G in Ogden’s lemma. Assume that p > 3. (We can have this assumption, because Ogden’s lemma holds for p implies that it holds for any q with q > p.) Consider the string z = apbpcp+p! in L. Suppose we mark all the positions of ‘a’ as distinguished. Let u, v, w, x, y be the five parts of z as specified in the Ogden’s lemma. Show that v = at and x = bt for some t.
-
Following the above step, show that there exists a variable A in V such that S * uAy * uvAxy * ap+p!bp+p!cp+p!.
-
In a similar manner, find another derivation for ap+p!bp+p!cp+p!, and show that this derivation corresponds to a distinct parse tree from the derivation in Part B. Conclude that L is inherently ambiguous.
|