hw03.tex
author Christian Urban <urbanc@in.tum.de>
Thu, 11 Oct 2012 10:58:18 +0100
changeset 29 774007c4b1b3
parent 27 0f05e90b960d
child 30 0e971bd4403d
permissions -rw-r--r--
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
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
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\section*{Homework 3}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\begin{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
\item Assume you have an alphabet consisting of the letters $a$, $b$ and $c$ only.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
(a) Find a regular expression that recognises the two strings $ab$ and $ac$. (b)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
Find a regular expression that matches all strings \emph{except} these two strings.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
Note, you can only use regular expressions of the form 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
$r ::= \varnothing \;|\; \epsilon \;|\; c  \;|\; r_1 + r_2  \;|\; r_1 \cdot r_2 \;|\; r^*$
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\item Define the function $zeroable$ which takes a regular expression as argument
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
and returns an integer. The function should satisfy the following property:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
$zeroable(r)$ \;if and only if\; $L(r) = \varnothing$
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
27
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    26
\item Define the tokens and regular expressions for a language
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    27
consisting of numbers, left-parenthesis (, right-parenthesis ),
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    28
identifiers and the operations $+$, $-$ and $*$. Can the following strings 
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    29
in this language be lexed?
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    30
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    31
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    32
\item \texttt{"}$(a + 3) * b$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    33
\item \texttt{"}$)()++ -33$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    34
\item \texttt{"}$(a / 3) * 3$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    35
\end{itemize}
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
\end{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
27
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    38
In case they can, can you give the corresponding token sequences.
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    39
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
%%% Local Variables: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
%%% End: