◀ ▲ ▶Branches / Logic / Definition: Grammar (Syntax)
The above examples motivate the following definition:
Definition: Grammar (Syntax)
Let $\Sigma$ be an alphabet. A grammar (or syntax ) is a tuple $G=(V,T,R,S)$ consisting of
- $V\subset\Sigma^*$ a finite set of variables,
- $T\subset\Sigma$ a finite set of terminal symbols (or terminals), i.e. some special characters from the alphabet $\Sigma$ such that $V\cap T=\emptyset$.
- A non-empty, finite set of rules $R$, i.e. pairs $(P,C)\in R$ of premises $P$ and conclusions $C$ such that $P\in (V\cup T)^*V (V\cup T)^*$ is a string containing at least one variable and $C\in(V\cup T)^*$ is a string.
- $S\in V$ as a starting symbol (a first to be replaced terminal symbol)
Notes
- A syntax rule $R$ expresses how a string $P$ containing a variable can be transformed into another string $C$.
- Syntax rules can be optional, for instance, $S\to HN$ and $S\to H$ might be two coexisting rules of syntax, replacing the starting variable by the concatenation of $HN$ or only by $H$.
- The (formal) language which is generated by the syntax, consists of all strings that can be generated when applying the ruleset, starting from the starting symbol.
- $(V\cup T)^*$ denotes the Kleene star of the union of all variables and all terminals of the grammar. Correspondingly, an element of this union is any (even the empty string) concatenation of variables and terminal symbols.
Table of Contents
Examples: 1
Mentioned in:
Branches: 1
Chapters: 2 3 4 5 6
Definitions: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Examples: 26 27
Explanations: 28
Parts: 29 30
Proofs: 31 32
Thank you to the contributors under CC BY-SA 4.0!
- Github:
-
References
Bibliography
- Knauer Ulrich: "Diskrete Strukturen - kurz gefasst", Spektrum Akademischer Verlag, 2001