140 likes | 260 Views
This text explores the concept of Context-Free Languages (CFL) in computational theory, focusing on single-step derivations, substitution rules, and the structure of context-free grammars (CFGs). It explains notation used in derivations, including the distinction between single and double arrows. The language generated by a grammar is defined, and examples of grammars that produce specific languages, such as those with balanced parentheses, are provided. Additionally, it addresses topics like parse trees, derivations, and the handling of ambiguity in grammar.
E N D
CS 3240: Languages and Computation Context-Free Languages
Context-Free Languages • A single step derivation “” consist of the substitution of a variable by a string according to a substitution rule in R • Note that rules use single arrows “”, while derivations themselves use double arrows “” • A sequence of several derivations (or none) is indicated by “ * ” • Previous example: “S * aabbaa” • L is a Context Free Language if and only if there is a context free grammar G=(V, Σ, P, S) such that L = L(G) = { w | w Σ * and S * w }
Some Remarks • The language L(G) = { w | w Σ* and S * w } contains only strings of terminals, not variables. • Notation: We can agglomerate several rules for one variable:A B A 01 by A B | 01 | AAA AA • What is the CFG ({S},{(,)},P, S) that produces the language of correct parentheses like (), (()), or ()(())? • Answer: S→ (S) | SS |