| 876 |      1 | % !TEX program = xelatex
 | 
|  |      2 | \documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
 | 
|  |      3 | \usepackage{../slides}
 | 
|  |      4 | \usepackage{../graphicss}
 | 
|  |      5 | \usepackage{../langs}
 | 
|  |      6 | \usepackage{../data}
 | 
|  |      7 | \usetikzlibrary{cd}
 | 
|  |      8 | 
 | 
|  |      9 | 
 | 
|  |     10 | \usepackage{tcolorbox}
 | 
|  |     11 | \newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
 | 
|  |     12 | \newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
 | 
|  |     13 | \newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
 | 
|  |     14 | 
 | 
|  |     15 | 
 | 
|  |     16 | 
 | 
|  |     17 | \hfuzz=220pt 
 | 
|  |     18 | 
 | 
|  |     19 | \lstset{language=Scala,
 | 
|  |     20 |         style=mystyle,
 | 
|  |     21 |         numbersep=0pt,
 | 
|  |     22 |         numbers=none,
 | 
|  |     23 |         xleftmargin=0mm}
 | 
|  |     24 | 
 | 
|  |     25 | \newcommand{\bl}[1]{\textcolor{blue}{#1}}     
 | 
|  |     26 |  
 | 
|  |     27 | % beamer stuff 
 | 
|  |     28 | \renewcommand{\slidecaption}{CFL 01, King's College London}
 | 
|  |     29 | 
 | 
|  |     30 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect1/main.pdf
 | 
|  |     31 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect2/main.pdf
 | 
|  |     32 | %% https://cs.rit.edu/~hh/teaching/_media/cc18/lectures/lect3/main.pdf
 | 
|  |     33 | 
 | 
| 928 |     34 | 
 | 
| 876 |     35 | \begin{document}
 | 
|  |     36 | 
 | 
|  |     37 | %\begin{frame}[t]
 | 
|  |     38 | %
 | 
|  |     39 | %\begin{mybox}
 | 
|  |     40 | %A physical explanation the \emph{dynamic matrix}\\
 | 
|  |     41 | %lots of text
 | 
|  |     42 | %\end{mybox}
 | 
|  |     43 | 
 | 
|  |     44 | 
 | 
|  |     45 | %\begin{mybox2}{Test}
 | 
|  |     46 | %A physical explanation the \emph{dynamic matrix}\\
 | 
|  |     47 | %lots of text
 | 
|  |     48 | %\end{mybox2}
 | 
|  |     49 | 
 | 
|  |     50 | %\begin{mybox3}{Test}
 | 
|  |     51 | %A physical explanation the \emph{dynamic matrix}\\
 | 
|  |     52 | %lots of text
 | 
|  |     53 | %\end{mybox3}
 | 
| 906 |     54 | % \end{frame}
 | 
|  |     55 | 
 | 
|  |     56 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 921 |     57 | %\begin{frame}[t]
 | 
|  |     58 | %\frametitle{%  
 | 
|  |     59 | %  \begin{tabular}{@ {}c@ {}}
 | 
|  |     60 | %  \\[-3mm]
 | 
|  |     61 | %  \LARGE Lunch with a Lecturer (29 March)\\[5mm] 
 | 
|  |     62 | %  \end{tabular}}
 | 
|  |     63 | %
 | 
|  |     64 | %  I teach CFL (compilers) and PEP (Scala)\bigskip
 | 
|  |     65 | %
 | 
|  |     66 | %  \begin{itemize}
 | 
|  |     67 | %  \item did undergraduate in Germany
 | 
|  |     68 | %  \item Master in St Andrews
 | 
|  |     69 | %  \item PhD in Cambridge  
 | 
|  |     70 | %  \end{itemize}\bigskip\bigskip
 | 
|  |     71 | %
 | 
|  |     72 | %  use mainly the Isabelle theorem prover in my work (see 6CCS3VER)
 | 
|  |     73 | %
 | 
|  |     74 | %  write code in functional programming languages (Scala, SML, Ocaml, Haskell)
 | 
|  |     75 | %\end{frame}
 | 
| 906 |     76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     77 | 
 | 
| 921 |     78 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |     79 | % \begin{frame}[c]
 | 
|  |     80 | % \frametitle{Why Bother with Regexes?}
 | 
| 906 |     81 | 
 | 
| 921 |     82 | % \begin{columns}[t,onlytextwidth]
 | 
|  |     83 | % \begin{column}{1.8cm}
 | 
|  |     84 | % \mbox{}   
 | 
|  |     85 | % \end{column}    
 | 
|  |     86 | % \begin{column}{.5\textwidth}
 | 
|  |     87 | % \small{}Ruby, Python, Java 8\medskip\\
 | 
|  |     88 | % \begin{tikzpicture}\footnotesize
 | 
|  |     89 | % \begin{axis}[
 | 
|  |     90 | %     xlabel={$n$},
 | 
|  |     91 | %     x label style={at={(1.05,0.0)}},
 | 
|  |     92 | %     ylabel={time in secs},
 | 
|  |     93 | %     enlargelimits=false,
 | 
|  |     94 | %     xtick={0,5,...,30},
 | 
|  |     95 | %     xmax=33,
 | 
|  |     96 | %     ymax=35,
 | 
|  |     97 | %     ytick={0,5,...,30},
 | 
|  |     98 | %     scaled ticks=false,
 | 
|  |     99 | %     axis lines=left,
 | 
|  |    100 | %     width=\textwidth,
 | 
|  |    101 | %     height=4cm, 
 | 
|  |    102 | %     legend entries={Python,Ruby},  
 | 
|  |    103 | %     legend pos=north west,
 | 
|  |    104 | %     legend cell align=left]
 | 
|  |    105 | % \addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
 | 
|  |    106 | % \addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
 | 
|  |    107 | % \end{axis}
 | 
|  |    108 | % \end{tikzpicture}
 | 
|  |    109 | % \begin{tikzpicture}\footnotesize
 | 
|  |    110 | % \begin{axis}[
 | 
|  |    111 | %     xlabel={$n$},
 | 
|  |    112 | %     x label style={at={(1.05,0.0)}},
 | 
|  |    113 | %     ylabel={time in secs},
 | 
|  |    114 | %     enlargelimits=false,
 | 
|  |    115 | %     xtick={0,5,...,30},
 | 
|  |    116 | %     xmax=33,
 | 
|  |    117 | %     ymax=35,
 | 
|  |    118 | %     ytick={0,5,...,30},
 | 
|  |    119 | %     scaled ticks=false,
 | 
|  |    120 | %     axis lines=left,
 | 
|  |    121 | %     width=\textwidth,
 | 
|  |    122 | %     height=4cm, 
 | 
|  |    123 | %     legend entries={Python, Java 8, JavaScript, Swift},  
 | 
|  |    124 | %     legend pos=north west,
 | 
|  |    125 | %     legend cell align=left]
 | 
|  |    126 | % \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
 | 
|  |    127 | % \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
|  |    128 | % \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
|  |    129 | % \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
|  |    130 | % \end{axis}
 | 
|  |    131 | % \end{tikzpicture}
 | 
|  |    132 | % %
 | 
|  |    133 | % \end{column}
 | 
|  |    134 | % \begin{column}{.5\textwidth}
 | 
|  |    135 | % \small{}In PEP \& CFL \medskip\\
 | 
|  |    136 | % \begin{tikzpicture}\footnotesize
 | 
|  |    137 | % \begin{axis}[
 | 
|  |    138 | %     xlabel={$n$},
 | 
|  |    139 | %     x label style={at={(1.07,0.0)}},
 | 
|  |    140 | %     ylabel={time in secs},
 | 
|  |    141 | %     enlargelimits=false,
 | 
|  |    142 | %     xtick={0,5000,...,10000},
 | 
|  |    143 | %     xmax=11000,
 | 
|  |    144 | %     ymax=35,
 | 
|  |    145 | %     ytick={0,5,...,30},
 | 
|  |    146 | %     scaled ticks=false,
 | 
|  |    147 | %     axis lines=left,
 | 
|  |    148 | %     width=\textwidth,
 | 
|  |    149 | %     height=4cm]
 | 
|  |    150 | % \addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
 | 
|  |    151 | % \addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
 | 
|  |    152 | % \end{axis}
 | 
|  |    153 | % \end{tikzpicture}
 | 
|  |    154 | % \begin{tikzpicture}\footnotesize
 | 
|  |    155 | % \begin{axis}[
 | 
|  |    156 | %     xlabel={$n$},
 | 
|  |    157 | %     x label style={at={(1.07,0.0)}},
 | 
|  |    158 | %     ylabel={time in secs},
 | 
|  |    159 | %     enlargelimits=false,
 | 
|  |    160 | %     ymax=35,
 | 
|  |    161 | %     ytick={0,5,...,30},
 | 
|  |    162 | %     scaled ticks=false,
 | 
|  |    163 | %     axis lines=left,
 | 
|  |    164 | %     width=\textwidth,
 | 
|  |    165 | %     height=4cm]
 | 
|  |    166 | % \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
|  |    167 | % \end{axis}
 | 
|  |    168 | % \end{tikzpicture}
 | 
|  |    169 | % \end{column}
 | 
|  |    170 | % \end{columns}
 | 
|  |    171 | % \medskip
 | 
| 906 |    172 | 
 | 
| 921 |    173 | % \begin{textblock}{3}(-0.1,3.3)
 | 
|  |    174 | % \small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
 | 
|  |    175 | % \end{textblock}
 | 
| 906 |    176 | 
 | 
| 921 |    177 | % \begin{textblock}{3}(-0.1,8.7)  
 | 
|  |    178 | % \small\hfill\bl{\texttt{(a*)*b}}:
 | 
|  |    179 | % \end{textblock}
 | 
| 906 |    180 | 
 | 
| 921 |    181 | % \begin{textblock}{3}(0.3,13)
 | 
|  |    182 | % \small{}matching with strings
 | 
|  |    183 | % \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
|  |    184 | % \end{textblock}
 | 
| 906 |    185 | 
 | 
| 921 |    186 | % \end{frame} 
 | 
|  |    187 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
| 906 |    188 |     
 | 
|  |    189 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 921 |    190 | % \begin{frame}[c,fragile]
 | 
|  |    191 | %   \frametitle{Incidents}
 | 
| 906 |    192 |     
 | 
| 921 |    193 | %   \begin{itemize}
 | 
|  |    194 | %   \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
 | 
|  |    195 | %   (first one for six years)\medskip
 | 
| 906 |    196 |   
 | 
| 921 |    197 | %   \begin{center}\small\color{blue}
 | 
|  |    198 | %   \begin{verbatim}  
 | 
|  |    199 | %   (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false|
 | 
|  |    200 | %   null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s
 | 
|  |    201 | %   |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
 | 
|  |    202 | %   \end{verbatim}
 | 
|  |    203 | %   \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
 | 
| 906 |    204 |   
 | 
| 921 |    205 | %   \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
 | 
|  |    206 | %     because of an evil regular expression
 | 
|  |    207 | %     \here{https://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016}    
 | 
|  |    208 | %   \end{itemize}
 | 
| 906 |    209 |   
 | 
| 921 |    210 | %   \begin{textblock}{6}(6,7.6)
 | 
|  |    211 | %     \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
 | 
|  |    212 | %     \footnotesize
 | 
|  |    213 | %     It serves more web traffic than Twitter, Amazon, Apple,
 | 
|  |    214 | %     Instagram, Bing \& Wikipedia combined.
 | 
|  |    215 | %     \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
 | 
|  |    216 | %     \end{textblock}
 | 
| 906 |    217 |   
 | 
| 921 |    218 | %   \end{frame}
 | 
|  |    219 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
| 906 |    220 |     
 | 
| 921 |    221 | % %\begin{frame}[c]
 | 
|  |    222 | % %
 | 
|  |    223 | % %\frametitle{}
 | 
|  |    224 | % %\begin{mybox3}{}\it
 | 
|  |    225 | %  ``This conversation is interesting to me, and I've researched it a little bit... I also disagree with Dr. Urban on the cost/benefit of non-GC languages...[..]\\
 | 
|  |    226 | %
 | 
|  |    227 | %  But regardless, Scala is a lot slower than, say, C or Rust. To say it's not is basically wrong (imo)....[..]
 | 
|  |    228 | %  ''\\
 | 
|  |    229 | %\mbox{}\hfill-- Oliver Iliffe,  discussion this year in PEP
 | 
|  |    230 | %\end{mybox3}\pause
 | 
|  |    231 | %
 | 
|  |    232 | %\end{frame}
 | 
| 906 |    233 | 
 | 
| 921 |    234 | %\begin{frame}<1-10>
 | 
|  |    235 | %\end{frame}  
 | 
| 876 |    236 | 
 | 
|  |    237 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    238 | \begin{frame}[t]
 | 
|  |    239 | \frametitle{%  
 | 
|  |    240 |   \begin{tabular}{@ {}c@ {}}
 | 
|  |    241 |   \\[-3mm]
 | 
|  |    242 |   \LARGE Compilers and \\[-1mm] 
 | 
| 880 |    243 |   \LARGE Formal Languages\\[-5mm] 
 | 
| 876 |    244 |   \end{tabular}}
 | 
|  |    245 | 
 | 
| 880 |    246 |   %\begin{center}
 | 
| 876 |    247 |   %\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm}
 | 
|  |    248 |   %\includegraphics[scale=0.31]{pics/ante2.jpg}\\
 | 
|  |    249 |   %\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)}
 | 
| 880 |    250 |   %\end{center}
 | 
| 876 |    251 | 
 | 
|  |    252 |   \normalsize
 | 
|  |    253 |   \begin{center}
 | 
|  |    254 |   \begin{tabular}{ll}
 | 
|  |    255 |   Email:  & christian.urban at kcl.ac.uk\\
 | 
| 880 |    256 |   Office Hour: & Fridays 11 -- 12\\
 | 
|  |    257 |   Location: & N7.07 (North Wing, Bush House)\\
 | 
| 876 |    258 |   Slides \& Progs: & KEATS\\
 | 
| 880 |    259 |   Pollev: & \texttt{\alert{https://pollev.com/cfltutoratki576}}\\  
 | 
| 876 |    260 |   \end{tabular}
 | 
|  |    261 |   \end{center}
 | 
|  |    262 | 
 | 
|  |    263 |   \begin{center}
 | 
|  |    264 |     \begin{tikzpicture}
 | 
|  |    265 |       \node[drop shadow,fill=white,inner sep=0pt] 
 | 
|  |    266 |       {\footnotesize\rowcolors{1}{capri!10}{white}
 | 
|  |    267 |         \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline
 | 
|  |    268 |           \cellcolor{blue!50}
 | 
|  |    269 |           1 Introduction, Languages          & 6 While-Language \\
 | 
|  |    270 |           2 Regular Expressions, Derivatives & 7 Compilation, JVM \\
 | 
|  |    271 |           3 Automata, Regular Languages      & 8 Compiling Functional Languages \\
 | 
|  |    272 |           4 Lexing, Tokenising               & 9 Optimisations \\
 | 
|  |    273 |           5 Grammars, Parsing                & 10 LLVM \\ \hline
 | 
|  |    274 |         \end{tabular}%
 | 
|  |    275 |       };
 | 
|  |    276 |     \end{tikzpicture}
 | 
|  |    277 |   \end{center}
 | 
|  |    278 | 
 | 
|  |    279 | \end{frame}
 | 
|  |    280 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    281 | 
 | 
|  |    282 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    283 | \begin{frame}<1-12>[c]
 | 
|  |    284 | \frametitle{The Goal of this Module\ldots}
 | 
|  |    285 | 
 | 
|  |    286 | \begin{center}
 | 
|  |    287 |   \begin{tikzpicture}[scale=1,
 | 
|  |    288 |                       node/.style={
 | 
|  |    289 |                       rectangle,rounded corners=3mm,
 | 
|  |    290 |                       very thick,draw=black!50,minimum height=18mm, minimum width=20mm,
 | 
|  |    291 |                       top color=white,bottom color=black!20,drop shadow}]
 | 
|  |    292 | 
 | 
|  |    293 |   \node at (3.05, 1.8) {\Large\bf \ldots{} you write a compiler};
 | 
|  |    294 | 
 | 
|  |    295 |   \node (0) at (-2.3,0) {};  
 | 
|  |    296 |   \node [above=5mm of 0]
 | 
|  |    297 |   {\makebox[0mm]{\footnotesize
 | 
|  |    298 |       \begin{tabular}{@{}l@{}}input\\[-1mm]program\end{tabular}}}; 
 | 
|  |    299 |      
 | 
|  |    300 |   \node (A) at (0,0)  [node] {};
 | 
|  |    301 |   \node [below right] at (A.north west) {lexer};
 | 
|  |    302 | 
 | 
|  |    303 |   \node (B) at (3,0)  [node] {};
 | 
|  |    304 |   \node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser};
 | 
|  |    305 | 
 | 
|  |    306 |   \node (C) at (6,0)  [node] {};
 | 
|  |    307 |   \node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen};
 | 
|  |    308 | 
 | 
|  |    309 |   \node (1) at (8.4,0) {};
 | 
|  |    310 |   \node [above=5mm of 1]
 | 
|  |    311 |   {\makebox[0mm]{\footnotesize
 | 
|  |    312 |       \begin{tabular}{@{}r@{}}binary\\[-1mm]code\end{tabular}}};
 | 
|  |    313 | 
 | 
| 928 |    314 |   \draw [->,line width=3mm] (0) -- (A); 
 | 
|  |    315 |   \draw [->,line width=3mm] (A) -- (B); 
 | 
|  |    316 |   \draw [->,line width=3mm] (B) -- (C); 
 | 
|  |    317 |   \draw [->,line width=3mm] (C) -- (1); 
 | 
| 876 |    318 |   \end{tikzpicture}
 | 
|  |    319 |   \end{center}
 | 
|  |    320 | 
 | 
|  |    321 | \only<2,3,4>{
 | 
|  |    322 | \begin{textblock}{1}(1,2.1)
 | 
|  |    323 | \begin{bubble}[9.8cm]
 | 
|  |    324 | \normalsize
 | 
|  |    325 | lexer input: a string\smallskip\\
 | 
|  |    326 | \hspace{5mm}\code{"read(n);"}\medskip\\
 | 
|  |    327 | lexer output: a sequence of tokens\smallskip\\
 | 
|  |    328 | \hspace{5mm}\code{key(read) lpar id(n) rpar semi}
 | 
|  |    329 | \end{bubble}
 | 
|  |    330 | \end{textblock}} 
 | 
|  |    331 | 
 | 
|  |    332 | \only<3,4>{
 | 
|  |    333 | \begin{textblock}{1}(6,7.8)
 | 
|  |    334 | \begin{tabular}{c}
 | 
|  |    335 | \includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm]
 | 
|  |    336 | \footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta)
 | 
|  |    337 | \end{tabular}
 | 
|  |    338 | \end{textblock}}
 | 
