# HG changeset patch # User Christian Urban # Date 1685046143 -3600 # Node ID 8160c55991b91372db454fea102ef81eee2c5b2c # Parent 2bf1516d730feb865dff8da6cbd0db2c609667d6 updated diff -r 2bf1516d730f -r 8160c55991b9 cws/cw01.pdf Binary file cws/cw01.pdf has changed diff -r 2bf1516d730f -r 8160c55991b9 cws/cw01.tex --- a/cws/cw01.tex Tue Apr 04 22:31:09 2023 +0100 +++ b/cws/cw01.tex Thu May 25 21:22:23 2023 +0100 @@ -57,6 +57,7 @@ $[c_1,c_2,\ldots,c_n]$ & a set of characters---for character ranges\\ $r^+$ & one or more times $r$\\ $r^?$ & optional $r$\\ + $r_1 \,\&\, r_2$ & intersection (matched by both $r_1$ and $r_2$)\\ $r^{\{n\}}$ & exactly $n$-times\\ $r^{\{..m\}}$ & zero or more times $r$ but no more than $m$-times\\ $r^{\{n..\}}$ & at least $n$-times $r$\\ @@ -72,7 +73,7 @@ case classes for the basic regular expressions, but also explicit case classes for the extended regular expressions.\footnote{Please call them - \code{RANGE}, \code{PLUS}, \code{OPTIONAL}, \code{NTIMES}, + \code{RANGE}, \code{PLUS}, \code{OPTIONAL}, \code{AND}, \code{NTIMES}, \code{UPTO}, \code{FROM} and \code{BETWEEN}.} That means do not treat the extended regular expressions by just translating them into the basic ones. See also Question 3, @@ -92,6 +93,7 @@ $L([c_1,c_2,\ldots,c_n])$ & $\dn$ & $\{[c_1], [c_2], \ldots, [c_n]\}$\\ $L(r^+)$ & $\dn$ & $\bigcup_{1\le i}.\;L(r)^i$\\ $L(r^?)$ & $\dn$ & $L(r) \cup \{[]\}$\\ + $L(r_1 \,\&\, r_2)$ & $\dn$ & $L(r_1) \cap L(r_2)$\\ $L(r^{\{n\}})$ & $\dn$ & $L(r)^n$\\ $L(r^{\{..m\}})$ & $\dn$ & $\bigcup_{0\le i \le m}.\;L(r)^i$\\ $L(r^{\{n..\}})$ & $\dn$ & $\bigcup_{n\le i}.\;L(r)^i$\\ @@ -121,8 +123,9 @@ \subsection*{Question 1 (Unmarked)} What is your King's email address (you will need it in -Question 5)? Also could you please let me know from where you will be mainly -studying? (online / in-person, in London / somewhere else) Thanks! +Question 5)? Also could you please let me know whether you are +a BSc / MSci and the year you are in (in case of MSci). Thanks! + \subsection*{Question 2 (Unmarked)} @@ -136,7 +139,7 @@ From the lectures you have seen the definitions for the functions \textit{nullable} and \textit{der} for the basic regular -expressions. Implement and write down the rules for the extended +expressions. Implement and \underline{write down} the rules for the extended regular expressions: \begin{center} @@ -144,6 +147,7 @@ $\textit{nullable}([c_1,c_2,\ldots,c_n])$ & $\dn$ & $?$\\ $\textit{nullable}(r^+)$ & $\dn$ & $?$\\ $\textit{nullable}(r^?)$ & $\dn$ & $?$\\ + $\textit{nullable}(r_1 \,\&\, r_2)$ & $\dn$ & $?$\\ $\textit{nullable}(r^{\{n\}})$ & $\dn$ & $?$\\ $\textit{nullable}(r^{\{..m\}})$ & $\dn$ & $?$\\ $\textit{nullable}(r^{\{n..\}})$ & $\dn$ & $?$\\ @@ -157,6 +161,7 @@ $der\, c\, ([c_1,c_2,\ldots,c_n])$ & $\dn$ & $?$\\ $der\, c\, (r^+)$ & $\dn$ & $?$\\ $der\, c\, (r^?)$ & $\dn$ & $?$\\ + $der\, c\, (r_1 \,\&\, r_2)$ & $\dn$ & $?$\\ $der\, c\, (r^{\{n\}})$ & $\dn$ & $?$\\ $der\, c\, (r^{\{..m\}})$ & $\dn$ & $?$\\ $der\, c\, (r^{\{n..\}})$ & $\dn$ & $?$\\ @@ -176,7 +181,7 @@ \noindent Given the definitions of \textit{nullable} and \textit{der}, it is easy to implement a regular expression matcher. Test your regular -expression matcher with (at least) the examples: +expression matcher with (\underline{at least}) the examples: \begin{center}