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