author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Mon, 11 Nov 2013 13:48:34 +0000 | |
changeset 183 | b17eff695c7f |
parent 102 | 1ab41c59e3d3 |
child 194 | 90796ee3c17a |
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} |
|
183
b17eff695c7f
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
16 |
\item Suppose the following grammar for positive numbers |
59 | 17 |
|
18 |
\begin{center} |
|
183
b17eff695c7f
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
19 |
|
59 | 20 |
\end{center} |
21 |
||
22 |
\item Consider the following grammar |
|
23 |
||
24 |
\begin{center} |
|
25 |
\begin{tabular}{l} |
|
26 |
$S \rightarrow N\cdot P$\\ |
|
27 |
$P \rightarrow V\cdot N$\\ |
|
28 |
$N \rightarrow N\cdot N$\\ |
|
29 |
$N \rightarrow A \cdot N$\\ |
|
30 |
$N \rightarrow \texttt{student} \;|\; \texttt{trainer} \;|\; \texttt{team} \;|\; \texttt{trains}$\\ |
|
31 |
$V \rightarrow \texttt{trains} \;|\; \texttt{team}$\\ |
|
32 |
$A \rightarrow \texttt{The} \;|\; \texttt{the}$\\ |
|
33 |
\end{tabular} |
|
34 |
\end{center} |
|
35 |
||
36 |
where $S$ is the start symbol and $S$, $P$, $N$, $V$ and $A$ are non-terminals. |
|
37 |
Using the CYK-algorithm, check whether or not the following string can be parsed |
|
38 |
by the grammar: |
|
39 |
||
40 |
\begin{center} |
|
41 |
\texttt{The trainer trains the student team} |
|
42 |
\end{center} |
|
43 |
||
60 | 44 |
\item {\bf (Optional)} The task is to match strings where the letters are in alphabetical order---for example, |
45 |
\texttt{abcfjz} would pass, but \texttt{acb} would not. Whitespace should be ignored---for example |
|
46 |
\texttt{ab c d} should pass. The point is to try to get the regular expression as short as possible! |
|
47 |
See: |
|
59 | 48 |
|
60 | 49 |
\begin{center} |
50 |
\url{http://callumacrae.github.com/regex-tuesday/challenge11.html} |
|
51 |
\end{center} |
|
59 | 52 |
\end{enumerate} |
53 |
||
54 |
\end{document} |
|
55 |
||
56 |
%%% Local Variables: |
|
57 |
%%% mode: latex |
|
58 |
%%% TeX-master: t |
|
59 |
%%% End: |