1
This topic covers context-free grammars (CFGs), parsing/derivation, grammar normal forms, pushdown automata (PDA), and closure properties of context-free languages.
2
A CFG is formally a 4-tuple (V, T, P, S): a set of variables (non-terminals), terminals, production rules, and a start symbol.
3
A derivation/parse tree graphically represents how a string is derived from the start symbol using the production rules.
4
A leftmost derivation always replaces the leftmost non-terminal first; a rightmost derivation always replaces the rightmost non-terminal first.
5
Top-down parsing builds the parse tree from the start symbol down towards the input string; bottom-up parsing starts from the input string and reduces up towards the start symbol.
6
The language of a grammar L(G) is the set of all terminal strings that can be derived from the start symbol.
7
A grammar is ambiguous if some string in its language has more than one distinct parse tree (or more than one leftmost derivation).
8
Chomsky Normal Form (CNF): every production is of the form A → BC or A → a (two variables, or a single terminal).
9
Greibach Normal Form (GNF): every production is of the form A → aα (a terminal followed by zero or more variables).
10
Backus-Naur Form (BNF) is a notation used to formally express context-free grammars, widely used to define the syntax of programming languages.
11
A Pushdown Automaton (PDA) is a finite automaton augmented with an auxiliary stack, giving it more memory/power than a plain finite automaton.
12
Equivalence of CFL and PDA: a language is context-free if and only if some PDA accepts it.
13
The pumping lemma for context-free languages is used to prove a language is NOT context-free.
14
Properties of context-free languages: CFLs are closed under union, concatenation, and Kleene star, but are NOT, in general, closed under intersection or complement.