| author | Christian Urban <urbanc@in.tum.de> | 
| Thu, 17 Oct 2019 13:41:30 +0100 | |
| changeset 661 | 32fd8125f56e | 
| parent 640 | 88f8b9723a05 | 
| child 726 | f6c2e8c48a1c | 
| permissions | -rw-r--r-- | 
| 631 | 1 | % !TEX program = xelatex | 
| 0 | 2 | \documentclass{article}
 | 
| 249 
377c59df7297
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
227diff
changeset | 3 | \usepackage{../style}
 | 
| 0 | 4 | |
| 5 | \begin{document}
 | |
| 6 | ||
| 7 | \section*{Homework 1}
 | |
| 8 | ||
| 331 
a2c18456c6b7
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
294diff
changeset | 9 | \HEADER | 
| 
a2c18456c6b7
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
294diff
changeset | 10 | |
| 0 | 11 | \begin{enumerate}
 | 
| 249 
377c59df7297
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
227diff
changeset | 12 | |
| 401 
5d85dc9779b1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
394diff
changeset | 13 | \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: 
394diff
changeset | 14 | in the lectures, install the Scala programming language | 
| 
5d85dc9779b1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
394diff
changeset | 15 | available (for free) from | 
| 249 
377c59df7297
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
227diff
changeset | 16 | |
| 0 | 17 | \begin{center}
 | 
| 18 | \url{http://www.scala-lang.org}
 | |
| 19 | \end{center}
 | |
| 20 | ||
| 401 
5d85dc9779b1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
394diff
changeset | 21 | 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: 
394diff
changeset | 22 | lectures, read the handout about Scala. | 
| 0 | 23 | |
| 639 | 24 | %\item {\bf (Optional)} Have a look at the crawler programs.
 | 
| 25 | % Can you find a usage for them in your daily programming | |
| 26 | % life? Can you improve them? For example in cases there | |
| 27 | % are links that appear on different recursion levels, the | |
| 28 | % crawlers visit such web-pages several times. Can this be | |
| 29 | % avoided? Also, the crawlers flag as problematic any page | |
| 30 | % that gives an error, but probably only 404 Not Found | |
| 31 | % errors should be flagged. Can you change that?) | |
| 104 
ffde837b1db1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
102diff
changeset | 32 | |
| 640 | 33 | \item {\bf (Optional)} Have a look at the catastrophic backtracking
 | 
| 34 | programs uploaded on KEATS. Convince yourself that they really require | |
| 35 | a lot of computation time. If you have similar examples in your own | |
| 36 | favourite programming language, I am happy to hear about it. | |
| 37 | ||
| 38 | ||
| 401 
5d85dc9779b1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
394diff
changeset | 39 | \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: 
394diff
changeset | 40 | about notation. Make sure you understand the concepts of | 
| 498 | 41 | 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: 
394diff
changeset | 42 |       what is meant by the term \emph{language}?
 | 
| 9 | 43 | |
| 550 | 44 | \item Give the definition for regular expressions---this is an | 
| 498 | 45 | inductive datatype. What is the | 
| 355 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 46 | meaning of a regular expression? (Hint: The meaning is | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 47 | defined recursively.) | 
| 0 | 48 | |
| 355 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 49 | \item Assume the concatenation operation of two strings is | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 50 | written as $s_1 @ s_2$. Define the operation of | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 51 |       \emph{concatenating} two sets of strings. This operation
 | 
| 394 
2f9fe225ecc8
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
355diff
changeset | 52 | is also written as $\_ \,@\, \_$. According to | 
| 
2f9fe225ecc8
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
355diff
changeset | 53 |       this definition, what is $A \,@\, \{\}$ equal to?
 | 
| 498 | 54 | Is in general $A\,@\,B$ equal to $B\,@\,A$? | 
| 0 | 55 | |
| 355 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 56 | \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: 
331diff
changeset | 57 | contains 7 strings. None of the strings is the empty | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 58 | string. How many strings are in $A \,@\, B$? | 
| 249 
377c59df7297
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
227diff
changeset | 59 | |
| 267 
a1544b804d1e
updated homeworks
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
258diff
changeset | 60 | \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: 
258diff
changeset | 61 |   rules, one for $\_^0$ and one for $\_^{n+1}$.)
 | 
| 109 
f2a90dda7e3b
added
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
104diff
changeset | 62 | |
| 355 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 63 | \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: 
416diff
changeset | 64 | 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: 
331diff
changeset | 65 | 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: 
331diff
changeset | 66 |       \{[a], [b], [c], []\}$.
 | 
| 293 
ca349cfe3474
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
267diff
changeset | 67 | |
| 507 | 68 | \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: 
438diff
changeset | 69 | the string $abcd$? (2) How many if they cannot include | 
| 
3056a4c071b0
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
438diff
changeset | 70 | $\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: 
438diff
changeset | 71 | 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: 
394diff
changeset | 72 | not allowed to contain $\_ + \_$? | 
| 0 | 73 | |
| 355 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 74 | \item When are two regular expressions equivalent? Can you | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 75 | think of instances where two regular expressions match | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 76 | 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: 
331diff
changeset | 77 | 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: 
331diff
changeset | 78 | obviously match the same strings, namely $[a]$ and | 
| 
a259eec25156
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
331diff
changeset | 79 | $[b]$. | 
| 403 
564f7584eff1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
401diff
changeset | 80 | |
| 416 | 81 | \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: 
438diff
changeset | 82 |       and by \emph{catastrophic backtracking}? 
 | 
| 403 
564f7584eff1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
401diff
changeset | 83 | |
| 
564f7584eff1
updated
 Christian Urban <christian dot urban at kcl dot ac dot uk> parents: 
401diff
changeset | 84 | \item \POSTSCRIPT | 
| 0 | 85 | \end{enumerate}
 | 
| 86 | ||
| 87 | \end{document}
 | |
| 88 | ||
| 89 | %%% Local Variables: | |
| 90 | %%% mode: latex | |
| 91 | %%% TeX-master: t | |
| 92 | %%% End: |