Left Recursion and Normal Forms: CNF vs GNF vs BNF
In a keyword grammar, a nonterminal is left-recursive if there is a derivation for some string (i.e., can derive a sentential form that begins with ). This notion matters because many top-down parsers (e.g., naive recursive-descent) can loop when confronted with left recursion.
For context-free grammar “normal forms”:
- keyword A grammar form where productions are restricted to or (with an allowance for special start-symbol rules in some definitions).
- keyword Productions are of the form where each rule begins with a terminal.
- keyword A general notation for context-free grammars with production rules like (typically no restriction that prevents left recursion).
Key intuition:
If every production for a nonterminal starts with a terminal (as in GNF), then it cannot immediately or indirectly “start by expanding itself” at the left edge in the same way left recursion is defined; whereas CNF and especially BNF do not enforce that “leftmost expansion begins with a terminal.”
The multiple-choice question
Which of the following does not have left recursions?
(i) Chomsky normal form
(ii) Greibach normal form
(iii) Backus-Naur form
(iv) All of the above
From standard grammar theory: Greibach normal form is designed so that derivations from nonterminals begin with terminals in a way that avoids left recursion in the usual sense for the nonterminal rewriting process. BNF is general and can represent left-recursive grammars. CNF does not universally eliminate left recursion either, because it permits rules where could derive strings that start with .
Therefore, the correct choice is:
✅ (ii) Greibach normal form
Left Recursion vs Normal Forms (GNF/CNF) — Educational Overview
Why GNF avoids left recursion (conceptual proof sketch)
In keyword every production has the shape: where is a terminal and is (possibly empty) a string of nonterminals.
Consider the leftmost derivation of :
- The first symbol produced at the left edge must be the terminal (because the first production used from starts with a terminal).
- To have left recursion , the leftmost symbol of the sentential form after some steps must again begin with .
- But under GNF, after expanding (at the left edge), the derivation immediately places a terminal at the leftmost position; you cannot “recover” a sentential form whose leftmost symbol is without violating the property that expansions at the left edge begin with terminals.
So GNF’s “leftmost terminal starts” structure blocks the left-recursive pattern.
What “no left recursion” really means here
Many courses treat “GNF has no left recursion” as a property of the restricted production shapes used in GNF derivations (i.e., leftmost derivations cannot keep on the left edge). Always align with the course’s exact definition of left recursion and the exact GNF variant.
CNF and BNF can still be left-recursive
CNF restricts productions to: But it does not force that the first step from a nonterminal begins with a terminal—it can begin with another nonterminal . If can derive a string whose leftmost nonterminal expansion leads back to , you can get left recursion.
BNF imposes no such structural restriction. Since BNF can express arbitrary productions, it can represent grammars that are directly left-recursive, such as: which is immediate left recursion by definition.
Productions like may allow via indirect derivations.
How to decide whether a normal form avoids left recursion
- 1Step 1
Use (leftmost symbol remains after some positive derivation steps).
- 2Step 2
If every expansion from begins with a terminal (as in GNF), the leftmost symbol cannot stay .
- 3Step 3
Ask: after expanding once, can the left edge become again? If the formalism forces a terminal first, it blocks left recursion.
- 4Step 4
BNF allows arbitrary productions; CNF allows , which can enable indirect left recursion.
- 5Step 5
The option whose production form prevents from persisting at the left edge is the one that does not have left recursion.
Do the normal forms structurally prevent left recursion?
Qualitative mapping based on production-shape constraints (typical textbook definitions).
Common confusion checks
Left Recursion & Normal Forms (Quick Recall)
Knowledge Check
A CFG is left-recursive (in the usual definition) if there exists which kind of derivation?