hws/hw01.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 01 Nov 2014 15:06:41 +0000
changeset 293 ca349cfe3474
parent 267 a1544b804d1e
child 294 c29853b672fb
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass{article}
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
     2
\usepackage{../style}
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\begin{document}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\section*{Homework 1}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\begin{enumerate}
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
     9
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    10
\item {\bf (Optional)} If you want to run the code presented in the
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    11
  lectures, install the Scala programming language available (for
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    12
  free) from
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
    13
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
\begin{center}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\url{http://www.scala-lang.org}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\end{center}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    18
      If you want to follow the code I present during the lectures,
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    19
      read the handout about Scala.
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    21
\item {\bf (Optional)} Have a look at the crawler programs.  Can you
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    22
  find a usage for them in your daily programming life? Can you
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    23
  improve them? (For example in cases there are links that appear on
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    24
  different recursion levels, the crawlers visit such web-pages
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    25
  several times. Can this be avoided?)
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    26
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    27
\item Read the handout of the first lecture and the handout about
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    28
  notation. Make sure you understand the concepts of strings and
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    29
  languages.  In the context of the AFL-course, what is meant by the
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    30
  term \emph{language}?
9
Christian Urban <urbanc@in.tum.de>
parents: 0
diff changeset
    31
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    32
\item Give the definition for regular expressions. What is the meaning
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    33
  of a regular expression? (Hint: The meaning is defined recursively.)
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    35
\item Assume the concatenation operation of two strings is written as
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    36
  $s_1 @ s_2$. Define the operation of \emph{concatenating}, written
293
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    37
  $\_ \,@\, \_$, two sets of strings.
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
293
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    39
\item Assume a set $A$ contains 4 strings and a set $B$ 7 strings. None
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    40
  of the strings is the empty string. How many strings are in $A \,@\, B$?
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
    41
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    42
\item How is the power of a language defined? (Hint: There are two
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    43
  rules, one for $\_^0$ and one for $\_^{n+1}$.)
109
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
    44
293
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    45
\item Let $A = \{[], [a], [b], [c]\}$. How many strings are in $A^4$?
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    46
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    47
\item How many regular expressions are there to match the string
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    48
  $abc$? How many if they cannot include $\epsilon$ and $\varnothing$?
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    49
  How many if they are also not allowed to contain stars? How many if
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    50
  they are also not allowed to contain $\_ + \_$?
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    52
\item When are two regular expressions equivalent? Can you think of
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    53
  instances where two regular expressions match the same strings, but
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    54
  it is not so obvious that they do? For example $a + b$ and $b + a$
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    55
  do not count\ldots they obviously match the same strings, namely
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    56
  $[a]$ and $[b]$.
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
\end{enumerate}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
\end{document}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
%%% Local Variables: 
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
%%% mode: latex
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
%%% TeX-master: t
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
%%% End: