To obtain a string of n Terminals from a given Chomsky normal form grammar, the number of productions to be used is :
2n − 1
Chomsky Normal Form (CNF) is a simplified form of context-free grammar. A context-free grammar is in Chomsky Normal Form if all its production rules are of one of the following forms:
The question asks about the number of productions needed to derive a non-empty string consisting of exactly \(n\) terminals from a CNF grammar. For a non-empty string (\(n \ge 1\)), the \(S \to \epsilon\) rule is not used in the derivation process itself to produce the final string of terminals.
Consider the structure of a derivation tree for a string of \(n\) terminals in CNF. Each internal node of the tree corresponds to an application of a rule of the form \(A \to BC\). Each leaf node corresponds to an application of a rule of the form \(A \to a\).
To obtain a string of \(n\) terminals, you must ultimately use \(n\) production rules of the form \(A \to a\), one for each terminal symbol in the final string. These \(n\) rules form the 'bottom layer' of the derivation.
Before applying these \(n\) rules, you must have \(n\) non-terminals available at the points where these rules are applied. The derivation starts with a single non-terminal (the start symbol). To get from 1 non-terminal to \(n\) non-terminals that are ready to be converted into terminals, you use rules of the form \(A \to BC\). Each application of \(A \to BC\) takes one non-terminal and replaces it with two non-terminals. This effectively increases the number of non-terminals in the sentential form by one.
Let's track the number of non-terminals:
To obtain \(n\) non-terminals from the initial 1 using only \(A \to BC\) rules, you need to apply this type of rule \(n-1\) times. For example:
So, the derivation proceeds in two phases:
The total number of productions used is the sum of the productions from Phase 1 and Phase 2.
Total productions = (Number of \(A \to BC\) rules) + (Number of \(A \to a\) rules)
Total productions = \((n-1) + n = 2n - 1\).
Let's say we want to derive a string of 3 terminals, like 'abc', from a CNF grammar. A possible sequence of derivations could be:
In this example, we used 2 productions of the form \(A \to BC\) and 3 productions of the form \(A \to a\).
Total productions = \(2 + 3 = 5\).
Using the formula \(2n - 1\) with \(n=3\), we get \(2(3) - 1 = 6 - 1 = 5\). The result matches.
This confirms that \(n-1\) rules of type \(A \to BC\) are needed to expand to \(n\) non-terminals from the start symbol, and \(n\) rules of type \(A \to a\) are needed to convert those \(n\) non-terminals into terminals.
| Production Type | Form | Purpose | Number of productions needed for \(n\) terminals |
|---|---|---|---|
| Branching Rules | \(A \to BC\) | Expand non-terminals | \(n-1\) |
| Terminal Rules | \(A \to a\) | Convert non-terminals to terminals | \(n\) |
| Total productions | \((n-1) + n = 2n - 1\) | ||
Therefore, to obtain a string of \(n\) terminals from a given Chomsky normal form grammar, the number of productions to be used is \(2n - 1\).
| Concept | Description | Relevance to Derivation |
|---|---|---|
| Chomsky Normal Form (CNF) | A restricted form of context-free grammar with specific production rule formats: \(A \to BC\), \(A \to a\), or \(S \to \epsilon\). | Constraints on rule types dictate the structure of derivation trees and the number of rule applications. |
| Production Rules | Rules defining how non-terminals can be replaced by other symbols (non-terminals or terminals). | Each step in a derivation corresponds to applying one production rule. Counting rule applications is key. |
| Terminals | The basic symbols that form the strings in the language. | The goal is to derive a string composed entirely of terminals. |
| Non-terminals | Symbols used in the grammar rules to represent sets of strings. Start symbol is a non-terminal. | Non-terminals are expanded or replaced by terminals during derivation. |
| Derivation Tree | A tree representation showing the application of production rules to derive a string from the start symbol. | In CNF, branching rules (\(A \to BC\)) create internal nodes with two children, and terminal rules (\(A \to a\)) create leaf nodes. |
Chomsky Normal Form is significant in the study of formal languages and automata theory due to several important properties:
Understanding the derivation process and the structure imposed by CNF rules is crucial for working with context-free languages and related algorithms.
Consider the following statements about Context Free Language (CFL):
Statement I: CFL is closed under homomorphism.
Statement II: CFL is closed under complement.
Which of the following is correct?
Match List-I with List-II:
Where L1: Regular language
L2: Context-free language
L3: Recursive language
L4: Recursively enumerable language
List-1 | List-2 |
(a) L' 3 U L 4 | (i) Context-free language |
(b) L' 2 U L 3 | (ii) Recursively enumerable language |
(c) L 1* ∩ L 2 | (iii) Recursive language |
Choose the correct from those given below:
How can the decision algorithm be constructed for deciding whether context-free language L is finite?
(a) By Constructing redundant CFG in CNF generating language L
(b) By constructing non-redundant CFG G in CNF generating language L
(c) By constructing non-redundant CFG in CNF generating language L-{∧} (∧ stands for null)
Which of the following is correct?
Which of the following statements is true ?
Consider the following statements with respect to the language L = {a nb n|n≥ 0}
S 1: L 2is context free language
S 2: L kis context-free language for any given k ≥ 1
S 3: L̅ and L* are context free languages
Which one of the following is correct?