S -> A A -> a A b | B B -> c B | ε
Problem 2.26 on page 130. If v is any sentence of length n >= 1 in the language of a grammar in Chomsky normal form, then there are exactly 2n-1 steps in any derivation of v.
Here is an outline of how to prove the result.
First, recall the notation defined on page 102 of the text:
u =>* v
means the string u derives the string v in 0 or more steps, where u and v strings of terminals and or non-terminals.
If u is the start symbol of the grammar, v is called a sentential form.
If u is the start symbol and v consists only of terminals, then v is not only a sentential form but also a sentence in the language of the grammar.
Now, for the method of the proof:
Let Pn be the statement:
If for a context-free grammar G = (V,T,S,R),
- u =>* v for u in V and v in T*, and
- v has length n, and
- G is in Chomsky normal
then the number of steps in u =>* v is 2n-1.
Prove Pn is true for all n >=1.
Use induction on n.
Note that the u in the statements Pn is restricted to be any single non-terminal, not a general string of grammar symbols. But even with this restriction, the general result that statements Pn are true (once proved), can still be applied to the case that u is the start symbol and v is a sentence in the language of the gramamr, showing that any sentence of length n in a grammar in Chomsky normal form, must have a derivation with exactly 2n - 1 steps.
For the inductive step you may find this fact useful:
If the number of steps in a derivation u =>* v is > 1, then since G is in Chomsky normal form, the first step in the derivation must be of the form u => XY for two non-terminals X and Y and we can write
u => XY =>* v1v2 = v where X =>* v1 and Y =>* v2for some non-terminals X and Y and strings v1 and v2.
These exercises will not be collected, but try to find a solution. They will be discussed in class. Fame and glory may be given for good solutions.
All strings in {a,b} that have the same number of a's as b's. The a's and b's can be in any order, but the total number of a's must equal the total number of b's. The null string is in this language.