author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 05 Jan 2016 01:46:41 +0000 | |
changeset 394 | 2f9fe225ecc8 |
parent 355 | a259eec25156 |
child 401 | 5d85dc9779b1 |
permissions | -rw-r--r-- |
0 | 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 | 3 |
|
4 |
\begin{document} |
|
5 |
||
6 |
\section*{Homework 1} |
|
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 | 10 |
\begin{enumerate} |
249
377c59df7297
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
11 |
|
267
a1544b804d1e
updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
12 |
\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
|
13 |
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
|
14 |
free) from |
249
377c59df7297
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
227
diff
changeset
|
15 |
|
0 | 16 |
\begin{center} |
17 |
\url{http://www.scala-lang.org} |
|
18 |
\end{center} |
|
19 |
||
267
a1544b804d1e
updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
20 |
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
|
21 |
read the handout about Scala. |
0 | 22 |
|
267
a1544b804d1e
updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
23 |
\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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
several times. Can this be avoided?) |
104
ffde837b1db1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
28 |
|
267
a1544b804d1e
updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
29 |
\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
|
30 |
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
|
31 |
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
|
32 |
term \emph{language}? |
9 | 33 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
34 |
\item Give the definition for regular expressions. What is the |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
35 |
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
|
36 |
defined recursively.) |
0 | 37 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
38 |
\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
|
39 |
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
|
40 |
\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
|
41 |
is also written as $\_ \,@\, \_$. According to |
2f9fe225ecc8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
355
diff
changeset
|
42 |
this definition, what is $A \,@\, \{\}$ equal to? |
0 | 43 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
44 |
\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
|
45 |
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
|
46 |
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
|
47 |
|
267
a1544b804d1e
updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
258
diff
changeset
|
48 |
\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
|
49 |
rules, one for $\_^0$ and one for $\_^{n+1}$.) |
109
f2a90dda7e3b
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
50 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
51 |
\item Let $A = \{[a], [b], [c], [d]\}$. (1) How many strings |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
52 |
are in $A^4$? (2) Consider the case of $A^4$ where one of |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
53 |
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
|
54 |
\{[a], [b], [c], []\}$. |
293
ca349cfe3474
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
267
diff
changeset
|
55 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
56 |
\item How many basic regular expressions are there to match |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
57 |
the string $abcd$? (ii) How many if they cannot include |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
58 |
$\epsilon$ and $\varnothing$? (iii) How many if they are |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
59 |
also not allowed to contain stars? (iv) How many if they |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
60 |
are also not allowed to contain $\_ + \_$? |
0 | 61 |
|
355
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
62 |
\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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
$[b]$. |
a259eec25156
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
331
diff
changeset
|
68 |
|
0 | 69 |
\end{enumerate} |
70 |
||
71 |
\end{document} |
|
72 |
||
73 |
%%% Local Variables: |
|
74 |
%%% mode: latex |
|
75 |
%%% TeX-master: t |
|
76 |
%%% End: |