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