hws/hw03.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 21 Oct 2013 15:02:54 +0100
changeset 146 9da175d5eb63
parent 132 04264d0c43bb
child 258 1e4da6d2490c
permissions -rw-r--r--
added new hws
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}
132
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    12
\item What is a regular language?
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    13
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
\item Assume you have an alphabet consisting of the letters $a$, $b$ and $c$ only.
146
9da175d5eb63 added new hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    15
(1) Find a regular expression that recognises the two strings $ab$ and $ac$. (2)
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
Find a regular expression that matches all strings \emph{except} these two strings.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
Note, you can only use regular expressions of the form 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
$r ::= \varnothing \;|\; \epsilon \;|\; c  \;|\; r_1 + r_2  \;|\; r_1 \cdot r_2 \;|\; r^*$
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
\item Define the function $zeroable$ which takes a regular expression as argument
132
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    23
and returns a boolean. The 
30
Christian Urban <urbanc@in.tum.de>
parents: 27
diff changeset
    24
function should satisfy the following property:
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
$zeroable(r)$ \;if and only if\; $L(r) = \varnothing$
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
27
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    29
\item Define the tokens and regular expressions for a language
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    30
consisting of numbers, left-parenthesis (, right-parenthesis ),
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    31
identifiers and the operations $+$, $-$ and $*$. Can the following strings 
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    32
in this language be lexed?
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    33
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    34
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    35
\item \texttt{"}$(a + 3) * b$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    36
\item \texttt{"}$)()++ -33$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    37
\item \texttt{"}$(a / 3) * 3$\texttt{"}
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    38
\end{itemize}
31
e22ba348b209 added hw04
Christian Urban <urbanc@in.tum.de>
parents: 30
diff changeset
    39
e22ba348b209 added hw04
Christian Urban <urbanc@in.tum.de>
parents: 30
diff changeset
    40
e22ba348b209 added hw04
Christian Urban <urbanc@in.tum.de>
parents: 30
diff changeset
    41
In case they can, can you give the corresponding token sequences.
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
\end{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
31
e22ba348b209 added hw04
Christian Urban <urbanc@in.tum.de>
parents: 30
diff changeset
    44
27
Christian Urban <urbanc@in.tum.de>
parents: 23
diff changeset
    45
23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
%%% Local Variables: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
%%% End: