author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 26 Sep 2014 14:06:55 +0100 | |
changeset 258 | 1e4da6d2490c |
parent 132 | 04264d0c43bb |
child 267 | a1544b804d1e |
permissions | -rw-r--r-- |
22 | 1 |
\documentclass{article} |
2 |
\usepackage{charter} |
|
3 |
\usepackage{hyperref} |
|
4 |
\usepackage{amssymb} |
|
5 |
\usepackage{amsmath} |
|
6 |
||
7 |
\begin{document} |
|
8 |
||
9 |
\section*{Homework 2} |
|
10 |
||
11 |
\begin{enumerate} |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
12 |
\item Review the first handout about sets of strings and read |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
13 |
the second handout. Assuming the alphabet is $\{a, b\}$, |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
14 |
decide which of the following equations are true in |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
15 |
general for arbitrary languages $A$, $B$ and $C$: |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
16 |
|
115
86c1c049eb3e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
17 |
\begin{eqnarray} |
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
18 |
(A \cup B) @ C & =^? & A @ C \cup B @ C\nonumber\\ |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
19 |
A^* \cup B^* & =^? & (A \cup B)^*\nonumber\\ |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
20 |
A^* @ A^* & =^? & A^*\nonumber\\ |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
21 |
(A \cap B)@ C & =^? & (A@C) \cap (B@C)\nonumber |
115
86c1c049eb3e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
22 |
\end{eqnarray} |
86c1c049eb3e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
23 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
24 |
\noindent In case an equation is true, give an explanation; |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
25 |
otherwise give a counter-example. |
115
86c1c049eb3e
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
26 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
27 |
\item What is the meaning of a regular expression? Give an |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
28 |
inductive definition. |
104
ffde837b1db1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
29 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
30 |
\item Given the regular expressions $r_1 = \epsilon$ and $r_2 |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
31 |
= \varnothing$ and $r_3 = a$. How many strings can the |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
32 |
regular expressions $r_1^*$, $r_2^*$ and $r_3^*$ each |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
33 |
match? |
104
ffde837b1db1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
34 |
|
ffde837b1db1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
35 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
36 |
\item Give regular expressions for (a) decimal numbers and for |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
37 |
(b) binary numbers. (Hint: Observe that the empty string |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
38 |
is not a number. Also observe that leading 0s are |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
39 |
normally not written.) |
22 | 40 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
41 |
\item Decide whether the following two regular expressions are |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
42 |
equivalent $(\epsilon + a)^* \equiv^? a^*$ and $(a \cdot |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
43 |
b)^* \cdot a \equiv^? a \cdot (b \cdot a)^*$. |
22 | 44 |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
45 |
\item Given the regular expression $r = (a \cdot b + b)^*$. |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
46 |
Compute what the derivative of $r$ is with respect to |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
47 |
$a$, $b$ and $c$. Is $r$ nullable? |
22 | 48 |
|
49 |
\item Prove that for all regular expressions $r$ we have |
|
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
50 |
|
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
51 |
\begin{center} |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
52 |
$\textit{nullable}(r) \quad \text{if and only if} |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
53 |
\quad [] \in L(r)$ |
22 | 54 |
\end{center} |
55 |
||
258
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
56 |
Write down clearly in each case what you need to prove and |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
57 |
what are the assumptions. |
1e4da6d2490c
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
58 |
|
22 | 59 |
\end{enumerate} |
60 |
||
61 |
\end{document} |
|
62 |
||
63 |
%%% Local Variables: |
|
64 |
%%% mode: latex |
|
65 |
%%% TeX-master: t |
|
66 |
%%% End: |