handouts/ho01.tex
changeset 830 dbf9d710ce65
parent 745 7dc3643a0cc5
child 871 94b84d880c2b
equal deleted inserted replaced
829:dc3c35673e94 830:dbf9d710ce65
    40 % 10 MOST(LY DEAD) INFLUENTIAL PROGRAMMING LANGUAGES
    40 % 10 MOST(LY DEAD) INFLUENTIAL PROGRAMMING LANGUAGES
    41 % https://www.hillelwayne.com/post/influential-dead-languages/
    41 % https://www.hillelwayne.com/post/influential-dead-languages/
    42 
    42 
    43 
    43 
    44 \begin{document}
    44 \begin{document}
    45 \fnote{\copyright{} Christian Urban, King's College London, 2014, 2015, 2016, 2017, 2018, 2019, 2020}
    45 \fnote{\copyright{} Christian Urban, King's College London, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021}
    46 
    46 
    47 \section*{Handout 1}
    47 \section*{Handout 1}
    48 
    48 
    49 
    49 
    50 The purpose of a compiler is to transform a program a human can read and
    50 The purpose of a compiler is to transform a program a human can read and
    51 write into code the machine can run as fast as possible. Developing a
    51 write into code machines can run as fast as possible. Developing a
    52 compiler is an old craft going back to 1952 with the first compiler
    52 compiler is an old craft going back to 1952 with the first compiler
    53 written by Grace Hopper.\footnote{Who many years ago was invited on a
    53 written by Grace Hopper.\footnote{Who many years ago was invited on a
    54 talk show hosted by David Letterman.
    54 talk show hosted by David Letterman.
    55 \here{https://youtu.be/3N_ywhx6_K0?t=31}} Why studying compilers
    55 \here{https://youtu.be/3N_ywhx6_K0?t=31}} Why studying compilers
    56 nowadays?  An interesting answer is given by John Regher in his compiler
    56 nowadays?  An interesting answer is given by John Regher in his compiler
   342 \url{https://www.tutorialdocs.com/article/regex-trap.html}
   342 \url{https://www.tutorialdocs.com/article/regex-trap.html}
   343 \end{center}  
   343 \end{center}  
   344 
   344 
   345 \noindent
   345 \noindent
   346 Finally, on 2 July 2019 Cloudflare had a global outage because of a 
   346 Finally, on 2 July 2019 Cloudflare had a global outage because of a 
   347 regular expression (they had no outage for the last 6 years).  What
   347 regular expression (they had no outage for the 6 years before).  What
   348 happened is nicely explained in the blog:
   348 happened is nicely explained in the blog:
   349 
   349 
   350 \begin{center}
   350 \begin{center}
   351 \url{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019}
   351 \url{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019}
   352 \end{center}  
   352 \end{center}  
   529 but often just write {\it hello}.
   529 but often just write {\it hello}.
   530 
   530 
   531 If you prefer to think in terms of the implementation
   531 If you prefer to think in terms of the implementation
   532 of regular expressions in Scala, the constructors and
   532 of regular expressions in Scala, the constructors and
   533 classes relate as follows\footnote{More about Scala is 
   533 classes relate as follows\footnote{More about Scala is 
   534 in the handout about \emph{A Crash-Course on Scala}.}
   534 in the handout about \emph{A Crash-Course on Scala} from PEP.}
   535 
   535 
   536 \begin{center}
   536 \begin{center}
   537 \begin{tabular}{rcl}
   537 \begin{tabular}{rcl}
   538 $\ZERO$       & $\mapsto$ & \texttt{ZERO}\\
   538 $\ZERO$       & $\mapsto$ & \texttt{ZERO}\\
   539 $\ONE$        & $\mapsto$ & \texttt{ONE}\\
   539 $\ONE$        & $\mapsto$ & \texttt{ONE}\\
   619                      & = & L(r_1) \cup L(r_2) \cup L(r_3)\\
   619                      & = & L(r_1) \cup L(r_2) \cup L(r_3)\\
   620                      & = & L(r_1) \cup L(r_2 + r_3)\\
   620                      & = & L(r_1) \cup L(r_2 + r_3)\\
   621                      & = & L(r_1 + (r_2 + r_3))
   621                      & = & L(r_1 + (r_2 + r_3))
   622 \end{eqnarray*}
   622 \end{eqnarray*}
   623 
   623 
       
   624 \noindent
       
   625 That means both languages are the same.
   624 The point of the definition of $L$ is that we can use it to
   626 The point of the definition of $L$ is that we can use it to
   625 precisely specify when a string $s$ is matched by a regular
   627 precisely specify when a string $s$ is matched by a regular
   626 expression $r$, namely if and only if $s \in L(r)$. In fact we
   628 expression $r$, namely if and only if $s \in L(r)$. In fact we
   627 will write a program \pcode{match} that takes any string $s$
   629 will write a program \pcode{match} that takes any string $s$
   628 and any regular expression $r$ as arguments and returns
   630 and any regular expression $r$ as arguments and returns
   713 have surprised some experts. Together with two colleagues from China, I was
   715 have surprised some experts. Together with two colleagues from China, I was
   714 able to prove the Myhill-Nerode theorem by only using regular
   716 able to prove the Myhill-Nerode theorem by only using regular
   715 expressions and the notion of derivatives. Earlier versions of
   717 expressions and the notion of derivatives. Earlier versions of
   716 this theorem used always automata in the proof. Using this
   718 this theorem used always automata in the proof. Using this
   717 theorem we can show that regular languages are closed under
   719 theorem we can show that regular languages are closed under
   718 complementation, something which Gasarch in his
   720 complementation, something which Bill Gasarch in his Computational Complexity
   719 blog\footnote{\url{http://goo.gl/2R11Fw}} assumed can only be
   721 blog\footnote{\url{http://goo.gl/2R11Fw}} assumed can only be
   720 shown via automata. So even somebody who has written a 700+-page
   722 shown via automata. So even somebody who has written a 700+-page
   721 book\footnote{\url{http://goo.gl/fD0eHx}} on regular
   723 book\footnote{\url{http://goo.gl/fD0eHx}} on regular
   722 expressions did not know better. Well, we showed it can also be
   724 expressions did not know better. Well, we showed it can also be
   723 done with regular expressions only.\footnote{\url{http://nms.kcl.ac.uk/christian.urban/Publications/posix.pdf}}
   725 done with regular expressions only.\footnote{\url{http://nms.kcl.ac.uk/christian.urban/Publications/posix.pdf}}