author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sun, 17 Nov 2013 18:16:20 +0000 | |
changeset 194 | 90796ee3c17a |
parent 183 | b17eff695c7f |
child 292 | 7ed2a25dd115 |
permissions | -rw-r--r-- |
59 | 1 |
\documentclass{article} |
2 |
\usepackage{charter} |
|
3 |
\usepackage{hyperref} |
|
4 |
\usepackage{amssymb} |
|
5 |
\usepackage{amsmath} |
|
6 |
\usepackage{tikz} |
|
7 |
\usetikzlibrary{automata} |
|
8 |
||
9 |
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions |
|
10 |
||
11 |
\begin{document} |
|
12 |
||
13 |
\section*{Homework 7} |
|
14 |
||
15 |
\begin{enumerate} |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
16 |
\item Suppose the context-sensitive grammar |
59 | 17 |
|
18 |
\begin{center} |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
19 |
\begin{tabular}{lcl} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
20 |
$S$ & $\rightarrow$ & $bSAA\;|\; \epsilon$\\ |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
21 |
$A$ & $\rightarrow$ & $a$\\ |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
22 |
$bA$ & $\rightarrow$ & $Ab$\\ |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
23 |
\end{tabular} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
24 |
\end{center} |
183
b17eff695c7f
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
25 |
|
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
26 |
where $S$ is the starting symbol of the grammar. |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
27 |
Give a derivation of the string $"\!aaabaaabb"$. |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
28 |
What can you say about the number of as and bs in the |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
29 |
strings recognised by this grammar. |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
30 |
|
59 | 31 |
|
32 |
\item Consider the following grammar |
|
33 |
||
34 |
\begin{center} |
|
35 |
\begin{tabular}{l} |
|
36 |
$S \rightarrow N\cdot P$\\ |
|
37 |
$P \rightarrow V\cdot N$\\ |
|
38 |
$N \rightarrow N\cdot N$\\ |
|
39 |
$N \rightarrow A \cdot N$\\ |
|
40 |
$N \rightarrow \texttt{student} \;|\; \texttt{trainer} \;|\; \texttt{team} \;|\; \texttt{trains}$\\ |
|
41 |
$V \rightarrow \texttt{trains} \;|\; \texttt{team}$\\ |
|
42 |
$A \rightarrow \texttt{The} \;|\; \texttt{the}$\\ |
|
43 |
\end{tabular} |
|
44 |
\end{center} |
|
45 |
||
46 |
where $S$ is the start symbol and $S$, $P$, $N$, $V$ and $A$ are non-terminals. |
|
47 |
Using the CYK-algorithm, check whether or not the following string can be parsed |
|
48 |
by the grammar: |
|
49 |
||
50 |
\begin{center} |
|
51 |
\texttt{The trainer trains the student team} |
|
52 |
\end{center} |
|
53 |
||
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
54 |
\item Transform the grammar |
59 | 55 |
|
60 | 56 |
\begin{center} |
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
57 |
\begin{tabular}{lcl} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
58 |
$A$ & $\rightarrow$ & $0A1 \;|\; BB$\\ |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
59 |
$B$ & $\rightarrow$ & $\epsilon \;|\; 2B$ |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
60 |
\end{tabular} |
60 | 61 |
\end{center} |
194
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
62 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
63 |
\noindent |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
64 |
into Chomsky normal form. |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
65 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
66 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
67 |
%\item {\bf (Optional)} The task is to match strings where the letters are in alphabetical order---for example, |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
68 |
%\texttt{abcfjz} would pass, but \texttt{acb} would not. Whitespace should be ignored---for example |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
69 |
%\texttt{ab c d} should pass. The point is to try to get the regular expression as short as possible! |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
70 |
%See: |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
71 |
|
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
72 |
%\begin{center} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
73 |
%\url{http://callumacrae.github.com/regex-tuesday/challenge11.html} |
90796ee3c17a
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
183
diff
changeset
|
74 |
%\end{center} |
59 | 75 |
\end{enumerate} |
76 |
||
77 |
\end{document} |
|
78 |
||
79 |
%%% Local Variables: |
|
80 |
%%% mode: latex |
|
81 |
%%% TeX-master: t |
|
82 |
%%% End: |