A context-free grammar is a quadruple in which
is a finite set of nonterminal symbols,
is a finite set of terminal symbols disjoint from
,
is the start symbol, and
is a finite set of production rules of the form
where
and
is a string of symbols from
. Repeatedly applying the rules beginning with
and retaining strings containing only terminal symbols generates a formal
language, called a context-free language.