# HG changeset patch # User Christian Urban # Date 1541118268 0 # Node ID 6d6e79f959333858e73839ace378892c8e4d0ba4 # Parent 4bf0096bc06b16d3a14a1740c2d11dc5c35d80f4 updated diff -r 4bf0096bc06b -r 6d6e79f95933 handouts/ho04.pdf Binary file handouts/ho04.pdf has changed diff -r 4bf0096bc06b -r 6d6e79f95933 handouts/ho04.tex --- a/handouts/ho04.tex Wed Oct 31 12:51:42 2018 +0000 +++ b/handouts/ho04.tex Fri Nov 02 00:24:28 2018 +0000 @@ -154,7 +154,7 @@ \end{tabular} \end{center} -\noindent There is are no cases for $\ZERO$ and $c$, since +\noindent There are no cases for $\ZERO$ and $c$, since these regular expression cannot match the empty string. Note also that in case of alternatives we give preference to the regular expression on the left-hand side. This will become @@ -240,6 +240,7 @@ Next we have to ``inject'' the last character, that is $c$ in the running example, into this value $v_4$ in order to calculate how $r_3$ could have matched the string $c$. +For this we call injection with $\textit{inj}(r_3, c, v_4)$. According to the definition of $\textit{inj}$ we obtain \begin{center} @@ -249,8 +250,9 @@ \noindent This is the correct result, because $r_3$ needs to use the right-hand alternative, and then $\ONE$ needs to match the empty string and $c$ needs to match $c$. -Next we need to inject back the letter $b$ into $v_3$. This -gives +Next we need to inject back the letter $b$ into $v_3$. +For this we call injection with $\textit{inj}(r_2, b, v_3)$. +This gives \begin{center} $v_2:\;Seq(Empty, Seq(Char(b), Char(c)))$ @@ -258,14 +260,16 @@ \noindent which is again the correct result for how $r_2$ matched the string $bc$. Finally we need to inject back the -letter $a$ into $v_2$ giving the final result +letter $a$ into $v_2$ giving the final result. +For this we call injection with $\textit{inj}(r_1, a, v_2)$ +and obtain \begin{center} $v_1:\;Seq(Char(a), Seq(Char(b), Char(c)))$ \end{center} -\noindent This now corresponds to how the regular -expression $a \cdot (b \cdot c)$ matched the string $abc$. +\noindent This value corresponds to how the regular expression $r_1$, +namely $a \cdot (b \cdot c)$, matched the string $abc$. There are a few auxiliary functions that are of interest when analysing this algorithm. One is called \emph{flatten}, diff -r 4bf0096bc06b -r 6d6e79f95933 hws/hw06.pdf Binary file hws/hw06.pdf has changed diff -r 4bf0096bc06b -r 6d6e79f95933 hws/hw06.tex --- a/hws/hw06.tex Wed Oct 31 12:51:42 2018 +0000 +++ b/hws/hw06.tex Fri Nov 02 00:24:28 2018 +0000 @@ -67,8 +67,8 @@ \end{center} there are several values for how these regular expressions can -recognise the string (for 1) $ab$ and (for 2) $aaa$. Give in each case -all the values and indicate which one is the POSIX value. +recognise the strings (for 1) $ab$ and (for 2) $aaa$. Give in each case +\emph{all} the values and indicate which one is the POSIX value. \item \POSTSCRIPT \end{enumerate}