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