|  |    339 | 
 | 
|  |    340 | \only<4>{
 | 
|  |    341 | \begin{textblock}{1}(0.5,12)\small
 | 
|  |    342 | \begin{tabular}{l@{}c@{}l}
 | 
|  |    343 |   \pcode{if}    & $\;\Rightarrow\;$ & keyword\\
 | 
|  |    344 |   \pcode{iffoo} & $\;\Rightarrow\;$ & identifier\\
 | 
|  |    345 | \end{tabular}  
 | 
|  |    346 | \end{textblock}}
 | 
|  |    347 | 
 | 
|  |    348 | \only<6>{
 | 
|  |    349 | \begin{textblock}{1}(1,1.5)
 | 
|  |    350 | \begin{bubble}[8.5cm]
 | 
|  |    351 | \normalsize
 | 
|  |    352 | parser input: a sequence of tokens\smallskip\\
 | 
|  |    353 | 
 | 
|  |    354 | {\small\hspace{5mm}\code{key(read) lpar id(n) rpar semi}}\smallskip\\
 | 
|  |    355 | 
 | 
|  |    356 | parser output: an abstract syntax tree\smallskip\\
 | 
|  |    357 | \footnotesize
 | 
|  |    358 | \hspace{2cm}\begin{tikzpicture}
 | 
|  |    359 |   \node {\code{read}}
 | 
|  |    360 |     child {node {\code{lpar}}}
 | 
|  |    361 |     child {node {\code{n}}}
 | 
|  |    362 |     child {node {\code{rpar}}};
 | 
|  |    363 | \end{tikzpicture}
 | 
|  |    364 | \end{bubble}
 | 
|  |    365 | \end{textblock}}
 | 
|  |    366 | 
 | 
|  |    367 | \only<8,9>{
 | 
|  |    368 | \begin{textblock}{1}(1,1.5)
 | 
|  |    369 | \begin{bubble}[4cm]
 | 
|  |    370 | \normalsize
 | 
|  |    371 | code generation:\smallskip\\
 | 
|  |    372 | \hspace{5mm}\code{istore 2}\\ 
 | 
|  |    373 | \hspace{5mm}\code{iload 2}\\ 
 | 
|  |    374 | \hspace{5mm}\code{ldc 10}\\
 | 
|  |    375 | \hspace{5mm}\code{isub}\\
 | 
|  |    376 | \hspace{5mm}\code{ifeq Label2}\\ 
 | 
|  |    377 | \hspace{5mm}\code{iload 2}\\
 | 
|  |    378 | \hspace{5mm}\code{...}\\
 | 
|  |    379 | \end{bubble}
 | 
|  |    380 | \end{textblock}}
 | 
|  |    381 | 
 | 
|  |    382 | \only<9>{
 | 
|  |    383 | \begin{textblock}{6}(8.4,7)
 | 
|  |    384 | \begin{bubble}[5cm]
 | 
|  |    385 | \mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm]
 | 
|  |    386 | \begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs,
 | 
|  |    387 |     xlabel=n,
 | 
|  |    388 |     enlargelimits=0.05,
 | 
|  |    389 |     ybar interval=0.7, legend style=small]
 | 
|  |    390 | \addplot file {interpreted2.data};
 | 
|  |    391 | \addplot file {compiled2.data};
 | 
|  |    392 | %\legend{interpreted, compiled}
 | 
|  |    393 | \end{axis}
 | 
|  |    394 | \end{tikzpicture}}
 | 
|  |    395 | \end{bubble}
 | 
|  |    396 | \end{textblock}}
 | 
|  |    397 | 
 | 
