hw07.tex
author Christian Urban <urbanc@in.tum.de>
Wed, 14 Nov 2012 00:02:38 +0000
changeset 60 68d664c204d2
parent 59 b64e876832cc
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}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\usepackage{charter}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
\usepackage{hyperref}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\usepackage{amssymb}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{amsmath}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage{tikz}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\usetikzlibrary{automata}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\section*{Homework 7}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\begin{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\item Suppose the following finite deterministic automaton over the alphabet $\{0, 1\}$.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
\begin{tikzpicture}[scale=2, line width=0.5mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  \node[state, initial, accepting]        (q0) at ( 0,1) {$q_0$};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  \node[state, accepting]                    (q1) at ( 1,1) {$q_1$};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
 \node[state] (q2) at ( 2,1) {$q_2$};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  \path[->] (q0) edge[bend left] node[above] {$0$} (q1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
                  (q1) edge[bend left] node[above] {$1$} (q0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
                  (q2) edge[bend left=50] node[below] {$1$} (q0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
                  (q1) edge node[above] {$0$} (q2)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
                  (q2) edge [loop right] node {$0$} ()
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
                  (q0) edge [loop below] node {$1$} ()
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
            ;
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
\end{tikzpicture}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
Give a regular expression that can recognise the same language as
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
this automaton. (Hint: If you use Brzozwski's method, you can assume
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
Arden's lemma which states that an equation of the form $q = q\cdot r + s$
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
has the unique solution $q = s \cdot r^*$.)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
\item Consider the following grammar 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
\begin{tabular}{l}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
$S \rightarrow N\cdot P$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
$P \rightarrow V\cdot N$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
$N \rightarrow N\cdot N$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
$N \rightarrow A \cdot N$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
$N \rightarrow \texttt{student} \;|\; \texttt{trainer} \;|\; \texttt{team} \;|\; \texttt{trains}$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
$V \rightarrow \texttt{trains} \;|\; \texttt{team}$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
$A \rightarrow \texttt{The} \;|\; \texttt{the}$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
\end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
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
    53
Using the CYK-algorithm, check whether or not the following string can be parsed
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
by the grammar:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
\texttt{The trainer trains the student team}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
60
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    60
\item {\bf (Optional)} The task is to match strings where the letters are in alphabetical order---for example, 
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    61
\texttt{abcfjz} would pass, but \texttt{acb} would not. Whitespace should be ignored---for example
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    62
\texttt{ab c d} should pass. The point is to try to get the regular expression as short as possible!
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    63
See:
59
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
60
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    65
\begin{center}
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    66
\url{http://callumacrae.github.com/regex-tuesday/challenge11.html}
68d664c204d2 updated
Christian Urban <urbanc@in.tum.de>
parents: 59
diff changeset
    67
\end{center}
59
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
\end{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
%%% Local Variables: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
%%% End: