Context-Free Grammar

Definition. A context-free grammar is a four-tuple G=(V,Σ,R,S)G = (V, \Sigma, R, S) where VV is a finite set of variables, Σ\Sigma is a finite set of terminals disjoint from VV, RR is a finite set of rules of the form A→wA \to w with A∈VA \in V and w∈(V∪Σ)∗w \in (V \cup \Sigma)^*, and S∈VS \in V is the start variable.

A grammar generates strings rather than recognizing them: begin with SS and repeatedly replace a variable by the right-hand side of one of its rules, until only terminals remain. The name records the restriction that a rule's left side is a single variable, so what a variable may become never depends on what surrounds it. Defined in Lecture 5, where grammars are proved equivalent to the pushdown automaton. A grammar may be ambiguous even when the language it generates has an unambiguous grammar.

Updated
Copyright © 2026 Jared Coleman. All rights reserved.