|  |    398 | \only<10>{
 | 
|  |    399 | \begin{textblock}{6}(1,3)
 | 
|  |    400 |   \begin{bubble}[11cm]
 | 
|  |    401 |     Compiler explorers, e.g.: \url{https://gcc.godbolt.org} \;\video{https://youtu.be/ysaBmhMEyUg}
 | 
|  |    402 |   \begin{tikzpicture}[]
 | 
|  |    403 |   \node (0) at (-2.3,0) {\includegraphics[scale=0.3]{pics/csource.png}};
 | 
|  |    404 |   \node (1) [right=35mm] at (0) {\includegraphics[scale=0.3]{pics/cassmbl.png}}; 
 | 
|  |    405 |   \draw [->,line width=4mm, red] (0) -- (1);   
 | 
|  |    406 |   \node (2) [below=20mm] at (0) {\LARGE\bf source};
 | 
|  |    407 |   \node (3) [right=40mm] at (2) {\LARGE\bf binary};
 | 
|  |    408 |   \draw [->,line width=1mm] (2) -- (3);   
 | 
|  |    409 | \end{tikzpicture}
 | 
|  |    410 | \end{bubble}
 | 
|  |    411 | 
 | 
|  |    412 | \end{textblock}}
 | 
|  |    413 | \only<11>{
 | 
|  |    414 | \begin{textblock}{6}(1,3)
 | 
|  |    415 |   \begin{bubble}[11cm]
 | 
|  |    416 |     Compiler explorer for Java: \url{https://javap.yawk.at} 
 | 
|  |    417 |   \begin{tikzpicture}[]
 | 
|  |    418 |   \node (0) at (-2.3,0) {\includegraphics[scale=0.4]{pics/jsource.png}};
 | 
|  |    419 |   \node (1) [right=35mm] at (0) {\includegraphics[scale=0.4]{pics/jassmbl.png}}; 
 | 
|  |    420 |   \draw [->,line width=4mm, red] (0) -- (1);   
 | 
|  |    421 |   \node (2) [below=20mm] at (0) {\LARGE\bf source};
 | 
|  |    422 |   \node (3) [right=40mm] at (2) {\LARGE\bf byte code};
 | 
|  |    423 |   \draw [->,line width=1mm] (2) -- (3);   
 | 
|  |    424 | \end{tikzpicture}
 | 
|  |    425 | \end{bubble}
 | 
|  |    426 | \end{textblock}}
 | 
|  |    427 | 
 | 
|  |    428 | 
 | 
|  |    429 | \end{frame}
 | 
|  |    430 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    431 | 
 | 
|  |    432 | 
 | 
|  |    433 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    434 | \begin{frame}[t]
 | 
|  |    435 | \frametitle{Why Study Compilers?}
 | 
|  |    436 | 
 | 
|  |    437 | 
 | 
|  |    438 | John Regehr {\small(Univ.~Utah, LLVM compiler hacker)}
 | 
|  |    439 | \here{https://blog.regehr.org/archives/1419}
 | 
|  |    440 | \smallskip\\
 | 
|  |    441 | 
 | 
|  |    442 | \begin{bubble}[10.5cm]
 | 
|  |    443 |   \bf ``\ldots{}It’s effectively a perpetual
 | 
|  |    444 |   employment act for solid compiler hackers.''
 | 
|  |    445 | \end{bubble}
 | 
|  |    446 | 
 | 
|  |    447 | \onslide<1->{
 | 
|  |    448 | \only<2>{
 | 
|  |    449 | \begin{itemize}
 | 
|  |    450 | \item {\bf Hardware is getting weirder
 | 
|  |    451 |   rather than getting clocked faster.}
 | 
|  |    452 | 
 | 
|  |    453 | \begin{itemize}
 | 
|  |    454 | \item[]  ``Almost all processors are multicores nowadays and it looks
 | 
|  |    455 |   like there is increasing asymmetry in resources across cores.
 | 
|  |    456 |   Processors come with vector units, crypto accelerators etc. We have
 | 
|  |    457 |   DSPs, GPUs, ARM big.little, and Xeon Phi. This is only scratching the
 | 
|  |    458 |   surface.''
 | 
|  |    459 | \end{itemize}  
 | 
|  |    460 | \end{itemize}}
 | 
|  |    461 | \only<3>{
 | 
|  |    462 | \begin{itemize}
 | 
|  |    463 | \item {\bf We’re getting tired of low-level languages and
 | 
|  |    464 |     their associated security disasters.}
 | 
|  |    465 |   
 | 
|  |    466 | \begin{itemize}
 | 
|  |    467 | \item [] ``We want to write new code, to whatever extent possible, in
 | 
|  |    468 |   safer, higher-level languages. Compilers are caught right in the
 | 
|  |    469 |   middle of these opposing trends: one of their main jobs is to help
 | 
|  |    470 |   bridge the large and growing gap between increasingly high-level
 | 
|  |    471 |   languages and increasingly wacky platforms.''
 | 
|  |    472 | \end{itemize}  
 | 
|  |    473 | \end{itemize}}}
 | 
|  |    474 | 
 | 
|  |    475 | \end{frame}
 | 
|  |    476 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    477 | 
 | 
| 879 |    478 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    479 | {
 | 
|  |    480 | \setbeamercolor{background canvas}{bg=cream}
 | 
|  |    481 | \begin{frame}[c]
 | 
|  |    482 | 
 | 
|  |    483 | \frametitle{}
 | 
|  |    484 | \begin{mybox3}{}\it
 | 
|  |    485 |    ``I enjoyed the module - it was genuinely the stand out academic
 | 
|  |    486 | experience of my undergraduate degree, and very much influenced my
 | 
|  |    487 | career interests. In fact I am currently working at ARM, in their Open
 | 
|  |    488 | Source Software group, on AArch64 specific optimisations for the
 | 
|  |    489 | Java/Kotlin compiler that forms part of the Android Runtime.''\\
 | 
|  |    490 | \mbox{}\hfill-- Hari Limaye in year 2021/22
 | 
|  |    491 | \end{mybox3}\pause
 | 
|  |    492 | 
 | 
|  |    493 | 
 | 
|  |    494 | Student numbers in CFL\medskip\\
 | 
|  |    495 | \begin{tabular}{ll}
 | 
|  |    496 | 2019: & 32\\  
 | 
|  |    497 | 2020: & 59\\  
 | 
|  |    498 | 2021: & 109\\
 | 
|  |    499 | 2022: & 121\\  
 | 
|  |    500 | \end{tabular}  
 | 
|  |    501 | 
 | 
|  |    502 | \end{frame}
 | 
|  |    503 | }
 | 
|  |    504 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    505 | 
 | 
|  |    506 | 
 | 
|  |    507 | 
 | 
| 876 |    508 | 
 | 
|  |    509 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    510 | \begin{frame}[c]
 | 
|  |    511 | \frametitle{Why Bother with Compilers?}
 | 
|  |    512 |   
 | 
|  |    513 | \textbf{Boeing 777's}: First flight in 1994. They want to achieve
 | 
|  |    514 | triple redundancy for potential hardware faults.
 | 
|  |    515 | \here{http://www.citemaster.net/get/db3a81c6-548e-11e5-9d2e-00163e009cc7/R8.pdf}\bigskip
 | 
|  |    516 |   
 | 
|  |    517 | They compile 1 Ada program to\medskip
 | 
|  |    518 |   
 | 
|  |    519 | \begin{itemize}
 | 
|  |    520 |   \item Intel 80486
 | 
|  |    521 |   \item Motorola 68040 (old Macintosh's)
 | 
|  |    522 |   \item AMD 29050 (RISC chips used often in laser printers)
 | 
|  |    523 | \end{itemize}\medskip\medskip
 | 
|  |    524 |   
 | 
|  |    525 | using 3 independent compilers.\bigskip\pause
 | 
|  |    526 |   
 | 
|  |    527 | \small Airbus uses C and static analysers. Recently started using CompCert.
 | 
|  |    528 | 
 | 
|  |    529 | \only<1->{%
 | 
|  |    530 | \begin{textblock}{6}(8,4.5)
 | 
|  |    531 | \includegraphics[scale=0.28]{../pics/777.png}
 | 
|  |    532 | \end{textblock}}
 | 
|  |    533 | 
 | 
|  |    534 | \end{frame}
 | 
|  |    535 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    536 | 
 | 
|  |    537 | 
 | 
|  |    538 | 
 | 
|  |    539 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    540 | \begin{frame}[c]
 | 
|  |    541 | \frametitle{What Do Compilers Do?}
 | 
|  |    542 | 
 | 
|  |    543 | Remember BF*** from PEP?
 | 
|  |    544 | 
 | 
|  |    545 | \begin{center}
 | 
|  |    546 | \begin{tabular}{rcl}
 | 
|  |    547 | \bl{\texttt{>}} & $\Rightarrow$ & move one cell right\\
 | 
|  |    548 | \bl{\texttt{<}} & $\Rightarrow$ & move one cell left\\
 | 
|  |    549 | \bl{\texttt{+}} & $\Rightarrow$ & increase cell by one\\
 | 
|  |    550 | \bl{\texttt{-}} & $\Rightarrow$ & decrease cell by one\\
 | 
|  |    551 | \bl{\texttt{.}} & $\Rightarrow$ & print current cell\\
 | 
|  |    552 | \bl{\texttt{,}} & $\Rightarrow$ & input current cell\\
 | 
|  |    553 | \bl{\texttt{[}} & $\Rightarrow$ & loop begin\\
 | 
|  |    554 | \bl{\texttt{]}} & $\Rightarrow$ & loop end\medskip\\
 | 
|  |    555 |                 & $\Rightarrow$ & everything else is a comment\\
 | 
|  |    556 | \end{tabular}  
 | 
|  |    557 | \end{center}  
 | 
|  |    558 | 
 | 
|  |    559 | \end{frame}
 | 
|  |    560 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    561 | 
 | 
|  |    562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    563 | \begin{frame}[c]
 | 
|  |    564 |   \frametitle{A ``Compiler'' for BF*** to C}
 | 
|  |    565 |   
 | 
|  |    566 |   \begin{center}
 | 
|  |    567 |   \begin{tabular}{rcl}
 | 
|  |    568 |   \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
 | 
|  |    569 |   \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
 | 
|  |    570 |   \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
 | 
|  |    571 |   \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
 | 
|  |    572 |   \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
 | 
|  |    573 |   \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
 | 
|  |    574 |   \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
 | 
|  |    575 |   \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
 | 
|  |    576 |                   & $\Rightarrow$ & ignore everything else\\
 | 
|  |    577 |   \end{tabular}  
 | 
|  |    578 |   \end{center}\bigskip  
 | 
|  |    579 |   
 | 
|  |    580 |   \texttt{char field[30000]\\ char *ptr = \&field[15000]}
 | 
|  |    581 |   
 | 
|  |    582 | \end{frame}
 | 
|  |    583 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    584 | 
 | 
|  |    585 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    586 | \begin{frame}[c]
 | 
|  |    587 |   \frametitle{Another~``Compiler''~for~BF~to~C}
 | 
|  |    588 |   
 | 
|  |    589 |   \begin{center}
 | 
|  |    590 |   \begin{tabular}{rcl}
 | 
|  |    591 |   \bl{\texttt{>\ldots>}} & $\Rightarrow$ & \texttt{ptr += n}\\
 | 
|  |    592 |   \bl{\texttt{<\ldots<}} & $\Rightarrow$ & \texttt{ptr -= n}\\
 | 
|  |    593 |   \bl{\texttt{+\ldots+}} & $\Rightarrow$ & \texttt{(*ptr) += n}\\
 | 
|  |    594 |   \bl{\texttt{-\ldots-}} & $\Rightarrow$ & \texttt{(*ptr) -= n}\\
 | 
|  |    595 |   \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
 | 
|  |    596 |   \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
 | 
|  |    597 |   \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
 | 
|  |    598 |   \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
 | 
|  |    599 |                   & $\Rightarrow$ & ignore everything else\\
 | 
|  |    600 |   \end{tabular}  
 | 
|  |    601 |   \end{center}\bigskip  
 | 
|  |    602 |   
 | 
|  |    603 |   \texttt{char field[30000]\\ char *ptr = \&field[15000]}
 | 
|  |    604 |   
 | 
|  |    605 | \end{frame}
 | 
|  |    606 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    607 |     
 | 
|  |    608 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    609 | \begin{frame}[t]
 | 
|  |    610 | \frametitle{A Brief Compiler History}
 | 
|  |    611 | 
 | 
|  |    612 | \bigskip
 | 
|  |    613 | \begin{itemize}
 | 
|  |    614 | \item Turing Machines, 1936 (a tape as memory)
 | 
|  |    615 | \item Regular Expressions, 1956\\
 | 
|  |    616 | \item The first compiler for COBOL, 1957\\ (Grace Hopper)\medskip
 | 
|  |    617 | \item But surprisingly research papers are still published nowadays\\
 | 
|  |    618 | \item ``Parsing: The Solved Problem That Isn't''
 | 
|  |    619 |   \here{https://tratt.net/laurie/blog/entries/parsing_the_solved_problem_that_isnt.html}
 | 
|  |    620 | \end{itemize}
 | 
|  |    621 | 
 | 
|  |    622 | 
 | 
|  |    623 | \begin{textblock}{8.5}(5,7.6)
 | 
|  |    624 | \begin{flushright}
 | 
|  |    625 | \includegraphics[scale=0.3]{pics/hopper.jpg}\\
 | 
|  |    626 | \footnotesize\textcolor{gray}{Grace Hopper}\smallskip\\
 | 
|  |    627 | 
 | 
|  |    628 | {\small\textcolor{gray}{(she made it to David Letterman's Tonight Show
 | 
|  |    629 |  \here{https://youtu.be/3N_ywhx6_K0?t=31})}}
 | 
|  |    630 | \end{flushright}
 | 
|  |    631 | \end{textblock}
 | 
|  |    632 | 
 | 
|  |    633 | \end{frame}
 | 
|  |    634 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    635 | 
 | 
|  |    636 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    637 | \begin{frame}[c]
 | 
|  |    638 | \frametitle{Some Housekeeping}
 | 
|  |    639 | 
 | 
|  |    640 | \textbf{Exam will be online:}\bigskip
 | 
|  |    641 | 
 | 
|  |    642 | \begin{itemize}
 | 
|  |    643 | \item final exam in January (35\%)
 | 
|  |    644 | \item five CWs (65\%) 
 | 
|  |    645 | \end{itemize}\bigskip\bigskip\pause
 | 
|  |    646 | 
 | 
|  |    647 | 
 | 
|  |    648 | \textbf{Weekly Homework (optional):}
 | 
|  |    649 | \begin{itemize}
 | 
|  |    650 | \item uploaded on KEATS, send answers via email, (try to!) respond individually
 | 
|  |    651 | \item \alert{\bf all} questions in the exam will be from the HWs!!
 | 
|  |    652 | \end{itemize}  
 | 
|  |    653 | 
 | 
|  |    654 | \end{frame}
 | 
|  |    655 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    656 | 
 | 
| 879 |    657 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |    658 | {
 | 
|  |    659 | \setbeamercolor{background canvas}{bg=cream}
 | 
|  |    660 | \begin{frame}[c]
 | 
|  |    661 | \frametitle{Homework}
 | 
|  |    662 | 
 | 
| 921 |    663 | Until 2 years ago: I did not give out solutions; students sent emails to me and I responded to them individually.\bigskip\\
 | 
| 879 |    664 | 
 | 
|  |    665 | 
 | 
| 921 |    666 | Since last year: We will review the homework mainly during the SGTs.\bigskip\\\pause
 | 
| 879 |    667 | 
 | 
|  |    668 | I will still choose the questions from the HW for the exam, but there might be
 | 
|  |    669 | some larger amount of deviation.
 | 
|  |    670 | 
 | 
|  |    671 | \end{frame}
 | 
|  |    672 | }
 | 
|  |    673 | 
 | 
| 876 |    674 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    675 | \begin{frame}[c]
 | 
|  |    676 | \frametitle{Some Housekeeping}
 | 
|  |    677 | 
 | 
|  |    678 | \textbf{Coursework (5 accounting for 65\%):}\bigskip
 | 
|  |    679 | 
 | 
|  |    680 | \begin{itemize}
 | 
|  |    681 | \item matcher (5\%)
 | 
|  |    682 | \item lexer (10\%)
 | 
|  |    683 | \item parser / interpreter (10\%)
 | 
|  |    684 | \item JVM compiler (15\%)
 | 
|  |    685 | \item LLVM compiler (25\%) 
 | 
|  |    686 | \end{itemize}\bigskip\pause
 | 
|  |    687 | 
 | 
|  |    688 | you can use \alert{any} programming language you like (Haskell, Rust)\\\pause
 | 
|  |    689 | you can use any code I show you and is uploaded to KEATS\ldots\textbf{BUT NOTHING ELSE!}
 | 
|  |    690 | 
 | 
|  |    691 | \end{frame}
 | 
|  |    692 | 
 | 
|  |    693 | 
 | 
|  |    694 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    695 | \begin{frame}[c]
 | 
|  |    696 | \frametitle{Lectures 1 - 5}
 | 
|  |    697 | 
 | 
|  |    698 | transforming strings into structured data\\[10mm]
 | 
|  |    699 | 
 | 
|  |    700 | {\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
 | 
|  |    701 | \hspace{5mm}(recognising ``words'')\\[6mm]
 | 
|  |    702 | 
 | 
|  |    703 | {\LARGE\bf Parsing}\medskip\\
 | 
|  |    704 | \hspace{5mm}(recognising ``sentences'')
 | 
|  |    705 | 
 | 
|  |    706 | \begin{textblock}{1}(10,9.1)
 | 
|  |    707 | \begin{tabular}{c}
 | 
|  |    708 | \includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
 | 
|  |    709 | \footnotesize Stone of Rosetta
 | 
|  |    710 | \end{tabular}
 | 
|  |    711 | \end{textblock}
 | 
|  |    712 | 
 | 
|  |    713 | \end{frame}
 | 
|  |    714 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    715 | 
 | 
|  |    716 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    717 | \begin{frame}[c]
 | 
|  |    718 | \frametitle{Lectures 1 - 5}
 | 
|  |    719 | 
 | 
|  |    720 | transforming strings into structured data\\[10mm]
 | 
|  |    721 | 
 | 
|  |    722 | {\LARGE\bf Lexing} {\hfill{}based on regular expressions}\medskip\\
 | 
|  |    723 | \hspace{5mm}(recognising ``words'')\\[6mm]
 | 
|  |    724 | 
 | 
|  |    725 | {\LARGE\bf Parsing}\medskip\\
 | 
|  |    726 | \hspace{5mm}(recognising ``sentences'')
 | 
|  |    727 | 
 | 
|  |    728 | \begin{textblock}{1}(10,9.1)
 | 
|  |    729 | \begin{tabular}{c}
 | 
|  |    730 | \includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm]
 | 
|  |    731 | \footnotesize Stone of Rosetta
 | 
|  |    732 | \end{tabular}
 | 
|  |    733 | \end{textblock}
 | 
|  |    734 | 
 | 
|  |    735 | \end{frame}
 | 
|  |    736 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    737 | 
 | 
|  |    738 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    739 | \begin{frame}[c]
 | 
|  |    740 |   \frametitle{Lectures 5 - 10}
 | 
|  |    741 |   
 | 
|  |    742 |   code generation for a small imperative and a small functional language\\[10mm]
 | 
|  |    743 |   
 | 
|  |    744 |   {\LARGE\bf Interpreters}\medskip\\
 | 
|  |    745 |   \hspace{5mm}(directly runs a program)\\[6mm]
 | 
|  |    746 |   
 | 
|  |    747 |   {\LARGE\bf Compilers}\medskip\\
 | 
|  |    748 |   \hspace{5mm}(generate JVM code and LLVM-IR code)
 | 
|  |    749 |   
 | 
|  |    750 |   \begin{textblock}{1}(8.8,8.1)
 | 
|  |    751 |   \begin{tabular}{c@{}c}
 | 
|  |    752 |     \includegraphics[scale=0.4]{../pics/javaduke.png} &
 | 
|  |    753 |     \includegraphics[scale=0.23]{../pics/llvmlogo.png}
 | 
|  |    754 |   \end{tabular}
 | 
|  |    755 |   \end{textblock}
 | 
|  |    756 |   
 | 
|  |    757 |   \end{frame}
 | 
|  |    758 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    759 |   
 | 
|  |    760 | 
 | 
|  |    761 | 
 | 
|  |    762 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    763 | \begin{frame}[t]
 | 
|  |    764 | \frametitle{Familiar Regular Expresssions}
 | 
|  |    765 | \small
 | 
|  |    766 | \begin{center}
 | 
|  |    767 | \texttt{[a-z0-9\_$\backslash{}$.-]+ @ [a-z0-9$\backslash{}$.-]+ . [a-z$\backslash{}$.]\{2,6\}}
 | 
|  |    768 | \end{center}\smallskip
 | 
|  |    769 | 
 | 
|  |    770 | \begin{center}
 | 
|  |    771 | \begin{tabular}{@{}lp{8.5cm}@{}}
 | 
|  |    772 | \pcode{re*} & matches 0 or more times\\
 | 
|  |    773 | \pcode{re+} & matches 1 or more times\\
 | 
|  |    774 | \pcode{re?} & matches 0 or 1 times\\
 | 
|  |    775 | \pcode{re\{n\}}	& matches exactly \pcode{n} number of times\\
 | 
|  |    776 | \pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\
 | 
|  |    777 | \pcode{[...]} & matches any single character inside the brackets\\
 | 
|  |    778 | \pcode{[^...]} & matches any single character not inside the 
 | 
|  |    779 | brackets\\
 | 
|  |    780 | \pcode{a-z A-Z} & character ranges\\
 | 
|  |    781 | \pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\
 | 
|  |    782 | \pcode{.} & matches every character except newline\\
 | 
|  |    783 | \pcode{(re)}	& groups regular expressions and remembers 
 | 
|  |    784 | the matched text
 | 
|  |    785 | \end{tabular}
 | 
|  |    786 | \end{center}
 | 
|  |    787 | 
 | 
|  |    788 | \end{frame}
 | 
|  |    789 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
| 879 |    790 | {
 | 
|  |    791 | \setbeamercolor{background canvas}{bg=cream}
 | 
|  |    792 | \begin{frame}[t]
 | 
|  |    793 | \frametitle{Notation for REs}
 | 
|  |    794 | 
 | 
|  |    795 | 
 | 
|  |    796 | 
 | 
|  |    797 |   
 | 
|  |    798 | \end{frame}  
 | 
|  |    799 | }
 | 
| 876 |    800 | 
 | 
|  |    801 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    802 | \begin{frame}[c]
 | 
|  |    803 | \frametitle{Some ``innocent'' examples}
 | 
|  |    804 | 
 | 
|  |    805 | Let's try two examples
 | 
|  |    806 | 
 | 
|  |    807 | \begin{center}
 | 
|  |    808 |   \bl{\texttt{(a*)*b}}
 | 
|  |    809 |   \hspace{2cm}
 | 
|  |    810 |   \bl{\texttt{[a?]\{n\}[a]\{n\}}}
 | 
|  |    811 | \end{center}\bigskip\pause  
 | 
|  |    812 | 
 | 
|  |    813 | and match them with strings of the form
 | 
|  |    814 | 
 | 
|  |    815 | \begin{center}
 | 
|  |    816 |   \bl{\texttt{a}},
 | 
|  |    817 |   \bl{\texttt{aa}},
 | 
|  |    818 |   \bl{\texttt{aaa}},
 | 
|  |    819 |   \bl{\texttt{aaaa}},
 | 
|  |    820 |   \bl{\texttt{aaaaa}},
 | 
|  |    821 |   \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
|  |    822 | \end{center}  
 | 
|  |    823 | 
 | 
|  |    824 | \end{frame}
 | 
|  |    825 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |    826 | 
 | 
|  |    827 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    828 | \begin{frame}[c]
 | 
|  |    829 | \frametitle{Why Bother with Regexes?}
 | 
|  |    830 | 
 | 
|  |    831 | \begin{columns}[t,onlytextwidth]
 | 
|  |    832 | \begin{column}{1.8cm}
 | 
|  |    833 | \mbox{}   
 | 
|  |    834 | \end{column}    
 | 
|  |    835 | \begin{column}{.5\textwidth}
 | 
|  |    836 | \small{}Ruby, Python, Java 8\medskip\\
 | 
|  |    837 | \begin{tikzpicture}\footnotesize
 | 
|  |    838 | \begin{axis}[
 | 
|  |    839 |     xlabel={$n$},
 | 
|  |    840 |     x label style={at={(1.05,0.0)}},
 | 
|  |    841 |     ylabel={time in secs},
 | 
|  |    842 |     enlargelimits=false,
 | 
|  |    843 |     xtick={0,5,...,30},
 | 
|  |    844 |     xmax=33,
 | 
|  |    845 |     ymax=35,
 | 
|  |    846 |     ytick={0,5,...,30},
 | 
|  |    847 |     scaled ticks=false,
 | 
|  |    848 |     axis lines=left,
 | 
|  |    849 |     width=\textwidth,
 | 
|  |    850 |     height=4cm, 
 | 
|  |    851 |     legend entries={Python,Ruby},  
 | 
|  |    852 |     legend pos=north west,
 | 
|  |    853 |     legend cell align=left]
 | 
|  |    854 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python.data};
 | 
|  |    855 | \addplot[brown,mark=triangle*, mark options={fill=white}] table {re-ruby.data};
 | 
|  |    856 | \end{axis}
 | 
|  |    857 | \end{tikzpicture}
 | 
|  |    858 | \begin{tikzpicture}\footnotesize
 | 
|  |    859 | \begin{axis}[
 | 
|  |    860 |     xlabel={$n$},
 | 
|  |    861 |     x label style={at={(1.05,0.0)}},
 | 
|  |    862 |     ylabel={time in secs},
 | 
|  |    863 |     enlargelimits=false,
 | 
|  |    864 |     xtick={0,5,...,30},
 | 
|  |    865 |     xmax=33,
 | 
|  |    866 |     ymax=35,
 | 
|  |    867 |     ytick={0,5,...,30},
 | 
|  |    868 |     scaled ticks=false,
 | 
|  |    869 |     axis lines=left,
 | 
|  |    870 |     width=\textwidth,
 | 
|  |    871 |     height=4cm, 
 | 
|  |    872 |     legend entries={Python, Java 8, JavaScript, Swift},  
 | 
|  |    873 |     legend pos=north west,
 | 
|  |    874 |     legend cell align=left]
 | 
|  |    875 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};   
 | 
|  |    876 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
|  |    877 | \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
|  |    878 | \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
|  |    879 | \end{axis}
 | 
|  |    880 | \end{tikzpicture}
 | 
|  |    881 | %
 | 
|  |    882 | \end{column}
 | 
|  |    883 | \begin{column}{.5\textwidth}
 | 
|  |    884 | \small{}Us (after next lecture)\medskip\\
 | 
|  |    885 | \begin{tikzpicture}\footnotesize
 | 
|  |    886 | \begin{axis}[
 | 
|  |    887 |     xlabel={$n$},
 | 
|  |    888 |     x label style={at={(1.07,0.0)}},
 | 
|  |    889 |     ylabel={time in secs},
 | 
|  |    890 |     enlargelimits=false,
 | 
|  |    891 |     xtick={0,5000,...,10000},
 | 
|  |    892 |     xmax=11000,
 | 
|  |    893 |     ymax=35,
 | 
|  |    894 |     ytick={0,5,...,30},
 | 
|  |    895 |     scaled ticks=false,
 | 
|  |    896 |     axis lines=left,
 | 
|  |    897 |     width=\textwidth,
 | 
|  |    898 |     height=4cm]
 | 
|  |    899 | \addplot[green,mark=square*,mark options={fill=white}] table {re2.data};
 | 
|  |    900 | \addplot[black,mark=square*,mark options={fill=white}] table {re3.data};
 | 
|  |    901 | \end{axis}
 | 
|  |    902 | \end{tikzpicture}
 | 
|  |    903 | \begin{tikzpicture}\footnotesize
 | 
|  |    904 | \begin{axis}[
 | 
|  |    905 |     xlabel={$n$},
 | 
|  |    906 |     x label style={at={(1.07,0.0)}},
 | 
|  |    907 |     ylabel={time in secs},
 | 
|  |    908 |     enlargelimits=false,
 | 
|  |    909 |     ymax=35,
 | 
|  |    910 |     ytick={0,5,...,30},
 | 
|  |    911 |     scaled ticks=false,
 | 
|  |    912 |     axis lines=left,
 | 
|  |    913 |     width=\textwidth,
 | 
|  |    914 |     height=4cm]
 | 
|  |    915 | \addplot[black,mark=square*,mark options={fill=white}] table {re3a.data};
 | 
|  |    916 | \end{axis}
 | 
|  |    917 | \end{tikzpicture}
 | 
|  |    918 | \end{column}
 | 
|  |    919 | \end{columns}
 | 
|  |    920 | \medskip
 | 
|  |    921 | 
 | 
|  |    922 | \begin{textblock}{3}(-0.1,3.3)
 | 
|  |    923 | \small\hfill\bl{\texttt{[a?]\{n\}[a]\{n\}}}:
 | 
|  |    924 | \end{textblock}
 | 
|  |    925 | 
 | 
|  |    926 | \begin{textblock}{3}(-0.1,8.7)  
 | 
|  |    927 | \small\hfill\bl{\texttt{(a*)*b}}:
 | 
|  |    928 | \end{textblock}
 | 
|  |    929 | 
 | 
|  |    930 | \begin{textblock}{3}(0.3,13)
 | 
|  |    931 | \small{}matching with strings
 | 
|  |    932 | \bl{$\underbrace{\texttt{a}...\texttt{a}}_n$}  
 | 
|  |    933 | \end{textblock}
 | 
|  |    934 | 
 | 
|  |    935 | \end{frame} 
 | 
|  |    936 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |    937 |     
 | 
|  |    938 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    939 | \begin{frame}[c,fragile]
 | 
|  |    940 |   \frametitle{Incidents}
 | 
|  |    941 |     
 | 
|  |    942 |   \begin{itemize}
 | 
|  |    943 |   \item a global outage on 2 July 2019 at \textbf{Cloudflare} 
 | 
|  |    944 |   (first one for six years)\medskip
 | 
|  |    945 |   
 | 
|  |    946 |   \begin{center}\small\color{blue}
 | 
|  |    947 |   \begin{verbatim}  
 | 
|  |    948 |   (?:(?:\"|'|\]|\}|\\|\d|(?:nan|infinity|true|false|
 | 
|  |    949 |   null|undefined|symbol|math)|\`|\-|\+)+[)]*;?((?:\s
 | 
|  |    950 |   |-|~|!|{}|\|\||\+)*.*(?:.*=.*)))  
 | 
|  |    951 |   \end{verbatim}
 | 
|  |    952 |   \end{center}\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip\bigskip    
 | 
|  |    953 |   
 | 
|  |    954 |   \item on 20 July 2016 the \textbf{Stack Exchange} webpage went down
 | 
|  |    955 |     because of an evil regular expression
 | 
|  |    956 |     \here{https://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016}    
 | 
|  |    957 |   \end{itemize}
 | 
|  |    958 |   
 | 
|  |    959 |   \begin{textblock}{6}(6,7.6)
 | 
|  |    960 |     \includegraphics[scale=0.14]{../pics/cloudflare.png}\\
 | 
|  |    961 |     \footnotesize
 | 
|  |    962 |     It serves more web traffic than Twitter, Amazon, Apple,
 | 
|  |    963 |     Instagram, Bing \& Wikipedia combined.
 | 
|  |    964 |     \here{https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/}
 | 
|  |    965 |     \end{textblock}
 | 
|  |    966 |   
 | 
|  |    967 |   \end{frame}
 | 
|  |    968 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
 | 
|  |    969 |     
 | 
|  |    970 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    971 | \begin{frame}[c]
 | 
|  |    972 | \frametitle{Evil Regular Expressions}
 | 
|  |    973 | 
 | 
|  |    974 | \begin{itemize}
 | 
|  |    975 | \item \alert{R}egular \alert{e}xpression \alert{D}enial \alert{o}f \alert{S}ervice (ReDoS)\medskip
 | 
|  |    976 | \item Some evil regular expressions:\medskip
 | 
|  |    977 | \begin{itemize}
 | 
|  |    978 | \item \bl{\texttt{[a?]\{n\}\;[a]\{n\}}}
 | 
|  |    979 | \item \bl{\texttt{(a*)*\;b}}  
 | 
|  |    980 | \item \bl{\texttt{([a-z]+)*}} 
 | 
|  |    981 | \item \bl{\texttt{(a + aa)*}}
 | 
|  |    982 | \item \bl{\texttt{(a + a?)*}}
 | 
|  |    983 | \end{itemize}
 | 
|  |    984 | 
 | 
|  |    985 | \item sometimes also called \alert{catastrophic backtracking}
 | 
|  |    986 | \item this is a problem for \alert{N}etwork \alert{I}ntrusion
 | 
|  |    987 |   \alert{D}etection systems, Cloudflare, StackExchange, Atom editor
 | 
|  |    988 | \item \url{https://vimeo.com/112065252}  
 | 
|  |    989 | \end{itemize}
 | 
|  |    990 | 
 | 
|  |    991 | \end{frame}
 | 
|  |    992 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    993 | 
 | 
|  |    994 | 
 | 
|  |    995 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |    996 | %\begin{frame}[c]
 | 
|  |    997 | %\frametitle{Today}
 | 
|  |    998 | %
 | 
|  |    999 | %\begin{itemize}
 | 
|  |   1000 | %\item While the ultimate goal is to implement a small compiler for the JVM
 | 
|  |   1001 | %  \ldots\bigskip
 | 
|  |   1002 | %\end{itemize}
 | 
|  |   1003 | %
 | 
|  |   1004 | %Let's start with:
 | 
|  |   1005 | %
 | 
|  |   1006 | %\begin{itemize}
 | 
|  |   1007 | %\item a web-crawler
 | 
|  |   1008 | %\item an email harvester
 | 
|  |   1009 | %\item \textcolor{gray}{(a web-scraper)}
 | 
|  |   1010 | %\end{itemize}
 | 
|  |   1011 | %
 | 
|  |   1012 | %\end{frame}
 | 
|  |   1013 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |   1014 | 
 | 
|  |   1015 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1016 | %\begin{frame}[t]
 | 
|  |   1017 | %\frametitle{A Web-Crawler}
 | 
|  |   1018 | %
 | 
|  |   1019 | %\mbox{}\\[10mm]
 | 
|  |   1020 | %
 | 
|  |   1021 | %\begin{enumerate}
 | 
|  |   1022 | %\item given an URL, read the corresponding webpage
 | 
|  |   1023 | %\item extract all links from it
 | 
|  |   1024 | %\item call the web-crawler again for all these links
 | 
|  |   1025 | %\end{enumerate}
 | 
|  |   1026 | %
 | 
|  |   1027 | %\end{frame}
 | 
|  |   1028 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1029 | 
 | 
|  |   1030 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1031 | %\begin{frame}[t]
 | 
|  |   1032 | %\frametitle{A Web-Crawler}
 | 
|  |   1033 | %
 | 
|  |   1034 | %\mbox{}\\[10mm]
 | 
|  |   1035 | %
 | 
|  |   1036 | %
 | 
|  |   1037 | %\begin{enumerate}
 | 
|  |   1038 | %\item given an URL, read the corresponding webpage
 | 
|  |   1039 | %\item if not possible print, out a problem
 | 
|  |   1040 | %\item if possible, extract all links from it
 | 
|  |   1041 | %\item call the web-crawler again for all these links
 | 
|  |   1042 | %\end{enumerate}\bigskip\pause
 | 
|  |   1043 | %
 | 
|  |   1044 | %\small (we need a bound for the number of recursive calls)
 | 
|  |   1045 | %
 | 
|  |   1046 | %\small (the purpose is to check all links on my own webpage)
 | 
|  |   1047 | %\end{frame}
 | 
|  |   1048 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1049 | 
 | 
|  |   1050 | 
 | 
|  |   1051 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1052 | %\begin{frame}[c]
 | 
|  |   1053 | %
 | 
|  |   1054 | %\begin{textblock}{1}(2,5)
 | 
|  |   1055 | %\begin{tabular}{c}
 | 
|  |   1056 | %\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm]
 | 
|  |   1057 | %\small Server
 | 
|  |   1058 | %\end{tabular}
 | 
|  |   1059 | %\end{textblock}
 | 
|  |   1060 | %
 | 
|  |   1061 | %\begin{textblock}{1}(5.6,4)
 | 
|  |   1062 | %  \begin{tikzpicture}[scale=1.1]
 | 
|  |   1063 | %  \draw[white] (0,1) node (X) {};
 | 
|  |   1064 | %  \draw[white] (2,1) node (Y) {};
 | 
|  |   1065 | %   \draw[white] (0,0) node (X1) {};
 | 
|  |   1066 | %  \draw[white] (2,0) node (Y1) {};
 | 
|  |   1067 | %   \draw[white] (0,-1) node (X2) {};
 | 
|  |   1068 | %  \draw[white] (2,-1) node (Y2) {};
 | 
|  |   1069 | %  \draw[red, <-, line width = 2mm] (X) -- (Y);
 | 
|  |   1070 | %  \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
 | 
|  |   1071 | %  \draw[red, ->, line width = 2mm] (X1) -- (Y1);
 | 
|  |   1072 | %  \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
 | 
|  |   1073 | %  \draw[red, <-, line width = 2mm] (X2) -- (Y2);
 | 
|  |   1074 | %  \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
 | 
|  |   1075 | %  \end{tikzpicture}
 | 
|  |   1076 | %\end{textblock}
 | 
|  |   1077 | %
 | 
|  |   1078 | %
 | 
|  |   1079 | %\begin{textblock}{1}(9,5.5)
 | 
|  |   1080 | %\begin{tabular}{c}
 | 
|  |   1081 | %\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm]
 | 
|  |   1082 | %\small Browser
 | 
|  |   1083 | %\end{tabular}
 | 
|  |   1084 | %\end{textblock}
 | 
|  |   1085 | %\end{frame}
 | 
|  |   1086 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1087 | 
 | 
|  |   1088 |   
 | 
|  |   1089 | 
 | 
|  |   1090 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1091 | %\begin{frame}[c]
 | 
|  |   1092 | %\frametitle{Scala}
 | 
|  |   1093 | %
 | 
|  |   1094 | %\small A simple Scala function for reading webpages:
 | 
|  |   1095 | %\bigskip
 | 
|  |   1096 | %
 | 
|  |   1097 | %\footnotesize
 | 
|  |   1098 | %\lstinputlisting{../progs/app0.scala}
 | 
|  |   1099 | %\medskip\pause
 | 
|  |   1100 | %
 | 
|  |   1101 | %\lstinline{get_page("""https://nms.kcl.ac.uk/christian.urban/""")}
 | 
|  |   1102 | %\bigskip\medskip\pause
 | 
|  |   1103 | %
 | 
|  |   1104 | %
 | 
|  |   1105 | %\small A slightly more complicated version for handling errors:
 | 
|  |   1106 | %\smallskip
 | 
|  |   1107 | %
 | 
|  |   1108 | %\footnotesize
 | 
|  |   1109 | %\lstinputlisting[xleftmargin=-4mm]{../progs/app1.scala}
 | 
|  |   1110 | %
 | 
|  |   1111 | %
 | 
|  |   1112 | %\end{frame}
 | 
|  |   1113 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1114 | 
 | 
|  |   1115 |  
 | 
|  |   1116 | 
 | 
|  |   1117 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1118 | %\begin{frame}[t]
 | 
|  |   1119 | %\frametitle{A Regular Expression}
 | 
|  |   1120 | %
 | 
|  |   1121 | %\begin{itemize}
 | 
|  |   1122 | %\item \ldots{} is a pattern or template for specifying strings
 | 
|  |   1123 | %\end{itemize}\bigskip
 | 
|  |   1124 | %  
 | 
|  |   1125 | %\begin{center}  
 | 
|  |   1126 | %\only<1>{\scode{"https?://[^"]*"}}%
 | 
|  |   1127 | %\only<2>{\scode{""""https?://[^"]*"""".r}}
 | 
|  |   1128 | %\end{center}\bigskip\bigskip
 | 
|  |   1129 | %
 | 
|  |   1130 | %matches for example\smallskip\\  
 | 
|  |   1131 | %\hspace{2mm}\code{"http://www.foobar.com"}\\
 | 
|  |   1132 | %\hspace{2mm}\code{"https://www.tls.org"}\smallskip\\
 | 
|  |   1133 | %
 | 
|  |   1134 | %but not\smallskip\\  
 | 
|  |   1135 | %\hspace{2mm}\code{"http://www."foo"bar.com"}\\
 | 
|  |   1136 | %
 | 
|  |   1137 | %\end{frame}
 | 
|  |   1138 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1139 | 
 | 
|  |   1140 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1141 | %\begin{frame}[c]
 | 
|  |   1142 | %\frametitle{Finding Operations in Scala}
 | 
|  |   1143 | %
 | 
|  |   1144 | %{\bf\code{rexp.findAllIn(string)}}\medskip
 | 
|  |   1145 | %  
 | 
|  |   1146 | %returns a list of all (sub)strings that match the 
 | 
|  |   1147 | %regular expression
 | 
|  |   1148 | %\bigskip\bigskip  
 | 
|  |   1149 | %  
 | 
|  |   1150 | %
 | 
|  |   1151 | %{\bf\code{rexp.findFirstIn(string)}}\medskip
 | 
|  |   1152 | % 
 | 
|  |   1153 | %returns either 
 | 
|  |   1154 | %
 | 
|  |   1155 | %\begin{itemize}
 | 
|  |   1156 | %\item \code{None} if no (sub)string matches or 
 | 
|  |   1157 | %\item \code{Some(s)} with the first (sub)string
 | 
|  |   1158 | %\end{itemize}
 | 
|  |   1159 | %
 | 
|  |   1160 | %\end{frame}
 | 
|  |   1161 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1162 | 
 | 
|  |   1163 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1164 | %\begin{frame}[c]
 | 
|  |   1165 | %
 | 
|  |   1166 | %\footnotesize
 | 
|  |   1167 | %\lstinputlisting{../progs/app2.scala}
 | 
|  |   1168 | %
 | 
|  |   1169 | %\end{frame}
 | 
|  |   1170 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1171 | 
 | 
|  |   1172 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1173 | %\begin{frame}[c]
 | 
|  |   1174 | %
 | 
|  |   1175 | %\small
 | 
|  |   1176 | %A version that only crawls links in ``my'' domain:\bigskip
 | 
|  |   1177 | %
 | 
|  |   1178 | %\footnotesize
 | 
|  |   1179 | %\lstinputlisting{../progs/app3.scala}
 | 
|  |   1180 | %
 | 
|  |   1181 | %\end{frame}
 | 
|  |   1182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1183 | 
 | 
|  |   1184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1185 | %\begin{frame}[c]
 | 
|  |   1186 | %\lstset{xleftmargin=-4mm}
 | 
|  |   1187 | %\small
 | 
|  |   1188 | %A little email harvester:
 | 
|  |   1189 | %
 | 
|  |   1190 | %\footnotesize
 | 
|  |   1191 | %\lstinputlisting{../progs/app4.scala}\bigskip
 | 
|  |   1192 | %
 | 
|  |   1193 | %\tiny
 | 
|  |   1194 | %\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}
 | 
|  |   1195 | %
 | 
|  |   1196 | %\end{frame}
 | 
|  |   1197 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1198 | 
 | 
|  |   1199 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1200 | \begin{frame}[t]
 | 
|  |   1201 | \frametitle{(Basic) Regular Expressions}
 | 
|  |   1202 | 
 | 
|  |   1203 | Their inductive definition:
 | 
|  |   1204 | 
 | 
|  |   1205 | 
 | 
|  |   1206 | \begin{textblock}{6}(2,7.5)
 | 
|  |   1207 |   \begin{tabular}{@ {}rrl@ {\hspace{13mm}}l}
 | 
|  |   1208 |   \bl{$r$} & \bl{$::=$}  & \bl{$\ZERO$}  & nothing\\
 | 
|  |   1209 |          & \bl{$\mid$} & \bl{$\ONE$}       & empty string / \pcode{""} / $[]$\\
 | 
|  |   1210 |          & \bl{$\mid$} & \bl{$c$}                         & character\\
 | 
|  |   1211 |          & \bl{$\mid$} & \bl{$r_1 + r_2$}  & alternative / choice\\
 | 
|  |   1212 |          & \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\
 | 
|  |   1213 |          & \bl{$\mid$} & \bl{$r^*$}            & star (zero or more)\\
 | 
|  |   1214 |   \end{tabular}
 | 
|  |   1215 |   \end{textblock}
 | 
|  |   1216 |   
 | 
|  |   1217 |   
 | 
|  |   1218 | \only<2->{\footnotesize
 | 
|  |   1219 | \begin{textblock}{9}(2,0.5)
 | 
|  |   1220 | \begin{bubble}[9.8cm]
 | 
|  |   1221 | \lstinputlisting{../progs/app01.scala}
 | 
|  |   1222 | \end{bubble}
 | 
|  |   1223 | \end{textblock}}
 | 
|  |   1224 |   
 | 
|  |   1225 | \end{frame}
 | 
|  |   1226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1227 | 
 | 
|  |   1228 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1229 | %\begin{frame}[t]
 | 
|  |   1230 | %\frametitle{Regular Expressions}
 | 
|  |   1231 | %
 | 
|  |   1232 | %\small
 | 
|  |   1233 | %In Scala:\bigskip
 | 
|  |   1234 | %
 | 
|  |   1235 | %\footnotesize
 | 
|  |   1236 | %\lstinputlisting{../progs/app51.scala}
 | 
|  |   1237 | %
 | 
|  |   1238 | %  
 | 
|  |   1239 | %\end{frame}
 | 
|  |   1240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1241 | 
 | 
|  |   1242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1243 | \begin{frame}[t]
 | 
|  |   1244 | \frametitle{Strings}
 | 
|  |   1245 | 
 | 
|  |   1246 | \ldots are lists of characters. For example \code{"hello"}
 | 
|  |   1247 | 
 | 
|  |   1248 | \begin{center}
 | 
|  |   1249 | \bl{$[h, e, l, l, o]$} or just \bl{$hello$}
 | 
|  |   1250 | \end{center}
 | 
|  |   1251 | 
 | 
|  |   1252 | the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\
 | 
|  |   1253 | 
 | 
|  |   1254 | the concatenation of two strings:
 | 
|  |   1255 | 
 | 
|  |   1256 | \begin{center}
 | 
|  |   1257 | \bl{$s_1 \,@\, s_2$}
 | 
|  |   1258 | \end{center}
 | 
|  |   1259 | 
 | 
|  |   1260 | \bl{\textit{foo $@$ bar = foobar}}\\
 | 
|  |   1261 | \bl{\textit{baz $@\, []$ = baz}}
 | 
|  |   1262 |   
 | 
|  |   1263 | \end{frame}
 | 
|  |   1264 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1265 | 
 | 
|  |   1266 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1267 | \begin{frame}[c]
 | 
|  |   1268 | \frametitle{Languages, Strings}
 | 
|  |   1269 | 
 | 
|  |   1270 | \begin{itemize}
 | 
|  |   1271 | \item \alert{\bf Strings} are lists of characters, for example
 | 
|  |   1272 | \begin{center}
 | 
|  |   1273 | \bl{$[]$},\;\bl{$abc$}  \hspace{2cm}(Pattern match: \bl{$c\!::\!s$})
 | 
|  |   1274 | \end{center}\bigskip
 | 
|  |   1275 | 
 | 
|  |   1276 | 
 | 
|  |   1277 | \item A \alert{\bf language} is a set of strings, for example\medskip
 | 
|  |   1278 | \begin{center}
 | 
|  |   1279 | \bl{$\{[], hello, \textit{foobar}, a, abc\}$}
 | 
|  |   1280 | \end{center}\bigskip
 | 
|  |   1281 | 
 | 
|  |   1282 | \item \alert{\bf Concatenation} of strings and languages
 | 
|  |   1283 | 
 | 
|  |   1284 | \begin{center}
 | 
|  |   1285 | \begin{tabular}{rcl}
 | 
|  |   1286 | \bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\
 | 
|  |   1287 | \bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | 
|  |   1288 | \end{tabular}
 | 
|  |   1289 | \end{center}
 | 
|  |   1290 | 
 | 
|  |   1291 | %\item The \alert{\bf meaning} of a regular expression is a set of 
 | 
|  |   1292 | %  strings, or language.
 | 
|  |   1293 | \end{itemize}  
 | 
|  |   1294 | 
 | 
|  |   1295 | \only<2>{
 | 
|  |   1296 | \begin{textblock}{4}(10.5,8)
 | 
|  |   1297 | \small
 | 
|  |   1298 | Let
 | 
|  |   1299 | 
 | 
|  |   1300 | \bl{$A = \{foo, bar\}$} \bl{$B = \{a, b\}$}
 | 
|  |   1301 | \[
 | 
|  |   1302 | \bl{A \,@\, B = \{fooa, foob, bara, barb\}}
 | 
|  |   1303 | \]
 | 
|  |   1304 | \end{textblock}}  
 | 
|  |   1305 | 
 | 
|  |   1306 | \end{frame}
 | 
|  |   1307 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1308 | 
 | 
|  |   1309 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1310 | \begin{frame}[c]
 | 
|  |   1311 |   \frametitle{Two Corner Cases}
 | 
|  |   1312 |    
 | 
|  |   1313 |   \Large
 | 
|  |   1314 |   \begin{center}
 | 
|  |   1315 |   \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
 | 
|  |   1316 |   \bl{$A \,@\, \{\} = \;?$}
 | 
|  |   1317 |   \end{center}  
 | 
|  |   1318 |     
 | 
|  |   1319 |   \end{frame}
 | 
|  |   1320 |   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |   1321 |   
 | 
|  |   1322 | 
 | 
|  |   1323 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1324 | \begin{frame}[c]
 | 
|  |   1325 | \frametitle{The Meaning of a Regex}
 | 
|  |   1326 | 
 | 
|  |   1327 |  ...all the strings a regular expression can match.   
 | 
|  |   1328 | 
 | 
|  |   1329 | \begin{center}
 | 
|  |   1330 |  \begin{tabular}{rcl}
 | 
|  |   1331 |  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
|  |   1332 |  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1333 |  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
|  |   1334 |  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
|  |   1335 |  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
 | 
|  |   1336 |  \bl{$L(r^*)$}           & \bl{$\dn$} & \\
 | 
|  |   1337 |   \end{tabular}
 | 
|  |   1338 | \end{center}
 | 
|  |   1339 | 
 | 
|  |   1340 | \begin{textblock}{14}(1.5,13.5)\small
 | 
|  |   1341 | \bl{$L$} is a function from regular expressions to 
 | 
|  |   1342 | sets of strings (languages):\smallskip\\
 | 
|  |   1343 | \bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
 | 
|  |   1344 | \end{textblock}
 | 
|  |   1345 | 
 | 
|  |   1346 | \end{frame}
 | 
|  |   1347 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1348 | 
 | 
|  |   1349 | 
 | 
|  |   1350 | 
 | 
|  |   1351 | 
 | 
|  |   1352 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1353 | \begin{frame}[c]
 | 
|  |   1354 |   \frametitle{The Power Operation}
 | 
|  |   1355 |   
 | 
|  |   1356 |   \begin{itemize}
 | 
|  |   1357 |   \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | 
|  |   1358 |   
 | 
|  |   1359 |   \begin{center}
 | 
|  |   1360 |   \begin{tabular}{lcl}
 | 
|  |   1361 |   \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1362 |   \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | 
|  |   1363 |   \end{tabular}
 | 
|  |   1364 |   \end{center}\bigskip
 | 
|  |   1365 |   
 | 
|  |   1366 |   \item[] For example
 | 
|  |   1367 |   
 | 
|  |   1368 |   \begin{center}
 | 
|  |   1369 |   \begin{tabular}{lcl@{\hspace{10mm}}l}
 | 
|  |   1370 |   \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | 
|  |   1371 |   \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | 
|  |   1372 |   \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | 
|  |   1373 |   \end{tabular}
 | 
|  |   1374 |   \end{center}
 | 
|  |   1375 |   
 | 
|  |   1376 |   \end{itemize}  
 | 
|  |   1377 |   
 | 
|  |   1378 |   \end{frame}
 | 
|  |   1379 |   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1380 |   
 | 
|  |   1381 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1382 | \begin{frame}[c]
 | 
|  |   1383 | \frametitle{The Meaning of a Regex}
 | 
|  |   1384 | 
 | 
|  |   1385 | \begin{textblock}{15}(1,4)
 | 
|  |   1386 |  \begin{tabular}{rcl}
 | 
|  |   1387 |  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
|  |   1388 |  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1389 |  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
|  |   1390 |  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
|  |   1391 |  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
 | 
|  |   1392 |  \bl{$L(r^*)$}           & \bl{$\dn$} & \onslide<2->{\bl{$\bigcup_{0 \le n} L(r)^n$}}\\
 | 
|  |   1393 |   \end{tabular}\bigskip
 | 
|  |   1394 |   
 | 
|  |   1395 | %\onslide<2->{
 | 
|  |   1396 | %\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\
 | 
|  |   1397 | %\bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\
 | 
|  |   1398 | %\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}}
 | 
|  |   1399 | %}  
 | 
|  |   1400 | \end{textblock}
 | 
|  |   1401 | 
 | 
|  |   1402 | \end{frame}
 | 
|  |   1403 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1404 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1405 | \begin{frame}[c]
 | 
|  |   1406 |   \frametitle{The Star Operation}
 | 
|  |   1407 |   
 | 
|  |   1408 |   \begin{itemize}
 | 
|  |   1409 |   \item The \alert{\bf Kleene Star} of a \underline{language}:
 | 
|  |   1410 |   \bigskip
 | 
|  |   1411 |   
 | 
|  |   1412 |   \begin{center}
 | 
|  |   1413 |   \begin{tabular}{c}
 | 
|  |   1414 |   \bl{$A\star \dn \bigcup_{0\le n} A^n$}
 | 
|  |   1415 |   \end{tabular}
 | 
|  |   1416 |   \end{center}\bigskip
 | 
|  |   1417 |   
 | 
|  |   1418 |   \item[] This expands to 
 | 
|  |   1419 |   
 | 
|  |   1420 |   \[
 | 
|  |   1421 |   \bl{A^0 \cup A^1 \cup A^2 \cup A^3 \cup A^4 \cup \ldots}
 | 
|  |   1422 |   \]
 | 
|  |   1423 |   
 | 
|  |   1424 |   or
 | 
|  |   1425 |   
 | 
|  |   1426 |   \small
 | 
|  |   1427 |   \[
 | 
|  |   1428 |   \bl{\{[]\} \;\cup\; A \;\cup\; A\,@\,A \;\cup\; 
 | 
|  |   1429 |     A\,@\,A\,@\,A \;\cup\; A\,@\,A\,@\,A\,@\,A \cup \ldots}
 | 
|  |   1430 |   \]
 | 
|  |   1431 |   
 | 
|  |   1432 |   \end{itemize}  
 | 
|  |   1433 |   
 | 
|  |   1434 |   \end{frame}
 | 
|  |   1435 |   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1436 | 
 | 
|  |   1437 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1438 | \begin{frame}[c]
 | 
|  |   1439 | \frametitle{The Meaning of a Regex}
 | 
|  |   1440 | 
 | 
|  |   1441 | \begin{textblock}{15}(1,4)
 | 
|  |   1442 |  \begin{tabular}{rcl}
 | 
|  |   1443 |  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
|  |   1444 |  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1445 |  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
|  |   1446 |  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
|  |   1447 |  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\
 | 
|  |   1448 |  \bl{$L(r^*)$}           & \bl{$\dn$} & \bl{$(L(r))\star$}\\
 | 
|  |   1449 |   \end{tabular}
 | 
|  |   1450 |   
 | 
|  |   1451 | \end{textblock}
 | 
|  |   1452 | 
 | 
|  |   1453 | \end{frame}
 | 
|  |   1454 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1455 | 
 | 
|  |   1456 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1457 | \begin{frame}[c]
 | 
|  |   1458 | \frametitle{The Meaning of Matching}
 | 
|  |   1459 | 
 | 
|  |   1460 | \begin{bubble}[10cm]
 | 
|  |   1461 | \large\bf 
 | 
|  |   1462 | A regular expression \bl{$r$} matches a string~\bl{$s$} 
 | 
|  |   1463 | provided
 | 
|  |   1464 | 
 | 
|  |   1465 | \begin{center}
 | 
|  |   1466 | \bl{$s \in L(r)$}\\ 
 | 
|  |   1467 | \end{center}
 | 
|  |   1468 | \end{bubble}\bigskip\bigskip
 | 
|  |   1469 | 
 | 
|  |   1470 | \ldots and the point of the next lecture is 
 | 
|  |   1471 | to decide this problem as fast as possible (unlike Python,
 | 
|  |   1472 | Ruby, Java)
 | 
|  |   1473 | 
 | 
|  |   1474 | \end{frame}
 | 
| 879 |   1475 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1476 | 
 | 
|  |   1477 | 
 | 
| 876 |   1478 | 
 | 
|  |   1479 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1480 | \begin{frame}[c]
 | 
|  |   1481 |   \frametitle{Questions}
 | 
|  |   1482 |   
 | 
|  |   1483 |   \begin{itemize}
 | 
|  |   1484 |   \item Say \bl{$A = \{[a],[b],[c],[d]\}$}.\bigskip
 | 
|  |   1485 |   
 | 
|  |   1486 |   \item[]
 | 
|  |   1487 |   How many strings are in \bl{$A^4$}\,?
 | 
|  |   1488 |   \bigskip\medskip\pause
 | 
|  |   1489 |   
 | 
|  |   1490 |   
 | 
|  |   1491 |  \item[]
 | 
|  |   1492 |   What if \bl{$A = \{[a],[b],[c],[]\}$};\\ 
 | 
|  |   1493 |   how many strings are then in \bl{$A^4$}\,?
 | 
|  |   1494 |   \end{itemize}  
 | 
|  |   1495 |   
 | 
|  |   1496 | \end{frame}
 | 
|  |   1497 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |   1498 | 
 | 
|  |   1499 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 879 |   1500 | \begin{frame}[c]
 | 
|  |   1501 |   \frametitle{Questions}
 | 
|  |   1502 | 
 | 
|  |   1503 |   \begin{itemize}
 | 
|  |   1504 |   \item Assume a set $A$ contains 4 strings and a set $B$
 | 
|  |   1505 |   contains 7 strings. None of the strings is the empty
 | 
|  |   1506 |   string.
 | 
|  |   1507 | 
 | 
|  |   1508 |   \item How many strings are in $A \,@\, B$?
 | 
|  |   1509 |   \end{itemize}
 | 
|  |   1510 | 
 | 
|  |   1511 |   
 | 
|  |   1512 | \end{frame}
 | 
|  |   1513 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |   1514 | 
 | 
|  |   1515 | 
 | 
|  |   1516 | 
 | 
|  |   1517 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
| 876 |   1518 | % \begin{frame}[c]
 | 
|  |   1519 | % \frametitle{Languages (Sets of Strings)}
 | 
|  |   1520 | 
 | 
|  |   1521 | % \begin{itemize}
 | 
|  |   1522 | 
 | 
|  |   1523 | % \item A \alert{\bf Language} is a set of strings, for example\medskip
 | 
|  |   1524 | % \begin{center}
 | 
|  |   1525 | % \bl{$\{[], hello, foobar, a, abc\}$}
 | 
|  |   1526 | % \end{center}\bigskip
 | 
|  |   1527 | 
 | 
|  |   1528 | % \item \alert{\bf Concatenation} for strings and languages
 | 
|  |   1529 | 
 | 
|  |   1530 | % \begin{center}
 | 
|  |   1531 | % \begin{tabular}{rcl}
 | 
|  |   1532 | % \bl{$foo\;@\;bar$} & \bl{$=$} & \bl{$foobar$}\medskip\\
 | 
|  |   1533 | % \bl{$A\;@\;B$}     & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$}
 | 
|  |   1534 | % \end{tabular}
 | 
|  |   1535 | % \end{center}
 | 
|  |   1536 | % \bigskip
 | 
|  |   1537 | 
 | 
|  |   1538 | % \small
 | 
|  |   1539 | % \item [] For example \bl{$A = \{foo, bar\}$}, \bl{$B = \{a, b\}$}
 | 
|  |   1540 | 
 | 
|  |   1541 | % \[
 | 
|  |   1542 | % \bl{A \,@\, B = \{fooa, foob, bara, barb\}}
 | 
|  |   1543 | % \]
 | 
|  |   1544 | 
 | 
|  |   1545 | 
 | 
|  |   1546 | 
 | 
|  |   1547 | 
 | 
|  |   1548 | % \end{itemize}  
 | 
|  |   1549 | % \end{frame}
 | 
|  |   1550 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1551 | 
 | 
|  |   1552 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1553 | % \begin{frame}[c]
 | 
|  |   1554 | %   \frametitle{Two Corner Cases}
 | 
|  |   1555 |    
 | 
|  |   1556 | %   \Large
 | 
|  |   1557 | %   \begin{center}
 | 
|  |   1558 | %   \bl{$A \,@\, \{[]\} = \;?$}\bigskip\bigskip\pause\\
 | 
|  |   1559 | %   \bl{$A \,@\, \{\} = \;?$}
 | 
|  |   1560 | %   \end{center}  
 | 
|  |   1561 |     
 | 
|  |   1562 | %   \end{frame}
 | 
|  |   1563 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 | 
|  |   1564 |   
 | 
|  |   1565 | 
 | 
|  |   1566 | 
 | 
|  |   1567 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1568 | % \begin{frame}[c]
 | 
|  |   1569 | % \frametitle{The Meaning of a Regex}
 | 
|  |   1570 | 
 | 
|  |   1571 | %  ...all the strings a regular expression can match.   
 | 
|  |   1572 | 
 | 
|  |   1573 | % \begin{center}
 | 
|  |   1574 | %  \begin{tabular}{rcl}
 | 
|  |   1575 | %  \bl{$L(\ZERO)$}  & \bl{$\dn$} & \bl{$\{\}$}\\
 | 
|  |   1576 | %  \bl{$L(\ONE)$}     & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1577 | %  \bl{$L(c)$}            & \bl{$\dn$} & \bl{$\{[c]\}$}\\
 | 
|  |   1578 | %  \bl{$L(r_1 + r_2)$}    & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\
 | 
|  |   1579 | %  \bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \,@\, L(r_2)$}\\
 | 
|  |   1580 | %  \bl{$L(r^*)$}           & \bl{$\dn$} & \\
 | 
|  |   1581 | %   \end{tabular}
 | 
|  |   1582 | % \end{center}
 | 
|  |   1583 | 
 | 
|  |   1584 | % \begin{textblock}{14}(1.5,13.5)\small
 | 
|  |   1585 | % \bl{$L$} is a function from regular expressions to 
 | 
|  |   1586 | % sets of strings (languages):\smallskip\\
 | 
|  |   1587 | % \bl{\quad$L$ : Rexp $\Rightarrow$ Set$[$String$]$}
 | 
|  |   1588 | % \end{textblock}
 | 
|  |   1589 | 
 | 
|  |   1590 | % \end{frame}
 | 
|  |   1591 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1592 | 
 | 
|  |   1593 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1594 | % \begin{frame}[c]
 | 
|  |   1595 | % \frametitle{The Power Operation}
 | 
|  |   1596 | 
 | 
|  |   1597 | % \begin{itemize}
 | 
|  |   1598 | % \item The \alert{\textbf{\boldmath$n$th Power}} of a language:
 | 
|  |   1599 | 
 | 
|  |   1600 | % \begin{center}
 | 
|  |   1601 | % \begin{tabular}{lcl}
 | 
|  |   1602 | % \bl{$A^0$}    & \bl{$\dn$} & \bl{$\{[]\}$}\\
 | 
|  |   1603 | % \bl{$A^{n+1}$} & \bl{$\dn$} & \bl{$A \,@\, A^n$}
 | 
|  |   1604 | % \end{tabular}
 | 
|  |   1605 | % \end{center}\bigskip
 | 
|  |   1606 | 
 | 
|  |   1607 | % \item[] For example
 | 
|  |   1608 | 
 | 
|  |   1609 | % \begin{center}
 | 
|  |   1610 | % \begin{tabular}{lcl@{\hspace{10mm}}l}
 | 
|  |   1611 | % \bl{$A^4$} & \bl{$=$} & \bl{$A \,@\, A \,@\, A \,@\, A$} & \bl{$(@\,\{[]\})$}\\
 | 
|  |   1612 | % \bl{$A^1$} & \bl{$=$} & \bl{$A$} & \bl{$(@\,\{[]\})$}\\
 | 
|  |   1613 | % \bl{$A^0$} & \bl{$=$} & \bl{$\{[]\}$}\\
 | 
|  |   1614 | % \end{tabular}
 | 
|  |   1615 | % \end{center}
 | 
|  |   1616 | 
 | 
|  |   1617 | % \end{itemize}  
 | 
|  |   1618 | 
 | 
|  |   1619 | % \end{frame}
 | 
|  |   1620 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 | 
|  |   1621 | 
 | 
|  |   1622 | 
 | 
|  |   1623 | 
 | 
|  |   1624 | 
 | 
|  |   1625 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1626 | % \begin{frame}[c]
 | 
|  |   1627 | % \frametitle{Written Exam}
 | 
|  |   1628 | 
 | 
|  |   1629 | % \begin{itemize}
 | 
|  |   1630 | % \item Accounts for 80\%.\bigskip
 | 
|  |   1631 | 
 | 
|  |   1632 | % \item The question ``\textit{Is this relevant for
 | 
|  |   1633 | %       the exam?}'' is very demotivating for the lecturer!\bigskip\\
 | 
|  |   1634 | 
 | 
|  |   1635 | % \item Deal: Whatever is in the homework (and is not marked
 | 
|  |   1636 | %       ``\textit{optional}'') is relevant for the exam.\bigskip
 | 
|  |   1637 |       
 | 
|  |   1638 | % \item Each lecture has also a handout. There are also handouts about
 | 
|  |   1639 | % notation and Scala.      
 | 
|  |   1640 | % \end{itemize}
 | 
|  |   1641 | 
 | 
|  |   1642 | % \end{frame}
 | 
|  |   1643 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1644 | 
 | 
|  |   1645 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1646 | % \begin{frame}[t]
 | 
|  |   1647 | % \frametitle{Coursework}
 | 
|  |   1648 | 
 | 
|  |   1649 | % \begin{itemize}
 | 
|  |   1650 | % \item Accounts for 20\%. Two strands. Choose \alert{\bf one}!\bigskip
 | 
|  |   1651 | % \end{itemize}
 | 
|  |   1652 | 
 | 
|  |   1653 | % \begin{columns}[t]
 | 
|  |   1654 | % \begin{column}{.5\textwidth}
 | 
|  |   1655 | % \underline{\bf Strand 1}\medskip
 | 
|  |   1656 | % \begin{itemize}
 | 
|  |   1657 | % \item 4 programming tasks:
 | 
|  |   1658 | % \begin{itemize}
 | 
|  |   1659 | % \item matcher (4\%, 11.10.) 
 | 
|  |   1660 | % \item lexer (5\%, 04.11.)
 | 
|  |   1661 | % \item parser (5\%, 22.11.)
 | 
|  |   1662 | % \item compiler (6\%, 13.12.)
 | 
|  |   1663 | % \end{itemize}
 | 
|  |   1664 | % \item in any lang.~you like,\\ but I want to see the\\ code
 | 
|  |   1665 | % \end{itemize}
 | 
|  |   1666 | % \end{column}
 | 
|  |   1667 | 
 | 
|  |   1668 | % \hspace{-45pt}\vrule{}\hspace{10pt}
 | 
|  |   1669 | % \begin{column}{.5\textwidth}
 | 
|  |   1670 | % \underline{\bf Strand 2}\smallskip\begin{itemize}
 | 
|  |   1671 | % \item one task: prove the correctness of a regular expression matcher in 
 | 
|  |   1672 | % the \underline{Isabelle} theorem prover
 | 
|  |   1673 | % \item 20\%, submission on~13.12.\hspace{-5mm}\mbox{}
 | 
|  |   1674 | % \end{itemize}
 | 
|  |   1675 | % \end{column}
 | 
|  |   1676 | % \end{columns}\medskip
 | 
|  |   1677 | 
 | 
|  |   1678 | % \small
 | 
|  |   1679 | % \begin{itemize}
 | 
|  |   1680 | % \item Solving more than one strand will {\bf not} give you more 
 | 
|  |   1681 | % marks.
 | 
|  |   1682 | 
 | 
|  |   1683 | % \end{itemize}
 | 
|  |   1684 | 
 | 
|  |   1685 | % \end{frame}
 | 
|  |   1686 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1687 | 
 | 
|  |   1688 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1689 | %\begin{frame}[c]
 | 
|  |   1690 | %\frametitle{Lecture Capture}
 | 
|  |   1691 | %
 | 
|  |   1692 | %\begin{itemize}
 | 
|  |   1693 | %\item Hope it works\ldots\pause actually no, it does not!\medskip\pause
 | 
|  |   1694 | %\item It is important to use lecture capture wisely\\ (it is only the ``baseline''):
 | 
|  |   1695 | %\begin{itemize}  
 | 
|  |   1696 | %\item Lecture recordings are a study and revision aid.
 | 
|  |   1697 | %\item Statistically, there is a clear and direct link between attendance and
 | 
|  |   1698 | %  attainment: students who do not attend lectures, do less well in exams.
 | 
|  |   1699 | %\end{itemize}
 | 
|  |   1700 | %
 | 
|  |   1701 | %\item Attending a lecture is more than watching it online -- if you do not
 | 
|  |   1702 | %attend, you miss out!  
 | 
|  |   1703 | %  
 | 
|  |   1704 | %\end{itemize}
 | 
|  |   1705 | %
 | 
|  |   1706 | %\end{frame}
 | 
|  |   1707 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1708 | 
 | 
|  |   1709 | 
 | 
|  |   1710 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1711 | \begin{frame}[c]
 | 
| 928 |   1712 | \frametitle{\begin{tabular}{c}\\[1cm]\alert{Questions?}\end{tabular}}
 | 
| 876 |   1713 | 
 | 
|  |   1714 | 
 | 
|  |   1715 | \begin{tabular}{lll}
 | 
| 921 |   1716 |   SGT TAs: & Flavio Melinte Citea & (was a KURF last summer)\\
 | 
|  |   1717 |            & Krishi Wali \\
 | 
|  |   1718 |            & Meilai Ji \medskip\\
 | 
| 928 |   1719 |   Amm Helpers & Harry Dilnot & (harry.dilnot@kcl.ac.uk)\\
 | 
|  |   1720 |               & Meilai Ji & (meilai.ji@kcl.ac.uk)\medskip\\
 | 
| 876 |   1721 | \end{tabular}  
 | 
|  |   1722 | \mbox{}
 | 
|  |   1723 | \end{frame}
 | 
|  |   1724 | 
 | 
|  |   1725 | \begin{frame}[c]
 | 
|  |   1726 | \end{frame}
 | 
|  |   1727 | 
 | 
|  |   1728 | \begin{frame}[c]
 | 
|  |   1729 | \end{frame}
 | 
|  |   1730 | 
 | 
|  |   1731 | \begin{frame}[c]
 | 
|  |   1732 | \end{frame}
 | 
|  |   1733 | 
 | 
|  |   1734 | \begin{frame}[c]
 | 
|  |   1735 | \end{frame}
 | 
|  |   1736 | 
 | 
|  |   1737 | \begin{frame}[c]
 | 
|  |   1738 | \end{frame}
 | 
|  |   1739 | 
 | 
|  |   1740 | \begin{frame}[c]
 | 
|  |   1741 | \end{frame}
 | 
|  |   1742 | 
 | 
|  |   1743 | \begin{frame}[c]
 | 
|  |   1744 | \end{frame}
 | 
|  |   1745 | 
 | 
|  |   1746 | \begin{frame}[c]
 | 
|  |   1747 | \end{frame}
 | 
|  |   1748 | 
 | 
|  |   1749 | \begin{frame}[c]
 | 
|  |   1750 | \end{frame}
 | 
|  |   1751 | 
 | 
|  |   1752 | \begin{frame}[c]
 | 
|  |   1753 | \end{frame}
 | 
|  |   1754 | 
 | 
|  |   1755 | \begin{frame}[c]
 | 
|  |   1756 | \end{frame}
 | 
|  |   1757 | 
 | 
|  |   1758 | \begin{frame}[c]
 | 
|  |   1759 | \end{frame}
 | 
|  |   1760 | 
 | 
|  |   1761 | \begin{frame}[c]
 | 
|  |   1762 | \end{frame}
 | 
|  |   1763 | 
 | 
|  |   1764 | \begin{frame}[c]
 | 
|  |   1765 | \end{frame}
 | 
|  |   1766 | 
 | 
|  |   1767 | 
 | 
|  |   1768 | \begin{frame}[c]
 | 
|  |   1769 | \begin{mybox3}{Coursework}
 | 
|  |   1770 |   Do we need to provide instructions on running the coursework files
 | 
|  |   1771 |   if we're using languages other than Scala? Thanks
 | 
|  |   1772 | \end{mybox3}\pause
 | 
|  |   1773 | 
 | 
|  |   1774 | \begin{mybox2}{Zip-File for Coursework}
 | 
|  |   1775 |   Please, please submit a zipfile that generates a subdirectory
 | 
|  |   1776 |   \begin{center}
 | 
|  |   1777 |   \texttt{NameFamilyName}  
 | 
|  |   1778 |   \end{center}  
 | 
|  |   1779 | \end{mybox2}
 | 
|  |   1780 | \end{frame}
 | 
|  |   1781 | 
 | 
|  |   1782 | 
 | 
|  |   1783 | \begin{frame}[c]
 | 
|  |   1784 | \begin{mybox3}{What is the trick?}\small
 | 
|  |   1785 |   What was the trick to improve the evil regular expressions matcher
 | 
|  |   1786 |   to have such good results compared to other programming languages?
 | 
|  |   1787 |   Is it working better on casual regular expressions (the ones that
 | 
|  |   1788 |   Python and Java handle pretty well), too? Or was it just optimised
 | 
|  |   1789 |   for these evil ones?
 | 
|  |   1790 | \end{mybox3}
 | 
|  |   1791 | \end{frame}
 | 
|  |   1792 | 
 | 
|  |   1793 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1794 | \begin{frame}[c]
 | 
|  |   1795 |   \frametitle{Thanks to Martin Mikusovic}
 | 
|  |   1796 | 
 | 
|  |   1797 | \bigskip    
 | 
|  |   1798 | \begin{center}
 | 
|  |   1799 | \begin{tikzpicture}
 | 
|  |   1800 |   \begin{axis}[
 | 
|  |   1801 |     xlabel={$n$},
 | 
|  |   1802 |     x label style={at={(1.05,0.0)}},
 | 
|  |   1803 |     ylabel={time in secs},
 | 
|  |   1804 |     enlargelimits=false,
 | 
|  |   1805 |     xtick={0,5,...,30},
 | 
|  |   1806 |     xmax=33,
 | 
|  |   1807 |     ymax=35,
 | 
|  |   1808 |     ytick={0,10,...,30},
 | 
|  |   1809 |     scaled ticks=false,
 | 
|  |   1810 |     axis lines=left,
 | 
|  |   1811 |     width=9cm,
 | 
|  |   1812 |     height=5.5cm, 
 | 
|  |   1813 |     legend entries={Java 8, Python, JavaScript, Swift},  
 | 
|  |   1814 |     legend pos=north west,
 | 
|  |   1815 |     legend cell align=left]
 | 
|  |   1816 | \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};
 | 
|  |   1817 | \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
 | 
|  |   1818 | \addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
 | 
|  |   1819 | \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
 | 
|  |   1820 | \end{axis}
 | 
|  |   1821 | \end{tikzpicture}
 | 
|  |   1822 | \end{center}
 | 
|  |   1823 | 
 | 
|  |   1824 | Regex: \bl{$(a^*)^* \cdot b$}
 | 
|  |   1825 | 
 | 
|  |   1826 | Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
 | 
|  |   1827 | 
 | 
|  |   1828 | \end{frame}
 | 
|  |   1829 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1830 | 
 | 
|  |   1831 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1832 | \begin{frame}[c]
 | 
|  |   1833 | \frametitle{Same Example in Java 9+}
 | 
|  |   1834 | 
 | 
|  |   1835 | \begin{center}
 | 
|  |   1836 | \begin{tikzpicture}
 | 
|  |   1837 |   \begin{axis}[
 | 
|  |   1838 |     xlabel={$n$},
 | 
|  |   1839 |     x label style={at={(1.09,-0.15)}},
 | 
|  |   1840 |     ylabel={time in secs},
 | 
|  |   1841 |     scaled x ticks=false,
 | 
|  |   1842 |     enlargelimits=false,
 | 
|  |   1843 |     xtick distance=10000,
 | 
|  |   1844 |     xmax=44000, 
 | 
|  |   1845 |     ytick={0,10,...,30}, 
 | 
|  |   1846 |     ymax=35, 
 | 
|  |   1847 |     axis lines=left,
 | 
|  |   1848 |     width=9cm,
 | 
|  |   1849 |     height=5cm, 
 | 
|  |   1850 |     legend entries={Java \liningnums{9}+},
 | 
|  |   1851 |     legend pos=north west,
 | 
|  |   1852 |     legend cell align=left]
 | 
|  |   1853 | \addplot[blue,mark=square*,mark options={fill=white}] table {re-java9.data};
 | 
|  |   1854 | \end{axis}
 | 
|  |   1855 | \end{tikzpicture}
 | 
|  |   1856 | \end{center}
 | 
|  |   1857 | 
 | 
|  |   1858 | Regex: \bl{$(a^*)^* \cdot b$}
 | 
|  |   1859 | 
 | 
|  |   1860 | Strings of the form \bl{$\underbrace{\,a\ldots a\,}_{n}$}
 | 
|  |   1861 | 
 | 
|  |   1862 | \end{frame}
 | 
|  |   1863 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1864 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1865 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 | 
|  |   1866 | % Questions
 | 
|  |   1867 | 
 | 
|  |   1868 | 
 | 
|  |   1869 | 
 | 
|  |   1870 | 
 | 
|  |   1871 | \begin{frame}[c]
 | 
|  |   1872 | \end{frame}
 | 
|  |   1873 | 
 | 
|  |   1874 | \begin{frame}[c]
 | 
|  |   1875 | \end{frame}
 | 
|  |   1876 | 
 | 
|  |   1877 | \begin{frame}[c]
 | 
|  |   1878 | \end{frame}
 | 
|  |   1879 | 
 | 
|  |   1880 | \begin{frame}[c]
 | 
|  |   1881 | \end{frame}
 | 
|  |   1882 | 
 | 
| 879 |   1883 | \begin{frame}[c]
 | 
| 876 |   1884 | 
 | 
|  |   1885 | \end{frame}
 | 
|  |   1886 | 
 | 
|  |   1887 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 | 
|  |   1888 | \end{document}
 | 
|  |   1889 | 
 | 
|  |   1890 | %%% Local Variables:  
 | 
|  |   1891 | %%% mode: latex
 | 
|  |   1892 | %%% TeX-master: t
 | 
|  |   1893 | %%% End: 
 | 
|  |   1894 | 
 |