A production or production rule in computer science is a rewrite rule specifying a symbol substitution that can be recursively performed to generate new symbol sequences. A finite set of productions
P
N
\Sigma
N
S\inN
In an unrestricted grammar, a production is of the form
u\tov
u
v
u
v
\epsilon
λ
V*NV* x V*=(V*\setminus\Sigma*) x V*
where
V:=N\cup\Sigma
{}*
V*NV*
\cup
\setminus
v
V*
(V\setminus\{S\})*
The other types of formal grammar in the Chomsky hierarchy impose additional restrictions on what constitutes a production. Notably in a context-free grammar, the left-hand side of a production must be a single nonterminal symbol. So productions are of the form:
N\to(N\cup\Sigma)*
To generate a string in the language, one begins with a string consisting of only a single start symbol, and then successively applies the rules (any number of times, in any order) to rewrite this string. This stops when a string containing only terminals is obtained. The language consists of all the strings that can be generated in this manner. Any particular sequence of legal choices taken during this rewriting process yields one particular string in the language. If there are multiple different ways of generating this single string, then the grammar is said to be ambiguous.
For example, assume the alphabet consists of
a
b
S
1.
S → aSb
2.
S → ba
then we start with
S
S
aSb
aSb
S
aSb
aaSbb
a
b
S
ba
aababb
S ⇒ aSb ⇒ aaSbb ⇒ aababb
\{ba,abab,aababb,aaababbb,...c\}