hws/hw01.tex
author Christian Urban <urbanc@in.tum.de>
Thu, 29 Nov 2018 02:18:05 +0000
changeset 613 bfd511b7ecbf
parent 550 71fc4a7a7039
child 631 f618dd4de24a
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
331
a2c18456c6b7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 294
diff changeset
     8
\HEADER
a2c18456c6b7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 294
diff changeset
     9
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\begin{enumerate}
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
    11
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    12
\item {\bf (Optional)} If you want to run the code presented
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    13
      in the lectures, install the Scala programming language
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    14
      available (for free) from
249
377c59df7297 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
    15
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\begin{center}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\url{http://www.scala-lang.org}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\end{center}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    20
      If you want to follow the code I present during the
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    21
      lectures, read the handout about Scala.
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    23
\item {\bf (Optional)} Have a look at the crawler programs.
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    24
      Can you find a usage for them in your daily programming
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 507
diff changeset
    25
      life? Can you improve them? For example in cases there
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    26
      are links that appear on different recursion levels, the
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    27
      crawlers visit such web-pages several times. Can this be
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 507
diff changeset
    28
      avoided? Also, the crawlers flag as problematic any page
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 507
diff changeset
    29
      that gives an error, but probably only 404 Not Found
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 507
diff changeset
    30
      errors should be flagged. Can you change that?)
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    31
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    32
\item Read the handout of the first lecture and the handout
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    33
      about notation. Make sure you understand the concepts of
498
ea47c3b8f35f updated
Christian Urban <urbanc@in.tum.de>
parents: 444
diff changeset
    34
      strings and languages. In the context of the CFL-course,
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    35
      what is meant by the term \emph{language}?
9
Christian Urban <urbanc@in.tum.de>
parents: 0
diff changeset
    36
550
71fc4a7a7039 updated
Christian Urban <urbanc@in.tum.de>
parents: 507
diff changeset
    37
\item Give the definition for regular expressions---this is an
498
ea47c3b8f35f updated
Christian Urban <urbanc@in.tum.de>
parents: 444
diff changeset
    38
      inductive datatype. What is the
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    39
      meaning of a regular expression? (Hint: The meaning is
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    40
      defined recursively.)
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    42
\item Assume the concatenation operation of two strings is
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    43
      written as $s_1 @ s_2$. Define the operation of
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    44
      \emph{concatenating} two sets of strings. This operation
394
2f9fe225ecc8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    45
      is also written as $\_ \,@\, \_$. According to 
2f9fe225ecc8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    46
      this definition, what is $A \,@\, \{\}$ equal to?
498
ea47c3b8f35f updated
Christian Urban <urbanc@in.tum.de>
parents: 444
diff changeset
    47
      Is in general $A\,@\,B$ equal to $B\,@\,A$?
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    49
\item Assume a set $A$ contains 4 strings and a set $B$
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    50
      contains 7 strings. None of the strings is the empty
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    51
      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
    52
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    53
\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
    54
  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
    55
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    56
\item Let $A = \{[a], [b], [c], [d]\}$. (1) How many strings
438
84608b4b3578 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 416
diff changeset
    57
      are in $A^4$? (2) Consider also the case of $A^4$ where one of
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    58
      the strings in $A$ is the empty string, for example $A =
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    59
      \{[a], [b], [c], []\}$.
293
ca349cfe3474 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    60
507
fdbc7d0ec04f updated
Christian Urban <urbanc@in.tum.de>
parents: 498
diff changeset
    61
\item (1) How many basic regular expressions are there to match
444
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 438
diff changeset
    62
      the string $abcd$? (2) How many if they cannot include
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 438
diff changeset
    63
      $\ONE$ and $\ZERO$? (3) How many if they are also not
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 438
diff changeset
    64
      allowed to contain stars? (4) How many if they are also
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 394
diff changeset
    65
      not allowed to contain $\_ + \_$?
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    67
\item When are two regular expressions equivalent? Can you
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    68
      think of instances where two regular expressions match
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    69
      the same strings, but it is not so obvious that they do?
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    70
      For example $a + b$ and $b + a$ do not count\ldots they
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    71
      obviously match the same strings, namely $[a]$ and
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 331
diff changeset
    72
      $[b]$.
403
564f7584eff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
    73
416
357c395ae838 updated
Christian Urban <urbanc@in.tum.de>
parents: 403
diff changeset
    74
\item What is meant by the notions \emph{evil regular expressions}
444
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 438
diff changeset
    75
      and by \emph{catastrophic backtracking}? 
403
564f7584eff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
    76
564f7584eff1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
    77
\item \POSTSCRIPT  
0
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
\end{enumerate}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
\end{document}
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
%%% Local Variables: 
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
%%% mode: latex
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
%%% TeX-master: t
3a5e09a2ae54 initial comit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
%%% End: