To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit e21fdd80 authored by zrene's avatar zrene
Browse files

Beispiele von CFG hinzugefügt

parent 97609f67
%! TEX root = DES.tex
%! TEX root = ../DES.tex
\section{Intelligentere Automaten}
\subsection{Kontext-freie Grammatik (CFG)}
......@@ -227,4 +227,150 @@ Ein String $x$ ist akzeptiert von $M$, wenn, nachdem $x$ auf das Tape geschriebe
\subsection{Decidability?, Halting-Problem?}
\subsection{Beispiele - Kontextfreie Grammatiken}
\begin{itemize}
\item $L = \{w\ |\ $the length of w is odd $\}$ \\
\textbf{Lösung}
\\ $ V = {X,A} $\\
$\Sigma = {0,1} $ \\
$ R= \begin{cases}
X \rightarrow XAX | A \\
A \rightarrow 0 | 1
\end{cases} \\
S = X
$\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $L = \{w\ |\ $contains more 1s than 0s $\}$ \\
\textbf{Lösung}
\\ $ V = {A} $\\
$\Sigma = {0,1} $ \\
$ R = \{ A \rightarrow AA\ |\ 1A0\ |\ 0A1\ |\ 1\ |\ \varepsilon\} $\\
$ S = A1A $ \\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $L = \{w\#x\#y\#z\ |\ w,x,y,z \ \in \{ a,b \}^* $ and $|w| = |z| , |x| = |y| \}$ \\
\textbf{Lösung}
\\ $ V = {A,B,Y} $\\
$\Sigma = {a,b,\#} $ \\
$ R= \begin{cases}
A \rightarrow YAY\ |\ \#B\# \\
B \rightarrow YBY\ | \# \\
Y \rightarrow a|b
\end{cases}$ \\
$ S = A $\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $L = \{w\#x\#y\#z\ |\ w,x,y,z \ \in \{ a,b \}^* $ and $|w| = |y| , |x| = |z| \}$ \\
\textbf{Lösung}\\
This Grammar is NOT context Free!\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\\
\item $ L = \{w | w $ starts and ends with the same symbol$\}$ \\
$S_0 \rightarrow 0 S_1 0 \ | \ 1 S_1 1\ |\ \varepsilon $ \\
$S_1 \rightarrow 0 S_1 \ | \ 1 S_1 |\ \varepsilon $\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{w | w=w^R $(w is a Palyndrom) $\}$ \\
$S_0 \rightarrow 1S_01\ | \ 0S_0 0 \ |\ 0\ |\ 1\ | \varepsilon$\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{w | $(w besitzt doppelt so viele 'a' wie 'b') $\}$ \\
$S_0 \rightarrow S_1aab\ |\ aS_1aab \ | \ aaS_1b \ |\ aabS_1\ | \ S_1aba \ | \ aS_1ba \ | \ abS_1a \ |$\\
.\ \ \ \ \ \ \ \ \ \ \ \ \ $ abaS_1 \ | \ S_1baa \ | \ bS_1aa \ | \ baS_1a \ | \ baaS_1 $ \\
$S_1 \rightarrow S_0 | \varepsilon$\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{a^i b^j c^k | i=j + k \}$ \\
$S_0 \rightarrow aS_0c \ |\ S_1$ \\
$S_1 \rightarrow aS_1b\ |\ \varepsilon$ \\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{a^i b^j c^k | j= i + k \}$ \\
$S_0 \rightarrow aS_1bS_2\ |\ S_1bS_2c\ |\ \varepsilon$ \\
$S_1 \rightarrow aS_1b\ |\ \varepsilon$ \\
$S_2 \rightarrow bS_2c\ |\ \varepsilon$ \\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{a^i b^j c^k | j= i + k \}$ \\
$S_0 \rightarrow aS_1bS_2\ |\ S_1bS_2c\ |\ \varepsilon$ \\
$S_1 \rightarrow aS_1b\ |\ \varepsilon$ \\
$S_2 \rightarrow bS_2c\ |\ \varepsilon$ \\
\\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{a^i b^j c^k | j= i $ or $ j = k \}$ \\
\begin{itemize}
\item $L_1 = \{a^i b^j c^k | j= i\}$
$S_1 \rightarrow aS_2bS_3\ |\ \varepsilon$ \\
$S_2 \rightarrow aS_2b\ |\ \varepsilon$ \\
$S_3 \rightarrow cS_3\ |\ \varepsilon$ \\
\item $L_2 = \{a^i b^j c^k | j= k\}$
$S_4 \rightarrow S_5bS_6c\ |\ \varepsilon$ \\
$S_5 \rightarrow cS_5\ |\ \varepsilon$ \\
$S_6 \rightarrow bS_6c\ |\ \varepsilon$ \\
\end{itemize}
$\rightarrow L = L_1\ |\ L_2 $ \\
$\Rightarrow S_0 \rightarrow S_1\ | \ S_4$ \\
\vspace{0.1cm}
\hrule
\vspace{-0.1cm}
\item $ L = \{a^i b^j c^k | i \neq i + k \}$ \\
$ \{a^i b^j c^k | i \neq i + k \} = \{a^i b^j c^k | i > j + k \} \cup \{a^i b^j c^k | i < j + k \}$ \\
\begin{itemize}
\item $L_1 = \{a^i b^j c^k | i> j + k \}$ \\
$S_1 \rightarrow aS_2$ \\
$S_2 \rightarrow aS_2\ |\ aS_2c \ |\S_3$ \\
$S_3 \rightarrow aS_3 \ |\ aS_3b \ |\ \varepsilon$ \\
\item $L_2 = \{a^i b^j c^k | i < j + k\}$
$S_4 \rightarrow s_5c$ \\
$S_5 \rightarrow s_5c \ |\ aS_5c \ |\ S_6 $ \\
$S_6 \rightarrow S_6b\ |\ aS_6b \ |\ \varepsilon $ \\
\end{itemize}
$ L = \{a^i b^j c^k | i \neq i + k \}$ \\
$\Rightarrow S_0 \rightarrow S_1| S_4$
\end{itemize}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment