Chapter 2

Context-Free Languages

[59/92%]
Show
LaTeX
Problem 2.1

Recall the CFG G4G_{4} that we gave in Example 2.4. For convenience, let's rename its variables with single letters as follows.

E→E+T∣TT→T×F∣FF→(E)∣a \begin{aligned} & E \rightarrow E+T \mid T \\ & T \rightarrow T \times F \mid F \\ & F \rightarrow (E) \mid \mathrm{a} \end{aligned}

Give parse trees and derivations for each string.

?
(a)

a

(b)

a+a\mathrm{a}+\mathrm{a}

(c)

a+a+aa+a+a

(d)

((a))

Problem 2.2
?
(a)

Use the languages A={am bncn∣m,n≥0}A=\left\{ \mathrm{a}^{m} \mathrm{~ b}^{n} \mathrm{c}^{n} \mid m, n \geq 0\right\} and B={an bncm∣m,n≥0}B=\left\{ \mathrm{a}^{n} \mathrm{~ b}^{n} \mathrm{c}^{m} \mid m, n \geq 0\right\} together with Example 2.36 to show that the class of context-free languages is not closed under intersection.

(b)

Use part (a) and DeMorgan's law (Theorem 0.20) to show that the class of context-free languages is not closed under complementation.

Problem 2.3

ᴬ Answer each part for the following context-free grammar GG.

R→XRX∣SS→aT b∣bTaT→XTX∣X∣εX→a∣b \begin{aligned} R & \rightarrow X R X \mid S \\ S & \rightarrow \mathrm{a} T \mathrm{~ b} \mid \mathrm{b} T \mathrm{a} \\ T & \rightarrow X T X \mid X \mid \varepsilon \\ X & \rightarrow \mathrm{a} \mid \mathrm{b} \end{aligned}
?
(a)

What are the variables of GG?

(b)

What are the terminals of GG?

(c)

Which is the start variable of GG?

(d)

Give three strings in L(G)L(G).

(e)

Give three strings not in L(G)L(G).

(f)

True or False: T⇒abaT \Rightarrow \mathrm{aba}.

(g)

True or False: T⇒∗T \stackrel{*}{\Rightarrow } aba.

(h)

True or False: T⇒TT \Rightarrow T.

(i)

True or False: T⇒∗TT \stackrel{*}{\Rightarrow } T.

(j)

True or False: XXX⇒∗X X X \stackrel{*}{\Rightarrow } aba.

(k)

True or False: X⇒∗X \stackrel{*}{\Rightarrow } aba.

(l)

True or False: T→∗XXT \xrightarrow {*} X X.

(m)

True or False: T⇒∗XXXT \stackrel{*}{\Rightarrow } X X X.

(n)

True or False: S⇒∗εS \stackrel{*}{\Rightarrow } \varepsilon.

(o)

Give a description in English of L(G)L(G).

Problem 2.4

Give context-free grammars that generate the following languages. In all parts, the alphabet Σ\Sigma is 0,1.

?
(a)

ᴬ {w∣w contains at least three 1 s }\left\{ w \mid w\text{ contains at least three 1 s }\right\}

(b)

{w∣w starts and ends with the same symbol}\left\{ w \mid w\text{ starts and ends with the same symbol}\right\}

(c)

{w∣the length of w is odd}\left\{ w \mid \text{the length of } w \text{ is odd}\right\}

(d)

ᴬ {w∣ the length of w is odd and its middle symbol is a 0}\left\{ w \mid \text{ the length of }w\text{ is odd and its middle symbol is a 0}\right\}

(e)

{w∣w=wR, that is, w is a palindrome}\left\{ w \mid w=w^{\mathcal{R}}, \text{ that is, } w \text{ is a palindrome}\right\}

(f)

The empty set

Problem 2.5

Give informal descriptions and state diagrams of pushdown automata for the languages in Exercise 2.4. In all parts, the alphabet Σ\Sigma is 0,1.

?
(a)

{w∣w contains at least three 1 s }\left\{ w \mid w\text{ contains at least three 1 s }\right\}

