<< What does it mean “without restricting the power of CFGs”? >>
<< Question: Why don’t we also delete \(B\) rules? >>
What was the point to this? Look at derivations.
We want to eliminate both types of useless production (ones that can’t be reached, and ones that don’t terminate).
To Remove Useless Productions:
Let \(G = (V,T,S,P)\).
NOTE: Now need to get rid of productions we can’t use.
Now, do it again.
NOTE: Last time talked about simpler CFG that had no \(\lambda\) productions, now we will show how to get rid of them.
NOTE: Don’t add \(A \rightarrow \lambda\)!
This becomes: \(A \rightarrow a \mid ab\)
But we didn’t get rid of unit productions!
Unit Production Dependency Graph:
There are additional examples in the book.
Any CFG \(G\) with \(\lambda\) not in \(L(G)\) has an equivalent grammar in CNF.
NOTE: Can get rid of \(\lambda\) productions and unit productions first!
This is like an s-grammar (or simple grammar), except the s-grammar definition includes a further restriction that any pair \((A, a)\) can occur at most in one rule.
This is so that you wouldn’t have to backtrack (only one choice to match the derivation of a string). So it is very restrictive.