A grammar is defined by
production rules (or just 'productions') that specify which symbols can replace which other symbols; these rules can be used to generate strings, or to parse them. Each such rule has a
head, or left-hand side, which consists of the string that can be replaced, and a
body, or right-hand side, which consists of a string that can replace it. Rules are often written in the form
head →
body; e.g., the rule
a →
b specifies that
a can be replaced by
b. In the classic formalization of generative grammars first proposed by
Noam Chomsky in the 1950s, a grammar
G consists of the following components: • A finite set of
nonterminal symbols. • A finite set of
terminal symbols that is
disjoint from . • A finite set of
production rules, each rule of the form :: V^{*} N V^{*} \rightarrow V^{*} :where V^{*} denotes the set of all possible finite-length strings over the vocabulary V=\Sigma\cup N using
Kleene star. That is, each production rule replaces one string of symbols that contains at least one nonterminal symbol with another. In the case that the body consists solely of the
empty string, it can be denoted with a special notation (often , or ) to avoid confusion. • A distinguished symbol S \in N that is the
start symbol. A grammar is formally defined as the ordered quadruple \langle N, \Sigma, P, S\rangle. Such a formal grammar is often called a
rewriting system or a
phrase structure grammar in the literature. == Example ==