cws/cw03.tex
changeset 94 ae4708c851ee
parent 86 f8a781322499
child 100 93260be6770f
equal deleted inserted replaced
93:21f41e08457d 94:ae4708c851ee
   325   function where in one the fixpoint is 1 and in the other
   325   function where in one the fixpoint is 1 and in the other
   326   it is the string $a$.\\ \mbox{}\hfill[1 Mark]  
   326   it is the string $a$.\\ \mbox{}\hfill[1 Mark]  
   327 \end{itemize}\bigskip  
   327 \end{itemize}\bigskip  
   328 
   328 
   329 
   329 
   330 
   330 \subsection*{Background}
   331 \noindent
   331 
   332 \textbf{Background} Although easily implementable in Scala, the idea
   332 Although easily implementable in Scala, the idea behind the derivative
   333 behind the derivative function might not so easy to be seen. To
   333 function might not so easy to be seen. To understand its purpose
   334 understand its purpose better, assume a regular expression $r$ can
   334 better, assume a regular expression $r$ can match strings of the form
   335 match strings of the form $c::cs$ (that means strings which start with
   335 $c::cs$ (that means strings which start with a character $c$ and have
   336 a character $c$ and have some rest, or tail, $cs$). If you now take the
   336 some rest, or tail, $cs$). If you now take the derivative of $r$ with
   337 derivative of $r$ with respect to the character $c$, then you obtain a
   337 respect to the character $c$, then you obtain a regular expressions
   338 regular expressions that can match all the strings $cs$.  In other
   338 that can match all the strings $cs$.  In other words, the regular
   339 words, the regular expression $\textit{der}\;c\;r$ can match the same
   339 expression $\textit{der}\;c\;r$ can match the same strings $c::cs$
   340 strings $c::cs$ that can be matched by $r$, except that the $c$ is
   340 that can be matched by $r$, except that the $c$ is chopped off.
   341 chopped off.
       
   342 
   341 
   343 Assume now $r$ can match the string $abc$. If you take the derivative
   342 Assume now $r$ can match the string $abc$. If you take the derivative
   344 according to $a$ then you obtain a regular expression that can match
   343 according to $a$ then you obtain a regular expression that can match
   345 $bc$ (it is $abc$ where the $a$ has been chopped off). If you now
   344 $bc$ (it is $abc$ where the $a$ has been chopped off). If you now
   346 build the derivative $\textit{der}\;b\;(\textit{der}\;a\;r))$ you
   345 build the derivative $\textit{der}\;b\;(\textit{der}\;a\;r))$ you