The crucial constraint is the left-hand side: in a context-free production it is exactly one variable. (If the LHS could be a string of symbols, you'd have a context-sensitive grammar.)
The 20% you must own: (1) CFG = single-variable-LHS rewrite rules; (2) language = all terminal strings derivable from S; (3) parse tree encodes structure; (4) ambiguity = ≥2 parse trees. From these you can reason about every parser, every programming-language syntax, and every nesting/counting problem regular expressions fail at.
Recall What are the four components of a CFG, and the LHS restriction?
G=(V,Σ,R,S): variables, terminals, productions, start symbol. Every production's LHS is exactly one variable⇒ context-free.
Recall Define
L(G) precisely.
L(G)={w∈Σ∗∣S⇒∗w} — only fully-terminal strings derivable from S.
Recall What makes a grammar ambiguous? (careful wording)
Some string has two distinct parse trees (equiv. two distinct leftmost derivations). Property of the grammar, not the language.
Recall Why can't a DFA recognise
{(n)n} but a CFG can?
Unbounded nesting needs unbounded counting (a stack); finite states can't, but S→(S)∣ε recurses freely.
Recall Feynman: explain a parse tree to a 12-year-old.
See hidden block below.
Recall (hidden Feynman)Recall Explain like I'm 12
Think of a grammar as LEGO instructions. You begin with one special block called S. Each instruction says "you may swap this block for these smaller blocks." You keep swapping until every block is a real letter you can't break further — that finished line of letters is your word. A parse tree is just the family photo showing which big block split into which small blocks. If the same word can be built into two different family photos, the instructions were sloppy — that sloppiness is called ambiguity.
Socho ek grammar ek recipe hai strings banane ki. Aap ek hi special symbol S se shuru karte ho, aur productions (rules) lagaate ho jisme har baar ek variable ko kisi aur cheez se replace karte ho — tab tak jab tak sirf real letters (terminals) bach jaayein. Jo final string banti hai, woh language L(G) ka part hai. "Context-free" ka matlab simple hai: rule ke left side par sirf ek variable hota hai, isliye aap usse kahin bhi replace kar sakte ho, aas-paas ke symbols matter nahi karte.
CFG itna important kyun hai? Kyunki ye nesting/recursion handle kar sakta hai — jaise matched brackets (()), ya programming language ka syntax. Regular expression aur DFA ye nahi kar paate kyunki unke paas counting ke liye memory (stack) nahi hoti. CFG ka rule S→(S)S∣ε apne aap ko andar bula sakta hai (recursion), isliye unlimited nesting ban jaati hai.
Parse tree ek family photo jaisa hai — kaunsa bada block kis chhote block me toota, ye dikhata hai. Derivation ki order (kaunsa variable pehle expand kiya) matter nahi karti, sirf tree ka structure matter karta hai. Ek tree ke liye exactly ek leftmost derivation hota hai. Agar ek hi string ke do alag-alag parse tree ban jaayein, toh grammar ambiguous hai — jaise a+a*a me precedence clear na ho toh do meanings ban jaate hain. Compiler ke liye ye galat hai, isliye hum precedence layers (E,T,F) laga ke grammar ko unambiguous bana dete hain. Yaad rakho: ambiguity ka test = do tree alag hone chahiye, sirf alag order se derive karna ambiguity nahi hai.