Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prove that derivations in Chomsky Normal Form require 2n - 1 steps?

I'm trying to prove the following:

If G is a Context Free Grammar in the Chomsky Normal Form, then for any string w belongs L(G) of length n ≥ 1, it requires exactly 2n-1 steps to make any derivation of w.

How would I go about proving this?

like image 402
Christian Magro Avatar asked Jul 12 '12 16:07

Christian Magro


People also ask

Why do grammars in Chomsky normal form have derivations of length 2n 1?

Applying n rules of form A→a to each non-terminal in the string above gives you a string containing only terminals and thus a string from the language decided by the grammar. The length of the string has not changed (it's still n) but we applied an additional n rules so in total we have applied n−1+n=2n−1 rules.

How many steps are in Chomsky normal form?

The key advantage is that in Chomsky Normal Form, every derivation of a string of n letters has exactly 2n − 1 steps.

How many derivations steps are required for a derivation of a string of n length if the grammar is in CNF?

2 Answers. CNF(Chomsky Normal Form) , in this case the no of steps would we require to derive string of length "n" is 2*n-1 (A) option.

How do you know if a grammar is in Chomsky normal form?

In formal language theory, a context-free grammar, G, is said to be in Chomsky normal form (first described by Noam Chomsky) if all of its production rules are of the form: A → BC, or. A → a, or.


1 Answers

As a hint - since every production in Chomsky Normal Form either has the form

S → AB, for nonterminals A and B, or the form

S → x, for terminal x,

Then deriving a string would work in the following way:

  • Create a string of exactly n nonterminals, then
  • Expand each nonterminal out to a single terminal.

Applying productions of the first form will increase the number of nonterminals from k to k + 1, since you replace one nonterminal (-1) with two nonterminals (+2) for a net gain of +1 nonterminal. Since your start with one nonterminal, this means you need to do n - 1 productions of the first form. You then need n more of the second form to convert the nonterminals to terminals, giving a total of n + (n - 1) = 2n - 1 productions.

To show that you need exactly this many, I would suggest doing a proof by contradiction and showing that you can't do it with any more or any fewer. As a hint, try counting the number of productions of each type that are made and showing that if it isn't 2n - 1, either the string is too short, or you will still have nonterminals remaining.

Hope this helps!

like image 104
templatetypedef Avatar answered Oct 06 '22 19:10

templatetypedef