diff --git a/semester3/ti-compact/parts/06_grammars.tex b/semester3/ti-compact/parts/06_grammars.tex new file mode 100644 index 0000000..9254014 --- /dev/null +++ b/semester3/ti-compact/parts/06_grammars.tex @@ -0,0 +1,27 @@ +\newsection +\section{Grammars} +\fancydef{Grammar} $G := (\Sigma_\text{N}, \Sigma_\text{T}, P, S)$ + +\begin{enumerate}[noitemsep] + \item \bi{Non-Terminals} $\Sigma_\text{N}$ (Are used for the rules) + \item \bi{Terminals} $\Sigma_\text{T}$ (The symbols at the end (i.e. only they can be remaining after the last derivation)) + \item \bi{Start symbol} $S \in \Sigma_\text{N}$ + \item \bi{Derivation rules} $P \subseteq \Sigma^*\Sigma_\text{N}\Sigma^* \times \Sigma^*$ +\end{enumerate} +where $\Sigma_\text{N} \cap \Sigma_\text{T} = \emptyset$ and $\Sigma := \Sigma_\text{N} \cup \Sigma_\text{T}$ + +\begin{definition}[]{Types of grammars} + \begin{enumerate} + \item $G$ is a \bi{Type-0-Grammar} if it has no further restrictions. + \item $G$ is a \bi{Type-1-Grammar} (or \bi{context-sensitive} (= Kontextsensitiv) Grammar) if we cannot replace a subword $\alpha$ with a shorter subword $\beta$. + \item $G$ is a \bi{Type-2-Grammar} (or \bi{context-free} (= Kontextfrei) Grammar) if all rules have the form $X \rightarrow \beta$ for a non-terminal $X$. + \item $G$ is a \bi{Type-3-Grammar} (or \bi{regular} (= regulär) Grammar) if all rules have the form $X \rightarrow u$ or $X \rightarrow uY$ + \end{enumerate} +\end{definition} +A few examples to highlight what kind of derivation rules are allowed. The rules disallowed in $n$ are also disallowed in $n + 1$: +\begin{enumerate} + \item All kind of rules are allowed + \item Rules like $X \rightarrow \lambda$ or $0Y1 \rightarrow 00$ are not allowed (they shorten the output) + \item Rules like $aA \rightarrow Sb$ are not allowed, as they are not context-free (i.e. all rules have to be of form $X \rightarrow \ldots$) + \item Rules like $S \rightarrow abbAB$ are not allowed, as two non-terminals appear +\end{enumerate} diff --git a/semester3/ti-compact/ti-compact.pdf b/semester3/ti-compact/ti-compact.pdf index 9c1ed27..690ceb5 100644 Binary files a/semester3/ti-compact/ti-compact.pdf and b/semester3/ti-compact/ti-compact.pdf differ diff --git a/semester3/ti-compact/ti-compact.tex b/semester3/ti-compact/ti-compact.tex index 3298672..595f348 100644 --- a/semester3/ti-compact/ti-compact.tex +++ b/semester3/ti-compact/ti-compact.tex @@ -68,6 +68,7 @@ All prior content is still relevent to the extent that you need an understanding \input{parts/03_turing-machines.tex} \input{parts/04_computability.tex} \input{parts/05_complexity.tex} +\input{parts/06_grammars.tex}