79 classes for |
79 classes for |
80 the extended regular expressions.\footnote{Please call them |
80 the extended regular expressions.\footnote{Please call them |
81 \code{RANGE}, \code{PLUS}, \code{OPTIONAL}, \code{INTER}, \code{NTIMES}, |
81 \code{RANGE}, \code{PLUS}, \code{OPTIONAL}, \code{INTER}, \code{NTIMES}, |
82 \code{UPTO}, \code{FROM} and \code{BETWEEN}.} |
82 \code{UPTO}, \code{FROM} and \code{BETWEEN}.} |
83 That means do not treat the extended regular expressions |
83 That means do not treat the extended regular expressions |
84 by just translating them into the basic ones. See also Question 1, |
84 by just translating them into the basic ones. See also Task 1, |
85 where you are asked to explicitly give the rules for \textit{nullable} |
85 where you are asked to explicitly give the rules for \textit{nullable} |
86 and \textit{der} for the extended regular expressions. Something like |
86 and \textit{der} for the extended regular expressions. Something like |
87 |
87 |
88 \[der\,c\,(r^+) \dn der\,c\,(r\cdot r^*)\] |
88 \[der\,c\,(r^+) \dn der\,c\,(r\cdot r^*)\] |
89 |
89 |
90 \noindent is \emph{not} allowed as answer in Question 1 and \emph{not} |
90 \noindent is \emph{not} allowed as answer in Task 1 and \emph{not} |
91 allowed in your code.\medskip |
91 allowed in your code.\medskip |
92 |
92 |
93 \noindent |
93 \noindent |
94 The meanings of the extended regular expressions are |
94 The meanings of the extended regular expressions are |
95 |
95 |
114 means in effect ``all the strings that $r$ cannot match''.\medskip |
114 means in effect ``all the strings that $r$ cannot match''.\medskip |
115 |
115 |
116 \noindent |
116 \noindent |
117 Be careful that your implementation of \textit{nullable} and |
117 Be careful that your implementation of \textit{nullable} and |
118 \textit{der} satisfies for every regular expression $r$ the following |
118 \textit{der} satisfies for every regular expression $r$ the following |
119 two properties (see also Question 1): |
119 two properties (see also Task 1): |
120 |
120 |
121 \begin{itemize} |
121 \begin{itemize} |
122 \item $\textit{nullable}(r)$ if and only if $[]\in L(r)$ |
122 \item $\textit{nullable}(r)$ if and only if $[]\in L(r)$ |
123 \item $L(der\,c\,r) = Der\,c\,(L(r))$ |
123 \item $L(der\,c\,r) = Der\,c\,(L(r))$ |
124 \end{itemize} |
124 \end{itemize} |
137 %Can you please also list all programming languages in which you have |
137 %Can you please also list all programming languages in which you have |
138 %already written programs (include only instances where you have spent |
138 %already written programs (include only instances where you have spent |
139 %at least a good working day fiddling with a program)? This is just |
139 %at least a good working day fiddling with a program)? This is just |
140 %for my curiosity to estimate what your background is. |
140 %for my curiosity to estimate what your background is. |
141 |
141 |
142 \subsection*{Question 1} |
142 \subsection*{Task 1} |
143 |
143 |
144 From the lectures you have seen the definitions for the functions |
144 From the lectures you have seen the definitions for the functions |
145 \textit{nullable} and \textit{der} for the basic regular |
145 \textit{nullable} and \textit{der} for the basic regular |
146 expressions. Implement and \underline{write down} the rules for the |
146 expressions. Implement and \underline{write down} the rules for the |
147 extended regular expressions (see questionaire at the end). |
147 extended regular expressions (see questionaire at the end). |
177 |
177 |
178 \noindent |
178 \noindent |
179 Does your matcher produce the expected results? Make sure you |
179 Does your matcher produce the expected results? Make sure you |
180 also test corner-cases, like $a^{\{0\}}$! |
180 also test corner-cases, like $a^{\{0\}}$! |
181 |
181 |
182 \subsection*{Question 2} |
182 \subsection*{Task 2} |
183 |
183 |
184 As you can see, there are a number of explicit regular expressions |
184 As you can see, there are a number of explicit regular expressions |
185 that deal with single or several characters, for example: |
185 that deal with single or several characters, for example: |
186 |
186 |
187 \begin{center} |
187 \begin{center} |
227 \end{tabular} |
227 \end{tabular} |
228 \end{center} |
228 \end{center} |
229 |
229 |
230 \noindent |
230 \noindent |
231 You can either add the constructor $CFUN$ to your implementation in |
231 You can either add the constructor $CFUN$ to your implementation in |
232 Question 3, or you can implement this questions first |
232 Task 3, or you can implement this questions first |
233 and then use $CFUN$ instead of \code{RANGE} and \code{CHAR} in Question 3. |
233 and then use $CFUN$ instead of \code{RANGE} and \code{CHAR} in Task 3. |
234 In an ideal world one would do this task first, but this might confuse |
234 In an ideal world one would do this task first, but this might confuse |
235 you with what you need to do in the previous question. |
235 you with what you need to do in the previous question. |
236 |
236 |
237 \subsection*{Question 3} |
237 \subsection*{Task 3} |
238 |
238 |
239 Suppose $[a\mbox{-}z0\mbox{-}9\_\,.\mbox{-}]$ stands for the regular expression |
239 Suppose $[a\mbox{-}z0\mbox{-}9\_\,.\mbox{-}]$ stands for the regular expression |
240 |
240 |
241 \[[a,b,c,\ldots,z,0,\dots,9,\_,.,\mbox{-}]\;.\] |
241 \[[a,b,c,\ldots,z,0,\dots,9,\_,.,\mbox{-}]\;.\] |
242 |
242 |
268 notation using parentheses where necessary. That means you |
268 notation using parentheses where necessary. That means you |
269 should use the infix notation $+$, $\cdot$, $^*$ and so on, |
269 should use the infix notation $+$, $\cdot$, $^*$ and so on, |
270 instead of raw code.\bigskip |
270 instead of raw code.\bigskip |
271 |
271 |
272 |
272 |
273 \subsection*{Question 4} |
273 \subsection*{Task 4} |
274 |
274 |
275 Implement the simplification rules in your regular expression matcher. |
275 Implement the simplification rules in your regular expression matcher. |
276 Consider the regular expression $/ \cdot * \cdot |
276 Consider the regular expression $/ \cdot * \cdot |
277 (\sim{}(\textit{ALL}^* \cdot * \cdot / \cdot \textit{ALL}^*)) \cdot * |
277 (\sim{}(\textit{ALL}^* \cdot * \cdot / \cdot \textit{ALL}^*)) \cdot * |
278 \cdot /$ and decide whether the following four strings are matched by |
278 \cdot /$ and decide whether the following four strings are matched by |
283 \item \texttt{"/*foobar*/"} |
283 \item \texttt{"/*foobar*/"} |
284 \item \texttt{"/*test*/test*/"} |
284 \item \texttt{"/*test*/test*/"} |
285 \item \texttt{"/*test/*test*/"} |
285 \item \texttt{"/*test/*test*/"} |
286 \end{enumerate} |
286 \end{enumerate} |
287 |
287 |
288 \subsection*{Question 5} |
288 \subsection*{Task 5} |
289 |
289 |
290 Let $r_1$ be the regular expression $a\cdot a\cdot a$ and $r_2$ be |
290 Let $r_1$ be the regular expression $a\cdot a\cdot a$ and $r_2$ be |
291 $(a^{\{19,19\}}) \cdot (a^?)$.\medskip |
291 $(a^{\{19,19\}}) \cdot (a^?)$.\medskip |
292 |
292 |
293 \noindent |
293 \noindent |
336 |
336 |
337 \noindent |
337 \noindent |
338 \uline{\hfill}\bigskip\bigskip |
338 \uline{\hfill}\bigskip\bigskip |
339 |
339 |
340 \noindent |
340 \noindent |
341 \textbf{Question 1:} |
341 \textbf{Task 1:} |
342 |
342 |
343 \begin{center} |
343 \begin{center} |
344 \def\arraystretch{1.6} |
344 \def\arraystretch{1.6} |
345 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
345 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
346 $\textit{nullable}([c_1,c_2,\ldots,c_n])$ & $\dn$ & \uline{\hspace{8cm}}\\ |
346 $\textit{nullable}([c_1,c_2,\ldots,c_n])$ & $\dn$ & \uline{\hspace{8cm}}\\ |
414 |
414 |
415 \noindent |
415 \noindent |
416 \uline{\hfill}\bigskip\bigskip |
416 \uline{\hfill}\bigskip\bigskip |
417 |
417 |
418 \noindent |
418 \noindent |
419 \textbf{Question 4:}\medskip |
419 \textbf{Task 4:}\medskip |
420 |
420 |
421 \noindent |
421 \noindent |
422 \textbf{1)}\; Yes / No\qquad |
422 \textbf{1)}\; Yes / No\qquad |
423 \textbf{2)}\; Yes / No\qquad |
423 \textbf{2)}\; Yes / No\qquad |
424 \textbf{3)}\; Yes / No\qquad |
424 \textbf{3)}\; Yes / No\qquad |
425 \textbf{4)}\; Yes / No\bigskip\bigskip |
425 \textbf{4)}\; Yes / No\bigskip\bigskip |
426 |
426 |
427 |
427 |
428 \noindent |
428 \noindent |
429 \textbf{Question 5:}\medskip |
429 \textbf{Task 5:}\medskip |
430 |
430 |
431 \def\arraystretch{1.5} |
431 \def\arraystretch{1.5} |
432 \begin{tabular}{l|c|c} |
432 \begin{tabular}{l|c|c} |
433 & $\quad{}r_1\quad$ & $\quad{}r_2\quad$\\\hline |
433 & $\quad{}r_1\quad$ & $\quad{}r_2\quad$\\\hline |
434 1. & & \\\hline |
434 1. & & \\\hline |