(b)

{w∣w starts and ends with the same symbol}\left\{ w \mid w\text{ starts and ends with the same symbol}\right\}

(c)

{w∣the length of w is odd}\left\{ w \mid \text{the length of } w \text{ is odd}\right\}

(d)

{w∣ the length of w is odd and its middle symbol is a 0}\left\{ w \mid \text{ the length of }w\text{ is odd and its middle symbol is a 0}\right\}

(e)

{w∣w=wR, that is, w is a palindrome}\left\{ w \mid w=w^{\mathcal{R}}, \text{ that is, } w \text{ is a palindrome}\right\}

(f)

The empty set

Problem 2.6

Give context-free grammars generating the following languages.

?
(a)

ᴬ The set of strings over the alphabet {a,b}\left\{ \mathbf{a}, \mathbf{b}\right\} with more a's than b's

(b)

The complement of the language {an bn∣n≥0}\left\{ \mathrm{a}^{n} \mathrm{~ b}^{n} \mid n \geq 0\right\}

(c)

ᴬ {w#x∣wR is a substring of x for w,x∈{0,1}∗}\left\{ w \# x \mid w^{\mathcal{R}} \text{ is a substring of } x \text{ for } w, x \in \left\{ 0,1\right\}^{*}\right\}

(d)

{x1#x2#⋯#xk∣k≥1, each xi∈{a,b}∗, and for some i and j,xi=xjR}\left\{ x_{1} \# x_{2} \# \cdots \# x_{k} \mid k \geq 1, \text{ each } x_{i} \in \left\{ \mathrm{a}, \mathrm{b}\right\}^{*}, \text{ and for some } i \text{ and } j, x_{i}=x_{j}^{\mathcal{R}}\right\}

Problem 2.7

ᴬ Give informal English descriptions of PDAs for the languages in Exercise 2.6.

?
Problem 2.8

ᴬ Show that the string the girl touches the boy with the flower has two different leftmost derivations in grammar G2G_{2} on page 103. Describe in English the two different meanings of this sentence.

?
Problem 2.9

Give a context-free grammar that generates the language

A={ai bjck∣i=j or j=k where i,j,k≥0}. A=\left\{ \mathrm{a}^{i} \mathrm{~ b}^{j} \mathrm{c}^{k} \mid i=j \text{ or } j=k \text{ where } i, j, k \geq 0\right\} .

Is your grammar ambiguous? Why or why not?

?
Problem 2.10

Give an informal description of a pushdown automaton that recognizes the language AA in Exercise 2.9.

?
Problem 2.11

Convert the CFG G4G_{4} given in Exercise 2.1 to an equivalent PDA, using the procedure given in Theorem 2.20.

?
Problem 2.12

Convert the CFG GG given in Exercise 2.3 to an equivalent PDA, using the procedure given in Theorem 2.20.

?
Problem 2.13

Let G=(V,Σ,R,S)G=(V, \Sigma , R, S) be the following grammar. V={S,T,U};Σ={0,#}V=\left\{ S, T, U\right\} ; \Sigma =\left\{ 0, \# \right\}; and RR is the set of rules:

S→TT∣UT→0T∣T0∣#U→0U00∣# \begin{aligned} S & \rightarrow T T \mid U \\ T & \rightarrow 0 T \mid T 0 \mid \# \\ U & \rightarrow 0 U 00 \mid \# \end{aligned}
?
(a)

Describe L(G)L(G) in English.

(b)

Prove that L(G)L(G) is not regular.

Problem 2.14

Convert the following CFG into an equivalent CFG in Chomsky normal form, using the procedure given in Theorem 2.9.

A→BAB∣B∣εB→00∣ε \begin{aligned} & A \rightarrow B A B \mid B \mid \varepsilon \\ & B \rightarrow 00 \mid \varepsilon \end{aligned}
?
Problem 2.15

Give a counterexample to show that the following construction fails to prove that the class of context-free languages is closed under star. Let AA be a CFL that is generated by the CFG G=(V,Σ,R,S)G=(V, \Sigma , R, S). Add the new rule S→SSS \rightarrow S S and call the resulting grammar G′G^{\prime }. This grammar is supposed to generate A∗A^{*}.

?
Problem 2.16

Show that the class of context-free languages is closed under the regular operations, union, concatenation, and star.

?
Problem 2.17

Use the results of Exercise 2.16 to give another proof that every regular language is context free, by showing how to convert a regular expression directly to an equivalent context-free grammar.

?
Problem 2.18

ᴬ

?
(a)

Let CC be a context-free language and RR be a regular language. Prove that the language C∩RC \cap R is context free.

(b)

Let A={w∣w∈{a,b,c}∗ and w contains equal numbers of a’s, b’s, and c’s}A=\left\{ w \mid w \in \left\{ \mathrm{a}, \mathrm{b}, \mathrm{c}\right\}^{*} \text{ and } w \text{ contains equal numbers of a's, b's, and c's}\right\}. Use part (a) to show that AA is not a CFL.

Problem 2.19
  • Let CFG GG be the following grammar.
S→aS b∣ bY∣YaY→ bY∣aY∣ε \begin{aligned} S & \rightarrow \mathrm{a} S \mathrm{~ b} \mid \mathrm{~ b} Y \mid Y \mathrm{a} \\ Y & \rightarrow \mathrm{~ b} Y \mid \mathrm{a} Y \mid \varepsilon \end{aligned}

Give a simple description of L(G)L(G) in English. Use that description to give a CFG for L(G)‾\overline{L(G)}, the complement of L(G)L(G).

?
Problem 2.20

Let A/B={w∣wx∈A for some x∈B}A / B=\left\{ w \mid w x \in A\text{ for some }x \in B\right\}. Show that if AA is context free and BB is regular, then A/BA / B is context free.

?
Problem 2.21
  • Let Σ={a,b}\Sigma =\left\{ \mathrm{a}, \mathrm{b}\right\}. Give a CFG generating the language of strings with twice as many a's as b's. Prove that your grammar is correct.
?
Problem 2.22
  • Let C={x#y∣x,y∈{0,1}∗ and x≠y}C=\left\{ x \# y \mid x, y \in \left\{ 0,1\right\}^{*} \text{ and } x \neq y\right\}. Show that CC is a context-free language.
?
Problem 2.23
  • Let D={xy∣x,y∈{0,1}∗ and ∣x∣=∣y∣ but x≠y}D=\left\{ x y \mid x, y \in \left\{ 0,1\right\}^{*} \text{ and } \left|x\right|=\left|y\right| \text{ but } x \neq y\right\}. Show that DD is a context-free language.
?
Problem 2.24
  • Let E={ai bj∣i≠j and 2i≠j}E=\left\{ \mathrm{a}^{i} \mathrm{~ b}^{j} \mid i \neq j \text{ and } 2 i \neq j\right\}. Show that EE is a context-free language.
?
Problem 2.25

For any language AA, let SUFFIX⁡(A)={v∣uv∈A for some string u}\operatorname {SUFFIX}(A)=\left\{ v \mid u v \in A\text{ for some string }u\right\}. Show that the class of context-free languages is closed under the SUFFIX operation.

?
Problem 2.26

Show that if GG is a CFG in Chomsky normal form, then for any string w∈L(G)w \in L(G) of length n≥1n \geq 1, exactly 2n−12 n-1 steps are required for any derivation of ww.

?
Problem 2.27
  • Let G=(V,Σ,R,⟨G=(V, \Sigma , R,\langle STMT ⟩)\rangle ) be the following grammar.
⟨ STMT ⟩→⟨ ASSIGN ⟩∣⟨ IF-THEN ⟩∣⟨ IF-THEN-ELSE ⟩⟨ IF-THEN ⟩→ if condition then ⟨ STMT ⟩⟨ IF-THEN-ELSE ⟩→ if condition then ⟨ STMT ⟩ else ⟨ STMT ⟩⟨ ASSIGN ⟩→ a :=1Σ={ if , condition , then, else ,a:=1}V={⟨ STMT ⟩,⟨ IF-  THEN ⟩,⟨ IF-  THEN-ELSE ⟩,⟨ ASSIGN ⟩} \begin{aligned} & \langle \text{ STMT }\rangle \rightarrow \langle \text{ ASSIGN }\rangle \mid \langle \text{ IF-THEN }\rangle \mid \langle \text{ IF-THEN-ELSE }\rangle \\ & \langle \text{ IF-THEN }\rangle \rightarrow \text{ if condition then }\langle \text{ STMT }\rangle \\ & \langle \text{ IF-THEN-ELSE }\rangle \rightarrow \text{ if condition then }\langle \text{ STMT }\rangle \text{ else }\langle \text{ STMT }\rangle \\ & \langle \text{ ASSIGN }\rangle \rightarrow \text{ a }:=1 \\ & \Sigma =\left\{ \text{ if }, \text{ condition }, \text{ then, else }, \mathrm{a}:=1\right\} \\ & V=\left\{ \langle \text{ STMT }\rangle ,\langle \text{ IF- } \text{ THEN }\rangle ,\langle \text{ IF- } \text{ THEN-ELSE }\rangle ,\langle \text{ ASSIGN }\rangle \right\} \end{aligned}

GG is a natural-looking grammar for a fragment of a programming language, but GG is ambiguous.

?
(a)

Show that GG is ambiguous.

(b)

Give a new unambiguous grammar for the same language.

Problem 2.28
  • Give unambiguous CFGs for the following languages.
?
(a)

{w∣in every prefix of w the number of a’s is at least the number of b’s}\left\{ w \mid \text{in every prefix of } w \text{ the number of a's is at least the number of b's}\right\}

(b)

{w∣the number of a’s and the number of b’s in w are equal}\left\{ w \mid \text{the number of a's and the number of b's in } w \text{ are equal}\right\}

(c)

{w∣ the number of a’s is at least the number of b’s in w}\left\{ w \mid \text{ the number of a's is at least the number of b's in }w\right\}

Problem 2.29
  • Show that the language AA in Exercise 2.9 is inherently ambiguous.
?
Problem 2.30

Use the pumping lemma to show that the following languages are not context free.

?
(a)

{0n1n0n1n∣n≥0}\left\{ 0^{n} 1^{n} 0^{n} 1^{n} \mid n \geq 0\right\}

(b)

ᴬ {0n#02n#03n∣n≥0}\left\{ 0^{n} \# 0^{2 n} \# 0^{3 n} \mid n \geq 0\right\}

(c)

ᴬ {w#t∣w is a substring of t, where w,t∈{a,b}∗}\left\{ w\# t \mid w \text{ is a substring of } t, \text{ where } w, t \in \left\{ \mathrm{a}, \mathrm{b}\right\}^{*}\right\}

(d)

{t1#t2#⋯#tk∣k≥2, each ti∈{a,b}∗, and ti=tj for some i≠j}\left\{ t_{1} \# t_{2} \# \cdots \# t_{k} \mid k \geq 2, \text{ each } t_{i} \in \left\{ \mathrm{a}, \mathrm{b}\right\}^{*}, \text{ and } t_{i}=t_{j} \text{ for some } i \neq j\right\}

Problem 2.31

Let BB be the language of all palindromes over 0,1 containing equal numbers of 0s and 1s. Show that BB is not context free.

?
Problem 2.32

Let Σ={1,2,3,4}\Sigma =\left\{ 1,2,3,4\right\} and C={w∈Σ∗∣ in w, the number of 1s equals the number of 2s, and the number of 3s equals the number of 4s}C=\left\{ w \in \Sigma^{*} \mid \text{ in } w\text{, the number of 1s equals the number of 2s, and the number of 3s equals the number of 4s}\right\}. Show that CC is not context free.

?
Problem 2.33
  • Show that F={ai bj∣i=kj for some positive integer k}F=\left\{ \mathrm{a}^{i} \mathrm{~ b}^{j} \mid i=k j \text{ for some positive integer } k\right\} is not context free.
?
Problem 2.34

Consider the language B=L(G)B=L(G), where GG is the grammar given in Exercise 2.13. The pumping lemma for context-free languages, Theorem 2.34, states the existence of a pumping length pp for BB. What is the minimum value of pp that works in the pumping lemma? Justify your answer.

?
Problem 2.35

Let GG be a CFG in Chomsky normal form that contains bb variables. Show that if GG generates some string with a derivation having at least 2b2^{b} steps, L(G)L(G) is infinite.

?
Problem 2.36

Give an example of a language that is not context free but that acts like a CFL in the pumping lemma. Prove that your example works. (See the analogous example for regular languages in Problem 1.54.)

?
Problem 2.37
  • Prove the following stronger form of the pumping lemma, wherein both pieces vv and yy must be nonempty when the string ss is broken up. If AA is a context-free language, then there is a number kk where, if ss is any string in AA of length at least kk, then ss may be divided into five pieces, s=uvxyzs=u v x y z, satisfying the conditions:
?
(a)

for each i≥0,uvixyiz∈Ai \geq 0, u v^{i} x y^{i} z \in A,

(b)

v≠εv \neq \varepsilon and y≠εy \neq \varepsilon, and

(c)

∣vxy∣≤k\left|v x y\right| \leq k.

Problem 2.38

ᴬ Refer to Problem 1.41 for the definition of the perfect shuffle operation. Show that the class of context-free languages is not closed under perfect shuffle.

Problem 1.41: For languages AA and BB, the perfect shuffle of AA and BB is the language

{w∣w=a1b1⋯akbk, where a1⋯ak∈A and b1⋯bk∈B, each ai,bi∈Σ}. \left\{ w \mid w=a_{1} b_{1} \cdots a_{k} b_{k}, \text{ where } a_{1} \cdots a_{k} \in A \text{ and } b_{1} \cdots b_{k} \in B, \text{ each } a_{i}, b_{i} \in \Sigma \right\} .
?
Problem 2.39

Refer to Problem 1.42 for the definition of the shuffle operation. Show that the class of context-free languages is not closed under shuffle.

Problem 1.42: For languages AA and BB, the shuffle of AA and BB is the language

{w∣w=a1b1⋯akbk, where a1⋯ak∈A and b1⋯bk∈B, each ai,bi∈Σ∗}. \left\{ w \mid w=a_{1} b_{1} \cdots a_{k} b_{k}, \text{ where } a_{1} \cdots a_{k} \in A \text{ and } b_{1} \cdots b_{k} \in B, \text{ each } a_{i}, b_{i} \in \Sigma ^{*}\right\} .
?
Problem 2.40
  • Say that a language is prefix-closed if all prefixes of every string in the language are also in the language. Let CC be an infinite, prefix-closed, context-free language. Show that CC contains an infinite regular subset.
?
Problem 2.41
  • Read the definitions of NOPREFIX⁡(A)\operatorname {NOPREFIX}(A) and NOEXTEND⁡(A)\operatorname {NOEXTEND}(A) in Problem 1.40.
?
(a)

Show that the class of CFLs is not closed under NOPREFIX.

(b)

Show that the class of CFLs is not closed under NOEXTEND.

Problem 2.42
  • Let Y={w∣w=t1#t2#⋯#tk for k≥0, each ti∈1∗, and ti≠tj whenever i≠j}Y=\left\{ w \mid w=t_{1} \# t_{2} \# \cdots \# t_{k} \text{ for } k \geq 0, \text{ each } t_{i} \in 1^{*}, \text{ and } t_{i} \neq t_{j} \text{ whenever } i \neq j\right\}. Here Σ={1,#}\Sigma =\left\{ 1, \# \right\}. Prove that YY is not context free.
?
Problem 2.43

For strings ww and tt, write w=∘tw \stackrel{\circ }{=} t if the symbols of ww are a permutation of the symbols of tt. In other words, w=∘tw \stackrel{\circ }{=} t if tt and ww have the same symbols in the same quantities, but possibly in a different order. For any string ww, define SCRAMBLE⁡(w)={t∣t=∘w}\operatorname {SCRAMBLE}(w)=\left\{ t \mid t \stackrel{\circ }{=} w\right\}. For any language AA, let SCRAMBLE⁡(A)={t∣t∈SCRAMBLE⁡(w) for some w∈A}\operatorname {SCRAMBLE}(A)=\left\{ t \mid t \in \operatorname {SCRAMBLE}(w)\text{ for some }w \in A\right\}.

?
(a)

Show that if Σ={0,1}\Sigma =\left\{ 0,1\right\}, then the SCRAMBLE of a regular language is context free.

(b)

What happens in part (a) if Σ\Sigma contains three or more symbols? Prove your answer.

Problem 2.44

If AA and BB are languages, define A⋄B={xy∣x∈A and y∈B and ∣x∣=∣y∣}A \diamond B=\left\{ x y \mid x \in A\text{ and }y \in B\text{ and }\left|x\right|=\left|y\right|\right\}. Show that if AA and BB are regular languages, then A⋄BA \diamond B is a CFL.

?
Problem 2.45
  • Let A={wtwR∣w,t∈{0,1}∗ and ∣w∣=∣t∣}A=\left\{ w t w^{\mathcal{R}} \mid w, t \in \left\{ 0,1\right\}^{*} \text{ and } \left|w\right|=\left|t\right|\right\}. Prove that AA is not a CFL.
?
Problem 2.46

Consider the following CFG GG :

S→SS∣TT→aT b∣ab \begin{aligned} & S \rightarrow S S \mid T \\ & T \rightarrow \mathrm{a} T \mathrm{~ b} \mid \mathrm{ab} \end{aligned}

Describe L(G)L(G) and show that GG is ambiguous. Give an unambiguous grammar HH where L(H)=L(G)L(H)=L(G) and sketch a proof that HH is unambiguous.

?
Problem 2.47

Let Σ={0,1}\Sigma =\left\{ 0,1\right\} and let BB be the collection of strings that contain at least one 1 in their second half. In other words, B={uv∣u∈Σ∗,v∈Σ∗1Σ∗ and ∣u∣≥∣v∣}B=\left\{ u v \mid u \in \Sigma^{*}, v \in \Sigma^{*} 1 \Sigma^{*} \text{ and } \left|u\right| \geq \left|v\right|\right\}.

?
(a)

Give a PDA that recognizes BB.

(b)

Give a CFG that generates BB.

Problem 2.48

Let Σ={0,1}\Sigma =\left\{ 0,1\right\}. Let C1C_{1} be the language of all strings that contain a 1 in their middle third. Let C2C_{2} be the language of all strings that contain two 1s in their middle third. So C1={xyz∣x,z∈Σ∗,y∈Σ∗1Σ∗, where ∣x∣=∣z∣≥∣y∣}C_{1}=\left\{ x y z \mid x, z \in \Sigma^{*}, y \in \Sigma^{*} 1 \Sigma^{*}, \text{ where } \left|x\right|=\left|z\right| \geq \left|y\right|\right\} and C2={xyz∣x,z∈Σ∗,y∈Σ∗1Σ∗1Σ∗, where ∣x∣=∣z∣≥∣y∣}C_{2}=\left\{ x y z \mid x, z \in \Sigma^{*}, y \in \Sigma^{*} 1 \Sigma^{*} 1 \Sigma^{*}, \text{ where } \left|x\right|=\left|z\right| \geq \left|y\right|\right\}.

?
(a)

Show that C1C_{1} is a CFL.

(b)

Show that C2C_{2} is not a CFL.

Problem 2.49
  • We defined the rotational closure of language AA to be RC⁡(A)={yx∣xy∈A}\operatorname {RC}(A)=\left\{ y x \mid x y \in A\right\}. Show that the class of CFLs is closed under rotational closure.
?
Problem 2.50
  • We defined the CUT of language AA to be CUT⁡(A)={yxz∣xyz∈A}\operatorname {CUT}(A)=\left\{ y x z \mid x y z \in A\right\}. Show that the class of CFLs is not closed under CUT.
?
Problem 2.51

Show that every DCFG is an unambiguous CFG.

?
Problem 2.52

ᴬ Show that every DCFG generates a prefix-free language.

?
Problem 2.53
  • Show that the class of DCFLs is not closed under the following operations:
?
(a)

Union

(b)

Intersection

(c)

Concatenation

(d)

Star

(e)

Reversal

Problem 2.54

Let GG be the following grammar:

S→T−1T→TaT b∣T bTa∣ε \begin{aligned} & S \rightarrow T-\mathbf{1} \\ & T \rightarrow T \mathrm{a} T \mathrm{~ b} \mid T \mathrm{~ b} T \mathrm{a} \mid \boldsymbol {\varepsilon } \end{aligned}
?
(a)

Show that L(G)={w⊣∣w contains equal numbers of a’s and b’s}L(G)=\left\{ w \dashv \mid w\text{ contains equal numbers of a's and b's}\right\}. Use a proof by induction on the length of ww.

(b)

Use the DKD K-test to show that GG is a DCFG.

(c)

Describe a DPDA that recognizes L(G)L(G).

Problem 2.55

Let G1G_{1} be the following grammar that we introduced in Example 2.45. Use the DKD K-test to show that G1G_{1} is not a DCFG.

R→S∣TS→aS b∣abT→aTbb∣abb \begin{aligned} & R \rightarrow S \mid T \\ & S \rightarrow \mathrm{a} S \mathrm{~ b} \mid \mathrm{ab} \\ & T \rightarrow \mathrm{a} T \mathrm{bb} \mid \mathrm{abb} \end{aligned}
?
Problem 2.56
  • Let A=L(G1)A=L\left(G_{1}\right) where G1G_{1} is defined in Problem 2.55. Show that AA is not a DCFL. (Hint: Assume that AA is a DCFL and consider its DPDA PP. Modify PP so that its input alphabet is {a,b,c}\left\{ \mathrm{a}, \mathrm{b}, \mathrm{c}\right\}. When it first enters an accept state, it pretends that c's are b's in the input from that point on. What language would the modified PP accept?)

Problem 2.55: G1G_{1} is the grammar

R→S∣TS→aS b∣abT→aTbb∣abb \begin{aligned} & R \rightarrow S \mid T \\ & S \rightarrow \mathrm{a} S \mathrm{~ b} \mid \mathrm{ab} \\ & T \rightarrow \mathrm{a} T \mathrm{bb} \mid \mathrm{abb} \end{aligned}
?
Problem 2.57
  • Let B={ai bjck∣i,j,k≥0 and i=j or i=k}B=\left\{ \mathrm{a}^{i} \mathrm{~ b}^{j} \mathrm{c}^{k} \mid i, j, k \geq 0 \text{ and } i=j \text{ or } i=k\right\}. Prove that BB is not a DCFL.
?
Problem 2.58
  • Let C={wwR∣w∈{0,1}∗}C=\left\{ w w^{\mathcal{R}} \mid w \in \left\{ 0,1\right\}^{*}\right\}. Prove that CC is not a DCFL. (Hint: Suppose that when some DPDA PP is started in state qq with symbol xx on the top of its stack, PP never pops its stack below xx, no matter what input string PP reads from that point on. In that case, the contents of PP 's stack at that point cannot affect its subsequent behavior, so PP 's subsequent behavior can depend only on qq and xx.)
?
Problem 2.59
  • If we disallow ε\varepsilon-rules in CFGs, we can simplify the DKD K-test. In the simplified test, we only need to check that each of DKD K 's accept states has a single rule. Prove that a CFG without ε\boldsymbol {\varepsilon }-rules passes the simplified DKD K-test iff it is a DCFG.
?