31
|
1 |
\documentclass{article}
|
|
2 |
\usepackage{charter}
|
|
3 |
\usepackage{hyperref}
|
|
4 |
\usepackage{amssymb}
|
|
5 |
\usepackage{amsmath}
|
|
6 |
|
32
|
7 |
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
|
|
8 |
|
31
|
9 |
\begin{document}
|
|
10 |
|
|
11 |
\section*{Homework 4}
|
|
12 |
|
|
13 |
\begin{enumerate}
|
34
|
14 |
\item Why is every finite set of strings a regular language?
|
|
15 |
|
|
16 |
|
32
|
17 |
\item Give an automaton that can recognise the language
|
|
18 |
$L(a^*\cdot b\cdot b^*\cdot(a\cdot a^*\cdot b\cdot b^*)^*)$.
|
|
19 |
|
|
20 |
\item Assume that $s^{-1}$ stands for the operation of reversing a
|
|
21 |
string $s$. Given the following \emph{reversing} function on regular
|
|
22 |
expressions
|
|
23 |
|
34
|
24 |
\begin{center}
|
|
25 |
\begin{tabular}{r@{\hspace{1mm}}c@{\hspace{1mm}}l}
|
|
26 |
$rev(\varnothing)$ & $\dn$ & $\varnothing$\\
|
|
27 |
$rev(\epsilon)$ & $\dn$ & $\epsilon$\\
|
|
28 |
$rev(c)$ & $\dn$ & $c$\\
|
|
29 |
$rev(r_1 + r_2)$ & $\dn$ & $rev(r_1) + rev(r_2)$\\
|
|
30 |
$rev(r_1 \cdot r_2)$ & $\dn$ & $rev(r_2) \cdot rev(r_1)$\\
|
|
31 |
$rev(r^*)$ & $\dn$ & $rev(r)^*$\\
|
|
32 |
\end{tabular}
|
|
33 |
\end{center}
|
|
34 |
|
|
35 |
|
32
|
36 |
and the set
|
|
37 |
|
31
|
38 |
\begin{center}
|
32
|
39 |
$Rev\,A \dn \{s^{-1} \;|\; s \in A\}$
|
31
|
40 |
\end{center}
|
|
41 |
|
34
|
42 |
prove whether
|
32
|
43 |
|
31
|
44 |
\begin{center}
|
32
|
45 |
$L(rev(r)) = Rev (L(r))$
|
31
|
46 |
\end{center}
|
|
47 |
|
32
|
48 |
holds.
|
31
|
49 |
|
32
|
50 |
\item Palindromes
|
31
|
51 |
|
|
52 |
\item (Optional) The tokenizer in \texttt{regexp3.scala} takes as
|
|
53 |
argument a string and a list of rules. The result is a list of tokens. Improve this tokenizer so
|
|
54 |
that it filters out all comments and whitespace from the result.
|
|
55 |
|
|
56 |
\item (Optional) Modify the tokenizer in \texttt{regexp2.scala} so that it
|
|
57 |
implements the \texttt{findAll} function. This function takes a regular
|
|
58 |
expressions and a string, and returns all substrings in this string that
|
|
59 |
match the regular expression.
|
|
60 |
\end{enumerate}
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
\end{document}
|
|
65 |
|
|
66 |
%%% Local Variables:
|
|
67 |
%%% mode: latex
|
|
68 |
%%% TeX-master: t
|
|
69 |
%%% End:
|