author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sat, 27 Sep 2014 00:37:02 +0100 | |
changeset 260 | 65d1ea0e989f |
parent 259 | e5f4b8ff23b8 |
child 272 | 1446bc47a294 |
permissions | -rw-r--r-- |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
\documentclass{article} |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
216
diff
changeset
|
2 |
\usepackage{../style} |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
3 |
\usepackage{../langs} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
\begin{document} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
7 |
\section*{Coursework 1 (Strand 1)} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
9 |
This coursework is worth 5\% and is due on 13 October at 16:00. You |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
10 |
are asked to implement a regular expression matcher and submit a |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
11 |
document containing the answers for the questions below. You can do |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
12 |
the implementation in any programming language you like, but you need |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
13 |
to submit the source code with which you answered the |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
14 |
questions. However, the coursework will \emph{only} be judged |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
15 |
according to the answers. You can submit your answers in a txt-file or |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
16 |
pdf. |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
17 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
18 |
\subsubsection*{Disclaimer} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
|
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
20 |
It should be understood that the work you submit represents your own |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
21 |
effort. You have not copied from anyone else. An exception is the |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
22 |
Scala code I showed during the lectures, which you can use.\bigskip |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
23 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
24 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
25 |
\subsubsection*{Tasks} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
26 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
27 |
The task is to implement a regular expression matcher based on |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
28 |
derivatives. The implementation should be able to deal with the usual |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
29 |
(basic) regular expressions |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
\[ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
\varnothing, \epsilon, c, r_1 + r_2, r_1 \cdot r_2, r^* |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
\] |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
\noindent |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
36 |
but also with the following extended regular expressions: |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
\begin{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
\begin{tabular}{ll} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
$[c_1 c_2 \ldots c_n]$ & a range of characters\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
$r^+$ & one or more times $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
$r^?$ & optional $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
$r^{\{n,m\}}$ & at least $n$-times $r$ but no more than $m$-times\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
$\sim{}r$ & not-regular expression of $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
\end{tabular} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
\end{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
\noindent |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
In the case of $r^{\{n,m\}}$ we have the convention that $0 \le n \le m$. |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
The meaning of these regular expressions is |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
\begin{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
\begin{tabular}{r@{\hspace{2mm}}c@{\hspace{2mm}}l} |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
54 |
$L([c_1 c_2 \ldots c_n])$ & $\dn$ & $\{[c_1], [c_2], \ldots, [c_n]\}$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
55 |
$L(r^+)$ & $\dn$ & $\bigcup_{1\le i}. L(r)^i$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
56 |
$L(r^?)$ & $\dn$ & $L(r) \cup \{[]\}$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
57 |
$L(r^{\{n,m\}})$ & $\dn$ & $\bigcup_{n\le i \le m}. L(r)^i$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
58 |
$L(\sim{}r)$ & $\dn$ & $\mathbb{A} - L(r)$ |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
\end{tabular} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
\end{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
\noindent |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
63 |
whereby in the last clause the set $\mathbb{A}$ stands for the set of |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
64 |
\emph{all} strings. So $\sim{}r$ means `all the strings that $r$ |
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
65 |
cannot match'. |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
67 |
Be careful that your implementation of $nullable$ and $der$ satisfies |
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
68 |
for every $r$ the following two properties (see also Question 2): |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
\begin{itemize} |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
71 |
\item $nullable(r)$ if and only if $[]\in L(r)$ |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
\item $L(der\,c\,r)) = Der\,c\,(L(r))$ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
\end{itemize} |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
74 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
75 |
\noindent |
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
76 |
{\bf Important!} Your implementation should have explicit cases for |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
77 |
the basic regular expressions, but also explicit cases for the |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
78 |
extended regular expressions. That means do not treat the extended |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
79 |
regular expressions by just translating them into the basic ones. See |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
80 |
also Question 2, where you are asked to explicitly give the rules for |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
81 |
\textit{nullable} and \textit{der} for the extended regular |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
82 |
expressions. |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
83 |
|
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
\subsection*{Question 1 (unmarked)} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
87 |
What is your King's email address (you will need it in Question 2)? |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
88 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
89 |
\subsection*{Question 2 (marked with 2\%)} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
90 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
91 |
This question does not require any implementation. From the lectures |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
92 |
you have seen the definitions for the functions \textit{nullable} and |
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
93 |
\textit{der} for the basic regular expressions. Give the rules for |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
94 |
the extended regular expressions: |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
96 |
\begin{center} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
97 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
98 |
$nullable([c_1 c_2 \ldots c_n])$ & $\dn$ & $?$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
99 |
$nullable(r^+)$ & $\dn$ & $?$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
100 |
$nullable(r^?)$ & $\dn$ & $?$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
101 |
$nullable(r^{\{n,m\}})$ & $\dn$ & $?$\\ |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
102 |
$nullable(\sim{}r)$ & $\dn$ & $?$\medskip\\ |
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
103 |
$der\, c\, ([c_1 c_2 \ldots c_n])$ & $\dn$ & $?$\\ |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
104 |
$der\, c\, (r^+)$ & $\dn$ & $?$\\ |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
105 |
$der\, c\, (r^?)$ & $\dn$ & $?$\\ |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
106 |
$der\, c\, (r^{\{n,m\}})$ & $\dn$ & $?$\\ |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
107 |
$der\, c\, (\sim{}r)$ & $\dn$ & $?$\\ |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
108 |
\end{tabular} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
109 |
\end{center} |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
110 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
111 |
\subsection*{Question 3 (marked with 1\%)} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
Implement the following regular expression for email addresses |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
\[ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
([a\mbox{-}z0\mbox{-}9\_\!\_\,.-]^+)\cdot @\cdot ([a\mbox{-}z0\mbox{-}9\,.-]^+)\cdot .\cdot ([a\mbox{-}z\,.]^{\{2,6\}}) |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
\] |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
\noindent |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
120 |
and calculate the derivative according to your email address. When |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
121 |
calculating the derivative, simplify all regular expressions as much |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
122 |
as possible, but at least apply the following six simplification |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
123 |
rules: |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
\begin{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
\begin{tabular}{l@{\hspace{2mm}}c@{\hspace{2mm}}l} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
$r \cdot \varnothing$ & $\mapsto$ & $\varnothing$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
$\varnothing \cdot r$ & $\mapsto$ & $\varnothing$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
$r \cdot \epsilon$ & $\mapsto$ & $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
$\epsilon \cdot r$ & $\mapsto$ & $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
$r + \varnothing$ & $\mapsto$ & $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
$\varnothing + r$ & $\mapsto$ & $r$\\ |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
\end{tabular} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
\end{center} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
136 |
\noindent |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
137 |
Write down your simplified derivative in the ``mathematicical'' |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
138 |
notation using parentheses where necessary. |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
139 |
|
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
140 |
\subsection*{Question 4 (marked with 1\%)} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
|
260
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
142 |
Suppose \textit{[a-z]} stands for the range regular expression |
65d1ea0e989f
updated cws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
259
diff
changeset
|
143 |
$[a,b,c,\ldots,z]$. Consider the regular expression $/ \cdot * \cdot |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
144 |
(\sim{}([a\mbox{-}z]^* \cdot * \cdot / \cdot [a\mbox{-}z]^*)) \cdot * |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
145 |
\cdot /$ and decide wether the following four strings are matched by |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
146 |
this regular expression. Answer yes or no. |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
\begin{enumerate} |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
149 |
\item \texttt{"/**/"} |
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
150 |
\item \texttt{"/*foobar*/"} |
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
151 |
\item \texttt{"/*test*/test*/"} |
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
152 |
\item \texttt{"/*test/*test*/"} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
\end{enumerate} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
155 |
\subsection*{Question 5 (marked with 1\%)} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
|
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
157 |
Let $r_1$ be the regular expression $a\cdot a\cdot a$ and $r_2$ be |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
158 |
$(a^{\{19,19\}}) \cdot (a^?)$. Decide whether the following three |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
159 |
strings consisting of $a$s only can be matched by $(r_1^+)^+$. |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
160 |
Similarly test them with $(r_2^+)^+$. Again answer in all six cases |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
161 |
with yes or no. \medskip |
130
5c4998375c46
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
129
diff
changeset
|
162 |
|
5c4998375c46
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
129
diff
changeset
|
163 |
\noindent |
259
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
164 |
These are strings are meant to be entirely made up of $a$s. Be careful |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
165 |
when copy-and-pasting the strings so as to not forgetting any $a$ and |
e5f4b8ff23b8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
166 |
to not introducing any other character. |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
\begin{enumerate} |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
169 |
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
171 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} |
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
172 |
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
174 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} |
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
175 |
\item \texttt{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\ |
216
f5ec7c597c5b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
177 |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} |
127
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
\end{enumerate} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
\end{document} |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
|
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
%%% Local Variables: |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
%%% mode: latex |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
%%% TeX-master: t |
41ef073ac6c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
186 |
%%% End: |