cws/cw01.tex
author Christian Urban <urbanc@in.tum.de>
Thu, 03 Nov 2016 00:53:53 +0000
changeset 6 aae256985251
child 9 48a477fdef21
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass{article}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\usepackage{style}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
%%\usepackage{../langs}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\begin{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\section*{Coursework 1 (Strand 1)}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
This coursework is worth 4\% and is due on 25 October at
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
16:00. You are asked to implement a regular expression matcher
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
and submit a document containing the answers for the questions
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
below. You can do the implementation in any programming
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
language you like, but you need to submit the source code with
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
which you answered the questions, otherwise a mark of 0\% will
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
be awarded. You can submit your answers in a txt-file or pdf.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
Code send as code.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\subsubsection*{Disclaimer}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
It should be understood that the work you submit represents
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
your own effort. You have not copied from anyone else. An
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
exception is the Scala code I showed during the lectures or
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
uploaded to KEATS, which you can freely use.\bigskip
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
\subsubsection*{Task}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
The task is to implement a regular expression matcher based on
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
derivatives of regular expressions. The implementation should
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
be able to deal with the usual (basic) regular expressions
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
\[
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
\ZERO,\; \ONE,\; c,\; r_1 + r_2,\; r_1 \cdot r_2,\; r^*
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
\]
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
but also with the following extended regular expressions:
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
\begin{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
\begin{tabular}{ll}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
$[c_1 c_2 \ldots c_n]$ & a range of characters\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
$r^+$ & one or more times $r$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
$r^?$ & optional $r$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
$r^{\{n,m\}}$ & at least $n$-times $r$ but no more than $m$-times\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
$\sim{}r$ & not-regular expression of $r$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
\end{tabular}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
\end{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
\noindent In the case of $r^{\{n,m\}}$ you can assume the
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
convention that $0 \le n \le m$. The meanings of the extended
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
regular expressions are
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
\begin{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
\begin{tabular}{r@{\hspace{2mm}}c@{\hspace{2mm}}l}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
$L([c_1 c_2 \ldots c_n])$ & $\dn$ & $\{[c_1], [c_2], \ldots, [c_n]\}$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
$L(r^+)$                  & $\dn$ & $\bigcup_{1\le i}. L(r)^i$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
$L(r^?)$                  & $\dn$ & $L(r) \cup \{[]\}$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
$L(r^{\{n,m\}})$           & $\dn$ & $\bigcup_{n\le i \le m}. L(r)^i$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
$L(\sim{}r)$              & $\dn$ & $\Sigma^* - L(r)$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
\end{tabular}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
\end{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
\noindent whereby in the last clause the set $\Sigma^*$ stands
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
for the set of \emph{all} strings over the alphabet $\Sigma$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
(in the implementation the alphabet can be just what is
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
represented by, say, the type \texttt{Char}). So $\sim{}r$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
means `all the strings that $r$ cannot match'. 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
Be careful that your implementation of \textit{nullable} and
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
\textit{der} satisfies for every $r$ the following two
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
properties (see also Question 2):
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
\begin{itemize}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
\item $\textit{nullable}(r)$ if and only if $[]\in L(r)$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
\item $L(der\,c\,r) = Der\,c\,(L(r))$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
\end{itemize}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
\noindent {\bf Important!} Your implementation should have
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
explicit cases for the basic regular expressions, but also
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
explicit cases for the extended regular expressions. That
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
means do not treat the extended regular expressions by just
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
translating them into the basic ones. See also Question 2,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
where you are asked to explicitly give the rules for
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
\textit{nullable} and \textit{der} for the extended regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
expressions.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
\subsection*{Question 1}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
What is your King's email address (you will need it in
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
Question 3)?
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
\subsection*{Question 2}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
This question does not require any implementation. From the
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
lectures you have seen the definitions for the functions
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
\textit{nullable} and \textit{der} for the basic regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
expressions. Give the rules for the extended regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
expressions:
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
\begin{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
$\textit{nullable}([c_1 c_2 \ldots c_n])$  & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
$\textit{nullable}(r^+)$                   & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
$\textit{nullable}(r^?)$                   & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
$\textit{nullable}(r^{\{n,m\}})$            & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
$\textit{nullable}(\sim{}r)$               & $\dn$ & $?$\medskip\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
$der\, c\, ([c_1 c_2 \ldots c_n])$  & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
$der\, c\, (r^+)$                   & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
$der\, c\, (r^?)$                   & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
$der\, c\, (r^{\{n,m\}})$            & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
$der\, c\, (\sim{}r)$               & $\dn$ & $?$\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
\end{tabular}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
\end{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
Remember your definitions have to satisfy the two properties
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
\begin{itemize}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
\item $\textit{nullable}(r)$ if and only if $[]\in L(r)$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
\item $L(der\,c\,r)) = Der\,c\,(L(r))$
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
\end{itemize}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
\subsection*{Question 3}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
Implement the following regular expression for email addresses
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
\[
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
([a\mbox{-}z0\mbox{-}9\_\!\_\,.-]^+)\cdot @\cdot ([a\mbox{-}z0\mbox{-}9\,.-]^+)\cdot .\cdot ([a\mbox{-}z\,.]^{\{2,6\}})
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
\]
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
\noindent and calculate the derivative according to your email
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
address. When calculating the derivative, simplify all regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
expressions as much as possible by applying the
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
following 7 simplification rules:
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
\begin{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}ll}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
$r \cdot \ZERO$ & $\mapsto$ & $\ZERO$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
$\ZERO \cdot r$ & $\mapsto$ & $\ZERO$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
$r \cdot \ONE$ & $\mapsto$ & $r$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
$\ONE \cdot r$ & $\mapsto$ & $r$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
$r + \ZERO$ & $\mapsto$ & $r$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
$\ZERO + r$ & $\mapsto$ & $r$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
$r + r$ & $\mapsto$ & $r$\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
\end{tabular}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
\end{center}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
\noindent Write down your simplified derivative in a readable
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
notation using parentheses where necessary. That means you
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
should use the infix notation $+$, $\cdot$, $^*$ and so on,
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
instead of code.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
\subsection*{Question 4}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
Suppose \textit{[a-z]} stands for the range regular expression
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
$[a,b,c,\ldots,z]$.  Consider the regular expression $/ \cdot * \cdot
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
(\sim{}([a\mbox{-}z]^* \cdot * \cdot / \cdot [a\mbox{-}z]^*)) \cdot *
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
\cdot /$ and decide wether the following four strings are matched by
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
this regular expression. Answer yes or no.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
\begin{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
\item \texttt{"/**/"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
\item \texttt{"/*foobar*/"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
\item \texttt{"/*test*/test*/"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
\item \texttt{"/*test/*test*/"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
\end{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
Also test your regular expression matcher with the regular
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
expression $a^{\{3,5\}}$ and the strings
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
\begin{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
\setcounter{enumi}{4}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
\item \texttt{aa}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
\item \texttt{aaa}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
\item \texttt{aaaaa}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
\item \texttt{aaaaaa}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
\end{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
Does your matcher produce the expected results?
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
\subsection*{Question 5}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
Let $r_1$ be the regular expression $a\cdot a\cdot a$ and $r_2$ be
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
$(a^{\{19,19\}}) \cdot (a^?)$.  Decide whether the following three
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
strings consisting of $a$s only can be matched by $(r_1^+)^+$.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
Similarly test them with $(r_2^+)^+$. Again answer in all six cases
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
with yes or no. \medskip
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
\noindent
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
These are strings are meant to be entirely made up of $a$s. Be careful
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
when copy-and-pasting the strings so as to not forgetting any $a$ and
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
to not introducing any other character.
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
\begin{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
\end{enumerate}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
\end{document}
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
%%% Local Variables: 
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
%%% mode: latex
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
%%% TeX-master: t
aae256985251 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
%%% End: