The exercises below use G and G′:
G is the context-free grammar ({E}, {+, x}, P, E), where P contains the following productions: E → E + E ∣ x.
G′ is a function from finite sets of productions (using the non-terminals {E, T} and terminals {+, x}) to grammars defined by G′(P) = ({E, T}, {+, x}, P, E).
(1p) Which of the following properties, if any, does G satisfy?
It is ambiguous.
The language L(G) is empty.
The language L(G) is infinite.
The string ε ∈ L(G).
The string x x ∈ L(G).
The string x + x ∈ L(G).
(1p) How many parse trees for G, with E as the root label and yield x + x + x, are there?
(1p) How many left-most derivations for G, starting with E, are there of the string x + x + x?
(1p) For which of the following definitions of P′ is L(G′(P′)) = L(G)?
E → T + E ∣ x
T → x
E → T + E ∣ T
T → x
E → T + E ∣ T
T → T + E ∣ x
E → x + E ∣ x
(1p) For which of the following definitions of P′ is G′(P′) unambiguous?
E → T + E ∣ x
T → x
E → T + E ∣ T
T → x
E → T + E ∣ T
T → T + E ∣ x
E → x + E ∣ x