Definition (grammar, language)
A (variable-based) grammar $G$ over $Σ$ is a tuple $(Σ, N, P, S)$ where
-
$Σ$ is a non-empty finite set (the alphabet, containing terminal symbols or letters);
-
$N$ is a non-empty finite set (the non-terminal symbols or variables), disjoint from $Σ$;
-
$(Ω, P)$ is a rewrite system, where $Ω = Σ\cup N$,
-
every rewrite rule $α\to β\in P$ has $α\in N^+$;
-
$S\in N$ (the start symbol).
Any subset $L\subseteq Σ^\ast$ is a language over $Σ$.
We say a word $w\in Ω^\ast$ is in sentential form if $w$ can be derived from the start symbol $S$.
A sentence is a word $w\in Σ^\ast$ in sentential form.
The language generated by $G$ is the set of all sentences: $$ \begin{align*} \mathcal{L}(G) = Σ^\ast \cap \mathcal{D}(G, S) = \set{w\in Σ^\ast \; | \; S\xrightarrow{G} w}. \end{align*} $$