CFG Derivations, Ambiguity Proofs & Chomsky Normal Form
“Parse tree multiplicity, inherent ambiguity, CNF 2n-1 steps, and CYK parsing.”
1.Context-Free Grammars & The Ambiguity Problem
§ 3.1.A Context-Free Grammar (CFG) is a 4-tuple G = (V, T, P, S), where production rules have the form A \to \alpha, with A \in V (a single non-terminal variable) and \alpha \in (V \cup T)^*.
Ambiguity in Grammars:
A grammar G is ambiguous if there exists at least one string w \in L(G) that has two or more distinct leftmost derivations (or equivalently, two or more distinct parse trees).
Inherent Ambiguity:
A context-free language L is inherently ambiguous if EVERY grammar that generates L is ambiguous. Classic inherently ambiguous language:
$L = { a^n b^n c^m d^m \mid n, m ≥ 1 } \cup { a^n b^m c^m d^n \mid n, m ≥ 1 }$
For strings where n = m (a^n b^n c^n d^n), every grammar is forced to generate duplicate parse trees.
Chomsky Normal Form (CNF):
A grammar is in CNF if all production rules are strictly of the form: A \to BC or A \to a (where A, B, C \in V and a \in T).
CNF Derivation Length Theorem: If a string w \in L(G) has length n ≥ 1, any derivation of w in a CNF grammar requires EXACTLY 2n - 1 steps (specifically: n - 1 rule applications of A \to BC, followed by n rule applications of A \to a).
2. GATE Worked Numerical: Derivation Steps in CNF Grammar
The formula 2n - 1 applies ONLY when the grammar is in Chomsky Normal Form (CNF)! For general grammars, derivation lengths can vary.
Problem: A context-free grammar G is in Chomsky Normal Form. A string w of length 15 is derived in G. How many derivation steps were executed?
Step 1: Identify CNF production structure:
Binary productions (A -> BC) increase the count of non-terminals by 1.
To grow from 1 start symbol S to 15 non-terminals requires: 15 - 1 = 14 applications of A -> BC.
Step 2: Terminal productions (A -> a):
Each of the 15 non-terminals must be converted into a terminal symbol: 15 applications of A -> a.
Step 3: Total derivation steps:
Total steps = (n - 1) + n = 2n - 1 = 2(15) - 1 = 30 - 1 = 29 steps.
Primary Academic References & Exam Sources
Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.
Curated for clarity, rigorous numerical solving, and semester excellence:
GATE-focused with clear minimal DFA construction and language classification.
Exam-pattern oriented with closure table drilling and decidability proofs.
Mathematically rigorous treatment for high-rank GATE aspirants.